From cb28e51202dddfb88d9f49eb7567713afa1122dd Mon Sep 17 00:00:00 2001 From: Emiliano Sanchez Date: Fri, 20 Oct 2023 12:30:13 -0300 Subject: [PATCH 1/4] add changelog entry --- CHANGES.txt | 3 +++ package-lock.json | 4 ++-- package.json | 2 +- src/types.ts | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 0898019d..8272b88b 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,6 @@ +1.9.2 (October 20, 2023) + - Added defaultTreatment property to the SplitView object returned by the `split` and `splits` methods of the SDK manager. + 1.9.2 (October 19, 2023) - Updated client module to support the Split Suite. - Updated some transitive dependencies for vulnerability fixes. diff --git a/package-lock.json b/package-lock.json index 4651ab50..f2dd4391 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@splitsoftware/splitio-commons", - "version": "1.9.2", + "version": "1.10.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@splitsoftware/splitio-commons", - "version": "1.9.2", + "version": "1.10.0", "license": "Apache-2.0", "dependencies": { "tslib": "^2.3.1" diff --git a/package.json b/package.json index ffdac7e1..889dea78 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@splitsoftware/splitio-commons", - "version": "1.9.2", + "version": "1.10.0", "description": "Split Javascript SDK common components", "main": "cjs/index.js", "module": "esm/index.js", diff --git a/src/types.ts b/src/types.ts index 786c9121..d2816072 100644 --- a/src/types.ts +++ b/src/types.ts @@ -611,7 +611,7 @@ export namespace SplitIO { [treatmentName: string]: string } /** - * Default treatment value for feature flag. + * The default treatment if the feature flag. * @property {string} defaultTreatment */ defaultTreatment: string, From 4dfd27f26d290879cf31012f76f668f461818084 Mon Sep 17 00:00:00 2001 From: Emiliano Sanchez Date: Fri, 20 Oct 2023 13:09:45 -0300 Subject: [PATCH 2/4] Add feature flag name as part of the readiness warning log message --- src/logger/messages/warn.ts | 2 +- src/sdkClient/clientInputValidation.ts | 2 +- src/utils/inputValidation/__tests__/isOperational.spec.ts | 2 +- src/utils/inputValidation/isOperational.ts | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/logger/messages/warn.ts b/src/logger/messages/warn.ts index 9917f862..b19039f5 100644 --- a/src/logger/messages/warn.ts +++ b/src/logger/messages/warn.ts @@ -14,7 +14,7 @@ export const codesWarn: [number, string][] = codesError.concat([ [c.SUBMITTERS_PUSH_FAILS, c.LOG_PREFIX_SYNC_SUBMITTERS + 'Dropping %s after retry. Reason: %s.'], [c.SUBMITTERS_PUSH_RETRY, c.LOG_PREFIX_SYNC_SUBMITTERS + 'Failed to push %s, keeping data to retry on next iteration. Reason: %s.'], // client status - [c.CLIENT_NOT_READY, '%s: the SDK is not ready, results may be incorrect. Make sure to wait for SDK readiness before using this method.'], + [c.CLIENT_NOT_READY, '%s: the SDK is not ready, results may be incorrect%s. Make sure to wait for SDK readiness before using this method.'], [c.CLIENT_NO_LISTENER, 'No listeners for SDK Readiness detected. Incorrect control treatments could have been logged if you called getTreatment/s while the SDK was not yet ready.'], // input validation [c.WARN_SETTING_NULL, '%s: Property "%s" is of invalid type. Setting value to null.'], diff --git a/src/sdkClient/clientInputValidation.ts b/src/sdkClient/clientInputValidation.ts index fb832b9d..513fa634 100644 --- a/src/sdkClient/clientInputValidation.ts +++ b/src/sdkClient/clientInputValidation.ts @@ -37,7 +37,7 @@ export function clientInputValidationDecorator { expect(validateIfOperational(loggerMock, readinessManagerMock, 'test_method')).toBe(false); // It should return true if SDK was ready. expect(readinessManagerMock.isReady).toBeCalledTimes(1); // It checks for SDK_READY status. expect(readinessManagerMock.isReadyFromCache).toBeCalledTimes(1); // It checks for SDK_READY_FROM_CACHE status. - expect(loggerMock.warn).toBeCalledWith(CLIENT_NOT_READY, ['test_method']); // It should log the expected warning. + expect(loggerMock.warn).toBeCalledWith(CLIENT_NOT_READY, ['test_method', '']); // It should log the expected warning. expect(loggerMock.error).not.toBeCalled(); // But it should not log any errors. }); }); diff --git a/src/utils/inputValidation/isOperational.ts b/src/utils/inputValidation/isOperational.ts index 05ad0aad..3d990433 100644 --- a/src/utils/inputValidation/isOperational.ts +++ b/src/utils/inputValidation/isOperational.ts @@ -9,9 +9,9 @@ export function validateIfNotDestroyed(log: ILogger, readinessManager: IReadines return false; } -export function validateIfOperational(log: ILogger, readinessManager: IReadinessManager, method: string) { +export function validateIfOperational(log: ILogger, readinessManager: IReadinessManager, method: string, featureFlagNameOrNames?: string | string[] | false) { if (readinessManager.isReady() || readinessManager.isReadyFromCache()) return true; - log.warn(CLIENT_NOT_READY, [method]); + log.warn(CLIENT_NOT_READY, [method, featureFlagNameOrNames ? ` for feature flag ${featureFlagNameOrNames.toString()}` : '']); return false; } From 85bb2b829898a3dcc7dab01c7f0c9b6c8efdba14 Mon Sep 17 00:00:00 2001 From: Emiliano Sanchez Date: Fri, 20 Oct 2023 13:13:07 -0300 Subject: [PATCH 3/4] fix typo --- CHANGES.txt | 2 +- src/types.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 8272b88b..a737f9bb 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,4 @@ -1.9.2 (October 20, 2023) +1.10.0 (October 20, 2023) - Added defaultTreatment property to the SplitView object returned by the `split` and `splits` methods of the SDK manager. 1.9.2 (October 19, 2023) diff --git a/src/types.ts b/src/types.ts index d2816072..d868b92a 100644 --- a/src/types.ts +++ b/src/types.ts @@ -611,7 +611,7 @@ export namespace SplitIO { [treatmentName: string]: string } /** - * The default treatment if the feature flag. + * The default treatment of the feature flag. * @property {string} defaultTreatment */ defaultTreatment: string, From 273bce86ce225422a08b9a31520d2387365acef0 Mon Sep 17 00:00:00 2001 From: Emiliano Sanchez Date: Fri, 20 Oct 2023 14:32:14 -0300 Subject: [PATCH 4/4] update changelog entry --- CHANGES.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES.txt b/CHANGES.txt index a737f9bb..0bb2cde5 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,5 +1,6 @@ 1.10.0 (October 20, 2023) - - Added defaultTreatment property to the SplitView object returned by the `split` and `splits` methods of the SDK manager. + - Added `defaultTreatment` property to the `SplitView` object returned by the `split` and `splits` methods of the SDK manager (Related to issue https://github.com/splitio/javascript-commons/issues/225). + - Updated log warning message to include the feature flag name when `getTreatment` method is called and the SDK client is not ready. 1.9.2 (October 19, 2023) - Updated client module to support the Split Suite.