@datadog/mobile-react-native-openfeature 3.9.0 → 3.11.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 (71) hide show
  1. package/README.md +118 -10
  2. package/lib/commonjs/datadogCoreProvider.js +129 -0
  3. package/lib/commonjs/datadogCoreProvider.js.map +1 -0
  4. package/lib/commonjs/offlineEvaluation.js +198 -0
  5. package/lib/commonjs/offlineEvaluation.js.map +1 -0
  6. package/lib/commonjs/offlineProvider.js +44 -8
  7. package/lib/commonjs/offlineProvider.js.map +1 -1
  8. package/lib/commonjs/rules-based.js +62 -0
  9. package/lib/commonjs/rules-based.js.map +1 -0
  10. package/lib/module/datadogCoreProvider.js +122 -0
  11. package/lib/module/datadogCoreProvider.js.map +1 -0
  12. package/lib/module/offlineEvaluation.js +192 -0
  13. package/lib/module/offlineEvaluation.js.map +1 -0
  14. package/lib/module/offlineProvider.js +45 -9
  15. package/lib/module/offlineProvider.js.map +1 -1
  16. package/lib/module/rules-based.js +50 -0
  17. package/lib/module/rules-based.js.map +1 -0
  18. package/lib/typescript/core/src/config/FileBasedConfiguration.d.ts.map +1 -1
  19. package/lib/typescript/core/src/config/FileBasedConfiguration.type.d.ts +2 -0
  20. package/lib/typescript/core/src/config/FileBasedConfiguration.type.d.ts.map +1 -1
  21. package/lib/typescript/core/src/config/async/AutoInstrumentationConfiguration.d.ts +4 -0
  22. package/lib/typescript/core/src/config/async/AutoInstrumentationConfiguration.d.ts.map +1 -1
  23. package/lib/typescript/core/src/config/async/PartialInitializationConfiguration.d.ts +2 -0
  24. package/lib/typescript/core/src/config/async/PartialInitializationConfiguration.d.ts.map +1 -1
  25. package/lib/typescript/core/src/config/features/RumConfiguration.d.ts +4 -0
  26. package/lib/typescript/core/src/config/features/RumConfiguration.d.ts.map +1 -1
  27. package/lib/typescript/core/src/config/features/RumConfiguration.type.d.ts +21 -0
  28. package/lib/typescript/core/src/config/features/RumConfiguration.type.d.ts.map +1 -1
  29. package/lib/typescript/core/src/config/features/RumConfigurationNative.d.ts +2 -0
  30. package/lib/typescript/core/src/config/features/RumConfigurationNative.d.ts.map +1 -1
  31. package/lib/typescript/core/src/flags/FlagsClient.d.ts +38 -1
  32. package/lib/typescript/core/src/flags/FlagsClient.d.ts.map +1 -1
  33. package/lib/typescript/core/src/flags/internal.d.ts +1 -0
  34. package/lib/typescript/core/src/flags/internal.d.ts.map +1 -1
  35. package/lib/typescript/core/src/flags/types.d.ts +1 -1
  36. package/lib/typescript/core/src/flags/types.d.ts.map +1 -1
  37. package/lib/typescript/core/src/rum/DdRum.d.ts +1 -0
  38. package/lib/typescript/core/src/rum/DdRum.d.ts.map +1 -1
  39. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.d.ts +2 -0
  40. package/lib/typescript/core/src/rum/instrumentation/resourceTracking/requestProxy/common/RequestContext.d.ts.map +1 -1
  41. package/lib/typescript/core/src/rum/types.d.ts +6 -0
  42. package/lib/typescript/core/src/rum/types.d.ts.map +1 -1
  43. package/lib/typescript/core/src/sdk/AccountInfoSingleton/AccountInfoSingleton.d.ts.map +1 -1
  44. package/lib/typescript/core/src/sdk/UserInfoSingleton/UserInfoSingleton.d.ts.map +1 -1
  45. package/lib/typescript/core/src/specs/NativeDdRum.d.ts +6 -0
  46. package/lib/typescript/core/src/specs/NativeDdRum.d.ts.map +1 -1
  47. package/lib/typescript/core/src/version.d.ts +1 -1
  48. package/lib/typescript/core/src/version.d.ts.map +1 -1
  49. package/lib/typescript/react-native-openfeature/src/datadogCoreProvider.d.ts +31 -0
  50. package/lib/typescript/react-native-openfeature/src/datadogCoreProvider.d.ts.map +1 -0
  51. package/lib/typescript/react-native-openfeature/src/index.d.ts +1 -0
  52. package/lib/typescript/react-native-openfeature/src/index.d.ts.map +1 -1
  53. package/lib/typescript/react-native-openfeature/src/offlineEvaluation.d.ts +33 -0
  54. package/lib/typescript/react-native-openfeature/src/offlineEvaluation.d.ts.map +1 -0
  55. package/lib/typescript/react-native-openfeature/src/offlineProvider.d.ts +14 -8
  56. package/lib/typescript/react-native-openfeature/src/offlineProvider.d.ts.map +1 -1
  57. package/lib/typescript/react-native-openfeature/src/rules-based.d.ts +17 -0
  58. package/lib/typescript/react-native-openfeature/src/rules-based.d.ts.map +1 -0
  59. package/package.json +8 -4
  60. package/rules-based/package.json +7 -0
  61. package/src/__tests__/__utils__/coreConfiguration.ts +84 -0
  62. package/src/__tests__/datadogCoreProvider.integration.test.ts +230 -0
  63. package/src/__tests__/datadogCoreProvider.test.ts +587 -0
  64. package/src/__tests__/entrypoints.test.ts +35 -0
  65. package/src/__tests__/offlineProvider.delegation.test.ts +795 -0
  66. package/src/__tests__/offlineProvider.test.ts +74 -10
  67. package/src/datadogCoreProvider.ts +223 -0
  68. package/src/index.ts +1 -0
  69. package/src/offlineEvaluation.ts +295 -0
  70. package/src/offlineProvider.ts +64 -13
  71. package/src/rules-based.ts +58 -0
