@splitsoftware/splitio-commons 1.12.2-rc.0 → 1.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGES.txt CHANGED
@@ -1,5 +1,8 @@
1
+ 1.13.1 (January 10, 2024)
2
+ - Updated client `destroy` method to release SDK key immediately and avoid unexpected warning logs when a factory is created with the same SDK key after the previous one was destroyed.
3
+
1
4
  1.13.0 (January 4, 2024)
2
- - Removed the getOptions method from the IPlatform interface to simplify the code. Request options can be handled inside the getFetch method.
5
+ - Removed the `getOptions` method from the `IPlatform` interface to simplify implementation. Request options can be handled within the `getFetch` method.
3
6
 
4
7
  1.12.1 (December 12, 2023)
5
8
  - Updated PluggableStorage, for producer mode, and LocalStorage, for standalone mode, to clear the storage before initiating the synchronization process if it was previously synchronized with a different SDK key (i.e., a different environment) or different Split Filter criteria.
package/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright © 2023 Split Software, Inc.
1
+ Copyright © 2024 Split Software, Inc.
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
@@ -45,17 +45,16 @@ function sdkClientFactory(params, isSharedClient) {
45
45
  destroy: function () {
46
46
  // Mark the SDK as destroyed immediately
47
47
  sdkReadinessManager.readinessManager.destroy();
48
- // record stat before flushing data
49
- if (!isSharedClient)
48
+ // For main client, release the SDK Key and record stat before flushing data
49
+ if (!isSharedClient) {
50
+ (0, apiKey_1.releaseApiKey)(settings.core.authorizationKey);
50
51
  telemetryTracker.sessionLength();
52
+ }
51
53
  // Stop background jobs
52
54
  syncManager && syncManager.stop();
53
55
  return __flush().then(function () {
54
56
  // Cleanup event listeners
55
57
  signalListener && signalListener.stop();
56
- // Release the SDK Key if it is the main client
57
- if (!isSharedClient)
58
- (0, apiKey_1.releaseApiKey)(settings.core.authorizationKey);
59
58
  // @TODO stop only if last client is destroyed
60
59
  if (uniqueKeysTracker)
61
60
  uniqueKeysTracker.stop();
@@ -58,7 +58,7 @@ function sdkFactory(params) {
58
58
  var impressionsTracker = (0, impressionsTracker_1.impressionsTrackerFactory)(settings, storage.impressions, strategy, integrationsManager, storage.telemetry);
59
59
  var eventTracker = (0, eventTracker_1.eventTrackerFactory)(settings, storage.events, integrationsManager, storage.telemetry);
60
60
  // splitApi is used by SyncManager and Browser signal listener
61
- var splitApi = splitApiFactory && splitApiFactory(settings, platform.getFetch, telemetryTracker);
61
+ var splitApi = splitApiFactory && splitApiFactory(settings, platform, telemetryTracker);
62
62
  var ctx = { splitApi: splitApi, eventTracker: eventTracker, impressionsTracker: impressionsTracker, telemetryTracker: telemetryTracker, uniqueKeysTracker: uniqueKeysTracker, sdkReadinessManager: sdkReadinessManager, readiness: readiness, settings: settings, storage: storage, platform: platform };
63
63
  var syncManager = syncManagerFactory && syncManagerFactory(ctx);
64
64
  ctx.syncManager = syncManager;
@@ -13,14 +13,14 @@ function userKeyToQueryParam(userKey) {
13
13
  * Factory of SplitApi objects, which group the collection of Split HTTP endpoints used by the SDK
14
14
  *
15
15
  * @param settings validated settings object
16
- * @param getFetch environment-specific `getFetch` method
16
+ * @param platform object containing environment-specific dependencies
17
17
  * @param telemetryTracker telemetry tracker
18
18
  */
19
- function splitApiFactory(settings, getFetch, telemetryTracker) {
19
+ function splitApiFactory(settings, platform, telemetryTracker) {
20
20
  var urls = settings.urls;
21
21
  var filterQueryString = settings.sync.__splitFiltersValidation && settings.sync.__splitFiltersValidation.queryString;
22
22
  var SplitSDKImpressionsMode = settings.sync.impressionsMode;
23
- var splitHttpClient = (0, splitHttpClient_1.splitHttpClientFactory)(settings, getFetch);
23
+ var splitHttpClient = (0, splitHttpClient_1.splitHttpClientFactory)(settings, platform.getFetch);
24
24
  return {
25
25
  // @TODO throw errors if health check requests fail, to log them in the Synchronizer
26
26
  getSdkAPIHealthCheck: function () {
@@ -42,17 +42,16 @@ export function sdkClientFactory(params, isSharedClient) {
42
42
  destroy: function () {
43
43
  // Mark the SDK as destroyed immediately
44
44
  sdkReadinessManager.readinessManager.destroy();
45
- // record stat before flushing data
46
- if (!isSharedClient)
45
+ // For main client, release the SDK Key and record stat before flushing data
46
+ if (!isSharedClient) {
47
+ releaseApiKey(settings.core.authorizationKey);
47
48
  telemetryTracker.sessionLength();
49
+ }
48
50
  // Stop background jobs
49
51
  syncManager && syncManager.stop();
50
52
  return __flush().then(function () {
51
53
  // Cleanup event listeners
52
54
  signalListener && signalListener.stop();
53
- // Release the SDK Key if it is the main client
54
- if (!isSharedClient)
55
- releaseApiKey(settings.core.authorizationKey);
56
55
  // @TODO stop only if last client is destroyed
57
56
  if (uniqueKeysTracker)
58
57
  uniqueKeysTracker.stop();
@@ -55,7 +55,7 @@ export function sdkFactory(params) {
55
55
  var impressionsTracker = impressionsTrackerFactory(settings, storage.impressions, strategy, integrationsManager, storage.telemetry);
56
56
  var eventTracker = eventTrackerFactory(settings, storage.events, integrationsManager, storage.telemetry);
57
57
  // splitApi is used by SyncManager and Browser signal listener
58
- var splitApi = splitApiFactory && splitApiFactory(settings, platform.getFetch, telemetryTracker);
58
+ var splitApi = splitApiFactory && splitApiFactory(settings, platform, telemetryTracker);
59
59
  var ctx = { splitApi: splitApi, eventTracker: eventTracker, impressionsTracker: impressionsTracker, telemetryTracker: telemetryTracker, uniqueKeysTracker: uniqueKeysTracker, sdkReadinessManager: sdkReadinessManager, readiness: readiness, settings: settings, storage: storage, platform: platform };
60
60
  var syncManager = syncManagerFactory && syncManagerFactory(ctx);
61
61
  ctx.syncManager = syncManager;
@@ -10,14 +10,14 @@ function userKeyToQueryParam(userKey) {
10
10
  * Factory of SplitApi objects, which group the collection of Split HTTP endpoints used by the SDK
11
11
  *
12
12
  * @param settings validated settings object
13
- * @param getFetch environment-specific `getFetch` method
13
+ * @param platform object containing environment-specific dependencies
14
14
  * @param telemetryTracker telemetry tracker
15
15
  */
16
- export function splitApiFactory(settings, getFetch, telemetryTracker) {
16
+ export function splitApiFactory(settings, platform, telemetryTracker) {
17
17
  var urls = settings.urls;
18
18
  var filterQueryString = settings.sync.__splitFiltersValidation && settings.sync.__splitFiltersValidation.queryString;
19
19
  var SplitSDKImpressionsMode = settings.sync.impressionsMode;
20
- var splitHttpClient = splitHttpClientFactory(settings, getFetch);
20
+ var splitHttpClient = splitHttpClientFactory(settings, platform.getFetch);
21
21
  return {
22
22
  // @TODO throw errors if health check requests fail, to log them in the Synchronizer
23
23
  getSdkAPIHealthCheck: function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splitsoftware/splitio-commons",
3
- "version": "1.12.2-rc.0",
3
+ "version": "1.13.1",
4
4
  "description": "Split Javascript SDK common components",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -72,7 +72,7 @@
72
72
  "jest": "^27.2.3",
73
73
  "jest-localstorage-mock": "^2.4.3",
74
74
  "lodash": "^4.17.21",
75
- "node-fetch": "^2.6.7",
75
+ "node-fetch": "^2.7.0",
76
76
  "redis-server": "1.2.2",
77
77
  "rimraf": "^3.0.2",
78
78
  "ts-jest": "^27.0.5",
@@ -56,8 +56,11 @@ export function sdkClientFactory(params: ISdkFactoryContext, isSharedClient?: bo
56
56
  // Mark the SDK as destroyed immediately
57
57
  sdkReadinessManager.readinessManager.destroy();
58
58
 
59
- // record stat before flushing data
60
- if (!isSharedClient) telemetryTracker.sessionLength();
59
+ // For main client, release the SDK Key and record stat before flushing data
60
+ if (!isSharedClient) {
61
+ releaseApiKey(settings.core.authorizationKey);
62
+ telemetryTracker.sessionLength();
63
+ }
61
64
 
62
65
  // Stop background jobs
63
66
  syncManager && syncManager.stop();
@@ -66,9 +69,6 @@ export function sdkClientFactory(params: ISdkFactoryContext, isSharedClient?: bo
66
69
  // Cleanup event listeners
67
70
  signalListener && signalListener.stop();
68
71
 
69
- // Release the SDK Key if it is the main client
70
- if (!isSharedClient) releaseApiKey(settings.core.authorizationKey);
71
-
72
72
  // @TODO stop only if last client is destroyed
73
73
  if (uniqueKeysTracker) uniqueKeysTracker.stop();
74
74
 
@@ -71,7 +71,7 @@ export function sdkFactory(params: ISdkFactoryParams): SplitIO.ICsSDK | SplitIO.
71
71
  const eventTracker = eventTrackerFactory(settings, storage.events, integrationsManager, storage.telemetry);
72
72
 
73
73
  // splitApi is used by SyncManager and Browser signal listener
74
- const splitApi = splitApiFactory && splitApiFactory(settings, platform.getFetch, telemetryTracker);
74
+ const splitApi = splitApiFactory && splitApiFactory(settings, platform, telemetryTracker);
75
75
 
76
76
  const ctx: ISdkFactoryContext = { splitApi, eventTracker, impressionsTracker, telemetryTracker, uniqueKeysTracker, sdkReadinessManager, readiness, settings, storage, platform };
77
77
 
@@ -17,19 +17,19 @@ function userKeyToQueryParam(userKey: string) {
17
17
  * Factory of SplitApi objects, which group the collection of Split HTTP endpoints used by the SDK
18
18
  *
19
19
  * @param settings validated settings object
20
- * @param getFetch environment-specific `getFetch` method
20
+ * @param platform object containing environment-specific dependencies
21
21
  * @param telemetryTracker telemetry tracker
22
22
  */
23
23
  export function splitApiFactory(
24
24
  settings: ISettings,
25
- getFetch: IPlatform['getFetch'],
25
+ platform: Pick<IPlatform, 'getFetch'>,
26
26
  telemetryTracker: ITelemetryTracker
27
27
  ): ISplitApi {
28
28
 
29
29
  const urls = settings.urls;
30
30
  const filterQueryString = settings.sync.__splitFiltersValidation && settings.sync.__splitFiltersValidation.queryString;
31
31
  const SplitSDKImpressionsMode = settings.sync.impressionsMode;
32
- const splitHttpClient = splitHttpClientFactory(settings, getFetch);
32
+ const splitHttpClient = splitHttpClientFactory(settings, platform.getFetch);
33
33
 
34
34
  return {
35
35
  // @TODO throw errors if health check requests fail, to log them in the Synchronizer
@@ -6,7 +6,7 @@ import { ITelemetryTracker } from '../trackers/types';
6
6
  * Factory of SplitApi objects, which group the collection of Split HTTP endpoints used by the SDK
7
7
  *
8
8
  * @param settings validated settings object
9
- * @param getFetch environment-specific `getFetch` method
9
+ * @param platform object containing environment-specific dependencies
10
10
  * @param telemetryTracker telemetry tracker
11
11
  */
12
- export declare function splitApiFactory(settings: ISettings, getFetch: IPlatform['getFetch'], telemetryTracker: ITelemetryTracker): ISplitApi;
12
+ export declare function splitApiFactory(settings: ISettings, platform: Pick<IPlatform, 'getFetch'>, telemetryTracker: ITelemetryTracker): ISplitApi;