From 610b524a7e4dbc14ed3c3ad592d1d66916e96af8 Mon Sep 17 00:00:00 2001 From: Gitar Date: Thu, 5 Dec 2024 20:52:52 +0000 Subject: [PATCH 1/7] [Gitar] Updating Ruby files --- launchdarkly/ruby/sample.rb | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/launchdarkly/ruby/sample.rb b/launchdarkly/ruby/sample.rb index 900c496..39d662a 100644 --- a/launchdarkly/ruby/sample.rb +++ b/launchdarkly/ruby/sample.rb @@ -17,13 +17,8 @@ module WelcomeHelper def check_feature_flags(user, ld_client) # If dark mode is enabled, check for high contrast mode - if ld_client.variation("is-dark-mode-enabled", user, false) - # Check and report the 'enable-high-contrast' feature flag for the specified user - high_contrast = ld_client.variation("enable-high-contrast", user, false) - puts "Dark mode - high contrast mode is #{high_contrast}" - else - puts "Light mode!" - end + high_contrast = ld_client.variation("enable-high-contrast", user, false) + puts "Dark mode - high contrast mode is #{high_contrast}" end def enabled_status(flag_value) From 5a595d887bdb37b9e19a9dd6cd3830330ab50174 Mon Sep 17 00:00:00 2001 From: Gitar Date: Thu, 5 Dec 2024 20:52:52 +0000 Subject: [PATCH 2/7] [Gitar] Updating Dart files --- launchdarkly/dart/sample.dart | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/launchdarkly/dart/sample.dart b/launchdarkly/dart/sample.dart index d56f93d..0a81c54 100644 --- a/launchdarkly/dart/sample.dart +++ b/launchdarkly/dart/sample.dart @@ -13,20 +13,8 @@ class SampleDart { await ldClient.start(user); - bool flagValue = await ldClient.boolVariation("is-dark-mode-enabled", false); - - if (flagValue) { - // The code to run if the feature is on - print("Dark mode!"); - } else { - // The code to run if the feature is off - bool otherFlag = await ldClient.boolVariation("is-ameyas-weird-blue-theme", false); - if (otherFlag) { - print("Why? Just... why?"); - } else { - print("Light mode it is, then!"); - } - } + // The code to run if the feature is on + print("Dark mode!"); await ldClient.close(); } From e22cdc83bdb6cff8665c8ef1b6464110d45003ff Mon Sep 17 00:00:00 2001 From: Gitar Date: Thu, 5 Dec 2024 20:52:52 +0000 Subject: [PATCH 3/7] [Gitar] Updating TSX files --- launchdarkly/react/sample.tsx | 49 +++++++++-------------------------- 1 file changed, 12 insertions(+), 37 deletions(-) diff --git a/launchdarkly/react/sample.tsx b/launchdarkly/react/sample.tsx index ab8c13c..32ddc62 100644 --- a/launchdarkly/react/sample.tsx +++ b/launchdarkly/react/sample.tsx @@ -25,11 +25,6 @@ const Header = () => { key: "user_key", name: "User Name", }); - const isDarkModeEnabled = ldClient.variation( - "is-dark-mode-enabled", - user, - false, - ); const enableHighContrast = ldClient.variation( "enable-high-contrast", user, @@ -37,38 +32,18 @@ const Header = () => { ); return ( -
- {isDarkModeEnabled ? ( -
- Dark Mode is enabled. -

Welcome to a darker, more soothing interface!

- {enableHighContrast ? ( -
- High Contrast mode is enabled, enhancing visual accessibility. -
- ) : ( -
High Contrast mode is disabled.
- )} -
- ) : ( -
- Dark Mode is disabled. -

Enjoy the default light theme.

- {enableHighContrast ? ( -
- High Contrast mode is enabled, enhancing visual accessibility. -
- ) : ( -
High Contrast mode is disabled.
- )} -
- )} +
+
+ Dark Mode is enabled. +

Welcome to a darker, more soothing interface!