@@ -1 +1 @@
1
- {"version":3,"names":["_webSdk","require","_coreProvider","_mappers","OF_ERROR_CODE","INVALID_CONTEXT","ErrorCode","PROVIDER_NOT_READY","GENERAL","DatadogOfflineOpenFeatureProvider","DatadogCoreOpenFeatureProvider","metadata","name","configurationInError","initialize","context","result","applyContext","status","toError","errorCode","onContextChange","_oldContext","newContext","setConfiguration","configuration","flagsClient","events","emit","ProviderEvents","Ready","ConfigurationChanged","details","message","Error","isEmptyContext","resetEvaluationContextWithoutFetching","setEvaluationContextWithoutFetching","toDdContext","InvalidContextError","ProviderNotReadyError","GeneralError","exports"],"sourceRoot":"../../src","sources":["offlineProvider.ts"],"mappings":";;;;;;AAUA,IAAAA,OAAA,GAAAC,OAAA;AAaA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAxBA;AACA;AACA;AACA;AACA;;AAsBA;AACA;;AAOA;AACA;AACA;;AAGA,MAAMG,aAAwD,GAAG;EAC7DC,eAAe,EAAEC,iBAAS,CAACD,eAAe;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AI,CAACC,sBAAc,CAACC,KAAK,CAAC;MAC1C;MACA;MACA,IAAI,CAACH,MAAM,CAACC,IAAI,CAACC,sBAAc,CAACE,oBAAoB,CAAC;IACzD,CAAC,MAAM;MACH,IAAI,CAAClB,oBAAoB,GAAG,IAAI;MAChC,MAAMmB,OAA2B,GAAG;QAChCC,OAAO,EACH,6FAA6F;QACjGb,SAAS,EAAEhB,aAAa,CAACY,MAAM,CAACI,SAAS;MAC7C,CAAC;MACD,IAAI,CAACO,MAAM,CAACC,IAAI,CAACC,sBAAc,CAACK,KAAK,EAAEF,OAAO,CAAC;IACnD;EACJ;EAEQf,YAAYA,CAACF,OAA4B,EAAuB;IACpE;IACA;IACA;IACA;IACA,MAAMC,MAAM,GAAG,IAAAmB,uBAAc,EAACpB,OAAO,CAAC,GAChC,IAAI,CAACW,WAAW,CAACU,qCAAqC,CAAC,CAAC,GACxD,IAAI,CAACV,WAAW,CAACW,mCAAmC,CAChD,IAAAC,oBAAW,EAACvB,OAAO,CACvB,CAAC;IAEP,IAAI,CAACF,oBAAoB,GAAGG,MAAM,CAACE,MAAM,KAAK,OAAO;IAErD,OAAOF,MAAM;EACjB;;EAEA;AACJ;AACA;AACA;AACA;AACA;EACYG,OAAOA,CAACC,SAAiC,EAAoB;IACjE,QAAQA,SAAS;MACb,KAAK,iBAAiB;QAClB,OAAO,IAAImB,2BAAmB,CAC1B,sGACJ,CAAC;MACL,KAAK,oBAAoB;QACrB,OAAO,IAAIC,6BAAqB,CAC5B,6FACJ,CAAC;MACL;QACI,OAAO,IAAIC,oBAAY,CACnB,qEACJ,CAAC;IACT;EACJ;AACJ;AAACC,OAAA,CAAAjC,iCAAA,GAAAA,iCAAA","ignoreList":[]}
1
+ {"version":3,"names":["_mobileReactNative","require","_webSdk","_coreProvider","_mappers","_offlineEvaluation","OF_ERROR_CODE","INVALID_CONTEXT","ErrorCode","PROVIDER_NOT_READY","PARSE_ERROR","GENERAL","DatadogOfflineOpenFeatureProvider","DatadogCoreOpenFeatureProvider","metadata","name","configurationInError","initialize","context","result","applyContext","status","toError","errorCode","onContextChange","_oldContext","newContext","setConfiguration","configuration","installConfiguration","events","emit","ProviderEvents","Ready","ConfigurationChanged","details","message","Error","flagsClient","__ddSetOfflineEvaluator","helpers","OfflineEvaluation","rules","InternalLog","log","SdkVerbosity","WARN","isEmptyContext","resetEvaluationContextWithoutFetching","__ddSetOfflineEvaluationContext","toDdContext","targetingKey","setEvaluationContextWithoutFetching","InvalidContextError","ProviderNotReadyError","ParseError","GeneralError","exports"],"sourceRoot":"../../src","sources":["offlineProvider.ts"],"mappings":";;;;;;AAOA,IAAAA,kBAAA,GAAAC,OAAA;AAKA,IAAAC,OAAA,GAAAD,OAAA;AAcA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,kBAAA,GAAAJ,OAAA;AA5BA;AACA;AACA;AACA;AACA;;AA0BA;AACA;;AAOA;AACA;AACA;;AAGA,MAAMK,aAAwD,GAAG;EAC7DC,eAAe,EAAEC,iBAAS,CAACD,eAAe;EAC1CE,kBAAkB,EAAED,iBAAS,CAACC,kBAAkB;EAChDC,WAAW,EAAEF,iBAAS,CAACE,WAAW;EAClCC,OAAO,EAAEH,iBAAS,CAACG;AACvB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,iCAAiC,SAASC,4CAA8B,CAAC;EACzEC,QAAQ,GAAqB;IAClCC,IAAI,EAAE;EACV,CAAC;;EAED;EACA;EACA;EACA;EACQC,oBAAoB,GAAG,KAAK;EAEpC,MAAMC,UAAUA,CAACC,OAA4B,GAAG,CAAC,CAAC,EAAiB;IAC/D,MAAMC,MAAM,GAAG,IAAI,CAACC,YAAY,CAACF,O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;QACrB,OAAO,IAAIC,6BAAqB,CAC5B,6FACJ,CAAC;MACL,KAAK,aAAa;QACd,OAAO,IAAIC,kBAAU,CACjB,qEACJ,CAAC;MACL;QACI,OAAO,IAAIC,oBAAY,CACnB,qEACJ,CAAC;IACT;EACJ;AACJ;AAACC,OAAA,CAAA7C,iCAAA,GAAAA,iCAAA","ignoreList":[]}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.DatadogCoreProvider = void 0;
7
+ Object.defineProperty(exports, "coreConfigurationFromString", {
8
+ enumerable: true,
9
+ get: function () {
10
+ return _rulesBased.configurationFromString;
11
+ }
12
+ });
13
+ var _rulesBased = require("@datadog/flagging-core/rules-based");
14
+ var _flaggingCore = require("@datadog/flagging-core");
15
+ var _datadogCoreProvider = require("./datadogCoreProvider");
16
+ /*
17
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
18
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
19
+ * Copyright 2016-Present Datadog, Inc.
20
+ */
21
+
22
+ // Rules parsing loads Protobuf-ES. Keep it behind this entry, as the browser SDK does.
23
+
24
+ /**
25
+ * Evaluates manually supplied precomputed or rules-based configurations in JavaScript using
26
+ * @datadog/flagging-core. Ported from openfeature-js-client's browser DatadogCoreProvider.
27
+ *
28
+ * Unlike the native-backed providers, this provider does not use DdFlags, fetch configuration,
29
+ * or send exposure/RUM events. Load a configuration before registering it with OpenFeature.
30
+ * Precomputed configurations require a matching OpenFeature context, including when it is empty.
31
+ */
32
+ class DatadogCoreProvider extends _datadogCoreProvider.DatadogCoreEvaluationProvider {
33
+ fallbackConfigurationSequence = 0;
34
+ computeConfigurationId(configuration) {
35
+ try {
36
+ // Retrieval metadata and the UFC build timestamp can change without changing rules.
37
+ // The backend's semantic Fingerprint() also excludes the rules' CreatedAt.
38
+ return (0, _flaggingCore.getMD5Hash)((0, _rulesBased.configurationToString)({
39
+ ...configuration,
40
+ precomputed: configuration.precomputed && {
41
+ ...configuration.precomputed,
42
+ fetchedAt: undefined,
43
+ etag: undefined
44
+ },
45
+ rules: configuration.rules && {
46
+ ...configuration.rules,
47
+ response: {
48
+ ...configuration.rules.response,
49
+ createdAt: undefined
50
+ },
51
+ fetchedAt: undefined,
52
+ etag: undefined
53
+ }
54
+ }));
55
+ } catch {
56
+ this.fallbackConfigurationSequence += 1;
57
+ return `core-configuration-${this.fallbackConfigurationSequence}`;
58
+ }
59
+ }
60
+ }
61
+ exports.DatadogCoreProvider = DatadogCoreProvider;
62
+ //# sourceMappingURL=rules-based.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_rulesBased","require","_flaggingCore","_datadogCoreProvider","DatadogCoreProvider","DatadogCoreEvaluationProvider","fallbackConfigurationSequence","computeConfigurationId","configuration","getMD5Hash","configurationToString","precomputed","fetchedAt","undefined","etag","rules","response","createdAt","exports"],"sourceRoot":"../../src","sources":["rules-based.ts"],"mappings":";;;;;;;;;;;;AAMA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAGA,IAAAE,oBAAA,GAAAF,OAAA;AAVA;AACA;AACA;AACA;AACA;;AAQA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,mBAAmB,SAASC,kDAA6B,CAAC;EAC3DC,6BAA6B,GAAG,CAAC;EAE/BC,sBAAsBA,CAC5BC,aAAiC,EAC3B;IACN,IAAI;MACA;MACA;MACA,OAAO,IAAAC,wBAAU,EACb,IAAAC,iCAAqB,EAAC;QAClB,GAAGF,aAAa;QAChBG,WAAW,EAAEH,aAAa,CAACG,WAAW,IAAI;UACtC,GAAGH,aAAa,CAACG,WAAW;UAC5BC,SAAS,EAAEC,SAAS;UACpBC,IAAI,EAAED;QACV,CAAC;QACDE,KAAK,EAAEP,aAAa,CAACO,KAAK,IAAI;UAC1B,GAAGP,aAAa,CAACO,KAAK;UACtBC,QAAQ,EAAE;YACN,GAAGR,aAAa,CAACO,KAAK,CAACC,QAAQ;YAC/BC,SAAS,EAAEJ;UACf,CAAC;UACDD,SAAS,EAAEC,SAAS;UACpBC,IAAI,EAAED;QACV;MACJ,CAAC,CACL,CAAC;IACL,CAAC,CAAC,MAAM;MACJ,IAAI,CAACP,6BAA6B,IAAI,CAAC;MACvC,OAAO,sBAAsB,IAAI,CAACA,6BAA6B,EAAE;IACrE;EACJ;AACJ;AAACY,OAAA,CAAAd,mBAAA,GAAAA,mBAAA","ignoreList":[]}
@@ -0,0 +1,122 @@
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 { evaluate, getFlagsConfigurationError } from '@datadog/flagging-core';
8
+ import { InvalidContextError, OpenFeatureEventEmitter, ParseError, ProviderEvents, ProviderNotReadyError } from '@openfeature/web-sdk';
9
+ /**
10
+ * Evaluates manually supplied configurations in JavaScript using @datadog/flagging-core.
11
+ * Ported from openfeature-js-client's browser DatadogCoreProvider.
12
+ *
13
+ * Unlike the native-backed providers, this provider does not use DdFlags, fetch configuration,
14
+ * or send exposure/RUM events. Load a configuration before registering it with OpenFeature.
15
+ * Precomputed configurations require a matching OpenFeature context, including when it is empty.
16
+ */
17
+ export class DatadogCoreEvaluationProvider {
18
+ metadata = {
19
+ name: 'datadog-core'
20
+ };
21
+ runsOn = 'client';
22
+ events = new OpenFeatureEventEmitter();
23
+ getConfiguration() {
24
+ return this.flagsConfiguration;
25
+ }
26
+ setConfiguration(configuration) {
27
+ const hadEvaluatableConfiguration = this.canEvaluateCurrentContext();
28
+ // Untyped callers can pass a non-object (e.g. `null`), which flagging-core cannot read.
29
+ // Like any other unusable configuration, it replaces the previous one and surfaces
30
+ // PARSE_ERROR until a valid configuration is set.
31
+ if (typeof configuration !== 'object' || configuration === null) {
32
+ this.flagsConfiguration = {
33
+ configurationError: 'Flags configuration must be an object'
34
+ };
35
+ this.flagsConfigurationId = undefined;
36
+ } else {
37
+ this.flagsConfiguration = configuration;
38
+ this.flagsConfigurationId = this.computeConfigurationId(configuration);
39
+ }
40
+ if (this.context === undefined) {
41
+ return;
42
+ }
43
+ const error = toOpenFeatureError(getFlagsConfigurationError(this.flagsConfiguration, this.context));
44
+ if (error) {
45
+ // The web-sdk's ErrorEvent type omits errorCode, but its provider wrapper reads it.
46
+ const details = {
47
+ error,
48
+ message: error.message,
49
+ errorCode: error.code
50
+ };
51
+ this.events.emit(ProviderEvents.Error, details);
52
+ return;
53
+ }
54
+ if (!hadEvaluatableConfiguration) {
55
+ this.events.emit(ProviderEvents.Ready);
56
+ }
57
+ this.events.emit(ProviderEvents.ConfigurationChanged);
58
+ }
59
+ initialize(context = {}) {
60
+ this.context = context;
61
+ const error = toOpenFeatureError(getFlagsConfigurationError(this.flagsConfiguration, context));
62
+ return error ? Promise.reject(error) : Promise.resolve();
63
+ }
64
+ onContextChange(_oldContext, newContext) {
65
+ this.context = newContext;
66
+ const error = toOpenFeatureError(getFlagsConfigurationError(this.flagsConfiguration, this.context));
67
+ if (error) {
68
+ throw error;
69
+ }
70
+ }
71
+ resolveBooleanEvaluation(flagKey, defaultValue, context, logger) {
72
+ return this.resolve('boolean', flagKey, defaultValue, context, logger);
73
+ }
74
+ resolveStringEvaluation(flagKey, defaultValue, context, logger) {
75
+ return this.resolve('string', flagKey, defaultValue, context, logger);
76
+ }
77
+ resolveNumberEvaluation(flagKey, defaultValue, context, logger) {
78
+ return this.resolve('number', flagKey, defaultValue, context, logger);
79
+ }
80
+ resolveObjectEvaluation(flagKey, defaultValue, context, logger) {
81
+ // OpenFeature requires a specific JsonValue subtype without runtime type information.
82
+ // Callers must provide a default value with the expected shape.
83
+ return this.resolve('object', flagKey, defaultValue, context, logger);
84
+ }
85
+ resolve(type, flagKey, defaultValue, context, logger) {
86
+ const details = evaluate(this.flagsConfiguration, type, flagKey, defaultValue, context, logger);
87
+ if (this.flagsConfigurationId === undefined || details.flagMetadata?.doLog !== true || typeof details.flagMetadata?.allocationKey !== 'string' || details.variant == null) {
88
+ return details;
89
+ }
90
+
91
+ // Preserve the browser provider's configuration identity for consumers of evaluation metadata.
92
+ return {
93
+ ...details,
94
+ flagMetadata: {
95
+ ...details.flagMetadata,
96
+ __dd_core_configuration_id: this.flagsConfigurationId
97
+ }
98
+ };
99
+ }
100
+ canEvaluateCurrentContext() {
101
+ return this.context !== undefined && !getFlagsConfigurationError(this.flagsConfiguration, this.context);
102
+ }
103
+
104
+ // The `/rules-based` entry adds the browser's configuration identity. Hashing a rules
105
+ // configuration needs the protobuf encoder, which the main entry must not load.
106
+ computeConfigurationId(_configuration) {
107
+ return undefined;
108
+ }
109
+ }
110
+ function toOpenFeatureError(error) {
111
+ if (!error) {
112
+ return undefined;
113
+ }
114
+ if (error.errorCode === 'PARSE_ERROR') {
115
+ return new ParseError(error.errorMessage);
116
+ }
117
+ if (error.errorCode === 'INVALID_CONTEXT') {
118
+ return new InvalidContextError(error.errorMessage);
119
+ }
120
+ return new ProviderNotReadyError(error.errorMessage);
121
+ }
122
+ //# sourceMappingURL=datadogCoreProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["evaluate","getFlagsConfigurationError","InvalidContextError","OpenFeatureEventEmitter","ParseError","ProviderEvents","ProviderNotReadyError","DatadogCoreEvaluationProvider","metadata","name","runsOn","events","getConfiguration","flagsConfiguration","setConfiguration","configuration","hadEvaluatableConfiguration","canEvaluateCurrentContext","configurationError","flagsConfigurationId","undefined","computeConfigurationId","context","error","toOpenFeatureError","details","message","errorCode","code","emit","Error","Ready","ConfigurationChanged","initialize","Promise","reject","resolve","onContextChange","_oldContext","newContext","resolveBooleanEvaluation","flagKey","defaultValue","logger","resolveStringEvaluation","resolveNumberEvaluation","resolveObjectEvaluation","type","flagMetadata","doLog","allocationKey","variant","__dd_core_configuration_id","_configuration","errorMessage"],"sourceRoot":"../../src","sources":["datadogCorePro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AC5B,IAAI,CAACA,KAAK,EAAE;IACR,OAAOH,SAAS;EACpB;EACA,IAAIG,KAAK,CAACI,SAAS,KAAK,aAAa,EAAE;IACnC,OAAO,IAAIvB,UAAU,CAACmB,KAAK,CAAC+B,YAAY,CAAC;EAC7C;EACA,IAAI/B,KAAK,CAACI,SAAS,KAAK,iBAAiB,EAAE;IACvC,OAAO,IAAIzB,mBAAmB,CAACqB,KAAK,CAAC+B,YAAY,CAAC;EACtD;EACA,OAAO,IAAIhD,qBAAqB,CAACiB,KAAK,CAAC+B,YAAY,CAAC;AACxD","ignoreList":[]}
@@ -0,0 +1,192 @@
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 { configMatchesContext } from '@datadog/flagging-core';
8
+ import { InternalLog, SdkVerbosity } from '@datadog/mobile-react-native';
9
+ import { ErrorCode, OpenFeatureError } from '@openfeature/web-sdk';
10
+ import { DatadogCoreEvaluationProvider } from './datadogCoreProvider';
11
+
12
+ // Keep the bridge contract owned by FlagsClient; no OpenFeature dependency enters the core SDK.
13
+
14
+ const logger = {
15
+ debug: message => InternalLog.log(String(message), SdkVerbosity.DEBUG),
16
+ info: message => InternalLog.log(String(message), SdkVerbosity.INFO),
17
+ warn: message => InternalLog.log(String(message), SdkVerbosity.WARN),
18
+ error: message => InternalLog.log(String(message), SdkVerbosity.ERROR)
19
+ };
20
+
21
+ /**
22
+ * Compatibility adapter for the released offline provider. DatadogCoreProvider owns evaluation;
23
+ * the named FlagsClient owns this adapter and native exposure/RUM delivery. Only the legacy
24
+ * precomputed input/context normalization and native tracking representation are adapted here.
25
+ */
26
+ export class OfflineEvaluation {
27
+ core = new DatadogCoreEvaluationProvider();
28
+ precomputedFlags = new Map();
29
+ context = {
30
+ targetingKey: '',
31
+ attributes: {}
32
+ };
33
+ coreContext = {};
34
+ // Whether the active context selects the precomputed snapshot. Fixed until the next reconcile.
35
+ servesPrecomputed = false;
36
+ constructor(configuration, helpers) {
37
+ this.configuration = {
38
+ ...configuration
39
+ };
40
+ const precomputed = configuration?.precomputed;
41
+ if (!precomputed && !this.configuration.rules && this.configuration.configurationError === undefined && this.configuration.precomputedError === undefined && this.configuration.rulesError === undefined) {
42
+ // A bare {} has no capability. The precomputed-only parser returns it for a rules-only wire.
43
+ InternalLog.log('DatadogOfflineOpenFeatureProvider received no precomputed or rules configuration. configurationFromString is precomputed-only; parse rules-based wires with coreConfigurationFromString from the /rules-based entry point.', SdkVerbosity.WARN);
44
+ }
45
+ if (precomputed) {
46
+ try {
47
+ this.precomputedFlags = helpers.decodePrecomputedFlags(precomputed.response);
48
+ const flags = Object.fromEntries(Array.from(this.precomputedFlags, ([key, flag]) => [key, {
49
+ allocationKey: flag.allocationKey,
50
+ variationKey: flag.variationKey,
51
+ // The released client checks the value's runtime type, including integer/float
52
+ // aliases and object-typed payloads containing primitives. Keep that behavior.
53
+ variationType: typeof flag.value,
54
+ variationValue: flag.value,
55
+ reason: flag.reason,
56
+ doLog: flag.doLog,
57
+ // The native decoder does not keep the split serial ID; read it from the wire.
58
+ serialId: precomputed.response.data.attributes.flags[key]?.serialId
59
+ }]));
60
+ this.configuration.precomputed = {
61
+ ...precomputed,
62
+ context: precomputed.context ? toOpenFeatureContext(helpers.normalizeWireContext(precomputed.context)) : undefined,
63
+ // The native decoder omits malformed entries; flagging-core's parser reports them.
64
+ flagErrors: precomputed.flagErrors,
65
+ response: {
66
+ data: {
67
+ attributes: {
68
+ createdAt: precomputed.response.data.attributes.createdAt,
69
+ flags
70
+ }
71
+ }
72
+ }
73
+ };
74
+ } catch (error) {
75
+ // A malformed precomputed branch must not hide a usable rules branch.
76
+ this.configuration.precomputed = undefined;
77
+ this.configuration.precomputedError = error instanceof Error ? error.message : String(error);
78
+ }
79
+ }
80
+ this.core.setConfiguration(this.configuration);
81
+ }
82
+ reconcile(context, hasTargetingKey = typeof context?.targetingKey === 'string') {
83
+ // An omitted override adopts the normalized embedded context. Rules-only configurations
84
+ // must not invent an anonymous subject: missing and explicitly empty keys differ.
85
+ const embedded = this.configuration.precomputed?.context;
86
+ this.context = context ?? (embedded ? {
87
+ targetingKey: embedded.targetingKey ?? '',
88
+ attributes: withoutTargetingKey(embedded)
89
+ } : {
90
+ targetingKey: '',
91
+ attributes: {}
92
+ });
93
+ const normalizedContext = toOpenFeatureContext(this.context);
94
+ // Snapshot matching retains released normalization/adoption. Only rules fallback uses the
95
+ // original subject presence; native tracking still receives the normalized context.
96
+ this.coreContext = configMatchesContext(this.configuration, normalizedContext) || hasTargetingKey === true ? normalizedContext : withoutTargetingKey(normalizedContext);
97
+ this.servesPrecomputed = configMatchesContext(this.configuration, this.coreContext);
98
+ try {
99
+ // Synchronous validation preserves the offline provider's context-change lifecycle.
100
+ this.core.onContextChange({}, this.coreContext);
101
+ return {
102
+ status: 'ready'
103
+ };
104
+ } catch (error) {
105
+ const code = error instanceof OpenFeatureError ? error.code : ErrorCode.GENERAL;
106
+ return {
107
+ status: 'error',
108
+ errorCode: code === ErrorCode.INVALID_CONTEXT || code === ErrorCode.PROVIDER_NOT_READY || code === ErrorCode.PARSE_ERROR ? code : ErrorCode.GENERAL
109
+ };
110
+ }
111
+ }
112
+ evaluate(key, defaultValue, type) {
113
+ const context = this.coreContext;
114
+ const result = this.resolve(key, defaultValue, type, context);
115
+ const allocationKey = result.flagMetadata?.allocationKey;
116
+ const details = {
117
+ key,
118
+ value: result.value,
119
+ reason: result.reason ?? 'UNKNOWN',
120
+ variant: result.variant,
121
+ allocationKey: typeof allocationKey === 'string' ? allocationKey : undefined,
122
+ errorCode: result.errorCode,
123
+ errorMessage: result.errorMessage
124
+ };
125
+ if (result.errorCode || typeof allocationKey !== 'string' || result.variant === undefined) {
126
+ return {
127
+ details
128
+ };
129
+ }
130
+
131
+ // Reuse original precomputed tracking metadata (including extraLogging and variationType).
132
+ // A rules result has no native cache entry, so build the same native tracking shape from
133
+ // the actual evaluated result, never from the fallback/default value.
134
+ const precomputed = this.servesPrecomputed ? this.precomputedFlags.get(key) : undefined;
135
+ const serialId = result.flagMetadata?.__dd_split_serial_id;
136
+ const serial = typeof serialId === 'number' ? {
137
+ serialId: String(serialId)
138
+ } : {};
139
+ const flag = precomputed ? {
140
+ ...precomputed,
141
+ ...serial
142
+ } : {
143
+ key,
144
+ value: result.value,
145
+ allocationKey,
146
+ variationKey: result.variant,
147
+ variationType: type,
148
+ variationValue: typeof result.value === 'object' ? JSON.stringify(result.value) : String(result.value),
149
+ reason: result.reason ?? 'UNKNOWN',
150
+ doLog: result.flagMetadata?.doLog === true,
151
+ extraLogging: {},
152
+ ...serial
153
+ };
154
+ // Even doLog=false evaluations reach native code: RUM tracking is independent of exposures.
155
+ return {
156
+ details,
157
+ exposure: {
158
+ flag,
159
+ context: this.context
160
+ }
161
+ };
162
+ }
163
+ resolve(key, defaultValue, type, context) {
164
+ // FlagsClient's typed getters guarantee the default's type. OpenFeature's object method
165
+ // additionally relies on the caller's JSON shape, just as DatadogCoreProvider does.
166
+ switch (type) {
167
+ case 'boolean':
168
+ return this.core.resolveBooleanEvaluation(key, defaultValue, context, logger);
169
+ case 'string':
170
+ return this.core.resolveStringEvaluation(key, defaultValue, context, logger);
171
+ case 'number':
172
+ return this.core.resolveNumberEvaluation(key, defaultValue, context, logger);
173
+ case 'object':
174
+ return this.core.resolveObjectEvaluation(key, defaultValue, context, logger);
175
+ }
176
+ }
177
+ }
178
+ function toOpenFeatureContext(context) {
179
+ return {
180
+ ...context.attributes,
181
+ targetingKey: context.targetingKey
182
+ };
183
+ }
184
+ function withoutTargetingKey(context) {
185
+ const {
186
+ targetingKey,
187
+ ...attributes
188
+ } = context;
189
+ // This context has already passed through FlagsClient's primitive-only normalization.
190
+ return attributes;
191
+ }
192
+ //# sourceMappingURL=offlineEvaluation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["configMatchesContext","InternalLog","SdkVerbosity","ErrorCode","OpenFeatureError","DatadogCoreEvaluationProvider","logger","debug","message","log","String","DEBUG","info","INFO","warn","WARN","error","ERROR","OfflineEvaluation","core","precomputedFlags","Map","context","targetingKey","attributes","coreContext","servesPrecomputed","constructor","configuration","helpers","precomputed","rules","configurationError","undefined","precomputedError","rulesError","decodePrecomputedFlags","response","flags","Object","fromEntries","Array","from","key","flag","allocationKey","variationKey","variationType","value","variationValue","reason","doLog","serialId","data","toOpenFeatureContext","normalizeWireContext","flagErrors","createdAt","Error","setConfiguration","reconcile","hasTargetingKey","embedded","withoutTargetingKey","normalizedContext","onContextChange","status","code","GENERAL","errorCode","INVALID_CONTEXT","PROVIDER_NOT_READY","PARSE_ERROR","evaluate","defaultValue","type","result","resolve","flagMetadata","details","variant","errorMessage","get","__dd_split_serial_id","serial","JSON","stringify","extraLogging","exposure","resolveBooleanEvaluation","resolveStringEvaluation","resolveNumberEvaluation","resolveObjectEvaluation"],"sourceRoot":"../../src","sources":["offlineEvaluation.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA,SAASA,oBAAoB,QAAQ,wBAAwB;AAK7D,SAASC,WAAW,EAAEC,YAAY,QAAQ,8BAA8B;AAMxE,SAASC,SAAS,EAAEC,gBAAgB,QAAQ,sBAAsB;AASlE,SAASC,6BAA6B,QAAQ,uBAAuB;;AAErE;;AASA,MAAMC,MAAc,GAAG;EACnBC,KAAK,EAAEC,OAAO,IAAIP,WAAW,CAACQ,GAAG,CAACC,MAAM,CAACF,OAAO,CAAC,EAAEN,YAAY,CAACS,KAAK,CAAC;EACtEC,IAAI,EAAEJ,OAAO,IAAIP,WAAW,CAACQ,GAAG,CAACC,MAAM,CAACF,OAAO,CAAC,EAAEN,YAAY,CAACW,IAAI,CAAC;EACpEC,IAAI,EAAEN,OAAO,IAAIP,WAAW,CAACQ,GAAG,CAACC,MAAM,CAACF,OAAO,CAAC,EAAEN,YAAY,CAACa,IAAI,CAAC;EACpEC,KAAK,EAAER,OAAO,IAAIP,W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Y;IAAE,GAAGC;EAAW,CAAC,GAAGF,OAAO;EAC/C;EACA,OAAOE,UAAU;AACrB","ignoreList":[]}
@@ -4,9 +4,11 @@
4
4
  * Copyright 2016-Present Datadog, Inc.
