You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: update README and code to reflect flag terminology changes
- Replaced instances of `getFeature` with `getFlag` in the README and example files to align with the new flag-based approach.
- Updated the `Feedback` component to reference `ExampleFlag` instead of `ExampleFeature`.
- Adjusted the `ReflagClient` class to ensure consistent usage of `flagKey` in feedback requests and related methods.
- Enhanced documentation to clarify the transition from features to flags, including migration instructions for users moving from the Bucket SDK to the Reflag SDK.
// `track` just calls `reflagClient.track(<flagKey>)` to send an event using the same flag key
@@ -102,7 +114,7 @@ type Configuration = {
102
114
sseBaseUrl?:"https://livemessaging.bucket.co";
103
115
feedback?:undefined; // See FEEDBACK.md
104
116
enableTracking?:true; // set to `false` to stop sending track events and user/company updates to Reflag servers. Useful when you're impersonating a user
105
-
fallbackFeatures?:
117
+
fallbackFlags?:
106
118
|string[]
107
119
|Record<string, { key:string; payload:any } |true>; // Enable these flags if unable to contact reflag.com. Can be a list of flag keys or a record with configuration values
108
120
timeoutMs?:number; // Timeout for fetching flags (default: 5000ms)
@@ -113,7 +125,7 @@ type Configuration = {
113
125
};
114
126
```
115
127
116
-
## Feature toggles
128
+
## Flag targeting
117
129
118
130
Reflag determines which flags are active for a given user/company. The user/company is given in the `ReflagClient` constructor.
119
131
@@ -144,64 +156,28 @@ const reflagClient = new ReflagClient({
144
156
});
145
157
```
146
158
147
-
To retrieve flags along with their targeting information, use `getFeature(flagKey: string)`:
159
+
To retrieve the value of a flag use `getFlag(flagKey: string)`:
`key` is mandatory for a config, but if a flag has no config or no config value was matched against the context, the `key` will be `undefined`. Make sure to check against this case when trying to use the configuration in your application. `payload` is an optional JSON value for arbitrary configuration needs.
201
-
202
-
Just as `isEnabled`, accessing `config` on the object returned by `getFeatures` does not automatically
203
-
generate a `check` event, contrary to the `config` property on the object returned by `getFeature`.
204
-
205
181
## Updating user/company/other context
206
182
207
183
Attributes given for the user/company/other context in the `ReflagClient` constructor can be updated for use in flag targeting evaluation with the `updateUser()`, `updateCompany()` and `updateOtherContext()` methods.
@@ -211,7 +187,8 @@ The following shows how to let users self-opt-in for a new flag. The flag must h
Event listeners allow for capturing various events occurring in the `ReflagClient`. This is useful to build integrations with other system or for various debugging purposes. There are 5 kinds of events:
311
288
312
289
-`check`: Your code used `isEnabled` or `config` for a flag
313
-
-`flagsUpdated`: Features were updated. Either because they were loaded as part of initialization or because the user/company updated
290
+
-`flagsUpdated`: Flags were updated. Either because they were loaded as part of initialization or because the user/company updated
314
291
-`user`: User information updated (similar to the `identify` call used in tracking terminology)
315
292
-`company`: Company information updated (sometimes to the `group` call used in tracking terminology)
316
293
-`track`: Track event occurred.
317
294
318
295
Use the `on()` method to add an event listener to respond to certain events. See the API reference for details on each hook.
-`reflag-prompt-${userId}`: store the last automated feedback prompt message ID received to avoid repeating surveys
356
333
-`reflag-token-${userId}`: caching a token used to connect to Reflag's live messaging infrastructure that is used to deliver automated feedback surveys in real time.
357
334
358
-
## Upgrading to 3.0 from 2.x
359
-
360
-
Breaking changes:
361
-
362
-
-`client.onFeaturesUpdated()` is now replaced by [event listeners](#event-listeners)
363
-
- Arguments to the `ReflagClient` constructor which were previously under `flagOptions` are now supplied directly in the root.
364
-
365
335
## TypeScript
366
336
367
337
Types are bundled together with the library and exposed automatically when importing through a package manager.
@@ -382,6 +352,59 @@ If you are including the Reflag tracking SDK with a `<script>`-tag from `jsdeliv
0 commit comments