@datadog/mobile-react-native-openfeature 3.6.0 → 3.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +187 -15
  2. package/lib/commonjs/index.js +7 -0
  3. package/lib/commonjs/index.js.map +1 -1
  4. package/lib/commonjs/provider.js +1 -1
  5. package/lib/commonjs/provider.js.map +1 -1
  6. package/lib/commonjs/rumContext.js +44 -0
  7. package/lib/commonjs/rumContext.js.map +1 -0
  8. package/lib/module/index.js +2 -1
  9. package/lib/module/index.js.map +1 -1
  10. package/lib/module/provider.js +1 -1
  11. package/lib/module/provider.js.map +1 -1
  12. package/lib/module/rumContext.js +37 -0
  13. package/lib/module/rumContext.js.map +1 -0
  14. package/lib/typescript/core/src/flags/internal.d.ts.map +1 -1
  15. package/lib/typescript/core/src/flags/rumIntegration.d.ts +14 -0
  16. package/lib/typescript/core/src/flags/rumIntegration.d.ts.map +1 -0
  17. package/lib/typescript/core/src/index.d.ts +2 -1
  18. package/lib/typescript/core/src/index.d.ts.map +1 -1
  19. package/lib/typescript/core/src/version.d.ts +1 -1
  20. package/lib/typescript/react-native-openfeature/src/index.d.ts +4 -2
  21. package/lib/typescript/react-native-openfeature/src/index.d.ts.map +1 -1
  22. package/lib/typescript/react-native-openfeature/src/provider.d.ts.map +1 -1
  23. package/lib/typescript/react-native-openfeature/src/rumContext.d.ts +23 -0
  24. package/lib/typescript/react-native-openfeature/src/rumContext.d.ts.map +1 -0
  25. package/package.json +3 -3
  26. package/src/__tests__/__utils__/rumContext.types.ts +55 -0
  27. package/src/__tests__/__utils__/tsconfig.json +8 -0
  28. package/src/__tests__/provider.test.ts +30 -0
  29. package/src/__tests__/rumContext.compatibility.test.ts +122 -0
  30. package/src/__tests__/rumContext.integration.test.ts +414 -0
  31. package/src/__tests__/rumContext.test.ts +100 -0
  32. package/src/__tests__/rumContext.types.test.ts +27 -0
  33. package/src/index.ts +4 -1
  34. package/src/provider.ts +5 -3
  35. package/src/rumContext.ts +54 -0
package/README.md CHANGED
@@ -29,7 +29,7 @@ yarn add @datadog/mobile-react-native @datadog/mobile-react-native-openfeature @
29
29
  Use the following example code snippet to initialize the Datadog SDK, enable the Feature Flags feature, and set up the OpenFeature provider.
30
30
 