5
5
  */
6
6
 
7
- import { ErrorCode, GeneralError, InvalidContextError, ProviderEvents, ProviderNotReadyError } from '@openfeature/web-sdk';
7
+ import { InternalLog, SdkVerbosity } from '@datadog/mobile-react-native';
8
+ import { ErrorCode, GeneralError, InvalidContextError, ParseError, ProviderEvents, ProviderNotReadyError } from '@openfeature/web-sdk';
8
9
  import { DatadogCoreOpenFeatureProvider } from './coreProvider';
9
10
  import { isEmptyContext, toDdContext } from './mappers';
11
+ import { OfflineEvaluation } from './offlineEvaluation';
10
12
 
11
13
  // The outcome of a `FlagsClient` reconcile. Derived from the client so the provider maps it to
12
14
  // OpenFeature transitions; not part of the package's public API.
@@ -18,21 +20,26 @@ import { isEmptyContext, toDdContext } from './mappers';
18
20
  const OF_ERROR_CODE = {
19
21
  INVALID_CONTEXT: ErrorCode.INVALID_CONTEXT,
20
22
  PROVIDER_NOT_READY: ErrorCode.PROVIDER_NOT_READY,
23
+ PARSE_ERROR: ErrorCode.PARSE_ERROR,
21
24
  GENERAL: ErrorCode.GENERAL
22
25
  };
