@configdirector/react-native-sdk 0.3.0 → 0.6.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.
|
@@ -459,7 +459,7 @@ var StreamingTransport = class {
|
|
|
459
459
|
this.dispatchMessage(data);
|
|
460
460
|
},
|
|
461
461
|
onConnect: () => {
|
|
462
|
-
this.logger.debug("[
|
|
462
|
+
this.logger.debug("[StreamingTransport] Connected");
|
|
463
463
|
resolve(this);
|
|
464
464
|
},
|
|
465
465
|
shouldReconnect: (state) => {
|
|
@@ -469,14 +469,16 @@ var StreamingTransport = class {
|
|
|
469
469
|
},
|
|
470
470
|
calculateReconnectDelay: (state) => {
|
|
471
471
|
const delay = this.options.connectionRetryDelay(state.attempt);
|
|
472
|
-
|
|
472
|
+
const logMessage = `[StreamingTransport] Scheduling reconnect attempt #${state.attempt} in ${delay}ms.`;
|
|
473
|
+
if (state.attempt <= 5) this.logger.info(logMessage);
|
|
474
|
+
else this.logger.warn(logMessage);
|
|
473
475
|
return delay;
|
|
474
476
|
},
|
|
475
477
|
onError: (error) => {
|
|
476
|
-
this.logger.debug("[
|
|
478
|
+
this.logger.debug("[StreamingTransport] Error: ", error);
|
|
477
479
|
},
|
|
478
480
|
onDisconnect: () => {
|
|
479
|
-
this.logger.debug("[
|
|
481
|
+
this.logger.debug("[StreamingTransport] Disconnected");
|
|
480
482
|
}
|
|
481
483
|
});
|
|
482
484
|
this.eventSource.connect();
|
|
@@ -492,7 +494,7 @@ var StreamingTransport = class {
|
|
|
492
494
|
const json = JSON.parse(data);
|
|
493
495
|
this.eventEmitter.emit("configSetReceived", json);
|
|
494
496
|
} catch (error) {
|
|
495
|
-
this.logger.error("[
|
|
497
|
+
this.logger.error("[StreamingTransport] Error parsing and dispatching config data update: ", error);
|
|
496
498
|
}
|
|
497
499
|
}
|
|
498
500
|
prepareFatalError(responseStatus, error) {
|
|
@@ -551,6 +553,7 @@ const parseConfigValue = (configState, defaultValue) => {
|
|
|
551
553
|
usedDefault: true,
|
|
552
554
|
reason: "value-missing"
|
|
553
555
|
};
|
|
556
|
+
if (configState.type === "json") return parseJson(value, defaultValue, requestedType);
|
|
554
557
|
if (typeof defaultValue === "string") return {
|
|
555
558
|
parsedValue: value,
|
|
556
559
|
requestedType,
|
|
@@ -612,6 +615,29 @@ const parseConfigFloat = (value) => {
|
|
|
612
615
|
if (isNaN(num) || !isFinite(num)) return;
|
|
613
616
|
return num;
|
|
614
617
|
};
|
|
618
|
+
const parseJson = (jsonString, defaultValue, requestedType) => {
|
|
619
|
+
if (typeof defaultValue === "string") return {
|
|
620
|
+
parsedValue: jsonString,
|
|
621
|
+
requestedType,
|
|
622
|
+
usedDefault: false,
|
|
623
|
+
reason: "found-match"
|
|
624
|
+
};
|
|
625
|
+
try {
|
|
626
|
+
return {
|
|
627
|
+
parsedValue: JSON.parse(jsonString),
|
|
628
|
+
requestedType,
|
|
629
|
+
usedDefault: false,
|
|
630
|
+
reason: "found-match"
|
|
631
|
+
};
|
|
632
|
+
} catch {
|
|
633
|
+
return {
|
|
634
|
+
parsedValue: defaultValue,
|
|
635
|
+
requestedType,
|
|
636
|
+
usedDefault: true,
|
|
637
|
+
reason: "invalid-json"
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
};
|
|
615
641
|
//#endregion
|
|
616
642
|
//#region ../shared/src/logger.ts
|
|
617
643
|
const LEVELS = {
|
|
@@ -993,6 +1019,7 @@ var DefaultConfigDirectorClient = class {
|
|
|
993
1019
|
const parseResult = parseConfigValue(configState, defaultValue);
|
|
994
1020
|
this.telemetryClient.evaluatedConfig({
|
|
995
1021
|
contextId: (_this$currentContext2 = this.currentContext) === null || _this$currentContext2 === void 0 ? void 0 : _this$currentContext2.id,
|
|
1022
|
+
type: configState.type,
|
|
996
1023
|
key: configKey,
|
|
997
1024
|
defaultValue,
|
|
998
1025
|
requestedType: parseResult.requestedType,
|
|
@@ -1063,12 +1090,13 @@ var DefaultConfigDirectorClient = class {
|
|
|
1063
1090
|
//#region ../shared/src/telemetry/utils.ts
|
|
1064
1091
|
const CONFIG_VALUE_MAX_LENGTH = 500;
|
|
1065
1092
|
const sanitizeValue = (value, type) => {
|
|
1066
|
-
if (type === "json") try {
|
|
1067
|
-
return djb2Hash(JSON.stringify(value));
|
|
1093
|
+
if (type === "json" || type == null && typeof value === "object") try {
|
|
1094
|
+
return { digest: djb2Hash(JSON.stringify(value)) };
|
|
1068
1095
|
} catch {
|
|
1069
|
-
return value.toString()
|
|
1096
|
+
return { digest: value.toString() };
|
|
1070
1097
|
}
|
|
1071
|
-
|
|
1098
|
+
if (value.toString().length > CONFIG_VALUE_MAX_LENGTH) return { digest: djb2Hash(value.toString()) };
|
|
1099
|
+
else return { value: value.toString() };
|
|
1072
1100
|
};
|
|
1073
1101
|
const djb2Hash = (data) => {
|
|
1074
1102
|
return djb2(new TextEncoder().encode(data)).toString(16).padStart(8, "0");
|
|
@@ -1492,7 +1520,7 @@ const createClient = (clientSdkKey, clientOptions) => {
|
|
|
1492
1520
|
const logger = (_clientOptions$logger = clientOptions === null || clientOptions === void 0 ? void 0 : clientOptions.logger) !== null && _clientOptions$logger !== void 0 ? _clientOptions$logger : createConsoleLogger("warn");
|
|
1493
1521
|
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, {
|
|
1494
1522
|
sdkName: "react-native-sdk",
|
|
1495
|
-
sdkVersion: "0.
|
|
1523
|
+
sdkVersion: "0.6.0"
|
|
1496
1524
|
}, {
|
|
1497
1525
|
...clientOptions,
|
|
1498
1526
|
logger
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@configdirector/react-native-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.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",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"react-native": "0.81.5",
|
|
73
73
|
"react-test-renderer": "19.1.0",
|
|
74
74
|
"tsdown": "^0.21.7",
|
|
75
|
-
"turbo": "^2.
|
|
75
|
+
"turbo": "^2.9.16",
|
|
76
76
|
"typescript": "^5.9.3",
|
|
77
77
|
"typescript-eslint": "^8.58.1",
|
|
78
78
|
"wtfnode": "^0.10.1"
|