statsig-node-vercel 0.2.0 → 0.4.0

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.
@@ -43,10 +43,15 @@ export class EdgeConfigDataAdapter implements IDataAdapter {
43
43
  }
44
44
 
45
45
  const data = await this.edgeConfigClient.get(this.edgeConfigItemKey);
46
- if (data === undefined) {
46
+ if (data == null) {
47
47
  return { error: new Error(`key (${key}) does not exist`) };
48
48
  }
49
- return { result: JSON.stringify(data) };
49
+ if (typeof data !== "object") {
50
+ return {
51
+ error: new Error(`Edge Config value expected to be an object or array`),
52
+ };
53
+ }
54
+ return { result: data };
50
55
  }
51
56
 
52
57
  // eslint-disable-next-line @typescript-eslint/require-await
package/README.md CHANGED
@@ -30,11 +30,14 @@ import { createClient } from "@vercel/edge-config";
30
30
 
31
31
  ```js
32
32
  const edgeConfigClient = createClient(process.env.EDGE_CONFIG);
33
- const dataAdapter = new EdgeConfigDataAdapter("KEY_FROM_INSTALLATION");
33
+ const dataAdapter = new EdgeConfigDataAdapter({
34
+ edgeConfigClient: edgeConfigClient,
35
+ edgeConfigItemKey: "ITEM_KEY_FROM_INSTALLATION", // something like "statsig-5FSfBpWM9kUPqeKRlZPkod"
36
+ })
34
37
  ```
35
38
 
36
- 6. When initializing the `statsig` sdk, add the adapter to options
39
+ 6. When initializing the `statsig` sdk, add the adapter to options, along with the initStrategyForIDLists and disableIdListsSync options to avoid a blocking network call for ID Lists. However, if you are using Statsig ID lists for evaluation, you'll need to omit those options and incur a network request to grab ID lists.
37
40
 
38
41
  ```js
39
- await statsig.initialize("server-secret-key", { dataAdapter: dataAdapter });
42
+ await statsig.initialize("server-secret-key", { dataAdapter: dataAdapter, initStrategyForIDLists: 'none', disableIdListsSync: true });
40
43
  ```
@@ -25,10 +25,15 @@ class EdgeConfigDataAdapter {
25
25
  };
26
26
  }
27
27
  const data = yield this.edgeConfigClient.get(this.edgeConfigItemKey);
28
- if (data === undefined) {
28
+ if (data == null) {
29
29
  return { error: new Error(`key (${key}) does not exist`) };
30
30
  }
31
- return { result: JSON.stringify(data) };
31
+ if (typeof data !== "object") {
32
+ return {
33
+ error: new Error(`Edge Config value expected to be an object or array`),
34
+ };
35
+ }
36
+ return { result: data };
32
37
  });
33
38
  }
34
39
  // eslint-disable-next-line @typescript-eslint/require-await
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "statsig-node-vercel",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -12,7 +12,7 @@
12
12
  "author": "",
13
13
  "license": "ISC",
14
14
  "dependencies": {
15
- "statsig-node": "5.1.0"
15
+ "statsig-node": "5.22.0"
16
16
  },
17
17
  "peerDependencies": {
18
18
  "@vercel/edge-config": "^0.1.4"
@@ -22,8 +22,9 @@
22
22
  "@babel/preset-env": "^7.18.10",
23
23
  "@babel/preset-typescript": "^7.18.6",
24
24
  "@types/jest": "^28.1.8",
25
+ "@types/node": "^20.14.10",
25
26
  "@vercel/edge-config": "^0.2.1",
26
27
  "jest": "^29.0.0",
27
28
  "jest-fetch-mock": "^3.0.3"
28
29
  }
29
- }
30
+ }