23
26
 
24
27
  /**
25
28
  * An offline Datadog OpenFeature provider.
26
29
  *
27
- * It behaves like the online `DatadogOpenFeatureProvider` — same flag evaluation and
28
- * exposure/RUM tracking — **except it never fetches configuration from the network**.
30
+ * Delegates precomputed and rules-based evaluation to `DatadogCoreProvider`, while preserving
31
+ * named native clients and exposure/RUM tracking. It never fetches configuration from the network.
29
32
  * Instead of fetching on `initialize`/`onContextChange`, it evaluates against a configuration
30
33
  * supplied via {@link DatadogOfflineOpenFeatureProvider.setConfiguration}. A precomputed
31
34
  * configuration carries the evaluation context it was computed for, so you should **not** call
32
35
  * `OpenFeature.setContext` for the offline precomputed flow — see the class remarks.
33
36
  *
34
- * A runtime context that does not match the configuration's embedded context (compared after
35
- * normalization) cannot be served (offline never fetches), so it puts the provider into the
37
+ * Rules are evaluated locally for the supplied context. A missing/null targeting key is not an
38
+ * anonymous subject: an evaluation that reaches a shard on the targeting key returns
39
+ * TARGETING_KEY_MISSING, while an explicit empty string remains a valid targeting key.
40
+ * Precomputed context normalization/adoption is unchanged.
41
+ * Without usable rules, a runtime context that does not match the precomputed configuration's embedded context (after normalization)
42
+ * cannot be served (offline never fetches), so it puts the provider into the
36
43
  * OpenFeature `ERROR` state and evaluations fall back to your coded defaults (`INVALID_CONTEXT`).
37
44
  * An empty *effective* context re-adopts the embedded context and recovers — but note that
38
45
  * `clearContext(domain)` falls back to the global context, which may itself be non-empty and
@@ -90,11 +97,12 @@ export class DatadogOfflineOpenFeatureProvider extends DatadogCoreOpenFeaturePro
90
97
  /**
91
98
  * Load a configuration into the provider for offline evaluation.
92
99
  *
93
- * @param configuration A configuration parsed from a `ConfigurationWire` string via
94
- * `configurationFromString`.
100
+ * @param configuration A precomputed or rules-based configuration parsed with
101
+ * `coreConfigurationFromString` from the `/rules-based` entry point. The existing precomputed-only `configurationFromString`
102
+ * output remains supported.
95
103
  */
