Skip to content

Commit 54e1d51

Browse files
Merge pull request #261 from splitio/development
Release v1.10.0
2 parents 5a1d096 + 94fc1cc commit 54e1d51

File tree

10 files changed

+21
-10
lines changed

10 files changed

+21
-10
lines changed

CHANGES.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
1.10.0 (October 20, 2023)
2+
- 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).
3+
- Updated log warning message to include the feature flag name when `getTreatment` method is called and the SDK client is not ready.
4+
15
1.9.2 (October 19, 2023)
26
- Updated client module to support the Split Suite.
37
- Updated some transitive dependencies for vulnerability fixes.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@splitsoftware/splitio-commons",
3-
"version": "1.9.2",
3+
"version": "1.10.0",
44
"description": "Split Javascript SDK common components",
55
"main": "cjs/index.js",
66
"module": "esm/index.js",

src/logger/messages/warn.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export const codesWarn: [number, string][] = codesError.concat([
1414
[c.SUBMITTERS_PUSH_FAILS, c.LOG_PREFIX_SYNC_SUBMITTERS + 'Dropping %s after retry. Reason: %s.'],
1515
[c.SUBMITTERS_PUSH_RETRY, c.LOG_PREFIX_SYNC_SUBMITTERS + 'Failed to push %s, keeping data to retry on next iteration. Reason: %s.'],
1616
// client status
17-
[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.'],
17+
[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.'],
1818
[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.'],
1919
// input validation
2020
[c.WARN_SETTING_NULL, '%s: Property "%s" is of invalid type. Setting value to null.'],

src/sdkClient/clientInputValidation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function clientInputValidationDecorator<TClient extends SplitIO.IClient |
3737
const attributes = validateAttributes(log, maybeAttributes, methodName);
3838
const isNotDestroyed = validateIfNotDestroyed(log, readinessManager, methodName);
3939

40-
validateIfOperational(log, readinessManager, methodName);
40+
validateIfOperational(log, readinessManager, methodName, splitOrSplits);
4141

4242
const valid = isNotDestroyed && key && splitOrSplits && attributes !== false;
4343

src/sdkManager/__tests__/mocks/output.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
"treatments": ["on", "off"],
77
"configs": {
88
"on": "\"color\": \"green\""
9-
}
9+
},
10+
"defaultTreatment": "off"
1011
}

src/sdkManager/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ function objectToView(splitObject: ISplit | null): SplitIO.SplitView | null {
3131
killed: splitObject.killed,
3232
changeNumber: splitObject.changeNumber || 0,
3333
treatments: collectTreatments(splitObject),
34-
configs: splitObject.configurations || {}
34+
configs: splitObject.configurations || {},
35+
defaultTreatment: splitObject.defaultTreatment
3536
};
3637
}
3738

src/types.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,6 +610,11 @@ export namespace SplitIO {
610610
configs: {
611611
[treatmentName: string]: string
612612
}
613+
/**
614+
* The default treatment of the feature flag.
615+
* @property {string} defaultTreatment
616+
*/
617+
defaultTreatment: string,
613618
};
614619
/**
615620
* A promise that resolves to a feature flag view.

src/utils/inputValidation/__tests__/isOperational.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ describe('validateIfOperational', () => {
5858
expect(validateIfOperational(loggerMock, readinessManagerMock, 'test_method')).toBe(false); // It should return true if SDK was ready.
5959
expect(readinessManagerMock.isReady).toBeCalledTimes(1); // It checks for SDK_READY status.
6060
expect(readinessManagerMock.isReadyFromCache).toBeCalledTimes(1); // It checks for SDK_READY_FROM_CACHE status.
61-
expect(loggerMock.warn).toBeCalledWith(CLIENT_NOT_READY, ['test_method']); // It should log the expected warning.
61+
expect(loggerMock.warn).toBeCalledWith(CLIENT_NOT_READY, ['test_method', '']); // It should log the expected warning.
6262
expect(loggerMock.error).not.toBeCalled(); // But it should not log any errors.
6363
});
6464
});

src/utils/inputValidation/isOperational.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ export function validateIfNotDestroyed(log: ILogger, readinessManager: IReadines
99
return false;
1010
}
1111

12-
export function validateIfOperational(log: ILogger, readinessManager: IReadinessManager, method: string) {
12+
export function validateIfOperational(log: ILogger, readinessManager: IReadinessManager, method: string, featureFlagNameOrNames?: string | string[] | false) {
1313
if (readinessManager.isReady() || readinessManager.isReadyFromCache()) return true;
1414

15-
log.warn(CLIENT_NOT_READY, [method]);
15+
log.warn(CLIENT_NOT_READY, [method, featureFlagNameOrNames ? ` for feature flag ${featureFlagNameOrNames.toString()}` : '']);
1616
return false;
1717
}

0 commit comments

Comments
 (0)