Skip to content

Commit

Permalink
Merge pull request #260 from splitio/release_v1.10.0
Browse files Browse the repository at this point in the history
Update readiness warning log message to include feature flag name
  • Loading branch information
EmilianoSanchez authored Oct 20, 2023
2 parents eaebd04 + 273bce8 commit 94fc1cc
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.10.0 (October 20, 2023)
- 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.
- Updated some transitive dependencies for vulnerability fixes.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/logger/messages/warn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.'],
Expand Down
2 changes: 1 addition & 1 deletion src/sdkClient/clientInputValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function clientInputValidationDecorator<TClient extends SplitIO.IClient |
const attributes = validateAttributes(log, maybeAttributes, methodName);
const isNotDestroyed = validateIfNotDestroyed(log, readinessManager, methodName);

validateIfOperational(log, readinessManager, methodName);
validateIfOperational(log, readinessManager, methodName, splitOrSplits);

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

Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ export namespace SplitIO {
[treatmentName: string]: string
}
/**
* Default treatment value for feature flag.
* The default treatment of the feature flag.
* @property {string} defaultTreatment
*/
defaultTreatment: string,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/inputValidation/__tests__/isOperational.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('validateIfOperational', () => {
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.
});
});
4 changes: 2 additions & 2 deletions src/utils/inputValidation/isOperational.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 94fc1cc

Please sign in to comment.