Skip to content
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

Release v2.0.0 #364

Merged
merged 212 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
212 commits
Select commit Hold shift + click to select a range
4506089
Add largeSegments cache in client-side InMemory storage
EmilianoSanchez Jul 10, 2024
ee60628
Remove unused KeyBuilderCS::buildOldSegmentNameKey method
EmilianoSanchez Jul 10, 2024
9ac6c25
Add largeSegments cache in client-side InLocal storage
EmilianoSanchez Jul 10, 2024
162b092
Unit tests
EmilianoSanchez Jul 10, 2024
764bb49
Add IN_LARGE_SEGMENT matcher
EmilianoSanchez Jul 10, 2024
b56f142
Added new configuration options
EmilianoSanchez Jul 11, 2024
6827eb6
Add new endpoint for myLargeSegments
EmilianoSanchez Jul 11, 2024
3c7d05f
Update Readiness Manager to handle largeSegments sync if largeSegment…
EmilianoSanchez Jul 11, 2024
fac27f9
Add unit tests
EmilianoSanchez Jul 11, 2024
84a1cd3
Add comment
EmilianoSanchez Jul 12, 2024
a33c306
Merge pull request #320 from splitio/SDKS-8593_large_segments_storage
EmilianoSanchez Jul 12, 2024
cd7fad9
Merge pull request #322 from splitio/SDKS-8407_large_segments_matcher
EmilianoSanchez Jul 12, 2024
633efc5
Merge pull request #323 from splitio/SDKS-8407_new_configs
EmilianoSanchez Jul 12, 2024
19c02cf
Merge branch 'development' into SDKS-8407_baseline
EmilianoSanchez Jul 12, 2024
04ac922
Refactor usesSegments method for usesMatcher
EmilianoSanchez Jul 12, 2024
afa72db
Merge branch 'SDKS-8407_splits_cache_updates' into SDKS-8407_new_endp…
EmilianoSanchez Jul 12, 2024
974a161
Merge branch 'SDKS-8407_new_endpoint' into SDKS-8407_readiness
EmilianoSanchez Jul 12, 2024
a5f6f36
Add myLargeSegmentsSyncTasks
EmilianoSanchez Jul 12, 2024
e8969bc
Refactor
EmilianoSanchez Jul 15, 2024
e42e09f
Remove redundant comment
EmilianoSanchez Jul 15, 2024
274c9d5
Handle MY_LARGE_SEGMENTS_UPDATE streaming notifications
EmilianoSanchez Jul 15, 2024
6bb6b57
Update TelemetryCache to handle new notification updates
EmilianoSanchez Jul 15, 2024
af4d9f1
Fix test
EmilianoSanchez Jul 15, 2024
8f7caab
Add new fields to telemetry payloads
EmilianoSanchez Jul 15, 2024
a18ff4a
Handle largeSegments list in MY_LARGE_SEGMENTS_UPDATE notifications
EmilianoSanchez Jul 15, 2024
922245c
Merge pull request #324 from splitio/SDKS-8407_splits_cache_updates
EmilianoSanchez Jul 16, 2024
cc82e28
Merge pull request #325 from splitio/SDKS-8407_new_endpoint
EmilianoSanchez Jul 16, 2024
82e4e9c
Merge pull request #326 from splitio/SDKS-8407_readiness
EmilianoSanchez Jul 16, 2024
d063560
Merge branch 'SDKS-8407_baseline' into SDKS-8407_sync_tasks
EmilianoSanchez Jul 17, 2024
cc92658
Update SyncManagerOnline and fix test
EmilianoSanchez Jul 17, 2024
c90545f
Merge branch 'SDKS-8407_sync_tasks' into SDKS-8407_streaming
EmilianoSanchez Jul 17, 2024
a2c68df
Handle delays for myLargeSegments fetch
EmilianoSanchez Jul 17, 2024
aad4621
Merge branch 'SDKS-8407_streaming_delay' into SDKS-8407_telemetry
EmilianoSanchez Jul 17, 2024
9434695
rc
EmilianoSanchez Jul 17, 2024
3765ec2
Update comments
EmilianoSanchez Jul 17, 2024
8778633
Merge pull request #327 from splitio/SDKS-8407_sync_tasks
EmilianoSanchez Jul 17, 2024
9212f67
Update MySegmentsFetcher to handle /myLargeSegments response payload
EmilianoSanchez Jul 17, 2024
57fd39b
Add unit tests and fix some typos
EmilianoSanchez Jul 19, 2024
62db638
Merge pull request #328 from splitio/SDKS-8407_streaming
EmilianoSanchez Jul 19, 2024
4706961
Merge branch 'SDKS-8407_baseline' into SDKS-8407_streaming_delay
EmilianoSanchez Jul 19, 2024
25180c2
Unit test
EmilianoSanchez Jul 19, 2024
688c617
Merge branch 'SDKS-8407_streaming_delay' into SDKS-8407_telemetry
EmilianoSanchez Jul 19, 2024
7992696
Merge branch 'SDKS-8407_telemetry' into SDKS-8407_polishing
EmilianoSanchez Jul 19, 2024
4374f94
Handle delay in UpdateWorker so that the timer can be cleared when sy…
EmilianoSanchez Jul 19, 2024
0affd41
Merge pull request #331 from splitio/SDKS-8407_telemetry
EmilianoSanchez Jul 19, 2024
227b7ef
Merge pull request #330 from splitio/SDKS-8407_streaming_delay
EmilianoSanchez Jul 19, 2024
574f1c1
Merge branch 'SDKS-8407_baseline' into SDKS-8407_polishing
EmilianoSanchez Jul 19, 2024
4b6676f
Readiness event fixes
EmilianoSanchez Jul 19, 2024
e6cb5c3
Refactor to simplify some code
EmilianoSanchez Jul 19, 2024
d2f42e8
rc
EmilianoSanchez Jul 19, 2024
cd00e3f
Fix typos
EmilianoSanchez Jul 23, 2024
284b125
Update types
EmilianoSanchez Jul 23, 2024
c075f6b
Handle MY_LARGE_SEGMENTS_UPDATE segment removal event with multiple s…
EmilianoSanchez Jul 23, 2024
f9ea1ca
rc
EmilianoSanchez Jul 23, 2024
86af495
rc with fixed type
EmilianoSanchez Jul 24, 2024
2a5a2ca
Handle some corner cases in MySegmentsUpdateWorker
EmilianoSanchez Jul 25, 2024
271303c
Polishing
EmilianoSanchez Jul 25, 2024
b7fe46f
rc
EmilianoSanchez Jul 25, 2024
391491b
Merge pull request #333 from splitio/SDKS-8407_readiness_refactors
EmilianoSanchez Jul 25, 2024
914355d
Merge pull request #334 from splitio/SDKS-8407_sync_refactors
EmilianoSanchez Jul 25, 2024
293a824
Filter myLargeSegments channels if largeSegmentsEnabled is false
EmilianoSanchez Jul 30, 2024
5dda9de
Update default FLAG_SPEC_VERSION to 1.2
EmilianoSanchez Jul 30, 2024
fbd7ee9
rc
EmilianoSanchez Jul 30, 2024
12c7233
Update test
EmilianoSanchez Jul 31, 2024
50e00b6
Updates in telemetry
EmilianoSanchez Aug 1, 2024
dcd20bd
Specialize a few argument types to avoid TS errors
EmilianoSanchez Aug 6, 2024
9d21c55
Handle logic for 'h' none
EmilianoSanchez Aug 6, 2024
b952f32
rc
EmilianoSanchez Aug 6, 2024
9052572
Update IMyLargeSegmentsResponse type
EmilianoSanchez Aug 7, 2024
5f6074c
Remove LS configs and unify endpoint
EmilianoSanchez Aug 20, 2024
56b7698
Update PushManager to have 2 MySegmentUpdateWorker instances per clie…
EmilianoSanchez Aug 20, 2024
004b707
Unify MY_SEGMENTS_UPDATE_V3 and MY_LARGE_SEGMENTS_UPDATE notifications
EmilianoSanchez Aug 23, 2024
fff7c45
New DTO for /memberships endpoint
EmilianoSanchez Aug 23, 2024
21a862a
Add getChangeNumber method to mySegments storages
EmilianoSanchez Aug 27, 2024
c5cd281
Unit tests
EmilianoSanchez Aug 27, 2024
60ca5f1
Merge branch 'SDKS-8407_mySegments_storages_updates' into SDKS-8407_u…
EmilianoSanchez Aug 27, 2024
2f02cf9
Polishing
EmilianoSanchez Aug 28, 2024
a4e97a9
rc
EmilianoSanchez Aug 29, 2024
f6bac4d
Reuse code for mySegment storages
EmilianoSanchez Aug 30, 2024
aaefc2b
Merge branch 'SDKS-8407_mySegments_storages_updates' into SDKS-8407_u…
EmilianoSanchez Aug 30, 2024
f49ccac
Update resetSegments method to handle instant updates
EmilianoSanchez Aug 30, 2024
fb8bd8f
Notification refactors: t->type, MEMBERSHIP_MS_UPDATE, MEMBERSHIP_LS_…
EmilianoSanchez Sep 1, 2024
4e290ee
Merge branch 'SDKS-8407_unify_notifications' into SDKS-8407_mySegment…
EmilianoSanchez Sep 1, 2024
8917d5b
Refactor: MEMBERSHIPS constant for telemetry
EmilianoSanchez Sep 1, 2024
680d889
Refactor to reduce code
EmilianoSanchez Sep 1, 2024
7c5396a
Add optional till param to fetchMemberships endpoint
EmilianoSanchez Sep 1, 2024
68c0c14
rc
EmilianoSanchez Sep 2, 2024
05e82f0
Merge branch 'SDKS-8407_mySegments_storages_updates_part2' into SDKS-…
EmilianoSanchez Sep 2, 2024
451d6f5
Add CDN bypass logic to MySegmentsUpdateWorker
EmilianoSanchez Sep 2, 2024
6a296cd
Refactor: keep a single MySegmentsUpdateWorker per user key
EmilianoSanchez Sep 2, 2024
eae7b3e
Refactor notification types
EmilianoSanchez Sep 3, 2024
1ca0be8
Merge pull request #337 from splitio/SDKS-8407_unify_endpoint
EmilianoSanchez Sep 3, 2024
7941bec
Merge pull request #339 from splitio/SDKS-8407_mySegments_storages_up…
EmilianoSanchez Sep 3, 2024
9b93a43
Merge pull request #338 from splitio/SDKS-8407_unify_notifications
EmilianoSanchez Sep 3, 2024
91802ec
Merge pull request #340 from splitio/SDKS-8407_mySegments_storages_up…
EmilianoSanchez Sep 3, 2024
0a87cfd
Merge branch 'SDKS-8407_baseline' into SDKS-8407_memberships_cdn_bypass
EmilianoSanchez Sep 3, 2024
907950b
Refactor notification types
EmilianoSanchez Sep 3, 2024
47040f0
Refactor telemetry largeSegmentCount
EmilianoSanchez Sep 3, 2024
2d49c01
rc
EmilianoSanchez Sep 3, 2024
8e0a1e3
Adding some corner cases to unit tests
EmilianoSanchez Sep 4, 2024
439eb3d
getDelay unit tests
EmilianoSanchez Sep 9, 2024
b1d4acb
Merge branch 'main' into SDKS-8407_baseline
EmilianoSanchez Sep 9, 2024
3a861d7
Merge branch 'SDKS-8407_baseline' into SDKS-8407_memberships_cdn_bypass
EmilianoSanchez Sep 9, 2024
f2ac28e
Merge pull request #341 from splitio/SDKS-8407_memberships_cdn_bypass
EmilianoSanchez Sep 9, 2024
1921de9
Update changelog entry
EmilianoSanchez Sep 9, 2024
d55fb78
Refactor IN_LARGE_SEGMENT matcher
EmilianoSanchez Sep 16, 2024
2ce5a64
Rollback fetch-mock upgrade
EmilianoSanchez Sep 16, 2024
76f785d
Add clients map to factory context
EmilianoSanchez Sep 17, 2024
2c8335e
Add factory.destroy method
EmilianoSanchez Sep 17, 2024
bcdff09
Add types and changelog entry
EmilianoSanchez Sep 17, 2024
670d213
Update detroy method to stop uniqueKeysTracker jobs in the main clien…
EmilianoSanchez Sep 18, 2024
f17519b
Update detroy method to stop uniqueKeysTracker jobs in the main clien…
EmilianoSanchez Sep 18, 2024
4ca9a5b
Merge branch 'update_destroy_method' into add_factory_destroy_method
EmilianoSanchez Sep 18, 2024
6797cfb
Update changelog entry
EmilianoSanchez Sep 18, 2024
4de7204
Segments cache: replace addToSegment, removeFromSegment and setChange…
EmilianoSanchez Sep 19, 2024
2fb780b
Remove addToSegment, removeFromSegment and setChangeNumber from ISegm…
EmilianoSanchez Sep 19, 2024
f6fa56e
Merge pull request #346 from splitio/SDKS-8407_polishing
EmilianoSanchez Sep 19, 2024
4e421c7
Merge branch 'SDKS-8407_baseline' into refactor_segments_cache_update…
EmilianoSanchez Sep 19, 2024
58e9ad0
Merge pull request #347 from splitio/update_destroy_method
EmilianoSanchez Sep 20, 2024
1b7a18a
Update changelog entry
EmilianoSanchez Sep 20, 2024
f6f245d
Update comment
EmilianoSanchez Sep 20, 2024
185ee24
Merge branch 'development' into add_factory_destroy_method
EmilianoSanchez Sep 20, 2024
9cd4e33
Merge pull request #349 from splitio/add_factory_destroy_method
EmilianoSanchez Sep 20, 2024
cbfdb29
Merge branch 'development' into SDKS-8407_baseline
EmilianoSanchez Sep 20, 2024
aed68a7
rc
EmilianoSanchez Sep 20, 2024
d2fbd1b
Unit test for factory destroy
EmilianoSanchez Sep 20, 2024
38092dc
Add onReadyFromCacheCb to storage factory params for code cleanup
EmilianoSanchez Oct 1, 2024
cf822b9
Add changelog entry
EmilianoSanchez Oct 1, 2024
5f865f3
Draft implementation of loadData and getSnapshot methods
EmilianoSanchez Oct 1, 2024
6ab2bc8
Polishing
EmilianoSanchez Oct 1, 2024
d653de6
Handle SplitKeyObject
EmilianoSanchez Oct 3, 2024
bf74104
Move SplitFactory side-effects into an init function, to expose for i…
EmilianoSanchez Oct 3, 2024
37d05eb
rc
EmilianoSanchez Oct 3, 2024
7b7feea
rename isPure to lazyInit
EmilianoSanchez Oct 4, 2024
9176f67
Bugfix on server-side polling manager
EmilianoSanchez Oct 4, 2024
cefdec9
Merge pull request #355 from splitio/bugfix_server_side_polling_manager
EmilianoSanchez Oct 4, 2024
e33101b
Merge branch 'development' into SDKS-8407_baseline
EmilianoSanchez Oct 4, 2024
6af7ee0
Merge branch 'SDKS-8407_baseline' into refactor_storage_emits_ready_f…
EmilianoSanchez Oct 4, 2024
1a00943
Merge branch 'refactor_storage_emits_ready_from_cache' into data_load…
EmilianoSanchez Oct 4, 2024
5eac7b1
changelog entry
EmilianoSanchez Oct 4, 2024
99f58b3
Merge branch 'data_loader_for_ssr' into init_function_for_side_effects
EmilianoSanchez Oct 4, 2024
fcdeb1b
changelog entry
EmilianoSanchez Oct 4, 2024
bdf69e8
Fix duplicated /memberships fetch of non-default clients when using l…
EmilianoSanchez Oct 5, 2024
7b6e433
Removed the deprecated GOOGLE_ANALYTICS_TO_SPLIT and SPLIT_TO_GOOGLE_…
EmilianoSanchez Oct 4, 2024
bb9a458
Update objectAssign polyfill to reduce code size
EmilianoSanchez Oct 7, 2024
9d97256
Update compat linter: 'defaults, ie 10, node 6' -> 'defaults, node 14'
EmilianoSanchez Oct 7, 2024
f82c7c6
Removed Map and Set polyfills
EmilianoSanchez Oct 7, 2024
781e72a
Simplify set utils and add CHANGELOG entry
EmilianoSanchez Oct 7, 2024
e1a49f5
Removed eslint-disable-next-line compat/compat
EmilianoSanchez Oct 8, 2024
4c979f7
Removed the migration logic for the old format of MySegments keys in …
EmilianoSanchez Oct 8, 2024
66210e6
Removed the function, which handled the logic to bound an optional t…
EmilianoSanchez Oct 8, 2024
9af5a94
Update changelog entry
EmilianoSanchez Oct 8, 2024
464102f
rc
EmilianoSanchez Oct 8, 2024
131ee7a
revert data_loader_for_ssr
EmilianoSanchez Oct 9, 2024
c7a2002
Adding setToArray util to avoid depending on Array.from
EmilianoSanchez Oct 9, 2024
fb616ca
Merge pull request #350 from splitio/refactor_segments_cache_update_m…
EmilianoSanchez Oct 18, 2024
c8b7074
Add issue link for future ref
EmilianoSanchez Oct 18, 2024
270d811
Revert "Add changelog entry"
EmilianoSanchez Oct 18, 2024
34c4bce
Revert "Add onReadyFromCacheCb to storage factory params for code cle…
EmilianoSanchez Oct 18, 2024
6b87017
Merge branch 'SDKS-8407_baseline' into init_function_for_side_effects
EmilianoSanchez Oct 18, 2024
4760132
Rename internal var
EmilianoSanchez Oct 18, 2024
57ba406
Revert lazy init in storage
EmilianoSanchez Oct 18, 2024
e81bd2f
Merge pull request #354 from splitio/init_function_for_side_effects
EmilianoSanchez Oct 18, 2024
f6e4922
Update changelog entry
EmilianoSanchez Oct 18, 2024
411ce8f
Fix lazy start on syncManagerOffline
EmilianoSanchez Oct 18, 2024
2459b10
Merge branch 'breaking_changes_update_supported_runtimes' into breaki…
EmilianoSanchez Oct 18, 2024
2950ee6
Merge pull request #359 from splitio/breaking_changes_remove_deprecat…
EmilianoSanchez Oct 18, 2024
b875d03
Merge pull request #357 from splitio/breaking_changes_update_supporte…
EmilianoSanchez Oct 18, 2024
2cbfe21
Merge pull request #356 from splitio/breaking_changes
EmilianoSanchez Oct 18, 2024
e954789
Merge branch 'SDKS-8407_baseline' into breaking_changes_baseline
EmilianoSanchez Oct 18, 2024
18b3243
rc
EmilianoSanchez Oct 18, 2024
af7981f
Polishing
EmilianoSanchez Oct 18, 2024
e79229a
Merge branch 'SDKS-8407_baseline' into breaking_changes_baseline
EmilianoSanchez Oct 18, 2024
9c381e1
Remove sync.localhostMode option and validation utils
EmilianoSanchez Oct 25, 2024
35953b7
1st step: move SplitIO namespace definition from Browser SDK to JS-Co…
EmilianoSanchez Oct 25, 2024
b415e43
rc
EmilianoSanchez Oct 25, 2024
7d91cc6
Merge branch 'remove_pluggable_localhost_mode' into refactor_type_def…
EmilianoSanchez Oct 25, 2024
c600e3d
2nd step: move SplitIO namespace definition from React Native SDK to …
EmilianoSanchez Oct 25, 2024
6905ae6
Polishing
EmilianoSanchez Oct 25, 2024
61eaece
Rename IClientSS to INodeClient and IAsyncClientSS to INodeAsyncClient
EmilianoSanchez Oct 25, 2024
7c3e6fa
3rc step: move SplitIO namespace definition from JS SDK to JS-Commons…
EmilianoSanchez Oct 25, 2024
901140a
rc
EmilianoSanchez Oct 25, 2024
d383fc5
Formatting
EmilianoSanchez Oct 25, 2024
61580e5
Add IReactNativeSettings to specialize the type. Fixed some defaults
EmilianoSanchez Oct 26, 2024
49d76b2
Polishing
EmilianoSanchez Oct 28, 2024
b09832f
Remove SplitIO namespace from 'src/types.ts' and reuse it from 'types…
EmilianoSanchez Oct 29, 2024
0ff9901
Fixed some types
EmilianoSanchez Oct 29, 2024
2e5df35
Polishing
EmilianoSanchez Oct 29, 2024
25a4b41
Merge branch 'refactor_type_definitions' into refactor_type_definitio…
EmilianoSanchez Oct 29, 2024
e40a824
Polishing
EmilianoSanchez Oct 29, 2024
d94771d
Merge branch 'refactor_type_definitions' into refactor_type_definitio…
EmilianoSanchez Oct 29, 2024
1e64d19
Refactor Settings interfaces
EmilianoSanchez Oct 29, 2024
4d2a5a4
Merge branch 'refactor_type_definitions' into refactor_type_definitio…
EmilianoSanchez Oct 29, 2024
912f20e
Add TSDoc linter rules
EmilianoSanchez Oct 29, 2024
1351df6
rc
EmilianoSanchez Oct 29, 2024
c1f766f
Merge pull request #361 from splitio/remove_pluggable_localhost_mode
EmilianoSanchez Oct 31, 2024
d13c68e
Merge branch 'breaking_changes_baseline' into refactor_type_definitions
EmilianoSanchez Oct 31, 2024
c7e8050
Merge branch 'refactor_type_definitions' into refactor_type_definitio…
EmilianoSanchez Oct 31, 2024
b352f71
Rename some TS interfaces to minimize breaking changes in JS SDK
EmilianoSanchez Oct 31, 2024
d8a3445
Polishing
EmilianoSanchez Oct 31, 2024
d052757
Move internal types outside namespace
EmilianoSanchez Oct 31, 2024
1e1d827
Revert specialization of the INodeAsyncSettings interface
EmilianoSanchez Oct 31, 2024
ecae2b2
rc
EmilianoSanchez Oct 31, 2024
549ee4f
Polishing
EmilianoSanchez Oct 31, 2024
5e115c2
Merge pull request #363 from splitio/refactor_type_definitions_intern…
EmilianoSanchez Nov 1, 2024
05aa2af
Merge pull request #362 from splitio/refactor_type_definitions
EmilianoSanchez Nov 1, 2024
a81642b
Merge pull request #360 from splitio/breaking_changes_baseline
EmilianoSanchez Nov 1, 2024
28c4b1b
Prepare stable version
EmilianoSanchez Nov 1, 2024
62741e8
Polishing
EmilianoSanchez Nov 1, 2024
5522808
Re-trigger CI
EmilianoSanchez Nov 2, 2024
dbddb86
Re-trigger CI
EmilianoSanchez Nov 2, 2024
6a13969
Merge pull request #329 from splitio/SDKS-8407_baseline
EmilianoSanchez Nov 2, 2024
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.18.0 (October XX, 2024)
- Added `factory.destroy()` method, which invokes the `destroy` method on all SDK clients created by the factory.
- Bugfixing - Fixed an issue with the server-side polling manager that caused dangling timers when the SDK was destroyed before it was ready.

