@datadog/mobile-react-native 3.0.3 → 3.1.1
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.
- package/DatadogSDKReactNative.podspec +10 -9
- package/android/build.gradle +10 -8
- package/android/src/main/kotlin/com/datadog/reactnative/DdFlagsImplementation.kt +237 -0
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkBridgeExt.kt +262 -78
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfiguration.kt +3 -3
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkConfigurationExt.kt +18 -18
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkNativeInitialization.kt +3 -2
- package/android/src/main/kotlin/com/datadog/reactnative/DdSdkReactNativePackage.kt +3 -1
- package/android/src/main/kotlin/com/datadog/reactnative/SdkVersion.kt +1 -1
- package/android/src/newarch/kotlin/com/datadog/reactnative/DdFlags.kt +66 -0
- package/android/src/oldarch/kotlin/com/datadog/reactnative/DdFlags.kt +63 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkBridgeExtTest.kt +242 -0
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkNativeInitializationTest.kt +4 -2
- package/android/src/test/kotlin/com/datadog/reactnative/DdSdkTest.kt +6 -3
- package/android/src/test/kotlin/com/datadog/tools/unit/DdSdkConfigurationExt.kt +3 -4
- package/android/src/test/kotlin/com/datadog/tools/unit/MapExt.kt +38 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/MockRumMonitor.kt +3 -0
- package/android/src/test/kotlin/com/datadog/tools/unit/forge/DdSdkConfigurationForgeryFactory.kt +1 -1
- package/android/src/test/resources/input/complete-configuration.json +10 -10
- package/ios/Sources/DatadogSDKReactNative.h +2 -0
- package/ios/Sources/DdFlags.h +24 -0
- package/ios/Sources/DdFlags.mm +83 -0
- package/ios/Sources/DdFlagsImplementation.swift +263 -0
- package/ios/Sources/DdSdkConfiguration.swift +4 -4
- package/ios/Sources/DdSdkNativeInitialization.swift +2 -2
- package/ios/Sources/RNDdSdkConfiguration.swift +11 -9
- package/ios/Sources/SdkVersion.swift +1 -1
- package/lib/commonjs/InternalLog.js +9 -7
- package/lib/commonjs/InternalLog.js.map +1 -1
- package/lib/commonjs/flags/DdFlags.js +51 -0
- package/lib/commonjs/flags/DdFlags.js.map +1 -0
- package/lib/commonjs/flags/FlagsClient.js +218 -0
- package/lib/commonjs/flags/FlagsClient.js.map +1 -0
- package/lib/commonjs/flags/internal.js +40 -0
- package/lib/commonjs/flags/internal.js.map +1 -0
- package/lib/commonjs/flags/types.js +6 -0
- package/lib/commonjs/flags/types.js.map +1 -0
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/sdk/DatadogProvider/Buffer/BufferSingleton.js +10 -8
- package/lib/commonjs/sdk/DatadogProvider/Buffer/BufferSingleton.js.map +1 -1
- package/lib/commonjs/specs/NativeDdFlags.js +19 -0
- package/lib/commonjs/specs/NativeDdFlags.js.map +1 -0
- package/lib/commonjs/version.js +1 -1
- package/lib/module/InternalLog.js +9 -6
- package/lib/module/InternalLog.js.map +1 -1
- package/lib/module/flags/DdFlags.js +45 -0
- package/lib/module/flags/DdFlags.js.map +1 -0
- package/lib/module/flags/FlagsClient.js +211 -0
- package/lib/module/flags/FlagsClient.js.map +1 -0
- package/lib/module/flags/internal.js +33 -0
- package/lib/module/flags/internal.js.map +1 -0
- package/lib/module/flags/types.js +2 -0
- package/lib/module/flags/types.js.map +1 -0
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/sdk/DatadogProvider/Buffer/BufferSingleton.js +10 -7
- package/lib/module/sdk/DatadogProvider/Buffer/BufferSingleton.js.map +1 -1
- package/lib/module/specs/NativeDdFlags.js +17 -0
- package/lib/module/specs/NativeDdFlags.js.map +1 -0
- package/lib/module/version.js +1 -1
- package/lib/typescript/InternalLog.d.ts +6 -4
- package/lib/typescript/InternalLog.d.ts.map +1 -1
- package/lib/typescript/flags/DdFlags.d.ts +3 -0
- package/lib/typescript/flags/DdFlags.d.ts.map +1 -0
- package/lib/typescript/flags/FlagsClient.d.ts +114 -0
- package/lib/typescript/flags/FlagsClient.d.ts.map +1 -0
- package/lib/typescript/flags/internal.d.ts +14 -0
- package/lib/typescript/flags/internal.d.ts.map +1 -0
- package/lib/typescript/flags/types.d.ts +202 -0
- package/lib/typescript/flags/types.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +5 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/nativeModulesTypes.d.ts +5 -0
- package/lib/typescript/nativeModulesTypes.d.ts.map +1 -1
- package/lib/typescript/sdk/DatadogProvider/Buffer/BufferSingleton.d.ts +7 -5
- package/lib/typescript/sdk/DatadogProvider/Buffer/BufferSingleton.d.ts.map +1 -1
- package/lib/typescript/specs/NativeDdFlags.d.ts +15 -0
- package/lib/typescript/specs/NativeDdFlags.d.ts.map +1 -0
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +2 -2
- package/src/InternalLog.tsx +14 -6
- package/src/flags/DdFlags.ts +59 -0
- package/src/flags/FlagsClient.ts +266 -0
- package/src/flags/__tests__/DdFlags.test.ts +65 -0
- package/src/flags/__tests__/FlagsClient.test.ts +320 -0
- package/src/flags/internal.ts +63 -0
- package/src/flags/types.ts +215 -0
- package/src/index.tsx +15 -1
- package/src/nativeModulesTypes.ts +6 -0
- package/src/sdk/DatadogProvider/Buffer/BufferSingleton.ts +16 -7
- package/src/specs/NativeDdFlags.ts +35 -0
- package/src/version.ts +1 -1
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.FlagsClient = void 0;
|
|
7
|
+
var _InternalLog = require("../InternalLog");
|
|
8
|
+
var _SdkVerbosity = require("../config/types/SdkVerbosity");
|
|
9
|
+
var _internal = require("./internal");
|
|
10
|
+
/*
|
|
11
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
12
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
13
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
class FlagsClient {
|
|
17
|
+
// eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
|
|
18
|
+
nativeFlags = require('../specs/NativeDdFlags').default;
|
|
19
|
+
evaluationContext = undefined;
|
|
20
|
+
flagsCache = {};
|
|
21
|
+
constructor(clientName = 'default') {
|
|
22
|
+
this.clientName = clientName;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Sets the evaluation context for the client.
|
|
27
|
+
*
|
|
28
|
+
* Should be called before evaluating any flags. Otherwise, the client will fall back to serving default flag values.
|
|
29
|
+
*
|
|
30
|
+
* Throws an error if there is an error setting the evaluation context and logs an error message.
|
|
31
|
+
*
|
|
32
|
+
* @param context The evaluation context to associate with the current client.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* const flagsClient = DdFlags.getClient();
|
|
37
|
+
*
|
|
38
|
+
* await flagsClient.setEvaluationContext({
|
|
39
|
+
* targetingKey: 'user-123',
|
|
40
|
+
* attributes: {
|
|
41
|
+
* favoriteFruit: 'apple'
|
|
42
|
+
* }
|
|
43
|
+
* });
|
|
44
|
+
*
|
|
45
|
+
* const flagValue = flagsClient.getBooleanValue('new-feature', false);
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
setEvaluationContext = async context => {
|
|
49
|
+
// Make sure to process the incoming context because we don't support nested object values in context.
|
|
50
|
+
const processedContext = (0, _internal.processEvaluationContext)(context);
|
|
51
|
+
try {
|
|
52
|
+
const result = await this.nativeFlags.setEvaluationContext(this.clientName, processedContext.targetingKey, processedContext.attributes ?? {});
|
|
53
|
+
this.evaluationContext = processedContext;
|
|
54
|
+
this.flagsCache = result;
|
|
55
|
+
} catch (error) {
|
|
56
|
+
if (error instanceof Error) {
|
|
57
|
+
_InternalLog.InternalLog.log(`Error setting flag evaluation context: ${error.message}`, _SdkVerbosity.SdkVerbosity.WARN);
|
|
58
|
+
}
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
track = (flag, context) => {
|
|
63
|
+
// A non-blocking call; don't await this.
|
|
64
|
+
this.nativeFlags.trackEvaluation(this.clientName, flag.key, flag, context.targetingKey, context.attributes ?? {}).catch(error => {
|
|
65
|
+
if (error instanceof Error) {
|
|
66
|
+
_InternalLog.InternalLog.log(`Error tracking flag evaluation: ${error.message}`, _SdkVerbosity.SdkVerbosity.WARN);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
getDetails = (key, defaultValue, type) => {
|
|
71
|
+
if (!this.evaluationContext) {
|
|
72
|
+
return {
|
|
73
|
+
key,
|
|
74
|
+
value: defaultValue,
|
|
75
|
+
reason: 'ERROR',
|
|
76
|
+
errorCode: 'PROVIDER_NOT_READY',
|
|
77
|
+
errorMessage: `The evaluation context is not set for '${this.clientName}'. Please, set context before evaluating any flags.`
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Retrieve the flag from the cache.
|
|
82
|
+
const flag = this.flagsCache[key];
|
|
83
|
+
if (!flag) {
|
|
84
|
+
return {
|
|
85
|
+
key,
|
|
86
|
+
value: defaultValue,
|
|
87
|
+
reason: 'ERROR',
|
|
88
|
+
errorCode: 'FLAG_NOT_FOUND'
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Validate the expected type against the actual flag value type.
|
|
93
|
+
const actualType = typeof flag.value;
|
|
94
|
+
if (actualType !== type) {
|
|
95
|
+
return {
|
|
96
|
+
key,
|
|
97
|
+
value: defaultValue,
|
|
98
|
+
reason: 'ERROR',
|
|
99
|
+
errorCode: 'TYPE_MISMATCH',
|
|
100
|
+
errorMessage: `Flag "${key}" returned a value of type "${typeof flag.value}". Use the corresponding method instead of the one expecting "${type}".`
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
this.track(flag, this.evaluationContext);
|
|
104
|
+
const details = {
|
|
105
|
+
key: flag.key,
|
|
106
|
+
value: flag.value,
|
|
107
|
+
variant: flag.variationKey,
|
|
108
|
+
allocationKey: flag.allocationKey,
|
|
109
|
+
reason: flag.reason
|
|
110
|
+
};
|
|
111
|
+
return details;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Evaluate a boolean feature flag with detailed evaluation information.
|
|
116
|
+
*
|
|
117
|
+
* @param key The key of the flag to evaluate.
|
|
118
|
+
* @param defaultValue Fallback value for when flag evaluation fails, flag is not found, or the client does not have an evaluation context set.
|
|
119
|
+
*/
|
|
120
|
+
getBooleanDetails = (key, defaultValue) => {
|
|
121
|
+
return this.getDetails(key, defaultValue, 'boolean');
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Evaluate a string feature flag with detailed evaluation information.
|
|
126
|
+
*
|
|
127
|
+
* @param key The key of the flag to evaluate.
|
|
128
|
+
* @param defaultValue Fallback value for when flag evaluation fails, flag is not found, or the client does not have an evaluation context set.
|
|
129
|
+
*/
|
|
130
|
+
getStringDetails = (key, defaultValue) => {
|
|
131
|
+
return this.getDetails(key, defaultValue, 'string');
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Evaluate a number feature flag with detailed evaluation information.
|
|
136
|
+
*
|
|
137
|
+
* @param key The key of the flag to evaluate.
|
|
138
|
+
* @param defaultValue Fallback value for when flag evaluation fails, flag is not found, or the client does not have an evaluation context set.
|
|
139
|
+
*/
|
|
140
|
+
getNumberDetails = (key, defaultValue) => {
|
|
141
|
+
return this.getDetails(key, defaultValue, 'number');
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Evaluate a JSON feature flag with detailed evaluation information.
|
|
146
|
+
*
|
|
147
|
+
* Even though the `defaultValue` is typed as `JsonValue`, the flag value should be a valid JSON object.
|
|
148
|
+
* Please use other typed methods to evaluate flags with primitive values.
|
|
149
|
+
*
|
|
150
|
+
* @param key The key of the flag to evaluate.
|
|
151
|
+
* @param defaultValue Fallback value for when flag evaluation fails, flag is not found, or the client does not have an evaluation context set.
|
|
152
|
+
*/
|
|
153
|
+
getObjectDetails = (key, defaultValue) => {
|
|
154
|
+
return this.getDetails(key, defaultValue, 'object');
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Evaluate a boolean feature flag value.
|
|
159
|
+
*
|
|
160
|
+
* @param key The key of the flag to evaluate.
|
|
161
|
+
* @param defaultValue Fallback value for when flag evaluation fails, flag is not found, or the client does not have an evaluation context set.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```ts
|
|
165
|
+
* const isNewFeatureEnabled = flagsClient.getBooleanValue('new-feature-enabled', false);
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
getBooleanValue = (key, defaultValue) => {
|
|
169
|
+
return this.getBooleanDetails(key, defaultValue).value;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Evaluate a string feature flag value.
|
|
174
|
+
*
|
|
175
|
+
* @param key The key of the flag to evaluate.
|
|
176
|
+
* @param defaultValue Fallback value for when flag evaluation fails, flag is not found, or the client does not have an evaluation context set.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```ts
|
|
180
|
+
* const appTheme = flagsClient.getStringValue('app-theme', 'light');
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
183
|
+
getStringValue = (key, defaultValue) => {
|
|
184
|
+
return this.getStringDetails(key, defaultValue).value;
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Evaluate a number feature flag value.
|
|
189
|
+
*
|
|
190
|
+
* @param key The key of the flag to evaluate.
|
|
191
|
+
* @param defaultValue Fallback value for when flag evaluation fails, flag is not found, or the client does not have an evaluation context set.
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* ```ts
|
|
195
|
+
* const ctaButtonSize = flagsClient.getNumberValue('cta-button-size', 16);
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
getNumberValue = (key, defaultValue) => {
|
|
199
|
+
return this.getNumberDetails(key, defaultValue).value;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Evaluate an object feature flag value.
|
|
204
|
+
*
|
|
205
|
+
* @param key The key of the flag to evaluate.
|
|
206
|
+
* @param defaultValue Fallback value for when flag evaluation fails, flag is not found, or the client does not have an evaluation context set.
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* ```ts
|
|
210
|
+
* const pageCalloutOptions = flagsClient.getObjectValue('page-callout', { color: 'purple', text: 'Woof!' });
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
getObjectValue = (key, defaultValue) => {
|
|
214
|
+
return this.getObjectDetails(key, defaultValue).value;
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
exports.FlagsClient = FlagsClient;
|
|
218
|
+
//# sourceMappingURL=FlagsClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_InternalLog","require","_SdkVerbosity","_internal","FlagsClient","nativeFlags","default","evaluationContext","undefined","flagsCache","constructor","clientName","setEvaluationContext","context","processedContext","processEvaluationContext","result","targetingKey","attributes","error","Error","InternalLog","log","message","SdkVerbosity","WARN","track","flag","trackEvaluation","key","catch","getDetails","defaultValue","type","value","reason","errorCode","errorMessage","actualType","details","variant","variationKey","allocationKey","getBooleanDetails","getStringDetails","getNumberDetails","getObjectDetails","getBooleanValue","getStringValue","getNumberValue","getObjectValue","exports"],"sourceRoot":"../../../src","sources":["flags/FlagsClient.ts"],"mappings":";;;;;;AAMA,IAAAA,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A;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACIe,cAAc,GAAGA,CAACpB,GAAW,EAAEG,YAAoB,KAAa;IAC5D,OAAO,IAAI,CAACa,gBAAgB,CAAChB,GAAG,EAAEG,YAAY,CAAC,CAACE,KAAK;EACzD,CAAC;;EAED;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACIgB,cAAc,GAAGA,CAAsBrB,GAAW,EAAEG,YAAe,KAAQ;IACvE,OAAO,IAAI,CAACc,gBAAgB,CAACjB,GAAG,EAAEG,YAAY,CAAC,CAACE,KAAK;EACzD,CAAC;AACL;AAACiB,OAAA,CAAA/C,WAAA,GAAAA,WAAA","ignoreList":[]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.processEvaluationContext = void 0;
|
|
7
|
+
var _InternalLog = require("../InternalLog");
|
|
8
|
+
var _SdkVerbosity = require("../config/types/SdkVerbosity");
|
|
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
|
+
const processEvaluationContext = context => {
|
|
16
|
+
const {
|
|
17
|
+
targetingKey
|
|
18
|
+
} = context;
|
|
19
|
+
|
|
20
|
+
// We should ignore non-primitive values in the context as per FFE SDK requirements OF.3.
|
|
21
|
+
const providedAttributes = context.attributes ?? {};
|
|
22
|
+
const attributes = {};
|
|
23
|
+
for (const [key, value] of Object.entries(providedAttributes)) {
|
|
24
|
+
const isPrimitiveValue = typeof value === 'boolean' || typeof value === 'string' || typeof value === 'number' || value === undefined || value === null;
|
|
25
|
+
if (!isPrimitiveValue) {
|
|
26
|
+
_InternalLog.InternalLog.log(`Non-primitive context value under "${key}" is not supported. Omitting this attribute from the evaluation context.`, _SdkVerbosity.SdkVerbosity.WARN);
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (value === undefined) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
attributes[key] = value;
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
targetingKey,
|
|
36
|
+
attributes
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
exports.processEvaluationContext = processEvaluationContext;
|
|
40
|
+
//# sourceMappingURL=internal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_InternalLog","require","_SdkVerbosity","processEvaluationContext","context","targetingKey","providedAttributes","attributes","key","value","Object","entries","isPrimitiveValue","undefined","InternalLog","log","SdkVerbosity","WARN","exports"],"sourceRoot":"../../../src","sources":["flags/internal.ts"],"mappings":";;;;;;AAMA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAPA;AACA;AACA;AACA;AACA;;AAmBO,MAAME,wBAAwB,GACjCC,OAA0B,IACN;EACpB,MAAM;IAAEC;EAAa,CAAC,GAAGD,OAAO;;EAEhC;EACA,MAAME,kBAA2C,GAC7CF,OAAO,CAACG,UAAU,IAAI,CAAC,CAAC;EAE5B,MAAMA,UAA0C,GAAG,CAAC,CAAC;EAErD,KAAK,MAAM,CAACC,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACL,kBAAkB,CAAC,EAAE;IAC3D,MAAMM,gBAAgB,GAClB,OAAOH,KAAK,KAAK,SAAS,IAC1B,OAAOA,KAAK,KAAK,QAAQ,IACzB,OAAOA,KAAK,KAAK,QAAQ,IACzBA,KAAK,KAAKI,SAAS,IACnBJ,KAAK,KAAK,IAAI;IAElB,IAAI,CAACG,gBAAgB,EAAE;MACnBE,wBAAW,CAACC,GAAG,CACX,sCAAsCP,GAAG,0EAA0E,EACnHQ,0BAAY,CAACC,IACjB,CAAC;MAED;IACJ;IAEA,IAAIR,KAAK,KAAKI,SAAS,EAAE;MACrB;IACJ;IAEAN,UAAU,CAACC,GAAG,CAAC,GAAGC,KAAK;EAC3B;EAEA,OAAO;IACHJ,YAAY;IACZE;EACJ,CAAC;AACL,CAAC;AAACW,OAAA,CAAAf,wBAAA,GAAAA,wBAAA","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../../src","sources":["flags/types.ts"],"mappings":"","ignoreList":[]}
|
package/lib/commonjs/index.js
CHANGED
|
@@ -69,6 +69,12 @@ Object.defineProperty(exports, "DdBabelInteractionTracking", {
|
|
|
69
69
|
return _DdBabelInteractionTracking.DdBabelInteractionTracking;
|
|
70
70
|
}
|
|
71
71
|
});
|
|
72
|
+
Object.defineProperty(exports, "DdFlags", {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: function () {
|
|
75
|
+
return _DdFlags.DdFlags;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
72
78
|
Object.defineProperty(exports, "DdLogs", {
|
|
73
79
|
enumerable: true,
|
|
74
80
|
get: function () {
|
|
@@ -237,6 +243,7 @@ var _ProxyConfiguration = require("./config/types/ProxyConfiguration");
|
|
|
237
243
|
var _SdkVerbosity = require("./config/types/SdkVerbosity");
|
|
238
244
|
var _TrackingConsent = require("./config/types/TrackingConsent");
|
|
239
245
|
var _types = require("./config/types");
|
|
246
|
+
var _DdFlags = require("./flags/DdFlags");
|
|
240
247
|
var _DdLogs = require("./logs/DdLogs");
|
|
241
248
|
var _DdRum = require("./rum/DdRum");
|
|
242
249
|
var _DdBabelInteractionTracking = require("./rum/instrumentation/interactionTracking/DdBabelInteractionTracking");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_DdSdkReactNative","require","_InternalLog","_DatadogProviderConfiguration","_FileBasedConfiguration","_CoreConfiguration","_LogsConfiguration","_RumConfiguration","_TraceConfiguration","_ProxyConfiguration","_SdkVerbosity","_TrackingConsent","_types","_DdLogs","_DdRum","_DdBabelInteractionTracking","_ddBabelUtils","_DatadogTracingContext","_DatadogTracingIdentifier","_TracingIdentifier","_graphqlHeaders","_types2","_DatadogProvider","_DdSdk","_DdTrace","_types3","_DefaultTimeProvider","_TimeProvider"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"names":["_DdSdkReactNative","require","_InternalLog","_DatadogProviderConfiguration","_FileBasedConfiguration","_CoreConfiguration","_LogsConfiguration","_RumConfiguration","_TraceConfiguration","_ProxyConfiguration","_SdkVerbosity","_TrackingConsent","_types","_DdFlags","_DdLogs","_DdRum","_DdBabelInteractionTracking","_ddBabelUtils","_DatadogTracingContext","_DatadogTracingIdentifier","_TracingIdentifier","_graphqlHeaders","_types2","_DatadogProvider","_DdSdk","_DdTrace","_types3","_DefaultTimeProvider","_TimeProvider"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,6BAAA,GAAAF,OAAA;AACA,IAAAG,uBAAA,GAAAH,OAAA;AAIA,IAAAI,kBAAA,GAAAJ,OAAA;AAEA,IAAAK,kBAAA,GAAAL,OAAA;AAEA,IAAAM,iBAAA,GAAAN,OAAA;AAEA,IAAAO,mBAAA,GAAAP,OAAA;AACA,IAAAQ,mBAAA,GAAAR,OAAA;AAIA,IAAAS,aAAA,GAAAT,OAAA;AACA,IAAAU,gBAAA,GAAAV,OAAA;AACA,IAAAW,MAAA,GAAAX,OAAA;AAOA,IAAAY,QAAA,GAAAZ,OAAA;AAQA,IAAAa,OAAA,GAAAb,OAAA;AACA,IAAAc,MAAA,GAAAd,OAAA;AACA,IAAAe,2BAAA,GAAAf,OAAA;AACA,IAAAgB,aAAA,GAAAhB,OAAA;AACA,IAAAiB,sBAAA,GAAAjB,OAAA;AACA,IAAAkB,yBAAA,GAAAlB,OAAA;AACA,IAAAmB,kBAAA,GAAAnB,OAAA;AAIA,IAAAoB,eAAA,GAAApB,OAAA;AAMA,IAAAqB,OAAA,GAAArB,OAAA;AACA,IAAAsB,gBAAA,GAAAtB,OAAA;AACA,IAAAuB,MAAA,GAAAvB,OAAA;AACA,IAAAwB,QAAA,GAAAxB,OAAA;AACA,IAAAyB,OAAA,GAAAzB,OAAA;AACA,IAAA0B,oBAAA,GAAA1B,OAAA;AAEA,IAAA2B,aAAA,GAAA3B,OAAA","ignoreList":[]}
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.BufferSingleton = void 0;
|
|
7
|
+
var _singletonUtils = require("../../../utils/singletonUtils");
|
|
7
8
|
var _BoundedBuffer = require("./BoundedBuffer");
|
|
8
9
|
var _PassThroughBuffer = require("./PassThroughBuffer");
|
|
9
10
|
/*
|
|
@@ -12,18 +13,19 @@ var _PassThroughBuffer = require("./PassThroughBuffer");
|
|
|
12
13
|
* Copyright 2016-Present Datadog, Inc.
|
|
13
14
|
*/
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
const BUFFER_SINGLETON_MODULE = 'com.datadog.reactnative.buffer_singleton';
|
|
17
|
+
class _BufferSingleton {
|
|
18
|
+
bufferInstance = new _BoundedBuffer.BoundedBuffer();
|
|
19
|
+
getInstance = () => {
|
|
18
20
|
return BufferSingleton.bufferInstance;
|
|
19
21
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
onInitialization = () => {
|
|
23
|
+
this.bufferInstance.drain();
|
|
24
|
+
this.bufferInstance = new _PassThroughBuffer.PassThroughBuffer();
|
|
23
25
|
};
|
|
24
|
-
|
|
26
|
+
reset = () => {
|
|
25
27
|
BufferSingleton.bufferInstance = new _BoundedBuffer.BoundedBuffer();
|
|
26
28
|
};
|
|
27
29
|
}
|
|
28
|
-
exports.BufferSingleton =
|
|
30
|
+
const BufferSingleton = exports.BufferSingleton = (0, _singletonUtils.getGlobalInstance)(BUFFER_SINGLETON_MODULE, () => new _BufferSingleton());
|
|
29
31
|
//# sourceMappingURL=BufferSingleton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_singletonUtils","require","_BoundedBuffer","_PassThroughBuffer","BUFFER_SINGLETON_MODULE","_BufferSingleton","bufferInstance","BoundedBuffer","getInstance","BufferSingleton","onInitialization","drain","PassThroughBuffer","reset","exports","getGlobalInstance"],"sourceRoot":"../../../../../src","sources":["sdk/DatadogProvider/Buffer/BufferSingleton.ts"],"mappings":";;;;;;AAMA,IAAAA,eAAA,GAAAC,OAAA;AAEA,IAAAC,cAAA,GAAAD,OAAA;AAEA,IAAAE,kBAAA,GAAAF,OAAA;AAVA;AACA;AACA;AACA;AACA;;AAQA,MAAMG,uBAAuB,GAAG,0CAA0C;AAE1E,MAAMC,gBAAgB,CAAC;EACXC,cAAc,GAAkB,IAAIC,4BAAa,CAAC,CAAC;EAE3DC,WAAW,GAAGA,CAAA,KAAqB;IAC/B,OAAOC,eAAe,CAACH,cAAc;EACzC,CAAC;EAEDI,gBAAgB,GAAGA,CAAA,KAAM;IACrB,IAAI,CAACJ,cAAc,CAACK,KAAK,CAAC,CAAC;IAC3B,IAAI,CAACL,cAAc,GAAG,IAAIM,oCAAiB,CAAC,CAAC;EACjD,CAAC;EAEDC,KAAK,GAAGA,CAAA,KAAM;IACVJ,eAAe,CAACH,cAAc,GAAG,IAAIC,4BAAa,CAAC,CAAC;EACxD,CAAC;AACL;AAEO,MAAME,eAAe,GAAAK,OAAA,CAAAL,eAAA,GAAG,IAAAM,iCAAiB,EAC5CX,uBAAuB,EACvB,MAAM,IAAIC,gBAAgB,CAAC,CAC/B,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
8
|
+
/*
|
|
9
|
+
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
|
|
10
|
+
* This product includes software developed at Datadog (https://www.datadoghq.com/).
|
|
11
|
+
* Copyright 2016-Present Datadog, Inc.
|
|
12
|
+
*/
|
|
13
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
14
|
+
/**
|
|
15
|
+
* Do not import this Spec directly, use DdNativeFlagsType instead.
|
|
16
|
+
*/
|
|
17
|
+
// eslint-disable-next-line import/no-default-export
|
|
18
|
+
var _default = exports.default = _reactNative.TurboModuleRegistry.get('DdFlags');
|
|
19
|
+
//# sourceMappingURL=NativeDdFlags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","get"],"sourceRoot":"../../../src","sources":["specs/NativeDdFlags.ts"],"mappings":";;;;;;AAQA,IAAAA,YAAA,GAAAC,OAAA;AARA;AACA;AACA;AACA;AACA;AAEA;AAMA;AACA;AACA;AAmBA;AAAA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GACeC,gCAAmB,CAACC,GAAG,CAAO,SAAS,CAAC","ignoreList":[]}
|
package/lib/commonjs/version.js
CHANGED
|
@@ -5,22 +5,24 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { SdkVerbosity } from './config/types/SdkVerbosity';
|
|
8
|
+
import { getGlobalInstance } from './utils/singletonUtils';
|
|
8
9
|
export const DATADOG_MESSAGE_PREFIX = 'DATADOG:';
|
|
10
|
+
const INTERNAL_LOG_MODULE = 'com.datadog.reactnative.internal_log';
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* /!\ DO NOT USE THIS IN YOUR APP /!\\
|
|
12
14
|
*
|
|
13
15
|
* This logger is only for debugging the Datadog SDK.
|
|
14
16
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (
|
|
17
|
+
class _InternalLog {
|
|
18
|
+
levelMap = new Map([[SdkVerbosity.DEBUG, 1], [SdkVerbosity.INFO, 2], [SdkVerbosity.WARN, 3], [SdkVerbosity.ERROR, 4]]);
|
|
19
|
+
verbosity = undefined;
|
|
20
|
+
log(message, verbosity) {
|
|
21
|
+
if (this.verbosity === undefined) {
|
|
20
22
|
return;
|
|
21
23
|
}
|
|
22
24
|
const requiredLevel = InternalLog.levelMap.get(verbosity);
|
|
23
|
-
const allowedLevel = InternalLog.levelMap.get(
|
|
25
|
+
const allowedLevel = InternalLog.levelMap.get(this.verbosity);
|
|
24
26
|
if (allowedLevel === undefined || requiredLevel === undefined) {
|
|
25
27
|
return;
|
|
26
28
|
}
|
|
@@ -39,4 +41,5 @@ export class InternalLog {
|
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
}
|
|
44
|
+
export const InternalLog = getGlobalInstance(INTERNAL_LOG_MODULE, () => new _InternalLog());
|
|
42
45
|
//# sourceMappingURL=InternalLog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["SdkVerbosity","DATADOG_MESSAGE_PREFIX","
|
|
1
|
+
{"version":3,"names":["SdkVerbosity","getGlobalInstance","DATADOG_MESSAGE_PREFIX","INTERNAL_LOG_MODULE","_InternalLog","levelMap","Map","DEBUG","INFO","WARN","ERROR","verbosity","undefined","log","message","requiredLevel","InternalLog","get","allowedLevel","prefixedMessage","console","error","warn","info","debug"],"sourceRoot":"../../src","sources":["InternalLog.tsx"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA,SAASA,YAAY,QAAQ,6BAA6B;AAC1D,SAASC,iBAAiB,QAAQ,wBAAwB;AAE1D,OAAO,MAAMC,sBAAsB,GAAG,UAAU;AAEhD,MAAMC,mBAAmB,GAAG,sCAAsC;;AAElE;AACA;AACA;AACA;AACA;AACA,MAAMC,YAAY,CAAC;EACPC,QAAQ,GAAG,IAAIC,GAAG,CAAuB,CAC7C,CAACN,YAAY,CAACO,KAAK,EAAE,CAAC,CAAC,EACvB,CAACP,YAAY,CAACQ,IAAI,EAAE,CAAC,CAAC,EACtB,CAACR,YAAY,CAACS,IAAI,EAAE,CAAC,CAAC,EACtB,CAACT,YAAY,CAACU,KAAK,EAAE,CAAC,CAAC,CAC1B,CAAC;EAEKC,SAAS,GAA6BC,SAAS;EAE/CC,GAAGA,CAACC,OAAe,EAAEH,SAAuB,EAAQ;IACvD,IAAI,IAAI,CAACA,SAAS,KAAKC,SAAS,EAAE;MAC9B;IACJ;IACA,MAAMG,aAAa,GAAGC,WAAW,CAACX,QAAQ,CAACY,GAAG,CAACN,SAAS,CAAC;IACzD,MAAMO,YAAY,GAAGF,WAAW,CAACX,QAAQ,CAACY,GAAG,CAAC,IAAI,CAACN,SAAS,CAAC;IAC7D,IAAIO,YAAY,KAAKN,SAAS,IAAIG,aAAa,KAAKH,SAAS,EAAE;MAC3D;IACJ;IACA,MAAMO,eAAe,GAAG,GAAGjB,sBAAsB,IAAIY,OAAO,EAAE;IAC9D,IAAIH,SAAS,KAAKX,YAAY,CAACU,KAAK,IAAIK,aAAa,IAAIG,YAAY,EAAE;MACnEE,OAAO,CAACC,KAAK,CAACF,eAAe,CAAC;IAClC;IAEA,IAAIR,SAAS,KAAKX,YAAY,CAACS,IAAI,IAAIM,aAAa,IAAIG,YAAY,EAAE;MAClEE,OAAO,CAACE,IAAI,CAACH,eAAe,CAAC;IACjC;IAEA,IAAIR,SAAS,KAAKX,YAAY,CAACQ,IAAI,IAAIO,aAAa,IAAIG,YAAY,EAAE;MAClEE,OAAO,CAACG,IAAI,CAACJ,eAAe,CAAC;IACjC;IAEA,IAAIR,SAAS,KAAKX,YAAY,CAACO,KAAK,IAAIQ,aAAa,IAAIG,YAAY,EAAE;MACnEE,OAAO,CAACI,KAAK,CAACL,eAAe,CAAC;IAClC;EACJ;AACJ;AAEA,OAAO,MAAMH,WAAW,GAAGf,iBAAiB,CACxCE,mBAAmB,EACnB,MAAM,IAAIC,YAAY,CAAC,CAC3B,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,45 @@
|
|
|
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 { InternalLog } from '../InternalLog';
|
|
8
|
+
import { SdkVerbosity } from '../config/types/SdkVerbosity';
|
|
9
|
+
import { getGlobalInstance } from '../utils/singletonUtils';
|
|
10
|
+
import { FlagsClient } from './FlagsClient';
|
|
11
|
+
const FLAGS_MODULE = 'com.datadog.reactnative.flags';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Implementation class for {@link DdFlagsType}. Please see the interface for documentation.
|
|
15
|
+
*/
|
|
16
|
+
class DdFlagsWrapper {
|
|
17
|
+
// eslint-disable-next-line global-require, @typescript-eslint/no-var-requires
|
|
18
|
+
nativeFlags = require('../specs/NativeDdFlags').default;
|
|
19
|
+
isFeatureEnabled = false;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* A map of client names to their corresponding {@link FlagsClient} instances.
|
|
23
|
+
*
|
|
24
|
+
* Each of these clients hold their own context and flags state.
|
|
25
|
+
*/
|
|
26
|
+
clients = {};
|
|
27
|
+
enable = async (configuration = {}) => {
|
|
28
|
+
await this.nativeFlags.enable({
|
|
29
|
+
enabled: true,
|
|
30
|
+
...configuration
|
|
31
|
+
});
|
|
32
|
+
this.isFeatureEnabled = true;
|
|
33
|
+
};
|
|
34
|
+
getClient = (clientName = 'default') => {
|
|
35
|
+
if (!this.isFeatureEnabled) {
|
|
36
|
+
InternalLog.log('`DdFlags.getClient()` called before Datadog Flags feature have been enabled. Client will fall back to serving default flag values.', SdkVerbosity.ERROR);
|
|
37
|
+
}
|
|
38
|
+
if (!this.clients[clientName]) {
|
|
39
|
+
this.clients[clientName] = new FlagsClient(clientName);
|
|
40
|
+
}
|
|
41
|
+
return this.clients[clientName];
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export const DdFlags = getGlobalInstance(FLAGS_MODULE, () => new DdFlagsWrapper());
|
|
45
|
+
//# sourceMappingURL=DdFlags.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["InternalLog","SdkVerbosity","getGlobalInstance","FlagsClient","FLAGS_MODULE","DdFlagsWrapper","nativeFlags","require","default","isFeatureEnabled","clients","enable","configuration","enabled","getClient","clientName","log","ERROR","DdFlags"],"sourceRoot":"../../../src","sources":["flags/DdFlags.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;;AAEA,SAASA,WAAW,QAAQ,gBAAgB;AAC5C,SAASC,YAAY,QAAQ,8BAA8B;AAE3D,SAASC,iBAAiB,QAAQ,yBAAyB;AAE3D,SAASC,WAAW,QAAQ,eAAe;AAG3C,MAAMC,YAAY,GAAG,+BAA+B;;AAEpD;AACA;AACA;AACA,MAAMC,cAAc,CAAwB;EACxC;EACQC,WAAW,GAAsBC,OAAO,CAAC,wBAAwB,CAAC,CACrEC,OAAO;EAEJC,gBAAgB,GAAG,KAAK;;EAEhC;AACJ;AACA;AACA;AACA;EACYC,OAAO,GAAgC,CAAC,CAAC;EAEjDC,MAAM,GAAG,MAAAA,CAAOC,aAAiC,GAAG,CAAC,CAAC,KAAoB;IACtE,MAAM,IAAI,CAACN,WAAW,CAACK,MAAM,CAAC;MAAEE,OAAO,EAAE,IAAI;MAAE,GAAGD;IAAc,CAAC,CAAC;IAElE,IAAI,CAACH,gBAAgB,GAAG,IAAI;EAChC,CAAC;EAEDK,SAAS,GAAGA,CAACC,UAAkB,GAAG,SAAS,KAAkB;IACzD,IAAI,CAAC,IAAI,CAACN,gBAAgB,EAAE;MACxBT,WAAW,CAACgB,GAAG,CACX,oIAAoI,EACpIf,YAAY,CAACgB,KACjB,CAAC;IACL;IAEA,IAAI,CAAC,IAAI,CAACP,OAAO,CAACK,UAAU,CAAC,EAAE;MAC3B,IAAI,CAACL,OAAO,CAACK,UAAU,CAAC,GAAG,IAAIZ,WAAW,CAACY,UAAU,CAAC;IAC1D;IAEA,OAAO,IAAI,CAACL,OAAO,CAACK,UAAU,CAAC;EACnC,CAAC;AACL;AAEA,OAAO,MAAMG,OAAoB,GAAGhB,iBAAiB,CACjDE,YAAY,EACZ,MAAM,IAAIC,cAAc,CAAC,CAC7B,CAAC","ignoreList":[]}
|