@statsig/statsig-node-core 0.4.3 → 0.5.1-beta.2506060236

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,12 @@
1
1
  import { StatsigNapiInternal, StatsigOptions } from './statsig-generated';
2
2
  export * from './statsig-generated';
3
+ export * from './sticky_values';
3
4
  export declare class Statsig extends StatsigNapiInternal {
5
+ private static _sharedInstance;
6
+ static shared(): Statsig;
7
+ static hasShared(): boolean;
8
+ static newShared(sdkKey: string, options?: StatsigOptions): Statsig;
9
+ static removeSharedInstance(): void;
10
+ private static _createErrorInstance;
4
11
  constructor(sdkKey: string, options?: StatsigOptions);
5
12
  }
package/index.js CHANGED
@@ -32,6 +32,7 @@ const node_fetch_1 = __importDefault(require("node-fetch"));
32
32
  const error_boundary_1 = require("./error_boundary");
33
33
  const statsig_generated_1 = require("./statsig-generated");
34
34
  __exportStar(require("./statsig-generated"), exports);
35
+ __exportStar(require("./sticky_values"), exports);
35
36
  function createProxyAgent(options) {
36
37
  const proxy = options === null || options === void 0 ? void 0 : options.proxyConfig;
37
38
  if ((proxy === null || proxy === void 0 ? void 0 : proxy.proxyHost) && (proxy === null || proxy === void 0 ? void 0 : proxy.proxyProtocol)) {
@@ -71,6 +72,33 @@ function createFetchFunc(options) {
71
72
  });
72
73
  }
73
74
  class Statsig extends statsig_generated_1.StatsigNapiInternal {
75
+ static shared() {
76
+ if (!Statsig.hasShared()) {
77
+ console.warn('[Statsig] No shared instance has been created yet. Call newShared() before using it. Returning an invalid instance');
78
+ return Statsig._createErrorInstance();
79
+ }
80
+ return Statsig._sharedInstance;
81
+ }
82
+ static hasShared() {
83
+ return Statsig._sharedInstance !== null;
84
+ }
85
+ static newShared(sdkKey, options) {
86
+ if (Statsig.hasShared()) {
87
+ console.warn('[Statsig] Shared instance has been created, call removeSharedInstance() if you want to create another one. ' +
88
+ 'Returning an invalid instance');
89
+ return Statsig._createErrorInstance();
90
+ }
91
+ Statsig._sharedInstance = new Statsig(sdkKey, options);
92
+ return Statsig._sharedInstance;
93
+ }
94
+ static removeSharedInstance() {
95
+ Statsig._sharedInstance = null;
96
+ }
97
+ static _createErrorInstance() {
98
+ let dummyInstance = new Statsig('INVALID-KEY');
99
+ dummyInstance.shutdown();
100
+ return dummyInstance;
101
+ }
74
102
  constructor(sdkKey, options) {
75
103
  const fetchFunc = createFetchFunc(options);
76
104
  super(fetchFunc, sdkKey, options);
@@ -78,3 +106,4 @@ class Statsig extends statsig_generated_1.StatsigNapiInternal {
78
106
  }
79
107
  }
80
108
  exports.Statsig = Statsig;
109
+ 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.1-beta.2506060236",
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.1-beta.2506060236",
49
+ "@statsig/statsig-node-core-linux-x64-gnu": "0.5.1-beta.2506060236",
50
+ "@statsig/statsig-node-core-win32-x64-msvc": "0.5.1-beta.2506060236",
51
+ "@statsig/statsig-node-core-darwin-x64": "0.5.1-beta.2506060236",
52
+ "@statsig/statsig-node-core-win32-ia32-msvc": "0.5.1-beta.2506060236",
53
+ "@statsig/statsig-node-core-linux-arm64-musl": "0.5.1-beta.2506060236",
54
+ "@statsig/statsig-node-core-linux-arm64-gnu": "0.5.1-beta.2506060236",
55
+ "@statsig/statsig-node-core-darwin-arm64": "0.5.1-beta.2506060236"
56
56
  }
57
57
  }
@@ -112,6 +112,8 @@ export declare function __internal__testDataStore(store: DataStore, path: string
112
112
 
113
113
  export declare function __internal__testObservabilityClient(client: ObservabilityClient, action: string, metricName: string, value: number, tags?: Record<string, string> | undefined | null): Promise<void>
114
114
 
115
+ export declare function __internal__testPersistentStorage(store: PersistentStorage, action: string, key?: string | undefined | null, configName?: string | undefined | null, data?: any | undefined | null): Promise<Record<string, string> | null>
116
+
115
117
  export interface ClientInitResponseOptions {
116
118
  hashAlgorithm?: string
117
119
  clientSdkKey?: string
@@ -191,6 +193,12 @@ export interface ParameterStoreEvaluationOptions {
191
193
  disableExposureLogging?: boolean
192
194
  }
193
195
 
196
+ export interface PersistentStorage {
197
+ load: (key: string) => UserPersistedValues | null
198
+ save: (key: string, config_name: string, data: StickyValues) => void
199
+ delete: (key: string, config_name: string) => void
200
+ }
201
+
194
202
  export interface ProxyConfig {
195
203
  proxyHost?: string
196
204
  proxyPort?: number
@@ -208,6 +216,11 @@ export interface SpecAdapterConfig {
208
216
  adapterType: 'data_store' | 'network_grpc_websocket' | 'network_http'
209
217
  specsUrl?: string
210
218
  initTimeoutMs: number
219
+ authenticationMode?: 'none' | 'tls' | 'mtls' | undefined | null
220
+ caCertPath?: string
221
+ clientCertPath?: string
222
+ clientKeyPath?: string
223
+ domainName?: string
211
224
  }
212
225
 
213
226
  export interface StatsigOptions {
@@ -372,4 +372,5 @@ module.exports.StatsigNapiInternal = nativeBinding.StatsigNapiInternal
372
372
  module.exports.StatsigUser = nativeBinding.StatsigUser
373
373
  module.exports.__internal__testDataStore = nativeBinding.__internal__testDataStore
374
374
  module.exports.__internal__testObservabilityClient = nativeBinding.__internal__testObservabilityClient
375
+ module.exports.__internal__testPersistentStorage = nativeBinding.__internal__testPersistentStorage
375
376
  module.exports.OverrideAdapterType = nativeBinding.OverrideAdapterType