96
104
  setConfiguration(configuration) {
97
- const result = this.flagsClient.setConfiguration(configuration);
105
+ const result = this.installConfiguration(configuration);
98
106
  if (result.status === 'ready') {
99
107
  if (this.configurationInError) {
100
108
  // Recover from a prior error: PROVIDER_READY clears the ERROR status (a bare
@@ -113,12 +121,38 @@ export class DatadogOfflineOpenFeatureProvider extends DatadogCoreOpenFeaturePro
113
121
  this.events.emit(ProviderEvents.Error, details);
114
122
  }
115
123
  }
124
+ installConfiguration(configuration) {
125
+ if (typeof this.flagsClient.__ddSetOfflineEvaluator === 'function') {
126
+ return this.flagsClient.__ddSetOfflineEvaluator(helpers => new OfflineEvaluation(configuration, helpers));
127
+ }
128
+
129
+ // Older core SDKs predate the evaluator bridge. Keep their released precomputed behavior,
130
+ // but never silently ignore usable rules or keep serving a stale configuration when they
131
+ // are supplied. A rules parse error has no rules to ignore, so precomputed data still loads.
132
+ if (configuration?.rules) {
133
+ InternalLog.log('DatadogOfflineOpenFeatureProvider rules-based evaluation requires an updated @datadog/mobile-react-native SDK. Update both Datadog packages together.', SdkVerbosity.WARN);
134
+ this.flagsClient.setConfiguration({});
135
+ return {
136
+ status: 'error',
137
+ errorCode: 'GENERAL'
138
+ };
139
+ }
140
+ return this.flagsClient.setConfiguration(configuration);
141
+ }
116
142
  applyContext(context) {
117
143
  // An empty context means "no external override": clear it so a loaded precomputed
118
144
  // configuration is served against its embedded context. Order-independent — the synthetic
119
145
  // `initialize({})`, `setContext({})`, and `clearContext()` all re-adopt the embedded
120
146
  // context rather than being treated as a mismatch.
121
- const result = isEmptyContext(context) ? this.flagsClient.resetEvaluationContextWithoutFetching() : this.flagsClient.setEvaluationContextWithoutFetching(toDdContext(context));
147
+ let result;
148
+ if (isEmptyContext(context)) {
149
+ result = this.flagsClient.resetEvaluationContextWithoutFetching();
150
+ } else if (typeof this.flagsClient.__ddSetOfflineEvaluationContext === 'function') {
151
+ result = this.flagsClient.__ddSetOfflineEvaluationContext(toDdContext(context), typeof context.targetingKey === 'string');
152
+ } else {
153
+ // Older core SDKs retain their precomputed-only context behavior.
154
+ result = this.flagsClient.setEvaluationContextWithoutFetching(toDdContext(context));
155
+ }
122
156
  this.configurationInError = result.status === 'error';
123
157
  return result;
124
158
  }
@@ -135,6 +169,8 @@ export class DatadogOfflineOpenFeatureProvider extends DatadogCoreOpenFeaturePro
135
169
  return new InvalidContextError('The evaluation context does not match the offline precomputed configuration. Serving default values.');
136
170
  case 'PROVIDER_NOT_READY':
137
171
  return new ProviderNotReadyError('The Datadog offline provider has no configuration loaded. Provide one via setConfiguration.');
172
+ case 'PARSE_ERROR':
173
+ return new ParseError('The Datadog offline provider cannot parse the loaded configuration.');
138
174
  default:
139
175
  return new GeneralError('The Datadog offline provider cannot serve the loaded configuration.');
140
176
  }
