Skip to content

Commit 430a752

Browse files
committed
chore: upgrade to Featurevisor v2.0
1 parent ed58ecb commit 430a752

3 files changed

Lines changed: 23 additions & 31 deletions

File tree

package-lock.json

Lines changed: 13 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
"author": "",
1212
"license": "MIT",
1313
"dependencies": {
14-
"@featurevisor/sdk": "^1.27.5"
14+
"@featurevisor/sdk": "^2.0.0"
1515
}
1616
}

src/index.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,25 @@ import { createInstance } from "@featurevisor/sdk";
1212
* Constants
1313
*/
1414
const DATAFILE_URL =
15-
"https://featurevisor-example-cloudflare.pages.dev/production/datafile-tag-all.json";
15+
"https://featurevisor-example-cloudflare.pages.dev/production/featurevisor-tag-all.json";
1616

1717
/**
1818
* Main
1919
*/
2020
async function main() {
21+
const datafileContent = await fetch(DATAFILE_URL)
22+
.then((res) => res.json());
23+
2124
const f = createInstance({
22-
datafileUrl: DATAFILE_URL,
23-
onReady: function () {
24-
console.log("Featurevisor SDK is ready");
25-
},
25+
datafile: datafileContent,
26+
context: {
27+
userId: "123"
28+
}
2629
});
2730

28-
await f.onReady();
29-
3031
const featureKey = "my_feature";
31-
const context = { userId: "123" };
3232

33-
const isEnabled = f.isEnabled(featureKey, context);
33+
const isEnabled = f.isEnabled(featureKey);
3434

3535
console.log(`Feature "${featureKey}" is ${isEnabled ? "enabled" : "disabled"}`);
3636
}

0 commit comments

Comments
 (0)