@statsig/statsig-node-core 0.4.3 → 0.5.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/index.d.ts CHANGED
@@ -1,5 +1,11 @@
1
1
  import { StatsigNapiInternal, StatsigOptions } from './statsig-generated';
2
2
  export * from './statsig-generated';
3
3
  export declare class Statsig extends StatsigNapiInternal {
4
+ private static _sharedInstance;
5
+ static shared(): Statsig;
6
+ static hasShared(): boolean;
7
+ static newShared(sdkKey: string, options?: StatsigOptions): Statsig;
8
+ static removeSharedInstance(): void;
9
+ private static _createErrorInstance;
4
10
  constructor(sdkKey: string, options?: StatsigOptions);
5
11
  }
package/index.js CHANGED
@@ -71,6 +71,33 @@ function createFetchFunc(options) {
71
71
  });
72
72
  }
73
73
  class Statsig extends statsig_generated_1.StatsigNapiInternal {
74
+ static shared() {
75
+ if (!Statsig.hasShared()) {
76
+ console.warn('[Statsig] No shared instance has been created yet. Call newShared() before using it. Returning an invalid instance');
77
+ return Statsig._createErrorInstance();
78
+ }
79
+ return Statsig._sharedInstance;
80
+ }
81
+ static hasShared() {
82
+ return Statsig._sharedInstance !== null;
83
+ }
84
+ static newShared(sdkKey, options) {
85
+ if (Statsig.hasShared()) {
86
+ console.warn('[Statsig] Shared instance has been created, call removeSharedInstance() if you want to create another one. ' +
87
+ 'Returning an invalid instance');
88
+ return Statsig._createErrorInstance();
89
+ }
90
+ Statsig._sharedInstance = new Statsig(sdkKey, options);
91
+ return Statsig._sharedInstance;
92
+ }
93
+ static removeSharedInstance() {
94
+ Statsig._sharedInstance = null;
95
+ }
96
+ static _createErrorInstance() {
97
+ let dummyInstance = new Statsig('INVALID-KEY');
98
+ dummyInstance.shutdown();
99
+ return dummyInstance;
100
+ }
74
101
  constructor(sdkKey, options) {
75
102
  const fetchFunc = createFetchFunc(options);
76
103
  super(fetchFunc, sdkKey, options);
@@ -78,3 +105,4 @@ class Statsig extends statsig_generated_1.StatsigNapiInternal {
78
105
  }
79
106
  }
80
107
  exports.Statsig = Statsig;
108
+ Statsig._sharedInstance = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@statsig/statsig-node-core",
3
- "version": "0.4.3",
3
+ "version": "0.5.0",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "jest --colors",
@@ -45,13 +45,13 @@
45
45
  ]
46
46
  },
47
47
  "optionalDependencies": {
48
- "@statsig/statsig-node-core-linux-x64-musl": "0.4.3",
49
- "@statsig/statsig-node-core-linux-x64-gnu": "0.4.3",
50
- "@statsig/statsig-node-core-win32-x64-msvc": "0.4.3",
51
- "@statsig/statsig-node-core-darwin-x64": "0.4.3",
52
- "@statsig/statsig-node-core-win32-ia32-msvc": "0.4.3",
53
- "@statsig/statsig-node-core-linux-arm64-musl": "0.4.3",
54
- "@statsig/statsig-node-core-linux-arm64-gnu": "0.4.3",
55
- "@statsig/statsig-node-core-darwin-arm64": "0.4.3"
48
+ "@statsig/statsig-node-core-linux-x64-musl": "0.5.0",
49
+ "@statsig/statsig-node-core-linux-x64-gnu": "0.5.0",
50
+ "@statsig/statsig-node-core-win32-x64-msvc": "0.5.0",
51
+ "@statsig/statsig-node-core-darwin-x64": "0.5.0",
52
+ "@statsig/statsig-node-core-win32-ia32-msvc": "0.5.0",
53
+ "@statsig/statsig-node-core-linux-arm64-musl": "0.5.0",
54
+ "@statsig/statsig-node-core-linux-arm64-gnu": "0.5.0",
55
+ "@statsig/statsig-node-core-darwin-arm64": "0.5.0"
56
56
  }
57
57
  }
@@ -208,6 +208,11 @@ export interface SpecAdapterConfig {
208
208
  adapterType: 'data_store' | 'network_grpc_websocket' | 'network_http'
209
209
  specsUrl?: string
210
210
  initTimeoutMs: number
211
+ authenticationMode?: 'none' | 'tls' | 'mtls' | undefined | null
212
+ caCertPath?: string
213
+ clientCertPath?: string
214
+ clientKeyPath?: string
215
+ domainName?: string
211
216
  }
212
217
 
213
218
  export interface StatsigOptions {