@splitsoftware/splitio-commons 1.13.1 → 1.13.2-rc.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.
Files changed (35) hide show
  1. package/CHANGES.txt +4 -0
  2. package/CONTRIBUTORS-GUIDE.md +1 -1
  3. package/README.md +5 -3
  4. package/cjs/evaluator/combiners/ifelseif.js +2 -2
  5. package/cjs/evaluator/parser/index.js +1 -2
  6. package/cjs/logger/messages/error.js +1 -1
  7. package/cjs/services/splitApi.js +1 -1
  8. package/cjs/storages/KeyBuilder.js +3 -2
  9. package/cjs/utils/constants/index.js +2 -1
  10. package/cjs/utils/labels/index.js +2 -1
  11. package/cjs/utils/settingsValidation/index.js +1 -1
  12. package/esm/evaluator/combiners/ifelseif.js +2 -2
  13. package/esm/evaluator/parser/index.js +1 -2
  14. package/esm/logger/messages/error.js +1 -1
  15. package/esm/services/splitApi.js +2 -2
  16. package/esm/storages/KeyBuilder.js +3 -2
  17. package/esm/utils/constants/index.js +1 -0
  18. package/esm/utils/labels/index.js +1 -0
  19. package/esm/utils/settingsValidation/index.js +1 -1
  20. package/package.json +2 -2
  21. package/src/evaluator/combiners/ifelseif.ts +2 -2
  22. package/src/evaluator/matchers/matcherTypes.ts +1 -1
  23. package/src/evaluator/parser/index.ts +1 -2
  24. package/src/logger/messages/error.ts +1 -1
  25. package/src/services/splitApi.ts +2 -2
  26. package/src/storages/KeyBuilder.ts +3 -2
  27. package/src/types.ts +3 -3
  28. package/src/utils/constants/index.ts +2 -0
  29. package/src/utils/labels/index.ts +1 -0
  30. package/src/utils/settingsValidation/index.ts +1 -1
  31. package/types/storages/KeyBuilder.d.ts +1 -1
  32. package/types/types.d.ts +3 -3
  33. package/types/utils/constants/index.d.ts +1 -0
  34. package/types/utils/labels/index.d.ts +1 -0
  35. package/types/utils/settingsValidation/logger/globalLogLevel.d.ts +8 -0
package/CHANGES.txt CHANGED
@@ -1,3 +1,7 @@
1
+ 1.14.0 (April XX, 2024)
2
+ - Updated impression label to 'unsupported matcher type' when the matcher type is not supported by the SDK.
3
+ - Updated Split API client to include the flags spec version query parameter for the `splitChanges` endpoint.
4
+
1
5
  1.13.1 (January 10, 2024)
2
6
  - 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
7
 
@@ -1,4 +1,4 @@
1
- # Contributing to the Split Javascript SDK Commons
1
+ # Contributing to the Split JavaScript SDK Commons
2
2
 
3
3
  Split SDK is an open source project and we welcome feedback and contribution. The information below describes how to build the project with your changes, run the tests, and send the Pull Request(PR).
4
4
 
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Split Javascript SDK common components
1
+ # Split JavaScript SDK common components
2
2
 
