@statsig/client-core 3.12.2 → 3.13.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statsig/client-core",
3
- "version": "3.12.2",
3
+ "version": "3.13.0",
4
4
  "dependencies": {},
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
@@ -1,3 +1,4 @@
1
+ import { NetworkCore } from './NetworkCore';
1
2
  import { DataAdapterAsyncOptions, DataAdapterResult, DataSource } from './StatsigDataAdapter';
2
3
  import { AnyStatsigOptions } from './StatsigOptionsCommon';
3
4
  import { StatsigUser, StatsigUserInternal } from './StatsigUser';
@@ -9,7 +10,7 @@ export declare abstract class DataAdapterCore {
9
10
  private _inMemoryCache;
10
11
  private _lastModifiedStoreKey;
11
12
  protected constructor(_adapterName: string, _cacheSuffix: string);
12
- attach(sdkKey: string, options: AnyStatsigOptions | null): void;
13
+ attach(sdkKey: string, options: AnyStatsigOptions | null, _network: NetworkCore | null): void;
13
14
  getDataSync(user?: StatsigUser | undefined): DataAdapterResult | null;
14
15
  setData(data: string, user?: StatsigUser): void;
15
16
  protected _getDataAsyncImpl(current: DataAdapterResult | null, user?: StatsigUserInternal, options?: DataAdapterAsyncOptions): Promise<DataAdapterResult | null>;
@@ -25,7 +25,7 @@ class DataAdapterCore {
25
25
  this._lastModifiedStoreKey = `statsig.last_modified_time.${_cacheSuffix}`;
26
26
  this._inMemoryCache = new InMemoryCache();
27
27
  }
28
- attach(sdkKey, options) {
28
+ attach(sdkKey, options, _network) {
29
29
  this._sdkKey = sdkKey;
30
30
  this._options = options;
31
31
  }
@@ -43,7 +43,7 @@ class StatsigClientBase {
43
43
  this._errorBoundary.wrap(this._logger);
44
44
  network.setErrorBoundary(this._errorBoundary);
45
45
  this.dataAdapter = adapter;
46
- this.dataAdapter.attach(sdkKey, options);
46
+ this.dataAdapter.attach(sdkKey, options, network);
47
47
  this.storageProvider = StorageProvider_1.Storage;
48
48
  this._primeReadyRipcord();
49
49
  _assignGlobalInstance(sdkKey, this);
@@ -1,4 +1,5 @@
1
1
  import { NetworkPriority } from './NetworkConfig';
2
+ import { NetworkCore } from './NetworkCore';
2
3
  import type { AnyStatsigOptions, NetworkConfigCommon } from './StatsigOptionsCommon';
3
4
  import { StatsigUser } from './StatsigUser';
4
5
  export type DataSource = 'Uninitialized' | 'Loading' | 'NoValues' | 'Cache' | 'Network' | 'NetworkNotModified' | 'Bootstrap' | 'Prefetch';
@@ -55,7 +56,7 @@ type DataAdapterCommon = {
55
56
  * @param {string} sdkKey The SDK key being used by the Statsig client.
56
57
  * @param {StatsigOptionsCommon | null} options The StatsigOptions being used by the Statsig client.
57
58
  */
58
- readonly attach: (sdkKey: string, options: AnyStatsigOptions | null) => void;
59
+ readonly attach: (sdkKey: string, options: AnyStatsigOptions | null, network: NetworkCore) => void;
59
60
  };
60
61
  export type EvaluationsDataAdapter = DataAdapterCommon & {
61
62
  /**
@@ -1,4 +1,4 @@
1
- export declare const SDK_VERSION = "3.12.2";
1
+ export declare const SDK_VERSION = "3.13.0";
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 = '3.12.2';
4
+ exports.SDK_VERSION = '3.13.0';
5
5
  let metadata = {
6
6
  sdkVersion: exports.SDK_VERSION,
7
7
  sdkType: 'js-mono', // js-mono is overwritten by Precomp and OnDevice clients
@@ -37,3 +37,7 @@ exports._notifyVisibilityChanged = _notifyVisibilityChanged;
37
37
  (0, SafeJs_1._addDocumentEventListenerSafe)('visibilitychange', () => {
38
38
  (0, exports._notifyVisibilityChanged)(document.visibilityState === 'visible' ? FOREGROUND : BACKGROUND);
39
39
  });
40
+ (0, SafeJs_1._addDocumentEventListenerSafe)('pagehide', () => {
41
+ isUnloading = true;
42
+ (0, exports._notifyVisibilityChanged)(BACKGROUND);
43
+ });