@@ -1 +1 @@
1
- {"version":3,"names":["ErrorCode","GeneralError","InvalidContextError","ProviderEvents","ProviderNotReadyError","DatadogCoreOpenFeatureProvider","isEmptyContext","toDdContext","OF_ERROR_CODE","INVALID_CONTEXT","PROVIDER_NOT_READY","GENERAL","DatadogOfflineOpenFeatureProvider","metadata","name","configurationInError","initialize","context","result","applyContext","status","toError","errorCode","onContextChange","_oldContext","newContext","setConfiguration","configuration","flagsClient","events","emit","Ready","ConfigurationChanged","details","message","Error","resetEvaluationContextWithoutFetching","setEvaluationContextWithoutFetching"],"sourceRoot":"../../src","sources":["offlineProvider.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAMA,SACIA,SAAS,EACTC,YAAY,EACZC,mBAAmB,EACnBC,cAAc,EACdC,qBAAqB,QAClB,sBAAsB;AAO7B,SAASC,8BAA8B,QAAQ,gBAAgB;AAC/D,SAASC,cAAc,EAAEC,WAAW,QAAQ,WAAW;;AAEvD;AACA;;AAOA;AACA;AACA;;AAGA,MAAMC,aAAwD,GAAG;EAC7DC,eAAe,EAAET,SAAS,CAACS,eAAe;EAC1CC,kBAAkB,EAAEV,SAAS,CAACU,kBAAkB;EAChDC,OAAO,EAAEX,SAAS,CAACW;AACvB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,iCAAiC,SAASP,8BAA8B,CAAC;EACzEQ,QAAQ,GAAqB;IAClCC,IAAI,EAAE;EACV,CAAC;;EAED;EACA;EACA;EACA;EACQC,oBAAoB,GAAG,KAAK;EAEpC,MAAMC,UAAUA,CAACC,OAA4B,GAAG,CAAC,CAAC,EAAiB;IAC/D,MAAMC,MAAM,GAAG,IAAI,CAACC,YAAY,CAACF,OAAO,CAAC;;IAEzC;IACA;IACA;IACA;IACA,IAAIC,MAAM,CAACE,MAAM,KAAK,OAAO,EAAE;MAC3B,MAAM,IA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AACU,OAAO,CACvB,CAAC;IAEP,IAAI,CAACF,oBAAoB,GAAGG,MAAM,CAACE,MAAM,KAAK,OAAO;IAErD,OAAOF,MAAM;EACjB;;EAEA;AACJ;AACA;AACA;AACA;AACA;EACYG,OAAOA,CAACC,SAAiC,EAAoB;IACjE,QAAQA,SAAS;MACb,KAAK,iBAAiB;QAClB,OAAO,IAAIpB,mBAAmB,CAC1B,sGACJ,CAAC;MACL,KAAK,oBAAoB;QACrB,OAAO,IAAIE,qBAAqB,CAC5B,6FACJ,CAAC;MACL;QACI,OAAO,IAAIH,YAAY,CACnB,qEACJ,CAAC;IACT;EACJ;AACJ","ignoreList":[]}
1
+ {"version":3,"names":["InternalLog","SdkVerbosity","ErrorCode","GeneralError","InvalidContextError","ParseError","ProviderEvents","ProviderNotReadyError","DatadogCoreOpenFeatureProvider","isEmptyContext","toDdContext","OfflineEvaluation","OF_ERROR_CODE","INVALID_CONTEXT","PROVIDER_NOT_READY","PARSE_ERROR","GENERAL","DatadogOfflineOpenFeatureProvider","metadata","name","configurationInError","initialize","context","result","applyContext","status","toError","errorCode","onContextChange","_oldContext","newContext","setConfiguration","configuration","installConfiguration","events","emit","Ready","ConfigurationChanged","details","message","Error","flagsClient","__ddSetOfflineEvaluator","helpers","rules","log","WARN","resetEvaluationContextWithoutFetching","__ddSetOfflineEvaluationContext","targetingKey","setEvaluationContextWithoutFetching"],"sourceRoot":"../../src","sources":["offlineProvider.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAGA,SAASA,WAAW,EAAEC,YAAY,QAAQ,8BAA8B;AAKxE,SACIC,SAAS,EACTC,YAAY,EACZC,mBAAmB,EACnBC,UAAU,EACVC,cAAc,EACdC,qBAAqB,QAClB,sBAAsB;AAO7B,SAASC,8BAA8B,QAAQ,gBAAgB;AAC/D,SAASC,cAAc,EAAEC,WAAW,QAAQ,WAAW;AACvD,SAASC,iBAAiB,QAAQ,qBAAqB;;AAEvD;AACA;;AAOA;AACA;AACA;;AAGA,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CAACM,qCAAqC,CAAC,CAAC;IACrE,CAAC,MAAM,IACH,OAAO,IAAI,CAACN,WAAW,CAACO,+BAA+B,KACvD,UAAU,EACZ;MACEzB,MAAM,GAAG,IAAI,CAACkB,WAAW,CAACO,+BAA+B,CACrDtC,WAAW,CAACY,OAAO,CAAC,EACpB,OAAOA,OAAO,CAAC2B,YAAY,KAAK,QACpC,CAAC;IACL,CAAC,MAAM;MACH;MACA1B,MAAM,GAAG,IAAI,CAACkB,WAAW,CAACS,mCAAmC,CACzDxC,WAAW,CAACY,OAAO,CACvB,CAAC;IACL;IAEA,IAAI,CAACF,oBAAoB,GAAGG,MAAM,CAACE,MAAM,KAAK,OAAO;IAErD,OAAOF,MAAM;EACjB;;EAEA;AACJ;AACA;AACA;AACA;AACA;EACYG,OAAOA,CAACC,SAAiC,EAAoB;IACjE,QAAQA,SAAS;MACb,KAAK,iBAAiB;QAClB,OAAO,IAAIvB,mBAAmB,CAC1B,sGACJ,CAAC;MACL,KAAK,oBAAoB;QACrB,OAAO,IAAIG,qBAAqB,CAC5B,6FACJ,CAAC;MACL,KAAK,aAAa;QACd,OAAO,IAAIF,UAAU,CACjB,qEACJ,CAAC;MACL;QACI,OAAO,IAAIF,YAAY,CACnB,qEACJ,CAAC;IACT;EACJ;AACJ","ignoreList":[]}
@@ -0,0 +1,50 @@
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 { configurationToString } from '@datadog/flagging-core/rules-based';
8
+ import { getMD5Hash } from '@datadog/flagging-core';
9
+ import { DatadogCoreEvaluationProvider } from './datadogCoreProvider';
10
+
11
+ // Rules parsing loads Protobuf-ES. Keep it behind this entry, as the browser SDK does.
12
+ export { configurationFromString as coreConfigurationFromString } from '@datadog/flagging-core/rules-based';
13
+ /**
14
+ * Evaluates manually supplied precomputed or rules-based configurations in JavaScript using
15
+ * @datadog/flagging-core. Ported from openfeature-js-client's browser DatadogCoreProvider.
16
+ *
17
+ * Unlike the native-backed providers, this provider does not use DdFlags, fetch configuration,
18
+ * or send exposure/RUM events. Load a configuration before registering it with OpenFeature.
19
+ * Precomputed configurations require a matching OpenFeature context, including when it is empty.
20
+ */
21
+ export class DatadogCoreProvider extends DatadogCoreEvaluationProvider {
22
+ fallbackConfigurationSequence = 0;
23
+ computeConfigurationId(configuration) {
24
+ try {
25
+ // Retrieval metadata and the UFC build timestamp can change without changing rules.
26
+ // The backend's semantic Fingerprint() also excludes the rules' CreatedAt.
27
+ return getMD5Hash(configurationToString({
28
+ ...configuration,
29
+ precomputed: configuration.precomputed && {
30
+ ...configuration.precomputed,
31
+ fetchedAt: undefined,
32
+ etag: undefined
33
+ },
34
+ rules: configuration.rules && {
35
+ ...configuration.rules,
36
+ response: {
37
+ ...configuration.rules.response,
38
+ createdAt: undefined
39
+ },
40
+ fetchedAt: undefined,
41
+ etag: undefined
42
+ }
43
+ }));
44
+ } catch {
45
+ this.fallbackConfigurationSequence += 1;
46
+ return `core-configuration-${this.fallbackConfigurationSequence}`;
47
+ }
48
+ }
49
+ }
50
+ //# sourceMappingURL=rules-based.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["configurationToString","getMD5Hash","DatadogCoreEvaluationProvider","configurationFromString","coreConfigurationFromString","DatadogCoreProvider","fallbackConfigurationSequence","computeConfigurationId","configuration","precomputed","fetchedAt","undefined","etag","rules","response","createdAt"],"sourceRoot":"../../src","sources":["rules-based.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA,SAASA,qBAAqB,QAAQ,oCAAoC;AAC1E,SAASC,UAAU,QAAQ,wBAAwB;AAGnD,SAASC,6BAA6B,QAAQ,uBAAuB;;AAErE;AACA,SAASC,uBAAuB,IAAIC,2BAA2B,QAAQ,oCAAoC;AAG3G;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,SAASH,6BAA6B,CAAC;EAC3DI,6BAA6B,GAAG,CAAC;EAE/BC,sBAAsBA,CAC5BC,aAAiC,EAC3B;IACN,IAAI;MACA;MACA;MACA,OAAOP,UAAU,CACbD,qBAAqB,CAAC;QAClB,GAAGQ,aAAa;QAChBC,WAAW,EAAED,aAAa,CAACC,WAAW,IAAI;UACtC,GAAGD,aAAa,CAACC,WAAW;UAC5BC,SAAS,EAAEC,SAAS;UACpBC,IAAI,EAAED;QACV,CAAC;QACDE,KAAK,EAAEL,aAAa,CAACK,KAAK,IAAI;UAC1B,GAAGL,aAAa,CAACK,KAAK;UACtBC,QAAQ,EAAE;YACN,GAAGN,aAAa,CAACK,KAAK,CAACC,QAAQ;YAC/BC,SAAS,EAAEJ;UACf,CAAC;UACDD,SAAS,EAAEC,SAAS;UACpBC,IAAI,EAAED;QACV;MACJ,CAAC,CACL,CAAC;IACL,CAAC,CAAC,MAAM;MACJ,IAAI,CAACL,6BAA6B,IAAI,CAAC;MACvC,OAAO,sBAAsB,IAAI,CAACA,6BAA6B,EAAE;IACrE;EACJ;AACJ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"FileBasedConfiguration.d.ts","sourceRoot":"","sources":["../../../../../../core/src/config/FileBasedConfiguration.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAEnF,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AA8BvE,qBAAa,sBAAuB,SAAQ,4BAA4B;gBACxD,MAAM,CAAC,EAAE;QACjB,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;QACpC,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;QAC1C,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;KACzC;CAqEJ;AAmBD,eAAO,MAAM,oBAAoB,+BACD,OAAO,KACpC,iBAyFF,CAAC;AAuBF,eAAO,MAAM,oBAAoB,mBACb,MAAM,KACvB,cAoBF,CAAC"}
1
+ {"version":3,"file":"FileBasedConfiguration.d.ts","sourceRoot":"","sources":["../../../../../../core/src/config/FileBasedConfiguration.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAEnF,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAC9E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AA8BvE,qBAAa,sBAAuB,SAAQ,4BAA4B;gBACxD,MAAM,CAAC,EAAE;QACjB,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;QACpC,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;QAC1C,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;KACzC;CAqEJ;AAmBD,eAAO,MAAM,oBAAoB,+BACD,OAAO,KACpC,iBA8FF,CAAC;AAuBF,eAAO,MAAM,oBAAoB,mBACb,MAAM,KACvB,cAoBF,CAAC"}
@@ -31,6 +31,8 @@ export interface JsonConfiguration extends CoreConfigurationOptions {
31
31
  nativeLongTaskThresholdMs?: number;
32
32
  nativeViewTracking?: boolean;
33
33
  nativeInteractionTracking?: boolean;
34
+ nativeIosResourceTracking?: boolean;
35
+ nativeIosResourceTrackingDisallowList?: string[];
34
36
  customEndpoint?: string;
35
37
  sessionSampleRate?: number;
36
38
  resourceTraceSampleRate?: number;