diff --git a/.circleci/config.yml b/.circleci/config.yml index 8cd4c0c..ea99f6f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -37,4 +37,4 @@ jobs: name: run demo command: | npm start | tee output.txt - grep "is true for this user" output.txt || (echo "Flag did not evaluate to expected true value" && exit 1) + grep "is true for this context" output.txt || (echo "Flag did not evaluate to expected true value" && exit 1) diff --git a/index.ts b/index.ts index a37065f..ea6bdc7 100644 --- a/index.ts +++ b/index.ts @@ -1,4 +1,4 @@ -import * as LaunchDarkly from 'launchdarkly-node-server-sdk'; +import * as LaunchDarkly from '@launchdarkly/node-server-sdk'; // Set sdkKey to your LaunchDarkly SDK key. const sdkKey = ""; @@ -6,11 +6,12 @@ const sdkKey = ""; // Set featureFlagKey to the feature flag key you want to evaluate. const featureFlagKey = "my-boolean-flag"; -// Set up the user properties. This use should appear on your LaunchDarkly -// users dashboard soon after you run the demo. -const user = { - "name": "Sandy", - "key": "example-user-key" +// Set up the context properties. This use should appear on your LaunchDarkly +// contexts dashboard soon after you run the demo. +const context = { + "kind": "user", + "name": "Sandy", + "key": "example-context-key" }; function showMessage(s: string) { @@ -20,24 +21,24 @@ function showMessage(s: string) { const client = LaunchDarkly.init(sdkKey); -client.once('ready', function() { +client.once('ready', function () { showMessage("SDK successfully initialized!"); - client.variation(featureFlagKey, user, false, function(err, showFeature) { - client.track("event-called", user); + client.variation(featureFlagKey, context, false, function (err, showFeature) { + client.track("event-called", context); if (showFeature) { // application code to show the feature - showMessage("Feature flag '" + featureFlagKey + "' is true for this user"); + showMessage("Feature flag '" + featureFlagKey + "' is true for this context"); } else { // the code to run if the feature is off - showMessage("Feature flag '" + featureFlagKey + "' is false for this user"); + showMessage("Feature flag '" + featureFlagKey + "' is false for this context"); } // Here we ensure that the SDK shuts down cleanly and has a chance to deliver analytics // events to LaunchDarkly before the program exits. If analytics events are not delivered, - // the user properties and flag usage statistics will not appear on your dashboard. In a + // the context properties and flag usage statistics will not appear on your dashboard. In a // normal long-running application, the SDK would continue running and events would be // delivered automatically in the background. - client.flush(function() { + client.flush(function () { client.close(); }); }); diff --git a/package.json b/package.json index 3f969cf..4c06f84 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,6 @@ "typescript": "2.4.1" }, "dependencies": { - "launchdarkly-node-server-sdk": "5.8.1" + "@launchdarkly/node-server-sdk": ">= 8.0.0" } }