@splitsoftware/splitio-commons 1.2.1-rc.10 → 1.2.1-rc.11

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.
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  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.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_WHITELIST = exports.ENGINE_MATCHER_STARTS_WITH = exports.ENGINE_MATCHER_STRING_INVALID = exports.ENGINE_MATCHER_STRING = exports.ENGINE_MATCHER_SEGMENT = exports.ENGINE_MATCHER_PART_OF = exports.ENGINE_MATCHER_LESS = exports.ENGINE_MATCHER_GREATER = exports.ENGINE_MATCHER_ENDS_WITH = exports.ENGINE_MATCHER_EQUAL_TO_SET = exports.ENGINE_MATCHER_EQUAL = exports.ENGINE_MATCHER_DEPENDENCY_PRE = exports.ENGINE_MATCHER_DEPENDENCY = exports.ENGINE_MATCHER_CONTAINS_STRING = exports.ENGINE_MATCHER_CONTAINS_ANY = exports.ENGINE_MATCHER_CONTAINS_ALL = exports.ENGINE_MATCHER_BOOLEAN = exports.ENGINE_MATCHER_BETWEEN = exports.ENGINE_MATCHER_ALL = exports.ENGINE_BUCKET = exports.ENGINE_COMBINER_IFELSEIF_NO_TREATMENT = exports.ENGINE_COMBINER_IFELSEIF = exports.ENGINE_COMBINER_AND = void 0;
4
- 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.STREAMING_PARSING_MY_SEGMENTS_UPDATE_V2 = exports.WARN_API_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 = exports.ENGINE_VALUE_INVALID = 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 = void 0;
5
- exports.LOG_PREFIX_CLEANUP = 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_INSTANTIATION = exports.LOG_PREFIX_SETTINGS = exports.ERROR_NOT_BOOLEAN = exports.ERROR_STORAGE_INVALID = exports.ERROR_LOCALHOST_MODULE_REQUIRED = exports.ERROR_HTTP = 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 = void 0;
4
+ 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.STREAMING_PARSING_MY_SEGMENTS_UPDATE_V2 = exports.WARN_API_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 = 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 = void 0;
5
+ exports.LOG_PREFIX_CLEANUP = 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_INSTANTIATION = exports.LOG_PREFIX_SETTINGS = exports.ERROR_NOT_BOOLEAN = exports.ERROR_STORAGE_INVALID = exports.ERROR_LOCALHOST_MODULE_REQUIRED = exports.ERROR_HTTP = 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 = 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.
@@ -74,6 +74,7 @@ exports.EVENTS_TRACKER_SUCCESS = 120;
74
74
  exports.IMPRESSIONS_TRACKER_SUCCESS = 121;
75
75
  exports.USER_CONSENT_UPDATED = 122;
76
76
  exports.USER_CONSENT_NOT_UPDATED = 123;
77
+ exports.USER_CONSENT_INITIAL = 124;
77
78
  exports.ENGINE_VALUE_INVALID = 200;
78
79
  exports.ENGINE_VALUE_NO_ATTRIBUTES = 201;
79
80
  exports.CLIENT_NO_LISTENER = 202;
