Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Gitar] Cleaning up stale flag: my-boolean-flag with value true #23

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 21 additions & 29 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,45 +1,37 @@
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 = "";

// Set featureFlagKey to the feature flag key you want to evaluate.
const featureFlagKey = "my-boolean-flag";

// 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"
kind: "user",
name: "Sandy",
key: "example-context-key",
};

function showMessage(s: string) {
console.log("*** " + s);
console.log("");
console.log("*** " + s);
console.log("");
}

const client = LaunchDarkly.init(sdkKey);

client.once('ready', function () {
showMessage("SDK successfully initialized!");
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 context");
} else {
// the code to run if the feature is off
showMessage("Feature flag '" + featureFlagKey + "' is false for this context");
}
client.once("ready", function () {
showMessage("SDK successfully initialized!");
client.track("event-called", context);
// application code to show the feature
showMessage(
"Feature flag '" + "my-boolean-flag" + "' is true 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 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.close();
});
});
// 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 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.close();
});
});