@statsig/statsig-node-core 0.12.2-beta.2511220235 → 0.12.2-beta.2511260239
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.
|
@@ -12,3 +12,4 @@ export type StickyValues = {
|
|
|
12
12
|
configVersion?: number | undefined;
|
|
13
13
|
};
|
|
14
14
|
export type UserPersistedValues = Record<string, StickyValues>;
|
|
15
|
+
export type SdkEvent = '*' | 'gate_evaluated' | 'dynamic_config_evaluated' | 'experiment_evaluated' | 'layer_evaluated' | 'specs_updated';
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DynamicConfig, Experiment, Layer, ParameterStore, StatsigNapiInternal, StatsigOptions, StatsigResult, StatsigUser } from './statsig-generated';
|
|
1
|
+
import { DynamicConfig, Experiment, Layer, ParameterStore, SdkEvent, StatsigNapiInternal, StatsigOptions, StatsigResult, StatsigUser } from './statsig-generated';
|
|
2
2
|
export * from './statsig-generated';
|
|
3
3
|
export { StatsigUser, Experiment, DynamicConfig, Layer, ParameterStore };
|
|
4
4
|
export declare class Statsig extends StatsigNapiInternal {
|
|
@@ -7,8 +7,8 @@ export declare class Statsig extends StatsigNapiInternal {
|
|
|
7
7
|
static hasShared(): boolean;
|
|
8
8
|
static newShared(sdkKey: string, options?: StatsigOptions): Statsig;
|
|
9
9
|
static removeSharedInstance(): void;
|
|
10
|
-
private static _createErrorInstance;
|
|
11
10
|
constructor(sdkKey: string, options?: StatsigOptions);
|
|
12
11
|
stopConsoleCapture(): void;
|
|
13
12
|
shutdown(timeout_ms?: number): Promise<StatsigResult>;
|
|
13
|
+
subscribe(eventName: SdkEvent, callback: (event: any) => void): string;
|
|
14
14
|
}
|
package/index.js
CHANGED
|
@@ -27,9 +27,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
29
|
exports.Statsig = exports.ParameterStore = exports.Layer = exports.DynamicConfig = exports.Experiment = exports.StatsigUser = void 0;
|
|
30
|
-
const console_capture_1 = require("./console_capture");
|
|
31
30
|
const https_proxy_agent_1 = require("https-proxy-agent");
|
|
32
31
|
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
32
|
+
const console_capture_1 = require("./console_capture");
|
|
33
33
|
const error_boundary_1 = require("./error_boundary");
|
|
34
34
|
const statsig_generated_1 = require("./statsig-generated");
|
|
35
35
|
Object.defineProperty(exports, "DynamicConfig", { enumerable: true, get: function () { return statsig_generated_1.DynamicConfig; } });
|
|
@@ -103,7 +103,7 @@ class Statsig extends statsig_generated_1.StatsigNapiInternal {
|
|
|
103
103
|
static shared() {
|
|
104
104
|
if (!Statsig.hasShared()) {
|
|
105
105
|
console.warn('[Statsig] No shared instance has been created yet. Call newShared() before using it. Returning an invalid instance');
|
|
106
|
-
return
|
|
106
|
+
return _createErrorInstance();
|
|
107
107
|
}
|
|
108
108
|
return Statsig._sharedInstance;
|
|
109
109
|
}
|
|
@@ -114,7 +114,7 @@ class Statsig extends statsig_generated_1.StatsigNapiInternal {
|
|
|
114
114
|
if (Statsig.hasShared()) {
|
|
115
115
|
console.warn('[Statsig] Shared instance has been created, call removeSharedInstance() if you want to create another one. ' +
|
|
116
116
|
'Returning an invalid instance');
|
|
117
|
-
return
|
|
117
|
+
return _createErrorInstance();
|
|
118
118
|
}
|
|
119
119
|
Statsig._sharedInstance = new Statsig(sdkKey, options);
|
|
120
120
|
return Statsig._sharedInstance;
|
|
@@ -122,11 +122,6 @@ class Statsig extends statsig_generated_1.StatsigNapiInternal {
|
|
|
122
122
|
static removeSharedInstance() {
|
|
123
123
|
Statsig._sharedInstance = null;
|
|
124
124
|
}
|
|
125
|
-
static _createErrorInstance() {
|
|
126
|
-
let dummyInstance = new Statsig('INVALID-KEY');
|
|
127
|
-
dummyInstance.shutdown();
|
|
128
|
-
return dummyInstance;
|
|
129
|
-
}
|
|
130
125
|
constructor(sdkKey, options) {
|
|
131
126
|
var _a;
|
|
132
127
|
const fetchFunc = createFetchFunc(options);
|
|
@@ -148,6 +143,21 @@ class Statsig extends statsig_generated_1.StatsigNapiInternal {
|
|
|
148
143
|
return _super.shutdown.call(this, timeout_ms);
|
|
149
144
|
});
|
|
150
145
|
}
|
|
146
|
+
subscribe(eventName, callback) {
|
|
147
|
+
return this.__INTERNAL_subscribe(eventName, (raw) => {
|
|
148
|
+
try {
|
|
149
|
+
callback(JSON.parse(raw));
|
|
150
|
+
}
|
|
151
|
+
catch (error) {
|
|
152
|
+
console.error(`[Statsig] Error parsing SDK Event: ${error}`);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
151
156
|
}
|
|
152
157
|
exports.Statsig = Statsig;
|
|
153
158
|
Statsig._sharedInstance = null;
|
|
159
|
+
function _createErrorInstance() {
|
|
160
|
+
let dummyInstance = new Statsig('INVALID-KEY');
|
|
161
|
+
dummyInstance.shutdown();
|
|
162
|
+
return dummyInstance;
|
|
163
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statsig/statsig-node-core",
|
|
3
|
-
"version": "0.12.2-beta.
|
|
3
|
+
"version": "0.12.2-beta.2511260239",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "jest --colors"
|
|
@@ -55,13 +55,13 @@
|
|
|
55
55
|
]
|
|
56
56
|
},
|
|
57
57
|
"optionalDependencies": {
|
|
58
|
-
"@statsig/statsig-node-core-linux-x64-musl": "0.12.2-beta.
|
|
59
|
-
"@statsig/statsig-node-core-linux-x64-gnu": "0.12.2-beta.
|
|
60
|
-
"@statsig/statsig-node-core-win32-x64-msvc": "0.12.2-beta.
|
|
61
|
-
"@statsig/statsig-node-core-darwin-x64": "0.12.2-beta.
|
|
62
|
-
"@statsig/statsig-node-core-win32-ia32-msvc": "0.12.2-beta.
|
|
63
|
-
"@statsig/statsig-node-core-linux-arm64-musl": "0.12.2-beta.
|
|
64
|
-
"@statsig/statsig-node-core-linux-arm64-gnu": "0.12.2-beta.
|
|
65
|
-
"@statsig/statsig-node-core-darwin-arm64": "0.12.2-beta.
|
|
58
|
+
"@statsig/statsig-node-core-linux-x64-musl": "0.12.2-beta.2511260239",
|
|
59
|
+
"@statsig/statsig-node-core-linux-x64-gnu": "0.12.2-beta.2511260239",
|
|
60
|
+
"@statsig/statsig-node-core-win32-x64-msvc": "0.12.2-beta.2511260239",
|
|
61
|
+
"@statsig/statsig-node-core-darwin-x64": "0.12.2-beta.2511260239",
|
|
62
|
+
"@statsig/statsig-node-core-win32-ia32-msvc": "0.12.2-beta.2511260239",
|
|
63
|
+
"@statsig/statsig-node-core-linux-arm64-musl": "0.12.2-beta.2511260239",
|
|
64
|
+
"@statsig/statsig-node-core-linux-arm64-gnu": "0.12.2-beta.2511260239",
|
|
65
|
+
"@statsig/statsig-node-core-darwin-arm64": "0.12.2-beta.2511260239"
|
|
66
66
|
}
|
|
67
67
|
}
|
package/patch-generated.js
CHANGED
|
@@ -2,20 +2,21 @@ const fs = require('fs');
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
|
|
4
4
|
const GENERATED_FILE = 'src/lib/statsig-generated.d.ts';
|
|
5
|
-
const FILES_TO_APPEND = [
|
|
6
|
-
'src/lib/persistent_storage_type.ts'
|
|
7
|
-
];
|
|
5
|
+
const FILES_TO_APPEND = ['src/lib/additional_types.ts'];
|
|
8
6
|
const generatedFileFullPath = path.resolve(__dirname, '..', GENERATED_FILE);
|
|
9
7
|
|
|
10
8
|
FILES_TO_APPEND.forEach((filePath) => {
|
|
11
9
|
const fullPath = path.resolve(__dirname, '..', filePath);
|
|
12
|
-
let header = `// ---- Manually defined typing section ----- \n
|
|
10
|
+
let header = `// ---- Manually defined typing section ----- \n`;
|
|
13
11
|
if (fs.existsSync(fullPath)) {
|
|
14
12
|
let content = fs.readFileSync(fullPath, 'utf8');
|
|
15
|
-
content = content.replace(
|
|
13
|
+
content = content.replace(
|
|
14
|
+
/^\s*import\s+.*?from\s+['"]\.\/statsig-generated['"];\s*$/gm,
|
|
15
|
+
'',
|
|
16
|
+
);
|
|
16
17
|
content = header + content;
|
|
17
18
|
fs.appendFileSync(generatedFileFullPath, content, 'utf8');
|
|
18
19
|
} else {
|
|
19
20
|
console.warn(`❌ File not found: ${filePath}`);
|
|
20
21
|
}
|
|
21
|
-
});
|
|
22
|
+
});
|
package/statsig-generated.d.ts
CHANGED
|
@@ -56,8 +56,8 @@ export declare class ParameterStore {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
export declare class StatsigNapiInternal {
|
|
59
|
-
|
|
60
|
-
unsubscribe(eventName:
|
|
59
|
+
__INTERNAL_subscribe(eventName: SdkEvent, callback: (raw: string) => void): string
|
|
60
|
+
unsubscribe(eventName: SdkEvent): void
|
|
61
61
|
unsubscribeById(subscriptionId: string): void
|
|
62
62
|
unsubscribeAll(): void
|
|
63
63
|
constructor(networkFunc: unknown, sdkKey: string, options?: StatsigOptions | undefined | null)
|
|
@@ -340,3 +340,11 @@ export type StickyValues = {
|
|
|
340
340
|
};
|
|
341
341
|
|
|
342
342
|
export type UserPersistedValues = Record<string, StickyValues>;
|
|
343
|
+
|
|
344
|
+
export type SdkEvent =
|
|
345
|
+
| '*'
|
|
346
|
+
| 'gate_evaluated'
|
|
347
|
+
| 'dynamic_config_evaluated'
|
|
348
|
+
| 'experiment_evaluated'
|
|
349
|
+
| 'layer_evaluated'
|
|
350
|
+
| 'specs_updated';
|
|
File without changes
|