@splitsoftware/splitio-browserjs 0.7.0 → 0.8.1-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGES.txt CHANGED
@@ -1,8 +1,14 @@
1
+ 0.8.0 (July 22, 2022)
2
+ - Added `autoRequire` configuration option to the Google Analytics to Split integration, which takes care of requiring the splitTracker plugin on trackers dynamically created by Google tag managers (See https://help.split.io/hc/en-us/articles/360040838752#set-up-with-gtm-and-gtag.js).
3
+ - Updated browser listener to push remaining impressions and events on 'visibilitychange' and 'pagehide' DOM events, instead of 'unload', which is not reliable in modern mobile and desktop Web browsers.
4
+ - Updated the synchronization flow to be more reliable in the event of an edge case generating delay in cache purge propagation, keeping the SDK cache properly synced.
5
+ - Updated some dependencies for vulnerability fixes.
6
+
1
7
  0.7.0 (June 29, 2022)
2
8
  - Added a new config option to control the tasks that listen or poll for updates on feature flags and segments, via the new config sync.enabled . Running online Split will always pull the most recent updates upon initialization, this only affects updates fetching on a running instance. Useful when a consistent session experience is a must or to save resources when updates are not being used.
3
9
  - Updated telemetry logic to track the anonymous config for user consent flag set to declined or unknown.
4
10
  - Updated submitters logic, to avoid duplicating the post of impressions to Split cloud when the SDK is destroyed while its periodic post of impressions is running.
5
-
11
+ - Bugfixing - Updated submitters logic, to avoid dropping impressions and events that are being tracked while POST request is pending.
6
12
 
7
13
  0.6.0 (May 24, 2022)
8
14
  - Added `scheduler.telemetryRefreshRate` property to SDK configuration.
@@ -19,7 +19,7 @@ var platform = { getFetch: getFetchFull_1.getFetch, getEventSource: getEventSour
19
19
  * @throws Will throw an error if the provided config is invalid.
20
20
  */
21
21
  function SplitFactory(config, __updateModules) {
22
- var settings = (0, full_1.settingsValidator)(config);
22
+ var settings = (0, full_1.settingsFactory)(config);
23
23
  var modules = (0, getModules_1.getModules)(settings, platform);
24
24
  if (__updateModules)
25
25
  __updateModules(modules);
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.defaults = void 0;
4
4
  var index_1 = require("@splitsoftware/splitio-commons/cjs/logger/index");
5
5
  var constants_1 = require("@splitsoftware/splitio-commons/cjs/utils/constants");
6
- var packageVersion = '0.7.0';
6
+ var packageVersion = '0.8.1-rc.0';
7
7
  /**
8
8
  * In browser, the default debug level, can be set via the `localStorage.splitio_debug` item.
9
9
  * Acceptable values are: 'DEBUG', 'INFO', 'WARN', 'ERROR', 'NONE'.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.settingsValidator = void 0;
3
+ exports.settingsFactory = void 0;
4
4
  var index_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/index");
5
5
  var defaults_1 = require("./defaults");
6
6
  var runtime_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/runtime");
@@ -19,7 +19,7 @@ var params = {
19
19
  localhost: builtin_1.validateLocalhostWithDefault,
20
20
  consent: consent_1.validateConsent,
21
21
  };
22
- function settingsValidator(config) {
22
+ function settingsFactory(config) {
23
23
  return (0, index_1.settingsValidation)(config, params);
24
24
  }
25
- exports.settingsValidator = settingsValidator;
25
+ exports.settingsFactory = settingsFactory;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.settingsValidator = void 0;
3
+ exports.settingsFactory = void 0;
4
4
  var index_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/index");
5
5
  var defaults_1 = require("./defaults");
6
6
  var runtime_1 = require("@splitsoftware/splitio-commons/cjs/utils/settingsValidation/runtime");
@@ -19,7 +19,7 @@ var params = {
19
19
  localhost: pluggable_2.validateLocalhost,
20
20
  consent: consent_1.validateConsent,
21
21
  };
22
- function settingsValidator(config) {
22
+ function settingsFactory(config) {
23
23
  return (0, index_1.settingsValidation)(config, params);
24
24
  }
25
- exports.settingsValidator = settingsValidator;
25
+ exports.settingsFactory = settingsFactory;
@@ -19,7 +19,7 @@ var platform = { getFetch: getFetchSlim_1.getFetch, getEventSource: getEventSour
19
19
  * @throws Will throw an error if the provided config is invalid.
20
20
  */
21
21
  function SplitFactory(config, __updateModules) {
22
- var settings = (0, settings_1.settingsValidator)(config);
22
+ var settings = (0, settings_1.settingsFactory)(config);
23
23
  var modules = (0, getModules_1.getModules)(settings, platform);
24
24
  if (__updateModules)
25
25
  __updateModules(modules);
@@ -1,4 +1,4 @@
1
- import { settingsValidator } from '../settings/full';
1
+ import { settingsFactory } from '../settings/full';
2
2
  import { getModules } from '../platform/getModules';
3
3
  import { sdkFactory } from '@splitsoftware/splitio-commons/esm/sdkFactory/index';
4
4
  import { getFetch } from '../platform/getFetchFull';
@@ -16,7 +16,7 @@ var platform = { getFetch: getFetch, getEventSource: getEventSource, EventEmitte
16
16
  * @throws Will throw an error if the provided config is invalid.
17
17
  */
18
18
  export function SplitFactory(config, __updateModules) {
19
- var settings = settingsValidator(config);
19
+ var settings = settingsFactory(config);
20
20
  var modules = getModules(settings, platform);
21
21
  if (__updateModules)
22
22
  __updateModules(modules);
@@ -1,6 +1,6 @@
1
1
  import { LogLevels, isLogLevelString } from '@splitsoftware/splitio-commons/esm/logger/index';
2
2
  import { CONSENT_GRANTED } from '@splitsoftware/splitio-commons/esm/utils/constants';
3
- var packageVersion = '0.7.0';
3
+ var packageVersion = '0.8.1-rc.0';
4
4
  /**
5
5
  * In browser, the default debug level, can be set via the `localStorage.splitio_debug` item.
6
6
  * Acceptable values are: 'DEBUG', 'INFO', 'WARN', 'ERROR', 'NONE'.
@@ -16,6 +16,6 @@ var params = {
16
16
  localhost: validateLocalhostWithDefault,
17
17
  consent: validateConsent,
18
18
  };
19
- export function settingsValidator(config) {
19
+ export function settingsFactory(config) {
20
20
  return settingsValidation(config, params);
21
21
  }
@@ -16,6 +16,6 @@ var params = {
16
16
  localhost: validateLocalhost,
17
17
  consent: validateConsent,
18
18
  };
19
- export function settingsValidator(config) {
19
+ export function settingsFactory(config) {
20
20
  return settingsValidation(config, params);
21
21
  }
@@ -1,4 +1,4 @@
1
- import { settingsValidator } from './settings';
1
+ import { settingsFactory } from './settings';
2
2
  import { getModules } from './platform/getModules';
3
3
  import { sdkFactory } from '@splitsoftware/splitio-commons/esm/sdkFactory/index';
4
4
  import { getFetch } from './platform/getFetchSlim';
@@ -16,7 +16,7 @@ var platform = { getFetch: getFetch, getEventSource: getEventSource, EventEmitte
16
16
  * @throws Will throw an error if the provided config is invalid.
17
17
  */
18
18
  export function SplitFactory(config, __updateModules) {
19
- var settings = settingsValidator(config);
19
+ var settings = settingsFactory(config);
20
20
  var modules = getModules(settings, platform);
21
21
  if (__updateModules)
22
22
  __updateModules(modules);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splitsoftware/splitio-browserjs",
3
- "version": "0.7.0",
3
+ "version": "0.8.1-rc.0",
4
4
  "description": "Split SDK for Javascript on Browser",
5
5
  "main": "cjs/index.js",
6
6
  "module": "esm/index.js",
@@ -14,7 +14,8 @@
14
14
  "esm",
15
15
  "src",
16
16
  "types",
17
- "full"
17
+ "full",
18
+ "scripts/ga-to-split-autorequire.js"
18
19
  ],
19
20
  "scripts": {
20
21
  "check": "npm run check:lint && npm run check:types && npm run check:version",
@@ -26,20 +27,19 @@
26
27
  "build:cjs": "rimraf cjs && tsc -outDir cjs -m CommonJS && ./scripts/build_cjs_replace_imports.sh",
27
28
  "build:umd-visualizer": "rollup --config rollup.visualizer.config.js",
28
29
  "build:umd": "rollup --config rollup.ci.config.js --branch=$BUILD_BRANCH --commit_hash=$BUILD_COMMIT",
30
+ "build:ga-to-split-autorequire": "terser ./node_modules/@splitsoftware/splitio-commons/src/integrations/ga/autoRequire.js --mangle --output ./scripts/ga-to-split-autorequire.js",
29
31
  "test": "npm run test:unit && npm run test:e2e",
30
32
  "test:unit": "jest",
31
- "test:e2e": "npm run test:e2e-logger && npm run test:e2e-offline && npm run test:e2e-online && npm run test:e2e-destroy && npm run test:e2e-errors && npm run test:e2e-push && npm run test:e2e-gaintegration && npm run test:e2e-consumer",
33
+ "test:e2e": "npm run test:e2e-logger && npm run test:e2e-offline && npm run test:e2e-online && npm run test:e2e-destroy && npm run test:e2e-errorCatching && npm run test:e2e-push && npm run test:e2e-gaIntegration && npm run test:e2e-consumer",
32
34
  "test:e2e-logger": "karma start karma/e2e.logger.karma.conf.js",
33
35
  "test:e2e-offline": "karma start karma/e2e.offline.karma.conf.js",
34
36
  "test:e2e-online": "karma start karma/e2e.online.karma.conf.js",
35
37
  "test:e2e-destroy": "karma start karma/e2e.destroy.karma.conf.js",
36
- "test:e2e-errors": "karma start karma/e2e.errors.karma.conf.js",
38
+ "test:e2e-errorCatching": "karma start karma/e2e.errorCatching.karma.conf.js",
37
39
  "test:e2e-push": "karma start karma/e2e.push.karma.conf.js",
38
- "test:e2e-gaintegration": "karma start karma/e2e.gaintegration.karma.conf.js",
40
+ "test:e2e-gaIntegration": "karma start karma/e2e.gaIntegration.karma.conf.js",
39
41
  "test:e2e-consumer": "karma start karma/e2e.consumer.karma.conf.js",
40
- "pretest-ts-decls": "npm run build:esm && npm run build:cjs && npm link",
41
- "test-ts-decls": "./scripts/ts-tests.sh",
42
- "posttest-ts-decls": "npm unlink && npm install",
42
+ "test-ts-decls": "tsc --build ts-tests",
43
43
  "publish:rc": "npm run check && npm run build && npm publish --tag rc",
44
44
  "publish:stable": "npm run check && npm run build && npm publish"
45
45
  },
@@ -61,7 +61,7 @@
61
61
  "bugs": "https://github.com/splitio/javascript-browser-client/issues",
62
62
  "homepage": "https://github.com/splitio/javascript-browser-client#readme",
63
63
  "dependencies": {
64
- "@splitsoftware/splitio-commons": "1.5.0",
64
+ "@splitsoftware/splitio-commons": "1.6.2-rc.4",
65
65
  "@types/google.analytics": "0.0.40"
66
66
  },
67
67
  "devDependencies": {
@@ -77,9 +77,9 @@
77
77
  "eslint-plugin-import": "^2.25.4",
78
78
  "fetch-mock": "^9.11.0",
79
79
  "jest": "^27.2.3",
80
- "karma": "^6.3.16",
81
- "karma-chrome-launcher": "^3.1.0",
82
- "karma-rollup-preprocessor": "^7.0.5",
80
+ "karma": "^6.4.0",
81
+ "karma-chrome-launcher": "^3.1.1",
82
+ "karma-rollup-preprocessor": "^7.0.8",
83
83
  "karma-tap": "^4.2.0",
84
84
  "replace": "^1.2.1",
85
85
  "rimraf": "^3.0.2",
@@ -0,0 +1 @@
1
+ (function(n,t,e){n[e]=n[e]||t;n[t]=n[t]||function(){n[t].q.push(arguments)};n[t].q=n[t].q||[];var r={};function i(n){return typeof n==="object"&&typeof n.name==="string"&&n.name}function o(e){if(e&&e[0]==="create"){var o=i(e[1])||i(e[2])||i(e[3])||(typeof e[3]==="string"?e[3]:undefined);if(!r[o]){r[o]=true;n[t]((o?o+".":"")+"require","splitTracker")}}}n[t].q.forEach(o);var u=n[t].q.push;n[t].q.push=function(n){var t=u.apply(this,arguments);o(n);return t}})(window,"ga","GoogleAnalyticsObject");
@@ -1,4 +1,4 @@
1
- import { settingsValidator } from '../settings/full';
1
+ import { settingsFactory } from '../settings/full';
2
2
  import { getModules } from '../platform/getModules';
3
3
  import { sdkFactory } from '@splitsoftware/splitio-commons/src/sdkFactory/index';
4
4
  import { ISdkFactoryParams } from '@splitsoftware/splitio-commons/src/sdkFactory/types';
@@ -19,7 +19,7 @@ const platform = { getFetch, getEventSource, EventEmitter, now };
19
19
  * @throws Will throw an error if the provided config is invalid.
20
20
  */
21
21
  export function SplitFactory(config: any, __updateModules?: (modules: ISdkFactoryParams) => void) {
22
- const settings = settingsValidator(config);
22
+ const settings = settingsFactory(config);
23
23
  const modules = getModules(settings, platform);
24
24
  if (__updateModules) __updateModules(modules);
25
25
  return sdkFactory(modules);
@@ -10,7 +10,7 @@ import { pluggableIntegrationsManagerFactory } from '@splitsoftware/splitio-comm
10
10
 
11
11
  import { shouldAddPt } from '@splitsoftware/splitio-commons/src/trackers/impressionObserver/utils';
12
12
  import { IPlatform, ISdkFactoryParams } from '@splitsoftware/splitio-commons/src/sdkFactory/types';
13
- import { ISettings } from '@splitsoftware/splitio-commons/src/types';
13
+ import { IntegrationFactory, ISettings } from '@splitsoftware/splitio-commons/src/types';
14
14
  import { CONSUMER_MODE, CONSUMER_PARTIAL_MODE, LOCALHOST_MODE } from '@splitsoftware/splitio-commons/src/utils/constants';
15
15
  import { createUserConsentAPI } from '@splitsoftware/splitio-commons/src/consent/sdkUserConsent';
16
16
 
@@ -26,7 +26,7 @@ export function getModules(settings: ISettings, platform: IPlatform): ISdkFactor
26
26
 
27
27
  platform,
28
28
 
29
- storageFactory: settings.storage,
29
+ storageFactory: settings.storage as ISdkFactoryParams['storageFactory'],
30
30
 
31
31
  splitApiFactory,
32
32
 
@@ -38,7 +38,7 @@ export function getModules(settings: ISettings, platform: IPlatform): ISdkFactor
38
38
 
39
39
  SignalListener: BrowserSignalListener as ISdkFactoryParams['SignalListener'],
40
40
 
41
- integrationsManagerFactory: settings.integrations && settings.integrations.length > 0 ? pluggableIntegrationsManagerFactory.bind(null, settings.integrations) : undefined,
41
+ integrationsManagerFactory: settings.integrations && settings.integrations.length > 0 ? pluggableIntegrationsManagerFactory.bind(null, settings.integrations as IntegrationFactory[]) : undefined,
42
42
 
43
43
  impressionsObserverFactory: shouldAddPt(settings) ? impressionObserverCSFactory : undefined,
44
44
 
@@ -2,7 +2,7 @@ import { LogLevels, isLogLevelString } from '@splitsoftware/splitio-commons/src/
2
2
  import { ConsentStatus, LogLevel } from '@splitsoftware/splitio-commons/src/types';
3
3
  import { CONSENT_GRANTED } from '@splitsoftware/splitio-commons/src/utils/constants';
4
4
 
5
- const packageVersion = '0.7.0';
5
+ const packageVersion = '0.8.1-rc.0';
6
6
 
7
7
  /**
8
8
  * In browser, the default debug level, can be set via the `localStorage.splitio_debug` item.
@@ -18,6 +18,6 @@ const params = {
18
18
  consent: validateConsent,
19
19
  };
20
20
 
21
- export function settingsValidator(config: any) {
21
+ export function settingsFactory(config: any) {
22
22
  return settingsValidation(config, params);
23
23
  }
@@ -18,6 +18,6 @@ const params = {
18
18
  consent: validateConsent,
19
19
  };
20
20
 
21
- export function settingsValidator(config: any) {
21
+ export function settingsFactory(config: any) {
22
22
  return settingsValidation(config, params);
23
23
  }
@@ -1,4 +1,4 @@
1
- import { settingsValidator } from './settings';
1
+ import { settingsFactory } from './settings';
2
2
  import { getModules } from './platform/getModules';
3
3
  import { sdkFactory } from '@splitsoftware/splitio-commons/src/sdkFactory/index';
4
4
  import { ISdkFactoryParams } from '@splitsoftware/splitio-commons/src/sdkFactory/types';
@@ -19,7 +19,7 @@ const platform = { getFetch, getEventSource, EventEmitter, now };
19
19
  * @throws Will throw an error if the provided config is invalid.
20
20
  */
21
21
  export function SplitFactory(config: any, __updateModules?: (modules: ISdkFactoryParams) => void) {
22
- const settings = settingsValidator(config);
22
+ const settings = settingsFactory(config);
23
23
  const modules = getModules(settings, platform);
24
24
  if (__updateModules) __updateModules(modules);
25
25
  return sdkFactory(modules);
@@ -3,9 +3,8 @@
3
3
  // Definitions by: Nico Zelaya <https://github.com/NicoZelaya/>
4
4
 
5
5
  /// <reference path="../splitio.d.ts" />
6
- export = JsSdk;
7
6
 
8
- declare module JsSdk {
7
+ declare module '@splitsoftware/splitio-browserjs/full' {
9
8
  /**
10
9
  * Full version of the Split.io sdk factory function.
11
10
  *
@@ -30,19 +29,19 @@ declare module JsSdk {
30
29
  *
31
30
  * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#sharing-state-with-a-pluggable-storage}
32
31
  */
33
- export function PluggableStorage(options: SplitIO.PluggableStorageOptions): SplitIO.StorageAsyncFactory;
32
+ export function PluggableStorage(options: SplitIO.PluggableStorageOptions): SplitIO.StorageAsyncFactory;
34
33
 
35
34
  /**
36
35
  * Enable 'Google Analytics to Split' integration, to track Google Analytics hits as Split events.
37
36
  *
38
- * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#integrations}
37
+ * @see {@link https://help.split.io/hc/en-us/articles/360040838752#google-analytics-to-split}
39
38
  */
40
39
  export function GoogleAnalyticsToSplit(options?: SplitIO.GoogleAnalyticsToSplitOptions): SplitIO.IntegrationFactory;
41
40
 
42
41
  /**
43
42
  * Enable 'Split to Google Analytics' integration, to track Split impressions and events as Google Analytics hits.
44
43
  *
45
- * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#integrations}
44
+ * @see {@link https://help.split.io/hc/en-us/articles/360040838752#split-to-google-analytics}
46
45
  */
47
46
  export function SplitToGoogleAnalytics(options?: SplitIO.SplitToGoogleAnalyticsOptions): SplitIO.IntegrationFactory;
48
47
 
package/types/index.d.ts CHANGED
@@ -3,9 +3,8 @@
3
3
  // Definitions by: Nico Zelaya <https://github.com/NicoZelaya/>
4
4
 
5
5
  /// <reference path="./splitio.d.ts" />
6
- export = JsSdk;
7
6
 
8
- declare module JsSdk {
7
+ declare module '@splitsoftware/splitio-browserjs' {
9
8
  /**
10
9
  * Slim version of the Split.io sdk factory function.
11
10
  *
@@ -35,14 +34,14 @@ declare module JsSdk {
35
34
  /**
36
35
  * Enable 'Google Analytics to Split' integration, to track Google Analytics hits as Split events.
37
36
  *
38
- * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#integrations}
37
+ * @see {@link https://help.split.io/hc/en-us/articles/360040838752#google-analytics-to-split}
39
38
  */
40
39
  export function GoogleAnalyticsToSplit(options?: SplitIO.GoogleAnalyticsToSplitOptions): SplitIO.IntegrationFactory;
41
40
 
42
41
  /**
43
42
  * Enable 'Split to Google Analytics' integration, to track Split impressions and events as Google Analytics hits.
44
43
  *
45
- * @see {@link https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK#integrations}
44
+ * @see {@link https://help.split.io/hc/en-us/articles/360040838752#split-to-google-analytics}
46
45
  */
47
46
  export function SplitToGoogleAnalytics(options?: SplitIO.SplitToGoogleAnalyticsOptions): SplitIO.IntegrationFactory;
48
47