@statsig/client-core 2.1.1 → 2.2.0-beta.2

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": "2.1.1",
3
+ "version": "2.2.0-beta.2",
4
4
  "dependencies": {},
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
@@ -28,6 +28,7 @@ class StatsigClientBase {
28
28
  (options === null || options === void 0 ? void 0 : options.disableStorage) && StorageProvider_1.Storage._setDisabled(true);
29
29
  (options === null || options === void 0 ? void 0 : options.initialSessionID) &&
30
30
  SessionID_1.StatsigSession.overrideInitialSessionID(options.initialSessionID, sdkKey);
31
+ (options === null || options === void 0 ? void 0 : options.storageProvider) && StorageProvider_1.Storage._setProvider(options.storageProvider);
31
32
  this._sdkKey = sdkKey;
32
33
  this._options = options !== null && options !== void 0 ? options : {};
33
34
  this.overrideAdapter = (_a = options === null || options === void 0 ? void 0 : options.overrideAdapter) !== null && _a !== void 0 ? _a : null;
@@ -1,4 +1,4 @@
1
- export declare const SDK_VERSION = "2.1.1";
1
+ export declare const SDK_VERSION = "2.2.0-beta.2";
2
2
  export type StatsigMetadata = {
3
3
  readonly [key: string]: string | undefined;
4
4
  readonly appVersion?: string;
@@ -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 = '2.1.1';
4
+ exports.SDK_VERSION = '2.2.0-beta.2';
5
5
  let metadata = {
6
6
  sdkVersion: exports.SDK_VERSION,
7
7
  sdkType: 'js-mono', // js-mono is overwritten by Precomp and OnDevice clients
@@ -1,6 +1,7 @@
1
1
  import { LogLevel } from './Log';
2
2
  import { NetworkArgs } from './NetworkConfig';
3
3
  import { OverrideAdapter } from './OverrideAdapter';
4
+ import { StorageProvider } from './StorageProvider';
4
5
  /** Options that can be set at init and updated during runtime. */
5
6
  export type StatsigRuntimeMutableOptions = {
6
7
  /**
@@ -110,6 +111,12 @@ export type StatsigOptionsCommon<NetworkConfig extends NetworkConfigCommon> = St
110
111
  * Note: Sessions still expire and will be replaced with an auto-generated SessionID.
111
112
  */
112
113
  initialSessionID?: string;
114
+ /**
115
+ * Swaps out the storage layer used by the SDK.
116
+ *
117
+ * default: `window.localStorage` on Web. `@react-native-async-storage/async-storage` on Mobile.
118
+ */
119
+ storageProvider?: StorageProvider;
113
120
  };
114
121
  export type AnyStatsigOptions = StatsigOptionsCommon<NetworkConfigCommon>;
115
122
  export type StatsigEnvironment = {
@@ -1,4 +1,5 @@
1
1
  export type StorageProvider = {
2
+ _isProviderReady: () => Promise<void> | null;
2
3
  _getProviderName: () => string;
3
4
  _getItem: (key: string) => string | null;
4
5
  _setItem: (key: string, value: string) => void;
@@ -5,6 +5,7 @@ const Log_1 = require("./Log");
5
5
  const SafeJs_1 = require("./SafeJs");
6
6
  const inMemoryStore = {};
7
7
  const _inMemoryProvider = {
8
+ _isProviderReady: () => null,
8
9
  _getProviderName: () => 'InMemory',
9
10
  _getItem: (key) => inMemoryStore[key] ? inMemoryStore[key] : null,
10
11
  _setItem: (key, value) => {
@@ -22,6 +23,7 @@ try {
22
23
  win.localStorage &&
23
24
  typeof win.localStorage.getItem === 'function') {
24
25
  _localStorageProvider = {
26
+ _isProviderReady: () => null,
25
27
  _getProviderName: () => 'LocalStorage',
26
28
  _getItem: (key) => win.localStorage.getItem(key),
27
29
  _setItem: (key, value) => win.localStorage.setItem(key, value),
@@ -48,6 +50,7 @@ function _inMemoryBreaker(get) {
48
50
  }
49
51
  }
50
52
  exports.Storage = {
53
+ _isProviderReady: () => { var _a, _b; return (_b = (_a = _current._isProviderReady) === null || _a === void 0 ? void 0 : _a.call(_current)) !== null && _b !== void 0 ? _b : null; },
51
54
  _getProviderName: () => _current._getProviderName(),
52
55
  _getItem: (key) => _inMemoryBreaker(() => _current._getItem(key)),
53
56
  _setItem: (key, value) => _current._setItem(key, value),