31
31
  ```tsx
32
- import { CoreConfiguration, DatadogProvider, DdFlags } from '@datadog/mobile-react-native';
32
+ import { CoreConfiguration, DatadogProvider, DdFlags, DdSdkReactNative } from '@datadog/mobile-react-native';
33
33
  import { DatadogOpenFeatureProvider } from '@datadog/mobile-react-native-openfeature';
34
34
  import { OpenFeature } from '@openfeature/react-sdk';
35
35
 
@@ -67,31 +67,203 @@ After completing this setup, your app is ready for flag evaluation with OpenFeat
67
67
 
68
68
  > **Note**: Sending flag evaluation data to Datadog is automatically enabled when using the Feature Flags SDK. Provide `rumIntegrationEnabled` and `trackExposures` parameters to the `DdFlags.enable()` call to configure.
69
69
 
70
+ ### RUM user context
71
+
72
+ Use `enrichWithRumUser()` when you explicitly want to use the current RUM user as part of an
73
+ OpenFeature evaluation context. Neither Datadog OpenFeature provider enriches context automatically.
74
+ This keeps context changes visible through OpenFeature and avoids changing flag assignments unless
75
+ your application opts in.
76
+
77
+ The helper maps the RUM user ID to `targetingKey`. It maps `name`, `email`, and flat string, number,
78
+ or boolean `extraInfo` properties to evaluation attributes. Merge precedence is `extraInfo`,
79
+ then the RUM user's own identity fields, then the application context (highest precedence).
80
+ `targetingKey`, `name`, and `email` in `extraInfo` follow the same merge rules as other attributes;
81
+ these keys are not reserved to a particular source. The helper does not apply targeting-key-specific
82
+ validation: numeric or boolean values overwritten later in the merge do not trigger targeting-key
83
+ warnings. The final `targetingKey` must be a string (including an empty string). If a non-string value
84
+ reaches the Datadog Flags context-processing layer, it logs an SDK warning and uses the anonymous subject
85
+ (`''`) for evaluation and tracking, regardless of whether the value came from `extraInfo` or the
86
+ application. It does not fall back to a lower-precedence identity or rewrite OpenFeature's context.
87
+ Application values can therefore supply a different targeting key (for example, a device or session
88
+ ID). When enrichment succeeds, an application field set to `undefined` removes the
89
+ corresponding RUM value and is omitted from the returned context. Null-valued and nested RUM user
90
+ properties are not included. If no RUM user is set, including after `clearUserInfo()`, the helper
91
+ normalizes the application context without adding RUM values or logging a warning. Actual failures
92
+ to read the RUM user still produce an SDK warning.
93
+
94
+ > **Note:** Numeric evaluation attributes currently differ by platform: Android converts them to
95
+ > strings (for example, `42` can become `"42.0"` across the React Native bridge), while iOS preserves
96
+ > numeric values. For consistent cross-platform targeting, explicitly supply consistently formatted
97
+ > strings in the application context, or omit inherited numeric attributes with `undefined`.
98
+
99
+ If the core SDK's `__ddEnrichEvaluationContextWithRumUser` helper is missing or not callable,
100
+ `enrichWithRumUser()` logs a console warning and returns the original application context unchanged,
101
+ including any `undefined` fields.
102
+ OpenFeature initialization and evaluation can continue using the application's context without RUM
103
+ values. Update the core SDK to at least the OpenFeature package's version, check for duplicate
104
+ installs with `npm ls @datadog/mobile-react-native`, and ensure test mocks preserve the real module
105
+ exports (use `@datadog/mobile-react-native/jest` or spread `jest.requireActual`). The warning is
106
+ visible even when SDK verbosity is not configured.
107
+
108
+ Keep the original application-owned context and enrich it before passing it to OpenFeature.
109
+ Use the exported `EnrichableEvaluationContext` type to explicitly type contexts that contain
110
+ `undefined` values; the helper returns an OpenFeature `EvaluationContext`. The following examples
111
+ assume the core Datadog SDK has already been initialized, as shown above. Await `setUserInfo()` before
112
+ enriching: the new RUM user is available only after that promise resolves.
113
+
114
+ ```tsx
115
+ import { DdFlags, DdSdkReactNative } from '@datadog/mobile-react-native';
116
+ import {
117
+ DatadogOpenFeatureProvider,
118
+ enrichWithRumUser
119
+ } from '@datadog/mobile-react-native-openfeature';
120
+ import type { EnrichableEvaluationContext } from '@datadog/mobile-react-native-openfeature';
121
+ import { OpenFeature } from '@openfeature/react-sdk';
122
+
123
+ // Keep the application-owned context; do not replace it with the enriched result.
124
+ const applicationContext: EnrichableEvaluationContext = {
125
+ region: 'us-east-1',
126
+ email: undefined // Omit the RUM email from the evaluation context.
127
+ };
128
+
129
+ const setUpFlags = async (): Promise<void> => {
130
+ await DdFlags.enable();
131
+ await DdSdkReactNative.setUserInfo({
132
+ id: 'user-123',
133
+ email: 'user@example.com',
134
+ extraInfo: { company_name: 'Example, Inc.' }
135
+ });
136
+
137
+ await OpenFeature.setContext(enrichWithRumUser(applicationContext));
138
+ await OpenFeature.setProviderAndWait(new DatadogOpenFeatureProvider());
139
+ };
140
+
141
+ void setUpFlags();
142
+ ```
143
+
144
+ `enrichWithRumUser()` reads the RUM user when it is called; it does not establish a live connection
145
+ between RUM and OpenFeature. After a login or account switch, update the RUM user and enrich the
146
+ original application-owned context again. On logout, await `clearUserInfo()` before enriching;
147
+ `setUserInfo({ id: '' })` is a no-op and does **not** clear the previous user.
148
+
149
+ ```tsx
150
+ import { DdSdkReactNative } from '@datadog/mobile-react-native';
151
+ import { enrichWithRumUser } from '@datadog/mobile-react-native-openfeature';
152
+ import type { EnrichableEvaluationContext } from '@datadog/mobile-react-native-openfeature';
153
+ import { OpenFeature } from '@openfeature/react-sdk';
154
+
155
+ // The same application-owned context as in the setup example.
156
+ const applicationContext: EnrichableEvaluationContext = {
157
+ region: 'us-east-1',
158
+ email: undefined
159
+ };
160
+
161
+ export const onLogin = async (): Promise<void> => {
162
+ await DdSdkReactNative.setUserInfo({
163
+ id: 'user-456',
164
+ email: 'next@example.com'
165
+ });
166
+ await OpenFeature.setContext(enrichWithRumUser(applicationContext));
167
+ };
168
+
169
+ export const onLogout = async (): Promise<void> => {
170
+ await DdSdkReactNative.clearUserInfo();
171
+ // No RUM targeting key remains; the provider uses the anonymous subject ('').
172
+ await OpenFeature.setContext(enrichWithRumUser(applicationContext));
173
+ };
174
+ ```
175
+
176
+ Wire these handlers into your application's authentication flow after flag setup. This logout
177
+ example assumes the application context has no targeting key of its own; explicitly supplied
178
+ application values remain authoritative even after the RUM user is cleared.
179
+
180
+ Do not pass `OpenFeature.getContext()` back to `enrichWithRumUser()`. That context already contains
181
+ values from the previous RUM user, so those values would be treated as application-owned overrides
182
+ and could prevent the new RUM user from replacing them. Retain the original application context
183
+ separately, as shown above.
184
+
185
+ `rumIntegrationEnabled` only controls whether feature flag evaluation events are sent to RUM. It
186
+ does not enable or disable `enrichWithRumUser()`. For the offline provider, continue to follow the
187
+ precomputed configuration context requirements below.
188
+
189
+ #### Isolating RUM context with an OpenFeature domain
190
+
191
+ > **Warning:** The examples above use the global OpenFeature context. A global `setContext()` also
192
+ > reaches domain-bound providers that have no explicit domain context, including other vendors'
193
+ > providers. Use a dedicated domain if RUM user attributes should only reach the Datadog provider.
194
+
195
+ As an alternative to the global setup above, register an explicit context and provider on the same
196
+ domain. Put this setup in `featureFlags.ts`. This example uses the current RUM user; await any
197
+ `setUserInfo()` call first:
198
+
199
+ ```tsx
200
+ import { DdFlags } from '@datadog/mobile-react-native';
201
+ import {
202
+ DatadogOpenFeatureProvider,
203
+ enrichWithRumUser
204
+ } from '@datadog/mobile-react-native-openfeature';
205
+ import { OpenFeature } from '@openfeature/react-sdk';
206
+
207
+ export const DATADOG_DOMAIN = 'datadog';
208
+ // Retain and export the application-owned context, not the enriched result.
209
+ export const applicationContext = { region: 'us-east-1', email: undefined };
210
+
211
+ export const setUpDatadogDomain = async (): Promise<void> => {
212
+ await DdFlags.enable();
213
+ await OpenFeature.setContext(
214
+ DATADOG_DOMAIN,
215
+ enrichWithRumUser(applicationContext)
216
+ );
217
+ await OpenFeature.setProviderAndWait(
218
+ DATADOG_DOMAIN,
219
+ new DatadogOpenFeatureProvider()
220
+ );
221
+ };
222
+
223
+ // In your app bootstrap, await setUpDatadogDomain() after core SDK initialization.
224
+ ```
225
+
226
+ Consumers must use the same domain: import `DATADOG_DOMAIN` from your setup module and use
227
+ `<OpenFeatureProvider domain={DATADOG_DOMAIN}>`, as in the React example below, or use
228
+ `OpenFeature.getClient(DATADOG_DOMAIN)` for a direct client. A client without a domain does not use
229
+ this domain's provider.
230
+
231
+ Pass `DATADOG_DOMAIN` to **every** subsequent context update as well:
232
+ `OpenFeature.setContext(DATADOG_DOMAIN, enrichWithRumUser(applicationContext))`. This includes both
233
+ login and logout handlers above and the `setContext()` call in the React example below. A global
234
+ update does not replace an explicit domain context, so omitting the domain would leave Datadog on
235
+ the previous user's context. On logout, set the re-enriched application context on the domain rather
236
+ than calling `clearContext(DATADOG_DOMAIN)`, which would resume inheriting the global context.
237
+
70
238
  ### Using the OpenFeature React SDK
71
239
 
72
240
  For complete details on using the OpenFeature React SDK, including flag evaluation, evaluation context management, and advanced setup options, see the OpenFeature React SDK [documentation][1].
73
241
 
74
- Short-form OpenFeature SDK usage example:
242
+ This example uses the dedicated Datadog domain and retained application context from
243
+ `featureFlags.ts` above. Await `setUpDatadogDomain()` after core SDK initialization and before
244
+ rendering the app.
245
+ Use domain-scoped login and logout handlers to re-enrich the context when the RUM user changes.
246
+ If you choose the global setup instead, omit the domain argument from context updates and the
247
+ `domain` prop from `OpenFeatureProvider` consistently.
75
248
 
76
249
  ```tsx
