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
Copy file name to clipboardExpand all lines: packages/react/README.md
+25-3
Original file line number
Diff line number
Diff line change
@@ -54,6 +54,7 @@ In addition to the feature provided by the [web sdk](https://openfeature.dev/doc
54
54
-[Re-rendering with Context Changes](#re-rendering-with-context-changes)
55
55
-[Re-rendering with Flag Configuration Changes](#re-rendering-with-flag-configuration-changes)
56
56
-[Suspense Support](#suspense-support)
57
+
-[Tracking](#tracking)
57
58
-[Testing](#testing)
58
59
-[FAQ and troubleshooting](#faq-and-troubleshooting)
59
60
-[Resources](#resources)
@@ -132,7 +133,7 @@ function App() {
132
133
133
134
#### Evaluation hooks
134
135
135
-
Within the provider, you can use the various evaluation hooks to evaluate flags.
136
+
Within the provider, you can use the various evaluation hooks to evaluate flags.
136
137
137
138
```tsx
138
139
function Page() {
@@ -236,7 +237,7 @@ Note that if your provider doesn't support updates, this configuration has no im
236
237
237
238
#### Suspense Support
238
239
239
-
> [!NOTE]
240
+
> [!NOTE]
240
241
> React suspense is an experimental feature and subject to change in future versions.
241
242
242
243
@@ -274,11 +275,32 @@ function Fallback() {
274
275
// component to render before READY.
275
276
return <p>Waiting for provider to be ready...</p>;
276
277
}
277
-
278
278
```
279
279
280
280
This can be disabled in the hook options (or in the [OpenFeatureProvider](#openfeatureprovider-context-provider)).
281
281
282
+
#### Tracking
283
+
284
+
The tracking API allows you to use OpenFeature abstractions and objects to associate user actions with feature flag evaluations.
285
+
This is essential for robust experimentation powered by feature flags.
286
+
For example, a flag enhancing the appearance of a UI component might drive user engagement to a new feature; to test this hypothesis, telemetry collected by a [hook](#hooks) or [provider](#providers) can be associated with telemetry reported in the client's `track` function.
287
+
288
+
The React SDK includes a hook for firing tracking events in the <OpenFeatureProvider> context in use:
289
+
290
+
```tsx
291
+
function MyComponent() {
292
+
293
+
// get a tracking function for this <OpenFeatureProvider>.
294
+
const { track } =useTrack();
295
+
296
+
// call the tracking event
297
+
// can be done in render, useEffect, or in handlers, depending on your use case
298
+
track(eventName, trackingDetails);
299
+
300
+
return <>...</>;
301
+
}
302
+
```
303
+
282
304
### Testing
283
305
284
306
The React SDK includes a built-in context provider for testing.
| ✅ |[Providers](#providers)| Integrate with a commercial, open source, or in-house feature management tool. |
100
-
| ✅ |[Targeting](#targeting)| Contextually-aware flag evaluation using [evaluation context](/docs/reference/concepts/evaluation-context). |
101
-
| ✅ |[Hooks](#hooks)| Add functionality to various stages of the flag evaluation life-cycle. |
102
-
| ✅ |[Logging](#logging)| Integrate with popular logging packages. |
103
-
| ✅ |[Domains](#domains)| Logically bind clients with providers. |
104
-
| ✅ |[Eventing](#eventing)| React to state changes in the provider or flag management system. |
105
-
| ✅ |[Shutdown](#shutdown)| Gracefully clean up a provider during application shutdown. |
106
-
| ✅ |[Transaction Context Propagation](#transaction-context-propagation)| Set a specific [evaluation context](/docs/reference/concepts/evaluation-context) for a transaction (e.g. an HTTP request or a thread) |
107
-
| ✅ |[Extending](#extending)| Extend OpenFeature with custom providers and hooks. |
99
+
| ✅ |[Providers](#providers)| Integrate with a commercial, open source, or in-house feature management tool. |
100
+
| ✅ |[Targeting](#targeting)| Contextually-aware flag evaluation using [evaluation context](/docs/reference/concepts/evaluation-context). |
101
+
| ✅ |[Hooks](#hooks)| Add functionality to various stages of the flag evaluation life-cycle. |
102
+
| ✅ |[Logging](#logging)| Integrate with popular logging packages. |
103
+
| ✅ |[Domains](#domains)| Logically bind clients with providers. |
104
+
| ✅ |[Eventing](#eventing)| React to state changes in the provider or flag management system. |
105
+
| ✅ |[Transaction Context Propagation](#transaction-context-propagation)| Set a specific [evaluation context](/docs/reference/concepts/evaluation-context) for a transaction (e.g. an HTTP request or a thread) |
106
+
| ✅ |[Tracking](#tracking)| Associate user actions with feature flag evaluations, particularly for A/B testing. |
107
+
| ✅ |[Shutdown](#shutdown)| Gracefully clean up a provider during application shutdown. |
108
+
| ✅ |[Extending](#extending)| Extend OpenFeature with custom providers and hooks. |
108
109
109
110
<sub>Implemented: ✅ | In-progress: ⚠️ | Not implemented yet: ❌</sub>
The tracking API allows you to use OpenFeature abstractions and objects to associate user actions with feature flag evaluations.
296
+
This is essential for robust experimentation powered by feature flags.
297
+
For example, a flag enhancing the appearance of a UI component might drive user engagement to a new feature; to test this hypothesis, telemetry collected by a [hook](#hooks) or [provider](#providers) can be associated with telemetry reported in the client's `track` function.
The tracking API allows you to use OpenFeature abstractions and objects to associate user actions with feature flag evaluations.
288
+
This is essential for robust experimentation powered by feature flags.
289
+
For example, a flag enhancing the appearance of a UI component might drive user engagement to a new feature; to test this hypothesis, telemetry collected by a [hook](#hooks) or [provider](#providers) can be associated with telemetry reported in the client's `track` function.
290
+
291
+
```ts
292
+
// flag is evaluated
293
+
client.getBooleanValue('new-feature', false);
294
+
295
+
// new feature is used and track function is called recording the usage
296
+
useNewFeature();
297
+
client.track('new-feature-used');
298
+
```
299
+
284
300
### Shutdown
285
301
286
302
The OpenFeature API provides a close function to perform a cleanup of all registered providers.
@@ -339,7 +355,7 @@ class MyProvider implements Provider {
339
355
}
340
356
341
357
// implement with "new OpenFeatureEventEmitter()", and use "emit()" to emit events
0 commit comments