@configdirector/react-native-sdk 0.5.0 → 0.7.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.
|
@@ -52,6 +52,14 @@ type ConfigDirectorContext = {
|
|
|
52
52
|
traits?: {
|
|
53
53
|
[key: string]: unknown;
|
|
54
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* Whether or not to treat the context as anonymous during evaluation. When `true`, the
|
|
57
|
+
* context values will be used for targeting rules evaluation but the context will not be
|
|
58
|
+
* persisted and will not appear in the dashboard.
|
|
59
|
+
*
|
|
60
|
+
* @default false
|
|
61
|
+
*/
|
|
62
|
+
anonymous?: boolean;
|
|
55
63
|
};
|
|
56
64
|
/**
|
|
57
65
|
* Metadata about your application. It is recommended you include these values when configuring
|
|
@@ -453,7 +453,8 @@ var StreamingTransport = class {
|
|
|
453
453
|
body: JSON.stringify({
|
|
454
454
|
givenContext: context,
|
|
455
455
|
metaContext: this.options.metaContext,
|
|
456
|
-
clientSdkKey: this.options.clientSdkKey
|
|
456
|
+
clientSdkKey: this.options.clientSdkKey,
|
|
457
|
+
instanceId: this.options.instanceId
|
|
457
458
|
}),
|
|
458
459
|
onMessage: ({ data }) => {
|
|
459
460
|
this.dispatchMessage(data);
|
|
@@ -819,6 +820,7 @@ var PollingTransport = class extends AbstractPollingTransport {
|
|
|
819
820
|
givenContext: context,
|
|
820
821
|
metaContext: this.options.metaContext,
|
|
821
822
|
clientSdkKey: this.options.clientSdkKey,
|
|
823
|
+
instanceId: this.options.instanceId,
|
|
822
824
|
lastUpdateTimestamp: this.lastUpdateTimestamp
|
|
823
825
|
})
|
|
824
826
|
}, this.logger);
|
|
@@ -876,6 +878,8 @@ var DefaultConfigDirectorClient = class {
|
|
|
876
878
|
_defineProperty(this, "readyResolve", void 0);
|
|
877
879
|
_defineProperty(this, "currentContext", void 0);
|
|
878
880
|
_defineProperty(this, "connectionMode", void 0);
|
|
881
|
+
_defineProperty(this, "instanceId", void 0);
|
|
882
|
+
this.instanceId = crypto.randomUUID();
|
|
879
883
|
this.logger = (_clientOptions$logger = clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.logger) !== null && _clientOptions$logger !== void 0 ? _clientOptions$logger : createDefaultLogger();
|
|
880
884
|
this.timeout = (_clientOptions$connec = clientOptions === null || clientOptions === void 0 || (_clientOptions$connec2 = clientOptions.connection) === null || _clientOptions$connec2 === void 0 ? void 0 : _clientOptions$connec2.timeout) !== null && _clientOptions$connec !== void 0 ? _clientOptions$connec : 3e3;
|
|
881
885
|
const urlFactory = (_internalClientOption = internalClientOptions === null || internalClientOptions === void 0 ? void 0 : internalClientOptions.urlFactory) !== null && _internalClientOption !== void 0 ? _internalClientOption : defaultUrlFactory;
|
|
@@ -884,6 +888,7 @@ var DefaultConfigDirectorClient = class {
|
|
|
884
888
|
const transportConstructor = this.getTransportConstructor(this.connectionMode);
|
|
885
889
|
this.telemetryClient = telemetryClient;
|
|
886
890
|
this.transport = new transportConstructor({
|
|
891
|
+
instanceId: this.instanceId,
|
|
887
892
|
clientSdkKey,
|
|
888
893
|
baseUrl,
|
|
889
894
|
resolveUrl: urlFactory,
|
|
@@ -1091,11 +1096,12 @@ var DefaultConfigDirectorClient = class {
|
|
|
1091
1096
|
const CONFIG_VALUE_MAX_LENGTH = 500;
|
|
1092
1097
|
const sanitizeValue = (value, type) => {
|
|
1093
1098
|
if (type === "json" || type == null && typeof value === "object") try {
|
|
1094
|
-
return djb2Hash(JSON.stringify(value));
|
|
1099
|
+
return { digest: djb2Hash(JSON.stringify(value)) };
|
|
1095
1100
|
} catch {
|
|
1096
|
-
return value.toString()
|
|
1101
|
+
return { digest: value.toString() };
|
|
1097
1102
|
}
|
|
1098
|
-
|
|
1103
|
+
if (value.toString().length > CONFIG_VALUE_MAX_LENGTH) return { digest: djb2Hash(value.toString()) };
|
|
1104
|
+
else return { value: value.toString() };
|
|
1099
1105
|
};
|
|
1100
1106
|
const djb2Hash = (data) => {
|
|
1101
1107
|
return djb2(new TextEncoder().encode(data)).toString(16).padStart(8, "0");
|
|
@@ -1519,7 +1525,7 @@ const createClient = (clientSdkKey, clientOptions) => {
|
|
|
1519
1525
|
const logger = (_clientOptions$logger = clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.logger) !== null && _clientOptions$logger !== void 0 ? _clientOptions$logger : createConsoleLogger("warn");
|
|
1520
1526
|
return new DefaultConfigDirectorClient(new ReactNativeTelemetryClient(clientSdkKey, (clientOptions === null || clientOptions === void 0 || (_clientOptions$connec = clientOptions.connection) === null || _clientOptions$connec === void 0 ? void 0 : _clientOptions$connec.url) ? urlFactory(clientOptions.connection.url) : CLIENT_BASE_URL, logger, urlFactory), clientSdkKey, {
|
|
1521
1527
|
sdkName: "react-native-sdk",
|
|
1522
|
-
sdkVersion: "0.
|
|
1528
|
+
sdkVersion: "0.7.0"
|
|
1523
1529
|
}, {
|
|
1524
1530
|
...clientOptions,
|
|
1525
1531
|
logger
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@configdirector/react-native-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "React Native client SDK for ConfigDirector. ConfigDirector is a remote configuration and feature flag service.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "ConfigDirector",
|