1.17.0 (September 6, 2024)
- Added `sync.requestOptions.getHeaderOverrides` configuration option to enhance SDK HTTP request Headers for Authorization Frameworks.
- Added `isTimedout` and `lastUpdate` properties to IStatusInterface to keep track of the timestamp of the last SDK event, used on React and Redux SDKs.
Expand Down
3 changes: 2 additions & 1 deletion src/__tests__/testUtils/fetchMock.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// http://www.wheresrhys.co.uk/fetch-mock/#usageinstallation
// @TODO upgrade fetch-mock when fetch-mock-jest vulnerabilities are fixed
// https://www.wheresrhys.co.uk/fetch-mock/docs/fetch-mock/Usage/cheatsheet#local-fetch-with-jest
import fetchMockLib from 'fetch-mock';

const fetchMock = fetchMockLib.sandbox();
Expand Down
6 changes: 4 additions & 2 deletions src/sdkClient/__tests__/sdkClientMethod.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const paramMocks = [
sdkReadinessManager: { sdkStatus: jest.fn(), readinessManager: { destroy: jest.fn() } },
signalListener: undefined,
settings: { mode: CONSUMER_MODE, log: loggerMock, core: { authorizationKey: 'sdk key '} },
telemetryTracker: telemetryTrackerFactory()
telemetryTracker: telemetryTrackerFactory(),
clients: {}
},
// SyncManager (i.e., Sync SDK) and Signal listener
{
Expand All @@ -23,7 +24,8 @@ const paramMocks = [
sdkReadinessManager: { sdkStatus: jest.fn(), readinessManager: { destroy: jest.fn() } },
signalListener: { stop: jest.fn() },
settings: { mode: STANDALONE_MODE, log: loggerMock, core: { authorizationKey: 'sdk key '} },
telemetryTracker: telemetryTrackerFactory()
telemetryTracker: telemetryTrackerFactory(),
clients: {}
}
];

