diff --git a/contents/docs/experiments/adding-experiment-code.mdx b/contents/docs/experiments/adding-experiment-code.mdx index f4a50d39b924..173ca06835b6 100644 --- a/contents/docs/experiments/adding-experiment-code.mdx +++ b/contents/docs/experiments/adding-experiment-code.mdx @@ -94,7 +94,7 @@ if (PostHog.getFeatureFlag("experiment-feature-flag-key") == "variant-name") { ```ios // In Swift -if (posthog.getFeatureFlag('experiment-feature-flag-key') == 'variant-name') { +if (posthog.getFeatureFlag("experiment-feature-flag-key") as? String == "variant-name") { // do something } ``` diff --git a/contents/docs/integrate/feature-flags-code/_snippets/feature-flags-code-ios.mdx b/contents/docs/integrate/feature-flags-code/_snippets/feature-flags-code-ios.mdx index 17900d4c64e2..6a27d68dce9b 100644 --- a/contents/docs/integrate/feature-flags-code/_snippets/feature-flags-code-ios.mdx +++ b/contents/docs/integrate/feature-flags-code/_snippets/feature-flags-code-ios.mdx @@ -1,7 +1,7 @@ ### Boolean feature flags ```swift -if (posthog.isFeatureEnabled('flag-key')) { +if (posthog.isFeatureEnabled("flag-key")) { // Do something differently for this user } ``` @@ -9,7 +9,7 @@ if (posthog.isFeatureEnabled('flag-key')) { ### Multivariate feature flags ```swift -if (posthog.getFeatureFlag('my-flag') == "variant-key") { // replace 'variant-key' with the key of your variant +if (posthog.getFeatureFlag("my-flag") as? String == "variant-key") { // replace "variant-key" with the key of your variant // do something } ``` diff --git a/contents/docs/libraries/ios/index.mdx b/contents/docs/libraries/ios/index.mdx index 0e601c3e53ef..9751b9b184a4 100644 --- a/contents/docs/libraries/ios/index.mdx +++ b/contents/docs/libraries/ios/index.mdx @@ -87,7 +87,7 @@ You can also manually flush the queue: ``` ```swift -posthog.capture('logged_out') +posthog.capture("logged_out") posthog.flush() ``` @@ -154,7 +154,7 @@ if ([[PHGPosthog sharedPostHog] getFeatureFlag:@"experiment-feature-flag-key"] = ``` ```swift -if (posthog.getFeatureFlag('experiment-feature-flag-key') == 'variant-name') { +if (posthog.getFeatureFlag("experiment-feature-flag-key") as? String == "variant-name") { // do something } ``` diff --git a/contents/product-engineers/ab-testing-guide-for-engineers.md b/contents/product-engineers/ab-testing-guide-for-engineers.md index 5cb752e2866a..d3e6ad0acd4a 100644 --- a/contents/product-engineers/ab-testing-guide-for-engineers.md +++ b/contents/product-engineers/ab-testing-guide-for-engineers.md @@ -116,7 +116,7 @@ It's absolutely **essential** to only log the users in your test who would actua To do so, ensure that checking your feature flag and logging their exposure is the *absolute* last condition you check in your code: -``` +```js // ❌ Incorrect. Will include unaffected users function showNewChanges(user) { if (posthog.getFeatureFlag('experiment-key') === 'control') { @@ -133,7 +133,7 @@ function showNewChanges(user) { } ``` -``` +```js // ✅ Correct. Will exclude unaffected users function showNewChanges(user) {