+ {enableHighContrast ? ( +
+ High Contrast mode is enabled, enhancing visual accessibility. +
+ ) : ( +
High Contrast mode is disabled.
+ )} +
); }; From 7d18799ef515b15e4ad9e19ff42b315df81a133f Mon Sep 17 00:00:00 2001 From: Gitar Date: Thu, 5 Dec 2024 20:52:52 +0000 Subject: [PATCH 4/7] [Gitar] Updating Go files --- launchdarkly/go/sample.go | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/launchdarkly/go/sample.go b/launchdarkly/go/sample.go index 3dee8b6..9393962 100644 --- a/launchdarkly/go/sample.go +++ b/launchdarkly/go/sample.go @@ -22,25 +22,17 @@ import ( ) func checkFeatureFlags(user lduser.User, ldClient *ld.LDClient) { - // Check the 'is-dark-mode-enabled' feature flag for the specified user - darkModeEnabled, err := ldClient.BoolVariation("is-dark-mode-enabled", user, false) - if err != nil { - fmt.Printf("Error evaluating feature flag 'is-dark-mode-enabled': %s\n", err) - return - } // Report the status of the dark mode - fmt.Println("Dark mode is", enabledStatus(darkModeEnabled)) + fmt.Println("Dark mode is", enabledStatus(true)) // If dark mode is enabled, check for high contrast mode - if darkModeEnabled { - // Check the 'enable-high-contrast' feature flag for the specified user - highContrastEnabled, err1 := ldClient.BoolVariation("enable-high-contrast", user, false) - if err1 != nil { - fmt.Printf("Error evaluating feature flag 'enable-high-contrast': %s\n", err1) - return - } - // Report the status of the high contrast mode - fmt.Println("High contrast mode is", enabledStatus(highContrastEnabled)) + // Check the 'enable-high-contrast' feature flag for the specified user + highContrastEnabled, err1 := ldClient.BoolVariation("enable-high-contrast", user, false) + if err1 != nil { + fmt.Printf("Error evaluating feature flag 'enable-high-contrast': %s\n", err1) + return } + // Report the status of the high contrast mode + fmt.Println("High contrast mode is", enabledStatus(highContrastEnabled)) } From 6c864587ee24fe1d2035865cf99f53c6263a0936 Mon Sep 17 00:00:00 2001 From: Gitar Date: Thu, 5 Dec 2024 20:52:52 +0000 Subject: [PATCH 5/7] [Gitar] Updating Java files --- launchdarkly/java/Sample.java | 17 ++--------------- launchdarkly/java/SampleDeep.java | 26 +++----------------------- 2 files changed, 5 insertions(+), 38 deletions(-) diff --git a/launchdarkly/java/Sample.java b/launchdarkly/java/Sample.java index a93aaeb..a04aa30 100644 --- a/launchdarkly/java/Sample.java +++ b/launchdarkly/java/Sample.java @@ -21,20 +21,7 @@ class Sample { public void sampleMethodCheckingFlag() { - LDClient client = new LDClient("sdk-key-123abc"); - LDContext context = LDContext - .builder("context-key-123abc") - .name("Sandy") - .build(); - // Check the 'is-dark-mode-enabled' feature flag for the specified user - boolean flagValue = client.boolVariation("is-dark-mode-enabled", context, false); - if (flagValue) { - // The code to run if the feature is on - System.out.println("Dark mode!"); - } else { - // The code to run if the feature is off - System.out.println("My eyes, they burn!"); - } + // The code to run if the feature is on + System.out.println("Dark mode!"); } - } diff --git a/launchdarkly/java/SampleDeep.java b/launchdarkly/java/SampleDeep.java index 43a55ae..36d77b6 100644 --- a/launchdarkly/java/SampleDeep.java +++ b/launchdarkly/java/SampleDeep.java @@ -23,28 +23,8 @@ class SampleDeep { public void sampleMethodCheckingFlag(Map config) { LDClient client = new LDClient("sdk-key-123abc"); - LDContext context = LDContext - .builder("context-key-123abc") - .name("Sandy") - .build(); - // Check the 'is-dark-mode-enabled' feature flag for the specified user - boolean flagValue = isDarkModeEnabled(); - if (flagValue || forceDarkModeFromLocalConfig(config)) { - // The code to run if the feature is on - System.out.println("Dark mode!"); - } else { - // The code to run if the feature is off - System.out.println("My eyes, they burn!"); - } + LDContext context = LDContext.builder("context-key-123abc").name("Sandy").build(); + // The code to run if the feature is on + System.out.println("Dark mode!"); } - - private bool isDarkModeEnabled() { - return client.boolVariation("is-dark-mode-enabled", context, false); - } - - // A non-feature-flag related condition that's part of our check - private bool forceDarkModeFromLocalConfig(Map config) { - return config.get("dark-mode").equals("on"); - } - } From b22bb13143fd6f815d76c1ac66a317dca74338b3 Mon Sep 17 00:00:00 2001 From: Gitar Date: Thu, 5 Dec 2024 20:52:52 +0000 Subject: [PATCH 6/7] [Gitar] Updating Kotlin files --- launchdarkly/kotlin/sample.kt | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/launchdarkly/kotlin/sample.kt b/launchdarkly/kotlin/sample.kt index 23878b5..54d0027 100644 --- a/launchdarkly/kotlin/sample.kt +++ b/launchdarkly/kotlin/sample.kt @@ -20,20 +20,14 @@ import com.launchdarkly.sdk.server.LDClient fun checkFeatureFlags( user: LDUser, ldClient: LDClient, -): String { +): String { try { - // Check the 'is-dark-mode-enabled' feature flag for the specified user - val darkModeEnabled = ldClient.boolVariation("is-dark-mode-enabled", user, false) - println("Dark mode is ${enabledStatus(darkModeEnabled)}") + println("Dark mode is ${enabledStatus(true)}") // If dark mode is enabled, check for high contrast mode - if (darkModeEnabled) { - val highContrastEnabled = ldClient.boolVariation("enable-high-contrast", user, false) - println("High contrast mode is ${enabledStatus(highContrastEnabled)}") - return "Dark Mode and high contrast" - } - println("No dark mode") - return "Light mode and no high contrast" + val highContrastEnabled = ldClient.boolVariation("enable-high-contrast", user, false) + println("High contrast mode is ${enabledStatus(highContrastEnabled)}") + return "Dark Mode and high contrast" } catch (e: Exception) { println("Error evaluating feature flags: ${e.message}") } From b70c292b0b44fe024fc778362d47cd9105d1c9d1 Mon Sep 17 00:00:00 2001 From: Gitar Date: Thu, 5 Dec 2024 20:52:52 +0000 Subject: [PATCH 7/7] [Gitar] Updating JavaScript files --- launchdarkly/node/sample.js | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/launchdarkly/node/sample.js b/launchdarkly/node/sample.js index 0c25516..d0e7810 100644 --- a/launchdarkly/node/sample.js +++ b/launchdarkly/node/sample.js @@ -23,24 +23,8 @@ import * as LaunchDarkly from "@launchdarkly/node-server-sdk"; const SDK_KEY = ""; -const context = { - kind: "user", - name: "Sandy", - key: "example-context-key", -}; const client = LaunchDarkly.init(SDK_KEY); client.once("ready", () => { - client.variation( - "is-dark-mode-enabled", - context, - false, - (err, useDarkMode) => { - if (useDarkMode) { - console.log("Dark mode is enabled"); - } else { - console.log("Dark mode is disabled"); - } - }, - ); + console.log("Dark mode is enabled"); });