@@ -18,6 +18,7 @@ exports.codesInfo = warn_1.codesWarn.concat([
18
18
  [c.IMPRESSIONS_TRACKER_SUCCESS, c.LOG_PREFIX_IMPRESSIONS_TRACKER + 'Successfully stored %s impression(s).'],
19
19
  [c.USER_CONSENT_UPDATED, 'setUserConsent: consent status changed from %s to %s.'],
20
20
  [c.USER_CONSENT_NOT_UPDATED, 'setUserConsent: call had no effect because it was the current consent status (%s).'],
21
+ [c.USER_CONSENT_INITIAL, 'Starting the SDK with %s user consent. No data will be sent.'],
21
22
  // synchronizer
22
23
  [c.POLLING_SMART_PAUSING, c.LOG_PREFIX_SYNC_POLLING + 'Turning segments data polling %s.'],
23
24
  [c.POLLING_START, c.LOG_PREFIX_SYNC_POLLING + 'Starting polling'],
@@ -2,11 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.userConsentProps = void 0;
4
4
  var constants_1 = require("../logger/constants");
5
+ var consent_1 = require("../utils/consent");
5
6
  var constants_2 = require("../utils/constants");
6
7
  var lang_1 = require("../utils/lang");
7
8
  // Extend client-side factory instances with user consent getter/setter
8
9
  function userConsentProps(settings, syncManager) {
9
10
  var log = settings.log;
11
+ if (!(0, consent_1.isConsentGranted)(settings))
12
+ log.info(constants_1.USER_CONSENT_INITIAL, [settings.userConsent]);
10
13
  return {
11
14
  setUserConsent: function (consent) {
12
15
  var _a, _b;
@@ -16,13 +19,13 @@ function userConsentProps(settings, syncManager) {
16
19
  return false;
17
20
  }
18
21
  var newConsentStatus = consent ? constants_2.CONSENT_GRANTED : constants_2.CONSENT_DECLINED;
19
- if (settings.userConsent !== newConsentStatus) { // @ts-ignore, modify readonly prop
22
+ if (settings.userConsent !== newConsentStatus) {
23
+ log.info(constants_1.USER_CONSENT_UPDATED, [settings.userConsent, newConsentStatus]); // @ts-ignore, modify readonly prop
20
24
  settings.userConsent = newConsentStatus;
21
25
  if (consent)
22
26
  (_a = syncManager === null || syncManager === void 0 ? void 0 : syncManager.submitter) === null || _a === void 0 ? void 0 : _a.start(); // resumes submitters if transitioning to GRANTED
23
27
  else
24
28
  (_b = syncManager === null || syncManager === void 0 ? void 0 : syncManager.submitter) === null || _b === void 0 ? void 0 : _b.stop(); // pauses submitters if transitioning to DECLINED
25
- log.info(constants_1.USER_CONSENT_UPDATED, [settings.userConsent, newConsentStatus]);
26
29
  }
27
30
  else {
28
31
  log.info(constants_1.USER_CONSENT_NOT_UPDATED, [newConsentStatus]);
@@ -69,6 +69,7 @@ export var EVENTS_TRACKER_SUCCESS = 120;
69
69
  export var IMPRESSIONS_TRACKER_SUCCESS = 121;
70
70
  export var USER_CONSENT_UPDATED = 122;
71
71
  export var USER_CONSENT_NOT_UPDATED = 123;
72
+ export var USER_CONSENT_INITIAL = 124;
72
73
  export var ENGINE_VALUE_INVALID = 200;
73
74
  export var ENGINE_VALUE_NO_ATTRIBUTES = 201;
74
75
  export var CLIENT_NO_LISTENER = 202;
@@ -14,6 +14,7 @@ export var codesInfo = codesWarn.concat([
14
14
  [c.IMPRESSIONS_TRACKER_SUCCESS, c.LOG_PREFIX_IMPRESSIONS_TRACKER + 'Successfully stored %s impression(s).'],
15
15
  [c.USER_CONSENT_UPDATED, 'setUserConsent: consent status changed from %s to %s.'],
16
16
  [c.USER_CONSENT_NOT_UPDATED, 'setUserConsent: call had no effect because it was the current consent status (%s).'],
17
+ [c.USER_CONSENT_INITIAL, 'Starting the SDK with %s user consent. No data will be sent.'],
17
18
  // synchronizer
18
19
  [c.POLLING_SMART_PAUSING, c.LOG_PREFIX_SYNC_POLLING + 'Turning segments data polling %s.'],
19
20
  [c.POLLING_START, c.LOG_PREFIX_SYNC_POLLING + 'Starting polling'],
@@ -1,9 +1,12 @@
1
- import { ERROR_NOT_BOOLEAN, USER_CONSENT_UPDATED, USER_CONSENT_NOT_UPDATED } from '../logger/constants';
1
+ import { ERROR_NOT_BOOLEAN, USER_CONSENT_UPDATED, USER_CONSENT_NOT_UPDATED, USER_CONSENT_INITIAL } from '../logger/constants';
2
+ import { isConsentGranted } from '../utils/consent';
2
3
  import { CONSENT_GRANTED, CONSENT_DECLINED } from '../utils/constants';
3
4
  import { isBoolean } from '../utils/lang';
4
5
  // Extend client-side factory instances with user consent getter/setter
5
6
  export function userConsentProps(settings, syncManager) {
6
7
  var log = settings.log;
8
+ if (!isConsentGranted(settings))
9
+ log.info(USER_CONSENT_INITIAL, [settings.userConsent]);
7
10
  return {
8
11
  setUserConsent: function (consent) {
9
12
  var _a, _b;
@@ -13,13 +16,13 @@ export function userConsentProps(settings, syncManager) {
13
16
  return false;
14
17
  }
15
18
  var newConsentStatus = consent ? CONSENT_GRANTED : CONSENT_DECLINED;
16
- if (settings.userConsent !== newConsentStatus) { // @ts-ignore, modify readonly prop
19
+ if (settings.userConsent !== newConsentStatus) {
20
+ log.info(USER_CONSENT_UPDATED, [settings.userConsent, newConsentStatus]); // @ts-ignore, modify readonly prop
17
21
  settings.userConsent = newConsentStatus;
18
22
  if (consent)
19
23
  (_a = syncManager === null || syncManager === void 0 ? void 0 : syncManager.submitter) === null || _a === void 0 ? void 0 : _a.start(); // resumes submitters if transitioning to GRANTED
20
24
  else
21
25
  (_b = syncManager === null || syncManager === void 0 ? void 0 : syncManager.submitter) === null || _b === void 0 ? void 0 : _b.stop(); // pauses submitters if transitioning to DECLINED
22
- log.info(USER_CONSENT_UPDATED, [settings.userConsent, newConsentStatus]);
23
26
  }
24
27
  else {
25
28
  log.info(USER_CONSENT_NOT_UPDATED, [newConsentStatus]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splitsoftware/splitio-commons",
3
- "version": "1.2.1-rc.10",
3
+ "version": "1.2.1-rc.11",
4
4
  "description": "Split Javascript SDK common components",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -70,6 +70,7 @@ export const EVENTS_TRACKER_SUCCESS = 120;
70
70
  export const IMPRESSIONS_TRACKER_SUCCESS = 121;
71
71
  export const USER_CONSENT_UPDATED = 122;
72
72
  export const USER_CONSENT_NOT_UPDATED = 123;
73
+ export const USER_CONSENT_INITIAL = 124;
73
74
 
74
75
  export const ENGINE_VALUE_INVALID = 200;
75
76
  export const ENGINE_VALUE_NO_ATTRIBUTES = 201;
@@ -16,6 +16,7 @@ export const codesInfo: [number, string][] = codesWarn.concat([
16
16
  [c.IMPRESSIONS_TRACKER_SUCCESS, c.LOG_PREFIX_IMPRESSIONS_TRACKER + 'Successfully stored %s impression(s).'],
17
17
  [c.USER_CONSENT_UPDATED, 'setUserConsent: consent status changed from %s to %s.'],
18
18
  [c.USER_CONSENT_NOT_UPDATED, 'setUserConsent: call had no effect because it was the current consent status (%s).'],
19
+ [c.USER_CONSENT_INITIAL, 'Starting the SDK with %s user consent. No data will be sent.'],
19
20
 
20
21
  // synchronizer
21
22
  [c.POLLING_SMART_PAUSING, c.LOG_PREFIX_SYNC_POLLING + 'Turning segments data polling %s.'],
@@ -1,6 +1,7 @@
1
- import { ERROR_NOT_BOOLEAN, USER_CONSENT_UPDATED, USER_CONSENT_NOT_UPDATED } from '../logger/constants';
1
+ import { ERROR_NOT_BOOLEAN, USER_CONSENT_UPDATED, USER_CONSENT_NOT_UPDATED, USER_CONSENT_INITIAL } from '../logger/constants';
2
2
  import { ISyncManager } from '../sync/types';
3
3
  import { ISettings } from '../types';
4
+ import { isConsentGranted } from '../utils/consent';
4
5
  import { CONSENT_GRANTED, CONSENT_DECLINED } from '../utils/constants';
5
6
  import { isBoolean } from '../utils/lang';
6
7
 
@@ -9,6 +10,8 @@ export function userConsentProps(settings: ISettings, syncManager?: ISyncManager
9
10
 
10
11
  const log = settings.log;
11
12
 
13
+ if (!isConsentGranted(settings)) log.info(USER_CONSENT_INITIAL, [settings.userConsent]);
14
+
12
15
  return {
13
16
  setUserConsent(consent: unknown) {
14
17
  // validate input param
@@ -19,13 +22,12 @@ export function userConsentProps(settings: ISettings, syncManager?: ISyncManager
19
22
 
20
23
  const newConsentStatus = consent ? CONSENT_GRANTED : CONSENT_DECLINED;
21
24
 
22
- if (settings.userConsent !== newConsentStatus) { // @ts-ignore, modify readonly prop
25
+ if (settings.userConsent !== newConsentStatus) {
26
+ log.info(USER_CONSENT_UPDATED, [settings.userConsent, newConsentStatus]); // @ts-ignore, modify readonly prop
23
27
  settings.userConsent = newConsentStatus;
24
28
 
25
29
  if (consent) syncManager?.submitter?.start(); // resumes submitters if transitioning to GRANTED
26
30
  else syncManager?.submitter?.stop(); // pauses submitters if transitioning to DECLINED
27
-
28
- log.info(USER_CONSENT_UPDATED, [settings.userConsent, newConsentStatus]);
29
31
  } else {
30
32
  log.info(USER_CONSENT_NOT_UPDATED, [newConsentStatus]);
31
33
  }
@@ -69,6 +69,7 @@ export declare const EVENTS_TRACKER_SUCCESS = 120;
69
69
  export declare const IMPRESSIONS_TRACKER_SUCCESS = 121;
70
70
  export declare const USER_CONSENT_UPDATED = 122;
71
71
  export declare const USER_CONSENT_NOT_UPDATED = 123;
72
+ export declare const USER_CONSENT_INITIAL = 124;
72
73
  export declare const ENGINE_VALUE_INVALID = 200;
73
74
  export declare const ENGINE_VALUE_NO_ATTRIBUTES = 201;
74
75
  export declare const CLIENT_NO_LISTENER = 202;