@splitsoftware/splitio-commons 2.0.0-rc.1 → 2.0.0-rc.3

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.
Files changed (55) hide show
  1. package/CHANGES.txt +1 -0
  2. package/cjs/logger/constants.js +1 -2
  3. package/cjs/logger/messages/error.js +0 -1
  4. package/cjs/sync/offline/LocalhostFromObject.js +3 -8
  5. package/cjs/sync/polling/updaters/segmentChangesUpdater.js +1 -1
  6. package/cjs/utils/settingsValidation/index.js +1 -4
  7. package/esm/logger/constants.js +0 -1
  8. package/esm/logger/messages/error.js +0 -1
  9. package/esm/sync/offline/LocalhostFromObject.js +2 -6
  10. package/esm/sync/polling/updaters/segmentChangesUpdater.js +1 -1
  11. package/esm/utils/settingsValidation/index.js +1 -4
  12. package/package.json +1 -1
  13. package/src/logger/constants.ts +0 -1
  14. package/src/logger/messages/error.ts +0 -1
  15. package/src/sync/offline/LocalhostFromObject.ts +2 -8
  16. package/src/sync/polling/updaters/segmentChangesUpdater.ts +1 -1
  17. package/src/types.ts +1 -12
  18. package/src/utils/settingsValidation/index.ts +1 -4
  19. package/src/utils/settingsValidation/types.ts +0 -2
  20. package/types/logger/constants.d.ts +0 -1
  21. package/types/sync/offline/LocalhostFromObject.d.ts +1 -2
  22. package/types/types.d.ts +0 -10
  23. package/types/utils/settingsValidation/index.d.ts +0 -1
  24. package/types/utils/settingsValidation/types.d.ts +0 -2
  25. package/cjs/utils/settingsValidation/localhost/builtin.js +0 -18
  26. package/cjs/utils/settingsValidation/localhost/pluggable.js +0 -22
  27. package/esm/utils/settingsValidation/localhost/builtin.js +0 -14
  28. package/esm/utils/settingsValidation/localhost/pluggable.js +0 -18
  29. package/src/utils/settingsValidation/localhost/builtin.ts +0 -16
  30. package/src/utils/settingsValidation/localhost/pluggable.ts +0 -22
  31. package/types/evaluator/matchers/sember_inlist.d.ts +0 -3
  32. package/types/evaluator/matchersTransform/set.d.ts +0 -5
  33. package/types/evaluator/matchersTransform/string.d.ts +0 -7
  34. package/types/integrations/browser.d.ts +0 -12
  35. package/types/integrations/ga/GaToSplit.d.ts +0 -40
  36. package/types/integrations/ga/GoogleAnalyticsToSplit.d.ts +0 -3
  37. package/types/integrations/ga/SplitToGa.d.ts +0 -34
  38. package/types/integrations/ga/SplitToGoogleAnalytics.d.ts +0 -3
  39. package/types/integrations/ga/types.d.ts +0 -148
  40. package/types/sdkClient/sdkClientMethodCSWithTT.d.ts +0 -8
  41. package/types/storages/AbstractSegmentsCacheSync.d.ts +0 -54
  42. package/types/storages/AbstractSplitsCache.d.ts +0 -46
  43. package/types/sync/streaming/mySegmentsV2utils.d.ts +0 -27
  44. package/types/sync/streaming/pushManagerCS_Spec1_3.d.ts +0 -9
  45. package/types/sync/streaming/pushManager_Spec1_3.d.ts +0 -9
  46. package/types/trackers/impressionObserver/utils.d.ts +0 -5
  47. package/types/utils/inputValidation/sdkKey.d.ts +0 -7
  48. package/types/utils/inputValidation/splitExistance.d.ts +0 -7
  49. package/types/utils/inputValidation/trafficTypeExistance.d.ts +0 -9
  50. package/types/utils/lang/maps.d.ts +0 -59
  51. package/types/utils/redis/RedisMock.d.ts +0 -4
  52. package/types/utils/settingsValidation/localhost/builtin.d.ts +0 -16
  53. package/types/utils/settingsValidation/localhost/pluggable.d.ts +0 -16
  54. package/types/utils/settingsValidation/logger/globalLogLevel.d.ts +0 -8
  55. /package/types/utils/{semVer.d.ts → Semver.d.ts} +0 -0
package/CHANGES.txt CHANGED
@@ -11,6 +11,7 @@
11
11
  - Removed the migration logic for the old format of MySegments keys in LocalStorage introduced in JavaScript SDK v10.17.3.
12
12
  - Removed the `sdkClientMethodCSWithTT` function, which handled the logic to bound an optional traffic type to SDK clients. Client-side SDK implementations must use `sdkClientMethodCS` module, which, unlike the previous function, does not allow passing a traffic type but simplifies the SDK API.
13
13
  - Removed internal ponyfills for `Map` and `Set` global objects, dropping support for IE and other outdated browsers. The SDK now requires the runtime environment to support these features natively or to provide a polyfill.
14
+ - Removed the `sync.localhostMode` configuration option to plug the LocalhostMode module.
14
15
 
15
16
  1.17.0 (September 6, 2024)
16
17
  - Added `sync.requestOptions.getHeaderOverrides` configuration option to enhance SDK HTTP request Headers for Authorization Frameworks.
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ENGINE_VALUE_INVALID = exports.USER_CONSENT_INITIAL = exports.USER_CONSENT_NOT_UPDATED = exports.USER_CONSENT_UPDATED = exports.IMPRESSIONS_TRACKER_SUCCESS = exports.EVENTS_TRACKER_SUCCESS = exports.SYNC_STOP_POLLING = exports.SYNC_CONTINUE_POLLING = exports.SYNC_START_POLLING = exports.SUBMITTERS_PUSH = exports.SUBMITTERS_PUSH_FULL_QUEUE = exports.STREAMING_DISCONNECTING = exports.STREAMING_DISABLED = exports.STREAMING_CONNECTING = exports.STREAMING_RECONNECT = exports.STREAMING_REFRESH_TOKEN = exports.SYNC_SPLITS_FETCH_RETRY = exports.POLLING_STOP = exports.POLLING_START = exports.POLLING_SMART_PAUSING = exports.NEW_FACTORY = exports.NEW_SHARED_CLIENT = exports.IMPRESSION_QUEUEING = exports.IMPRESSION = exports.CLIENT_READY = exports.CLIENT_READY_FROM_CACHE = exports.ENGINE_MATCHER_RESULT = exports.SETTINGS_SPLITS_FILTER = exports.SYNC_TASK_STOP = exports.SYNC_TASK_EXECUTE = exports.SYNC_TASK_START = exports.STREAMING_NEW_MESSAGE = exports.SYNC_SPLITS_SEGMENTS = exports.SYNC_SPLITS_REMOVED = exports.SYNC_SPLITS_NEW = exports.SYNC_SPLITS_FETCH = exports.SYNC_OFFLINE_DATA = exports.RETRIEVE_MANAGER = exports.RETRIEVE_CLIENT_EXISTING = exports.RETRIEVE_CLIENT_DEFAULT = exports.CLEANUP_DEREGISTERING = exports.CLEANUP_REGISTERING = exports.ENGINE_SANITIZE = exports.ENGINE_VALUE = exports.ENGINE_MATCHER_DEPENDENCY_PRE = exports.ENGINE_MATCHER_DEPENDENCY = exports.ENGINE_BUCKET = exports.ENGINE_COMBINER_IFELSEIF_NO_TREATMENT = exports.ENGINE_COMBINER_IFELSEIF = exports.ENGINE_COMBINER_AND = void 0;
4
4
  exports.ERROR_INVALID_CONFIG_PARAM = exports.ERROR_EMPTY_ARRAY = exports.ERROR_EMPTY = exports.ERROR_INVALID = exports.ERROR_INVALID_KEY_OBJECT = exports.ERROR_TOO_LONG = exports.ERROR_NULL = exports.ERROR_CLIENT_DESTROYED = exports.ERROR_NOT_FINITE = exports.ERROR_SIZE_EXCEEDED = exports.ERROR_NOT_PLAIN_OBJECT = exports.ERROR_EVENT_TYPE_FORMAT = exports.ERROR_EVENTS_TRACKER = exports.ERROR_IMPRESSIONS_LISTENER = exports.ERROR_IMPRESSIONS_TRACKER = exports.ERROR_STREAMING_AUTH = exports.ERROR_STREAMING_SSE = exports.ERROR_SYNC_OFFLINE_LOADING = exports.ERROR_CLIENT_CANNOT_GET_READY = exports.ERROR_CLIENT_LISTENER = exports.ERROR_LOGLEVEL_INVALID = exports.ERROR_ENGINE_COMBINER_IFELSEIF = exports.WARN_FLAGSET_WITHOUT_FLAGS = exports.WARN_FLAGSET_NOT_CONFIGURED = exports.WARN_LOWERCASE_FLAGSET = exports.WARN_INVALID_FLAGSET = exports.STREAMING_PARSING_SPLIT_UPDATE = exports.STREAMING_PARSING_MEMBERSHIPS_UPDATE = exports.WARN_SDK_KEY = exports.WARN_SPLITS_FILTER_EMPTY = exports.WARN_SPLITS_FILTER_INVALID = exports.WARN_SPLITS_FILTER_IGNORED = exports.WARN_INTEGRATION_INVALID = exports.WARN_NOT_EXISTENT_TT = exports.WARN_LOWERCASE_TRAFFIC_TYPE = exports.WARN_NOT_EXISTENT_SPLIT = exports.WARN_TRIMMING = exports.WARN_CONVERTING = exports.WARN_TRIMMING_PROPERTIES = exports.WARN_SETTING_NULL = exports.SUBMITTERS_PUSH_RETRY = exports.SUBMITTERS_PUSH_FAILS = exports.STREAMING_FALLBACK = exports.STREAMING_PARSING_MESSAGE_FAILS = exports.STREAMING_PARSING_ERROR_FAILS = exports.SYNC_SPLITS_FETCH_FAILS = exports.SYNC_MYSEGMENTS_FETCH_RETRY = exports.CLIENT_NOT_READY = exports.CLIENT_NO_LISTENER = exports.ENGINE_VALUE_NO_ATTRIBUTES = void 0;