Expand Down
4 changes: 3 additions & 1 deletion src/sdkClient/__tests__/sdkClientMethodCS.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ const params = {
syncManager: syncManagerMock,
signalListener: { stop: jest.fn() },
settings: settingsWithKey,
telemetryTracker: telemetryTrackerFactory()
telemetryTracker: telemetryTrackerFactory(),
clients: {}
};

const invalidAttributes = [
Expand All @@ -71,6 +72,7 @@ describe('sdkClientMethodCSFactory', () => {
partialStorages.length = 0;
partialSdkReadinessManagers.length = 0;
partialSyncManagers.length = 0;
params.clients = {};
});

// list of factory functions and their types (whether it ignores TT or not)
Expand Down
5 changes: 5 additions & 0 deletions src/sdkClient/identity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { SplitIO } from '../types';

export function buildInstanceId(key: SplitIO.SplitKey, trafficType?: string) { // @ts-ignore
return `${key.matchingKey ? key.matchingKey : key}-${key.bucketingKey ? key.bucketingKey : key}-${trafficType ? trafficType : ''}`;
}
10 changes: 5 additions & 5 deletions src/sdkClient/sdkClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,11 @@ export function sdkClientFactory(params: ISdkFactoryContext, isSharedClient?: bo
syncManager && syncManager.stop();

return __flush().then(() => {
// Cleanup event listeners
signalListener && signalListener.stop();

// @TODO stop only if last client is destroyed
if (uniqueKeysTracker) uniqueKeysTracker.stop();
// For main client, cleanup event listeners and scheduled jobs
if (!isSharedClient) {
signalListener && signalListener.stop();
uniqueKeysTracker && uniqueKeysTracker.stop();
}

// Cleanup storage
return storage.destroy();
Expand Down
5 changes: 4 additions & 1 deletion src/sdkClient/sdkClientMethod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ import { RETRIEVE_CLIENT_DEFAULT } from '../logger/constants';
import { ISdkFactoryContext } from '../sdkFactory/types';

/**
* Factory of client method for server-side SDKs (ISDK and IAsyncSDK)
* Factory of client method for server-side SDKs
*/
export function sdkClientMethodFactory(params: ISdkFactoryContext): () => SplitIO.IClient | SplitIO.IAsyncClient {
const log = params.settings.log;
const clientInstance = sdkClientFactory(params);

// Only one client in server-side without bound key
params.clients[''] = clientInstance;

return function client() {
if (arguments.length > 0) {
throw new Error('Shared Client not supported by the storage mechanism. Create isolated instances instead.');
Expand Down
18 changes: 6 additions & 12 deletions src/sdkClient/sdkClientMethodCS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,14 @@ import { objectAssign } from '../utils/lang/objectAssign';
import { RETRIEVE_CLIENT_DEFAULT, NEW_SHARED_CLIENT, RETRIEVE_CLIENT_EXISTING, LOG_PREFIX_CLIENT_INSTANTIATION } from '../logger/constants';
import { SDK_SEGMENTS_ARRIVED } from '../readiness/constants';
import { ISdkFactoryContext } from '../sdkFactory/types';

function buildInstanceId(key: SplitIO.SplitKey) {
// @ts-ignore
return `${key.matchingKey ? key.matchingKey : key}-${key.bucketingKey ? key.bucketingKey : key}-`;
}
import { buildInstanceId } from './identity';

/**
* Factory of client method for the client-side API variant where TT is ignored.
* Therefore, clients don't have a bound TT for the track method.
*/
export function sdkClientMethodCSFactory(params: ISdkFactoryContext): (key?: SplitIO.SplitKey) => SplitIO.ICsClient {
const { storage, syncManager, sdkReadinessManager, settings: { core: { key }, startup: { readyTimeout }, log } } = params;
const { clients, storage, syncManager, sdkReadinessManager, settings: { core: { key }, startup: { readyTimeout }, log } } = params;

const mainClientInstance = clientCSDecorator(
log,
Expand All @@ -31,8 +27,7 @@ export function sdkClientMethodCSFactory(params: ISdkFactoryContext): (key?: Spl
const defaultInstanceId = buildInstanceId(parsedDefaultKey);

// Cache instances created per factory.
const clientInstances: Record<string, SplitIO.ICsClient> = {};
clientInstances[defaultInstanceId] = mainClientInstance;
clients[defaultInstanceId] = mainClientInstance;

return function client(key?: SplitIO.SplitKey) {
if (key === undefined) {
Expand All @@ -48,7 +43,7 @@ export function sdkClientMethodCSFactory(params: ISdkFactoryContext): (key?: Spl

const instanceId = buildInstanceId(validKey);

if (!clientInstances[instanceId]) {
if (!clients[instanceId]) {
const matchingKey = getMatching(validKey);

const sharedSdkReadiness = sdkReadinessManager.shared(readyTimeout);
Expand All @@ -70,13 +65,12 @@ export function sdkClientMethodCSFactory(params: ISdkFactoryContext): (key?: Spl

// As shared clients reuse all the storage information, we don't need to check here if we
// will use offline or online mode. We should stick with the original decision.
clientInstances[instanceId] = clientCSDecorator(
clients[instanceId] = clientCSDecorator(
log,
sdkClientFactory(objectAssign({}, params, {
sdkReadinessManager: sharedSdkReadiness,
storage: sharedStorage || storage,
syncManager: sharedSyncManager,
signalListener: undefined, // only the main client "destroy" method stops the signal listener
}), true) as SplitIO.IClient,
validKey
);
Expand All @@ -88,6 +82,6 @@ export function sdkClientMethodCSFactory(params: ISdkFactoryContext): (key?: Spl
log.debug(RETRIEVE_CLIENT_EXISTING);
}

return clientInstances[instanceId];
return clients[instanceId] as SplitIO.ICsClient;
};
}
18 changes: 6 additions & 12 deletions src/sdkClient/sdkClientMethodCSWithTT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,15 @@ import { objectAssign } from '../utils/lang/objectAssign';
import { RETRIEVE_CLIENT_DEFAULT, NEW_SHARED_CLIENT, RETRIEVE_CLIENT_EXISTING, LOG_PREFIX_CLIENT_INSTANTIATION } from '../logger/constants';
import { SDK_SEGMENTS_ARRIVED } from '../readiness/constants';
import { ISdkFactoryContext } from '../sdkFactory/types';

function buildInstanceId(key: SplitIO.SplitKey, trafficType?: string) {
// @ts-ignore
return `${key.matchingKey ? key.matchingKey : key}-${key.bucketingKey ? key.bucketingKey : key}-${trafficType !== undefined ? trafficType : ''}`;
}
import { buildInstanceId } from './identity';

/**
* Factory of client method for the client-side (browser) variant of the Isomorphic JS SDK,
* where clients can have a bound TT for the track method, which is provided via the settings
* (default client) or the client method (shared clients).
*/
export function sdkClientMethodCSFactory(params: ISdkFactoryContext): (key?: SplitIO.SplitKey, trafficType?: string) => SplitIO.ICsClient {
const { storage, syncManager, sdkReadinessManager, settings: { core: { key, trafficType }, startup: { readyTimeout }, log } } = params;
const { clients, storage, syncManager, sdkReadinessManager, settings: { core: { key, trafficType }, startup: { readyTimeout }, log } } = params;

const mainClientInstance = clientCSDecorator(
log,
Expand All @@ -34,8 +30,7 @@ export function sdkClientMethodCSFactory(params: ISdkFactoryContext): (key?: Spl
const defaultInstanceId = buildInstanceId(parsedDefaultKey, trafficType);

// Cache instances created per factory.
const clientInstances: Record<string, SplitIO.ICsClient> = {};
clientInstances[defaultInstanceId] = mainClientInstance;
clients[defaultInstanceId] = mainClientInstance;

return function client(key?: SplitIO.SplitKey, trafficType?: string) {
if (key === undefined) {
Expand All @@ -58,7 +53,7 @@ export function sdkClientMethodCSFactory(params: ISdkFactoryContext): (key?: Spl
}
const instanceId = buildInstanceId(validKey, validTrafficType);

if (!clientInstances[instanceId]) {
if (!clients[instanceId]) {
const matchingKey = getMatching(validKey);

const sharedSdkReadiness = sdkReadinessManager.shared(readyTimeout);
Expand All @@ -80,13 +75,12 @@ export function sdkClientMethodCSFactory(params: ISdkFactoryContext): (key?: Spl

// As shared clients reuse all the storage information, we don't need to check here if we
// will use offline or online mode. We should stick with the original decision.
clientInstances[instanceId] = clientCSDecorator(
clients[instanceId] = clientCSDecorator(
log,
sdkClientFactory(objectAssign({}, params, {
sdkReadinessManager: sharedSdkReadiness,
storage: sharedStorage || storage,
syncManager: sharedSyncManager,
signalListener: undefined, // only the main client "destroy" method stops the signal listener
}), true) as SplitIO.IClient,
validKey,
validTrafficType
Expand All @@ -99,6 +93,6 @@ export function sdkClientMethodCSFactory(params: ISdkFactoryContext): (key?: Spl
log.debug(RETRIEVE_CLIENT_EXISTING);
}

return clientInstances[instanceId];
return clients[instanceId] as SplitIO.ICsClient;
};
}
10 changes: 7 additions & 3 deletions src/sdkFactory/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { sdkReadinessManagerFactory } from '../readiness/sdkReadinessManager';
import { impressionsTrackerFactory } from '../trackers/impressionsTracker';
import { eventTrackerFactory } from '../trackers/eventTracker';
import { telemetryTrackerFactory } from '../trackers/telemetryTracker';
import { SplitIO } from '../types';
import { IBasicClient, SplitIO } from '../types';
import { validateAndTrackApiKey } from '../utils/inputValidation/apiKey';
import { createLoggerAPI } from '../logger/sdkLogger';
import { NEW_FACTORY, RETRIEVE_MANAGER } from '../logger/constants';
Expand Down Expand Up @@ -48,7 +48,7 @@ export function sdkFactory(params: ISdkFactoryParams): SplitIO.ICsSDK | SplitIO.
},
});
// @TODO add support for dataloader: `if (params.dataLoader) params.dataLoader(storage);`

const clients: Record<string, IBasicClient> = {};
const telemetryTracker = telemetryTrackerFactory(storage.telemetry, platform.now);
const integrationsManager = integrationsManagerFactory && integrationsManagerFactory({ settings, storage, telemetryTracker });

Expand All @@ -73,7 +73,7 @@ export function sdkFactory(params: ISdkFactoryParams): SplitIO.ICsSDK | SplitIO.
// splitApi is used by SyncManager and Browser signal listener
const splitApi = splitApiFactory && splitApiFactory(settings, platform, telemetryTracker);

const ctx: ISdkFactoryContext = { splitApi, eventTracker, impressionsTracker, telemetryTracker, uniqueKeysTracker, sdkReadinessManager, readiness, settings, storage, platform };
const ctx: ISdkFactoryContext = { clients, splitApi, eventTracker, impressionsTracker, telemetryTracker, uniqueKeysTracker, sdkReadinessManager, readiness, settings, storage, platform };

const syncManager = syncManagerFactory && syncManagerFactory(ctx as ISdkFactoryContextSync);
ctx.syncManager = syncManager;
Expand Down Expand Up @@ -105,5 +105,9 @@ export function sdkFactory(params: ISdkFactoryParams): SplitIO.ICsSDK | SplitIO.
Logger: createLoggerAPI(log),

settings,

destroy() {
return Promise.all(Object.keys(clients).map(key => clients[key].destroy())).then(() => {});
}
}, extraProps && extraProps(ctx));
}
3 changes: 2 additions & 1 deletion src/sdkFactory/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { IStorageAsync, IStorageSync, IStorageFactoryParams } from '../storages/
import { ISyncManager } from '../sync/types';
import { IImpressionObserver } from '../trackers/impressionObserver/types';
import { IImpressionsTracker, IEventTracker, ITelemetryTracker, IFilterAdapter, IUniqueKeysTracker } from '../trackers/types';
import { SplitIO, ISettings, IEventEmitter } from '../types';
import { SplitIO, ISettings, IEventEmitter, IBasicClient } from '../types';

/**
* Environment related dependencies.
Expand Down Expand Up @@ -49,6 +49,7 @@ export interface ISdkFactoryContext {
signalListener?: ISignalListener
splitApi?: ISplitApi
syncManager?: ISyncManager,
clients: Record<string, IBasicClient>,
}

export interface ISdkFactoryContextSync extends ISdkFactoryContext {
Expand Down
5 changes: 2 additions & 3 deletions src/sync/polling/pollingManagerSS.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { splitsSyncTaskFactory } from './syncTasks/splitsSyncTask';
import { segmentsSyncTaskFactory } from './syncTasks/segmentsSyncTask';
import { IPollingManager, ISegmentsSyncTask, ISplitsSyncTask } from './types';
import { thenable } from '../../utils/promise/thenable';
import { POLLING_START, POLLING_STOP, LOG_PREFIX_SYNC_POLLING } from '../../logger/constants';
import { ISdkFactoryContextSync } from '../../sdkFactory/types';

Expand Down Expand Up @@ -29,9 +28,9 @@ export function pollingManagerSSFactory(
log.debug(LOG_PREFIX_SYNC_POLLING + `Segments will be refreshed each ${settings.scheduler.segmentsRefreshRate} millis`);

const startingUp = splitsSyncTask.start();
if (thenable(startingUp)) {
if (startingUp) {
startingUp.then(() => {
segmentsSyncTask.start();
if (splitsSyncTask.isRunning()) segmentsSyncTask.start();
});
}
},
Expand Down
8 changes: 7 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ export interface IStatusInterface extends IEventEmitter {
* @interface IBasicClient
* @extends IStatusInterface
*/
interface IBasicClient extends IStatusInterface {
export interface IBasicClient extends IStatusInterface {
/**
* Flush data
* @function flush
Expand Down Expand Up @@ -459,6 +459,12 @@ interface IBasicSDK {
* @property Logger
*/
Logger: ILoggerAPI
/**
* Destroy all the clients created by this factory.
* @function destroy
* @returns {Promise<void>}
*/
destroy(): Promise<void>
}
/****** Exposed namespace ******/
/**
Expand Down
Loading