Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
7991440
fixed node-fetch vulnerability, and fetch API rejection handling
EmilianoSanchez Feb 1, 2022
d8824d2
added remaining unit tests and modules from JS SDK
EmilianoSanchez Feb 3, 2022
3a5141a
added isBrowserClient flag to SDK clients
EmilianoSanchez Feb 3, 2022
cdd8558
upgrade node-fetch for vulnerability fix
EmilianoSanchez Feb 7, 2022
a3664ab
Merge pull request #76 from splitio/migration_unit_tests
EmilianoSanchez Feb 7, 2022
1849671
Merge branch 'development' into migration_updates
EmilianoSanchez Feb 7, 2022
14434bf
Merge pull request #75 from splitio/migration_updates
EmilianoSanchez Feb 10, 2022
f4fbd1a
update push manager and add unit tests
EmilianoSanchez Feb 10, 2022
fbf6192
CI update to use node v14, which doesn't close on unhandled promise r…
EmilianoSanchez Feb 10, 2022
bd92314
polishing
EmilianoSanchez Feb 10, 2022
8821ad1
remove guard conditions from SyncManager start/stop. They are not req…
EmilianoSanchez Feb 11, 2022
fedb5aa
Removed some types and interfaces, to clean up code
EmilianoSanchez Feb 13, 2022
5396747
Merge pull request #77 from splitio/migration_updates
EmilianoSanchez Feb 14, 2022
67769a3
updated dependencies and added runtime validators from JS SDK to reus…
EmilianoSanchez Feb 14, 2022
e3c9ebd
update logger types
EmilianoSanchez Feb 15, 2022
c9eaafa
polish on some log messages and added value to integrations
EmilianoSanchez Feb 16, 2022
34dbeaa
added missing method in push manager
EmilianoSanchez Feb 16, 2022
16e4ace
Merge pull request #78 from splitio/migration_updates
EmilianoSanchez Feb 16, 2022
b6fe47d
implementation and unit tests
EmilianoSanchez Feb 17, 2022
2478bbc
move node runtime validator to JS SDK
EmilianoSanchez Feb 17, 2022
3d470c0
Merge pull request #80 from splitio/migration_updates
EmilianoSanchez Feb 17, 2022
7d3af30
Merge branch 'development' into impressions_queue_size_limit
EmilianoSanchez Feb 17, 2022
c0a1b69
Merge pull request #79 from splitio/impressions_queue_size_limit
EmilianoSanchez Feb 22, 2022
0e67f8a
implementation and unit tests
EmilianoSanchez Feb 23, 2022
5862079
updated settings interface
EmilianoSanchez Feb 23, 2022
b2dfd2e
update submitters to not drop data if queues are full but consent has…
EmilianoSanchez Feb 23, 2022
7342389
Modify browser listener flow to avoid flushing data without consent
EmilianoSanchez Feb 23, 2022
bae3e5e
added getter & setter for user consent in factory
EmilianoSanchez Feb 24, 2022
961f56c
constants to uppercase
EmilianoSanchez Feb 24, 2022
8d1714c
Merge pull request #81 from splitio/user_consent_handle_trackers_and_…
EmilianoSanchez Feb 24, 2022
81e7031
Merge branch 'user_consent_handle_trackers_and_submitters' into user_…
EmilianoSanchez Feb 24, 2022
37cc9fb
constants to uppercase
EmilianoSanchez Feb 24, 2022
86448b5
Merge pull request #82 from splitio/user_consent_browser_listener
EmilianoSanchez Feb 24, 2022
e978c07
Merge branch 'user_consent_baseline' into user_consent_setter_and_getter
EmilianoSanchez Feb 24, 2022
9669ad8
constants to uppercase
EmilianoSanchez Feb 24, 2022
fb7f3f0
validate config.userConsent
EmilianoSanchez Feb 24, 2022
14105d8
fixed type check issue
EmilianoSanchez Feb 24, 2022
881e534
Merge branch 'user_consent_setter_and_getter' into user_consent_confi…
EmilianoSanchez Feb 24, 2022
9e71ee2
fixed test
EmilianoSanchez Feb 24, 2022
3dc3638
localstorage update
EmilianoSanchez Feb 25, 2022
d855259
Merge pull request #85 from splitio/change/localstorageKeyChanges
EmilianoSanchez Feb 25, 2022
692d032
Merge branch 'user_consent_baseline' into user_consent_setter_and_getter
EmilianoSanchez Mar 2, 2022
cb95986
Merge branch 'user_consent_setter_and_getter' into user_consent_confi…
EmilianoSanchez Mar 2, 2022
a16b603
prepare rc
EmilianoSanchez Mar 2, 2022
a4bf0fa
update validatePrefix function, for consistency with JS SDK
EmilianoSanchez Mar 3, 2022
0e36a90
feedback and polishing
EmilianoSanchez Mar 3, 2022
57d2191
Merge pull request #84 from splitio/user_consent_config_validation
EmilianoSanchez Mar 3, 2022
582b53a
Merge pull request #83 from splitio/user_consent_setter_and_getter
EmilianoSanchez Mar 3, 2022
002912f
fixed issue with event submitter push window
EmilianoSanchez Mar 4, 2022
8255eae
validate undefined authorizationKey in SSEClient
EmilianoSanchez Mar 8, 2022
9ab79d2
move consent check from client to trackers
EmilianoSanchez Mar 8, 2022
ac554e2
Merge pull request #87 from splitio/user_consent_polishing
EmilianoSanchez Mar 8, 2022
6bff120
fixed map, to use ponyfill on browsers with partial support of Map co…
EmilianoSanchez Mar 9, 2022
bbaed1f
updated isClientSide flag
EmilianoSanchez Mar 14, 2022
6eb52fc
code syntax refactor
EmilianoSanchez Mar 15, 2022
7620e08
in-transit encryption support added
EmilianoSanchez Mar 15, 2022
20cb703
Merge pull request #88 from splitio/user_consent_trackers_refactor
EmilianoSanchez Mar 15, 2022
05637d0
forwarding connectionTimeout to ioredis connectTimeout
EmilianoSanchez Mar 17, 2022
ff721fd
Merge pull request #89 from splitio/redis_intransit_encryption_support
EmilianoSanchez Mar 25, 2022
e1e6698
implementation and tests
EmilianoSanchez Mar 25, 2022
c5aee70
fixed type issue
EmilianoSanchez Mar 25, 2022
4621c01
updated isObject util function
EmilianoSanchez Mar 28, 2022
94173b5
Merge pull request #91 from splitio/isobject_util_update
mmelograno Mar 28, 2022
ec387c2
Bump minimist from 1.2.5 to 1.2.6
dependabot[bot] Mar 29, 2022
cb32d4e
performance improvement
EmilianoSanchez Mar 29, 2022
b9161b2
size improvement
EmilianoSanchez Mar 29, 2022
9aac950
Merge pull request #92 from splitio/dependabot/npm_and_yarn/minimist-…
EmilianoSanchez Mar 29, 2022
5bcf761
updated some type signatures
EmilianoSanchez Mar 29, 2022
4242996
Merge pull request #93 from splitio/isobject_util_update
EmilianoSanchez Mar 29, 2022
5fa4af7
Merge branch 'user_consent_baseline' into settings_key_and_tt_validation
EmilianoSanchez Mar 29, 2022
5020990
handle key and TT validation separately
EmilianoSanchez Mar 29, 2022
0ca9ff5
fixed issue with a info log
EmilianoSanchez Mar 31, 2022
f053eaf
added info log for initial user consent
EmilianoSanchez Mar 31, 2022
dd08b91
Merge pull request #90 from splitio/settings_key_and_tt_validation
EmilianoSanchez Mar 31, 2022
9e98b33
Merge pull request #86 from splitio/user_consent_baseline
EmilianoSanchez Apr 4, 2022
a03092f
prepare release v1.3.0
EmilianoSanchez Apr 4, 2022
2345419
refactors regarding user consent API
EmilianoSanchez Apr 5, 2022
dea639b
update in param
EmilianoSanchez Apr 5, 2022
50fbef4
added gha for updating license year
mmelograno Apr 5, 2022
5f905fd
Merge pull request #96 from splitio/gha-license-year
mmelograno Apr 5, 2022
7c424b1
Merge pull request #95 from splitio/user_consent_update
EmilianoSanchez Apr 5, 2022
985239a
Merge branch 'development' into release_v1.3.0
EmilianoSanchez Apr 5, 2022
b849b8f
update changelog
EmilianoSanchez Apr 6, 2022
66f8198
Merge pull request #94 from splitio/release_v1.3.0
EmilianoSanchez Apr 6, 2022
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- name: Set up nodejs
uses: actions/setup-node@v2
with:
node-version: 'lts/*'
node-version: '14'
cache: 'npm'