250
+ import { useEffect } from 'react';
251
+ import { enrichWithRumUser } from '@datadog/mobile-react-native-openfeature';
77
252
  import { OpenFeature, OpenFeatureProvider, useFlag } from '@openfeature/react-sdk';
253
+ import { applicationContext, DATADOG_DOMAIN } from './featureFlags';
78
254
 
79
255
  function AppWithProviders() {
80
- // For advanced feature flag targeting based on current user or device.
81
256
  useEffect(() => {
82
- const user = { ... }; // Obtained from your authentication logic.
83
-
84
- OpenFeature.setContext({
85
- // User or anonymous ID for consistent feature flag evaluations.
86
- targetingKey: user.id,
87
- // Properties for more granular targeting.
88
- region: user.country
89
- });
90
- }, [])
91
-
92
- // Wrap your app with OpenFeatureProvider to allow flag evaluations throughout the app.
257
+ // Enrich the retained application context, never OpenFeature.getContext().
258
+ void OpenFeature.setContext(
259
+ DATADOG_DOMAIN,
260
+ enrichWithRumUser(applicationContext)
261
+ );
262
+ }, []);
263
+
264
+ // Use the same domain for flag evaluation and context updates.
93
265
  return (
94
- <OpenFeatureProvider>
266
+ <OpenFeatureProvider domain={DATADOG_DOMAIN}>
95
267
  <App />
96
268
  </OpenFeatureProvider>
97
269
  );
@@ -21,7 +21,14 @@ Object.defineProperty(exports, "configurationFromString", {
21
21
  return _mobileReactNative.configurationFromString;
22
22
  }
23
23
  });
24
+ Object.defineProperty(exports, "enrichWithRumUser", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _rumContext.enrichWithRumUser;
28
+ }
29
+ });
24
30
  var _mobileReactNative = require("@datadog/mobile-react-native");
25
31
  var _offlineProvider = require("./offlineProvider");
26
32
  var _provider = require("./provider");
