@statsig/serverless-client 3.31.0 → 3.31.1
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@statsig/serverless-client",
|
|
3
|
-
"version": "3.31.
|
|
3
|
+
"version": "3.31.1",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"homepage": "https://github.com/statsig-io/js-client-monorepo",
|
|
6
6
|
"repository": {
|
|
@@ -9,13 +9,17 @@
|
|
|
9
9
|
"directory": "packages/serverless"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@statsig/client-core": "3.31.
|
|
13
|
-
"@statsig/js-on-device-eval-client": "3.31.
|
|
12
|
+
"@statsig/client-core": "3.31.1",
|
|
13
|
+
"@statsig/js-on-device-eval-client": "3.31.1"
|
|
14
14
|
},
|
|
15
15
|
"type": "commonjs",
|
|
16
16
|
"main": "./src/index.js",
|
|
17
17
|
"typings": "./src/index.d.ts",
|
|
18
18
|
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./src/index.d.ts",
|
|
21
|
+
"default": "./src/index.js"
|
|
22
|
+
},
|
|
19
23
|
"./cloudflare": {
|
|
20
24
|
"types": "./src/provider/cloudflare.d.ts",
|
|
21
25
|
"default": "./src/provider/cloudflare.js"
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { DataAdapterSyncOptions, StatsigUpdateDetails } from '@statsig/client-core';
|
|
1
2
|
import { StatsigOnDeviceEvalClient, StatsigOptions } from '@statsig/js-on-device-eval-client';
|
|
2
3
|
export declare class StatsigServerlessClient extends StatsigOnDeviceEvalClient {
|
|
3
4
|
constructor(sdkKey: string, options?: StatsigOptions | null);
|
|
5
|
+
initializeSync(options?: DataAdapterSyncOptions): StatsigUpdateDetails;
|
|
6
|
+
initializeViaURL(url: string): Promise<StatsigUpdateDetails>;
|
|
4
7
|
}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
2
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
12
|
exports.StatsigServerlessClient = void 0;
|
|
4
13
|
const js_on_device_eval_client_1 = require("@statsig/js-on-device-eval-client");
|
|
@@ -7,5 +16,49 @@ class StatsigServerlessClient extends js_on_device_eval_client_1.StatsigOnDevice
|
|
|
7
16
|
const edgeSafeOptions = Object.assign({ disableStorage: true, loggingEnabled: 'always', includeCurrentPageUrlWithEvents: false }, options);
|
|
8
17
|
super(sdkKey, edgeSafeOptions);
|
|
9
18
|
}
|
|
19
|
+
initializeSync(options) {
|
|
20
|
+
return super.initializeSync(Object.assign({ disableBackgroundCacheRefresh: true }, options));
|
|
21
|
+
}
|
|
22
|
+
initializeViaURL(url) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
let response;
|
|
25
|
+
const startTime = performance.now();
|
|
26
|
+
try {
|
|
27
|
+
response = yield fetch(url);
|
|
28
|
+
}
|
|
29
|
+
catch (_a) {
|
|
30
|
+
return {
|
|
31
|
+
duration: performance.now() - startTime,
|
|
32
|
+
source: 'Bootstrap',
|
|
33
|
+
success: false,
|
|
34
|
+
error: new Error(`Failed to retrieve config specs from CDN`),
|
|
35
|
+
sourceUrl: url,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
if (!response.ok) {
|
|
39
|
+
return {
|
|
40
|
+
duration: performance.now() - startTime,
|
|
41
|
+
source: 'Bootstrap',
|
|
42
|
+
success: false,
|
|
43
|
+
error: new Error(`Retrieval from storage returned status ${response.status}`),
|
|
44
|
+
sourceUrl: url,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
const specs = yield response.json();
|
|
49
|
+
this.dataAdapter.setData(JSON.stringify(specs));
|
|
50
|
+
return this.initializeSync();
|
|
51
|
+
}
|
|
52
|
+
catch (_b) {
|
|
53
|
+
return {
|
|
54
|
+
duration: performance.now() - startTime,
|
|
55
|
+
source: 'Bootstrap',
|
|
56
|
+
success: false,
|
|
57
|
+
error: new Error('Config specs were not parsed successfully'),
|
|
58
|
+
sourceUrl: url,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
10
63
|
}
|
|
11
64
|
exports.StatsigServerlessClient = StatsigServerlessClient;
|
|
@@ -40,9 +40,7 @@ class StatsigCloudflareClient extends StatsigServerlessClient_1.StatsigServerles
|
|
|
40
40
|
const specs = yield kvBinding.get(kvKey);
|
|
41
41
|
if (specs) {
|
|
42
42
|
this.dataAdapter.setData(specs);
|
|
43
|
-
return this.initializeSync(
|
|
44
|
-
disableBackgroundCacheRefresh: true,
|
|
45
|
-
});
|
|
43
|
+
return this.initializeSync();
|
|
46
44
|
}
|
|
47
45
|
else {
|
|
48
46
|
client_core_1.Log.error(`Failed to fetch specs from Cloudflare KV for key "${kvKey}"`);
|
package/src/provider/fastly.js
CHANGED
|
@@ -71,9 +71,7 @@ class StatsigFastlyClient extends StatsigServerlessClient_1.StatsigServerlessCli
|
|
|
71
71
|
configData = res;
|
|
72
72
|
}
|
|
73
73
|
this.dataAdapter.setData(configData);
|
|
74
|
-
return this.initializeSync(
|
|
75
|
-
disableBackgroundCacheRefresh: true,
|
|
76
|
-
});
|
|
74
|
+
return this.initializeSync();
|
|
77
75
|
}
|
|
78
76
|
return {
|
|
79
77
|
duration: performance.now() - startTime,
|