diff --git a/.eslintrc b/.eslintrc index 9954be9..e45bc6c 100644 --- a/.eslintrc +++ b/.eslintrc @@ -31,7 +31,8 @@ "@typescript-eslint/no-unused-vars": "error", "keyword-spacing": "error", "comma-style": "error", - "no-trailing-spaces": "error" + "no-trailing-spaces": "error", + "space-before-function-paren": ["error", {"named": "never"}] }, "overrides": [ @@ -39,7 +40,6 @@ "files": ["src/**/*.ts"], "excludedFiles": ["src/**/__tests__/**"], "extends": [ - "eslint:recommended", "plugin:compat/recommended" ], "rules": { diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 76742e4..8c36339 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -63,14 +63,14 @@ jobs: matrix: environment: - stage - - stage-eu + # - stage-eu include: - environment: stage account_id: "079419646996" bucket: split-public-stage - - environment: stage-eu - account_id: "901851837056" - bucket: split-public-stage-eu-west-1 + # - environment: stage-eu + # account_id: "901851837056" + # bucket: split-public-stage-eu-west-1 steps: - name: Download assets @@ -106,14 +106,14 @@ jobs: matrix: environment: - prod - - prod-eu + # - prod-eu include: - environment: prod account_id: "825951051969" bucket: split-public - - environment: prod-eu - account_id: "842946900133" - bucket: split-public-eu-west-1 + # - environment: prod-eu + # account_id: "842946900133" + # bucket: split-public-eu-west-1 steps: - name: Download assets diff --git a/CHANGES.txt b/CHANGES.txt index b40c5af..66511bc 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,7 @@ +0.9.3 (March 20, 2023) + - Updated @splitsoftware/splitio-commons package to version 1.8.1 that includes minor improvements. + - Updated some transitive dependencies for vulnerability fixes. + 0.9.2 (December 16, 2022) - Updated some transitive dependencies for vulnerability fixes. - Bugfixing - Upgrade @splitsoftware/splitio-commons package to version 1.7.3 which includes a memory leak fix for localhost mode (Related to issue https://github.com/splitio/javascript-commons/issues/181) among other improvements. diff --git a/LICENSE b/LICENSE index 051b5fd..65f5999 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright © 2022 Split Software, Inc. +Copyright © 2023 Split Software, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/README.md b/README.md index e72c230..3058b34 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Split JavaScript SDK for Browsers -[![npm version](https://badge.fury.io/js/%40splitsoftware%2Fsplitio-browserjs.svg)](https://badge.fury.io/js/%40splitsoftware%2Fsplitio) [![Build Status](https://github.com/splitio/javascript-browser-client/actions/workflows/ci-cd.yml/badge.svg)](https://github.com/splitio/javascript-browser-client/actions/workflows/ci-cd.yml) +[![npm version](https://badge.fury.io/js/%40splitsoftware%2Fsplitio-browserjs.svg)](https://badge.fury.io/js/%40splitsoftware%2Fsplitio-browserjs) [![Build Status](https://github.com/splitio/javascript-browser-client/actions/workflows/ci-cd.yml/badge.svg)](https://github.com/splitio/javascript-browser-client/actions/workflows/ci-cd.yml) ## Overview This SDK is designed to work with Split, the platform for controlled rollouts, which serves features to your users via a Split feature flag to manage your complete customer experience. @@ -63,11 +63,12 @@ Split has built and maintains SDKs for: * .NET [Github](https://github.com/splitio/dotnet-client) [Docs](https://help.split.io/hc/en-us/articles/360020240172--NET-SDK) * Android [Github](https://github.com/splitio/android-client) [Docs](https://help.split.io/hc/en-us/articles/360020343291-Android-SDK) +* Angular [Github](https://github.com/splitio/angular-sdk-plugin) [Docs](https://help.split.io/hc/en-us/articles/6495326064397-Angular-utilities) * GO [Github](https://github.com/splitio/go-client) [Docs](https://help.split.io/hc/en-us/articles/360020093652-Go-SDK) * iOS [Github](https://github.com/splitio/ios-client) [Docs](https://help.split.io/hc/en-us/articles/360020401491-iOS-SDK) * Java [Github](https://github.com/splitio/java-client) [Docs](https://help.split.io/hc/en-us/articles/360020405151-Java-SDK) -* Javascript [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK) -* Javascript for Browser [Github](https://github.com/splitio/javascript-browser-client) [Docs](https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK) +* JavaScript [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK) +* JavaScript for Browser [Github](https://github.com/splitio/javascript-browser-client) [Docs](https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK) * Node [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK) * PHP [Github](https://github.com/splitio/php-client) [Docs](https://help.split.io/hc/en-us/articles/360020350372-PHP-SDK) * Python [Github](https://github.com/splitio/python-client) [Docs](https://help.split.io/hc/en-us/articles/360020359652-Python-SDK) diff --git a/package-lock.json b/package-lock.json index d29505e..3d8daaf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "@splitsoftware/splitio-browserjs", - "version": "0.9.2", + "version": "0.9.3-rc.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@splitsoftware/splitio-browserjs", - "version": "0.9.2", + "version": "0.9.3-rc.1", "license": "Apache-2.0", "dependencies": { - "@splitsoftware/splitio-commons": "1.7.3", + "@splitsoftware/splitio-commons": "1.8.1", "@types/google.analytics": "0.0.40" }, "devDependencies": { @@ -3273,9 +3273,9 @@ "dev": true }, "node_modules/@splitsoftware/splitio-commons": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-1.7.3.tgz", - "integrity": "sha512-rWZ05g6eY0YlaDuNDWc3e/cPudbVRX7y8Lp0eKXE1wIFMf9P5pAdQWvb2KiXXsvGepM0FwA9U6epxEqatBIpiA==", + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-1.8.1.tgz", + "integrity": "sha512-NHamCh+NwPTjO69kk5e6VaXjASPJzs0u3gWxITjmi0RPvGnNZ2M38/3ya1XSfARNjbDIpgHXlc1iywT07o3lEg==", "dependencies": { "tslib": "^2.3.1" }, @@ -14296,9 +14296,9 @@ "dev": true }, "@splitsoftware/splitio-commons": { - "version": "1.7.3", - "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-1.7.3.tgz", - "integrity": "sha512-rWZ05g6eY0YlaDuNDWc3e/cPudbVRX7y8Lp0eKXE1wIFMf9P5pAdQWvb2KiXXsvGepM0FwA9U6epxEqatBIpiA==", + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/@splitsoftware/splitio-commons/-/splitio-commons-1.8.1.tgz", + "integrity": "sha512-NHamCh+NwPTjO69kk5e6VaXjASPJzs0u3gWxITjmi0RPvGnNZ2M38/3ya1XSfARNjbDIpgHXlc1iywT07o3lEg==", "requires": { "tslib": "^2.3.1" } diff --git a/package.json b/package.json index e36abb3..0fc6728 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@splitsoftware/splitio-browserjs", - "version": "0.9.2", - "description": "Split SDK for Javascript on Browser", + "version": "0.9.3-rc.1", + "description": "Split SDK for JavaScript on Browser", "main": "cjs/index.js", "module": "esm/index.js", "types": "types", @@ -64,7 +64,7 @@ "bugs": "https://github.com/splitio/javascript-browser-client/issues", "homepage": "https://github.com/splitio/javascript-browser-client#readme", "dependencies": { - "@splitsoftware/splitio-commons": "1.7.3", + "@splitsoftware/splitio-commons": "1.8.1", "@types/google.analytics": "0.0.40" }, "devDependencies": { diff --git a/rollup.ci.config.js b/rollup.ci.config.js index 41a79b4..30717ac 100644 --- a/rollup.ci.config.js +++ b/rollup.ci.config.js @@ -3,7 +3,7 @@ import terser from '@rollup/plugin-terser'; export default env => { - const fileName = (outputSuffix) => `split-browser${env.branch !== 'main' ? `-dev-${env.commit_hash || VERSION}` : `-${VERSION}`}${outputSuffix ? `.${outputSuffix}` : ''}`; + const fileName = (outputSuffix) => `split-browser-${env.branch !== 'main' ? `dev-${env.commit_hash || VERSION}` : VERSION}${outputSuffix ? `.${outputSuffix}` : ''}`; const createRollupConfig = (input, outputSuffix) => ({ input, diff --git a/rollup.common.js b/rollup.common.js index f32b0f6..96c9336 100644 --- a/rollup.common.js +++ b/rollup.common.js @@ -8,7 +8,7 @@ export const plugins = [ nodeResolve({ // defaults `extensions` plus '.ts' files extensions: [ - '.mjs', '.js', '.json', '.node' + '.mjs', '.js', '.json', '.node', '.ts' ], browser: true, preferBuiltins: false, diff --git a/src/__tests__/browserSuites/events.spec.js b/src/__tests__/browserSuites/events.spec.js index a33dd79..e9280ac 100644 --- a/src/__tests__/browserSuites/events.spec.js +++ b/src/__tests__/browserSuites/events.spec.js @@ -72,9 +72,9 @@ export function withoutBindingTT(fetchMock, assert) { // Key binded as with getTreatment. tsStart = Date.now(); assert.ok(client.track('sometraffictype', 'someEvent', 10), 'client.track returns true if an event is added to the queue.'); - assert.ok(client.track('othertraffictype', 'genericEvent', 25), 'client.track returns true if event value is null and is added to the queue.'); - assert.ok(client.track('othertraffictype', 'genericEvent', 25, null), 'client.track returns true if event properties is null and is added to the queue.'); - assert.ok(client.track('othertraffictype', 'genericEvent', 24, { prop1: true, prop2: 'a', prop3: 2, prop4: null, willBeNulled: {} }), 'client.track returns true if event properties is an object and is added to the queue.'); + assert.ok(client.track('othertraffictype', 'genericEvent', 25), 'client.track returns true if event value is null and is added to the queue.'); + assert.ok(client.track('othertraffictype', 'genericEvent', 25, null), 'client.track returns true if event properties is null and is added to the queue.'); + assert.ok(client.track('othertraffictype', 'genericEvent', 24, { prop1: true, prop2: 'a', prop3: 2, prop4: null, willBeNulled: {} }), 'client.track returns true if event properties is an object and is added to the queue.'); assert.ok(client.track('othertraffictype', 'my.click.event'), 'client.track returns true if an event is added to the queue.'); assert.ok(client.track('othertraffictype', 'my.checkout.event', null), 'client.track returns true if an event is added to the queue.'); tsEnd = Date.now(); @@ -89,7 +89,7 @@ export function withoutBindingTT(fetchMock, assert) { assert.notOk(client.track(10, 'sometraffictype', 'someEvent'), 'client.track returns false if an event data was incorrect and it could not be added to the queue.'); assert.notOk(client.track('asd', 20, 'trafficType'), 'client.track returns false if an event data was incorrect and it could not be added to the queue.'); assert.notOk(client.track('othertraffictype', 'my.checkout.event', null, []), 'client.track returns false if an event properties was incorrect and it could not be added to the queue.'); - assert.notOk(client.track('othertraffictype', 'my.checkout.event', null, function() {}), 'client.track returns false if an event properties was incorrect and it could not be added to the queue.'); + assert.notOk(client.track('othertraffictype', 'my.checkout.event', null, function () { }), 'client.track returns false if an event properties was incorrect and it could not be added to the queue.'); assert.notOk(client.track('othertraffictype', 'my.checkout.event', null, 'asd'), 'client.track returns false if an event properties was incorrect and it could not be added to the queue.'); } @@ -143,8 +143,8 @@ export function bindingTT(fetchMock, assert) { tsStart = Date.now(); assert.ok(client.track('someEvent', 10), 'client.track returns true if an event is added to the queue.'); assert.ok(client.track('genericEvent', 25), 'client.track returns true if an event is added to the queue'); - assert.ok(client.track('genericEvent', 25, null), 'client.track returns true if event properties is null and is added to the queue.'); - assert.ok(client.track('genericEvent', 24, { prop1: true, prop2: 'a', prop3: 2, prop4: null, willBeNulled: {} }), 'client.track returns true if event properties is an object and is added to the queue.'); + assert.ok(client.track('genericEvent', 25, null), 'client.track returns true if event properties is null and is added to the queue.'); + assert.ok(client.track('genericEvent', 24, { prop1: true, prop2: 'a', prop3: 2, prop4: null, willBeNulled: {} }), 'client.track returns true if event properties is an object and is added to the queue.'); assert.ok(client.track('my.click.event'), 'client.track returns true if an event is added to the queue.'); assert.ok(client.track('my.checkout.event', null), 'client.track returns true if an event is added to the queue.'); tsEnd = Date.now(); @@ -158,6 +158,6 @@ export function bindingTT(fetchMock, assert) { assert.notOk(client.track('randomEvent', 'invalid value'), 'client.track returns false if event value is invalid and it could not be added to the queue.'); assert.notOk(client.track('my.checkout.event', ['some', 'stuff']), 'client.track returns false if event value is invalid and it could not be added to the queue.'); assert.notOk(client.track('my.checkout.event', null, []), 'client.track returns false if an event properties was incorrect and it could not be added to the queue.'); - assert.notOk(client.track('my.checkout.event', null, function() {}), 'client.track returns false if an event properties was incorrect and it could not be added to the queue.'); + assert.notOk(client.track('my.checkout.event', null, function () { }), 'client.track returns false if an event properties was incorrect and it could not be added to the queue.'); assert.notOk(client.track('my.checkout.event', null, 'asd'), 'client.track returns false if an event properties was incorrect and it could not be added to the queue.'); } diff --git a/src/__tests__/browserSuites/impressions-listener.spec.js b/src/__tests__/browserSuites/impressions-listener.spec.js index de6c41e..299daca 100644 --- a/src/__tests__/browserSuites/impressions-listener.spec.js +++ b/src/__tests__/browserSuites/impressions-listener.spec.js @@ -31,7 +31,7 @@ const config = { streamingEnabled: false }; -export default function(assert) { +export default function (assert) { const splitio = SplitFactory(config); const client = splitio.client(); const client2 = splitio.client({ matchingKey: 'marcio@split.io', bucketingKey: 'impr_bucketing_2' }); diff --git a/src/__tests__/browserSuites/manager.spec.js b/src/__tests__/browserSuites/manager.spec.js index ce13cd3..856242a 100644 --- a/src/__tests__/browserSuites/manager.spec.js +++ b/src/__tests__/browserSuites/manager.spec.js @@ -3,7 +3,7 @@ import splitChangesMockReal from '../mocks/splitchanges.real.json'; import map from 'lodash/map'; import { url } from '../testUtils'; -export default async function(settings, fetchMock, assert) { +export default async function (settings, fetchMock, assert) { fetchMock.getOnce({ url: url(settings, '/splitChanges?since=-1'), overwriteRoutes: true }, { status: 200, body: splitChangesMockReal }); const mockSplits = splitChangesMockReal; diff --git a/src/settings/defaults.ts b/src/settings/defaults.ts index d9d6a08..0190392 100644 --- a/src/settings/defaults.ts +++ b/src/settings/defaults.ts @@ -2,7 +2,7 @@ import { LogLevels, isLogLevelString } from '@splitsoftware/splitio-commons/src/ import { ConsentStatus, LogLevel } from '@splitsoftware/splitio-commons/src/types'; import { CONSENT_GRANTED } from '@splitsoftware/splitio-commons/src/utils/constants'; -const packageVersion = '0.9.2'; +const packageVersion = '0.9.3-rc.1'; /** * In browser, the default debug level, can be set via the `localStorage.splitio_debug` item. diff --git a/types/full/index.d.ts b/types/full/index.d.ts index 50536af..fd18469 100644 --- a/types/full/index.d.ts +++ b/types/full/index.d.ts @@ -1,4 +1,4 @@ -// Declaration file for Javascript Browser Split Software SDK +// Declaration file for JavaScript Browser Split Software SDK // Project: http://www.split.io/ // Definitions by: Nico Zelaya diff --git a/types/index.d.ts b/types/index.d.ts index 25d89a9..b9a1773 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1,4 +1,4 @@ -// Declaration file for Javascript Browser Split Software SDK +// Declaration file for JavaScript Browser Split Software SDK // Project: http://www.split.io/ // Definitions by: Nico Zelaya diff --git a/types/splitio.d.ts b/types/splitio.d.ts index 9a4d665..6482370 100644 --- a/types/splitio.d.ts +++ b/types/splitio.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Javascript Browser Split Software SDK +// Type definitions for JavaScript Browser Split Software SDK // Project: http://www.split.io/ // Definitions by: Nico Zelaya @@ -296,9 +296,14 @@ interface IStatusInterface extends IEventEmitter { */ interface IBasicClient extends IStatusInterface { /** - * Destroy the client instance. + * Destroys the client instance. + * + * In 'standalone' and 'partial consumer' modes, this method will flush any pending impressions and events. + * In 'standalone' mode, it also stops the synchronization of feature flag definitions with the backend. + * In 'consumer' and 'partial consumer' modes, this method also disconnects the SDK from the Pluggable storage. + * * @function destroy - * @returns {Promise} + * @returns {Promise} A promise that will be resolved once the client is destroyed. */ destroy(): Promise } @@ -541,7 +546,7 @@ declare namespace SplitIO { /** * Optional prefix to prevent any kind of data collision when having multiple factories using the same storage type. * @property {string} prefix - * @default SPLITIO + * @default 'SPLITIO' */ prefix?: string } @@ -565,7 +570,7 @@ declare namespace SplitIO { /** * Optional prefix to prevent any kind of data collision when having multiple factories using the same storage wrapper. * @property {string} prefix - * @default SPLITIO + * @default 'SPLITIO' */ prefix?: string, /** @@ -896,7 +901,7 @@ declare namespace SplitIO { * For "localhost" mode, use "localhost" as authorizationKey. * * @property {'standalone'} mode - * @default standalone + * @default 'standalone' */ mode?: 'standalone', /**