5
- exports.LOG_PREFIX_CLEANUP = exports.LOG_PREFIX_UNIQUE_KEYS_TRACKER = exports.LOG_PREFIX_EVENTS_TRACKER = exports.LOG_PREFIX_IMPRESSIONS_TRACKER = exports.LOG_PREFIX_SYNC_SUBMITTERS = exports.LOG_PREFIX_SYNC_POLLING = exports.LOG_PREFIX_SYNC_MYSEGMENTS = exports.LOG_PREFIX_SYNC_SEGMENTS = exports.LOG_PREFIX_SYNC_SPLITS = exports.LOG_PREFIX_SYNC_STREAMING = exports.LOG_PREFIX_SYNC_OFFLINE = exports.LOG_PREFIX_SYNC_MANAGER = exports.LOG_PREFIX_SYNC = exports.LOG_PREFIX_ENGINE_VALUE = exports.LOG_PREFIX_ENGINE_MATCHER = exports.LOG_PREFIX_ENGINE_COMBINER = exports.LOG_PREFIX_ENGINE = exports.LOG_PREFIX_CLIENT_INSTANTIATION = exports.LOG_PREFIX_INSTANTIATION = exports.LOG_PREFIX_SETTINGS = exports.ENGINE_MATCHER_ERROR = exports.ERROR_SETS_FILTER_EXCLUSIVE = exports.ERROR_TOO_MANY_SETS = exports.ERROR_MIN_CONFIG_PARAM = exports.ERROR_NOT_BOOLEAN = exports.ERROR_STORAGE_INVALID = exports.ERROR_LOCALHOST_MODULE_REQUIRED = exports.ERROR_HTTP = void 0;
5
+ exports.LOG_PREFIX_CLEANUP = exports.LOG_PREFIX_UNIQUE_KEYS_TRACKER = exports.LOG_PREFIX_EVENTS_TRACKER = exports.LOG_PREFIX_IMPRESSIONS_TRACKER = exports.LOG_PREFIX_SYNC_SUBMITTERS = exports.LOG_PREFIX_SYNC_POLLING = exports.LOG_PREFIX_SYNC_MYSEGMENTS = exports.LOG_PREFIX_SYNC_SEGMENTS = exports.LOG_PREFIX_SYNC_SPLITS = exports.LOG_PREFIX_SYNC_STREAMING = exports.LOG_PREFIX_SYNC_OFFLINE = exports.LOG_PREFIX_SYNC_MANAGER = exports.LOG_PREFIX_SYNC = exports.LOG_PREFIX_ENGINE_VALUE = exports.LOG_PREFIX_ENGINE_MATCHER = exports.LOG_PREFIX_ENGINE_COMBINER = exports.LOG_PREFIX_ENGINE = exports.LOG_PREFIX_CLIENT_INSTANTIATION = exports.LOG_PREFIX_INSTANTIATION = exports.LOG_PREFIX_SETTINGS = exports.ENGINE_MATCHER_ERROR = exports.ERROR_SETS_FILTER_EXCLUSIVE = exports.ERROR_TOO_MANY_SETS = exports.ERROR_MIN_CONFIG_PARAM = exports.ERROR_NOT_BOOLEAN = exports.ERROR_STORAGE_INVALID = exports.ERROR_HTTP = void 0;
6
6
  /**
7
7
  * Message codes used to trim string log messages from commons and client-side API modules,
8
8
  * in order to reduce the minimal SDK size for Browser and eventually other client-side environments.
@@ -111,7 +111,6 @@ exports.ERROR_EMPTY = 319;
111
111
  exports.ERROR_EMPTY_ARRAY = 320;
112
112
  exports.ERROR_INVALID_CONFIG_PARAM = 321;
113
113
  exports.ERROR_HTTP = 322;
114
- exports.ERROR_LOCALHOST_MODULE_REQUIRED = 323;
115
114
  exports.ERROR_STORAGE_INVALID = 324;
116
115
  exports.ERROR_NOT_BOOLEAN = 325;
117
116
  exports.ERROR_MIN_CONFIG_PARAM = 326;
@@ -35,7 +35,6 @@ exports.codesError = [
35
35
  [c.ERROR_NOT_BOOLEAN, '%s: provided param must be a boolean value.'],
36
36
  // initialization / settings validation
37
37
  [c.ERROR_INVALID_CONFIG_PARAM, c.LOG_PREFIX_SETTINGS + ': you passed an invalid "%s" config param. It should be one of the following values: %s. Defaulting to "%s".'],
38
- [c.ERROR_LOCALHOST_MODULE_REQUIRED, c.LOG_PREFIX_SETTINGS + ': an invalid value was received for "sync.localhostMode" config. A valid entity should be provided for localhost mode.'],
39
38
  [c.ERROR_STORAGE_INVALID, c.LOG_PREFIX_SETTINGS + ': the provided storage is invalid.%s Falling back into default MEMORY storage'],
40
39
  [c.ERROR_MIN_CONFIG_PARAM, c.LOG_PREFIX_SETTINGS + ': the provided "%s" config param is lower than allowed. Setting to the minimum value %s seconds'],
41
40
  [c.ERROR_TOO_MANY_SETS, c.LOG_PREFIX_SETTINGS + ': the amount of flag sets provided are big causing uri length error.'],
@@ -1,13 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LocalhostFromObject = void 0;
3
+ exports.localhostFromObjectFactory = void 0;
4
4
  var splitsParserFromSettings_1 = require("./splitsParser/splitsParserFromSettings");
5
5
  var syncManagerOffline_1 = require("./syncManagerOffline");
6
- // Singleton instance of the factory function for offline SyncManager from object (a.k.a. localhostFromObject)
6
+ // Singleton instance of the factory function for offline SyncManager from object
7
7
  // SDK instances instantiate their SyncManagers with the same factory
8
- var localhostFromObject = (0, syncManagerOffline_1.syncManagerOfflineFactory)(splitsParserFromSettings_1.splitsParserFromSettingsFactory);
9
- localhostFromObject.type = 'LocalhostFromObject';
10
- function LocalhostFromObject() {
11
- return localhostFromObject;
12
- }
13
- exports.LocalhostFromObject = LocalhostFromObject;
8
+ exports.localhostFromObjectFactory = (0, syncManagerOffline_1.syncManagerOfflineFactory)(splitsParserFromSettings_1.splitsParserFromSettingsFactory);
@@ -26,7 +26,7 @@ function segmentChangesUpdaterFactory(log, segmentChangesFetcher, segments, read
26
26
  segmentChangesFetcher(since, segmentName, noCache, till).then(function (changes) {
27
27
  return Promise.all(changes.map(function (x) {
28
28
  log.debug(constants_2.LOG_PREFIX_SYNC_SEGMENTS + "Processing " + segmentName + " with till = " + x.till + ". Added: " + x.added.length + ". Removed: " + x.removed.length);
29
- return segments.update(x.name, x.added, x.removed, x.till);
29
+ return segments.update(segmentName, x.added, x.removed, x.till);
30
30
  })).then(function (updates) {
31
31
  return updates.some(function (update) { return update; });
32
32
  });
@@ -70,7 +70,6 @@ exports.base = {
70
70
  splitFilters: undefined,
71
71
  // impressions collection mode
72
72
  impressionsMode: constants_1.OPTIMIZED,
73
- localhostMode: undefined,
74
73
  enabled: true,
75
74
  flagSpecVersion: constants_1.FLAG_SPEC_VERSION
76
75
  },
@@ -88,7 +87,7 @@ function fromSecondsToMillis(n) {
88
87
  * @param validationParams defaults and fields validators used to validate and creates a settings object from a given config
89
88
  */
