@statsig/client-core 3.15.1 → 3.15.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statsig/client-core",
3
- "version": "3.15.1",
3
+ "version": "3.15.3",
4
4
  "license": "ISC",
5
5
  "homepage": "https://github.com/statsig-io/js-client-monorepo",
6
6
  "repository": {
@@ -5,7 +5,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports._getInstance = exports._getStatsigGlobalFlag = exports._getStatsigGlobal = void 0;
6
6
  const Log_1 = require("./Log");
7
7
  const _getStatsigGlobal = () => {
8
- return __STATSIG__ ? __STATSIG__ : statsigGlobal;
8
+ // Avoid ReferenceError, which is happening with Cloudflare pages
9
+ try {
10
+ return typeof __STATSIG__ !== 'undefined' ? __STATSIG__ : statsigGlobal;
11
+ }
12
+ catch (e) {
13
+ return statsigGlobal;
14
+ }
9
15
  };
10
16
  exports._getStatsigGlobal = _getStatsigGlobal;
11
17
  const _getStatsigGlobalFlag = (flag) => {
@@ -23,7 +23,7 @@ export type CommonContext = {
23
23
  options: AnyStatsigOptions;
24
24
  errorBoundary: ErrorBoundary;
25
25
  session: StatsigSession;
26
- stableID: string;
26
+ stableID: string | null;
27
27
  };
28
28
  export type OnDeviceEvaluationsContext = CommonContext & {
29
29
  values: DownloadConfigSpecsResponse | null;
package/src/SessionID.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StatsigSession = exports.SessionID = void 0;
4
+ const __StatsigGlobal_1 = require("./$_StatsigGlobal");
4
5
  const CacheKey_1 = require("./CacheKey");
5
6
  const Log_1 = require("./Log");
6
7
  const StorageProvider_1 = require("./StorageProvider");
@@ -74,7 +75,8 @@ function _bumpSession(session) {
74
75
  }
75
76
  function _createSessionTimeout(sdkKey, duration) {
76
77
  return setTimeout(() => {
77
- const client = __STATSIG__ === null || __STATSIG__ === void 0 ? void 0 : __STATSIG__.instance(sdkKey);
78
+ var _a;
79
+ const client = (_a = (0, __StatsigGlobal_1._getStatsigGlobal)()) === null || _a === void 0 ? void 0 : _a.instance(sdkKey);
78
80
  if (client) {
79
81
  client.$emt({ name: 'session_expired' });
80
82
  }
package/src/StableID.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  export declare const StableID: {
2
2
  cookiesEnabled: boolean;
3
3
  randomID: string;
4
- get: (sdkKey: string) => string;
4
+ get: (sdkKey: string) => string | null;
5
5
  setOverride: (override: string, sdkKey: string) => void;
6
6
  _setCookiesEnabled: (sdkKey: string, cookiesEnabled: boolean) => void;
7
+ _setDisabled: (sdkKey: string, disabled: boolean) => void;
7
8
  };
package/src/StableID.js CHANGED
@@ -8,10 +8,14 @@ const StorageProvider_1 = require("./StorageProvider");
8
8
  const UUID_1 = require("./UUID");
9
9
  const PROMISE_MAP = {};
10
10
  const COOKIE_ENABLED_MAP = {};
11
+ const DISABLED_MAP = {};
11
12
  exports.StableID = {
12
13
  cookiesEnabled: false,
13
14
  randomID: Math.random().toString(36),
14
15
  get: (sdkKey) => {
16
+ if (DISABLED_MAP[sdkKey]) {
17
+ return null;
18
+ }
15
19
  if (PROMISE_MAP[sdkKey] != null) {
16
20
  return PROMISE_MAP[sdkKey];
17
21
  }
@@ -39,6 +43,9 @@ exports.StableID = {
39
43
  _setCookiesEnabled: (sdkKey, cookiesEnabled) => {
40
44
  COOKIE_ENABLED_MAP[sdkKey] = cookiesEnabled;
41
45
  },
46
+ _setDisabled: (sdkKey, disabled) => {
47
+ DISABLED_MAP[sdkKey] = disabled;
48
+ },
42
49
  };
43
50
  function _getStableIDStorageKey(sdkKey) {
44
51
  return `statsig.stable_id.${(0, CacheKey_1._getStorageKey)(sdkKey)}`;
@@ -35,6 +35,7 @@ class StatsigClientBase {
35
35
  (options === null || options === void 0 ? void 0 : options.storageProvider) && StorageProvider_1.Storage._setProvider(options.storageProvider);
36
36
  (options === null || options === void 0 ? void 0 : options.enableCookies) &&
37
37
  this.updateRuntimeOptions({ enableCookies: options.enableCookies });
38
+ (options === null || options === void 0 ? void 0 : options.disableStableID) && StableID_1.StableID._setDisabled(sdkKey, true);
38
39
  this._sdkKey = sdkKey;
39
40
  this._options = options !== null && options !== void 0 ? options : {};
40
41
  this._memoCache = {};
@@ -1,12 +1,12 @@
1
- export declare const SDK_VERSION = "3.15.1";
1
+ export declare const SDK_VERSION = "3.15.3";
2
2
  export type StatsigMetadata = {
3
- readonly [key: string]: string | undefined;
3
+ readonly [key: string]: string | undefined | null;
4
4
  readonly appVersion?: string;
5
5
  readonly deviceModel?: string;
6
6
  readonly deviceModelName?: string;
7
7
  readonly locale?: string;
8
8
  readonly sdkVersion: string;
9
- readonly stableID?: string;
9
+ readonly stableID?: string | null;
10
10
  readonly systemName?: string;
11
11
  readonly systemVersion?: string;
12
12
  };
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StatsigMetadataProvider = exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = '3.15.1';
4
+ exports.SDK_VERSION = '3.15.3';
5
5
  let metadata = {
6
6
  sdkVersion: exports.SDK_VERSION,
7
7
  sdkType: 'js-mono', // js-mono is overwritten by Precomp and OnDevice clients
@@ -73,6 +73,12 @@ export type StatsigOptionsCommon<NetworkConfig extends NetworkConfigCommon> = St
73
73
  * default: `false`
74
74
  */
75
75
  disableCompression?: boolean;
76
+ /**
77
+ * When true, the SDK will not generate a stableID for the user. Useful when bootstrapping from a server without a StableID.
78
+ *
79
+ * default: `false`
80
+ */
81
+ disableStableID?: boolean;
76
82
  /**
77
83
  * Whether or not Statsig should use raw JSON for network requests where possible.
78
84
  *
package/src/index.js CHANGED
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.Storage = exports.Log = exports.EventLogger = exports.Diagnostics = void 0;
18
18
  /** Statsig Global should go first */
19
19
  require("./$_StatsigGlobal");
20
+ const __StatsigGlobal_1 = require("./$_StatsigGlobal");
20
21
  const Diagnostics_1 = require("./Diagnostics");
21
22
  Object.defineProperty(exports, "Diagnostics", { enumerable: true, get: function () { return Diagnostics_1.Diagnostics; } });
22
23
  const EventLogger_1 = require("./EventLogger");
@@ -65,5 +66,4 @@ __exportStar(require("./UUID"), exports);
65
66
  __exportStar(require("./VisibilityObserving"), exports);
66
67
  __exportStar(require("./StatsigUpdateDetails"), exports);
67
68
  __exportStar(require("./SDKFlags"), exports);
68
- __STATSIG__ = Object.assign(Object.assign({}, (__STATSIG__ !== null && __STATSIG__ !== void 0 ? __STATSIG__ : {})), { Log: Log_1.Log,
69
- SDK_VERSION: StatsigMetadata_1.SDK_VERSION });
69
+ Object.assign((0, __StatsigGlobal_1._getStatsigGlobal)(), { Log: Log_1.Log, SDK_VERSION: StatsigMetadata_1.SDK_VERSION });