Skip to content

Commit 4f58205

Browse files
committed
add standard comments and outputs
1 parent f624656 commit 4f58205

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

index.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,37 @@ const sdkKey = "";
66
// Set featureFlagKey to the feature flag key you want to evaluate.
77
const featureFlagKey = "my-boolean-flag";
88

9-
const client = LaunchDarkly.init(sdkKey);
10-
119
// Set up the user properties. This use should appear on your LaunchDarkly
1210
// users dashboard soon after you run the demo.
1311
const user = {
1412
"name": "Sandy",
1513
"key": "example-user-key"
1614
};
1715

16+
function showMessage(s: string) {
17+
console.log("*** " + s);
18+
console.log("");
19+
}
20+
21+
const client = LaunchDarkly.init(sdkKey);
22+
1823
client.once('ready', function() {
19-
// TODO : Enter the key for your feature flag here
20-
client.variation("enable-pinning", user, false, function(err, showFeature) {
24+
showMessage("SDK successfully initialized!");
25+
client.variation(featureFlagKey, user, false, function(err, showFeature) {
2126
client.track("event-called", user);
2227
if (showFeature) {
2328
// application code to show the feature
24-
console.log("Showing your feature to " + user.key );
29+
showMessage("Feature flag '" + featureFlagKey + "' is true for this user");
2530
} else {
26-
// the code to run if the feature is off
27-
console.log("Not showing your feature to " + user.key);
31+
// the code to run if the feature is off
32+
showMessage("Feature flag '" + featureFlagKey + "' is false for this user");
2833
}
34+
35+
// Here we ensure that the SDK shuts down cleanly and has a chance to deliver analytics
36+
// events to LaunchDarkly before the program exits. If analytics events are not delivered,
37+
// the user properties and flag usage statistics will not appear on your dashboard. In a
38+
// normal long-running application, the SDK would continue running and events would be
39+
// delivered automatically in the background.
2940
client.flush(function() {
3041
client.close();
3142
});

0 commit comments

Comments
 (0)