diff --git a/pages/docs/tracking-methods/sdks/android/android-flags.mdx b/pages/docs/tracking-methods/sdks/android/android-flags.mdx index 52b65bd99e..e6de6e7db4 100644 --- a/pages/docs/tracking-methods/sdks/android/android-flags.mdx +++ b/pages/docs/tracking-methods/sdks/android/android-flags.mdx @@ -71,22 +71,15 @@ Following initialization, you can reload feature flag assignments in a couple of ```java String updatedDistinctId = ""; +// Reload after login mixpanel.identify(updatedDistinctId); ``` -2) If variant assignment keys or properties used in Runtime Targeting change during the lifetime of your application, you can manually reload flags by updating the context: +2) To refresh flag variants that may have changed during the lifetime of your app, you can manually reload flags: ```java -JSONObject newCustomProperties = new JSONObject(); -newCustomProperties.put("platform", "android"); - -JSONObject newContext = new JSONObject(); -newContext.put("company_id", "Y"); -newContext.put("customProperties", newCustomProperties); - -// Update the context and reload flags -mixpanel.getOptions().featureFlagsContext = newContext; -mixpanel.getFlags().loadFlags(); +// Manually reload flags if desired +mixpanel.flags.loadFlags(); ``` ## Flag Evaluation @@ -99,14 +92,14 @@ This action triggers tracking an exposure event, `$experiment_started` to your M ```java // Get just the flag value asynchronously -mixpanel.getFlags().getVariantValue("my-feature-flag", "control", new FlagCompletionCallback() { +mixpanel.flags.getVariantValue("my-feature-flag", "control", new FlagCompletionCallback() { @Override public void onComplete(Object value) { // This runs on the main thread if (value.equals("variant_a")) { - showExperimentForVariantA(); + showExperienceForVariantA(); } else if (value.equals("variant_b")) { - showExperimentForVariantB(); + showExperienceForVariantB(); } else { showDefaultExperience(); } @@ -118,7 +111,7 @@ mixpanel.getFlags().getVariantValue("my-feature-flag", "control", new FlagComple ```java // Check if a boolean flag is enabled asynchronously -mixpanel.getFlags().isEnabled("my-boolean-flag", false, new FlagCompletionCallback() { +mixpanel.flags.isEnabled("my-boolean-flag", false, new FlagCompletionCallback() { @Override public void onComplete(Boolean isEnabled) { // This runs on the main thread @@ -137,13 +130,13 @@ mixpanel.getFlags().isEnabled("my-boolean-flag", false, new FlagCompletionCallba ```java // Get just the flag value synchronously -Object flagValue = mixpanel.getFlags().getVariantValueSync("my-feature-flag", "control"); +Object flagValue = mixpanel.flags.getVariantValueSync("my-feature-flag", "control"); // Use flag value in your application logic if (flagValue.equals("variant_a")) { - showExperimentForVariantA(); + showExperienceForVariantA(); } else if (flagValue.equals("variant_b")) { - showExperimentForVariantB(); + showExperienceForVariantB(); } else { showDefaultExperience(); } @@ -152,7 +145,7 @@ if (flagValue.equals("variant_a")) { **Feature Gates: Check if Flag is Enabled/Disabled** ```java // Check if a boolean flag is enabled -boolean isEnabled = mixpanel.getFlags().isEnabledSync("my-boolean-flag", false); +boolean isEnabled = mixpanel.flags.isEnabledSync("my-boolean-flag", false); if (isEnabled) { showNewFeature(); diff --git a/pages/docs/tracking-methods/sdks/javascript/javascript-flags.mdx b/pages/docs/tracking-methods/sdks/javascript/javascript-flags.mdx index 02802d18ab..18f83b1b02 100644 --- a/pages/docs/tracking-methods/sdks/javascript/javascript-flags.mdx +++ b/pages/docs/tracking-methods/sdks/javascript/javascript-flags.mdx @@ -74,7 +74,7 @@ updated_distinct_id = "" mixpanel.identify(updated_distinct_id) ``` -2) If variant assignment keys or properties used in Runtime Targeting change during the lifetime of your application, you can manually reload with those new properties +2) To refresh flag variants that may have changed during the lifetime of your app, you can manually reload flags with a new context: ```javascript mixpanel.flags.update_context({ @@ -99,7 +99,7 @@ const variant_value = await mixpanel.flags.get_variant_value("my-feature-flag", // Use flag value in your application logic if (variant_value == "variant_a") { - showExperimentForVariantA(); + showExperienceForVariantA(); } else if (variant_value == "variant_b") { showExperienceForVariantB(); } else if (variant_value == "control") { @@ -110,15 +110,13 @@ if (variant_value == "variant_a") { **Feature Gates: Check if Flag is Enabled/Disabled** ```javascript // Fetch the variant value once flags are ready and track an exposure event *if* the user context is in a rollout group for the feature flag. -const variant_value = await mixpanel.flags.get_variant_value("my-feature-flag", "control"); +const isEnabled = await mixpanel.flags.is_enabled("my-feature-flag", control"); -// Use flag value in your application logic -if (variant_value == "variant_a") { - showExperimentForVariantA(); -} else if (variant_value == "variant_b") { - showExperienceForVariantB(); -} else if (variant_value == "control") { - showDefaultExperience(); +// Use the result in your application logic. +if (isEnabled) { + showNewFeature(); +} else { + showOldFeature(); } ``` diff --git a/pages/docs/tracking-methods/sdks/swift/swift-flags.mdx b/pages/docs/tracking-methods/sdks/swift/swift-flags.mdx index c4e50150fa..4cb81d490c 100644 --- a/pages/docs/tracking-methods/sdks/swift/swift-flags.mdx +++ b/pages/docs/tracking-methods/sdks/swift/swift-flags.mdx @@ -73,12 +73,6 @@ Mixpanel.mainInstance().identify(distinctId: updatedDistinctId) 2) If variant assignment keys or properties used in Runtime Targeting change during the lifetime of your application, you can manually reload flags by updating the context: ```swift -Mixpanel.mainInstance().flags.delegate?.getOptions().featureFlagsContext = [ - "company_id": "Y", - "customProperties": [ - "platform": "ios" - ] -] Mixpanel.mainInstance().flags.loadFlags() ``` @@ -99,9 +93,9 @@ Mixpanel.mainInstance().flags.getVariantValue("my-feature-flag", fallbackValue: if let stringValue = value as? String { switch stringValue { case "variant_a": - showExperimentForVariantA() + showExperienceForVariantA() case "variant_b": - showExperimentForVariantB() + showExperienceForVariantB() default: showDefaultExperience() } @@ -135,9 +129,9 @@ let flagValue = Mixpanel.mainInstance().flags.getVariantValueSync("my-feature-fl // Use flag value in your application logic if flagValue as? String == "variant_a" { - showExperimentForVariantA() + showExperienceForVariantA() } else if flagValue as? String == "variant_b" { - showExperimentForVariantB() + showExperienceForVariantB() } else { showDefaultExperience() }