Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.3.1 (April 19, 2022)
- Bugfixing - Added peer dependencies to avoid issues when requiring some third-party dependencies used by modules of the package (Related to issue https://github.com/splitio/javascript-client/issues/662).
- Bugfixing - Updated `ready` method to rejects the promise with an Error object instead of a string value (Related to issue https://github.com/splitio/javascript-client/issues/654).

1.3.0 (April 6, 2022)
- Added user consent feature to allow delaying or disabling the data tracking from SDK until user consent is explicitly granted or declined. Read more in our docs.
- Added `scheduler.impressionsQueueSize` property to SDK configuration to limit the amount of impressions tracked in memory. Read more in our docs.
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

16 changes: 14 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@splitsoftware/splitio-commons",
"version": "1.3.0",
"version": "1.3.1",
"description": "Split Javascript SDK common components",
"main": "cjs/index.js",
"module": "esm/index.js",
Expand Down Expand Up @@ -46,6 +46,18 @@
"dependencies": {
"tslib": "^2.3.1"
},
"peerDependencies": {
"js-yaml": "^3.13.1",
"ioredis": "^4.28.0"
},
"peerDependenciesMeta": {
"js-yaml": {
"optional": true
},
"ioredis": {
"optional": true
}
},
"devDependencies": {
"@types/google.analytics": "0.0.40",
"@types/ioredis": "^4.28.0",
Expand All @@ -62,7 +74,7 @@
"ioredis": "^4.28.0",
"jest": "^27.2.3",
"jest-localstorage-mock": "^2.4.3",
"js-yaml": "^3.14.0",
"js-yaml": "^3.13.1",
"lodash": "^4.17.21",
"node-fetch": "^2.6.7",
"redis-server": "1.2.2",
Expand Down
3 changes: 2 additions & 1 deletion src/readiness/__tests__/sdkReadinessManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,8 @@ describe('SDK Readiness Manager - Ready promise', () => {
.then(() => { throw new Error(); })
.then(() => { throw new Error(); })
.catch((error) => {
expect(error).toBe('Split SDK has emitted SDK_READY_TIMED_OUT event.');
expect(error instanceof Error).toBe(true);
expect(error.message).toBe('Split SDK has emitted SDK_READY_TIMED_OUT event.');
expect(loggerMock.error).toBeCalledTimes(2); // If we provide an onRejected handler, even chaining several onFulfilled handlers, the error is not logged.
done();
});
Expand Down
12 changes: 7 additions & 5 deletions src/readiness/sdkReadinessManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function sdkReadinessManagerFactory(

// default onRejected handler, that just logs the error, if ready promise doesn't have one.
function defaultOnRejected(err: any) {
log.error(err);
log.error(err && err.message);
}

function generateReadyPromise() {
Expand All @@ -62,7 +62,9 @@ export function sdkReadinessManagerFactory(
if (readyCbCount === internalReadyCbCount && !promise.hasOnFulfilled()) log.warn(CLIENT_NO_LISTENER);
resolve();
});
readinessManager.gate.once(SDK_READY_TIMED_OUT, reject);
readinessManager.gate.once(SDK_READY_TIMED_OUT, (message: string) => {
reject(new Error(message));
});
}), defaultOnRejected);

return promise;
Expand Down Expand Up @@ -106,10 +108,10 @@ export function sdkReadinessManagerFactory(
* @function ready
* @returns {Promise<void>}
*/
ready: () => {
ready() {
if (readinessManager.hasTimedout()) {
if (!readinessManager.isReady()) {
return promiseWrapper(Promise.reject('Split SDK has emitted SDK_READY_TIMED_OUT event.'), defaultOnRejected);
return promiseWrapper(Promise.reject(new Error('Split SDK has emitted SDK_READY_TIMED_OUT event.')), defaultOnRejected);
} else {
return Promise.resolve();
}
Expand All @@ -118,7 +120,7 @@ export function sdkReadinessManagerFactory(
},

// Expose status for internal purposes only. Not considered part of the public API, and might be updated eventually.
__getStatus: () => {
__getStatus() {
return {
isReady: readinessManager.isReady(),
isReadyFromCache: readinessManager.isReadyFromCache(),
Expand Down
4 changes: 2 additions & 2 deletions src/trackers/impressionsTracker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ export function impressionsTrackerFactory(
// copy of impression, to avoid unexpected behaviour if modified by integrations or impressionListener
impression: objectAssign({}, impressions[i]),
attributes,
ip: ip as string,
hostname: hostname as string,
ip,
hostname,
sdkLanguageVersion: version
};

Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,8 +535,8 @@ export namespace SplitIO {
export type ImpressionData = {
impression: ImpressionDTO,
attributes?: SplitIO.Attributes,
ip: string,
hostname: string,
ip: string| false,
hostname: string | false,
sdkLanguageVersion: string
};
/**
Expand Down