- name: npm CI
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/update-license-year.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Update License Year

on:
schedule:
- cron: "0 3 1 1 *" # 03:00 AM on January 1
push:
branches:
- main
- master

permissions:
contents: write
pull-requests: write

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set Current year
run: "echo CURRENT=$(date +%Y) >> $GITHUB_ENV"

- name: Set Previous Year
run: "echo PREVIOUS=$(($CURRENT-1)) >> $GITHUB_ENV"

- name: Update LICENSE
uses: jacobtomlinson/gha-find-replace@v2
with:
find: ${{ env.PREVIOUS }}
replace: ${{ env.CURRENT }}
include: "LICENSE"
regex: false

- name: Commit files
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git commit -m "Updated License Year" -a

- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: Update License Year
branch: update-license
14 changes: 14 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
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.
- Added support to accept TLS configuration options to the Redis storage in NodeJS. Read more in our docs.
- Updated format for MySegments keys in LocalStorage, keeping backwards compatibility (issue https://github.com/splitio/javascript-client/issues/638).
- Updated some modules due to general polishing and refactors, including updates in some log messages.
- Updated some dependencies for vulnerability fixes.
- Bugfixing - Updated internal isObject utility function, to avoid unexpected behaviors on frameworks and libraries that uses multiple VM contexts, like NuxtJS dev server.
- Bugfixing - Fixed validation of `core.key` SDK configuration param, to parse it into a string and log a warning when passing a number (Related to issue https://github.com/splitio/react-native-client/issues/19).
- Bugfixing - Fixed validation of `sync.impressionsMode` SDK configuration param, to avoid an exception on SplitFactory instantiation when passing a non-string value.
- Bugfixing - Fixed an issue with `connectionTimeout` options params of Redis storage, that was being ignored and not passed down to the underlying ioredis client.
- Bugfixing - Fixed streaming synchronization issue with multiple clients.
- Bugfixing - Fixed issue with internal Map ponyfill that results in logger not working properly on IE11 browser.

1.2.0 (January 19, 2022)
- Added support to SDK clients on browser to optionally bind attributes to the client, keeping these loaded within the SDK along with the user ID, for easier usage when requesting flag.

Expand Down
124 changes: 64 additions & 60 deletions package-lock.json

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

14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@splitsoftware/splitio-commons",
"version": "1.2.0",
"version": "1.3.0",
"description": "Split Javascript SDK common components",
"main": "cjs/index.js",
"module": "esm/index.js",
Expand All @@ -20,8 +20,8 @@
"check:lint": "eslint src --ext .js,.ts",
"check:types": "tsc --noEmit",
"build": "npm run build:cjs && npm run build:esm",
"build:esm": "rimraf esm && tsc -m es2015 --outDir esm -d true --declarationDir types --importHelpers",
"build:cjs": "rimraf cjs && tsc -m CommonJS --outDir cjs --importHelpers",
"build:esm": "rimraf esm && tsc -m es2015 --outDir esm -d true --declarationDir types",
"build:cjs": "rimraf cjs && tsc -m CommonJS --outDir cjs",
"test": "jest",
"test:coverage": "jest --coverage",
"publish:rc": "npm run check && npm run test && npm run build && npm publish --tag rc",
Expand All @@ -44,7 +44,7 @@
"bugs": "https://github.com/splitio/javascript-commons/issues",
"homepage": "https://github.com/splitio/javascript-commons#readme",
"dependencies": {
"tslib": "^2.1.0"
"tslib": "^2.3.1"
},
"devDependencies": {
"@types/google.analytics": "0.0.40",
Expand All @@ -58,17 +58,17 @@
"eslint": "^7.32.0",
"eslint-plugin-compat": "3.7.0",
"eslint-plugin-import": "^2.25.3",
"fetch-mock": "^9.10.7",
"fetch-mock": "^9.11.0",
"ioredis": "^4.28.0",
"jest": "^27.2.3",
"jest-localstorage-mock": "^2.4.3",
"js-yaml": "^3.14.0",
"lodash": "^4.17.21",
"node-fetch": "^2.6.1",
"node-fetch": "^2.6.7",
"redis-server": "1.2.2",
"rimraf": "^3.0.2",
"ts-jest": "^27.0.5",
"typescript": "^4.0.2"
"typescript": "4.4.4"
},
"sideEffects": false
}
5 changes: 3 additions & 2 deletions src/__tests__/testUtils/fetchMock.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { sandbox } from 'fetch-mock';
// http://www.wheresrhys.co.uk/fetch-mock/#usageinstallation
import fetchMockLib from 'fetch-mock';

const fetchMock = sandbox();
const fetchMock = fetchMockLib.sandbox();

// config the fetch mock to chain routes (appends the new route to the list of routes)
fetchMock.config.overwriteRoutes = false;
Expand Down
45 changes: 45 additions & 0 deletions src/consent/__tests__/sdkUserConsent.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { createUserConsentAPI } from '../sdkUserConsent';
import { syncTaskFactory } from '../../sync/__tests__/syncTask.mock';
import { fullSettings } from '../../utils/settingsValidation/__tests__/settings.mocks';

test('createUserConsentAPI', () => {
const settings = { ...fullSettings, userConsent: 'UNKNOWN' };
const syncManager = { submitter: syncTaskFactory() };
const storage = {
events: { clear: jest.fn() },
impressions: { clear: jest.fn() }
};

// @ts-ignore
const props = createUserConsentAPI({ settings, syncManager, storage });

// getUserConsent returns settings.userConsent
expect(props.getStatus()).toBe(settings.userConsent);
expect(props.getStatus()).toBe(props.Status.UNKNOWN);

// setting user consent to 'GRANTED'
expect(props.setStatus(true)).toBe(true);
expect(props.setStatus(true)).toBe(true); // calling again has no affect
expect(syncManager.submitter.start).toBeCalledTimes(1); // submitter resumed
expect(syncManager.submitter.stop).toBeCalledTimes(0);
expect(props.getStatus()).toBe(props.Status.GRANTED);

// setting user consent to 'DECLINED'
expect(props.setStatus(false)).toBe(true);
expect(props.setStatus(false)).toBe(true); // calling again has no affect
expect(syncManager.submitter.start).toBeCalledTimes(1);
expect(syncManager.submitter.stop).toBeCalledTimes(1); // submitter paused
expect(props.getStatus()).toBe(props.Status.DECLINED);
expect(storage.events.clear).toBeCalledTimes(1); // storage tracked data dropped
expect(storage.impressions.clear).toBeCalledTimes(1);

// Invalid values have no effect
expect(props.setStatus('DECLINED')).toBe(false); // strings are not valid
expect(props.setStatus('GRANTED')).toBe(false);
expect(props.setStatus(undefined)).toBe(false);
expect(props.setStatus({})).toBe(false);

expect(syncManager.submitter.start).toBeCalledTimes(1);
expect(syncManager.submitter.stop).toBeCalledTimes(1);
expect(props.getStatus()).toBe(props.Status.DECLINED);
});
8 changes: 8 additions & 0 deletions src/consent/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ISettings } from '../types';
import { CONSENT_GRANTED } from '../utils/constants';

export function isConsentGranted(settings: ISettings) {
const userConsent = settings.userConsent;
// undefined userConsent is handled as granted (default)
return !userConsent || userConsent === CONSENT_GRANTED;
}
Loading