@statsig/statsig-node-core 0.0.10-beta.2 → 0.0.10-beta.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.
- package/package.json +9 -9
- package/statsig-generated.d.ts +218 -0
- package/statsig-generated.js +374 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statsig/statsig-node-core",
|
|
3
|
-
"version": "0.0.10-beta.
|
|
3
|
+
"version": "0.0.10-beta.4",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "jest --colors",
|
|
@@ -44,13 +44,13 @@
|
|
|
44
44
|
]
|
|
45
45
|
},
|
|
46
46
|
"optionalDependencies": {
|
|
47
|
-
"@statsig/statsig-node-core-linux-x64-musl": "0.0.10-beta.
|
|
48
|
-
"@statsig/statsig-node-core-linux-x64-gnu": "0.0.10-beta.
|
|
49
|
-
"@statsig/statsig-node-core-win32-x64-msvc": "0.0.10-beta.
|
|
50
|
-
"@statsig/statsig-node-core-darwin-x64": "0.0.10-beta.
|
|
51
|
-
"@statsig/statsig-node-core-win32-ia32-msvc": "0.0.10-beta.
|
|
52
|
-
"@statsig/statsig-node-core-linux-arm64-musl": "0.0.10-beta.
|
|
53
|
-
"@statsig/statsig-node-core-linux-arm64-gnu": "0.0.10-beta.
|
|
54
|
-
"@statsig/statsig-node-core-darwin-arm64": "0.0.10-beta.
|
|
47
|
+
"@statsig/statsig-node-core-linux-x64-musl": "0.0.10-beta.4",
|
|
48
|
+
"@statsig/statsig-node-core-linux-x64-gnu": "0.0.10-beta.4",
|
|
49
|
+
"@statsig/statsig-node-core-win32-x64-msvc": "0.0.10-beta.4",
|
|
50
|
+
"@statsig/statsig-node-core-darwin-x64": "0.0.10-beta.4",
|
|
51
|
+
"@statsig/statsig-node-core-win32-ia32-msvc": "0.0.10-beta.4",
|
|
52
|
+
"@statsig/statsig-node-core-linux-arm64-musl": "0.0.10-beta.4",
|
|
53
|
+
"@statsig/statsig-node-core-linux-arm64-gnu": "0.0.10-beta.4",
|
|
54
|
+
"@statsig/statsig-node-core-darwin-arm64": "0.0.10-beta.4"
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/* auto-generated by NAPI-RS */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export declare class DynamicConfig {
|
|
4
|
+
name: string
|
|
5
|
+
value: Record<string, any>
|
|
6
|
+
ruleID: string
|
|
7
|
+
idType: string
|
|
8
|
+
getValue(param_name: string, fallback: boolean | number | string | object | Array<any> | null): any
|
|
9
|
+
getRuleId(): string
|
|
10
|
+
getIdType(): string
|
|
11
|
+
getEvaluationDetails(): EvaluationDetails
|
|
12
|
+
getSecondaryExposures(): Array<SecondaryExposure> | null
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export declare class Experiment {
|
|
16
|
+
name: string
|
|
17
|
+
value: Record<string, any>
|
|
18
|
+
ruleID: string
|
|
19
|
+
idType: string
|
|
20
|
+
groupName?: string
|
|
21
|
+
getValue(param_name: string, fallback: boolean | number | string | object | Array<any> | null): any
|
|
22
|
+
getRuleId(): string
|
|
23
|
+
getIdType(): string
|
|
24
|
+
getGroupName(): string | null
|
|
25
|
+
getEvaluationDetails(): EvaluationDetails
|
|
26
|
+
getSecondaryExposures(): Array<SecondaryExposure> | null
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export declare class Layer {
|
|
30
|
+
name: string
|
|
31
|
+
ruleID: string
|
|
32
|
+
groupName?: string
|
|
33
|
+
allocatedExperimentName?: string
|
|
34
|
+
getValue(param_name: string, fallback: boolean | number | string | object | Array<any> | null): any
|
|
35
|
+
getRuleId(): string
|
|
36
|
+
getGroupName(): string | null
|
|
37
|
+
getEvaluationDetails(): EvaluationDetails
|
|
38
|
+
getSecondaryExposures(): Array<SecondaryExposure> | null
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export declare class StatsigNapiInternal {
|
|
42
|
+
constructor(networkFunc: NapiNetworkFunc, sdkKey: string, options?: StatsigOptions | undefined | null)
|
|
43
|
+
initialize(): Promise<StatsigResult>
|
|
44
|
+
shutdown(timeoutMs?: number | undefined | null): Promise<StatsigResult>
|
|
45
|
+
flushEvents(): Promise<StatsigResult>
|
|
46
|
+
logEvent(user: StatsigUser, eventName: string, value?: string | number | null, metadata?: Record<string, string> | undefined | null): void
|
|
47
|
+
checkGate(user: StatsigUser, gateName: string, options?: FeatureGateEvaluationOptions | undefined | null): boolean
|
|
48
|
+
getFeatureGate(user: StatsigUser, featureName: string, options?: FeatureGateEvaluationOptions | undefined | null): FeatureGate
|
|
49
|
+
getFieldsNeededForGate(gateName: string): Array<string>
|
|
50
|
+
getDynamicConfig(user: StatsigUser, configName: string, options?: DynamicConfigEvaluationOptions | undefined | null): DynamicConfig
|
|
51
|
+
getFieldsNeededForDynamicConfig(configName: string): Array<string>
|
|
52
|
+
getExperiment(user: StatsigUser, experimentName: string, options?: ExperimentEvaluationOptions | undefined | null): Experiment
|
|
53
|
+
getFieldsNeededForExperiment(experimentName: string): Array<string>
|
|
54
|
+
getLayer(user: StatsigUser, layerName: string, options?: LayerEvaluationOptions | undefined | null): Layer
|
|
55
|
+
getFieldsNeededForLayer(layerName: string): Array<string>
|
|
56
|
+
getClientInitializeResponse(user: StatsigUser, options?: ClientInitResponseOptions | undefined | null): string
|
|
57
|
+
manuallyLogFeatureGateExposure(user: StatsigUser, gateName: string): void
|
|
58
|
+
manuallyLogDynamicConfigExposure(user: StatsigUser, configName: string): void
|
|
59
|
+
manuallyLogExperimentExposure(user: StatsigUser, experimentName: string): void
|
|
60
|
+
manuallyLogLayerParamExposure(user: StatsigUser, layerName: string, paramName: string): void
|
|
61
|
+
overrideGate(gateName: string, value: boolean, adapter?: OverrideAdapterType | undefined | null): void
|
|
62
|
+
overrideDynamicConfig(configName: string, value: Record<string, any>, adapter?: OverrideAdapterType | undefined | null): void
|
|
63
|
+
overrideExperiment(experimentName: string, value: Record<string, any>, adapter?: OverrideAdapterType | undefined | null): void
|
|
64
|
+
overrideExperimentByGroupName(experimentName: string, groupName: string, adapter?: OverrideAdapterType | undefined | null): void
|
|
65
|
+
overrideLayer(layerName: string, value: Record<string, any>, adapter?: OverrideAdapterType | undefined | null): void
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export declare class StatsigUser {
|
|
69
|
+
constructor(args: ({userID: string} | {customIDs: Record<string, string> }) & StatsigUserArgs)
|
|
70
|
+
static withUserID(userId: string): StatsigUser
|
|
71
|
+
static withCustomIDs(customIds: Record<string, string>): StatsigUser
|
|
72
|
+
get customIDs(): Record<string, string> | null
|
|
73
|
+
set customIDs(value: Record<string, string> | null)
|
|
74
|
+
get custom(): Record<string, string> | null
|
|
75
|
+
set custom(value: Record<string, string | number | boolean | Array<string | number | boolean>> | null)
|
|
76
|
+
get privateAttributes(): Record<string, string> | null
|
|
77
|
+
set privateAttributes(value: Record<string, string | number | boolean | Array<string | number | boolean>> | null)
|
|
78
|
+
get userID(): string | null
|
|
79
|
+
set userID(value: any)
|
|
80
|
+
get email(): string | null
|
|
81
|
+
set email(value: any)
|
|
82
|
+
get ip(): string | null
|
|
83
|
+
set ip(value: any)
|
|
84
|
+
get userAgent(): string | null
|
|
85
|
+
set userAgent(value: any)
|
|
86
|
+
get country(): string | null
|
|
87
|
+
set country(value: any)
|
|
88
|
+
get locale(): string | null
|
|
89
|
+
set locale(value: any)
|
|
90
|
+
get appVersion(): string | null
|
|
91
|
+
set appVersion(value: any)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export declare function __internal__testDataStore(store: DataStore, path: string, value: string): Promise<[DataStoreResponse | undefined | null, boolean]>
|
|
95
|
+
|
|
96
|
+
export declare function __internal__testObservabilityClient(client: ObservabilityClient, action: string, metricName: string, value: number, tags?: Record<string, string> | undefined | null): Promise<void>
|
|
97
|
+
|
|
98
|
+
export interface ClientInitResponseOptions {
|
|
99
|
+
hashAlgorithm?: string
|
|
100
|
+
clientSdkKey?: string
|
|
101
|
+
includeLocalOverrides?: boolean
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface DataStore {
|
|
105
|
+
initialize?: () => Promise<void>
|
|
106
|
+
shutdown?: () => Promise<void>
|
|
107
|
+
get?: (key: string) => Promise<DataStoreResponse>
|
|
108
|
+
set?: (key: string, value: string, time?: number) => Promise<void>
|
|
109
|
+
supportPollingUpdatesFor?: (key: string) => Promise<boolean>
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface DataStoreResponse {
|
|
113
|
+
result?: string
|
|
114
|
+
time?: number
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface DynamicConfigEvaluationOptions {
|
|
118
|
+
disableExposureLogging?: boolean
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface EvaluationDetails {
|
|
122
|
+
reason: string
|
|
123
|
+
lcut?: number
|
|
124
|
+
receivedAt?: number
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface ExperimentEvaluationOptions {
|
|
128
|
+
disableExposureLogging?: boolean
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface FeatureGate {
|
|
132
|
+
name: string
|
|
133
|
+
value: boolean
|
|
134
|
+
ruleID: string
|
|
135
|
+
idType: string
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface FeatureGateEvaluationOptions {
|
|
139
|
+
disableExposureLogging?: boolean
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface LayerEvaluationOptions {
|
|
143
|
+
disableExposureLogging?: boolean
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface NapiNetworkFuncResult {
|
|
147
|
+
status: number
|
|
148
|
+
data?: Array<number>
|
|
149
|
+
error?: string
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export interface ObservabilityClient {
|
|
153
|
+
initialize?: () => void
|
|
154
|
+
increment?: (metricName: string, value: number, tags: Record<string, string>) => void
|
|
155
|
+
gauge?: (metricName: string, value: number, tags: Record<string, string>) => void
|
|
156
|
+
dist?: (metricName: string, value: number, tags: Record<string, string>) => void
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export interface OverrideAdapterConfig {
|
|
160
|
+
adapterType: OverrideAdapterType
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export declare const enum OverrideAdapterType {
|
|
164
|
+
LocalOverride = 0
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export interface SecondaryExposure {
|
|
168
|
+
gate: string
|
|
169
|
+
gateValue: string
|
|
170
|
+
ruleId: string
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export interface SpecAdapterConfig {
|
|
174
|
+
adapterType: 'data_store' | 'network_grpc_websocket' | 'network_http'
|
|
175
|
+
specsUrl?: string
|
|
176
|
+
initTimeoutMs: number
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export interface StatsigOptions {
|
|
180
|
+
dataStore?: DataStore
|
|
181
|
+
disableAllLogging?: boolean
|
|
182
|
+
enableIdLists?: boolean
|
|
183
|
+
enableUserAgentParsing?: boolean
|
|
184
|
+
enableCountryLookup?: boolean
|
|
185
|
+
environment?: string
|
|
186
|
+
eventLoggingFlushIntervalMs?: number
|
|
187
|
+
eventLoggingMaxQueueSize?: number
|
|
188
|
+
fallbackToStatsigApi?: boolean
|
|
189
|
+
idListsSyncIntervalMs?: number
|
|
190
|
+
idListsUrl?: string
|
|
191
|
+
initTimeoutMs?: number
|
|
192
|
+
logEventUrl?: string
|
|
193
|
+
observabilityClient?: ObservabilityClient
|
|
194
|
+
outputLogLevel?: 'none' | 'debug' | 'info' | 'warn' | 'error'
|
|
195
|
+
specAdaptersConfig?: Array<SpecAdapterConfig>
|
|
196
|
+
specsUrl?: string
|
|
197
|
+
specsSyncIntervalMs?: number
|
|
198
|
+
serviceName?: string
|
|
199
|
+
overrideAdapterConfig?: Array<OverrideAdapterConfig>
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export interface StatsigResult {
|
|
203
|
+
isSuccess: boolean
|
|
204
|
+
error?: string
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export interface StatsigUserArgs {
|
|
208
|
+
userID?: string
|
|
209
|
+
customIDs?: Record<string, string>
|
|
210
|
+
email?: string
|
|
211
|
+
ip?: string
|
|
212
|
+
userAgent?: string
|
|
213
|
+
country?: string
|
|
214
|
+
locale?: string
|
|
215
|
+
appVersion?: string
|
|
216
|
+
custom?: Record<string, string | number | boolean | Array<string | number | boolean>>
|
|
217
|
+
privateAttributes?: Record<string, string | number | boolean | Array<string | number | boolean>>
|
|
218
|
+
}
|
|
@@ -0,0 +1,374 @@
|
|
|
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('@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('@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('@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('@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('@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('@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('@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('@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('@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('@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('@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('@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('@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('@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('@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('@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('@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('@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('@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('@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('@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.DynamicConfig = nativeBinding.DynamicConfig
|
|
368
|
+
module.exports.Experiment = nativeBinding.Experiment
|
|
369
|
+
module.exports.Layer = nativeBinding.Layer
|
|
370
|
+
module.exports.StatsigNapiInternal = nativeBinding.StatsigNapiInternal
|
|
371
|
+
module.exports.StatsigUser = nativeBinding.StatsigUser
|
|
372
|
+
module.exports.__internal__testDataStore = nativeBinding.__internal__testDataStore
|
|
373
|
+
module.exports.__internal__testObservabilityClient = nativeBinding.__internal__testObservabilityClient
|
|
374
|
+
module.exports.OverrideAdapterType = nativeBinding.OverrideAdapterType
|