vybekiit 0.7.34 → 0.7.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/dist/bin.js +520 -9
  2. package/dist/global-skills/eas-app-stores/SKILL.md +2 -2
  3. package/dist/global-skills/eas-hosting/SKILL.md +2 -2
  4. package/dist/global-skills/eas-observe/SKILL.md +7 -15
  5. package/dist/global-skills/eas-observe/references/queries.md +51 -10
  6. package/dist/global-skills/eas-observe/references/setup.md +60 -7
  7. package/dist/global-skills/eas-simulator/SKILL.md +2 -2
  8. package/dist/global-skills/eas-simulator/references/run-your-app.md +2 -0
  9. package/dist/global-skills/eas-update/SKILL.md +2 -2
  10. package/dist/global-skills/eas-update-insights/SKILL.md +2 -2
  11. package/dist/global-skills/eas-workflows/SKILL.md +2 -2
  12. package/dist/global-skills/expo-animation/SKILL.md +2 -2
  13. package/dist/global-skills/expo-app-clip/SKILL.md +2 -2
  14. package/dist/global-skills/expo-brownfield/SKILL.md +2 -2
  15. package/dist/global-skills/expo-data-fetching/SKILL.md +2 -2
  16. package/dist/global-skills/expo-design-system/SKILL.md +2 -2
  17. package/dist/global-skills/expo-dev-client/SKILL.md +4 -2
  18. package/dist/global-skills/expo-dom/SKILL.md +2 -2
  19. package/dist/global-skills/expo-examples/SKILL.md +2 -2
  20. package/dist/global-skills/expo-migrate-module/SKILL.md +2 -2
  21. package/dist/global-skills/expo-module/SKILL.md +2 -2
  22. package/dist/global-skills/expo-native-ui/SKILL.md +2 -2
  23. package/dist/global-skills/expo-overview/SKILL.md +9 -4
  24. package/dist/global-skills/expo-overview/references/launch-without-dev-menu.md +24 -0
  25. package/dist/global-skills/expo-project-structure/SKILL.md +2 -2
  26. package/dist/global-skills/expo-router/SKILL.md +2 -2
  27. package/dist/global-skills/expo-ui/SKILL.md +2 -2
  28. package/dist/global-skills/expo-upgrade/SKILL.md +2 -2
  29. package/dist/global-skills/expo-web-to-native/SKILL.md +2 -2
  30. package/dist/global-skills/expo-web-to-native/references/verify-on-device.md +1 -1
  31. package/dist/global-skills/firebase-app-hosting-basics/SKILL.md +16 -3
  32. package/dist/global-skills/firebase-app-hosting-basics/references/cli_commands.md +10 -12
  33. package/dist/global-skills/firebase-app-hosting-basics/references/configuration.md +2 -1
  34. package/dist/global-skills/firebase-basics/SKILL.md +6 -4
  35. package/dist/global-skills/firebase-basics/references/web_setup.md +3 -3
  36. package/dist/global-skills/instrument-feature-flags/references/adding-feature-flag-code.md +81 -333
  37. package/dist/global-skills/instrument-feature-flags/references/android.md +19 -13
  38. package/dist/global-skills/instrument-feature-flags/references/api.md +17 -13
  39. package/dist/global-skills/instrument-feature-flags/references/best-practices.md +35 -35
  40. package/dist/global-skills/instrument-feature-flags/references/django.md +120 -72
  41. package/dist/global-skills/instrument-feature-flags/references/dotnet.md +48 -102
  42. package/dist/global-skills/instrument-feature-flags/references/elixir.md +4 -10
  43. package/dist/global-skills/instrument-feature-flags/references/flask.md +55 -39
  44. package/dist/global-skills/instrument-feature-flags/references/flutter.md +19 -13
  45. package/dist/global-skills/instrument-feature-flags/references/go.md +21 -13
  46. package/dist/global-skills/instrument-feature-flags/references/ios.md +19 -13
  47. package/dist/global-skills/instrument-feature-flags/references/java.md +4 -12
  48. package/dist/global-skills/instrument-feature-flags/references/laravel.md +18 -16
  49. package/dist/global-skills/instrument-feature-flags/references/next-js.md +44 -54
  50. package/dist/global-skills/instrument-feature-flags/references/nodejs.md +21 -13
  51. package/dist/global-skills/instrument-feature-flags/references/php.md +21 -13
  52. package/dist/global-skills/instrument-feature-flags/references/python.md +22 -14
  53. package/dist/global-skills/instrument-feature-flags/references/react-native.md +18 -13
  54. package/dist/global-skills/instrument-feature-flags/references/react.md +21 -14
  55. package/dist/global-skills/instrument-feature-flags/references/ruby-on-rails.md +31 -68
  56. package/dist/global-skills/instrument-feature-flags/references/ruby.md +21 -13
  57. package/dist/global-skills/instrument-feature-flags/references/rust.md +10 -34
  58. package/dist/global-skills/instrument-feature-flags/references/usage.md +94 -114
  59. package/dist/global-skills/instrument-feature-flags/references/web.md +21 -13
  60. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-android.md +7 -7
  61. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-expo.md +2 -2
  62. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-fastapi.md +1 -1
  63. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-flask.md +1 -1
  64. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-laravel.md +2 -2
  65. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-php.md +1 -1
  66. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-python.md +1 -1
  67. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-ruby.md +1 -1
  68. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-swift.md +4 -4
  69. package/dist/global-skills/instrument-product-analytics/references/android.md +64 -109
  70. package/dist/global-skills/instrument-product-analytics/references/angular.md +32 -28
  71. package/dist/global-skills/instrument-product-analytics/references/astro.md +29 -34
  72. package/dist/global-skills/instrument-product-analytics/references/configuration.md +27 -42
  73. package/dist/global-skills/instrument-product-analytics/references/django.md +120 -72
  74. package/dist/global-skills/instrument-product-analytics/references/dotnet.md +48 -102
  75. package/dist/global-skills/instrument-product-analytics/references/elixir.md +25 -50
  76. package/dist/global-skills/instrument-product-analytics/references/flask.md +55 -39
  77. package/dist/global-skills/instrument-product-analytics/references/flutter.md +94 -96
  78. package/dist/global-skills/instrument-product-analytics/references/go.md +39 -77
  79. package/dist/global-skills/instrument-product-analytics/references/identify-users.md +24 -26
  80. package/dist/global-skills/instrument-product-analytics/references/ios.md +22 -22
  81. package/dist/global-skills/instrument-product-analytics/references/laravel.md +18 -16
  82. package/dist/global-skills/instrument-product-analytics/references/next-js.md +44 -54
  83. package/dist/global-skills/instrument-product-analytics/references/nuxt-js-3-6.md +32 -34
  84. package/dist/global-skills/instrument-product-analytics/references/nuxt-js.md +36 -36
  85. package/dist/global-skills/instrument-product-analytics/references/php.md +42 -87
  86. package/dist/global-skills/instrument-product-analytics/references/posthog-python.md +15 -12
  87. package/dist/global-skills/instrument-product-analytics/references/python.md +106 -154
  88. package/dist/global-skills/instrument-product-analytics/references/react-native.md +97 -176
  89. package/dist/global-skills/instrument-product-analytics/references/react-router-v6.md +29 -40
  90. package/dist/global-skills/instrument-product-analytics/references/react-router-v7-data-mode.md +29 -38
  91. package/dist/global-skills/instrument-product-analytics/references/react-router-v7-declarative-mode.md +29 -40
  92. package/dist/global-skills/instrument-product-analytics/references/react-router-v7-framework-mode.md +32 -37
  93. package/dist/global-skills/instrument-product-analytics/references/ruby-on-rails.md +31 -68
  94. package/dist/global-skills/instrument-product-analytics/references/ruby.md +40 -96
  95. package/dist/global-skills/instrument-product-analytics/references/svelte.md +34 -34
  96. package/dist/global-skills/instrument-product-analytics/references/tanstack-start.md +19 -19
  97. package/dist/global-skills/instrument-product-analytics/references/usage.md +94 -114
  98. package/dist/global-skills/instrument-product-analytics/references/vue-js.md +33 -45
  99. package/dist/global-skills/mongodb-search-and-ai/SKILL.md +40 -22
  100. package/dist/global-skills/mongodb-search-and-ai/references/automated-embedding.md +8 -2
  101. package/dist/global-skills/mongodb-search-and-ai/references/quick-start.md +725 -0
  102. package/dist/global-skills/mongodb-search-and-ai/scripts/quickstart_complete.py +386 -0
  103. package/dist/global-skills/neon/references/claimable-neon.md +2 -0
  104. package/dist/global-skills/neon-realtime/references/queries.md +2 -2
  105. package/dist/global-skills/resend/SKILL.md +1 -1
  106. package/dist/global-skills/resend/references/inboxes.md +49 -21
  107. package/dist/global-skills/resend/references/webhooks.md +1 -1
  108. package/dist/global-skills/stripe-best-practices/SKILL.md +1 -1
  109. package/dist/global-skills/stripe-best-practices/references/connect.md +1 -1
  110. package/dist/global-skills/stripe-best-practices/references/security.md +9 -9
  111. package/dist/global-skills/vybekiitReferences/backend/AGENTS.md +1 -1
  112. package/dist/global-skills/vybekiitReferences/backend/agent/goal-routes.json +303 -18
  113. package/dist/global-skills/vybekiitReferences/extension/AGENTS.md +1 -1
  114. package/dist/global-skills/vybekiitReferences/extension/agent/goal-routes.json +352 -18
  115. package/dist/global-skills/vybekiitReferences/mobile/AGENTS.md +1 -1
  116. package/dist/global-skills/vybekiitReferences/mobile/agent/goal-routes.json +413 -22
  117. package/dist/global-skills/vybekiitReferences/spa/AGENTS.md +1 -1
  118. package/dist/global-skills/vybekiitReferences/spa/agent/goal-routes.json +391 -21
  119. package/dist/global-skills/vybekiitReferences/web/AGENTS.md +14 -2
  120. package/dist/global-skills/vybekiitReferences/web/agent/goal-routes.json +490 -32
  121. package/package.json +8 -8
@@ -2,14 +2,16 @@
2
2
 
3
3
  # Adding feature flag code
4
4
 
5
+ Canonical URL: https://posthog.com/docs/feature-flags/adding-feature-flag-code
6
+
7
+ > **Cloud region:** This page uses US Cloud hosts. For an EU Cloud project, use `https://eu.posthog.com` instead of `https://us.posthog.com` (app host for links).
8
+
5
9
  Once you've created your feature flag in PostHog, the next step is to add your code:
6
10
 
7
11
  ## Web
8
12
 
9
13
  ### Boolean feature flags
10
14
 
11
- Web
12
-
13
15
  ```javascript
14
16
  const result = posthog.getFeatureFlagResult('flag-key')
15
17
  if (result?.enabled) {
@@ -22,8 +24,6 @@ if (result?.enabled) {
22
24
 
23
25
  ### Multivariate feature flags
24
26
 
25
- Web
26
-
27
27
  ```javascript
28
28
  const result = posthog.getFeatureFlagResult('flag-key')