3
3
  [![npm version](https://badge.fury.io/js/%40splitsoftware%2Fsplitio-commons.svg)](https://badge.fury.io/js/%40splitsoftware%2Fsplitio-commons) [![Build Status](https://github.com/splitio/javascript-commons/actions/workflows/ci.yml/badge.svg)](https://github.com/splitio/javascript-commons/actions/workflows/ci.yml)
4
4
 
@@ -27,13 +27,15 @@ Split has built and maintains SDKs for:
27
27
  * .NET [Github](https://github.com/splitio/dotnet-client) [Docs](https://help.split.io/hc/en-us/articles/360020240172--NET-SDK)
28
28
  * Android [Github](https://github.com/splitio/android-client) [Docs](https://help.split.io/hc/en-us/articles/360020343291-Android-SDK)
29
29
  * Angular [Github](https://github.com/splitio/angular-sdk-plugin) [Docs](https://help.split.io/hc/en-us/articles/6495326064397-Angular-utilities)
30
+ * Flutter [Github](https://github.com/splitio/flutter-sdk-plugin) [Docs](https://help.split.io/hc/en-us/articles/8096158017165-Flutter-plugin)
30
31
  * GO [Github](https://github.com/splitio/go-client) [Docs](https://help.split.io/hc/en-us/articles/360020093652-Go-SDK)
31
32
  * iOS [Github](https://github.com/splitio/ios-client) [Docs](https://help.split.io/hc/en-us/articles/360020401491-iOS-SDK)
32
33
  * Java [Github](https://github.com/splitio/java-client) [Docs](https://help.split.io/hc/en-us/articles/360020405151-Java-SDK)
33
- * Javascript [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK)
34
- * Javascript for Browser [Github](https://github.com/splitio/javascript-browser-client) [Docs](https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK)
34
+ * JavaScript [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK)
35
+ * JavaScript for Browser [Github](https://github.com/splitio/javascript-browser-client) [Docs](https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK)
35
36
  * Node [Github](https://github.com/splitio/javascript-client) [Docs](https://help.split.io/hc/en-us/articles/360020564931-Node-js-SDK)
36
37
  * PHP [Github](https://github.com/splitio/php-client) [Docs](https://help.split.io/hc/en-us/articles/360020350372-PHP-SDK)
38
+ * PHP thin-client [Github](https://github.com/splitio/php-thin-client) [Docs](https://help.split.io/hc/en-us/articles/18305128673933-PHP-Thin-Client-SDK)
37
39
  * Python [Github](https://github.com/splitio/python-client) [Docs](https://help.split.io/hc/en-us/articles/360020359652-Python-SDK)
38
40
  * React [Github](https://github.com/splitio/react-client) [Docs](https://help.split.io/hc/en-us/articles/360038825091-React-SDK)
39
41
  * React Native [Github](https://github.com/splitio/react-native-client) [Docs](https://help.split.io/hc/en-us/articles/4406066357901-React-Native-SDK)
@@ -12,7 +12,7 @@ function ifElseIfCombinerContext(log, predicates) {
12
12
  log.error(constants_2.ERROR_ENGINE_COMBINER_IFELSEIF);
13
13
  return {
14
14
  treatment: constants_1.CONTROL,
15
- label: LabelsConstants.EXCEPTION
15
+ label: LabelsConstants.UNSUPPORTED_MATCHER_TYPE
16
16
  };
17
17
  }
18
18
  function computeTreatment(predicateResults) {
@@ -39,7 +39,7 @@ function ifElseIfCombinerContext(log, predicates) {
39
39
  return computeTreatment(predicateResults);
40
40
  }
41
41
  // if there is none predicates, then there was an error in parsing phase
42
- if (!Array.isArray(predicates) || Array.isArray(predicates) && predicates.length === 0) {
42
+ if (!Array.isArray(predicates) || predicates.length === 0) {
43
43
  return unexpectedInputHandler;
44
44
  }
45
45
  else {
@@ -30,8 +30,7 @@ function parser(log, conditions, storage) {
30
30
  return Boolean(result ^ matcherDto.negate);
31
31
  };
32
32
  });
33
- // if matcher's factory can't instanciate the matchers, the expressions array
34
- // will be empty
33
+ // if matcher's factory can't instantiate the matchers, the expressions array will be empty
35
34
  if (expressions.length === 0) {
36
35
  // reset any data collected during parsing
37
36
  predicates = [];
@@ -5,7 +5,7 @@ var tslib_1 = require("tslib");
5
5
  var c = (0, tslib_1.__importStar)(require("../constants"));
6
6
  exports.codesError = [
7
7
  // evaluator
8
- [c.ERROR_ENGINE_COMBINER_IFELSEIF, c.LOG_PREFIX_ENGINE_COMBINER + 'Invalid feature flag, no valid rules found'],
8
+ [c.ERROR_ENGINE_COMBINER_IFELSEIF, c.LOG_PREFIX_ENGINE_COMBINER + 'Invalid feature flag, no valid rules or unsupported matcher type found'],
9
9
  // SDK
10
10
  [c.ERROR_LOGLEVEL_INVALID, 'logger: Invalid Log Level - No changes to the logs will be applied.'],
11
11
  [c.ERROR_CLIENT_CANNOT_GET_READY, 'The SDK will not get ready. Reason: %s'],
@@ -41,7 +41,7 @@ function splitApiFactory(settings, platform, telemetryTracker) {
41
41
  return splitHttpClient(url, undefined, telemetryTracker.trackHttp(constants_1.TOKEN));
42
42
  },
43
43
  fetchSplitChanges: function (since, noCache, till) {
44
- var url = urls.sdk + "/splitChanges?since=" + since + (till ? '&till=' + till : '') + (filterQueryString || '');
44
+ var url = urls.sdk + "/splitChanges?s=" + constants_1.FLAGS_SPEC + "&since=" + since + (till ? '&till=' + till : '') + (filterQueryString || '');
45
45
  return splitHttpClient(url, noCache ? noCacheHeaderOptions : undefined, telemetryTracker.trackHttp(constants_1.SPLITS))
46
46
  .catch(function (err) {
47
47
  if (err.statusCode === 414)
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getStorageHash = exports.KeyBuilder = exports.validatePrefix = void 0;
4
+ var constants_1 = require("../utils/constants");
4
5
  var lang_1 = require("../utils/lang");
5
6
  var murmur3_1 = require("../utils/murmur3/murmur3");
6
7
  var everythingAtTheEnd = /[^.]+$/;
@@ -66,10 +67,10 @@ var KeyBuilder = /** @class */ (function () {
66
67
  }());
67
68
  exports.KeyBuilder = KeyBuilder;
68
69
  /**
69
- * Generates a murmur32 hash based on the authorization key and the feature flags filter query.
70
+ * Generates a murmur32 hash based on the authorization key, the feature flags filter query, and version of SplitChanges API.
70
71
  * The hash is in hexadecimal format (8 characters max, 32 bits).
71
72
  */
72
73
  function getStorageHash(settings) {
73
- return (0, murmur3_1.hash)(settings.core.authorizationKey + "::" + settings.sync.__splitFiltersValidation.queryString).toString(16);
74
+ return (0, murmur3_1.hash)(settings.core.authorizationKey + "::" + settings.sync.__splitFiltersValidation.queryString + "::" + constants_1.FLAGS_SPEC).toString(16);
74
75
  }
75
76
  exports.getStorageHash = getStorageHash;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MY_SEGMENT = exports.SEGMENT = exports.TOKEN = exports.TELEMETRY = exports.EVENTS = exports.IMPRESSIONS_COUNT = exports.IMPRESSIONS = exports.SPLITS = exports.NONE_ENUM = exports.DEBUG_ENUM = exports.OPTIMIZED_ENUM = exports.CONSUMER_PARTIAL_ENUM = exports.CONSUMER_ENUM = exports.STANDALONE_ENUM = exports.DEDUPED = exports.DROPPED = exports.QUEUED = exports.NAMES_FN_LABEL = exports.SPLITS_FN_LABEL = exports.SPLIT_FN_LABEL = exports.TRACK_FN_LABEL = exports.GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SETS = exports.GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SET = exports.GET_TREATMENTS_BY_FLAG_SETS = exports.GET_TREATMENTS_BY_FLAG_SET = exports.GET_TREATMENTS_WITH_CONFIG = exports.GET_TREATMENT_WITH_CONFIG = exports.GET_TREATMENTS = exports.GET_TREATMENT = exports.CONSENT_UNKNOWN = exports.CONSENT_DECLINED = exports.CONSENT_GRANTED = exports.STORAGE_PLUGGABLE = exports.STORAGE_REDIS = exports.STORAGE_LOCALSTORAGE = exports.STORAGE_MEMORY = exports.CONSUMER_PARTIAL_MODE = exports.CONSUMER_MODE = exports.PRODUCER_MODE = exports.STANDALONE_MODE = exports.LOCALHOST_MODE = exports.NONE = exports.OPTIMIZED = exports.DEBUG = exports.SPLIT_EVENT = exports.SPLIT_IMPRESSION = exports.NA = exports.UNKNOWN = exports.CONTROL_WITH_CONFIG = exports.CONTROL = void 0;
4
- exports.PAUSED = exports.ENABLED = exports.DISABLED = exports.NON_REQUESTED = exports.REQUESTED = exports.POLLING = exports.STREAMING = exports.AUTH_REJECTION = exports.SYNC_MODE_UPDATE = exports.ABLY_ERROR = exports.TOKEN_REFRESH = exports.SSE_CONNECTION_ERROR = exports.STREAMING_STATUS = exports.OCCUPANCY_SEC = exports.OCCUPANCY_PRI = exports.CONNECTION_ESTABLISHED = exports.TRACK = exports.TREATMENTS_WITH_CONFIG_BY_FLAGSETS = exports.TREATMENTS_WITH_CONFIG_BY_FLAGSET = exports.TREATMENTS_BY_FLAGSETS = exports.TREATMENTS_BY_FLAGSET = exports.TREATMENTS_WITH_CONFIG = exports.TREATMENT_WITH_CONFIG = exports.TREATMENTS = exports.TREATMENT = void 0;
4
+ exports.FLAGS_SPEC = exports.PAUSED = exports.ENABLED = exports.DISABLED = exports.NON_REQUESTED = exports.REQUESTED = exports.POLLING = exports.STREAMING = exports.AUTH_REJECTION = exports.SYNC_MODE_UPDATE = exports.ABLY_ERROR = exports.TOKEN_REFRESH = exports.SSE_CONNECTION_ERROR = exports.STREAMING_STATUS = exports.OCCUPANCY_SEC = exports.OCCUPANCY_PRI = exports.CONNECTION_ESTABLISHED = exports.TRACK = exports.TREATMENTS_WITH_CONFIG_BY_FLAGSETS = exports.TREATMENTS_WITH_CONFIG_BY_FLAGSET = exports.TREATMENTS_BY_FLAGSETS = exports.TREATMENTS_BY_FLAGSET = exports.TREATMENTS_WITH_CONFIG = exports.TREATMENT_WITH_CONFIG = exports.TREATMENTS = exports.TREATMENT = void 0;
5
5
  // Special treatments
6
6
  exports.CONTROL = 'control';
7
7
  exports.CONTROL_WITH_CONFIG = {
@@ -90,3 +90,4 @@ exports.NON_REQUESTED = 1;
90
90
  exports.DISABLED = 0;
91
91
  exports.ENABLED = 1;
92
92
  exports.PAUSED = 2;
93
+ exports.FLAGS_SPEC = '1.1';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NOT_IN_SPLIT = exports.SPLIT_ARCHIVED = exports.EXCEPTION = exports.SDK_NOT_READY = exports.SPLIT_NOT_FOUND = exports.NO_CONDITION_MATCH = exports.SPLIT_KILLED = void 0;
3
+ exports.UNSUPPORTED_MATCHER_TYPE = exports.NOT_IN_SPLIT = exports.SPLIT_ARCHIVED = exports.EXCEPTION = exports.SDK_NOT_READY = exports.SPLIT_NOT_FOUND = exports.NO_CONDITION_MATCH = exports.SPLIT_KILLED = void 0;
4
4
  exports.SPLIT_KILLED = 'killed';
5
5
  exports.NO_CONDITION_MATCH = 'default rule';
6
6
  exports.SPLIT_NOT_FOUND = 'definition not found';
@@ -8,3 +8,4 @@ exports.SDK_NOT_READY = 'not ready';
8
8
  exports.EXCEPTION = 'exception';
9
9
  exports.SPLIT_ARCHIVED = 'archived';
10
10
  exports.NOT_IN_SPLIT = 'not in split';
11
+ exports.UNSUPPORTED_MATCHER_TYPE = 'unsupported matcher type';
@@ -57,7 +57,7 @@ exports.base = {
57
57
  // Telemetry Server
58
58
  telemetry: 'https://telemetry.split.io/api',
59
59
  },
60
- // Defines which kind of storage we should instanciate.
60
+ // Defines which kind of storage we should instantiate.
61
61
  storage: undefined,
62
62
  // Defines if the logs are enabled, SDK wide.
63
63
  debug: undefined,
@@ -8,7 +8,7 @@ export function ifElseIfCombinerContext(log, predicates) {
8
8
  log.error(ERROR_ENGINE_COMBINER_IFELSEIF);
9
9
  return {
10
10
  treatment: CONTROL,
11
- label: LabelsConstants.EXCEPTION
11
+ label: LabelsConstants.UNSUPPORTED_MATCHER_TYPE
12
12
  };
13
13
  }
14
14
  function computeTreatment(predicateResults) {
@@ -35,7 +35,7 @@ export function ifElseIfCombinerContext(log, predicates) {
35
35
  return computeTreatment(predicateResults);
36
36
  }
37
37
  // if there is none predicates, then there was an error in parsing phase
38
- if (!Array.isArray(predicates) || Array.isArray(predicates) && predicates.length === 0) {
38
+ if (!Array.isArray(predicates) || predicates.length === 0) {
39
39
  return unexpectedInputHandler;
40
40
  }
41
41
  else {
@@ -27,8 +27,7 @@ export function parser(log, conditions, storage) {
27
27
  return Boolean(result ^ matcherDto.negate);
28
28
  };
29
29
  });
30
- // if matcher's factory can't instanciate the matchers, the expressions array
31
- // will be empty
30
+ // if matcher's factory can't instantiate the matchers, the expressions array will be empty
32
31
  if (expressions.length === 0) {
33
32
  // reset any data collected during parsing
34
33
  predicates = [];
@@ -1,7 +1,7 @@
1
1
  import * as c from '../constants';
2
2
  export var codesError = [
3
3
  // evaluator
4
- [c.ERROR_ENGINE_COMBINER_IFELSEIF, c.LOG_PREFIX_ENGINE_COMBINER + 'Invalid feature flag, no valid rules found'],
4
+ [c.ERROR_ENGINE_COMBINER_IFELSEIF, c.LOG_PREFIX_ENGINE_COMBINER + 'Invalid feature flag, no valid rules or unsupported matcher type found'],
5
5
  // SDK
6
6
  [c.ERROR_LOGLEVEL_INVALID, 'logger: Invalid Log Level - No changes to the logs will be applied.'],
7
7
  [c.ERROR_CLIENT_CANNOT_GET_READY, 'The SDK will not get ready. Reason: %s'],
@@ -1,6 +1,6 @@
1
1
  import { splitHttpClientFactory } from './splitHttpClient';
2
2
  import { objectAssign } from '../utils/lang/objectAssign';
3
- import { SPLITS, IMPRESSIONS, IMPRESSIONS_COUNT, EVENTS, TELEMETRY, TOKEN, SEGMENT, MY_SEGMENT } from '../utils/constants';
3
+ import { SPLITS, IMPRESSIONS, IMPRESSIONS_COUNT, EVENTS, TELEMETRY, TOKEN, SEGMENT, MY_SEGMENT, FLAGS_SPEC } from '../utils/constants';
4
4
  import { ERROR_TOO_MANY_SETS } from '../logger/constants';
5
5
  var noCacheHeaderOptions = { headers: { 'Cache-Control': 'no-cache' } };
6
6
  function userKeyToQueryParam(userKey) {
@@ -38,7 +38,7 @@ export function splitApiFactory(settings, platform, telemetryTracker) {
38
38
  return splitHttpClient(url, undefined, telemetryTracker.trackHttp(TOKEN));
39
39
  },
40
40
  fetchSplitChanges: function (since, noCache, till) {
41
- var url = urls.sdk + "/splitChanges?since=" + since + (till ? '&till=' + till : '') + (filterQueryString || '');
41
+ var url = urls.sdk + "/splitChanges?s=" + FLAGS_SPEC + "&since=" + since + (till ? '&till=' + till : '') + (filterQueryString || '');
42
42
  return splitHttpClient(url, noCache ? noCacheHeaderOptions : undefined, telemetryTracker.trackHttp(SPLITS))
43
43
  .catch(function (err) {
44
44
  if (err.statusCode === 414)
@@ -1,3 +1,4 @@
1
+ import { FLAGS_SPEC } from '../utils/constants';
1
2
  import { startsWith } from '../utils/lang';
2
3
  import { hash } from '../utils/murmur3/murmur3';
3
4
  var everythingAtTheEnd = /[^.]+$/;
@@ -62,9 +63,9 @@ var KeyBuilder = /** @class */ (function () {
62
63
  }());
63
64
  export { KeyBuilder };
64
65
  /**
65
- * Generates a murmur32 hash based on the authorization key and the feature flags filter query.
66
+ * Generates a murmur32 hash based on the authorization key, the feature flags filter query, and version of SplitChanges API.
66
67
  * The hash is in hexadecimal format (8 characters max, 32 bits).
67
68
  */
68
69
  export function getStorageHash(settings) {
69
- return hash(settings.core.authorizationKey + "::" + settings.sync.__splitFiltersValidation.queryString).toString(16);
70
+ return hash(settings.core.authorizationKey + "::" + settings.sync.__splitFiltersValidation.queryString + "::" + FLAGS_SPEC).toString(16);
70
71
  }
@@ -86,3 +86,4 @@ export var NON_REQUESTED = 1;
86
86
  export var DISABLED = 0;
87
87
  export var ENABLED = 1;
88
88
  export var PAUSED = 2;
89
+ export var FLAGS_SPEC = '1.1';
@@ -5,3 +5,4 @@ export var SDK_NOT_READY = 'not ready';
5
5
  export var EXCEPTION = 'exception';
6
6
  export var SPLIT_ARCHIVED = 'archived';
7
7
  export var NOT_IN_SPLIT = 'not in split';
8
+ export var UNSUPPORTED_MATCHER_TYPE = 'unsupported matcher type';
@@ -54,7 +54,7 @@ export var base = {
54
54
  // Telemetry Server
55
55
  telemetry: 'https://telemetry.split.io/api',
56
56
  },
57
- // Defines which kind of storage we should instanciate.
57
+ // Defines which kind of storage we should instantiate.
58
58
  storage: undefined,
59
59
  // Defines if the logs are enabled, SDK wide.
60
60
  debug: undefined,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@splitsoftware/splitio-commons",
3
- "version": "1.13.1",
4
- "description": "Split Javascript SDK common components",
3
+ "version": "1.13.2-rc.1",
4
+ "description": "Split JavaScript SDK common components",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
7
7
  "types": "types",
@@ -14,7 +14,7 @@ export function ifElseIfCombinerContext(log: ILogger, predicates: IEvaluator[]):
14
14
 
15
15
  return {
16
16
  treatment: CONTROL,
17
- label: LabelsConstants.EXCEPTION
17
+ label: LabelsConstants.UNSUPPORTED_MATCHER_TYPE
18
18
  };
19
19
  }
20
20
 
@@ -50,7 +50,7 @@ export function ifElseIfCombinerContext(log: ILogger, predicates: IEvaluator[]):
50
50
  }
51
51
 
52
52
  // if there is none predicates, then there was an error in parsing phase
53
- if (!Array.isArray(predicates) || Array.isArray(predicates) && predicates.length === 0) {
53
+ if (!Array.isArray(predicates) || predicates.length === 0) {
54
54
  return unexpectedInputHandler;
55
55
  } else {
56
56
  return ifElseIfCombiner;
@@ -1,5 +1,5 @@
1
1
  export const matcherTypes: Record<string, number> = {
2
- UNDEFINED: 0,
2
+ UNDEFINED: 0, // Value for unsupported or invalid matchers
3
3
  ALL_KEYS: 1,
4
4
  IN_SEGMENT: 2,
5
5
  WHITELIST: 3,
@@ -44,8 +44,7 @@ export function parser(log: ILogger, conditions: ISplitCondition[], storage: ISt
44
44
  };
45
45
  });
46
46
 
47
- // if matcher's factory can't instanciate the matchers, the expressions array
48
- // will be empty
47
+ // if matcher's factory can't instantiate the matchers, the expressions array will be empty
49
48
  if (expressions.length === 0) {
50
49
  // reset any data collected during parsing
51
50
  predicates = [];
@@ -2,7 +2,7 @@ import * as c from '../constants';
2
2
 
3
3
  export const codesError: [number, string][] = [
4
4
  // evaluator
5
- [c.ERROR_ENGINE_COMBINER_IFELSEIF, c.LOG_PREFIX_ENGINE_COMBINER + 'Invalid feature flag, no valid rules found'],
5
+ [c.ERROR_ENGINE_COMBINER_IFELSEIF, c.LOG_PREFIX_ENGINE_COMBINER + 'Invalid feature flag, no valid rules or unsupported matcher type found'],
6
6
  // SDK
7
7
  [c.ERROR_LOGLEVEL_INVALID, 'logger: Invalid Log Level - No changes to the logs will be applied.'],
8
8
  [c.ERROR_CLIENT_CANNOT_GET_READY, 'The SDK will not get ready. Reason: %s'],
@@ -4,7 +4,7 @@ import { splitHttpClientFactory } from './splitHttpClient';
4
4
  import { ISplitApi } from './types';
5
5
  import { objectAssign } from '../utils/lang/objectAssign';
6
6
  import { ITelemetryTracker } from '../trackers/types';
7
- import { SPLITS, IMPRESSIONS, IMPRESSIONS_COUNT, EVENTS, TELEMETRY, TOKEN, SEGMENT, MY_SEGMENT } from '../utils/constants';
7
+ import { SPLITS, IMPRESSIONS, IMPRESSIONS_COUNT, EVENTS, TELEMETRY, TOKEN, SEGMENT, MY_SEGMENT, FLAGS_SPEC } from '../utils/constants';
8
8
  import { ERROR_TOO_MANY_SETS } from '../logger/constants';
9
9
 
10
10
  const noCacheHeaderOptions = { headers: { 'Cache-Control': 'no-cache' } };
@@ -54,7 +54,7 @@ export function splitApiFactory(
54
54
  },
55
55
 
56
56
  fetchSplitChanges(since: number, noCache?: boolean, till?: number) {
57
- const url = `${urls.sdk}/splitChanges?since=${since}${till ? '&till=' + till : ''}${filterQueryString || ''}`;
57
+ const url = `${urls.sdk}/splitChanges?s=${FLAGS_SPEC}&since=${since}${till ? '&till=' + till : ''}${filterQueryString || ''}`;
58
58
  return splitHttpClient(url, noCache ? noCacheHeaderOptions : undefined, telemetryTracker.trackHttp(SPLITS))
59
59
  .catch((err) => {
60
60
  if (err.statusCode === 414) settings.log.error(ERROR_TOO_MANY_SETS);
@@ -1,4 +1,5 @@
1
1
  import { ISettings } from '../types';
2
+ import { FLAGS_SPEC } from '../utils/constants';
2
3
  import { startsWith } from '../utils/lang';
3
4
  import { hash } from '../utils/murmur3/murmur3';
4
5
 
@@ -81,9 +82,9 @@ export class KeyBuilder {
81
82
  }
82
83
 
83
84
  /**
84
- * Generates a murmur32 hash based on the authorization key and the feature flags filter query.
85
+ * Generates a murmur32 hash based on the authorization key, the feature flags filter query, and version of SplitChanges API.
85
86
  * The hash is in hexadecimal format (8 characters max, 32 bits).
86
87
  */
87
88
  export function getStorageHash(settings: ISettings) {
88
- return hash(`${settings.core.authorizationKey}::${settings.sync.__splitFiltersValidation.queryString}`).toString(16);
89
+ return hash(`${settings.core.authorizationKey}::${settings.sync.__splitFiltersValidation.queryString}::${FLAGS_SPEC}`).toString(16);
89
90
  }
package/src/types.ts CHANGED
@@ -353,7 +353,7 @@ interface INodeBasicSettings extends ISharedSettings {
353
353
  IPAddressesEnabled?: boolean
354
354
  },
355
355
  /**
356
- * Defines which kind of storage we should instanciate.
356
+ * Defines which kind of storage we should instantiate.
357
357
  * @property {Object} storage
358
358
  */
359
359
  storage?: (params: any) => any,
@@ -918,7 +918,7 @@ export namespace SplitIO {
918
918
  */
919
919
  features?: MockedFeaturesMap,
920
920
  /**
921
- * Defines which kind of storage we should instanciate.
921
+ * Defines which kind of storage we should instantiate.
922
922
  * @property {Object} storage
923
923
  */
924
924
  storage?: (params: IStorageFactoryParams) => IStorageSync | IStorageAsync,
@@ -944,7 +944,7 @@ export namespace SplitIO {
944
944
  */
945
945
  urls?: UrlSettings,
946
946
  /**
947
- * Defines which kind of storage we should instanciate.
947
+ * Defines which kind of storage we should instantiate.
948
948
  * @property {Object} storage
949
949
  */
950
950
  storage?: (params: IStorageFactoryParams) => IStorageSync,
@@ -104,3 +104,5 @@ export const NON_REQUESTED = 1;
104
104
  export const DISABLED = 0;
105
105
  export const ENABLED = 1;
106
106
  export const PAUSED = 2;
107
+
108
+ export const FLAGS_SPEC = '1.1';
@@ -5,3 +5,4 @@ export const SDK_NOT_READY = 'not ready';
5
5
  export const EXCEPTION = 'exception';
6
6
  export const SPLIT_ARCHIVED = 'archived';
7
7
  export const NOT_IN_SPLIT = 'not in split';
8
+ export const UNSUPPORTED_MATCHER_TYPE = 'unsupported matcher type';
@@ -61,7 +61,7 @@ export const base = {
61
61
  telemetry: 'https://telemetry.split.io/api',
62
62
  },
63
63
 
64
- // Defines which kind of storage we should instanciate.
64
+ // Defines which kind of storage we should instantiate.
65
65
  storage: undefined,
66
66
 
67
67
  // Defines if the logs are enabled, SDK wide.
@@ -16,7 +16,7 @@ export declare class KeyBuilder {
16
16
  buildHashKey(): string;
17
17
  }
18
18
  /**
19
- * Generates a murmur32 hash based on the authorization key and the feature flags filter query.
19
+ * Generates a murmur32 hash based on the authorization key, the feature flags filter query, and version of SplitChanges API.
20
20
  * The hash is in hexadecimal format (8 characters max, 32 bits).
21
21
  */
22
22
  export declare function getStorageHash(settings: ISettings): string;
package/types/types.d.ts CHANGED
@@ -347,7 +347,7 @@ interface INodeBasicSettings extends ISharedSettings {
347
347
  IPAddressesEnabled?: boolean;
348
348
  };
349
349
  /**
350
- * Defines which kind of storage we should instanciate.
350
+ * Defines which kind of storage we should instantiate.
351
351
  * @property {Object} storage
352
352
  */
353
353
  storage?: (params: any) => any;
@@ -915,7 +915,7 @@ export declare namespace SplitIO {
915
915
  */
916
916
  features?: MockedFeaturesMap;
917
917
  /**
918
- * Defines which kind of storage we should instanciate.
918
+ * Defines which kind of storage we should instantiate.
919
919
  * @property {Object} storage
920
920
  */
921
921
  storage?: (params: IStorageFactoryParams) => IStorageSync | IStorageAsync;
@@ -941,7 +941,7 @@ export declare namespace SplitIO {
941
941
  */
942
942
  urls?: UrlSettings;
943
943
  /**
944
- * Defines which kind of storage we should instanciate.
944
+ * Defines which kind of storage we should instantiate.
945
945
  * @property {Object} storage
946
946
  */
947
947
  storage?: (params: IStorageFactoryParams) => IStorageSync;
@@ -78,3 +78,4 @@ export declare const NON_REQUESTED = 1;
78
78
  export declare const DISABLED = 0;
79
79
  export declare const ENABLED = 1;
80
80
  export declare const PAUSED = 2;
81
+ export declare const FLAGS_SPEC = "1.1";
@@ -5,3 +5,4 @@ export declare const SDK_NOT_READY = "not ready";
5
5
  export declare const EXCEPTION = "exception";
6
6
  export declare const SPLIT_ARCHIVED = "archived";
7
7
  export declare const NOT_IN_SPLIT = "not in split";
8
+ export declare const UNSUPPORTED_MATCHER_TYPE = "unsupported matcher type";
@@ -0,0 +1,8 @@
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;