Skip to content

Release v2.2.0 #400

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 61 commits into from
Mar 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
0cb3a1f
Move validateCache call from splitChangesUpdater to syncManagerOnline
EmilianoSanchez Dec 18, 2024
d392cc8
Replace splits::checkCache method with storage::validateCache method
EmilianoSanchez Dec 18, 2024
8938334
Extract validation logic into SplitsCacheInLocal::validateCache method
EmilianoSanchez Dec 18, 2024
1b061eb
Simplify SplitsCacheInLocal::setChangeNumber moving clear logic to Sp…
EmilianoSanchez Dec 18, 2024
ffd724d
Remove SplitsCacheInLocal::storageHash
EmilianoSanchez Dec 18, 2024
e13f819
Move expirationTimestamp logic inside validateCache method
EmilianoSanchez Dec 18, 2024
b32e3ee
Move validateCache logic outside SplitsCacheInLocal
EmilianoSanchez Dec 18, 2024
679f841
Polishing
EmilianoSanchez Dec 18, 2024
6070b54
Merge branch 'cache_expiration_move_validateCache_call' into cache_ex…
EmilianoSanchez Dec 18, 2024
6605bfc
Refactor validateCache function
EmilianoSanchez Dec 18, 2024
9b8d36a
Clear segments and largeSegments caches
EmilianoSanchez Dec 18, 2024
87fbc4f
expirationDays configuration
EmilianoSanchez Dec 18, 2024
aca35fe
clearOnInit configuration
EmilianoSanchez Dec 18, 2024
534d6ca
Reuse Date.now() result
EmilianoSanchez Dec 19, 2024
6451cda
Handle clearOnInit case with older version of the SDK where lastClear…
EmilianoSanchez Dec 19, 2024
956c1df
Handle no cache: cache should not be clearer
EmilianoSanchez Dec 19, 2024
28b7fb9
Add unit test
EmilianoSanchez Dec 19, 2024
6dc1e61
rc
EmilianoSanchez Dec 19, 2024
5ea10ad
Add changelog entry
EmilianoSanchez Dec 19, 2024
7100734
Fix typo
EmilianoSanchez Dec 20, 2024
49c7f52
Merge pull request #378 from splitio/cache_expiration_move_validateCa…
EmilianoSanchez Dec 26, 2024
edb8995
Merge pull request #379 from splitio/cache_expiration_refactor_valida…
EmilianoSanchez Dec 26, 2024
760e2d0
Merge branch 'cache_expiration_baseline' into cache_expiration_valida…
EmilianoSanchez Dec 26, 2024
4069c24
Merge pull request #380 from splitio/cache_expiration_validateExpirat…
EmilianoSanchez Dec 26, 2024
4c7e781
Updated SDK_READY_FROM_CACHE event when using LOCALSTORAGE storage ty…
EmilianoSanchez Jan 2, 2025
d5a5eaa
rc
EmilianoSanchez Jan 2, 2025
d854156
Update changelog entry
EmilianoSanchez Jan 2, 2025
757778f
Merge branch 'main' into cache_expiration_baseline
EmilianoSanchez Jan 13, 2025
d56ea52
Merge branch 'cache_expiration_baseline' into SDKS-9171_sdk_ready_fro…
EmilianoSanchez Jan 13, 2025
1afa2f8
Merge branch 'SDKS-9171_sdk_ready_from_cache' into release_v2.1.0
EmilianoSanchez Jan 13, 2025
20d97aa
rc
EmilianoSanchez Jan 13, 2025
3ba1eb1
Merge branch 'main' into cache_expiration_baseline
EmilianoSanchez Jan 17, 2025
96e5aa6
Merge branch 'cache_expiration_baseline' into SDKS-9171_sdk_ready_fro…
EmilianoSanchez Jan 17, 2025
1cc5ad6
Remove unnecessary comment
EmilianoSanchez Feb 5, 2025
40124f7
Refactor Split cache: add 'update' method
EmilianoSanchez Feb 19, 2025
02c10e9
Polishing
EmilianoSanchez Feb 19, 2025
bcc770e
Replace deprecated String.substr() with String.slice()
EmilianoSanchez Feb 25, 2025
be49475
Move methods from KeyBuilder to KeyBuilderCS
EmilianoSanchez Feb 26, 2025
8377736
Polishing in splits cache
EmilianoSanchez Feb 26, 2025
6e7d790
Merge pull request #389 from splitio/refactor_splits_cache_update_method
EmilianoSanchez Feb 26, 2025
e57e045
Merge branch 'development' into cache_expiration_baseline
EmilianoSanchez Feb 26, 2025
fad235b
Add impression properties support
EmilianoSanchez Mar 14, 2025
a3ab306
Debug strategy for impressions with properties
EmilianoSanchez Mar 19, 2025
a976968
Add options to client methods
EmilianoSanchez Mar 19, 2025
b24882b
Unit tests
EmilianoSanchez Mar 20, 2025
7a7de54
Remove unnecessary 'track' function overwrite in clientAttributesDeco…
EmilianoSanchez Mar 20, 2025
ad36a0f
Updated CHANGES.txt file and additional polishing
EmilianoSanchez Mar 20, 2025
d66c7fc
Update type definitions
EmilianoSanchez Mar 20, 2025
bffcdaf
Add error handling
EmilianoSanchez Mar 25, 2025
491ed34
Enhance input validation to ignore empty object properties
EmilianoSanchez Mar 25, 2025
23f4909
Impression properties in consumer mode
EmilianoSanchez Mar 27, 2025
0abe3b2
rc
EmilianoSanchez Mar 27, 2025
89c14f0
Update type definitions
EmilianoSanchez Mar 27, 2025
9aebb37
Update DEBUG strategy
EmilianoSanchez Mar 28, 2025
81fbc9a
Merge pull request #398 from splitio/impression_properties
EmilianoSanchez Mar 28, 2025
eb408ad
Merge pull request #385 from splitio/SDKS-9171_sdk_ready_from_cache
EmilianoSanchez Mar 28, 2025
65dd894
Merge branch 'development' into cache_expiration_baseline
EmilianoSanchez Mar 28, 2025
ac8d76b
Merge pull request #383 from splitio/cache_expiration_baseline
EmilianoSanchez Mar 28, 2025
69f63d1
rc
EmilianoSanchez Mar 28, 2025
752f736
stable version
EmilianoSanchez Mar 28, 2025
d6a0e69
Merge pull request #401 from splitio/release_v2.2.0
EmilianoSanchez Mar 28, 2025
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
7 changes: 7 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2.2.0 (March 28, 2025)
- Added a new optional argument to the client `getTreatment` methods to allow passing additional evaluation options, such as a map of properties to append to the generated impressions sent to Split backend. Read more in our docs.
- Added two new configuration options for the SDK storage in browsers when using storage type `LOCALSTORAGE`:
- `storage.expirationDays` to specify the validity period of the rollout cache.
- `storage.clearOnInit` to clear the rollout cache on SDK initialization.
- Updated SDK_READY_FROM_CACHE event when using the `LOCALSTORAGE` storage type to be emitted alongside the SDK_READY event if it has not already been emitted.