29
29
  if (result?.variant == 'variant-key') { // replace 'variant-key' with the key of your variant
@@ -38,8 +38,6 @@ if (result?.variant == 'variant-key') { // replace 'variant-key' with the key of
38
38
 
39
39
  You can inspect all currently loaded feature flags with `getAllFeatureFlags()`. It returns each flag's `key`, `enabled` state, `variant`, and `payload`, and does not send a `$feature_flag_called` event, so calling it won't affect your experiment results or flag usage analytics:
40
40
 
41
- Web
42
-
43
41
  ```javascript
44
42
  for (const flag of posthog.getAllFeatureFlags()) {
45
43
  console.log(flag.key, flag.enabled, flag.variant, flag.payload)
@@ -54,8 +52,6 @@ This means that for most pages, the feature flags are available immediately —
54
52
 
55
53
  To handle this, you can use the `onFeatureFlags` callback to wait for the feature flag request to finish:
56
54
 
57
- Web
58
-
59
55
  ```javascript
60
56
  posthog.onFeatureFlags(function (flags, flagVariants, { errorsLoading }) {
61
57
  // feature flags are guaranteed to be available at this point
@@ -81,8 +77,6 @@ You won't usually need to use these, but they are useful if you want to be extra
81
77
 
82
78
  By default, the JavaScript SDK requests that every eligible feature flag be evaluated for the current user. If you'd only like to evaluate and return a subset of flags, pass `flag_keys` when initializing PostHog:
83
79
 
84
- Web
85
-
86
80
  ```javascript
87
81
  posthog.init('<ph_project_token>', {
88
82
  api_host: 'https://us.i.posthog.com',
@@ -97,8 +91,6 @@ PostHog scopes evaluation and the response to those keys for this SDK instance.
97
91
 
98
92
  Feature flag values are cached. If something has changed with your user and you'd like to refetch their flag values, call:
99
93
 
100
- Web
101
-
102
94
  ```javascript
103
95
  posthog.reloadFeatureFlags()
104
96
  ```
@@ -107,8 +99,6 @@ posthog.reloadFeatureFlags()
107
99
 
108
100
  Sometimes, you might want to evaluate feature flags using properties that haven't been ingested yet, or were set incorrectly earlier. You can do so by setting properties the flag depends on with these calls:
109
101
 
110
- Web
111
-
112
102
  ```javascript
113
103
  posthog.setPersonPropertiesForFlags({'property1': 'value', property2: 'value2'})
114
104
  ```
@@ -117,23 +107,17 @@ posthog.setPersonPropertiesForFlags({'property1': 'value', property2: 'value2'})
117
107
 
118
108
  Whenever you set these properties, we also trigger a reload of feature flags to ensure we have the latest values. You can disable this by passing in the optional parameter for reloading:
119
109
 
120
- Web
121
-
122
110
  ```javascript
123
111
  posthog.setPersonPropertiesForFlags({'property1': 'value', property2: 'value2'}, false)
124
112
  ```
125
113
 
126
114
  At any point, you can reset these properties by calling `resetPersonPropertiesForFlags`:
127
115
 
128
- Web
129
-
130
116
  ```javascript
131
117
  posthog.resetPersonPropertiesForFlags()
132
118
  ```
133
119
 
134
- The same holds for [group](/manual/group-analytics.md) properties:
135
-
136
- Web
120
+ The same holds for [group](https://posthog.com/manual/group-analytics.md) properties:
137
121
 
138
122
  ```javascript
139
123
  // set properties for a group
@@ -172,8 +156,6 @@ This enables any geolocation-based flags to work without manually setting these
172
156
 
173
157
  You can configure the `feature_flag_request_timeout_ms` parameter when initializing your PostHog client to set a flag request timeout. This helps prevent your code from being blocked in the case when PostHog's servers are too slow to respond. By default, this is set at 3 seconds.
174
158
 
175
- JavaScript
176
-
177
159
  ```javascript
178
160
  posthog.init('<ph_project_token>', {
179
161
  api_host: 'https://us.i.posthog.com',
@@ -186,8 +168,6 @@ posthog.init('<ph_project_token>', {
186
168
 
187
169
  When using the PostHog SDK, it's important to handle potential errors that may occur during feature flag operations. Here's an example of how to wrap PostHog SDK methods in an error handler:
188
170
 
189
- JavaScript
190
-
191
171
  ```javascript
192
172
  function handleFeatureFlag(client, flagKey, distinctId) {
193
173
  try {
@@ -237,8 +217,6 @@ PostHog provides several hooks to make it easy to use feature flags in your Reac
237
217
 
238
218
  #### Example 1: Using a boolean feature flag
239
219
 
240
- React
241
-
242
220
  ```jsx
243
221
  import { useFeatureFlagEnabled, useFeatureFlagPayload } from '@posthog/react'
244
222
 
@@ -270,16 +248,12 @@ export default App;
270
248
 
271
249
  To avoid handling `undefined` while flags are loading, pass a default value as the second argument:
272
250
 
273
- React
274
-
275
251
  ```jsx
276
252
  const showWelcomeMessage = useFeatureFlagEnabled('flag-key', false)
277
253
  ```
278
254
 
279
255
  #### Example 2: Using a multivariate feature flag
280
256
 
281
- React
282
-
283
257
  ```jsx
284
258
  import { useFeatureFlagVariantKey } from '@posthog/react'
285
259
 
@@ -320,8 +294,6 @@ export default App;
320
294
 
321
295
  The `useFeatureFlagPayload` hook does *not* send a [`$feature_flag_called`](https://posthog.com/docs/experiments/new-experimentation-engine#experiment-exposure) event, which is required for the experiment to be tracked. To ensure the exposure event is sent, you should **always** use the `useFeatureFlagPayload` hook with either the `useFeatureFlagEnabled` or `useFeatureFlagVariantKey` hook.
322
296
 
323
- React
324
-
325
297
  ```jsx
326
298
  import { useFeatureFlagEnabled, useFeatureFlagPayload } from '@posthog/react'
327
299
 
@@ -353,12 +325,10 @@ The `PostHogFeature` component simplifies code by handling feature flag related
353
325
 
354
326
  It also automatically captures metrics, like how many times a user interacts with this feature.
355
327
 
356
- > **Note:** You still need the [`PostHogProvider`](/docs/libraries/react.md#installation) at the top level for this to work.
328
+ > **Note:** You still need the [`PostHogProvider`](https://posthog.com/docs/libraries/react.md#installation) at the top level for this to work.
357
329
 
358
330
  Here is an example:
359
331
 
360
- React
361
-
362
332
  ```jsx
363
333
  import { PostHogFeature } from '@posthog/react'
364
334
 
@@ -385,8 +355,6 @@ If you wish to customise logic around when the component is considered visible,
385
355
 
386
356
  If your flag has a payload, you can pass a function to children whose first argument is the payload. For example:
387
357
 
388
- React
389
-
390
358
  ```jsx
391
359
  import { PostHogFeature } from '@posthog/react'
392
360
 
@@ -411,8 +379,6 @@ function App() {
411
379
 
412
380
  You can configure the `feature_flag_request_timeout_ms` parameter when initializing your PostHog client to set a flag request timeout. This helps prevent your code from being blocked in the case when PostHog's servers are too slow to respond. By default, this is set at 3 seconds.
413
381
 
414
- JavaScript
415
-
416
382
  ```javascript
417
383
  posthog.init('<ph_project_token>', {
418
384
  api_host: 'https://us.i.posthog.com',
@@ -426,8 +392,6 @@ posthog.init('<ph_project_token>', {
426
392
 
427
393
  When using the PostHog SDK, it's important to handle potential errors that may occur during feature flag operations. Here's an example of how to wrap PostHog SDK methods in an error handler:
428
394
 
429
- JavaScript
430
-
431
395
  ```javascript
432
396
  function handleFeatureFlag(client, flagKey, distinctId) {
433
397
  try {
@@ -467,8 +431,6 @@ Call `client.evaluateFlags()` once for the user, then read values from the retur
467
431
 
468
432
  #### Boolean feature flags
469
433
 
470
- Node.js
471
-
472
434
  ```javascript
473
435
  const flags = await client.evaluateFlags('distinct_id_of_your_user')
474
436
 
@@ -481,8 +443,6 @@ if (flags.isEnabled('flag-key')) {
481
443
 
482
444
  #### Multivariate feature flags
483
445
 
484
- Node.js
485
-
486
446
  ```javascript
487
447
  const flags = await client.evaluateFlags('distinct_id_of_your_user')
488
448
  const enabledVariant = flags.getFlag('flag-key')
@@ -500,9 +460,9 @@ if (enabledVariant === 'variant-key') { // replace 'variant-key' with the key of
500
460
 
501
461
  ### Step 2: Include feature flag information when capturing events
502
462
 
503
- If you want use your feature flag to breakdown or filter events in your [insights](/docs/product-analytics/insights.md), you'll need to include feature flag information in those events. This ensures that the feature flag value is attributed correctly to the event.
463
+ If you want use your feature flag to breakdown or filter events in your [insights](https://posthog.com/docs/product-analytics/insights.md), you'll need to include feature flag information in those events. This ensures that the feature flag value is attributed correctly to the event.
504
464
 
505
- > **Note:** This step is only required for events captured using our server-side SDKs or [API](/docs/api.md).
465
+ > **Note:** This step is only required for events captured using our server-side SDKs or [API](https://posthog.com/docs/api.md).
506
466
 
507
467
  There are two methods you can use to include feature flag information in your events:
508
468
 
@@ -510,8 +470,6 @@ There are two methods you can use to include feature flag information in your ev
510
470
 
511
471
  Pass the same `flags` object that you used for branching. This attaches the exact flag values from that evaluation and doesn't make another `/flags` request.
512
472
 
513
- Node.js
514
-
515
473
  ```javascript
516
474
  const flags = await client.evaluateFlags('distinct_id_of_your_user')
517
475
 
@@ -530,8 +488,6 @@ By default, this attaches every flag in the snapshot using `$feature/<flag-key>`
530
488
 
531
489
  To reduce event property bloat, pass a filtered snapshot:
532
490
 
533
- Node.js
534
-
535
491
  ```javascript
536
492
  // Attach only flags accessed with isEnabled() or getFlag() before this call
537
493
  client.capture({
@@ -554,8 +510,6 @@ client.capture({
554
510
 
555
511
  In the event properties, include `$feature/feature_flag_name: variant_key`:
556
512
 
557
- Node.js
558
-
559
513
  ```javascript
560
514
  client.capture({
561
515
  distinctId: 'distinct_id_of_your_user',
@@ -571,8 +525,6 @@ client.capture({
571
525
 
572
526
  By default, `evaluateFlags()` evaluates every flag for the user. If you only need a few flags, pass `flagKeys` to request only those flags:
573
527
 
574
- Node.js
575
-
576
528
  ```javascript
577
529
  const flags = await client.evaluateFlags('distinct_id_of_your_user', {
578
530
  flagKeys: ['checkout-flow', 'new-dashboard'],
@@ -581,7 +533,7 @@ const flags = await client.evaluateFlags('distinct_id_of_your_user', {
581
533
 
582
534
  ### Sending `$feature_flag_called` events
583
535
 
584
- Capturing `$feature_flag_called` events enables PostHog to know when a flag was accessed by a user and provide [analytics and insights](/docs/product-analytics/insights.md) on the flag. With `evaluateFlags()`, the SDK sends this event when you call `flags.isEnabled()` or `flags.getFlag()` for a flag.
536
+ Capturing `$feature_flag_called` events enables PostHog to know when a flag was accessed by a user and provide [analytics and insights](https://posthog.com/docs/product-analytics/insights.md) on the flag. With `evaluateFlags()`, the SDK sends this event when you call `flags.isEnabled()` or `flags.getFlag()` for a flag.
585
537
 
586
538
  The SDK deduplicates these events per `(distinct_id, flag, value)` in a local cache. If you reinitialize the PostHog client, the cache resets and `$feature_flag_called` events may be sent again. PostHog handles duplicates, so duplicate `$feature_flag_called` events don't affect your analytics.
587
539
 
@@ -589,14 +541,12 @@ The SDK deduplicates these events per `(distinct_id, flag, value)` in a local ca
589
541
 
590
542
  ### Advanced: Overriding server properties
591
543
 
592
- Sometimes, you may want to evaluate feature flags using [person properties](/docs/product-analytics/person-properties.md), [groups](/docs/product-analytics/group-analytics.md), or group properties that haven't been ingested yet, or were set incorrectly earlier.
544
+ Sometimes, you may want to evaluate feature flags using [person properties](https://posthog.com/docs/product-analytics/person-properties.md), [groups](https://posthog.com/docs/product-analytics/group-analytics.md), or group properties that haven't been ingested yet, or were set incorrectly earlier.
593
545
 
594
546
  You can provide properties to evaluate the flag with by using the `person properties`, `groups`, and `group properties` arguments. PostHog will then use these values to evaluate the flag, instead of any properties currently stored on your PostHog server.
595
547
 
596
548
  For example:
597
549
 
598
- Node.js
599
-
600
550
  ```javascript
601
551
  const flags = await client.evaluateFlags('distinct_id_of_the_user', {
602
552
  personProperties: {
@@ -652,8 +602,6 @@ Simply include any of these properties in the `person_properties` parameter alon
652
602
 
653
603
  You can configure the `featureFlagsRequestTimeoutMs` parameter when initializing your PostHog client to set a flag request timeout. This helps prevent your code from being blocked if PostHog's servers are too slow to respond. By default, this is set to 3 seconds.
654
604
 
655
- JavaScript
656
-
657
605
  ```javascript
658
606
  const client = new PostHog('<ph_project_token>', {
659
607
  host: 'https://us.i.posthog.com',
@@ -671,8 +619,6 @@ Call `posthog.evaluate_flags()` once for the user, then read values from the ret
671
619
 
672
620
  #### Boolean feature flags
673
621
 
674
- Python
675
-
676
622
  ```python
677
623
  flags = posthog.evaluate_flags("distinct_id_of_your_user")
678
624
 
@@ -684,8 +630,6 @@ if flags.is_enabled("flag-key"):
684
630
 
685
631
  #### Multivariate feature flags
686
632
 
687
- Python
688
-
689
633
  ```python
690
634
  flags = posthog.evaluate_flags("distinct_id_of_your_user")
691
635
 
@@ -703,9 +647,9 @@ if enabled_variant == "variant-key": # replace "variant-key" with the key of yo
703
647
 
704
648
  ### Step 2: Include feature flag information when capturing events
705
649
 
706
- If you want use your feature flag to breakdown or filter events in your [insights](/docs/product-analytics/insights.md), you'll need to include feature flag information in those events. This ensures that the feature flag value is attributed correctly to the event.
650
+ If you want use your feature flag to breakdown or filter events in your [insights](https://posthog.com/docs/product-analytics/insights.md), you'll need to include feature flag information in those events. This ensures that the feature flag value is attributed correctly to the event.
707
651
 
708
- > **Note:** This step is only required for events captured using our server-side SDKs or [API](/docs/api.md).
652
+ > **Note:** This step is only required for events captured using our server-side SDKs or [API](https://posthog.com/docs/api.md).
709
653
 
710
654
  There are two methods you can use to include feature flag information in your events:
711
655
 
@@ -713,8 +657,6 @@ There are two methods you can use to include feature flag information in your ev
713
657
 
714
658
  Pass the same `flags` object that you used for branching. This attaches the exact flag values from that evaluation and doesn't make another `/flags` request.
715
659
 
716
- Python
717
-
718
660
  ```python
719
661
  flags = posthog.evaluate_flags("distinct_id_of_your_user")
720
662
 
@@ -733,8 +675,6 @@ By default, this attaches every flag in the snapshot using `$feature/<flag-key>`
733
675
 
734
676
  To reduce event property bloat, pass a filtered snapshot:
735
677
 
736
- Python
737
-
738
678
  ```python
739
679
  # Attach only flags accessed with is_enabled() or get_flag() before this call
740
680
  posthog.capture(
@@ -757,8 +697,6 @@ posthog.capture(
757
697
 
758
698
  In the event properties, include `$feature/feature_flag_name: variant_key`:
759
699
 
760
- Python
761
-
762
700
  ```python
763
701
  posthog.capture(
764
702
  "event_name",
@@ -774,8 +712,6 @@ posthog.capture(
774
712
 
775
713
  By default, `posthog.evaluate_flags()` evaluates every flag for the user. If you only need a few flags, pass `flag_keys` to request only those flags:
776
714
 
777
- Python
778
-
779
715
  ```python
780
716
  flags = posthog.evaluate_flags(
781
717
  "distinct_id_of_your_user",
@@ -785,7 +721,7 @@ flags = posthog.evaluate_flags(
785
721
 
786
722
  ### Sending `$feature_flag_called` events
787
723
 
788
- Capturing `$feature_flag_called` events enables PostHog to know when a flag was accessed by a user and provide [analytics and insights](/docs/product-analytics/insights.md) on the flag. With `posthog.evaluate_flags()`, the SDK sends this event when you call `flags.is_enabled()` or `flags.get_flag()` for a flag.
724
+ Capturing `$feature_flag_called` events enables PostHog to know when a flag was accessed by a user and provide [analytics and insights](https://posthog.com/docs/product-analytics/insights.md) on the flag. With `posthog.evaluate_flags()`, the SDK sends this event when you call `flags.is_enabled()` or `flags.get_flag()` for a flag.
789
725
 
790
726
  The SDK deduplicates these events per `(distinct_id, flag, value)` in a local cache. If you reinitialize the PostHog client, the cache resets and `$feature_flag_called` events may be sent again. PostHog handles duplicates, so duplicate `$feature_flag_called` events don't affect your analytics.
791
727
 
@@ -793,14 +729,12 @@ The SDK deduplicates these events per `(distinct_id, flag, value)` in a local ca
793
729
 
794
730
  ### Advanced: Overriding server properties
795
731
 
796
- Sometimes, you may want to evaluate feature flags using [person properties](/docs/product-analytics/person-properties.md), [groups](/docs/product-analytics/group-analytics.md), or group properties that haven't been ingested yet, or were set incorrectly earlier.
732
+ Sometimes, you may want to evaluate feature flags using [person properties](https://posthog.com/docs/product-analytics/person-properties.md), [groups](https://posthog.com/docs/product-analytics/group-analytics.md), or group properties that haven't been ingested yet, or were set incorrectly earlier.
797
733
 
798
734
  You can provide properties to evaluate the flag with by using the `person properties`, `groups`, and `group properties` arguments. PostHog will then use these values to evaluate the flag, instead of any properties currently stored on your PostHog server.
799
735
 
800
736
  For example:
801
737
 
802
- Python
803
-
804
738
  ```python
805
739
  flags = posthog.evaluate_flags(
806
740
  "distinct_id_of_the_user",
@@ -850,8 +784,6 @@ Simply include any of these properties in the `person_properties` parameter alon
850
784
 
851
785
  You can configure the `feature_flags_request_timeout_seconds` parameter when initializing your PostHog client to set a flag request timeout. This helps prevent your code from being blocked if PostHog's servers are too slow to respond. By default, this is set to 3 seconds.
852
786
 
853
- Python
854
-
855
787
  ```python
856
788
  posthog = Posthog(
857
789
  "<ph_project_token>",
@@ -870,8 +802,6 @@ Call `PostHog::evaluateFlags()` once for the user, then read values from the ret
870
802
 
871
803
  #### Boolean feature flags
872
804
 
873
- PHP
874
-
875
805
  ```php
876
806
  $flags = PostHog::evaluateFlags('distinct_id_of_your_user');
877
807
 
@@ -884,8 +814,6 @@ if ($flags->isEnabled('flag-key')) {
884
814
 
885
815
  #### Multivariate feature flags
886
816
 
887
- PHP
888
-
889
817
  ```php
890
818
  $flags = PostHog::evaluateFlags('distinct_id_of_your_user');
891
819
 
@@ -906,9 +834,9 @@ You can also call `$flags->getKeys()` to list the evaluated flag keys, or `$flag
906
834
 
907
835
  ### Step 2: Include feature flag information when capturing events
908
836
 
909
- If you want use your feature flag to breakdown or filter events in your [insights](/docs/product-analytics/insights.md), you'll need to include feature flag information in those events. This ensures that the feature flag value is attributed correctly to the event.
837
+ If you want use your feature flag to breakdown or filter events in your [insights](https://posthog.com/docs/product-analytics/insights.md), you'll need to include feature flag information in those events. This ensures that the feature flag value is attributed correctly to the event.
910
838
 
911
- > **Note:** This step is only required for events captured using our server-side SDKs or [API](/docs/api.md).
839
+ > **Note:** This step is only required for events captured using our server-side SDKs or [API](https://posthog.com/docs/api.md).
912
840
 
913
841
  There are two methods you can use to include feature flag information in your events:
914
842
 
@@ -916,8 +844,6 @@ There are two methods you can use to include feature flag information in your ev
916
844
 
917
845
  Pass the same `flags` object that you used for branching. This attaches the exact flag values from that evaluation and doesn't make another `/flags` request.
918
846
 
919
- PHP
920
-
921
847
  ```php
922
848
  $flags = PostHog::evaluateFlags('distinct_id_of_your_user');
923
849
 
@@ -936,8 +862,6 @@ By default, this attaches every flag in the snapshot using `$feature/<flag-key>`
936
862
 
937
863
  To reduce event property bloat, pass a filtered snapshot:
938
864
 
939
- PHP
940
-
941
865
  ```php
942
866
  // Attach only flags accessed with isEnabled() or getFlag() before this call
943
867
  PostHog::capture([
@@ -960,8 +884,6 @@ PostHog::capture([
960
884
 
961
885
  In the event properties, include `$feature/feature_flag_name: variant_key`:
962
886
 
963
- PHP
964
-
965
887
  ```php
966
888
  PostHog::capture([
967
889
  'distinctId' => 'distinct_id_of_your_user',
@@ -977,8 +899,6 @@ PostHog::capture([
977
899
 
978
900
  By default, `evaluateFlags()` evaluates every flag for the user. If you only need a few flags, pass `flagKeys` to request only those flags:
979
901
 
980
- PHP
981
-
982
902
  ```php
983
903
  $flags = PostHog::evaluateFlags(
984
904
  distinctId: 'distinct_id_of_your_user',
@@ -990,8 +910,6 @@ $flags = PostHog::evaluateFlags(
990
910
 
991
911
  `evaluateFlags()` also accepts optional parameters for local evaluation and GeoIP behavior:
992
912
 
993
- PHP
994
-
995
913
  ```php
996
914
  $flags = PostHog::evaluateFlags(
997
915
  distinctId: 'distinct_id_of_your_user',
@@ -1006,7 +924,7 @@ $flags = PostHog::evaluateFlags(
1006
924
 
1007
925
  ### Sending `$feature_flag_called` events
1008
926
 
1009
- Capturing `$feature_flag_called` events enables PostHog to know when a flag was accessed by a user and provide [analytics and insights](/docs/product-analytics/insights.md) on the flag. With `evaluateFlags()`, the SDK sends this event when you call `$flags->isEnabled()` or `$flags->getFlag()` for a flag.
927
+ Capturing `$feature_flag_called` events enables PostHog to know when a flag was accessed by a user and provide [analytics and insights](https://posthog.com/docs/product-analytics/insights.md) on the flag. With `evaluateFlags()`, the SDK sends this event when you call `$flags->isEnabled()` or `$flags->getFlag()` for a flag.
1010
928
 
1011
929
  The SDK deduplicates these events per `(flag key, distinct_id)` in a local cache. If you reinitialize the PostHog client, the cache resets and `$feature_flag_called` events may be sent again. PostHog handles duplicates, so duplicate `$feature_flag_called` events don't affect your analytics.
1012
930
 
@@ -1014,14 +932,12 @@ The SDK deduplicates these events per `(flag key, distinct_id)` in a local cache
1014
932
 
1015
933
  ### Advanced: Overriding server properties
1016
934
 
1017
- Sometimes, you may want to evaluate feature flags using [person properties](/docs/product-analytics/person-properties.md), [groups](/docs/product-analytics/group-analytics.md), or group properties that haven't been ingested yet, or were set incorrectly earlier.
935
+ Sometimes, you may want to evaluate feature flags using [person properties](https://posthog.com/docs/product-analytics/person-properties.md), [groups](https://posthog.com/docs/product-analytics/group-analytics.md), or group properties that haven't been ingested yet, or were set incorrectly earlier.
1018
936
 
1019
937
  You can provide properties to evaluate the flag with by using the `person properties`, `groups`, and `group properties` arguments. PostHog will then use these values to evaluate the flag, instead of any properties currently stored on your PostHog server.
1020
938
 
1021
939
  For example:
1022
940
 
1023
- PHP
1024
-
1025
941
  ```php
1026
942
  $flags = PostHog::evaluateFlags(
1027
943
  distinctId: 'distinct_id_of_the_user',
@@ -1072,8 +988,6 @@ Simply include any of these properties in the `person_properties` parameter alon
1072
988
 
1073
989
  You can configure the `feature_flag_request_timeout_ms` parameter when initializing your PostHog client to set a flag request timeout. This helps prevent your code from being blocked if PostHog's servers are too slow to respond. By default, this is set to 3 seconds.
1074
990
 
1075
- PHP
1076
-
1077
991
  ```php
1078
992
  PostHog::init("<ph_project_token>",
1079
993
  [
@@ -1093,8 +1007,6 @@ Call `posthog.evaluate_flags()` once for the user, then read values from the ret
1093
1007
 
1094
1008
  #### Boolean feature flags
1095
1009
 
1096
- Ruby
1097
-
1098
1010
  ```ruby
1099
1011
  flags = posthog.evaluate_flags('distinct_id_of_your_user')
1100
1012
 
@@ -1107,8 +1019,6 @@ end
1107
1019
 
1108
1020
  #### Multivariate feature flags
1109
1021
 
1110
- Ruby
1111
-
1112
1022
  ```ruby
1113
1023
  flags = posthog.evaluate_flags('distinct_id_of_your_user')
1114
1024
 
@@ -1127,9 +1037,9 @@ end
1127
1037
 
1128
1038
  ### Step 2: Include feature flag information when capturing events
1129
1039
 
1130
- If you want use your feature flag to breakdown or filter events in your [insights](/docs/product-analytics/insights.md), you'll need to include feature flag information in those events. This ensures that the feature flag value is attributed correctly to the event.
1040
+ If you want use your feature flag to breakdown or filter events in your [insights](https://posthog.com/docs/product-analytics/insights.md), you'll need to include feature flag information in those events. This ensures that the feature flag value is attributed correctly to the event.
1131
1041
 
1132
- > **Note:** This step is only required for events captured using our server-side SDKs or [API](/docs/api.md).
1042
+ > **Note:** This step is only required for events captured using our server-side SDKs or [API](https://posthog.com/docs/api.md).
1133
1043
 
1134
1044
  There are two methods you can use to include feature flag information in your events:
1135
1045
 
@@ -1137,8 +1047,6 @@ There are two methods you can use to include feature flag information in your ev
1137
1047
 
1138
1048
  Pass the same `flags` object that you used for branching. This attaches the exact flag values from that evaluation and doesn't make another `/flags` request.
1139
1049
 
1140
- Ruby
1141
-
1142
1050
  ```ruby
1143
1051
  flags = posthog.evaluate_flags('distinct_id_of_your_user')
1144
1052
 
@@ -1157,8 +1065,6 @@ By default, this attaches every flag in the snapshot using `$feature/<flag-key>`
1157
1065
 
1158
1066
  To reduce event property bloat, pass a filtered snapshot:
1159
1067
 
1160
- Ruby
1161
-
1162
1068
  ```ruby
1163
1069
  # Attach only flags accessed with enabled?() or get_flag() before this call
1164
1070
  posthog.capture({
@@ -1181,8 +1087,6 @@ posthog.capture({
1181
1087
 
1182
1088
  In the event properties, include `$feature/feature_flag_name: variant_key`:
1183
1089
 
1184
- Ruby
1185
-
1186
1090
  ```ruby
1187
1091
  posthog.capture({
1188
1092
  distinct_id: 'distinct_id_of_your_user',
@@ -1198,8 +1102,6 @@ posthog.capture({
1198
1102
 
1199
1103
  By default, `evaluate_flags()` evaluates every flag for the user. If you only need a few flags, pass `flag_keys` to request only those flags:
1200
1104
 
1201
- Ruby
1202
-
1203
1105
  ```ruby
1204
1106
  flags = posthog.evaluate_flags(
1205
1107
  'distinct_id_of_your_user',
@@ -1211,8 +1113,6 @@ flags = posthog.evaluate_flags(
1211
1113
 
1212
1114
  If you want to skip the remote `/flags` request and only use locally cached definitions, pass `only_evaluate_locally: true`:
1213
1115
 
1214
- Ruby
1215
-
1216
1116
  ```ruby
1217
1117
  flags = posthog.evaluate_flags(
1218
1118
  'distinct_id_of_your_user',
@@ -1224,8 +1124,6 @@ flags = posthog.evaluate_flags(
1224
1124
 
1225
1125
  Pass `disable_geoip: true` to disable GeoIP lookup for remote flag evaluation:
1226
1126
 
1227
- Ruby
1228
-
1229
1127
  ```ruby
1230
1128
  flags = posthog.evaluate_flags(
1231
1129
  'distinct_id_of_your_user',
@@ -1235,7 +1133,7 @@ flags = posthog.evaluate_flags(
1235
1133
 
1236
1134
  ### Sending `$feature_flag_called` events
1237
1135
 
1238
- Capturing `$feature_flag_called` events enables PostHog to know when a flag was accessed by a user and provide [analytics and insights](/docs/product-analytics/insights.md) on the flag. With `evaluate_flags()`, the SDK sends this event when you call `flags.enabled?()` or `flags.get_flag()` for a flag.
1136
+ Capturing `$feature_flag_called` events enables PostHog to know when a flag was accessed by a user and provide [analytics and insights](https://posthog.com/docs/product-analytics/insights.md) on the flag. With `evaluate_flags()`, the SDK sends this event when you call `flags.enabled?()` or `flags.get_flag()` for a flag.
1239
1137
 
1240
1138
  The SDK deduplicates these events per `(distinct_id, flag, value)` in a local cache. If you reinitialize the PostHog client, the cache resets and `$feature_flag_called` events may be sent again. PostHog handles duplicates, so duplicate `$feature_flag_called` events don't affect your analytics.
1241
1139
 
@@ -1243,14 +1141,12 @@ The SDK deduplicates these events per `(distinct_id, flag, value)` in a local ca
1243
1141
 
1244
1142
  ### Advanced: Overriding server properties
1245
1143
 
1246
- Sometimes, you may want to evaluate feature flags using [person properties](/docs/product-analytics/person-properties.md), [groups](/docs/product-analytics/group-analytics.md), or group properties that haven't been ingested yet, or were set incorrectly earlier.
1144
+ Sometimes, you may want to evaluate feature flags using [person properties](https://posthog.com/docs/product-analytics/person-properties.md), [groups](https://posthog.com/docs/product-analytics/group-analytics.md), or group properties that haven't been ingested yet, or were set incorrectly earlier.
1247
1145
 
1248
1146
  You can provide properties to evaluate the flag with by using the `person properties`, `groups`, and `group properties` arguments. PostHog will then use these values to evaluate the flag, instead of any properties currently stored on your PostHog server.
1249
1147
 
1250
1148
  For example:
1251
1149
 
1252
- Ruby
1253
-
1254
1150
  ```ruby
1255
1151
  flags = posthog.evaluate_flags(
1256
1152
  'distinct_id_of_the_user',
@@ -1307,8 +1203,6 @@ Simply include any of these properties in the `person_properties` parameter alon
1307
1203
 
1308
1204
  You can configure the `feature_flag_request_timeout_seconds` parameter when initializing your PostHog client to set a flag request timeout. This helps prevent your code from being blocked if PostHog's servers are too slow to respond. By default, this is set to 3 seconds.
1309
1205
 
1310
- Ruby
1311
-
1312
1206
  ```ruby
1313
1207
  posthog = PostHog::Client.new({
1314
1208
  # rest of your configuration...
@@ -1326,8 +1220,6 @@ Call `client.EvaluateFlags()` once for the user, then read values from the retur
1326
1220
 
1327
1221
  #### Boolean feature flags
1328
1222
 
1329
- Go
1330
-
1331
1223
  ```go
1332
1224
  flags, err := client.EvaluateFlags(posthog.EvaluateFlagsPayload{
1333
1225
  DistinctId: "distinct_id_of_your_user",
@@ -1345,8 +1237,6 @@ if flags.IsEnabled("flag-key") {
1345
1237
 
1346
1238
  #### Multivariate feature flags
1347
1239
 
1348
- Go
1349
-
1350
1240
  ```go
1351
1241
  flags, err := client.EvaluateFlags(posthog.EvaluateFlagsPayload{
1352
1242
  DistinctId: "distinct_id_of_your_user",
@@ -1370,9 +1260,9 @@ if enabledVariant == "variant-key" { // replace "variant-key" with the key of yo
1370
1260
 
1371
1261
  ### Step 2: Include feature flag information when capturing events
1372
1262
 
1373
- If you want use your feature flag to breakdown or filter events in your [insights](/docs/product-analytics/insights.md), you'll need to include feature flag information in those events. This ensures that the feature flag value is attributed correctly to the event.
1263
+ If you want use your feature flag to breakdown or filter events in your [insights](https://posthog.com/docs/product-analytics/insights.md), you'll need to include feature flag information in those events. This ensures that the feature flag value is attributed correctly to the event.
1374
1264
 
1375
- > **Note:** This step is only required for events captured using our server-side SDKs or [API](/docs/api.md).
1265
+ > **Note:** This step is only required for events captured using our server-side SDKs or [API](https://posthog.com/docs/api.md).
1376
1266
 
1377
1267
  There are two methods you can use to include feature flag information in your events:
1378
1268
 
@@ -1380,8 +1270,6 @@ There are two methods you can use to include feature flag information in your ev
1380
1270
 
1381
1271
  Pass the same `flags` object that you used for branching. This attaches the exact flag values from that evaluation and doesn't make another `/flags` request.
1382
1272
 
1383
- Go
1384
-
1385
1273
  ```go
1386
1274
  flags, err := client.EvaluateFlags(posthog.EvaluateFlagsPayload{
1387
1275
  DistinctId: "distinct_id_of_your_user",
@@ -1405,8 +1293,6 @@ By default, this attaches every flag in the snapshot using `$feature/<flag-key>`
1405
1293
 
1406
1294
  To reduce event property bloat, pass a filtered snapshot:
1407
1295
 
1408
- Go
1409
-
1410
1296
  ```go
1411
1297
  // Attach only flags accessed with IsEnabled() or GetFlag() before this call
1412
1298
  client.Enqueue(posthog.Capture{
@@ -1429,8 +1315,6 @@ client.Enqueue(posthog.Capture{
1429
1315
 
1430
1316
  In the event properties, include `$feature/feature_flag_name: variant_key`:
1431
1317
 
1432
- Go
1433
-
1434
1318
  ```go
1435
1319
  client.Enqueue(posthog.Capture{
1436
1320
  DistinctId: "distinct_id_of_your_user",
@@ -1444,8 +1328,6 @@ client.Enqueue(posthog.Capture{
1444
1328
 
1445
1329
  By default, `EvaluateFlags()` evaluates every flag for the user. If you only need a few flags, pass `FlagKeys` to request only those flags:
1446
1330
 
1447
- Go
1448
-
1449
1331
  ```go
1450
1332
  flags, err := client.EvaluateFlags(posthog.EvaluateFlagsPayload{
1451
1333
  DistinctId: "distinct_id_of_your_user",
@@ -1455,7 +1337,7 @@ flags, err := client.EvaluateFlags(posthog.EvaluateFlagsPayload{
1455
1337
 
1456
1338
  ### Sending `$feature_flag_called` events
1457
1339
 
1458
- Capturing `$feature_flag_called` events enables PostHog to know when a flag was accessed by a user and provide [analytics and insights](/docs/product-analytics/insights.md) on the flag. With `EvaluateFlags()`, the SDK sends this event when you call `flags.IsEnabled()` or `flags.GetFlag()` for a flag.
1340
+ Capturing `$feature_flag_called` events enables PostHog to know when a flag was accessed by a user and provide [analytics and insights](https://posthog.com/docs/product-analytics/insights.md) on the flag. With `EvaluateFlags()`, the SDK sends this event when you call `flags.IsEnabled()` or `flags.GetFlag()` for a flag.
1459
1341
 
1460
1342
  The SDK deduplicates these events per `(distinct_id, flag, value)` in a local cache. If you reinitialize the PostHog client, the cache resets and `$feature_flag_called` events may be sent again. PostHog handles duplicates, so duplicate `$feature_flag_called` events don't affect your analytics.
1461
1343
 
@@ -1463,14 +1345,12 @@ The SDK deduplicates these events per `(distinct_id, flag, value)` in a local ca
1463
1345
 
1464
1346
  ### Advanced: Overriding server properties
1465
1347
 
1466
- Sometimes, you may want to evaluate feature flags using [person properties](/docs/product-analytics/person-properties.md), [groups](/docs/product-analytics/group-analytics.md), or group properties that haven't been ingested yet, or were set incorrectly earlier.
1348
+ Sometimes, you may want to evaluate feature flags using [person properties](https://posthog.com/docs/product-analytics/person-properties.md), [groups](https://posthog.com/docs/product-analytics/group-analytics.md), or group properties that haven't been ingested yet, or were set incorrectly earlier.
1467
1349
 
1468
1350
  You can provide properties to evaluate the flag with by using the `person properties`, `groups`, and `group properties` arguments. PostHog will then use these values to evaluate the flag, instead of any properties currently stored on your PostHog server.
1469
1351
 
1470
1352
  For example:
1471
1353
 
1472
- Go
1473
-
1474
1354
  ```go
1475
1355
  flags, err := client.EvaluateFlags(posthog.EvaluateFlagsPayload{
1476
1356
  DistinctId: "distinct_id_of_the_user",
@@ -1526,8 +1406,6 @@ Simply include any of these properties in the `person_properties` parameter alon
1526
1406
 
1527
1407
  You can configure the `FeatureFlagRequestTimeout` parameter when initializing your PostHog client to set a flag request timeout. This helps prevent your code from being blocked if PostHog's servers are too slow to respond. By default, this is set to 3 seconds.
1528
1408
 
1529
- Go
1530
-
1531
1409
  ```go
1532
1410
  // import "time"
1533
1411
 
@@ -1552,8 +1430,6 @@ There are two ways to implement feature flags in React Native:
1552
1430
 
1553
1431
  #### Example 1: Boolean feature flags
1554
1432
 
1555
- React Native
1556
-
1557
1433
  ```jsx
1558
1434
  import { useFeatureFlag } from 'posthog-react-native'
1559
1435
 
@@ -1573,8 +1449,6 @@ const MyComponent = () => {
1573
1449
 
1574
1450
  #### Example 2: Multivariate feature flags
1575
1451
 
1576
- React Native
1577
-
1578
1452
  ```jsx
1579
1453
  import { useFeatureFlag } from 'posthog-react-native'
1580
1454
 
@@ -1596,8 +1470,6 @@ const MyComponent = () => {
1596
1470
 
1597
1471
  ### Method 2: Loading the flag directly
1598
1472
 
1599
- React Native
1600
-
1601
1473
  ```jsx
1602
1474
  // Defaults to undefined if not loaded yet or if there was a problem loading
1603
1475
  posthog.isFeatureEnabled('key-for-your-boolean-flag')
@@ -1616,8 +1488,6 @@ posthog.getFeatureFlagResult('key-for-your-multivariate-flag')?.payload
1616
1488
 
1617
1489
  You can inspect all currently loaded feature flags with `getAllFeatureFlags()`. It returns each flag's `key`, `enabled` state, `variant`, and `payload`, and does not send a `$feature_flag_called` event, so calling it won't affect your experiment results or flag usage analytics:
1618
1490
 
1619
- React Native
1620
-
1621
1491
  ```jsx
1622
1492
  for (const flag of posthog.getAllFeatureFlags()) {
1623
1493
  console.log(flag.key, flag.enabled, flag.variant, flag.payload)
@@ -1632,8 +1502,6 @@ This means that for most screens, the feature flags are available immediately
1632
1502
 
1633
1503
  To handle this, you can use the `onFeatureFlags` callback to wait for the feature flag request to finish:
1634
1504
 
1635
- React Native
1636
-
1637
1505
  ```jsx
1638
1506
  posthog.onFeatureFlags((flags) => {
1639
1507
  // feature flags are guaranteed to be available at this point
@@ -1649,16 +1517,12 @@ PostHog loads feature flags when instantiated and refreshes whenever methods are
1649
1517
 
1650
1518
  If want to manually trigger a refresh, you can call `reloadFeatureFlagsAsync()`:
1651
1519
 
1652
- React Native
1653
-
1654
1520
  ```jsx
1655
1521
  posthog.reloadFeatureFlagsAsync().then((refreshedFlags) => console.log(refreshedFlags))
1656
1522
  ```
1657
1523
 
1658
1524
  Or when you want to trigger the reload, but don't care about the result:
1659
1525
 
1660
- React Native
1661
-
1662
1526
  ```jsx
1663
1527
  posthog.reloadFeatureFlags()
1664
1528
  ```
@@ -1671,8 +1535,6 @@ For example, if a user last opened your app when a flag was `false`, that value
1671
1535
 
1672
1536
  To ensure fresh flag values:
1673
1537
 
1674
- React Native
1675
-
1676
1538
  ```jsx
1677
1539
  // Force refresh on app start
1678
1540
  await posthog.reloadFeatureFlagsAsync()
@@ -1680,8 +1542,6 @@ await posthog.reloadFeatureFlagsAsync()
1680
1542
 
1681
1543
  Or clear cached values for inactive users:
1682
1544
 
1683
- React Native
1684
-
1685
1545
  ```jsx
1686
1546
  if (lastActiveDate < migrationDate) {
1687
1547
  posthog.reset() // Clears all cached data
@@ -1692,8 +1552,6 @@ if (lastActiveDate < migrationDate) {
1692
1552
 
1693
1553
  You can configure the `featureFlagsRequestTimeoutMs` parameter when initializing your PostHog client to set a flag request timeout. This helps prevent your code from being blocked in the case when PostHog's servers are too slow to respond. By default, this is set at 10 seconds.
1694
1554
 
1695
- React Native
1696
-
1697
1555
  ```jsx
1698
1556
  export const posthog = new PostHog('<ph_project_token>', {
1699
1557
  // usually 'https://us.i.posthog.com' or 'https://eu.i.posthog.com'
@@ -1706,8 +1564,6 @@ export const posthog = new PostHog('<ph_project_token>', {
1706
1564
 
1707
1565
  When using the PostHog SDK, it's important to handle potential errors that may occur during feature flag operations. Here's an example of how to wrap PostHog SDK methods in an error handler:
1708
1566
 
1709
- React Native
1710
-
1711
1567
  ```jsx
1712
1568
  function handleFeatureFlag(client, flagKey, distinctId) {
1713
1569
  try {
@@ -1741,8 +1597,6 @@ try {
1741
1597
 
1742
1598
  Sometimes, you might want to evaluate feature flags using properties that haven't been ingested yet, or were set incorrectly earlier. You can do so by setting properties the flag depends on with these calls:
1743
1599
 
1744
- React Native
1745
-
1746
1600
  ```jsx
1747
1601
  posthog.setPersonPropertiesForFlags({'property1': 'value', property2: 'value2'})
1748
1602
  ```
@@ -1751,23 +1605,17 @@ Note that these are set for the entire session. Successive calls are additive: a
1751
1605
 
1752
1606
  Whenever you set these properties, we also trigger a reload of feature flags to ensure we have the latest values. You can disable this by passing in the optional parameter for reloading:
1753
1607
 
1754
- React Native
1755
-
1756
1608
  ```jsx
1757
1609
  posthog.setPersonPropertiesForFlags({'property1': 'value', property2: 'value2'}, false)
1758
1610
  ```
1759
1611
 
1760
1612
  At any point, you can reset these properties by calling `resetPersonPropertiesForFlags`:
1761
1613
 
1762
- React Native
1763
-
1764
1614
  ```jsx
1765
1615
  posthog.resetPersonPropertiesForFlags()
1766
1616
  ```
1767
1617
 
1768
- The same holds for [group](/docs/product-analytics/group-analytics.md) properties:
1769
-
1770
- React Native
1618
+ The same holds for [group](https://posthog.com/docs/product-analytics/group-analytics.md) properties:
1771
1619
 
1772
1620
  ```jsx
1773
1621
  // set properties for a group
@@ -1803,8 +1651,6 @@ This enables any geolocation-based flags to work without manually setting these
1803
1651
 
1804
1652
  ### Boolean feature flags
1805
1653
 
1806
- Kotlin
1807
-
1808
1654
  ```kotlin
1809
1655
  import com.posthog.PostHog
1810
1656
 
@@ -1819,8 +1665,6 @@ if (result?.enabled == true) {
1819
1665
 
1820
1666
  ### Multivariate feature flags
1821
1667
 
1822
- Kotlin
1823
-
1824
1668
  ```kotlin
1825
1669
  import com.posthog.PostHog
1826
1670
 
@@ -1837,8 +1681,6 @@ if (result?.variant == "variant-key") { // replace "variant-key" with the key of
1837
1681
 
1838
1682
  You can inspect all currently loaded feature flags with `PostHog.getAllFeatureFlags()`. It returns each flag's `key`, `enabled` state, `variant`, and `payload`, and does not send a `$feature_flag_called` event, so calling it won't affect your experiment results or flag usage analytics:
1839
1683
 
1840
- Kotlin
1841
-
1842
1684
  ```kotlin
1843
1685
  import com.posthog.PostHog
1844
1686
 
@@ -1855,8 +1697,6 @@ This means that for most screens, the feature flags are available immediately
1855
1697
 
1856
1698
  To handle this, you can use the `onFeatureFlags` callback to wait for the feature flag request to finish:
1857
1699
 
1858
- Kotlin
1859
-
1860
1700
  ```kotlin
1861
1701
  import com.posthog.PostHog
1862
1702
  import com.posthog.android.PostHogAndroidConfig
@@ -1883,8 +1723,6 @@ PostHog.reloadFeatureFlags {
1883
1723
 
1884
1724
  Feature flag values are cached. If something has changed with your user and you'd like to refetch their flag values, call:
1885
1725
 
1886
- Kotlin
1887
-
1888
1726
  ```kotlin
1889
1727
  import com.posthog.PostHog
1890
1728
 
@@ -1895,8 +1733,6 @@ PostHog.reloadFeatureFlags()
1895
1733
 
1896
1734
  To track when someone sees or interacts with a feature, use `captureFeatureView` and `captureFeatureInteraction`.
1897
1735
 
1898
- Kotlin
1899
-
1900
1736
  ```kotlin
1901
1737
  import com.posthog.PostHog
1902
1738
 
@@ -1908,8 +1744,6 @@ PostHog.captureFeatureInteraction("flag-key", flagVariant = "variant-key")
1908
1744
 
1909
1745
  ### Boolean feature flags
1910
1746
 
1911
- Swift
1912
-
1913
1747
  ```swift
1914
1748
  if let result = PostHogSDK.shared.getFeatureFlagResult("flag-key"), result.enabled {
1915
1749
  // Do something differently for this user
@@ -1921,8 +1755,6 @@ if let result = PostHogSDK.shared.getFeatureFlagResult("flag-key"), result.enabl
1921
1755
 
1922
1756
  ### Multivariate feature flags
1923
1757
 
1924
- Swift
1925
-
1926
1758
  ```swift
1927
1759
  if let result = PostHogSDK.shared.getFeatureFlagResult("flag-key"), result.variant == "variant-key" { // replace "variant-key" with the key of your variant
1928
1760
  // Do something differently for this user
@@ -1936,8 +1768,6 @@ if let result = PostHogSDK.shared.getFeatureFlagResult("flag-key"), result.varia
1936
1768
 
1937
1769
  If your payload is a JSON object, you can decode it into a `Decodable` type:
1938
1770
 
1939
- Swift
1940
-
1941
1771
  ```swift
1942
1772
  struct FlagPayload: Decodable {
1943
1773
  let title: String
@@ -1953,8 +1783,6 @@ if let result = PostHogSDK.shared.getFeatureFlagResult("flag-key"),
1953
1783
 
1954
1784
  You can inspect all currently loaded feature flags with `getAllFeatureFlags()`. It returns each flag's `key`, `enabled` state, `variant`, and `payload`, and does not send a `$feature_flag_called` event, so calling it won't affect your experiment results or flag usage analytics:
1955
1785
 
1956
- Swift
1957
-
1958
1786
  ```swift
1959
1787
  for flag in PostHogSDK.shared.getAllFeatureFlags() ?? [] {
1960
1788
  print(flag.key, flag.enabled, flag.variant as Any, flag.payload as Any)
@@ -1965,8 +1793,6 @@ for flag in PostHogSDK.shared.getAllFeatureFlags() ?? [] {
1965
1793
 
1966
1794
  Feature flag values are cached. If something has changed with your user and you'd like to refetch their flag values, call:
1967
1795
 
1968
- Swift
1969
-
1970
1796
  ```swift
1971
1797
  PostHogSDK.shared.reloadFeatureFlags()
1972
1798
  ```
@@ -1977,43 +1803,55 @@ Every time a user opens the app, we send a request in the background to fetch th
1977
1803
 
1978
1804
  This means that for most screens, the feature flags are available immediately – **except for the first time a user visits**.
1979
1805
 
1980
- To handle this, you can use the `didReceiveFeatureFlags` notification to wait for the feature flag request to finish:
1981
-
1982
- Swift
1806
+ To handle this, you can use the `onFeatureFlags` callback to be notified when flags are loaded or change. It's available in version 3.89.0+:
1983
1807
 
1984
1808
  ```swift
1985
- class AppDelegate: NSObject, UIApplicationDelegate {
1986
- func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
1987
- // register for `didReceiveFeatureFlags` notification before SDK initialization
1988
- NotificationCenter.default.addObserver(
1989
- self,
1990
- selector: #selector(receiveFeatureFlags),
1991
- name: PostHogSDK.didReceiveFeatureFlags,
1992
- object: nil
1993
- )
1809
+ let subscription = PostHogSDK.shared.onFeatureFlags { loaded in
1810
+ if loaded.errorsLoading {
1811
+ // Loading failed, so the flags are the last known values, which can be empty.
1812
+ // Fall back to your default experience if you need fresh values.
1813
+ return
1814
+ }
1815
+ if PostHogSDK.shared.isFeatureEnabled("flag-key") {
1816
+ // do something
1817
+ }
1818
+ }
1994
1819
 
1995
- let POSTHOG_PROJECT_TOKEN = "<ph_project_token>"
1996
- // usually 'https://us.i.posthog.com' or 'https://eu.i.posthog.com'
1997
- let POSTHOG_HOST = "https://us.i.posthog.com"
1820
+ // Later, to stop receiving updates
1821
+ subscription.unsubscribe()
1822
+ ```
1998
1823
 
1999
- let config = PostHogConfig(projectToken: POSTHOG_PROJECT_TOKEN, host: POSTHOG_HOST)
1824
+ The callback runs on the main thread. It's called when flags load – including from [bootstrap values](https://posthog.com/docs/feature-flags/bootstrapping.md) – and again each time they're reloaded, for example after `reloadFeatureFlags()`, `reset()`, or an `identify()` or `group()` call that changes the distinct ID or group. A reload doesn't have to change any values, so treat each call as "flags may have changed". If flags have already loaded when you register, it's called shortly afterwards with the current values. You can register before calling `setup()`.
2000
1825
 
2001
- PostHogSDK.shared.setup(config)
1826
+ #### Callback parameters
2002
1827
 
2003
- return true
2004
- }
1828
+ The callback receives a `PostHogFeatureFlagsLoaded` object with the following properties:
1829
+
1830
+ - `flags: [String]`: The keys of the enabled feature flags.
1831
+
1832
+ - `variants: [String: Any]`: The values of the enabled feature flags, keyed by flag key. A value is `true` for an enabled boolean flag, or the variant key for a multivariate flag.
2005
1833
 
2006
- // The "receiveFeatureFlags" method will be called when the SDK receives the feature flags from the server.
2007
- @objc func receiveFeatureFlags() {
2008
- print("receiveFeatureFlags called")
1834
+ - `errorsLoading: Bool`: `true` if the latest attempt to load feature flags failed, for example because the device is offline. The flags and variants then hold the last known values, which can be empty – for example, on a fresh install with no [bootstrap values](https://posthog.com/docs/feature-flags/bootstrapping.md). In that case, `isFeatureEnabled` returns `false` because the flag is unknown, not because PostHog evaluated it as disabled.
1835
+
1836
+ On versions earlier than 3.89.0, observe the `PostHogSDK.didReceiveFeatureFlags` notification instead. Register the observer before calling `setup()`:
1837
+
1838
+ ```swift
1839
+ let observer = NotificationCenter.default.addObserver(
1840
+ forName: PostHogSDK.didReceiveFeatureFlags,
1841
+ object: nil,
1842
+ queue: .main
1843
+ ) { _ in
1844
+ if PostHogSDK.shared.isFeatureEnabled("flag-key") {
1845
+ // do something
2009
1846
  }
2010
1847
  }
1848
+
1849
+ // Later, to stop receiving updates
1850
+ NotificationCenter.default.removeObserver(observer)
2011
1851
  ```
2012
1852
 
2013
1853
  Alternatively, you can use the completion block of the `reloadFeatureFlags(_:)` method. This allows you to execute logic immediately after the flags are reloaded:
2014
1854
 
2015
- Swift
2016
-
2017
1855
  ```swift
2018
1856
  // Reload feature flags and check if a specific feature is enabled
2019
1857
  PostHogSDK.shared.reloadFeatureFlags {
@@ -2027,8 +1865,6 @@ PostHogSDK.shared.reloadFeatureFlags {
2027
1865
 
2028
1866
  To track when someone sees or interacts with a feature, use `captureFeatureView` and `captureFeatureInteraction`.
2029
1867
 
2030
- Swift
2031
-
2032
1868
  ```swift
2033
1869
  PostHogSDK.shared.captureFeatureView(flag: "flag-key", flagVariant: "variant-key")
2034
1870
  PostHogSDK.shared.captureFeatureInteraction(flag: "flag-key", flagVariant: "variant-key")
@@ -2038,8 +1874,6 @@ PostHogSDK.shared.captureFeatureInteraction(flag: "flag-key", flagVariant: "vari
2038
1874
 
2039
1875
  ### Boolean feature flags
2040
1876
 
2041
- Dart
2042
-
2043
1877
  ```dart
2044
1878
  final result = await Posthog().getFeatureFlagResult('flag-key');
2045
1879
  if (result != null && result.enabled) {
@@ -2052,8 +1886,6 @@ if (result != null && result.enabled) {
2052
1886
 
2053
1887
  ### Multivariate feature flags
2054
1888
 
2055
- Dart
2056
-
2057
1889
  ```dart
2058
1890
  final result = await Posthog().getFeatureFlagResult('flag-key');
2059
1891
  if (result != null && result.variant == 'variant-key') { // replace 'variant-key' with the key of your variant
@@ -2074,8 +1906,6 @@ This means that for most screens, the feature flags are available immediately
2074
1906
 
2075
1907
  To handle this, you can use the `onFeatureFlags` callback in your config to be notified when flags are loaded:
2076
1908
 
2077
- Dart
2078
-
2079
1909
  ```dart
2080
1910
  final config = PostHogConfig('<ph_project_token>');
2081
1911
  config.host = 'https://us.i.posthog.com';
@@ -2091,8 +1921,6 @@ await Posthog().setup(config);
2091
1921
 
2092
1922
  Feature flag values are cached. If something has changed with your user and you'd like to refetch their flag values, call:
2093
1923
 
2094
- Dart
2095
-
2096
1924
  ```dart
2097
1925
  await Posthog().reloadFeatureFlags();
2098
1926
  ```
@@ -2107,8 +1935,6 @@ Call `posthog.evaluateFlags()` once for the user, then read values from the retu
2107
1935
 
2108
1936
  #### Boolean feature flags
2109
1937
 
2110
- Java
2111
-
2112
1938
  ```java
2113
1939
  PostHogFeatureFlagEvaluations flags = posthog.evaluateFlags("distinct_id_of_your_user");
2114
1940
 
@@ -2122,8 +1948,6 @@ if (flags.isEnabled("flag-key")) {
2122
1948
 
2123
1949
  #### Multivariate feature flags
2124
1950
 
2125
- Java
2126
-
2127
1951
  ```java
2128
1952
  PostHogFeatureFlagEvaluations flags = posthog.evaluateFlags("distinct_id_of_your_user");
2129
1953
 
@@ -2144,9 +1968,9 @@ if ("variant-key".equals(enabledVariant)) { // replace "variant-key" with the ke
2144
1968
 
2145
1969
  ### Step 2: Include feature flag information when capturing events
2146
1970
 
2147
- If you want use your feature flag to breakdown or filter events in your [insights](/docs/product-analytics/insights.md), you'll need to include feature flag information in those events. This ensures that the feature flag value is attributed correctly to the event.
1971
+ If you want use your feature flag to breakdown or filter events in your [insights](https://posthog.com/docs/product-analytics/insights.md), you'll need to include feature flag information in those events. This ensures that the feature flag value is attributed correctly to the event.
2148
1972
 
2149
- > **Note:** This step is only required for events captured using our server-side SDKs or [API](/docs/api.md).
1973
+ > **Note:** This step is only required for events captured using our server-side SDKs or [API](https://posthog.com/docs/api.md).
2150
1974
 
2151
1975
  There are two methods you can use to include feature flag information in your events:
2152
1976
 
@@ -2154,8 +1978,6 @@ There are two methods you can use to include feature flag information in your ev
2154
1978
 
2155
1979
  Pass the same `flags` object that you used for branching. This attaches the exact flag values from that evaluation and doesn't make another `/flags` request.
2156
1980
 
2157
- Java
2158
-
2159
1981
  ```java
2160
1982
  PostHogFeatureFlagEvaluations flags = posthog.evaluateFlags("distinct_id_of_your_user");
2161
1983
 
@@ -2176,8 +1998,6 @@ By default, this attaches every flag in the snapshot using `$feature/<flag-key>`
2176
1998
 
2177
1999
  To reduce event property bloat, pass a filtered snapshot:
2178
2000
 
2179
- Java
2180
-
2181
2001
  ```java
2182
2002
  // Attach only flags accessed with isEnabled() or getFlag() before this call
2183
2003
  posthog.capture(
@@ -2204,8 +2024,6 @@ posthog.capture(
2204
2024
 
2205
2025
  In the event properties, include `$feature/feature_flag_name: variant_key`:
2206
2026
 
2207
- Java
2208
-
2209
2027
  ```java
2210
2028
  posthog.capture(
2211
2029
  "distinct_id_of_your_user",
@@ -2220,8 +2038,6 @@ posthog.capture(
2220
2038
 
2221
2039
  By default, `evaluateFlags()` evaluates every flag for the user. If you only need a few flags, pass `flagKeys` to request only those flags:
2222
2040
 
2223
- Java
2224
-
2225
2041
  ```java
2226
2042
  import java.util.Arrays;
2227
2043
 
@@ -2235,7 +2051,7 @@ PostHogFeatureFlagEvaluations flags = posthog.evaluateFlags(
2235
2051
 
2236
2052
  ### Sending `$feature_flag_called` events
2237
2053
 
2238
- Capturing `$feature_flag_called` events enables PostHog to know when a flag was accessed by a user and provide [analytics and insights](/docs/product-analytics/insights.md) on the flag. With `evaluateFlags()`, the SDK sends this event when you call `flags.isEnabled()` or `flags.getFlag()` for a flag.
2054
+ Capturing `$feature_flag_called` events enables PostHog to know when a flag was accessed by a user and provide [analytics and insights](https://posthog.com/docs/product-analytics/insights.md) on the flag. With `evaluateFlags()`, the SDK sends this event when you call `flags.isEnabled()` or `flags.getFlag()` for a flag.
2239
2055
 
2240
2056
  The SDK deduplicates these events per `(distinct_id, flag, value)` in a local cache. If you reinitialize the PostHog client, the cache resets and `$feature_flag_called` events may be sent again. PostHog handles duplicates, so duplicate `$feature_flag_called` events don't affect your analytics.
2241
2057
 
@@ -2243,14 +2059,12 @@ The SDK deduplicates these events per `(distinct_id, flag, value)` in a local ca
2243
2059
 
2244
2060
  ### Advanced: Overriding server properties
2245
2061
 
2246
- Sometimes, you may want to evaluate feature flags using [person properties](/docs/product-analytics/person-properties.md), [groups](/docs/product-analytics/group-analytics.md), or group properties that haven't been ingested yet, or were set incorrectly earlier.
2062
+ Sometimes, you may want to evaluate feature flags using [person properties](https://posthog.com/docs/product-analytics/person-properties.md), [groups](https://posthog.com/docs/product-analytics/group-analytics.md), or group properties that haven't been ingested yet, or were set incorrectly earlier.
2247
2063
 
2248
2064
  You can provide properties to evaluate the flag with by using the `person properties`, `groups`, and `group properties` arguments. PostHog will then use these values to evaluate the flag, instead of any properties currently stored on your PostHog server.
2249
2065
 
2250
2066
  For example:
2251
2067
 
2252
- Java
2253
-
2254
2068
  ```java
2255
2069
  import com.posthog.server.PostHogEvaluateFlagsOptions;
2256
2070
 
@@ -2307,8 +2121,6 @@ Call `client.evaluate_flags()` once for the user, then read values from the retu
2307
2121
 
2308
2122
  #### Boolean feature flags
2309
2123
 
2310
- Rust
2311
-
2312
2124
  ```rust
2313
2125
  use posthog_rs::EvaluateFlagsOptions;
2314
2126
 
@@ -2326,8 +2138,6 @@ if flags.is_enabled("flag-key") {
2326
2138
 
2327
2139
  #### Multivariate feature flags
2328
2140
 
2329
- Rust
2330
-
2331
2141
  ```rust
2332
2142
  use posthog_rs::{EvaluateFlagsOptions, FlagValue};
2333
2143
 
@@ -2352,9 +2162,9 @@ match flags.get_flag("flag-key") {
2352
2162
 
2353
2163
  ### Step 2: Include feature flag information when capturing events
2354
2164
 
2355
- If you want use your feature flag to breakdown or filter events in your [insights](/docs/product-analytics/insights.md), you'll need to include feature flag information in those events. This ensures that the feature flag value is attributed correctly to the event.
2165
+ If you want use your feature flag to breakdown or filter events in your [insights](https://posthog.com/docs/product-analytics/insights.md), you'll need to include feature flag information in those events. This ensures that the feature flag value is attributed correctly to the event.
2356
2166
 
2357
- > **Note:** This step is only required for events captured using our server-side SDKs or [API](/docs/api.md).
2167
+ > **Note:** This step is only required for events captured using our server-side SDKs or [API](https://posthog.com/docs/api.md).
2358
2168
 
2359
2169
  There are two methods you can use to include feature flag information in your events:
2360
2170
 
@@ -2362,8 +2172,6 @@ There are two methods you can use to include feature flag information in your ev
2362
2172
 
2363
2173
  Pass the same `flags` object that you used for branching. This attaches the exact flag values from that evaluation and doesn't make another `/flags` request.
2364
2174
 
2365
- Rust
2366
-
2367
2175
  ```rust
2368
2176
  use posthog_rs::{EvaluateFlagsOptions, Event};
2369
2177
 
@@ -2385,8 +2193,6 @@ By default, this attaches every flag in the snapshot using `$feature/<flag-key>`
2385
2193
 
2386
2194
  To reduce event property bloat, pass a filtered snapshot:
2387
2195
 
2388
- Rust
2389
-
2390
2196
  ```rust
2391
2197
  // Attach only flags accessed with is_enabled() or get_flag() before this call
2392
2198
  let mut event = Event::new("event_name", "distinct_id_of_your_user");
@@ -2405,8 +2211,6 @@ client.capture(event);
2405
2211
 
2406
2212
  In the event properties, include `$feature/feature_flag_name: variant_key`:
2407
2213
 
2408
- Rust
2409
-
2410
2214
  ```rust
2411
2215
  use posthog_rs::Event;
2412
2216
 
@@ -2419,8 +2223,6 @@ client.capture(event);
2419
2223
 
2420
2224
  By default, `evaluate_flags()` evaluates every flag for the user. If you only need a few flags, pass `flag_keys` to request only those flags:
2421
2225
 
2422
- Rust
2423
-
2424
2226
  ```rust
2425
2227
  use posthog_rs::EvaluateFlagsOptions;
2426
2228
 
@@ -2435,7 +2237,7 @@ let flags = client.evaluate_flags(
2435
2237
 
2436
2238
  ### Sending `$feature_flag_called` events
2437
2239
 
2438
- Capturing `$feature_flag_called` events enables PostHog to know when a flag was accessed by a user and provide [analytics and insights](/docs/product-analytics/insights.md) on the flag. With `evaluate_flags()`, the SDK sends this event when you call `flags.is_enabled()` or `flags.get_flag()` for a flag.
2240
+ Capturing `$feature_flag_called` events enables PostHog to know when a flag was accessed by a user and provide [analytics and insights](https://posthog.com/docs/product-analytics/insights.md) on the flag. With `evaluate_flags()`, the SDK sends this event when you call `flags.is_enabled()` or `flags.get_flag()` for a flag.
2439
2241
 
2440
2242
  The SDK deduplicates these events per `(distinct_id, flag, value)` in a local cache. If you reinitialize the PostHog client, the cache resets and `$feature_flag_called` events may be sent again. PostHog handles duplicates, so duplicate `$feature_flag_called` events don't affect your analytics.
2441
2243
 
@@ -2445,8 +2247,6 @@ The SDK deduplicates these events per `(distinct_id, flag, value)` in a local ca
2445
2247
 
2446
2248
  If you're using the blocking client (with `default-features = false`), the API is the same but without `.await`:
2447
2249
 
2448
- Rust
2449
-
2450
2250
  ```rust
2451
2251
  use posthog_rs::EvaluateFlagsOptions;
2452
2252
 
@@ -2470,8 +2270,6 @@ Call `PostHog.FeatureFlags.evaluate_flags/1` once for the user, then read values
2470
2270
 
2471
2271
  #### Boolean feature flags
2472
2272
 
2473
- Elixir
2474
-
2475
2273
  ```elixir
2476
2274
  {:ok, snapshot} = PostHog.FeatureFlags.evaluate_flags("distinct_id_of_your_user")
2477
2275
 
@@ -2484,8 +2282,6 @@ end
2484
2282
 
2485
2283
  #### Multivariate feature flags
2486
2284
 
2487
- Elixir
2488
-
2489
2285
  ```elixir
2490
2286
  {:ok, snapshot} = PostHog.FeatureFlags.evaluate_flags("distinct_id_of_your_user")
2491
2287
 
@@ -2504,9 +2300,9 @@ end
2504
2300
 
2505
2301
  ### Step 2: Include feature flag information when capturing events
2506
2302
 
2507
- If you want use your feature flag to breakdown or filter events in your [insights](/docs/product-analytics/insights.md), you'll need to include feature flag information in those events. This ensures that the feature flag value is attributed correctly to the event.
2303
+ If you want use your feature flag to breakdown or filter events in your [insights](https://posthog.com/docs/product-analytics/insights.md), you'll need to include feature flag information in those events. This ensures that the feature flag value is attributed correctly to the event.
2508
2304
 
2509
- > **Note:** This step is only required for events captured using our server-side SDKs or [API](/docs/api.md).
2305
+ > **Note:** This step is only required for events captured using our server-side SDKs or [API](https://posthog.com/docs/api.md).
2510
2306
 
2511
2307
  There are two methods you can use to include feature flag information in your events:
2512
2308
 
@@ -2514,8 +2310,6 @@ There are two methods you can use to include feature flag information in your ev
2514
2310
 
2515
2311
  Put the same `snapshot` object that you used for branching into context. Subsequent captures from the same process attach the exact flag values from that evaluation and don't make another `/flags` request.
2516
2312
 
2517
- Elixir
2518
-
2519
2313
  ```elixir
2520
2314
  {:ok, snapshot} = PostHog.FeatureFlags.evaluate_flags("distinct_id_of_your_user")
2521
2315
 
@@ -2531,8 +2325,6 @@ By default, this attaches every flag in the snapshot using `$feature/<flag-key>`
2531
2325
 
2532
2326
  To reduce event property bloat, put a filtered snapshot in context:
2533
2327
 
2534
- Elixir
2535
-
2536
2328
  ```elixir
2537
2329
  {:ok, snapshot} = PostHog.FeatureFlags.evaluate_flags("distinct_id_of_your_user")
2538
2330
 
@@ -2554,8 +2346,6 @@ PostHog.FeatureFlags.set_in_context(
2554
2346
 
2555
2347
  In the event properties, include `$feature/feature_flag_name: variant_key`:
2556
2348
 
2557
- Elixir
2558
-
2559
2349
  ```elixir
2560
2350
  PostHog.capture("event_name", %{
2561
2351
  "$feature/feature-flag-key" => "variant-key",
@@ -2567,8 +2357,6 @@ PostHog.capture("event_name", %{
2567
2357
 
2568
2358
  By default, `evaluate_flags/1` evaluates every flag for the user. If you only need a few flags, pass `flag_keys` to request only those flags:
2569
2359
 
2570
- Elixir
2571
-
2572
2360
  ```elixir
2573
2361
  {:ok, snapshot} =
2574
2362
  PostHog.FeatureFlags.evaluate_flags(%{
@@ -2579,7 +2367,7 @@ Elixir
2579
2367
 
2580
2368
  ### Sending `$feature_flag_called` events
2581
2369
 
2582
- Capturing `$feature_flag_called` events enables PostHog to know when a flag was accessed by a user and provide [analytics and insights](/docs/product-analytics/insights.md) on the flag. With `evaluate_flags/1`, the SDK sends this event when you call `PostHog.FeatureFlags.Evaluations.enabled?/2` or `PostHog.FeatureFlags.Evaluations.get_flag/2` for a flag.
2370
+ Capturing `$feature_flag_called` events enables PostHog to know when a flag was accessed by a user and provide [analytics and insights](https://posthog.com/docs/product-analytics/insights.md) on the flag. With `evaluate_flags/1`, the SDK sends this event when you call `PostHog.FeatureFlags.Evaluations.enabled?/2` or `PostHog.FeatureFlags.Evaluations.get_flag/2` for a flag.
2583
2371
 
2584
2372
  `PostHog.FeatureFlags.Evaluations.get_flag_payload/2` doesn't send `$feature_flag_called` events.
2585
2373
 
@@ -2593,8 +2381,6 @@ Call `EvaluateFlagsAsync()` once for the user, then read values from the returne
2593
2381
 
2594
2382
  #### Boolean feature flags
2595
2383
 
2596
- C#
2597
-
2598
2384
  ```csharp
2599
2385
  var flags = await posthog.EvaluateFlagsAsync("distinct_id_of_your_user");
2600
2386
 
@@ -2608,8 +2394,6 @@ if (flags.IsEnabled("flag-key"))
2608
2394
 
2609
2395
  #### Multivariate feature flags
2610
2396
 
2611
- C#
2612
-
2613
2397
  ```csharp
2614
2398
  var flags = await posthog.EvaluateFlagsAsync("distinct_id_of_your_user");
2615
2399
 
@@ -2629,9 +2413,9 @@ if (enabledVariant == "variant-key") // replace "variant-key" with the key of yo
2629
2413
 
2630
2414
  ### Step 2: Include feature flag information when capturing events
2631
2415
 
2632
- If you want use your feature flag to breakdown or filter events in your [insights](/docs/product-analytics/insights.md), you'll need to include feature flag information in those events. This ensures that the feature flag value is attributed correctly to the event.
2416
+ If you want use your feature flag to breakdown or filter events in your [insights](https://posthog.com/docs/product-analytics/insights.md), you'll need to include feature flag information in those events. This ensures that the feature flag value is attributed correctly to the event.
2633
2417
 
2634
- > **Note:** This step is only required for events captured using our server-side SDKs or [API](/docs/api.md).
2418
+ > **Note:** This step is only required for events captured using our server-side SDKs or [API](https://posthog.com/docs/api.md).
2635
2419
 
2636
2420
  There are two methods you can use to include feature flag information in your events:
2637
2421
 
@@ -2639,8 +2423,6 @@ There are two methods you can use to include feature flag information in your ev
2639
2423
 
2640
2424
  Pass the same `flags` object that you used for branching. This attaches the exact flag values from that evaluation and doesn't make another `/flags` request.
2641
2425
 
2642
- C#
2643
-
2644
2426
  ```csharp
2645
2427
  var flags = await posthog.EvaluateFlagsAsync("distinct_id_of_your_user");
2646
2428
 
@@ -2662,8 +2444,6 @@ By default, this attaches every flag in the snapshot using `$feature/<flag-key>`
2662
2444
 
2663
2445
  To reduce event property bloat, pass a filtered snapshot:
2664
2446
 
2665
- C#
2666
-
2667
2447
  ```csharp
2668
2448
  // Attach only flags accessed with IsEnabled() or GetFlag() before this call
2669
2449
  posthog.Capture(
@@ -2688,8 +2468,6 @@ posthog.Capture(
2688
2468
 
2689
2469
  In the event properties, include `$feature/feature_flag_name: variant_key`:
2690
2470
 
2691
- C#
2692
-
2693
2471
  ```csharp
2694
2472
  posthog.Capture(
2695
2473
  "distinct_id_of_your_user",
@@ -2706,8 +2484,6 @@ posthog.Capture(
2706
2484
 
2707
2485
  By default, `EvaluateFlagsAsync()` evaluates every flag for the user. If you only need a few flags, pass `FlagKeysToEvaluate` to request only those flags:
2708
2486
 
2709
- C#
2710
-
2711
2487
  ```csharp
2712
2488
  var flags = await posthog.EvaluateFlagsAsync(
2713
2489
  "distinct_id_of_your_user",
@@ -2720,7 +2496,7 @@ var flags = await posthog.EvaluateFlagsAsync(
2720
2496
 
2721
2497
  ### Sending `$feature_flag_called` events
2722
2498
 
2723
- Capturing `$feature_flag_called` events enables PostHog to know when a flag was accessed by a user and provide [analytics and insights](/docs/product-analytics/insights.md) on the flag. With `EvaluateFlagsAsync()`, the SDK sends this event when you call `flags.IsEnabled()` or `flags.GetFlag()` for a flag.
2499
+ Capturing `$feature_flag_called` events enables PostHog to know when a flag was accessed by a user and provide [analytics and insights](https://posthog.com/docs/product-analytics/insights.md) on the flag. With `EvaluateFlagsAsync()`, the SDK sends this event when you call `flags.IsEnabled()` or `flags.GetFlag()` for a flag.
2724
2500
 
2725
2501
  The SDK deduplicates these events per `(distinct_id, flag, value)` in a local cache. If you reinitialize the PostHog client, the cache resets and `$feature_flag_called` events may be sent again. PostHog handles duplicates, so duplicate `$feature_flag_called` events don't affect your analytics.
2726
2502
 
@@ -2728,14 +2504,12 @@ The SDK deduplicates these events per `(distinct_id, flag, value)` in a local ca
2728
2504
 
2729
2505
  ### Advanced: Overriding server properties
2730
2506
 
2731
- Sometimes, you may want to evaluate feature flags using [person properties](/docs/product-analytics/person-properties.md), [groups](/docs/product-analytics/group-analytics.md), or group properties that haven't been ingested yet, or were set incorrectly earlier.
2507
+ Sometimes, you may want to evaluate feature flags using [person properties](https://posthog.com/docs/product-analytics/person-properties.md), [groups](https://posthog.com/docs/product-analytics/group-analytics.md), or group properties that haven't been ingested yet, or were set incorrectly earlier.
2732
2508
 
2733
2509
  You can provide properties to evaluate the flag with by using the `person properties`, `groups`, and `group properties` arguments. PostHog will then use these values to evaluate the flag, instead of any properties currently stored on your PostHog server.
2734
2510
 
2735
2511
  For example:
2736
2512
 
2737
- C#
2738
-
2739
2513
  ```csharp
2740
2514
  var flags = await posthog.EvaluateFlagsAsync(
2741
2515
  "distinct_id_of_the_user",
@@ -2977,8 +2751,6 @@ Evaluation runtime (server vs. client) is automatically detected based on your r
2977
2751
 
2978
2752
  **Examples of runtime detection:**
2979
2753
 
2980
- JavaScript
2981
-
2982
2754
  ```javascript
2983
2755
  // Browser fetch - Detected as CLIENT runtime
2984
2756
  // Will receive: client-only flags + "all" flags
@@ -2996,8 +2768,6 @@ const response = await fetch("https://us.i.posthog.com/flags?v=2", {
2996
2768
  });
2997
2769
  ```
2998
2770
 
2999
- Python
3000
-
3001
2771
  ```python
3002
2772
  # Python requests - Detected as SERVER runtime
3003
2773
  # Will receive: server-only flags + "all" flags
@@ -3014,8 +2784,6 @@ response = requests.post(
3014
2784
  )
3015
2785
  ```
3016
2786
 
3017
- Terminal
3018
-
3019
2787
  ```shell
3020
2788
  # curl - Detected as SERVER runtime
3021
2789
  # Will receive: server-only flags + "all" flags
@@ -3027,8 +2795,6 @@ curl -v -L --header "Content-Type: application/json" -d '{
3027
2795
  # curl/ in User-Agent indicates server-side
3028
2796
  ```
3029
2797
 
3030
- JavaScript
3031
-
3032
2798
  ```javascript
3033
2799
  // Node.js with custom User-Agent - Control runtime detection
3034
2800
  const response = await fetch("https://us.i.posthog.com/flags?v=2", {
@@ -3048,8 +2814,6 @@ const response = await fetch("https://us.i.posthog.com/flags?v=2", {
3048
2814
 
3049
2815
  Both features work together as sequential filters:
3050
2816
 
3051
- JavaScript
3052
-
3053
2817
  ```javascript
3054
2818
  // Example: Production web client
3055
2819
  const response = await fetch("https://us.i.posthog.com/flags?v=2", {
@@ -3082,9 +2846,7 @@ The response varies depending on whether you include the `config=true` query par
3082
2846
 
3083
2847
  Use this endpoint when you only need to evaluate feature flags. It returns a response with just the flag evaluation results.
3084
2848
 
3085
- > **Note:** If a feature flag is associated with an experiment that has a [holdout group](/docs/experiments/holdouts.md), users in the holdout receive a variant value in the format `holdout-{holdout_id}` (e.g., `holdout-727`). You can detect holdout users by checking if the variant starts with `holdout-`.
3086
-
3087
- JSON
2849
+ > **Note:** If a feature flag is associated with an experiment that has a [holdout group](https://posthog.com/docs/experiments/holdouts.md), users in the holdout receive a variant value in the format `holdout-{holdout_id}` (e.g., `holdout-727`). You can detect holdout users by checking if the variant starts with `holdout-`.
3088
2850
 
3089
2851
  ```json
3090
2852
  {
@@ -3140,8 +2902,6 @@ JSON
3140
2902
 
3141
2903
  Use this endpoint when you need both feature flag evaluation and PostHog configuration information (useful for client-side SDKs that need to initialize PostHog):
3142
2904
 
3143
- JSON
3144
-
3145
2905
  ```json
3146
2906
  {
3147
2907
  "config": {
@@ -3211,8 +2971,6 @@ If your organization exceeds its feature flag quota, the `/flags` endpoint will
3211
2971
 
3212
2972
  For basic response (`/flags?v=2`):
3213
2973
 
3214
- JSON
3215
-
3216
2974
  ```json
3217
2975
  {
3218
2976
  "flags": {},
@@ -3224,8 +2982,6 @@ JSON
3224
2982
 
3225
2983
  For full response with configuration (`/flags?v=2&config=true`):
3226
2984
 
3227
- JSON
3228
-
3229
2985
  ```json
3230
2986
  {
3231
2987
  "config": {
@@ -3252,9 +3008,9 @@ When you receive a response with `quotaLimited` containing `"feature_flags"`, it
3252
3008
 
3253
3009
  ### Step 2: Include feature flag information when capturing events
3254
3010
 
3255
- If you want use your feature flag to breakdown or filter events in your [insights](/docs/product-analytics/insights.md), you'll need to include feature flag information in those events. This ensures that the feature flag value is attributed correctly to the event.
3011
+ If you want use your feature flag to breakdown or filter events in your [insights](https://posthog.com/docs/product-analytics/insights.md), you'll need to include feature flag information in those events. This ensures that the feature flag value is attributed correctly to the event.
3256
3012
 
3257
- > **Note:** This step is only required for events captured using our server-side SDKs or [API](/docs/api.md).
3013
+ > **Note:** This step is only required for events captured using our server-side SDKs or [API](https://posthog.com/docs/api.md).
3258
3014
 
3259
3015
  To do this, include the `$feature/feature_flag_name` property in your event:
3260
3016
 
@@ -3341,7 +3097,7 @@ print(response)
3341
3097
 
3342
3098
  ### Advanced: Overriding server properties
3343
3099
 
3344
- Sometimes, you may want to evaluate feature flags using [person properties](/docs/product-analytics/person-properties.md), [groups](/docs/product-analytics/group-analytics.md), or group properties that haven't been ingested yet, or were set incorrectly earlier.
3100
+ Sometimes, you may want to evaluate feature flags using [person properties](https://posthog.com/docs/product-analytics/person-properties.md), [groups](https://posthog.com/docs/product-analytics/group-analytics.md), or group properties that haven't been ingested yet, or were set incorrectly earlier.
3345
3101
 
3346
3102
  You can provide properties to evaluate the flag with by using the `person properties`, `groups`, and `group properties` arguments. PostHog will then use these values to evaluate the flag, instead of any properties currently stored on your PostHog server.
3347
3103
 
@@ -3430,11 +3186,3 @@ The list of properties that this overrides:
3430
3186
  5. `$geoip_continent_code`
3431
3187
  6. `$geoip_postal_code`
3432
3188
  7. `$geoip_time_zone`
3433
-
3434
- ### Still have questions?
3435
-
3436
- Ask PostHog AI
3437
-
3438
- ### Was this page useful?
3439
-
3440
- HelpfulCould be better