@oai-statsig/statsig-node-core 0.19.4

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.
@@ -0,0 +1,314 @@
1
+ /* auto-generated by NAPI-RS */
2
+ /* eslint-disable */
3
+ export declare class LayerParamExposureData {
4
+
5
+ }
6
+
7
+ export declare class ParameterStore {
8
+ name: string
9
+ getValue<T>(paramName: string, fallback?: T): T
10
+ getEvaluationDetails(): EvaluationDetails
11
+ toJSON(): Record<string, any>
12
+ }
13
+
14
+ export declare class StatsigNapiInternal {
15
+ __INTERNAL_subscribe(eventName: SdkEvent, callback: (raw: string) => void): string
16
+ unsubscribe(eventName: SdkEvent): void
17
+ unsubscribeById(subscriptionId: string): void
18
+ unsubscribeAll(): void
19
+ constructor(sdkKey: string, options?: StatsigOptions | undefined | null)
20
+ initialize(): Promise<StatsigResult>
21
+ shutdown(timeoutMs?: number | undefined | null): Promise<StatsigResult>
22
+ flushEvents(): Promise<StatsigResult>
23
+ logEvent(user: StatsigUser, eventName: string, value?: string | number | null, metadata?: Record<string, string | number | boolean | null | undefined> | null | undefined): void
24
+ forwardLogLineEvent(user: StatsigUser, logLevel: 'trace' | 'debug' |'log' | 'info' | 'warn' | 'error', value?: string | undefined | null, metadata?: Record<string, string> | undefined | null): void
25
+ checkGate(user: StatsigUser, gateName: string, options?: FeatureGateEvaluationOptions | undefined | null): boolean
26
+ __INTERNAL_getFeatureGate(user: StatsigUser, featureName: string, options?: FeatureGateEvaluationOptions | undefined | null): Record<string, unknown>
27
+ getFieldsNeededForGate(gateName: string): Array<string>
28
+ __INTERNAL_getDynamicConfig(user: StatsigUser, configName: string, options?: DynamicConfigEvaluationOptions | undefined | null): Record<string, unknown>
29
+ getFieldsNeededForDynamicConfig(configName: string): Array<string>
30
+ __INTERNAL_getExperiment(user: StatsigUser, experimentName: string, options?: ExperimentEvaluationOptions | undefined | null): Record<string, unknown>
31
+ __INTERNAL_getExperimentByGroupName(experimentName: string, groupName: string): Record<string, unknown>
32
+ getFieldsNeededForExperiment(experimentName: string): Array<string>
33
+ __INTERNAL_getLayer(user: StatsigUser, layerName: string, options?: LayerEvaluationOptions | undefined | null): Record<string, unknown>
34
+ __INTERNAL_logLayerParamExposure(raw: LayerParamExposureData, paramName: string): void
35
+ getFieldsNeededForLayer(layerName: string): Array<string>
36
+ identify(user: StatsigUser): void
37
+ getParameterStore(user: StatsigUser, parameterStoreName: string, options?: ParameterStoreEvaluationOptions | undefined | null): ParameterStore
38
+ getClientInitializeResponse(user: StatsigUser, options?: ClientInitResponseOptions | undefined | null): string
39
+ manuallyLogFeatureGateExposure(user: StatsigUser, gateName: string): void
40
+ manuallyLogDynamicConfigExposure(user: StatsigUser, configName: string): void
41
+ manuallyLogExperimentExposure(user: StatsigUser, experimentName: string): void
42
+ manuallyLogLayerParamExposure(user: StatsigUser, layerName: string, paramName: string): void
43
+ overrideGate(gateName: string, value: boolean, id?: string | undefined | null): void
44
+ overrideDynamicConfig(configName: string, value: Record<string, any>, id?: string | undefined | null): void
45
+ overrideExperiment(experimentName: string, value: Record<string, any>, id?: string | undefined | null): void
46
+ overrideExperimentByGroupName(experimentName: string, groupName: string, id?: string | undefined | null): void
47
+ overrideLayer(layerName: string, value: Record<string, any>, id?: string | undefined | null): void
48
+ overrideParameterStore(parameterStoreName: string, value: Record<string, any>, id?: string | undefined | null): void
49
+ removeGateOverride(gateName: string, id?: string | undefined | null): void
50
+ removeDynamicConfigOverride(configName: string, id?: string | undefined | null): void
51
+ removeExperimentOverride(experimentName: string, id?: string | undefined | null): void
52
+ removeLayerOverride(layerName: string, id?: string | undefined | null): void
53
+ removeParameterStoreOverride(parameterStoreName: string, id?: string | undefined | null): void
54
+ removeAllOverrides(): void
55
+ getFeatureGateList(): Array<string>
56
+ getDynamicConfigList(): Array<string>
57
+ getExperimentList(): Array<string>
58
+ getParameterStoreList(): Array<string>
59
+ getParsedUserAgentValueForUser(user: StatsigUser): Record<string, string | undefined | null> | null
60
+ }
61
+
62
+ export declare class StatsigUser {
63
+ constructor(args: ({userID: string} | {customIDs: Record<string, string> }) & StatsigUserArgs)
64
+ static withUserID(userId: string): StatsigUser
65
+ static withCustomIDs(customIds: Record<string, string>): StatsigUser
66
+ get customIDs(): Record<string, string> | null
67
+ set customIDs(value: Record<string, string> | null)
68
+ get custom(): Record<string, string | number | boolean | Array<string | number | boolean>> | null
69
+ set custom(value: Record<string, string | number | boolean | Array<string | number | boolean>> | null)
70
+ get privateAttributes(): Record<string, string | number | boolean | Array<string | number | boolean>> | null
71
+ set privateAttributes(value: Record<string, string | number | boolean | Array<string | number | boolean>> | null)
72
+ get statsigEnvironment(): Record<string, string> | null
73
+ set statsigEnvironment(value: { tier?: string, [key: string]: string | undefined } | undefined)
74
+ get userID(): string | null
75
+ set userID(value: any)
76
+ get email(): string | null
77
+ set email(value: any)
78
+ get ip(): string | null
79
+ set ip(value: any)
80
+ get userAgent(): string | null
81
+ set userAgent(value: any)
82
+ get country(): string | null
83
+ set country(value: any)
84
+ get locale(): string | null
85
+ set locale(value: any)
86
+ get appVersion(): string | null
87
+ set appVersion(value: any)
88
+ toJSON(): any
89
+ }
90
+
91
+ export declare function __internal__testDataStore(store: DataStore, path: string, value: string): Promise<[DataStoreResponse | undefined | null, boolean]>
92
+
93
+ export declare function __internal__testObservabilityClient(client: ObservabilityClient, action: string, metricName: string, value: number, tags?: Record<string, string> | undefined | null): Promise<void>
94
+
95
+ export declare function __internal__testOutputLogger(logger: OutputLoggerProvider, action: string, tag?: string | undefined | null, message?: string | undefined | null): Promise<void>
96
+
97
+ 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>
98
+
99
+ export interface ClientInitResponseOptions {
100
+ hashAlgorithm?: string
101
+ clientSdkKey?: string
102
+ includeLocalOverrides?: boolean
103
+ featureGateFilter?: Set<string>
104
+ experimentFilter?: Set<string>
105
+ dynamicConfigFilter?: Set<string>
106
+ layerFilter?: Set<string>
107
+ paramStoreFilter?: Set<string>
108
+ removeIdType?: boolean
109
+ removeDefaultValueGates?: boolean
110
+ responseFormat?: GCIRResponseFormat
111
+ previousResponseHash?: string
112
+ }
113
+
114
+ export interface ConsoleCaptureOptions {
115
+ enabled: boolean
116
+ logLevels?: Array<'trace' | 'debug' | 'log' | 'info' | 'warn' | 'error'>
117
+ user?: StatsigUser
118
+ maxKeys?: number
119
+ maxDepth?: number
120
+ maxLength?: number
121
+ }
122
+
123
+ export interface DataStore {
124
+ initialize?: () => Promise<void>
125
+ shutdown?: () => Promise<void>
126
+ get?: (key: string) => Promise<DataStoreResponse>
127
+ getBytes?: (key: string) => Promise<{ result?: Uint8Array; time?: number }>
128
+ set?: (key: string, value: string, time?: number) => Promise<void>
129
+ setBytes?: (key: string, value: ArrayBuffer | Uint8Array, time?: number) => Promise<void>
130
+ supportPollingUpdatesFor?: (key: string) => Promise<boolean>
131
+ }
132
+
133
+ export interface DataStoreBytesResponse {
134
+ result?: Uint8Array
135
+ time?: number
136
+ }
137
+
138
+ export interface DataStoreResponse {
139
+ result?: string
140
+ time?: number
141
+ }
142
+
143
+ export interface DynamicConfigEvaluationOptions {
144
+ disableExposureLogging?: boolean
145
+ }
146
+
147
+ export interface EvaluationDetails {
148
+ reason: string
149
+ lcut?: number
150
+ receivedAt?: number
151
+ version?: number
152
+ }
153
+
154
+ export interface ExperimentEvaluationOptions {
155
+ disableExposureLogging?: boolean
156
+ userPersistedValues?: Record<string, any>
157
+ }
158
+
159
+ export interface FeatureGateEvaluationOptions {
160
+ disableExposureLogging?: boolean
161
+ }
162
+
163
+ export declare const enum GCIRResponseFormat {
164
+ Initialize = 0,
165
+ InitializeWithSecondaryExposureMapping = 1,
166
+ InitializeV2 = 2
167
+ }
168
+
169
+ export interface LayerEvaluationOptions {
170
+ disableExposureLogging?: boolean
171
+ userPersistedValues?: Record<string, any>
172
+ }
173
+
174
+ export interface ObservabilityClient {
175
+ initialize?: () => void
176
+ increment?: (metricName: string, value: number, tags: Record<string, string>) => void
177
+ gauge?: (metricName: string, value: number, tags: Record<string, string>) => void
178
+ dist?: (metricName: string, value: number, tags: Record<string, string>) => void
179
+ error?: (tag: string, error: string) => void
180
+ }
181
+
182
+ export interface OutputLoggerProvider {
183
+ initialize?: () => void
184
+ debug?: (tag: string, message: string) => void
185
+ info?: (tag: string, message: string) => void
186
+ warn?: (tag: string, message: string) => void
187
+ error?: (tag: string, message: string) => void
188
+ shutdown?: () => void
189
+ }
190
+
191
+ export interface OverrideAdapterConfig {
192
+ adapterType: OverrideAdapterType
193
+ }
194
+
195
+ export declare const enum OverrideAdapterType {
196
+ LocalOverride = 0
197
+ }
198
+
199
+ export interface ParameterStoreEvaluationOptions {
200
+ disableExposureLogging?: boolean
201
+ }
202
+
203
+ export interface PersistentStorage {
204
+ load: (key: string) => UserPersistedValues | null
205
+ save: (key: string, config_name: string, data: StickyValues) => void
206
+ delete: (key: string, config_name: string) => void
207
+ }
208
+
209
+ export interface ProxyConfig {
210
+ proxyHost?: string
211
+ proxyPort?: number
212
+ proxyAuth?: string
213
+ proxyProtocol?: string
214
+ caCertPath?: string
215
+ }
216
+
217
+ export interface SecondaryExposure {
218
+ gate: string
219
+ gateValue: string
220
+ ruleId: string
221
+ }
222
+
223
+ export interface SpecAdapterConfig {
224
+ adapterType: 'data_store' | 'network_grpc_websocket' | 'network_http'
225
+ specsUrl?: string
226
+ initTimeoutMs: number
227
+ authenticationMode?: 'none' | 'tls' | 'mtls' | undefined | null
228
+ caCertPath?: string
229
+ clientCertPath?: string
230
+ clientKeyPath?: string
231
+ domainName?: string
232
+ }
233
+
234
+ export declare function statsigCaptureLogLine(level: string, payload: Array<string>, sdkKey: string, stackTrace?: string | undefined | null): void
235
+
236
+ export interface StatsigOptions {
237
+ dataStore?: DataStore
238
+ dataStoreKeySchemaVersion?: 'v2' | 'v3'
239
+ disableAllLogging?: boolean
240
+ disableCountryLookup?: boolean
241
+ disableNetwork?: boolean
242
+ logEventConnectionReuse?: boolean
243
+ enableIdLists?: boolean
244
+ enableDcsDeltas?: boolean
245
+ environment?: string
246
+ eventLoggingFlushIntervalMs?: number
247
+ eventLoggingMaxQueueSize?: number
248
+ fallbackToStatsigApi?: boolean
249
+ globalCustomFields?: Record<string, string | number | boolean | Array<string | number | boolean>>
250
+ idListsSyncIntervalMs?: number
251
+ idListsUrl?: string
252
+ downloadIdListFileApi?: string
253
+ initTimeoutMs?: number
254
+ logEventUrl?: string
255
+ observabilityClient?: ObservabilityClient
256
+ outputLogLevel?: 'none' | 'debug' | 'info' | 'warn' | 'error'
257
+ outputLoggerProvider?: OutputLoggerProvider
258
+ configCompressionMode?: 'gzip' | 'dictionary'
259
+ overrideAdapterConfig?: Array<OverrideAdapterConfig>
260
+ serviceName?: string
261
+ persistentStorage?: PersistentStorage
262
+ specAdaptersConfig?: Array<SpecAdapterConfig>
263
+ specsSyncIntervalMs?: number
264
+ specsUrl?: string
265
+ waitForCountryLookupInit?: boolean
266
+ waitForUserAgentInit?: boolean
267
+ proxyConfig?: ProxyConfig
268
+ consoleCaptureOptions?: ConsoleCaptureOptions
269
+ useThirdPartyUaParser?: boolean
270
+ experimentalFlags?: Set<string>
271
+ }
272
+
273
+ export interface StatsigResult {
274
+ isSuccess: boolean
275
+ error?: string
276
+ }
277
+
278
+ export interface StatsigUserArgs {
279
+ userID?: string
280
+ customIDs?: Record<string, string>
281
+ email?: string
282
+ ip?: string
283
+ userAgent?: string
284
+ country?: string
285
+ locale?: string
286
+ appVersion?: string
287
+ statsigEnvironment?: { tier?: string, [key: string]: string | undefined } | undefined
288
+ custom?: Record<string, string | number | boolean | Array<string | number | boolean> | null | undefined | Record<string, unknown>>
289
+ privateAttributes?: Record<string, string | number | boolean | Array<string | number | boolean> | Record<string, unknown>>
290
+ }
291
+ // ---- Manually defined typing section -----
292
+
293
+ export type StickyValues = {
294
+ value: boolean;
295
+ json_value: Record<string, unknown>;
296
+ rule_id: string;
297
+ group_name: string | null;
298
+ secondary_exposures: SecondaryExposure[];
299
+ undelegated_secondary_exposures: SecondaryExposure[];
300
+ config_delegate: string | null;
301
+ explicit_parameters: string[] | null;
302
+ time: number;
303
+ configVersion?: number | undefined;
304
+ };
305
+
306
+ export type UserPersistedValues = Record<string, StickyValues>;
307
+
308
+ export type SdkEvent =
309
+ | '*'
310
+ | 'gate_evaluated'
311
+ | 'dynamic_config_evaluated'
312
+ | 'experiment_evaluated'
313
+ | 'layer_evaluated'
314
+ | 'specs_updated';
@@ -0,0 +1,377 @@
1
+ // prettier-ignore
2
+ /* eslint-disable */
3
+ // @ts-nocheck
4
+ /* auto-generated by NAPI-RS */
5
+
6
+ const { createRequire } = require('node:module')
7
+ require = createRequire(__filename)
8
+
9
+ const { readFileSync } = require('node:fs')
10
+ let nativeBinding = null
11
+ const loadErrors = []
12
+
13
+ const isMusl = () => {
14
+ let musl = false
15
+ if (process.platform === 'linux') {
16
+ musl = isMuslFromFilesystem()
17
+ if (musl === null) {
18
+ musl = isMuslFromReport()
19
+ }
20
+ if (musl === null) {
21
+ musl = isMuslFromChildProcess()
22
+ }
23
+ }
24
+ return musl
25
+ }
26
+
27
+ const isFileMusl = (f) => f.includes('libc.musl-') || f.includes('ld-musl-')
28
+
29
+ const isMuslFromFilesystem = () => {
30
+ try {
31
+ return readFileSync('/usr/bin/ldd', 'utf-8').includes('musl')
32
+ } catch {
33
+ return null
34
+ }
35
+ }
36
+
37
+ const isMuslFromReport = () => {
38
+ const report = typeof process.report.getReport === 'function' ? process.report.getReport() : null
39
+ if (!report) {
40
+ return null
41
+ }
42
+ if (report.header && report.header.glibcVersionRuntime) {
43
+ return false
44
+ }
45
+ if (Array.isArray(report.sharedObjects)) {
46
+ if (report.sharedObjects.some(isFileMusl)) {
47
+ return true
48
+ }
49
+ }
50
+ return false
51
+ }
52
+
53
+ const isMuslFromChildProcess = () => {
54
+ try {
55
+ return require('child_process').execSync('ldd --version', { encoding: 'utf8' }).includes('musl')
56
+ } catch (e) {
57
+ // If we reach this case, we don't know if the system is musl or not, so is better to just fallback to false
58
+ return false
59
+ }
60
+ }
61
+
62
+ function requireNative() {
63
+ if (process.platform === 'android') {
64
+ if (process.arch === 'arm64') {
65
+ try {
66
+ return require('./statsig-node-core.android-arm64.node')
67
+ } catch (e) {
68
+ loadErrors.push(e)
69
+ }
70
+ try {
71
+ return require('@oai-statsig/statsig-node-core-android-arm64')
72
+ } catch (e) {
73
+ loadErrors.push(e)
74
+ }
75
+
76
+ } else if (process.arch === 'arm') {
77
+ try {
78
+ return require('./statsig-node-core.android-arm-eabi.node')
79
+ } catch (e) {
80
+ loadErrors.push(e)
81
+ }
82
+ try {
83
+ return require('@oai-statsig/statsig-node-core-android-arm-eabi')
84
+ } catch (e) {
85
+ loadErrors.push(e)
86
+ }
87
+
88
+ } else {
89
+ loadErrors.push(new Error(`Unsupported architecture on Android ${process.arch}`))
90
+ }
91
+ } else if (process.platform === 'win32') {
92
+ if (process.arch === 'x64') {
93
+ try {
94
+ return require('./statsig-node-core.win32-x64-msvc.node')
95
+ } catch (e) {
96
+ loadErrors.push(e)
97
+ }
98
+ try {
99
+ return require('@oai-statsig/statsig-node-core-win32-x64-msvc')
100
+ } catch (e) {
101
+ loadErrors.push(e)
102
+ }
103
+
104
+ } else if (process.arch === 'ia32') {
105
+ try {
106
+ return require('./statsig-node-core.win32-ia32-msvc.node')
107
+ } catch (e) {
108
+ loadErrors.push(e)
109
+ }
110
+ try {
111
+ return require('@oai-statsig/statsig-node-core-win32-ia32-msvc')
112
+ } catch (e) {
113
+ loadErrors.push(e)
114
+ }
115
+
116
+ } else if (process.arch === 'arm64') {
117
+ try {
118
+ return require('./statsig-node-core.win32-arm64-msvc.node')
119
+ } catch (e) {
120
+ loadErrors.push(e)
121
+ }
122
+ try {
123
+ return require('@oai-statsig/statsig-node-core-win32-arm64-msvc')
124
+ } catch (e) {
125
+ loadErrors.push(e)
126
+ }
127
+
128
+ } else {
129
+ loadErrors.push(new Error(`Unsupported architecture on Windows: ${process.arch}`))
130
+ }
131
+ } else if (process.platform === 'darwin') {
132
+ try {
133
+ return require('./statsig-node-core.darwin-universal.node')
134
+ } catch (e) {
135
+ loadErrors.push(e)
136
+ }
137
+ try {
138
+ return require('@oai-statsig/statsig-node-core-darwin-universal')
139
+ } catch (e) {
140
+ loadErrors.push(e)
141
+ }
142
+
143
+ if (process.arch === 'x64') {
144
+ try {
145
+ return require('./statsig-node-core.darwin-x64.node')
146
+ } catch (e) {
147
+ loadErrors.push(e)
148
+ }
149
+ try {
150
+ return require('@oai-statsig/statsig-node-core-darwin-x64')
151
+ } catch (e) {
152
+ loadErrors.push(e)
153
+ }
154
+
155
+ } else if (process.arch === 'arm64') {
156
+ try {
157
+ return require('./statsig-node-core.darwin-arm64.node')
158
+ } catch (e) {
159
+ loadErrors.push(e)
160
+ }
161
+ try {
162
+ return require('@oai-statsig/statsig-node-core-darwin-arm64')
163
+ } catch (e) {
164
+ loadErrors.push(e)
165
+ }
166
+
167
+ } else {
168
+ loadErrors.push(new Error(`Unsupported architecture on macOS: ${process.arch}`))
169
+ }
170
+ } else if (process.platform === 'freebsd') {
171
+ if (process.arch === 'x64') {
172
+ try {
173
+ return require('./statsig-node-core.freebsd-x64.node')
174
+ } catch (e) {
175
+ loadErrors.push(e)
176
+ }
177
+ try {
178
+ return require('@oai-statsig/statsig-node-core-freebsd-x64')
179
+ } catch (e) {
180
+ loadErrors.push(e)
181
+ }
182
+
183
+ } else if (process.arch === 'arm64') {
184
+ try {
185
+ return require('./statsig-node-core.freebsd-arm64.node')
186
+ } catch (e) {
187
+ loadErrors.push(e)
188
+ }
189
+ try {
190
+ return require('@oai-statsig/statsig-node-core-freebsd-arm64')
191
+ } catch (e) {
192
+ loadErrors.push(e)
193
+ }
194
+
195
+ } else {
196
+ loadErrors.push(new Error(`Unsupported architecture on FreeBSD: ${process.arch}`))
197
+ }
198
+ } else if (process.platform === 'linux') {
199
+ if (process.arch === 'x64') {
200
+ if (isMusl()) {
201
+ try {
202
+ return require('./statsig-node-core.linux-x64-musl.node')
203
+ } catch (e) {
204
+ loadErrors.push(e)
205
+ }
206
+ try {
207
+ return require('@oai-statsig/statsig-node-core-linux-x64-musl')
208
+ } catch (e) {
209
+ loadErrors.push(e)
210
+ }
211
+
212
+ } else {
213
+ try {
214
+ return require('./statsig-node-core.linux-x64-gnu.node')
215
+ } catch (e) {
216
+ loadErrors.push(e)
217
+ }
218
+ try {
219
+ return require('@oai-statsig/statsig-node-core-linux-x64-gnu')
220
+ } catch (e) {
221
+ loadErrors.push(e)
222
+ }
223
+
224
+ }
225
+ } else if (process.arch === 'arm64') {
226
+ if (isMusl()) {
227
+ try {
228
+ return require('./statsig-node-core.linux-arm64-musl.node')
229
+ } catch (e) {
230
+ loadErrors.push(e)
231
+ }
232
+ try {
233
+ return require('@oai-statsig/statsig-node-core-linux-arm64-musl')
234
+ } catch (e) {
235
+ loadErrors.push(e)
236
+ }
237
+
238
+ } else {
239
+ try {
240
+ return require('./statsig-node-core.linux-arm64-gnu.node')
241
+ } catch (e) {
242
+ loadErrors.push(e)
243
+ }
244
+ try {
245
+ return require('@oai-statsig/statsig-node-core-linux-arm64-gnu')
246
+ } catch (e) {
247
+ loadErrors.push(e)
248
+ }
249
+
250
+ }
251
+ } else if (process.arch === 'arm') {
252
+ if (isMusl()) {
253
+ try {
254
+ return require('./statsig-node-core.linux-arm-musleabihf.node')
255
+ } catch (e) {
256
+ loadErrors.push(e)
257
+ }
258
+ try {
259
+ return require('@oai-statsig/statsig-node-core-linux-arm-musleabihf')
260
+ } catch (e) {
261
+ loadErrors.push(e)
262
+ }
263
+
264
+ } else {
265
+ try {
266
+ return require('./statsig-node-core.linux-arm-gnueabihf.node')
267
+ } catch (e) {
268
+ loadErrors.push(e)
269
+ }
270
+ try {
271
+ return require('@oai-statsig/statsig-node-core-linux-arm-gnueabihf')
272
+ } catch (e) {
273
+ loadErrors.push(e)
274
+ }
275
+
276
+ }
277
+ } else if (process.arch === 'riscv64') {
278
+ if (isMusl()) {
279
+ try {
280
+ return require('./statsig-node-core.linux-riscv64-musl.node')
281
+ } catch (e) {
282
+ loadErrors.push(e)
283
+ }
284
+ try {
285
+ return require('@oai-statsig/statsig-node-core-linux-riscv64-musl')
286
+ } catch (e) {
287
+ loadErrors.push(e)
288
+ }
289
+
290
+ } else {
291
+ try {
292
+ return require('./statsig-node-core.linux-riscv64-gnu.node')
293
+ } catch (e) {
294
+ loadErrors.push(e)
295
+ }
296
+ try {
297
+ return require('@oai-statsig/statsig-node-core-linux-riscv64-gnu')
298
+ } catch (e) {
299
+ loadErrors.push(e)
300
+ }
301
+
302
+ }
303
+ } else if (process.arch === 'ppc64') {
304
+ try {
305
+ return require('./statsig-node-core.linux-ppc64-gnu.node')
306
+ } catch (e) {
307
+ loadErrors.push(e)
308
+ }
309
+ try {
310
+ return require('@oai-statsig/statsig-node-core-linux-ppc64-gnu')
311
+ } catch (e) {
312
+ loadErrors.push(e)
313
+ }
314
+
315
+ } else if (process.arch === 's390x') {
316
+ try {
317
+ return require('./statsig-node-core.linux-s390x-gnu.node')
318
+ } catch (e) {
319
+ loadErrors.push(e)
320
+ }
321
+ try {
322
+ return require('@oai-statsig/statsig-node-core-linux-s390x-gnu')
323
+ } catch (e) {
324
+ loadErrors.push(e)
325
+ }
326
+
327
+ } else {
328
+ loadErrors.push(new Error(`Unsupported architecture on Linux: ${process.arch}`))
329
+ }
330
+ } else {
331
+ loadErrors.push(new Error(`Unsupported OS: ${process.platform}, architecture: ${process.arch}`))
332
+ }
333
+ }
334
+
335
+ nativeBinding = requireNative()
336
+
337
+ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
338
+ try {
339
+ nativeBinding = require('./statsig-node-core.wasi.cjs')
340
+ } catch (err) {
341
+ if (process.env.NAPI_RS_FORCE_WASI) {
342
+ loadErrors.push(err)
343
+ }
344
+ }
345
+ if (!nativeBinding) {
346
+ try {
347
+ nativeBinding = require('@oai-statsig/statsig-node-core-wasm32-wasi')
348
+ } catch (err) {
349
+ if (process.env.NAPI_RS_FORCE_WASI) {
350
+ loadErrors.push(err)
351
+ }
352
+ }
353
+ }
354
+ }
355
+
356
+ if (!nativeBinding) {
357
+ if (loadErrors.length > 0) {
358
+ // TODO Link to documentation with potential fixes
359
+ // - The package owner could build/publish bindings for this arch
360
+ // - The user may need to bundle the correct files
361
+ // - The user may need to re-install node_modules to get new packages
362
+ throw new Error('Failed to load native binding', { cause: loadErrors })
363
+ }
364
+ throw new Error(`Failed to load native binding`)
365
+ }
366
+
367
+ module.exports.LayerParamExposureData = nativeBinding.LayerParamExposureData
368
+ module.exports.ParameterStore = nativeBinding.ParameterStore
369
+ module.exports.StatsigNapiInternal = nativeBinding.StatsigNapiInternal
370
+ module.exports.StatsigUser = nativeBinding.StatsigUser
371
+ module.exports.__internal__testDataStore = nativeBinding.__internal__testDataStore
372
+ module.exports.__internal__testObservabilityClient = nativeBinding.__internal__testObservabilityClient
373
+ module.exports.__internal__testOutputLogger = nativeBinding.__internal__testOutputLogger
374
+ module.exports.__internal__testPersistentStorage = nativeBinding.__internal__testPersistentStorage
375
+ module.exports.GCIRResponseFormat = nativeBinding.GCIRResponseFormat
376
+ module.exports.OverrideAdapterType = nativeBinding.OverrideAdapterType
377
+ module.exports.statsigCaptureLogLine = nativeBinding.statsigCaptureLogLine