33
+ var _rumContext = require("./rumContext");
27
34
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_mobileReactNative","require","_offlineProvider","_provider"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAMA,IAAAA,kBAAA,GAAAC,OAAA;AAEA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA","ignoreList":[]}
1
+ {"version":3,"names":["_mobileReactNative","require","_offlineProvider","_provider","_rumContext"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,IAAAA,kBAAA,GAAAC,OAAA;AAEA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAEA,IAAAG,WAAA,GAAAH,OAAA","ignoreList":[]}
@@ -30,7 +30,7 @@ class DatadogOpenFeatureProvider extends _coreProvider.DatadogCoreOpenFeaturePro
30
30
  const newDdContext = (0, _mappers.toDdContext)(newContext);
31
31
 
32
32
  // Promise chain in case `onContextChange` is called multiple times.
33
- this.contextChangePromise = this.contextChangePromise.then(() => {
33
+ this.contextChangePromise = this.contextChangePromise.catch(() => undefined).then(() => {
34
34
  return this.flagsClient.setEvaluationContext(newDdContext);
35
35
  });
36
36
 
@@ -1 +1 @@
1
- {"version":3,"names":["_coreProvider","require","_mappers","DatadogOpenFeatureProvider","DatadogCoreOpenFeatureProvider","metadata","name","contextChangePromise","Promise","resolve","initialize","context","ddContext","toDdContext","flagsClient","setEvaluationContext","onContextChange","_oldContext","newContext","newDdContext","then","exports"],"sourceRoot":"../../src","sources":["provider.ts"],"mappings":";;;;;;AAWA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAZA;AACA;AACA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACO,MAAME,0BAA0B,SAASC,4CAA8B,CAAC;EAClEC,QAAQ,GAAqB;IAClCC,IAAI,EAAE;EACV,CAAC;EAEOC,oBAAoB,GAAGC,OAAO,CAACC,OAAO,CAAC,CAAC;EAEhD,MAAMC,UAAUA,CAACC,OAA4B,GAAG,CAAC,CAAC,EAAiB;IAC/D,MAAMC,SAAS,GAAG,IAAAC,oBAAW,EAACF,OAAO,CAAC;IACtC,IAAI,CAACJ,oBAAoB,GAAG,IAAI,CAACO,WAAW,CAACC,oBAAoB,CAC7DH,SACJ,CAAC;IAED,MAAM,IAAI,CAACL,oBAAoB;EACnC;EAEA,MAAMS,eAAeA,CACjBC,WAAgC,EAChCC,UAA+B,EAClB;IACb,MAAMC,YAAY,GAAG,IAAAN,oBAAW,EAACK,UAAU,CAAC;;IAE5C;IACA,IAAI,CAACX,oBAAoB,GAAG,IAAI,CAACA,oBAAoB,CAACa,IAAI,CAAC,MAAM;MAC7D,OAAO,IAAI,CAACN,WAAW,CAACC,oBAAoB,CAACI,YAAY,CAAC;IAC9D,CAAC,CAAC;;IAEF;IACA,MAAM,IAAI,CAACZ,oBAAoB;EACnC;AACJ;AAACc,OAAA,CAAAlB,0BAAA,GAAAA,0BAAA","ignoreList":[]}
1
+ {"version":3,"names":["_coreProvider","require","_mappers","DatadogOpenFeatureProvider","DatadogCoreOpenFeatureProvider","metadata","name","contextChangePromise","Promise","resolve","initialize","context","ddContext","toDdContext","flagsClient","setEvaluationContext","onContextChange","_oldContext","newContext","newDdContext","catch","undefined","then","exports"],"sourceRoot":"../../src","sources":["provider.ts"],"mappings":";;;;;;AAWA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAZA;AACA;AACA;AACA;AACA;;AAYA;AACA;AACA;AACA;AACO,MAAME,0BAA0B,SAASC,4CAA8B,CAAC;EAClEC,QAAQ,GAAqB;IAClCC,IAAI,EAAE;EACV,CAAC;EAEOC,oBAAoB,GAAGC,OAAO,CAACC,OAAO,CAAC,CAAC;EAEhD,MAAMC,UAAUA,CAACC,OAA4B,GAAG,CAAC,CAAC,EAAiB;IAC/D,MAAMC,SAAS,GAAG,IAAAC,oBAAW,EAACF,OAAO,CAAC;IACtC,IAAI,CAACJ,oBAAoB,GAAG,IAAI,CAACO,WAAW,CAACC,oBAAoB,CAC7DH,SACJ,CAAC;IAED,MAAM,IAAI,CAACL,oBAAoB;EACnC;EAEA,MAAMS,eAAeA,CACjBC,WAAgC,EAChCC,UAA+B,EAClB;IACb,MAAMC,YAAY,GAAG,IAAAN,oBAAW,EAACK,UAAU,CAAC;;IAE5C;IACA,IAAI,CAACX,oBAAoB,GAAG,IAAI,CAACA,oBAAoB,CAChDa,KAAK,CAAC,MAAMC,SAAS,CAAC,CACtBC,IAAI,CAAC,MAAM;MACR,OAAO,IAAI,CAACR,WAAW,CAACC,oBAAoB,CAACI,YAAY,CAAC;IAC9D,CAAC,CAAC;;IAEN;IACA,MAAM,IAAI,CAACZ,oBAAoB;EACnC;AACJ;AAACgB,OAAA,CAAApB,0BAAA,GAAAA,0BAAA","ignoreList":[]}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.enrichWithRumUser = void 0;
7
+ var DatadogSdk = _interopRequireWildcard(require("@datadog/mobile-react-native"));
8
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
9
+ /*
10
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
11
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
12
+ * Copyright 2016-Present Datadog, Inc.
13
+ */
14
+
15
+ /**
16
+ * An application context that permits top-level undefined values to remove RUM defaults.
17
+ * Unlike OpenFeature's EvaluationContext, this input can contain these explicit tombstones.
18
+ * If enrichment cannot run, the context is returned unchanged, including undefined values.
19
+ */
20
+
21
+ /**
22
+ * Explicitly add the current RUM user to an OpenFeature evaluation context.
23
+ *
24
+ * The helper reads the RUM user each time it is called and returns a new context; it does not keep
25
+ * the OpenFeature context synchronized when the RUM user changes. The RUM user ID supplies the
26
+ * targeting key, while flat primitive user properties supply attributes. Application fields take
27
+ * precedence, and an explicitly undefined application field removes the corresponding RUM value
28
+ * from the returned context when enrichment succeeds.
29
+ *
30
+ * If the core SDK's enrichment helper is unavailable, logs a warning and returns the application
31
+ * context unchanged so OpenFeature initialization and evaluation can continue without RUM values.
32
+ */
33
+ const enrichWithRumUser = context => {
34
+ const enricher = DatadogSdk.__ddEnrichEvaluationContextWithRumUser;
35
+ if (typeof enricher !== 'function') {
36
+ // InternalLog may also be absent from the core module, or have verbosity disabled.
37
+ // eslint-disable-next-line no-console
38
+ console.warn('DATADOG: `enrichWithRumUser` could not access the core RUM enrichment helper. Returning the application context unchanged. Check SDK compatibility.');
39
+ return context;
40
+ }
41
+ return enricher(context);
42
+ };
43
+ exports.enrichWithRumUser = enrichWithRumUser;
44
+ //# sourceMappingURL=rumContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["DatadogSdk","_interopRequireWildcard","require","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","enrichWithRumUser","context","enricher","__ddEnrichEvaluationContextWithRumUser","console","warn","exports"],"sourceRoot":"../../src","sources":["rumContext.ts"],"mappings":";;;;;;AAMA,IAAAA,UAAA,GAAAC,uBAAA,CAAAC,OAAA;AAA2D,SAAAD,wBAAAE,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAJ,uBAAA,YAAAA,CAAAE,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAN3D;AACA;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMkB,iBAAiB,GAC1BC,OAAoC,IAChB;EACpB,MAAMC,QAAQ,GAAIxB,UAAU,CAEzByB,sCAAsC;EAEzC,IAAI,OAAOD,QAAQ,KAAK,UAAU,EAAE;IAChC;IACA;IACAE,OAAO,CAACC,IAAI,CACR,qJACJ,CAAC;IAED,OAAOJ,OAAO;EAClB;EAEA,OAAOC,QAAQ,CAACD,OAAO,CAAC;AAC5B,CAAC;AAACK,OAAA,CAAAN,iBAAA,GAAAA,iBAAA","ignoreList":[]}
@@ -7,5 +7,6 @@
7
7
  import { configurationFromString } from '@datadog/mobile-react-native';
8
8
  import { DatadogOfflineOpenFeatureProvider } from './offlineProvider';
9
9
  import { DatadogOpenFeatureProvider } from './provider';
10
- export { DatadogOpenFeatureProvider, DatadogOfflineOpenFeatureProvider, configurationFromString };
10
+ import { enrichWithRumUser } from './rumContext';
11
+ export { DatadogOpenFeatureProvider, DatadogOfflineOpenFeatureProvider, enrichWithRumUser, configurationFromString };
11
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["configurationFromString","DatadogOfflineOpenFeatureProvider","DatadogOpenFeatureProvider"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA,SAASA,uBAAuB,QAAQ,8BAA8B;AAEtE,SAASC,iCAAiC,QAAQ,mBAAmB;AACrE,SAASC,0BAA0B,QAAQ,YAAY;AAGvD,SACIA,0BAA0B,EAC1BD,iCAAiC,EACjCD,uBAAuB","ignoreList":[]}
1
+ {"version":3,"names":["configurationFromString","DatadogOfflineOpenFeatureProvider","DatadogOpenFeatureProvider","enrichWithRumUser"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA,SAASA,uBAAuB,QAAQ,8BAA8B;AAEtE,SAASC,iCAAiC,QAAQ,mBAAmB;AACrE,SAASC,0BAA0B,QAAQ,YAAY;AAEvD,SAASC,iBAAiB,QAAQ,cAAc;AAGhD,SACID,0BAA0B,EAC1BD,iCAAiC,EACjCE,iBAAiB,EACjBH,uBAAuB","ignoreList":[]}
@@ -24,7 +24,7 @@ export class DatadogOpenFeatureProvider extends DatadogCoreOpenFeatureProvider {
24
24
  const newDdContext = toDdContext(newContext);
25
25
 
26
26
  // Promise chain in case `onContextChange` is called multiple times.
27
- this.contextChangePromise = this.contextChangePromise.then(() => {
27
+ this.contextChangePromise = this.contextChangePromise.catch(() => undefined).then(() => {
28
28
  return this.flagsClient.setEvaluationContext(newDdContext);
29
29
  });
30
30
 
@@ -1 +1 @@
1
- {"version":3,"names":["DatadogCoreOpenFeatureProvider","toDdContext","DatadogOpenFeatureProvider","metadata","name","contextChangePromise","Promise","resolve","initialize","context","ddContext","flagsClient","setEvaluationContext","onContextChange","_oldContext","newContext","newDdContext","then"],"sourceRoot":"../../src","sources":["provider.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAOA,SAASA,8BAA8B,QAAQ,gBAAgB;AAC/D,SAASC,WAAW,QAAQ,WAAW;AAIvC;AACA;AACA;AACA;AACA,OAAO,MAAMC,0BAA0B,SAASF,8BAA8B,CAAC;EAClEG,QAAQ,GAAqB;IAClCC,IAAI,EAAE;EACV,CAAC;EAEOC,oBAAoB,GAAGC,OAAO,CAACC,OAAO,CAAC,CAAC;EAEhD,MAAMC,UAAUA,CAACC,OAA4B,GAAG,CAAC,CAAC,EAAiB;IAC/D,MAAMC,SAAS,GAAGT,WAAW,CAACQ,OAAO,CAAC;IACtC,IAAI,CAACJ,oBAAoB,GAAG,IAAI,CAACM,WAAW,CAACC,oBAAoB,CAC7DF,SACJ,CAAC;IAED,MAAM,IAAI,CAACL,oBAAoB;EACnC;EAEA,MAAMQ,eAAeA,CACjBC,WAAgC,EAChCC,UAA+B,EAClB;IACb,MAAMC,YAAY,GAAGf,WAAW,CAACc,UAAU,CAAC;;IAE5C;IACA,IAAI,CAACV,oBAAoB,GAAG,IAAI,CAACA,oBAAoB,CAACY,IAAI,CAAC,MAAM;MAC7D,OAAO,IAAI,CAACN,WAAW,CAACC,oBAAoB,CAACI,YAAY,CAAC;IAC9D,CAAC,CAAC;;IAEF;IACA,MAAM,IAAI,CAACX,oBAAoB;EACnC;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["DatadogCoreOpenFeatureProvider","toDdContext","DatadogOpenFeatureProvider","metadata","name","contextChangePromise","Promise","resolve","initialize","context","ddContext","flagsClient","setEvaluationContext","onContextChange","_oldContext","newContext","newDdContext","catch","undefined","then"],"sourceRoot":"../../src","sources":["provider.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAOA,SAASA,8BAA8B,QAAQ,gBAAgB;AAC/D,SAASC,WAAW,QAAQ,WAAW;AAIvC;AACA;AACA;AACA;AACA,OAAO,MAAMC,0BAA0B,SAASF,8BAA8B,CAAC;EAClEG,QAAQ,GAAqB;IAClCC,IAAI,EAAE;EACV,CAAC;EAEOC,oBAAoB,GAAGC,OAAO,CAACC,OAAO,CAAC,CAAC;EAEhD,MAAMC,UAAUA,CAACC,OAA4B,GAAG,CAAC,CAAC,EAAiB;IAC/D,MAAMC,SAAS,GAAGT,WAAW,CAACQ,OAAO,CAAC;IACtC,IAAI,CAACJ,oBAAoB,GAAG,IAAI,CAACM,WAAW,CAACC,oBAAoB,CAC7DF,SACJ,CAAC;IAED,MAAM,IAAI,CAACL,oBAAoB;EACnC;EAEA,MAAMQ,eAAeA,CACjBC,WAAgC,EAChCC,UAA+B,EAClB;IACb,MAAMC,YAAY,GAAGf,WAAW,CAACc,UAAU,CAAC;;IAE5C;IACA,IAAI,CAACV,oBAAoB,GAAG,IAAI,CAACA,oBAAoB,CAChDY,KAAK,CAAC,MAAMC,SAAS,CAAC,CACtBC,IAAI,CAAC,MAAM;MACR,OAAO,IAAI,CAACR,WAAW,CAACC,oBAAoB,CAACI,YAAY,CAAC;IAC9D,CAAC,CAAC;;IAEN;IACA,MAAM,IAAI,CAACX,oBAAoB;EACnC;AACJ","ignoreList":[]}
@@ -0,0 +1,37 @@
1
+ /*
2
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
+ * Copyright 2016-Present Datadog, Inc.
5
+ */
6
+
7
+ import * as DatadogSdk from '@datadog/mobile-react-native';
8
+
9
+ /**
10
+ * An application context that permits top-level undefined values to remove RUM defaults.
11
+ * Unlike OpenFeature's EvaluationContext, this input can contain these explicit tombstones.
12
+ * If enrichment cannot run, the context is returned unchanged, including undefined values.
13
+ */
14
+
15
+ /**
16
+ * Explicitly add the current RUM user to an OpenFeature evaluation context.
17
+ *
18
+ * The helper reads the RUM user each time it is called and returns a new context; it does not keep
19
+ * the OpenFeature context synchronized when the RUM user changes. The RUM user ID supplies the
20
+ * targeting key, while flat primitive user properties supply attributes. Application fields take
21
+ * precedence, and an explicitly undefined application field removes the corresponding RUM value
22
+ * from the returned context when enrichment succeeds.
23
+ *
24
+ * If the core SDK's enrichment helper is unavailable, logs a warning and returns the application
25
+ * context unchanged so OpenFeature initialization and evaluation can continue without RUM values.
26
+ */
27
+ export const enrichWithRumUser = context => {
28
+ const enricher = DatadogSdk.__ddEnrichEvaluationContextWithRumUser;
29
+ if (typeof enricher !== 'function') {
30
+ // InternalLog may also be absent from the core module, or have verbosity disabled.
31
+ // eslint-disable-next-line no-console
32
+ console.warn('DATADOG: `enrichWithRumUser` could not access the core RUM enrichment helper. Returning the application context unchanged. Check SDK compatibility.');
33
+ return context;
34
+ }
35
+ return enricher(context);
36
+ };
37
+ //# sourceMappingURL=rumContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["DatadogSdk","enrichWithRumUser","context","enricher","__ddEnrichEvaluationContextWithRumUser","console","warn"],"sourceRoot":"../../src","sources":["rumContext.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA,OAAO,KAAKA,UAAU,MAAM,8BAA8B;;AAM1D;AACA;AACA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,iBAAiB,GAC1BC,OAAoC,IAChB;EACpB,MAAMC,QAAQ,GAAIH,UAAU,CAEzBI,sCAAsC;EAEzC,IAAI,OAAOD,QAAQ,KAAK,UAAU,EAAE;IAChC;IACA;IACAE,OAAO,CAACC,IAAI,CACR,qJACJ,CAAC;IAED,OAAOJ,OAAO;EAClB;EAEA,OAAOC,QAAQ,CAACD,OAAO,CAAC;AAC5B,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../../../../core/src/flags/internal.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,iBAAiB,EAAkB,MAAM,SAAS,CAAC;AAEjE,MAAM,WAAW,cAAc;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,OAAO,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACzC;AAED,eAAO,MAAM,wBAAwB,YACxB,iBAAiB,KAC3B,iBAwCF,CAAC"}
1
+ {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../../../../../core/src/flags/internal.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,iBAAiB,EAAkB,MAAM,SAAS,CAAC;AAEjE,MAAM,WAAW,cAAc;IAC3B,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,OAAO,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACzC;AAED,eAAO,MAAM,wBAAwB,YACxB,iBAAiB,KAC3B,iBAmDF,CAAC"}
@@ -0,0 +1,14 @@
1
+ type FlatEvaluationContext = Record<string, unknown> & {
2
+ targetingKey?: string | undefined;
3
+ };
4
+ /**
5
+ * Add the current RUM user to an OpenFeature-shaped evaluation context.
6
+ *
7
+ * @internal Used by the explicit helper in the Datadog OpenFeature package. This is a point-in-time
8
+ * read; it does not synchronize OpenFeature when the RUM user changes. RUM values provide defaults;
9
+ * fields explicitly supplied by the application remain authoritative. An explicitly undefined
10
+ * field removes the corresponding RUM default and is omitted from the effective context.
11
+ */
12
+ export declare const __ddEnrichEvaluationContextWithRumUser: (context: FlatEvaluationContext) => FlatEvaluationContext;
13
+ export {};
14
+ //# sourceMappingURL=rumIntegration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rumIntegration.d.ts","sourceRoot":"","sources":["../../../../../../core/src/flags/rumIntegration.ts"],"names":[],"mappings":"AAWA,KAAK,qBAAqB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IACnD,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,sCAAsC,YACtC,qBAAqB,KAC/B,qBAuBF,CAAC"}
@@ -20,6 +20,7 @@ import { DdFlags } from './flags/DdFlags';
20
20
  import type { FlagsClient } from './flags/FlagsClient';
21
21
  import { configurationFromString, configurationToString } from './flags/configuration';
22
22
  import type { ParsedFlagsConfiguration } from './flags/configuration';
23
+ import { __ddEnrichEvaluationContextWithRumUser } from './flags/rumIntegration';
23
24
  import type { FlagsConfiguration, FlagDetails, EvaluationContext, PrimitiveValue } from './flags/types';
24
25
  import { DdLogs } from './logs/DdLogs';
25
26
  import { DdRum } from './rum/DdRum';
@@ -38,6 +39,6 @@ import { ErrorSource, FeatureOperationFailure } from './types';
38
39
  import { DefaultTimeProvider } from './utils/time-provider/DefaultTimeProvider';
39
40
  import type { Timestamp } from './utils/time-provider/TimeProvider';
40
41
  import { TimeProvider } from './utils/time-provider/TimeProvider';
41
- export { DatadogProvider, DatadogProviderConfiguration, FileBasedConfiguration, InitializationMode, DdLogs, DdFlags, configurationFromString, configurationToString, DdTrace, DdRum, RumActionType, ErrorSource, FeatureOperationFailure, CoreConfiguration, RumConfiguration, LogsConfiguration, TraceConfiguration, DdSdkReactNative, DdSdk, InternalLog, ProxyConfiguration, ProxyType, TrackingConsent, SdkVerbosity, VitalsUpdateFrequency, PropagatorType, UploadFrequency, BatchSize, BatchProcessingLevel, TimeProvider, DefaultTimeProvider, DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER, DATADOG_GRAPH_QL_OPERATION_NAME_HEADER, DATADOG_GRAPH_QL_VARIABLES_HEADER, DATADOG_GRAPH_QL_PAYLOAD_HEADER, DATADOG_GRAPH_QL_ERROR_HEADER, TracingIdType, TracingIdFormat, DatadogTracingIdentifier, DatadogTracingContext, DdBabelInteractionTracking, __ddExtractText };
42
+ export { DatadogProvider, DatadogProviderConfiguration, FileBasedConfiguration, InitializationMode, DdLogs, DdFlags, configurationFromString, configurationToString, DdTrace, DdRum, RumActionType, ErrorSource, FeatureOperationFailure, CoreConfiguration, RumConfiguration, LogsConfiguration, TraceConfiguration, DdSdkReactNative, DdSdk, InternalLog, ProxyConfiguration, ProxyType, TrackingConsent, SdkVerbosity, VitalsUpdateFrequency, PropagatorType, UploadFrequency, BatchSize, BatchProcessingLevel, TimeProvider, DefaultTimeProvider, DATADOG_GRAPH_QL_OPERATION_TYPE_HEADER, DATADOG_GRAPH_QL_OPERATION_NAME_HEADER, DATADOG_GRAPH_QL_VARIABLES_HEADER, DATADOG_GRAPH_QL_PAYLOAD_HEADER, DATADOG_GRAPH_QL_ERROR_HEADER, TracingIdType, TracingIdFormat, DatadogTracingIdentifier, DatadogTracingContext, DdBabelInteractionTracking, __ddExtractText, __ddEnrichEvaluationContextWithRumUser };
42
43
  export type { Timestamp, FirstPartyHost, AutoInstrumentationConfiguration, PartialInitializationConfiguration, CoreConfigurationOptions, RumConfigurationOptions, LogsConfigurationOptions, TraceConfigurationOptions, FlagsConfiguration, FlagsClient, ParsedFlagsConfiguration, EvaluationContext, PrimitiveValue, FlagDetails };
43
44
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../core/src/index.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,4BAA4B,EAAE,MAAM,uCAAuC,CAAC;AACrF,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,iDAAiD,CAAC;AACxG,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,mDAAmD,CAAC;AAC5G,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAC;AACzF,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,0CAA0C,CAAC;AACzF,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AACvF,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AACtE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AAC3F,OAAO,EAAE,kBAAkB,EAAE,MA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,EAAE,MAAM,uCAAuC,CAAC;AACxE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AAElE,OAAO,EACH,eAAe,EACf,4BAA4B,EAC5B,sBAAsB,EACtB,kBAAkB,EAClB,MAAM,EACN,OAAO,EACP,uBAAuB,EACvB,qBAAqB,EACrB,OAAO,EACP,KAAK,EACL,aAAa,EACb,WAAW,EACX,uBAAuB,EACvB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,KAAK,EACL,WAAW,EACX,kBAAkB,EAClB,SAAS,EACT,eAAe,EACf,YAAY,EACZ,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,SAAS,EACT,oBAAoB,EACpB,YAAY,EACZ,mBAAmB,EACnB,sCAAsC,EACtC,sCAAsC,EACtC,iCAAiC,EACjC,+BAA+B,EAC/B,6BAA6B,EAC7B,aAAa,EACb,eAAe,EACf,wBAAwB,EACxB,qBAAqB,EACrB,0BAA0B,EAC1B,eAAe,EAClB,CAAC;AACF,YAAY,EACR,SAAS,EACT,cAAc,EACd,gCAAgC,EAChC,kCAAkC,EAClC,wBAAwB,EACxB,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,EACzB,kBAAkB,EAClB,WAAW,EACX,wBAAwB,EACxB,iBAAiB,EACjB,cAAc,EACd,WAAW,EACd,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../core/src/index.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAA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B,EACvB,qBAAqB,EACrB,OAAO,EACP,KAAK,EACL,aAAa,EACb,WAAW,EACX,uBAAuB,EACvB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,KAAK,EACL,WAAW,EACX,kBAAkB,EAClB,SAAS,EACT,eAAe,EACf,YAAY,EACZ,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,SAAS,EACT,oBAAoB,EACpB,YAAY,EACZ,mBAAmB,EACnB,sCAAsC,EACtC,sCAAsC,EACtC,iCAAiC,EACjC,+BAA+B,EAC/B,6BAA6B,EAC7B,aAAa,EACb,eAAe,EACf,wBAAwB,EACxB,qBAAqB,EACrB,0BAA0B,EAC1B,eAAe,EACf,sCAAsC,EACzC,CAAC;AACF,YAAY,EACR,SAAS,EACT,cAAc,EACd,gCAAgC,EAChC,kCAAkC,EAClC,wBAAwB,EACxB,uBAAuB,EACvB,wBAAwB,EACxB,yBAAyB,EACzB,kBAAkB,EAClB,WAAW,EACX,wBAAwB,EACxB,iBAAiB,EACjB,cAAc,EACd,WAAW,EACd,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare const version = "3.6.0";
1
+ export declare const version = "3.8.0";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -2,6 +2,8 @@ import { configurationFromString } from '@datadog/mobile-react-native';
2
2
  import { DatadogOfflineOpenFeatureProvider } from './offlineProvider';
3
3
  import { DatadogOpenFeatureProvider } from './provider';
4
4
  import type { DatadogOpenFeatureProviderOptions } from './provider';
5
- export { DatadogOpenFeatureProvider, DatadogOfflineOpenFeatureProvider, configurationFromString };
6
- export type { DatadogOpenFeatureProviderOptions };
5
+ import { enrichWithRumUser } from './rumContext';
6
+ import type { EnrichableEvaluationContext } from './rumContext';
7
+ export { DatadogOpenFeatureProvider, DatadogOfflineOpenFeatureProvider, enrichWithRumUser, configurationFromString };
8
+ export type { DatadogOpenFeatureProviderOptions, EnrichableEvaluationContext };
7
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAEvE,OAAO,EAAE,iCAAiC,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,YAAY,CAAC;AAEpE,OAAO,EACH,0BAA0B,EAC1B,iCAAiC,EACjC,uBAAuB,EAC1B,CAAC;AACF,YAAY,EAAE,iCAAiC,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,uBAAuB,EAAE,MAAM,8BAA8B,CAAC;AAEvE,OAAO,EAAE,iCAAiC,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAEhE,OAAO,EACH,0BAA0B,EAC1B,iCAAiC,EACjC,iBAAiB,EACjB,uBAAuB,EAC1B,CAAC;AACF,YAAY,EAAE,iCAAiC,EAAE,2BAA2B,EAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../../src/provider.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACR,iBAAiB,IAAI,mBAAmB,EACxC,gBAAgB,EACnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,8BAA8B,EAAE,MAAM,gBAAgB,CAAC;AAGhE,YAAY,EAAE,iCAAiC,EAAE,MAAM,gBAAgB,CAAC;AAExE;;;GAGG;AACH,qBAAa,0BAA2B,SAAQ,8BAA8B;IAC1E,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAEjC;IAEF,OAAO,CAAC,oBAAoB,CAAqB;IAE3C,UAAU,CAAC,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;IAS5D,eAAe,CACjB,WAAW,EAAE,mBAAmB,EAChC,UAAU,EAAE,mBAAmB,GAChC,OAAO,CAAC,IAAI,CAAC;CAWnB"}
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../../src/provider.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACR,iBAAiB,IAAI,mBAAmB,EACxC,gBAAgB,EACnB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,8BAA8B,EAAE,MAAM,gBAAgB,CAAC;AAGhE,YAAY,EAAE,iCAAiC,EAAE,MAAM,gBAAgB,CAAC;AAExE;;;GAGG;AACH,qBAAa,0BAA2B,SAAQ,8BAA8B;IAC1E,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAEjC;IAEF,OAAO,CAAC,oBAAoB,CAAqB;IAE3C,UAAU,CAAC,OAAO,GAAE,mBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;IAS5D,eAAe,CACjB,WAAW,EAAE,mBAAmB,EAChC,UAAU,EAAE,mBAAmB,GAChC,OAAO,CAAC,IAAI,CAAC;CAanB"}
@@ -0,0 +1,23 @@
1
+ import type { EvaluationContext, EvaluationContextValue } from '@openfeature/web-sdk';
2
+ /**
3
+ * An application context that permits top-level undefined values to remove RUM defaults.
4
+ * Unlike OpenFeature's EvaluationContext, this input can contain these explicit tombstones.
5
+ * If enrichment cannot run, the context is returned unchanged, including undefined values.
6
+ */
7
+ export type EnrichableEvaluationContext = {
8
+ targetingKey?: string | undefined;
9
+ } & Record<string, EvaluationContextValue | undefined>;
10
+ /**
11
+ * Explicitly add the current RUM user to an OpenFeature evaluation context.
12
+ *
13
+ * The helper reads the RUM user each time it is called and returns a new context; it does not keep
14
+ * the OpenFeature context synchronized when the RUM user changes. The RUM user ID supplies the
15
+ * targeting key, while flat primitive user properties supply attributes. Application fields take
16
+ * precedence, and an explicitly undefined application field removes the corresponding RUM value
17
+ * from the returned context when enrichment succeeds.
18
+ *
19
+ * If the core SDK's enrichment helper is unavailable, logs a warning and returns the application
20
+ * context unchanged so OpenFeature initialization and evaluation can continue without RUM values.
21
+ */
22
+ export declare const enrichWithRumUser: (context: EnrichableEvaluationContext) => EvaluationContext;
23
+ //# sourceMappingURL=rumContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rumContext.d.ts","sourceRoot":"","sources":["../../../../src/rumContext.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EACR,iBAAiB,EACjB,sBAAsB,EACzB,MAAM,sBAAsB,CAAC;AAE9B;;;;GAIG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACtC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC,GAAG,MAAM,CAAC,MAAM,EAAE,sBAAsB,GAAG,SAAS,CAAC,CAAC;AAIvD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,YACjB,2BAA2B,KACrC,iBAgBF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datadog/mobile-react-native-openfeature",
3
- "version": "3.6.0",
3
+ "version": "3.8.0",
4
4
  "description": "A client-side React Native module to provide OpenFeature integration with Datadog Feature Flags",
5
5
  "keywords": [
6
6
  "datadog",
@@ -38,7 +38,7 @@
38
38
  "prepare": "rm -rf lib && yarn bob build"
39
39
  },
40
40
  "devDependencies": {
41
- "@datadog/mobile-react-native": "^3.6.0",
41
+ "@datadog/mobile-react-native": "^3.8.0",
42
42
  "@openfeature/core": "^1.9.2",
43
43
  "@openfeature/web-sdk": "^1.8.0",
44
44
  "@testing-library/react-native": "7.0.2",
@@ -83,5 +83,5 @@
83
83
  ]
84
84
  ]
85
85
  },
86
- "gitHead": "398e96d73be0341493adbbf8f4e2d7e3ca9d584b"
86
+ "gitHead": "b3bba94530197b781002f4cafc50122dbb28b3cd"
87
87
  }
@@ -0,0 +1,55 @@
1
+ /*
2
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
+ * Copyright 2016-Present Datadog, Inc.
5
+ */
6
+
7
+ import { __ddEnrichEvaluationContextWithRumUser } from '@datadog/mobile-react-native';
8
+ import type { EvaluationContext } from '@openfeature/web-sdk';
9
+
10
+ import type { EnrichableEvaluationContext } from '../../index';
11
+ import { enrichWithRumUser } from '../../index';
12
+
13
+ // Compiled, not executed: valid inputs must compile, and invalid inputs must stay rejected.
14
+ export const checkRumContextTypes = (optionalId: string | undefined) => {
15
+ const applicationContext: EnrichableEvaluationContext = {
16
+ targetingKey: optionalId,
17
+ email: undefined,
18
+ plan: undefined,
19
+ region: 'us-east-1',
20
+ profile: { tier: 'pro' },
21
+ roles: ['admin'],
22
+ createdAt: new Date(),
23
+ active: true,
24
+ age: 42,
25
+ nullable: null
26
+ };
27
+ const existingContext: EvaluationContext = { targetingKey: 'user-123' };
28
+ const emailTombstone = { email: undefined };
29
+ const optionalTargetingKey = { targetingKey: optionalId, region: 'us' };
30
+
31
+ const results: EvaluationContext[] = [
32
+ enrichWithRumUser(applicationContext),
33
+ enrichWithRumUser(existingContext),
34
+ enrichWithRumUser({}),
35
+ enrichWithRumUser({ email: undefined, plan: undefined }),
36
+ enrichWithRumUser(emailTombstone),
37
+ enrichWithRumUser({ targetingKey: undefined }),
38
+ enrichWithRumUser(optionalTargetingKey)
39
+ ];
40
+
41
+ // @ts-expect-error A targeting key must be a string or undefined.
42
+ enrichWithRumUser({ targetingKey: 42 });
43
+ // @ts-expect-error Functions are not OpenFeature context values.
44
+ enrichWithRumUser({ callback: () => true });
45
+ // @ts-expect-error Tombstones only apply to top-level attributes.
46
+ enrichWithRumUser({ profile: { tier: undefined } });
47
+
48
+ const coreResult = __ddEnrichEvaluationContextWithRumUser({
49
+ email: undefined
50
+ });
51
+ // @ts-expect-error Enrichment does not preserve the input's exact shape.
52
+ const unchangedShape: { email: undefined } = coreResult;
53
+
54
+ return { results, unchangedShape };
55
+ };
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "../../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "noEmit": true
5
+ },
6
+ "include": ["rumContext.types.ts", "../rumContext.test.ts"],
7
+ "exclude": []
8
+ }