90
89
  function settingsValidation(config, validationParams) {
91
- var defaults = validationParams.defaults, runtime = validationParams.runtime, storage = validationParams.storage, integrations = validationParams.integrations, logger = validationParams.logger, localhost = validationParams.localhost, consent = validationParams.consent, flagSpec = validationParams.flagSpec;
90
+ var defaults = validationParams.defaults, runtime = validationParams.runtime, storage = validationParams.storage, integrations = validationParams.integrations, logger = validationParams.logger, consent = validationParams.consent, flagSpec = validationParams.flagSpec;
92
91
  // creates a settings object merging base, defaults and config objects.
93
92
  var withDefaults = (0, lang_1.merge)({}, exports.base, defaults, config);
94
93
  // Keeps reference to the `features` property
@@ -160,8 +159,6 @@ function settingsValidation(config, validationParams) {
160
159
  // @ts-ignore, modify readonly prop
161
160
  if (integrations)
162
161
  withDefaults.integrations = integrations(withDefaults);
163
- if (localhost)
164
- sync.localhostMode = localhost(withDefaults);
165
162
  // validate push options
166
163
  if (withDefaults.streamingEnabled !== false) { // @ts-ignore, modify readonly prop
167
164
  withDefaults.streamingEnabled = true;
@@ -106,7 +106,6 @@ export var ERROR_EMPTY = 319;
106
106
  export var ERROR_EMPTY_ARRAY = 320;
107
107
  export var ERROR_INVALID_CONFIG_PARAM = 321;
108
108
  export var ERROR_HTTP = 322;
109
- export var ERROR_LOCALHOST_MODULE_REQUIRED = 323;
110
109
  export var ERROR_STORAGE_INVALID = 324;
111
110
  export var ERROR_NOT_BOOLEAN = 325;
112
111
  export var ERROR_MIN_CONFIG_PARAM = 326;
@@ -31,7 +31,6 @@ export var codesError = [
31
31
  [c.ERROR_NOT_BOOLEAN, '%s: provided param must be a boolean value.'],
32
32
  // initialization / settings validation
33
33
  [c.ERROR_INVALID_CONFIG_PARAM, c.LOG_PREFIX_SETTINGS + ': you passed an invalid "%s" config param. It should be one of the following values: %s. Defaulting to "%s".'],
34
- [c.ERROR_LOCALHOST_MODULE_REQUIRED, c.LOG_PREFIX_SETTINGS + ': an invalid value was received for "sync.localhostMode" config. A valid entity should be provided for localhost mode.'],
35
34
  [c.ERROR_STORAGE_INVALID, c.LOG_PREFIX_SETTINGS + ': the provided storage is invalid.%s Falling back into default MEMORY storage'],
36
35
  [c.ERROR_MIN_CONFIG_PARAM, c.LOG_PREFIX_SETTINGS + ': the provided "%s" config param is lower than allowed. Setting to the minimum value %s seconds'],
37
36
  [c.ERROR_TOO_MANY_SETS, c.LOG_PREFIX_SETTINGS + ': the amount of flag sets provided are big causing uri length error.'],
@@ -1,9 +1,5 @@
1
1
  import { splitsParserFromSettingsFactory } from './splitsParser/splitsParserFromSettings';
2
2
  import { syncManagerOfflineFactory } from './syncManagerOffline';
3
- // Singleton instance of the factory function for offline SyncManager from object (a.k.a. localhostFromObject)
3
+ // Singleton instance of the factory function for offline SyncManager from object
4
4
  // SDK instances instantiate their SyncManagers with the same factory
5
- var localhostFromObject = syncManagerOfflineFactory(splitsParserFromSettingsFactory);
6
- localhostFromObject.type = 'LocalhostFromObject';
7
- export function LocalhostFromObject() {
8
- return localhostFromObject;
9
- }
5
+ export var localhostFromObjectFactory = syncManagerOfflineFactory(splitsParserFromSettingsFactory);
@@ -23,7 +23,7 @@ export function segmentChangesUpdaterFactory(log, segmentChangesFetcher, segment
23
23
  segmentChangesFetcher(since, segmentName, noCache, till).then(function (changes) {
24
24
  return Promise.all(changes.map(function (x) {
25
25
  log.debug(LOG_PREFIX_SYNC_SEGMENTS + "Processing " + segmentName + " with till = " + x.till + ". Added: " + x.added.length + ". Removed: " + x.removed.length);
26
- return segments.update(x.name, x.added, x.removed, x.till);
26
+ return segments.update(segmentName, x.added, x.removed, x.till);
27
27
  })).then(function (updates) {
28
28
  return updates.some(function (update) { return update; });
29
29
  });
@@ -67,7 +67,6 @@ export var base = {
67
67
  splitFilters: undefined,
68
68
  // impressions collection mode
69
69
  impressionsMode: OPTIMIZED,
70
- localhostMode: undefined,
71
70
  enabled: true,
72
71
  flagSpecVersion: FLAG_SPEC_VERSION
73
72
  },
@@ -85,7 +84,7 @@ function fromSecondsToMillis(n) {
85
84
  * @param validationParams defaults and fields validators used to validate and creates a settings object from a given config
86
85
  */
87
86
  export function settingsValidation(config, validationParams) {
88
- var defaults = validationParams.defaults, runtime = validationParams.runtime, storage = validationParams.storage, integrations = validationParams.integrations, logger = validationParams.logger, localhost = validationParams.localhost, consent = validationParams.consent, flagSpec = validationParams.flagSpec;
87
+ var defaults = validationParams.defaults, runtime = validationParams.runtime, storage = validationParams.storage, integrations = validationParams.integrations, logger = validationParams.logger, consent = validationParams.consent, flagSpec = validationParams.flagSpec;
89
88
  // creates a settings object merging base, defaults and config objects.
90
89
  var withDefaults = merge({}, base, defaults, config);
91
90
  // Keeps reference to the `features` property
@@ -157,8 +156,6 @@ export function settingsValidation(config, validationParams) {
157
156
  // @ts-ignore, modify readonly prop
158
157
  if (integrations)
159
158
  withDefaults.integrations = integrations(withDefaults);
160
- if (localhost)
161
- sync.localhostMode = localhost(withDefaults);
162
159
  // validate push options
163
160
  if (withDefaults.streamingEnabled !== false) { // @ts-ignore, modify readonly prop
164
161
  withDefaults.streamingEnabled = true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splitsoftware/splitio-commons",
3
- "version": "2.0.0-rc.1",
3
+ "version": "2.0.0-rc.3",
4
4
  "description": "Split JavaScript SDK common components",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -109,7 +109,6 @@ export const ERROR_EMPTY = 319;
109
109
  export const ERROR_EMPTY_ARRAY = 320;
110
110
  export const ERROR_INVALID_CONFIG_PARAM = 321;
111
111
  export const ERROR_HTTP = 322;
112
- export const ERROR_LOCALHOST_MODULE_REQUIRED = 323;
113
112
  export const ERROR_STORAGE_INVALID = 324;
114
113
  export const ERROR_NOT_BOOLEAN = 325;
115
114
  export const ERROR_MIN_CONFIG_PARAM = 326;
@@ -32,7 +32,6 @@ export const codesError: [number, string][] = [
32
32
  [c.ERROR_NOT_BOOLEAN, '%s: provided param must be a boolean value.'],
33
33
  // initialization / settings validation
34
34
  [c.ERROR_INVALID_CONFIG_PARAM, c.LOG_PREFIX_SETTINGS + ': you passed an invalid "%s" config param. It should be one of the following values: %s. Defaulting to "%s".'],
35
- [c.ERROR_LOCALHOST_MODULE_REQUIRED, c.LOG_PREFIX_SETTINGS + ': an invalid value was received for "sync.localhostMode" config. A valid entity should be provided for localhost mode.'],
36
35
  [c.ERROR_STORAGE_INVALID, c.LOG_PREFIX_SETTINGS+': the provided storage is invalid.%s Falling back into default MEMORY storage'],
37
36
  [c.ERROR_MIN_CONFIG_PARAM, c.LOG_PREFIX_SETTINGS + ': the provided "%s" config param is lower than allowed. Setting to the minimum value %s seconds'],
38
37
  [c.ERROR_TOO_MANY_SETS, c.LOG_PREFIX_SETTINGS + ': the amount of flag sets provided are big causing uri length error.'],
@@ -1,12 +1,6 @@
1
1
  import { splitsParserFromSettingsFactory } from './splitsParser/splitsParserFromSettings';
2
2
  import { syncManagerOfflineFactory } from './syncManagerOffline';
3
- import { SplitIO } from '../../types';
4
3
 
5
- // Singleton instance of the factory function for offline SyncManager from object (a.k.a. localhostFromObject)
4
+ // Singleton instance of the factory function for offline SyncManager from object
6
5
  // SDK instances instantiate their SyncManagers with the same factory
7
- const localhostFromObject = syncManagerOfflineFactory(splitsParserFromSettingsFactory) as SplitIO.LocalhostFactory;
8
- localhostFromObject.type = 'LocalhostFromObject';
9
-
10
- export function LocalhostFromObject(): SplitIO.LocalhostFactory {
11
- return localhostFromObject;
12
- }
6
+ export const localhostFromObjectFactory = syncManagerOfflineFactory(splitsParserFromSettingsFactory);
@@ -38,7 +38,7 @@ export function segmentChangesUpdaterFactory(
38
38
  segmentChangesFetcher(since, segmentName, noCache, till).then((changes) => {
39
39
  return Promise.all(changes.map(x => {
40
40
  log.debug(`${LOG_PREFIX_SYNC_SEGMENTS}Processing ${segmentName} with till = ${x.till}. Added: ${x.added.length}. Removed: ${x.removed.length}`);
41
- return segments.update(x.name, x.added, x.removed, x.till);
41
+ return segments.update(segmentName, x.added, x.removed, x.till);
42
42
  })).then((updates) => {
43
43
  return updates.some(update => update);
44
44
  });
package/src/types.ts CHANGED
@@ -1,11 +1,8 @@
1
+ /* eslint-disable no-use-before-define */
1
2
  import { ISplitFiltersValidation } from './dtos/types';
2
3
  import { IIntegration, IIntegrationFactoryParams } from './integrations/types';
3
4
  import { ILogger } from './logger/types';
4
- import { ISdkFactoryContext } from './sdkFactory/types';
5
- /* eslint-disable no-use-before-define */
6
-
7
5
  import { IStorageFactoryParams, IStorageSync, IStorageAsync, IStorageSyncFactory, IStorageAsyncFactory } from './storages/types';
8
- import { ISyncManagerCS } from './sync/types';
9
6
 
10
7
  /**
11
8
  * Reduced version of NodeJS.EventEmitter interface with the minimal methods used by the SDK
@@ -116,7 +113,6 @@ export interface ISettings {
116
113
  splitFilters: SplitIO.SplitFilter[],
117
114
  impressionsMode: SplitIO.ImpressionsMode,
118
115
  __splitFiltersValidation: ISplitFiltersValidation,
119
- localhostMode?: SplitIO.LocalhostFactory,
120
116
  enabled: boolean,
121
117
  flagSpecVersion: string,
122
118
  requestOptions?: {
@@ -666,13 +662,6 @@ export namespace SplitIO {
666
662
  * @typedef {Promise<SplitNames>} SplitNamesAsync
667
663
  */
668
664
  export type SplitNamesAsync = Promise<SplitNames>;
669
- /**
670
- * Localhost mode factory.
671
- */
672
- export type LocalhostFactory = {
673
- type: 'LocalhostFromObject' | 'LocalhostFromFile'
674
- (params: ISdkFactoryContext): ISyncManagerCS
675
- }
676
665
  /**
677
666
  * Impression listener interface. This is the interface that needs to be implemented
678
667
  * by the element you provide to the SDK as impression listener.
@@ -80,7 +80,6 @@ export const base = {
80
80
  splitFilters: undefined,
81
81
  // impressions collection mode
82
82
  impressionsMode: OPTIMIZED,
83
- localhostMode: undefined,
84
83
  enabled: true,
85
84
  flagSpecVersion: FLAG_SPEC_VERSION
86
85
  },
@@ -102,7 +101,7 @@ function fromSecondsToMillis(n: number) {
102
101
  */
103
102
  export function settingsValidation(config: unknown, validationParams: ISettingsValidationParams) {
104
103
 
105
- const { defaults, runtime, storage, integrations, logger, localhost, consent, flagSpec } = validationParams;
104
+ const { defaults, runtime, storage, integrations, logger, consent, flagSpec } = validationParams;
106
105
 
107
106
  // creates a settings object merging base, defaults and config objects.
108
107
  const withDefaults = merge({}, base, defaults, config) as ISettings;
@@ -180,8 +179,6 @@ export function settingsValidation(config: unknown, validationParams: ISettingsV
180
179
  // @ts-ignore, modify readonly prop
181
180
  if (integrations) withDefaults.integrations = integrations(withDefaults);
182
181
 
183
- if (localhost) sync.localhostMode = localhost(withDefaults);
184
-
185
182
  // validate push options
186
183
  if (withDefaults.streamingEnabled !== false) { // @ts-ignore, modify readonly prop
187
184
  withDefaults.streamingEnabled = true;
@@ -20,8 +20,6 @@ export interface ISettingsValidationParams {
20
20
  integrations?: (settings: ISettings) => ISettings['integrations'],
21
21
  /** Logger validator (`settings.debug`) */
22
22
  logger: (settings: ISettings) => ISettings['log'],
23
- /** Localhost mode validator (`settings.sync.localhostMode`) */
24
- localhost?: (settings: ISettings) => ISettings['sync']['localhostMode'],
25
23
  /** User consent validator (`settings.userConsent`) */
26
24
  consent?: (settings: ISettings) => ISettings['userConsent'],
27
25
  /** Flag spec version validation. Configurable by the JS Synchronizer but not by the SDKs */
@@ -106,7 +106,6 @@ export declare const ERROR_EMPTY = 319;
106
106
  export declare const ERROR_EMPTY_ARRAY = 320;
107
107
  export declare const ERROR_INVALID_CONFIG_PARAM = 321;
108
108
  export declare const ERROR_HTTP = 322;
109
- export declare const ERROR_LOCALHOST_MODULE_REQUIRED = 323;
110
109
  export declare const ERROR_STORAGE_INVALID = 324;
111
110
  export declare const ERROR_NOT_BOOLEAN = 325;
112
111
  export declare const ERROR_MIN_CONFIG_PARAM = 326;
@@ -1,2 +1 @@
1
- import { SplitIO } from '../../types';
2
- export declare function LocalhostFromObject(): SplitIO.LocalhostFactory;
1
+ export declare const localhostFromObjectFactory: (params: import("../../sdkFactory/types").ISdkFactoryContextSync) => import("../types").ISyncManagerCS;
package/types/types.d.ts CHANGED
@@ -1,9 +1,7 @@
1
1
  import { ISplitFiltersValidation } from './dtos/types';
2
2
  import { IIntegration, IIntegrationFactoryParams } from './integrations/types';
3
3
  import { ILogger } from './logger/types';
4
- import { ISdkFactoryContext } from './sdkFactory/types';
5
4
  import { IStorageFactoryParams, IStorageSync, IStorageAsync, IStorageSyncFactory, IStorageAsyncFactory } from './storages/types';
6
- import { ISyncManagerCS } from './sync/types';
7
5
  /**
8
6
  * Reduced version of NodeJS.EventEmitter interface with the minimal methods used by the SDK
9
7
  * @see {@link https://nodejs.org/api/events.html}
@@ -110,7 +108,6 @@ export interface ISettings {
110
108
  splitFilters: SplitIO.SplitFilter[];
111
109
  impressionsMode: SplitIO.ImpressionsMode;
112
110
  __splitFiltersValidation: ISplitFiltersValidation;
113
- localhostMode?: SplitIO.LocalhostFactory;
114
111
  enabled: boolean;
115
112
  flagSpecVersion: string;
116
113
  requestOptions?: {
@@ -659,13 +656,6 @@ export declare namespace SplitIO {
659
656
  * @typedef {Promise<SplitNames>} SplitNamesAsync
660
657
  */
661
658
  type SplitNamesAsync = Promise<SplitNames>;
662
- /**
663
- * Localhost mode factory.
664
- */
665
- type LocalhostFactory = {
666
- type: 'LocalhostFromObject' | 'LocalhostFromFile';
667
- (params: ISdkFactoryContext): ISyncManagerCS;
668
- };
669
659
  /**
670
660
  * Impression listener interface. This is the interface that needs to be implemented
671
661
  * by the element you provide to the SDK as impression listener.
@@ -35,7 +35,6 @@ export declare const base: {
35
35
  sync: {
36
36
  splitFilters: undefined;
37
37
  impressionsMode: string;
38
- localhostMode: undefined;
39
38
  enabled: boolean;
40
39
  flagSpecVersion: string;
41
40
  };
@@ -23,8 +23,6 @@ export interface ISettingsValidationParams {
23
23
  integrations?: (settings: ISettings) => ISettings['integrations'];
24
24
  /** Logger validator (`settings.debug`) */
25
25
  logger: (settings: ISettings) => ISettings['log'];
26
- /** Localhost mode validator (`settings.sync.localhostMode`) */
27
- localhost?: (settings: ISettings) => ISettings['sync']['localhostMode'];
28
26
  /** User consent validator (`settings.userConsent`) */
29
27
  consent?: (settings: ISettings) => ISettings['userConsent'];
30
28
  /** Flag spec version validation. Configurable by the JS Synchronizer but not by the SDKs */
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateLocalhostWithDefault = void 0;
4
- var LocalhostFromObject_1 = require("../../../sync/offline/LocalhostFromObject");
5
- var pluggable_1 = require("./pluggable");
6
- /**
7
- * This function validates `settings.sync.localhostMode` object
8
- *
9
- * @param {any} settings config object provided by the user to initialize the sdk
10
- *
11
- * @returns {Object} provided localhost mode module at `settings.sync.localhostMode` if valid, or a default LocalhostFromObject instance if not provided or invalid
12
- */
13
- function validateLocalhostWithDefault(settings) {
14
- if (!settings.sync.localhostMode)
15
- return (0, LocalhostFromObject_1.LocalhostFromObject)();
16
- return (0, pluggable_1.validateLocalhost)(settings) || (0, LocalhostFromObject_1.LocalhostFromObject)();
17
- }
18
- exports.validateLocalhostWithDefault = validateLocalhostWithDefault;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateLocalhost = void 0;
4
- var constants_1 = require("../../../logger/constants");
5
- var constants_2 = require("../../constants");
6
- /**
7
- * This function validates `settings.sync.localhostMode` object
8
- *
9
- * @param {any} settings config object provided by the user to initialize the sdk
10
- *
11
- * @returns {Object | undefined} provided localhost mode module at `settings.sync.localhostMode`, or undefined if it is not provided or invalid
12
- */
13
- function validateLocalhost(settings) {
14
- var localhostMode = settings.sync.localhostMode;
15
- // localhostMode.type is used for internal validation. Not considered part of the public API, and might be updated eventually.
16
- if (settings.mode === constants_2.LOCALHOST_MODE && (typeof localhostMode !== 'function' || localhostMode.type !== 'LocalhostFromObject')) {
17
- settings.log.error(constants_1.ERROR_LOCALHOST_MODULE_REQUIRED);
18
- return undefined;
19
- }
20
- return localhostMode;
21
- }
22
- exports.validateLocalhost = validateLocalhost;
@@ -1,14 +0,0 @@
1
- import { LocalhostFromObject } from '../../../sync/offline/LocalhostFromObject';
2
- import { validateLocalhost } from './pluggable';
3
- /**
4
- * This function validates `settings.sync.localhostMode` object
5
- *
6
- * @param {any} settings config object provided by the user to initialize the sdk
7
- *
8
- * @returns {Object} provided localhost mode module at `settings.sync.localhostMode` if valid, or a default LocalhostFromObject instance if not provided or invalid
9
- */
10
- export function validateLocalhostWithDefault(settings) {
11
- if (!settings.sync.localhostMode)
12
- return LocalhostFromObject();
13
- return validateLocalhost(settings) || LocalhostFromObject();
14
- }
@@ -1,18 +0,0 @@
1
- import { ERROR_LOCALHOST_MODULE_REQUIRED } from '../../../logger/constants';
2
- import { LOCALHOST_MODE } from '../../constants';
3
- /**
4
- * This function validates `settings.sync.localhostMode` object
5
- *
6
- * @param {any} settings config object provided by the user to initialize the sdk
7
- *
8
- * @returns {Object | undefined} provided localhost mode module at `settings.sync.localhostMode`, or undefined if it is not provided or invalid
9
- */
10
- export function validateLocalhost(settings) {
11
- var localhostMode = settings.sync.localhostMode;
12
- // localhostMode.type is used for internal validation. Not considered part of the public API, and might be updated eventually.
13
- if (settings.mode === LOCALHOST_MODE && (typeof localhostMode !== 'function' || localhostMode.type !== 'LocalhostFromObject')) {
14
- settings.log.error(ERROR_LOCALHOST_MODULE_REQUIRED);
15
- return undefined;
16
- }
17
- return localhostMode;
18
- }
@@ -1,16 +0,0 @@
1
- import { ILogger } from '../../../logger/types';
2
- import { SDKMode, } from '../../../types';
3
- import { LocalhostFromObject } from '../../../sync/offline/LocalhostFromObject';
4
- import { validateLocalhost } from './pluggable';
5
-
6
- /**
7
- * This function validates `settings.sync.localhostMode` object
8
- *
9
- * @param {any} settings config object provided by the user to initialize the sdk
10
- *
11
- * @returns {Object} provided localhost mode module at `settings.sync.localhostMode` if valid, or a default LocalhostFromObject instance if not provided or invalid
12
- */
13
- export function validateLocalhostWithDefault(settings: { log: ILogger, sync: { localhostMode?: any }, mode: SDKMode }) {
14
- if (!settings.sync.localhostMode) return LocalhostFromObject();
15
- return validateLocalhost(settings) || LocalhostFromObject();
16
- }
@@ -1,22 +0,0 @@
1
- import { ERROR_LOCALHOST_MODULE_REQUIRED } from '../../../logger/constants';
2
- import { ILogger } from '../../../logger/types';
3
- import { SDKMode, } from '../../../types';
4
- import { LOCALHOST_MODE } from '../../constants';
5
-
6
- /**
7
- * This function validates `settings.sync.localhostMode` object
8
- *
9
- * @param {any} settings config object provided by the user to initialize the sdk
10
- *
11
- * @returns {Object | undefined} provided localhost mode module at `settings.sync.localhostMode`, or undefined if it is not provided or invalid
12
- */
13
- export function validateLocalhost(settings: { log: ILogger, sync: { localhostMode?: any}, mode: SDKMode }) {
14
- const localhostMode = settings.sync.localhostMode;
15
-
16
- // localhostMode.type is used for internal validation. Not considered part of the public API, and might be updated eventually.
17
- if (settings.mode === LOCALHOST_MODE && (typeof localhostMode !== 'function' || localhostMode.type !== 'LocalhostFromObject')) {
18
- settings.log.error(ERROR_LOCALHOST_MODULE_REQUIRED);
19
- return undefined;
20
- }
21
- return localhostMode;
22
- }
@@ -1,3 +0,0 @@
1
- import { ISet } from '../../utils/lang/sets';
2
- import { ILogger } from '../../logger/types';
3
- export declare function inListSemverMatcherContext(log: ILogger, ruleAttr: ISet<string>): (runtimeAttr: string) => boolean;
@@ -1,5 +0,0 @@
1
- import { ISplitMatcher } from '../../dtos/types';
2
- /**
3
- * Extract whitelist array. Used by set and string matchers
4
- */
5
- export declare function setTransform(whitelistObject: ISplitMatcher['whitelistMatcherData']): string[] | null | undefined;
@@ -1,7 +0,0 @@
1
- import { ISplitMatcher } from '../../dtos/types';
2
- /**
3
- * Extract value from string matcher data.
4
- */
5
- export declare function stringTransform({ stringMatcherData }: ISplitMatcher): {
6
- value: string | null | undefined;
7
- };
@@ -1,12 +0,0 @@
1
- import { IIntegrationManager, IIntegrationFactoryParams } from './types';
2
- import { BrowserIntegration } from './ga/types';
3
- /**
4
- * IntegrationsManager factory for the browser variant of the isomorphic JS SDK.
5
- * The integrations manager instantiates integration modules, and bypass tracked events and impressions to them.
6
- *
7
- * @param integrations valid integration settings object for browser sdk
8
- * @param params information of the Sdk factory instance that integrations can access to
9
- *
10
- * @returns integration manager or undefined if `integrations` are not present in settings.
11
- */
12
- export declare function integrationsManagerFactory(integrations: BrowserIntegration[], params: IIntegrationFactoryParams): IIntegrationManager | undefined;
@@ -1,40 +0,0 @@
1
- /// <reference types="google.analytics" />
2
- import { SplitIO } from '../../types';
3
- import { Identity, GoogleAnalyticsToSplitOptions } from './types';
4
- import { ILogger } from '../../logger/types';
5
- import { IIntegrationFactoryParams } from '../types';
6
- export declare const defaultMapper: (model: UniversalAnalytics.Model) => SplitIO.EventData;
7
- export declare const defaultPrefix = "ga";
8
- /**
9
- * Return a new list of identities removing invalid and duplicated ones.
10
- *
11
- * @param {Array} identities list of identities
12
- * @returns list of valid and unique identities. The list might be empty if `identities` is not an array or all its elements are invalid.
13
- */
14
- export declare function validateIdentities(identities?: Identity[]): Identity[];
15
- /**
16
- * Checks if EventData fields (except EventTypeId) are valid, and logs corresponding warnings.
17
- * EventTypeId is validated separately.
18
- *
19
- * @param {EventData} data event data instance to validate. Precondition: data != undefined
20
- * @returns {boolean} Whether the data instance is a valid EventData or not.
21
- */
22
- export declare function validateEventData(log: ILogger, eventData: any): eventData is SplitIO.EventData;
23
- /**
24
- * Fixes the passed string value to comply with EventTypeId format, by removing invalid characters and truncating if necessary.
25
- *
26
- * @param {object} log factory logger
27
- * @param {string} eventTypeId string value to fix.
28
- * @returns {string} Fixed version of `eventTypeId`.
29
- */
30
- export declare function fixEventTypeId(log: ILogger, eventTypeId: any): any;
31
- /**
32
- * GaToSplit integration.
33
- * This function provides the SplitTracker plugin to ga command queue.
34
- *
35
- * @param {object} sdkOptions options passed at the SDK integrations settings (isomorphic SDK) or the GoogleAnalyticsToSplit plugin (pluggable browser SDK)
36
- * @param {object} storage SDK storage passed to track events
37
- * @param {object} coreSettings core settings used to define an identity if no one provided as SDK or plugin options
38
- * @param {object} log factory logger
39
- */
40
- export declare function GaToSplit(sdkOptions: GoogleAnalyticsToSplitOptions, params: IIntegrationFactoryParams): void;
@@ -1,3 +0,0 @@
1
- import { IntegrationFactory } from '../types';
2
- import { GoogleAnalyticsToSplitOptions } from './types';
3
- export declare function GoogleAnalyticsToSplit(options?: GoogleAnalyticsToSplitOptions): IntegrationFactory;
@@ -1,34 +0,0 @@
1
- /// <reference types="google.analytics" />
2
- import { SplitIO } from '../../types';
3
- import { IIntegration } from '../types';
4
- import { SplitToGoogleAnalyticsOptions } from './types';
5
- import { ILogger } from '../../logger/types';
6
- export declare class SplitToGa implements IIntegration {
7
- static defaultTrackerNames: string[];
8
- private trackerNames;
9
- private filter?;
10
- private mapper?;
11
- private impressions;
12
- private events;
13
- private log;
14
- static defaultMapper({ type, payload }: SplitIO.IntegrationData): UniversalAnalytics.FieldsObject;
15
- static getGa(): UniversalAnalytics.ga | undefined;
16
- /**
17
- * Validates if a given object is a UniversalAnalytics.FieldsObject instance, and logs a warning if not.
18
- * It checks that the object contains a `hitType`, since it is the minimal field required to send the hit
19
- * and avoid the GA error `No hit type specified. Aborting hit.`.
20
- * Other validations (e.g., an `event` hitType must have a `eventCategory` and `eventAction`) are handled
21
- * and logged (as warnings or errors depending the case) by GA debugger, but the hit is sent anyway.
22
- *
23
- * @param {object} log factory logger
24
- * @param {UniversalAnalytics.FieldsObject} fieldsObject object to validate.
25
- * @returns {boolean} Whether the data instance is a valid FieldsObject or not.
26
- */
27
- static validateFieldsObject(log: ILogger, fieldsObject: any): fieldsObject is UniversalAnalytics.FieldsObject;
28
- /**
29
- * constructor description
30
- * @param {object} options options passed at the SDK integrations settings (isomorphic SDK) or the SplitToGoogleAnalytics plugin (pluggable browser SDK)
31
- */
32
- constructor(log: ILogger, options: SplitToGoogleAnalyticsOptions);
33
- queue(data: SplitIO.IntegrationData): void;
34
- }
@@ -1,3 +0,0 @@
1
- import { IntegrationFactory } from '../types';
2
- import { SplitToGoogleAnalyticsOptions } from './types';
3
- export declare function SplitToGoogleAnalytics(options?: SplitToGoogleAnalyticsOptions): IntegrationFactory;
@@ -1,148 +0,0 @@
1
- /// <reference types="google.analytics" />
2
- import { SplitIO } from '../../types';
3
- /**
4
- * A pair of user key and it's trafficType, required for tracking valid Split events.
5
- * @typedef {Object} Identity
6
- * @property {string} key The user key.
7
- * @property {string} trafficType The key traffic type.
8
- */
9
- export declare type Identity = {
10
- key: string;
11
- trafficType: string;
12
- };
13
- /**
14
- * Options for GoogleAnalyticsToSplit integration plugin
15
- */
16
- export interface GoogleAnalyticsToSplitOptions {
17
- /**
18
- * Optional flag to filter GA hits from being tracked as Split events.
19
- * @property {boolean} hits
20
- * @default true
21
- */
22
- hits?: boolean;
23
- /**
24
- * Optional predicate used to define a custom filter for tracking GA hits as Split events.
25
- * For example, the following filter allows to track only 'event' hits:
26
- * `(model) => model.get('hitType') === 'event'`
27
- * By default, all hits are tracked as Split events.
28
- */
29
- filter?: (model: UniversalAnalytics.Model) => boolean;
30
- /**
31
- * Optional function useful when you need to modify the Split event before tracking it.
32
- * This function is invoked with two arguments:
33
- * 1. the GA model object representing the hit.
34
- * 2. the default format of the mapped Split event instance.
35
- * The return value must be a Split event, that can be the second argument or a new object.
36
- *
37
- * For example, the following mapper adds a custom property to events:
38
- * `(model, defaultMapping) => {
39
- * defaultMapping.properties.someProperty = SOME_VALUE;
40
- * return defaultMapping;
41
- * }`
42
- */
43
- mapper?: (model: UniversalAnalytics.Model, defaultMapping: SplitIO.EventData) => SplitIO.EventData;
44
- /**
45
- * Optional prefix for EventTypeId, to prevent any kind of data collision between events.
46
- * @property {string} prefix
47
- * @default 'ga'
48
- */
49
- prefix?: string;
50
- /**
51
- * List of Split identities (key & traffic type pairs) used to track events.
52
- * If not provided, events are sent using the key and traffic type provided at SDK config
53
- */
54
- identities?: Identity[];
55
- /**
56
- * Optional flag to log an error if the `auto-require` script is not detected.
57
- * The auto-require script automatically requires the `splitTracker` plugin for created trackers,
58
- * and should be placed right after your Google Analytics, Google Tag Manager or gtag.js script tag.
59
- *
60
- * @see {@link https://help.split.io/hc/en-us/articles/360040838752#set-up-with-gtm-and-gtag.js}
61
- *
62
- * @property {boolean} autoRequire
63
- * @default false
64
- */
65
- autoRequire?: boolean;
66
- }
67
- /**
68
- * Enable 'Google Analytics to Split' integration, to track Google Analytics hits as Split events.
69
- * Used by the browser variant of the isomorphic JS SDK.
70
- *
71
- * @see {@link https://help.split.io/hc/en-us/articles/360040838752#google-analytics-to-split}
72
- */
73
- export interface IGoogleAnalyticsToSplitConfig extends GoogleAnalyticsToSplitOptions {
74
- type: 'GOOGLE_ANALYTICS_TO_SPLIT';
75
- }
76
- /**
77
- * Options for SplitToGoogleAnalytics integration plugin
78
- */
79
- export interface SplitToGoogleAnalyticsOptions {
80
- /**
81
- * Optional flag to filter Split impressions from being tracked as GA hits.
82
- * @property {boolean} impressions
83
- * @default true
84
- */
85
- impressions?: boolean;
86
- /**
87
- * Optional flag to filter Split events from being tracked as GA hits.
88
- * @property {boolean} events
89
- * @default true
90
- */
91
- events?: boolean;
92
- /**
93
- * Optional predicate used to define a custom filter for tracking Split data (events and impressions) as GA hits.
94
- * For example, the following filter allows to track only impressions, equivalent to setting events to false:
95
- * `(data) => data.type === 'IMPRESSION'`
96
- */
97
- filter?: (data: SplitIO.IntegrationData) => boolean;
98
- /**
99
- * Optional function useful when you need to modify the GA hit before sending it.
100
- * This function is invoked with two arguments:
101
- * 1. the input data (Split event or impression).
102
- * 2. the default format of the mapped FieldsObject instance (GA hit).
103
- * The return value must be a FieldsObject, that can be the second argument or a new object.
104
- *
105
- * For example, the following mapper adds a custom dimension to hits:
106
- * `(data, defaultMapping) => {
107
- * defaultMapping.dimension1 = SOME_VALUE;
108
- * return defaultMapping;
109
- * }`
110
- *
111
- * Default FieldsObject instance for data.type === 'IMPRESSION':
112
- * `{
113
- * hitType: 'event',
114
- * eventCategory: 'split-impression',
115
- * eventAction: 'Evaluate ' + data.payload.impression.feature,
116
- * eventLabel: 'Treatment: ' + data.payload.impression.treatment + '. Targeting rule: ' + data.payload.impression.label + '.',
117
- * nonInteraction: true,
118
- * }`
119
- * Default FieldsObject instance for data.type === 'EVENT':
120
- * `{
121
- * hitType: 'event',
122
- * eventCategory: 'split-event',
123
- * eventAction: data.payload.eventTypeId,
124
- * eventValue: data.payload.value,
125
- * nonInteraction: true,
126
- * }`
127
- */
128
- mapper?: (data: SplitIO.IntegrationData, defaultMapping: UniversalAnalytics.FieldsObject) => UniversalAnalytics.FieldsObject;
129
- /**
130
- * List of tracker names to send the hit. An empty string represents the default tracker.
131
- * If not provided, hits are only sent to default tracker.
132
- */
133
- trackerNames?: string[];
134
- }
135
- /**
136
- * Enable 'Split to Google Analytics' integration, to track Split impressions and events as Google Analytics hits.
137
- * Used by the browser variant of the isomorphic JS SDK.
138
- *
139
- * @see {@link https://help.split.io/hc/en-us/articles/360040838752#split-to-google-analytics}
140
- */
141
- export interface ISplitToGoogleAnalyticsConfig extends SplitToGoogleAnalyticsOptions {
142
- type: 'SPLIT_TO_GOOGLE_ANALYTICS';
143
- }
144
- /**
145
- * Available integration options for the browser
146
- * Used by the browser variant of the isomorphic JS SDK.
147
- */
148
- export declare type BrowserIntegration = ISplitToGoogleAnalyticsConfig | IGoogleAnalyticsToSplitConfig;
@@ -1,8 +0,0 @@
1
- import { SplitIO } from '../types';
2
- import { ISdkFactoryContext } from '../sdkFactory/types';
3
- /**
4
- * Factory of client method for the client-side (browser) variant of the Isomorphic JS SDK,
5
- * where clients can have a bound TT for the track method, which is provided via the settings
6
- * (default client) or the client method (shared clients).
7
- */
8
- export declare function sdkClientMethodCSFactory(params: ISdkFactoryContext): (key?: SplitIO.SplitKey, trafficType?: string) => SplitIO.ICsClient;
@@ -1,54 +0,0 @@
1
- import { IMySegmentsResponse } from '../dtos/types';
2
- import { MySegmentsData } from '../sync/polling/types';
3
- import { ISegmentsCacheSync } from './types';
4
- /**
5
- * This class provides a skeletal implementation of the ISegmentsCacheSync interface
6
- * to minimize the effort required to implement this interface.
7
- */
8
- export declare abstract class AbstractSegmentsCacheSync implements ISegmentsCacheSync {
9
- /**
10
- * For server-side synchronizer: add `segmentKeys` list of keys to `name` segment.
11
- * For client-side synchronizer: add `name` segment to the cache. `segmentKeys` is undefined.
12
- */
13
- abstract addToSegment(name: string, segmentKeys?: string[]): boolean;
14
- /**
15
- * For server-side synchronizer: remove `segmentKeys` list of keys from `name` segment.
16
- * For client-side synchronizer: remove `name` segment from the cache. `segmentKeys` is undefined.
17
- */
18
- abstract removeFromSegment(name: string, segmentKeys?: string[]): boolean;
19
- /**
20
- * For server-side synchronizer: check if `key` is in `name` segment.
21
- * For client-side synchronizer: check if `name` segment is in the cache. `key` is undefined.
22
- */
23
- abstract isInSegment(name: string, key?: string): boolean;
24
- /**
25
- * clear the cache.
26
- */
27
- clear(): void;
28
- /**
29
- * For server-side synchronizer: add the given list of segments to the cache, with an empty list of keys. The segments that already exist are not modified.
30
- * For client-side synchronizer: the method is not used.
31
- */
32
- registerSegments(names: string[]): boolean;
33
- /**
34
- * For server-side synchronizer: get the list of segments to fetch changes.
35
- * Also used for the `seC` (segment count) telemetry stat.
36
- */
37
- abstract getRegisteredSegments(): string[];
38
- /**
39
- * Only used for the `skC`(segment keys count) telemetry stat: 1 for client-side, and total count of keys in server-side.
40
- * @TODO for client-side it should be the number of clients, but it requires a refactor of MySegments caches to simplify the code.
41
- */
42
- abstract getKeysCount(): number;
43
- /**
44
- * For server-side synchronizer: change number of `name` segment.
45
- * For client-side synchronizer: change number of mySegments.
46
- */
47
- abstract setChangeNumber(name?: string, changeNumber?: number): boolean | void;
48
- abstract getChangeNumber(name: string): number;
49
- /**
50
- * For server-side synchronizer: the method is not used.
51
- * For client-side synchronizer: it resets or updates the cache.
52
- */
53
- resetSegments(segmentsData: MySegmentsData | IMySegmentsResponse): boolean;
54
- }
@@ -1,46 +0,0 @@
1
- import { ISplit, MaybeThenable } from '../dtos/types';
2
- /**
3
- * This class provides a skeletal implementation of the ISplitsCacheAsync interface
4
- * to minimize the effort required to implement this interface.
5
- */
6
- export declare abstract class AbstractSplitsCache {
7
- /**
8
- * Check if the splits information is already stored in cache. This data can be preloaded.
9
- * It is used as condition to emit SDK_SPLITS_CACHE_LOADED, and then SDK_READY_FROM_CACHE.
10
- */
11
- checkCache(): boolean;
12
- protected abstract addSplit(name: string, split: ISplit): MaybeThenable<boolean>;
13
- /**
14
- * Add a list of splits.
15
- * The returned promise is resolved when the operation success or rejected if it fails (e.g., wrapper operation fails).
16
- */
17
- protected addSplits(entries: [string, ISplit][]): Promise<boolean[]>;
18
- protected abstract removeSplit(name: string): MaybeThenable<boolean>;
19
- /**
20
- * Remove a list of splits.
21
- * The returned promise is resolved when the operation success, with a boolean array indicating if the splits existed or not.
22
- * or rejected if it fails (e.g., wrapper operation fails).
23
- */
24
- protected removeSplits(names: string[]): Promise<boolean[]>;
25
- protected abstract setChangeNumber(changeNumber: number): MaybeThenable<boolean | void>;
26
- /**
27
- * Updates the cache with the provided changeNumber, feature flags to add and feature flags to remove.
28
- *
29
- * @returns {Promise<boolean>} a promise that resolved once the operation is performed successfully. The fulfillment value is `true` if at least one feature flag was added, modified or removed; or `false` if there was no change.
30
- * The promise will reject if some storage operation rejects.
31
- */
32
- update(changeNumber: number, toAdd: [string, ISplit][], toRemove?: string[]): Promise<boolean>;
33
- abstract getSplit(name: string): MaybeThenable<ISplit | null>;
34
- /**
35
- * Kill `name` split and set `defaultTreatment` and `changeNumber`.
36
- * Used for SPLIT_KILL push notifications.
37
- *
38
- * @param {string} name
39
- * @param {string} defaultTreatment
40
- * @param {number} changeNumber
41
- * @returns {Promise} a promise that is resolved once the split kill operation is performed. The fulfillment value is a boolean: `true` if the operation successed updating the split or `false` if no split is updated,
42
- * for instance, if the `changeNumber` is old, or if the split is not found (e.g., `/splitchanges` hasn't been fetched yet), or if the storage fails to apply the update.
43
- * The promise will never be rejected.
44
- */
45
- killLocally(name: string, defaultTreatment: string, changeNumber: number): Promise<boolean>;
46
- }
@@ -1,27 +0,0 @@
1
- import { Compression, KeyList } from './SSEHandler/types';
2
- /**
3
- * Decode, decompress and parse the provided 'data' into a KeyList object
4
- *
5
- * @param {string} data
6
- * @param {number} compression
7
- * @returns {{a?: string[], r?: string[] }}
8
- * @throws if data string cannot be decoded, decompressed or parsed
9
- */
10
- export declare function parseKeyList(data: string, compression: Compression): KeyList;
11
- /**
12
- * Decode, decompress and parse the provided 'data' into a Bitmap object
13
- *
14
- * @param {string} data
15
- * @param {number} compression
16
- * @returns {Uint8Array}
17
- * @throws if data string cannot be decoded or decompressed
18
- */
19
- export declare function parseBitmap(data: string, compression: Compression): Uint8Array;
20
- /**
21
- * Check if the 'bitmap' bit at 'hash64hex' position is 1
22
- *
23
- * @param {Uint8Array} bitmap
24
- * @param {string} hash64hex 16-chars string, representing a number in hexa
25
- * @returns {boolean}
26
- */
27
- export declare function isInBitmap(bitmap: Uint8Array, hash64hex: string): boolean;
@@ -1,9 +0,0 @@
1
- import { IPushManager } from './types';
2
- import { IPollingManager } from '../polling/types';
3
- import { ISdkFactoryContextSync } from '../../sdkFactory/types';
4
- /**
5
- * PushManager factory:
6
- * - for server-side if key is not provided in settings.
7
- * - for client-side, with support for multiple clients, if key is provided in settings
8
- */
9
- export declare function pushManagerFactory(params: ISdkFactoryContextSync, pollingManager: IPollingManager): IPushManager | undefined;
@@ -1,9 +0,0 @@
1
- import { IPushManager } from './types';
2
- import { IPollingManager } from '../polling/types';
3
- import { ISdkFactoryContextSync } from '../../sdkFactory/types';
4
- /**
5
- * PushManager factory:
6
- * - for server-side if key is not provided in settings.
7
- * - for client-side, with support for multiple clients, if key is provided in settings
8
- */
9
- export declare function pushManagerFactory(params: ISdkFactoryContextSync, pollingManager: IPollingManager): IPushManager | undefined;
@@ -1,5 +0,0 @@
1
- import { ISettings } from '../../types';
2
- /**
3
- * Storage is async if mode is consumer or partial consumer
4
- */
5
- export declare function isStorageSync(settings: Pick<ISettings, 'mode'>): boolean;
@@ -1,7 +0,0 @@
1
- import { ILogger } from '../../logger/types';
2
- /** validates the given SDK key */
3
- export declare function validateApiKey(log: ILogger, maybeSdkKey: any): string | false;
4
- export declare const usedKeysMap: Record<string, number>;
5
- /** validates the given SDK key and also warns if it is in use */
6
- export declare function validateAndTrackApiKey(log: ILogger, maybeSdkKey: any): string | false;
7
- export declare function releaseApiKey(sdkKey: string): void;
@@ -1,7 +0,0 @@
1
- import { IReadinessManager } from '../../readiness/types';
2
- import { ILogger } from '../../logger/types';
3
- /**
4
- * This is defined here and in this format mostly because of the logger and the fact that it's considered a validation at product level.
5
- * But it's not going to run on the input validation layer. In any case, the most compeling reason to use it as we do is to avoid going to Redis and get a split twice.
6
- */
7
- export declare function validateSplitExistance(log: ILogger, readinessManager: IReadinessManager, splitName: string, labelOrSplitObj: any, method: string): boolean;
@@ -1,9 +0,0 @@
1
- import { ISplitsCacheBase } from '../../storages/types';
2
- import { IReadinessManager } from '../../readiness/types';
3
- import { SDKMode } from '../../types';
4
- import { MaybeThenable } from '../../dtos/types';
5
- import { ILogger } from '../../logger/types';
6
- /**
7
- * Separated from the previous method since on some cases it'll be async.
8
- */
9
- export declare function validateTrafficTypeExistance(log: ILogger, readinessManager: IReadinessManager, splitsCache: ISplitsCacheBase, mode: SDKMode, maybeTT: string, method: string): MaybeThenable<boolean>;
@@ -1,59 +0,0 @@
1
- /**
2
- * Map implementation based on es6-map polyfill (https://github.com/medikoo/es6-map/blob/master/polyfill.js),
3
- * with the minimal features used by the SDK.
4
-
5
- Copyright (C) 2013 Mariusz Nowak (www.medikoo.com)
6
-
7
- Permission is hereby granted, free of charge, to any person obtaining a copy
8
- of this software and associated documentation files (the "Software"), to deal
9
- in the Software without restriction, including without limitation the rights
10
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- copies of the Software, and to permit persons to whom the Software is
12
- furnished to do so, subject to the following conditions:
13
-
14
- The above copyright notice and this permission notice shall be included in
15
- all copies or substantial portions of the Software.
16
-
17
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23
- THE SOFTWARE.
24
- **/
25
- export interface IMap<K, V> {
26
- clear(): void;
27
- delete(key: K): boolean;
28
- forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void;
29
- get(key: K): V | undefined;
30
- has(key: K): boolean;
31
- set(key: K, value: V): this;
32
- readonly size: number;
33
- }
34
- export declare class MapPoly<K, V> implements IMap<K, V> {
35
- private __mapKeysData__;
36
- private __mapValuesData__;
37
- constructor(entries?: readonly (readonly [K, V])[] | null);
38
- clear(): void;
39
- delete(key: K): boolean;
40
- forEach(callbackfn: (value: V, key: K, map: Map<K, V>) => void, thisArg?: any): void;
41
- get(key: K): V | undefined;
42
- has(key: K): boolean;
43
- set(key: K, value: V): this;
44
- get size(): number;
45
- }
46
- interface IMapConstructor {
47
- new (): IMap<any, any>;
48
- new <K, V>(entries?: readonly (readonly [K, V])[] | null): IMap<K, V>;
49
- readonly prototype: IMap<any, any>;
50
- }
51
- /**
52
- * return the Map constructor to use. If native Map is not available or it doesn't support the required features (e.g., IE11),
53
- * a ponyfill with minimal features is returned instead.
54
- *
55
- * Exported for testing purposes only.
56
- */
57
- export declare function __getMapConstructor(): IMapConstructor;
58
- export declare const _Map: IMapConstructor;
59
- export {};
@@ -1,4 +0,0 @@
1
- export declare class RedisMock {
2
- private pipelineMethods;
3
- constructor();
4
- }
@@ -1,16 +0,0 @@
1
- import { ILogger } from '../../../logger/types';
2
- import { SDKMode } from '../../../types';
3
- /**
4
- * This function validates `settings.sync.localhostMode` object
5
- *
6
- * @param {any} settings config object provided by the user to initialize the sdk
7
- *
8
- * @returns {Object} provided localhost mode module at `settings.sync.localhostMode` if valid, or a default LocalhostFromObject instance if not provided or invalid
9
- */
10
- export declare function validateLocalhostWithDefault(settings: {
11
- log: ILogger;
12
- sync: {
13
- localhostMode?: any;
14
- };
15
- mode: SDKMode;
16
- }): any;
@@ -1,16 +0,0 @@
1
- import { ILogger } from '../../../logger/types';
2
- import { SDKMode } from '../../../types';
3
- /**
4
- * This function validates `settings.sync.localhostMode` object
5
- *
6
- * @param {any} settings config object provided by the user to initialize the sdk
7
- *
8
- * @returns {Object | undefined} provided localhost mode module at `settings.sync.localhostMode`, or undefined if it is not provided or invalid
9
- */
10
- export declare function validateLocalhost(settings: {
11
- log: ILogger;
12
- sync: {
13
- localhostMode?: any;
14
- };
15
- mode: SDKMode;
16
- }): any;
@@ -1,8 +0,0 @@
1
- import { LogLevel } from '../../../types';
2
- /**
3
- * The debug level can be set globally via the `localStorage.splitio_debug` item in browser, or the `SPLITIO_DEBUG` env var in NodeJS.
4
- * Acceptable values are: 'DEBUG', 'INFO', 'WARN', 'ERROR', 'NONE'.
5
- * Other acceptable values are 'on', 'enable' and 'enabled', which are equivalent to 'DEBUG'.
6
- * Any other value, like undefined, null or an invalid string, returns `undefined` and means that the global log level is not set.
7
- */
8
- export declare function getGlobalLogLevel(): LogLevel | undefined;
File without changes