2.1.0 (January 17, 2025)
- Added support for the new impressions tracking toggle available on feature flags, both respecting the setting and including the new field being returned on `SplitView` type objects. Read more in our docs.

Expand Down
311 changes: 74 additions & 237 deletions package-lock.json

Large diffs are not rendered by default.

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": "2.1.0",
"version": "2.2.0",
"description": "Split JavaScript SDK common components",
"main": "cjs/index.js",
"module": "esm/index.js",
Expand Down
3 changes: 0 additions & 3 deletions src/evaluator/parser/__tests__/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import { parser } from '..';
import { keyParser } from '../../../utils/key';
import { ISplitCondition } from '../../../dtos/types';
import { bucket } from '../../../utils/murmur3/murmur3';
import { loggerMock } from '../../../logger/__tests__/sdkLogger.mock';

test('PARSER / if user is in segment all 100%:on', async function () {
Expand Down Expand Up @@ -662,8 +661,6 @@ test('PARSER / if user is in segment all then split 20%:A,20%:B,60%:A', async fu
let evaluation = await evaluator(keyParser('aa'), 31, 100, 31);
expect(evaluation.treatment).toBe('A'); // 20%:A // bucket 6 with murmur3

console.log(bucket('b297', 31));

evaluation = await evaluator(keyParser('b297'), 31, 100, 31);
expect(evaluation.treatment).toBe('B'); // 20%:B // bucket 34 with murmur3

Expand Down
4 changes: 1 addition & 3 deletions src/logger/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ export const RETRIEVE_CLIENT_EXISTING = 28;
export const RETRIEVE_MANAGER = 29;
export const SYNC_OFFLINE_DATA = 30;
export const SYNC_SPLITS_FETCH = 31;
export const SYNC_SPLITS_NEW = 32;
export const SYNC_SPLITS_REMOVED = 33;
export const SYNC_SPLITS_SEGMENTS = 34;
export const SYNC_SPLITS_UPDATE = 32;
export const STREAMING_NEW_MESSAGE = 35;
export const SYNC_TASK_START = 36;
export const SYNC_TASK_EXECUTE = 37;
Expand Down
4 changes: 1 addition & 3 deletions src/logger/messages/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ export const codesDebug: [number, string][] = codesInfo.concat([
// synchronizer
[c.SYNC_OFFLINE_DATA, c.LOG_PREFIX_SYNC_OFFLINE + 'Feature flags data: \n%s'],
[c.SYNC_SPLITS_FETCH, c.LOG_PREFIX_SYNC_SPLITS + 'Spin up feature flags update using since = %s'],
[c.SYNC_SPLITS_NEW, c.LOG_PREFIX_SYNC_SPLITS + 'New feature flags %s'],
[c.SYNC_SPLITS_REMOVED, c.LOG_PREFIX_SYNC_SPLITS + 'Removed feature flags %s'],
[c.SYNC_SPLITS_SEGMENTS, c.LOG_PREFIX_SYNC_SPLITS + 'Segment names collected %s'],
[c.SYNC_SPLITS_UPDATE, c.LOG_PREFIX_SYNC_SPLITS + 'New feature flags %s. Removed feature flags %s. Segment names collected %s'],
[c.STREAMING_NEW_MESSAGE, c.LOG_PREFIX_SYNC_STREAMING + 'New SSE message received, with data: %s.'],
[c.SYNC_TASK_START, c.LOG_PREFIX_SYNC + ': Starting %s. Running each %s millis'],
[c.SYNC_TASK_EXECUTE, c.LOG_PREFIX_SYNC + ': Running %s'],
Expand Down
2 changes: 1 addition & 1 deletion src/logger/messages/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const codesError: [number, string][] = [
// input validation
[c.ERROR_EVENT_TYPE_FORMAT, '%s: you passed "%s", event_type must adhere to the regular expression /^[a-zA-Z0-9][-_.:a-zA-Z0-9]{0,79}$/g. This means an event_type must be alphanumeric, cannot be more than 80 characters long, and can only include a dash, underscore, period, or colon as separators of alphanumeric characters.'],
[c.ERROR_NOT_PLAIN_OBJECT, '%s: %s must be a plain object.'],
[c.ERROR_SIZE_EXCEEDED, '%s: the maximum size allowed for the properties is 32768 bytes, which was exceeded. Event not queued.'],
[c.ERROR_SIZE_EXCEEDED, '%s: the maximum size allowed for the properties is 32768 bytes, which was exceeded.'],
[c.ERROR_NOT_FINITE, '%s: value must be a finite number.'],
[c.ERROR_NULL, '%s: you passed a null or undefined %s. It must be a non-empty string.'],
[c.ERROR_TOO_LONG, '%s: %s too long. It must have 250 characters or less.'],
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 @@ -18,7 +18,7 @@ export const codesWarn: [number, string][] = codesError.concat([
[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.'],
[c.WARN_TRIMMING_PROPERTIES, '%s: Event has more than 300 properties. Some of them will be trimmed when processed.'],
[c.WARN_TRIMMING_PROPERTIES, '%s: more than 300 properties were provided. Some of them will be trimmed when processed.'],
[c.WARN_CONVERTING, '%s: %s "%s" is not of type string, converting.'],
[c.WARN_TRIMMING, '%s: %s "%s" has extra whitespace, trimming.'],
[c.WARN_NOT_EXISTENT_SPLIT, '%s: feature flag "%s" does not exist in this environment. Please double check what feature flags exist in the Split user interface.'],
Expand Down
14 changes: 13 additions & 1 deletion src/readiness/__tests__/readinessManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ import { EventEmitter } from '../../utils/MinEvents';
import { IReadinessManager } from '../types';
import { SDK_READY, SDK_UPDATE, SDK_SPLITS_ARRIVED, SDK_SEGMENTS_ARRIVED, SDK_READY_FROM_CACHE, SDK_SPLITS_CACHE_LOADED, SDK_READY_TIMED_OUT } from '../constants';
import { ISettings } from '../../types';
import { STORAGE_LOCALSTORAGE } from '../../utils/constants';

const settings = {
startup: {
readyTimeout: 0,
},
storage: {
type: STORAGE_LOCALSTORAGE
}
} as unknown as ISettings;

Expand Down Expand Up @@ -67,7 +71,14 @@ test('READINESS MANAGER / Ready event should be fired once', () => {
const readinessManager = readinessManagerFactory(EventEmitter, settings);
let counter = 0;

readinessManager.gate.on(SDK_READY_FROM_CACHE, () => {
expect(readinessManager.isReadyFromCache()).toBe(true);
expect(readinessManager.isReady()).toBe(true);
counter++;
});

readinessManager.gate.on(SDK_READY, () => {
expect(readinessManager.isReadyFromCache()).toBe(true);
expect(readinessManager.isReady()).toBe(true);
counter++;
});
Expand All @@ -79,7 +90,7 @@ test('READINESS MANAGER / Ready event should be fired once', () => {
readinessManager.splits.emit(SDK_SPLITS_ARRIVED);
readinessManager.segments.emit(SDK_SEGMENTS_ARRIVED);

expect(counter).toBe(1); // should be called once
expect(counter).toBe(2); // should be called once
});

test('READINESS MANAGER / Ready from cache event should be fired once', (done) => {
Expand All @@ -88,6 +99,7 @@ test('READINESS MANAGER / Ready from cache event should be fired once', (done) =

readinessManager.gate.on(SDK_READY_FROM_CACHE, () => {
expect(readinessManager.isReadyFromCache()).toBe(true);
expect(readinessManager.isReady()).toBe(false);
counter++;
});

Expand Down
5 changes: 5 additions & 0 deletions src/readiness/readinessManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ISettings } from '../types';
import SplitIO from '../../types/splitio';
import { SDK_SPLITS_ARRIVED, SDK_SPLITS_CACHE_LOADED, SDK_SEGMENTS_ARRIVED, SDK_READY_TIMED_OUT, SDK_READY_FROM_CACHE, SDK_UPDATE, SDK_READY } from './constants';
import { IReadinessEventEmitter, IReadinessManager, ISegmentsEventEmitter, ISplitsEventEmitter } from './types';
import { STORAGE_LOCALSTORAGE } from '../utils/constants';

function splitsEventEmitterFactory(EventEmitter: new () => SplitIO.IEventEmitter): ISplitsEventEmitter {
const splitsEventEmitter = objectAssign(new EventEmitter(), {
Expand Down Expand Up @@ -114,6 +115,10 @@ export function readinessManagerFactory(
isReady = true;
try {
syncLastUpdate();
if (!isReadyFromCache && settings.storage?.type === STORAGE_LOCALSTORAGE) {
isReadyFromCache = true;
gate.emit(SDK_READY_FROM_CACHE);
}
gate.emit(SDK_READY);
} catch (e) {
// throws user callback exceptions in next tick
Expand Down
Loading