vybekiit 0.7.26 → 0.7.27

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 (232) hide show
  1. package/dist/bin.js +3891 -1301
  2. package/dist/global-skills/aws-cdk/SKILL.md +19 -5
  3. package/dist/global-skills/aws-cdk/references/fast-deployments.md +191 -0
  4. package/dist/global-skills/aws-cdk/references/troubleshooting-deployment.md +16 -0
  5. package/dist/global-skills/aws-cloudformation/SKILL.md +16 -26
  6. package/dist/global-skills/aws-cloudformation/references/check-cloudformation-template-compliance.script.md +7 -3
  7. package/dist/global-skills/aws-cloudformation/references/cloudformation-language-server.md +177 -0
  8. package/dist/global-skills/aws-cloudformation/references/cloudformation-pre-deploy-validation.script.md +8 -2
  9. package/dist/global-skills/aws-cloudformation/references/persist-template-context.script.md +5 -8
  10. package/dist/global-skills/aws-cloudformation/references/retrieve-template-context.script.md +1 -1
  11. package/dist/global-skills/aws-cloudformation/references/security-considerations.md +51 -0
  12. package/dist/global-skills/aws-cloudformation/references/troubleshoot-failed-stack.script.md +138 -0
  13. package/dist/global-skills/aws-cloudformation/references/{validate-cloudformation-template.script.md → validate-with-cfn-lint.script.md} +15 -27
  14. package/dist/global-skills/aws-cloudformation/references/validate-with-cloudformation-validate.script.md +181 -0
  15. package/dist/global-skills/aws-cloudformation/references/validation-tool-selection.md +44 -0
  16. package/dist/global-skills/aws-serverless/SKILL.md +9 -1
  17. package/dist/global-skills/aws-serverless/references/architecture.md +3 -1
  18. package/dist/global-skills/aws-serverless/references/lambda.md +3 -1
  19. package/dist/global-skills/aws-serverless/references/orchestration.md +1 -0
  20. package/dist/global-skills/better-auth-best-practices/SKILL.md +18 -8
  21. package/dist/global-skills/eas-app-stores/SKILL.md +31 -15
  22. package/dist/global-skills/eas-app-stores/agents/openai.yaml +2 -2
  23. package/dist/global-skills/eas-app-stores/references/ios-app-store.md +37 -32
  24. package/dist/global-skills/eas-app-stores/references/native-ios.md +167 -0
  25. package/dist/global-skills/eas-app-stores/references/play-store.md +3 -7
  26. package/dist/global-skills/eas-app-stores/references/testflight.md +39 -35
  27. package/dist/global-skills/eas-simulator/SKILL.md +48 -26
  28. package/dist/global-skills/eas-simulator/references/controllers.md +32 -3
  29. package/dist/global-skills/eas-simulator/references/run-your-app.md +34 -4
  30. package/dist/global-skills/eas-simulator/references/troubleshooting.md +8 -4
  31. package/dist/global-skills/eas-update/SKILL.md +146 -0
  32. package/dist/global-skills/eas-update/agents/openai.yaml +4 -0
  33. package/dist/global-skills/expo-animation/RECIPES.md +2 -2
  34. package/dist/global-skills/expo-animation/SKILL.md +9 -2
  35. package/dist/global-skills/expo-brownfield/SKILL.md +18 -11
  36. package/dist/global-skills/expo-brownfield/agents/openai.yaml +2 -2
  37. package/dist/global-skills/expo-brownfield/references/brownfield-integrated.md +94 -69
  38. package/dist/global-skills/expo-brownfield/references/brownfield-isolated.md +40 -42
  39. package/dist/global-skills/expo-brownfield/references/comparison.md +5 -5
  40. package/dist/global-skills/expo-brownfield/references/feature-integration.md +163 -0
  41. package/dist/global-skills/expo-brownfield/references/troubleshooting.md +17 -17
  42. package/dist/global-skills/expo-brownfield/references/version-compatibility.md +40 -0
  43. package/dist/global-skills/expo-data-fetching/SKILL.md +27 -6
  44. package/dist/global-skills/expo-design-system/SKILL.md +27 -7
  45. package/dist/global-skills/expo-design-system/references/audit.md +7 -2
  46. package/dist/global-skills/expo-design-system/references/native-slop.md +74 -0
  47. package/dist/global-skills/expo-examples/SKILL.md +0 -1
  48. package/dist/global-skills/expo-examples/references/catalog.md +1 -1
  49. package/dist/global-skills/expo-migrate-module/SKILL.md +21 -10
  50. package/dist/global-skills/expo-migrate-module/references/compatibility.md +80 -23
  51. package/dist/global-skills/expo-migrate-module/references/migration-map.md +162 -11
  52. package/dist/global-skills/expo-native-ui/SKILL.md +25 -16
  53. package/dist/global-skills/expo-native-ui/agents/openai.yaml +2 -2
  54. package/dist/global-skills/expo-native-ui/references/controls.md +5 -46
  55. package/dist/global-skills/expo-native-ui/references/icons.md +21 -2
  56. package/dist/global-skills/expo-native-ui/references/media.md +15 -20
  57. package/dist/global-skills/expo-native-ui/references/visual-effects.md +12 -11
  58. package/dist/global-skills/expo-overview/SKILL.md +17 -12
  59. package/dist/global-skills/expo-router/SKILL.md +5 -3
  60. package/dist/global-skills/expo-router/references/tabs.md +5 -5
  61. package/dist/global-skills/expo-upgrade/SKILL.md +3 -1
  62. package/dist/global-skills/expo-web-to-native/references/false-friends.md +2 -2
  63. package/dist/global-skills/expo-web-to-native/references/native-patterns.md +1 -1
  64. package/dist/global-skills/firebase-ai-logic-basics/SKILL.md +13 -16
  65. package/dist/global-skills/firebase-ai-logic-basics/references/ios_setup.md +4 -5
  66. package/dist/global-skills/firebase-ai-logic-basics/references/usage_patterns_android.md +4 -4
  67. package/dist/global-skills/firebase-ai-logic-basics/references/usage_patterns_web.md +3 -3
  68. package/dist/global-skills/firebase-auth-basics/SKILL.md +11 -6
  69. package/dist/global-skills/firebase-auth-basics/references/client_sdk_android.md +4 -5
  70. package/dist/global-skills/firebase-auth-basics/references/client_sdk_web.md +3 -3
  71. package/dist/global-skills/firebase-auth-basics/references/flutter_setup.md +24 -25
  72. package/dist/global-skills/firebase-auth-basics/references/security_rules.md +4 -2
  73. package/dist/global-skills/firebase-crashlytics/references/android_setup.md +7 -4
  74. package/dist/global-skills/firebase-crashlytics/references/ios_setup.md +2 -3
  75. package/dist/global-skills/firebase-data-connect/SKILL.md +2 -1
  76. package/dist/global-skills/firebase-data-connect/examples.md +4 -4
  77. package/dist/global-skills/firebase-data-connect/reference/config.md +5 -4
  78. package/dist/global-skills/firebase-data-connect/reference/realtime.md +1 -2
  79. package/dist/global-skills/firebase-data-connect/reference/sdk_flutter.md +2 -2
  80. package/dist/global-skills/firebase-data-connect/reference/sdk_ios.md +2 -2
  81. package/dist/global-skills/firebase-data-connect/reference/sdk_web.md +17 -6
  82. package/dist/global-skills/firebase-data-connect/reference/security.md +5 -5
  83. package/dist/global-skills/firebase-data-connect/templates.md +2 -1
  84. package/dist/global-skills/firebase-firestore/SKILL.md +20 -8
  85. package/dist/global-skills/firebase-firestore/references/enterprise/android_sdk_usage.md +5 -4
  86. package/dist/global-skills/firebase-firestore/references/enterprise/data_model.md +12 -3
  87. package/dist/global-skills/firebase-firestore/references/enterprise/indexes.md +16 -18
  88. package/dist/global-skills/firebase-firestore/references/enterprise/provisioning.md +1 -1
  89. package/dist/global-skills/firebase-firestore/references/enterprise/python_sdk_usage.md +5 -1
  90. package/dist/global-skills/firebase-firestore/references/enterprise/web_sdk_usage.md +7 -7
  91. package/dist/global-skills/firebase-firestore/references/standard/android_sdk_usage.md +5 -5
  92. package/dist/global-skills/firebase-firestore/references/standard/flutter_setup.md +4 -4
  93. package/dist/global-skills/firebase-firestore/references/standard/indexes.md +16 -18
  94. package/dist/global-skills/firebase-firestore/references/standard/provisioning.md +1 -1
  95. package/dist/global-skills/firebase-remote-config-basics/SKILL.md +0 -5
  96. package/dist/global-skills/firebase-remote-config-basics/references/android_setup.md +36 -8
  97. package/dist/global-skills/firebase-remote-config-basics/references/ios_setup.md +1 -7
  98. package/dist/global-skills/firebase-security-rules-auditor/SKILL.md +17 -6
  99. package/dist/global-skills/{firebase-firestore/references/standard/security_rules.md → firestore-rules-creation/SKILL.md} +24 -13
  100. package/dist/global-skills/grow-my-customers/SKILL.md +23 -0
  101. package/dist/global-skills/instrument-feature-flags/SKILL.md +25 -25
  102. package/dist/global-skills/instrument-feature-flags/references/adding-feature-flag-code.md +141 -285
  103. package/dist/global-skills/instrument-feature-flags/references/android.md +6 -15
  104. package/dist/global-skills/instrument-feature-flags/references/api.md +4 -11
  105. package/dist/global-skills/instrument-feature-flags/references/best-practices.md +1 -13
  106. package/dist/global-skills/instrument-feature-flags/references/django.md +14 -27
  107. package/dist/global-skills/instrument-feature-flags/references/dotnet.md +20 -79
  108. package/dist/global-skills/instrument-feature-flags/references/elixir.md +1 -9
  109. package/dist/global-skills/instrument-feature-flags/references/flask.md +13 -13
  110. package/dist/global-skills/instrument-feature-flags/references/flutter.md +3 -24
  111. package/dist/global-skills/instrument-feature-flags/references/go.md +3 -15
  112. package/dist/global-skills/instrument-feature-flags/references/ios.md +4 -17
  113. package/dist/global-skills/instrument-feature-flags/references/java.md +5 -13
  114. package/dist/global-skills/instrument-feature-flags/references/laravel.md +13 -17
  115. package/dist/global-skills/instrument-feature-flags/references/next-js.md +25 -32
  116. package/dist/global-skills/instrument-feature-flags/references/nodejs.md +8 -15
  117. package/dist/global-skills/instrument-feature-flags/references/php.md +1 -15
  118. package/dist/global-skills/instrument-feature-flags/references/python.md +2 -15
  119. package/dist/global-skills/instrument-feature-flags/references/react-native.md +13 -15
  120. package/dist/global-skills/instrument-feature-flags/references/react.md +17 -21
  121. package/dist/global-skills/instrument-feature-flags/references/ruby-on-rails.md +37 -83
  122. package/dist/global-skills/instrument-feature-flags/references/ruby.md +2 -15
  123. package/dist/global-skills/instrument-feature-flags/references/rust.md +13 -25
  124. package/dist/global-skills/instrument-feature-flags/references/usage.md +14 -63
  125. package/dist/global-skills/instrument-feature-flags/references/web.md +9 -14
  126. package/dist/global-skills/instrument-product-analytics/SKILL.md +29 -29
  127. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-astro-hybrid.md +3 -1
  128. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-astro-ssr.md +3 -1
  129. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-astro-static.md +3 -1
  130. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-astro-view-transitions.md +3 -1
  131. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-ruby-on-rails.md +3 -1
  132. package/dist/global-skills/instrument-product-analytics/references/android.md +72 -107
  133. package/dist/global-skills/instrument-product-analytics/references/angular.md +26 -28
  134. package/dist/global-skills/instrument-product-analytics/references/astro.md +13 -24
  135. package/dist/global-skills/instrument-product-analytics/references/configuration.md +45 -63
  136. package/dist/global-skills/instrument-product-analytics/references/django.md +14 -27
  137. package/dist/global-skills/instrument-product-analytics/references/dotnet.md +20 -79
  138. package/dist/global-skills/instrument-product-analytics/references/elixir.md +47 -49
  139. package/dist/global-skills/instrument-product-analytics/references/flask.md +13 -13
  140. package/dist/global-skills/instrument-product-analytics/references/flutter.md +60 -90
  141. package/dist/global-skills/instrument-product-analytics/references/go.md +17 -56
  142. package/dist/global-skills/instrument-product-analytics/references/identify-users.md +15 -15
  143. package/dist/global-skills/instrument-product-analytics/references/ios.md +11 -15
  144. package/dist/global-skills/instrument-product-analytics/references/laravel.md +13 -17
  145. package/dist/global-skills/instrument-product-analytics/references/next-js.md +25 -32
  146. package/dist/global-skills/instrument-product-analytics/references/nuxt-js-3-6.md +13 -27
  147. package/dist/global-skills/instrument-product-analytics/references/nuxt-js.md +14 -28
  148. package/dist/global-skills/instrument-product-analytics/references/php.md +33 -84
  149. package/dist/global-skills/instrument-product-analytics/references/posthog-python.md +229 -9
  150. package/dist/global-skills/instrument-product-analytics/references/python.md +415 -106
  151. package/dist/global-skills/instrument-product-analytics/references/react-native.md +161 -155
  152. package/dist/global-skills/instrument-product-analytics/references/react-router-v6.md +12 -33
  153. package/dist/global-skills/instrument-product-analytics/references/react-router-v7-data-mode.md +15 -33
  154. package/dist/global-skills/instrument-product-analytics/references/react-router-v7-declarative-mode.md +12 -33
  155. package/dist/global-skills/instrument-product-analytics/references/react-router-v7-framework-mode.md +26 -41
  156. package/dist/global-skills/instrument-product-analytics/references/ruby-on-rails.md +37 -83
  157. package/dist/global-skills/instrument-product-analytics/references/ruby.md +48 -108
  158. package/dist/global-skills/instrument-product-analytics/references/svelte.md +18 -24
  159. package/dist/global-skills/instrument-product-analytics/references/tanstack-start.md +17 -19
  160. package/dist/global-skills/instrument-product-analytics/references/usage.md +14 -63
  161. package/dist/global-skills/instrument-product-analytics/references/vue-js.md +29 -28
  162. package/dist/global-skills/manifest.json +8 -2
  163. package/dist/global-skills/mongodb-search-and-ai/SKILL.md +28 -37
  164. package/dist/global-skills/mongodb-search-and-ai/references/automated-embedding.md +438 -0
  165. package/dist/global-skills/mongodb-search-and-ai/references/hybrid-search.md +60 -4
  166. package/dist/global-skills/mongodb-search-and-ai/references/vector-search.md +46 -108
  167. package/dist/global-skills/neon/SKILL.md +207 -213
  168. package/dist/global-skills/neon/references/auth.md +12 -0
  169. package/dist/global-skills/neon/references/claimable-neon.md +10 -14
  170. package/dist/global-skills/neon/references/function-triggers.md +53 -0
  171. package/dist/global-skills/neon/references/logs-loki.md +61 -0
  172. package/dist/global-skills/neon/references/parse-env.md +32 -0
  173. package/dist/global-skills/neon/references/sdk.md +7 -0
  174. package/dist/global-skills/neon-ai-gateway/SKILL.md +14 -16
  175. package/dist/global-skills/neon-auth/SKILL.md +155 -0
  176. package/dist/global-skills/neon-auth/references/managed-auth.md +173 -0
  177. package/dist/global-skills/neon-auth/references/self-managed.md +25 -0
  178. package/dist/global-skills/neon-functions/SKILL.md +159 -84
  179. package/dist/global-skills/neon-functions/references/ai-sdk.md +4 -6
  180. package/dist/global-skills/neon-functions/references/function-triggers.md +249 -0
  181. package/dist/global-skills/neon-functions/references/mastra-studio.md +3 -3
  182. package/dist/global-skills/neon-functions/references/mcp.md +1 -1
  183. package/dist/global-skills/neon-functions/references/production-hardening.md +340 -0
  184. package/dist/global-skills/neon-functions/references/sse.md +8 -5
  185. package/dist/global-skills/neon-object-storage/SKILL.md +10 -11
  186. package/dist/global-skills/neon-postgres/SKILL.md +120 -17
  187. package/dist/global-skills/neon-postgres/references/full-text-search.md +99 -0
  188. package/dist/global-skills/neon-postgres/references/hybrid-search.md +90 -0
  189. package/dist/global-skills/neon-postgres/references/lakebase-search-drizzle.md +172 -0
  190. package/dist/global-skills/neon-postgres/references/vector-search.md +137 -0
  191. package/dist/global-skills/neon-postgres-branches/SKILL.md +3 -3
  192. package/dist/global-skills/neon-postgres-egress-optimizer/SKILL.md +1 -1
  193. package/dist/global-skills/onboarding/SKILL.md +8 -6
  194. package/dist/global-skills/resend/SKILL.md +4 -2
  195. package/dist/global-skills/resend/references/broadcasts.md +6 -1
  196. package/dist/global-skills/resend/references/receiving.md +29 -10
  197. package/dist/global-skills/resend/references/sending/email-management.md +14 -4
  198. package/dist/global-skills/resend/references/topics.md +9 -6
  199. package/dist/global-skills/resend/references/usage.md +117 -0
  200. package/dist/global-skills/resend/references/webhooks.md +59 -2
  201. package/dist/global-skills/stripe-best-practices/SKILL.md +35 -29
  202. package/dist/global-skills/stripe-best-practices/references/billing.md +9 -2
  203. package/dist/global-skills/stripe-best-practices/references/payments.md +4 -2
  204. package/dist/global-skills/stripe-best-practices/references/security.md +3 -1
  205. package/dist/global-skills/stripe-best-practices/references/tax.md +39 -20
  206. package/dist/global-skills/supabase/SKILL.md +6 -0
  207. package/dist/global-skills/use-railway/SKILL.md +42 -22
  208. package/dist/global-skills/use-railway/references/analyze-db.md +7 -6
  209. package/dist/global-skills/use-railway/references/cloud-agents.md +70 -0
  210. package/dist/global-skills/use-railway/references/configure.md +17 -2
  211. package/dist/global-skills/use-railway/references/databases.md +107 -0
  212. package/dist/global-skills/use-railway/references/deploy.md +5 -5
  213. package/dist/global-skills/use-railway/references/feature-flags.md +25 -13
  214. package/dist/global-skills/use-railway/references/iac.md +66 -77
  215. package/dist/global-skills/use-railway/references/operate.md +26 -3
  216. package/dist/global-skills/use-railway/references/request.md +31 -23
  217. package/dist/global-skills/use-railway/references/setup.md +16 -5
  218. package/dist/global-skills/use-railway/references/tracing.md +261 -0
  219. package/dist/global-skills/use-railway/references/usage.md +52 -0
  220. package/dist/global-skills/validate-my-idea/SKILL.md +54 -0
  221. package/dist/global-skills/{feedback → vybekiit-feedback}/SKILL.md +16 -12
  222. package/dist/global-skills/watch-my-app/SKILL.md +53 -0
  223. package/dist/global-skills/workers-best-practices/SKILL.md +36 -103
  224. package/dist/global-skills/workers-best-practices/references/configuration.md +139 -0
  225. package/dist/global-skills/workers-best-practices/references/platform-apis.md +51 -0
  226. package/dist/global-skills/workers-best-practices/references/{rules.md → runtime-patterns.md} +13 -137
  227. package/dist/global-skills/wrangler/SKILL.md +48 -901
  228. package/dist/global-skills/xcode-project-setup/scripts/xcode_spm_setup/Sources/main.swift +19 -15
  229. package/package.json +9 -8
  230. package/dist/global-skills/expo-native-ui/references/animations.md +0 -220
  231. package/dist/global-skills/firebase-firestore/references/enterprise/security_rules.md +0 -577
  232. package/dist/global-skills/workers-best-practices/references/review.md +0 -174
@@ -1,10 +1,6 @@
1
1
  > AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt
2
2
 
3
- # Adding feature flag code - Docs
4
-
5
- Copy page
6
-
7
- # Adding feature flag code - Docs
3
+ # Adding feature flag code
8
4
 
9
5
  Once you've created your feature flag in PostHog, the next step is to add your code:
10
6
 
@@ -14,12 +10,11 @@ Once you've created your feature flag in PostHog, the next step is to add your c
14
10
 
15
11
  Web
16
12
 
17
- PostHog AI
18
-
19
13
  ```javascript
20
14
  const result = posthog.getFeatureFlagResult('flag-key')
21
15
  if (result?.enabled) {
22
16
  // Do something differently for this user
17
+
23
18
  // Optional: fetch the payload from the same evaluation result
24
19
  const matchedFlagPayload = result?.payload
25
20
  }
@@ -29,12 +24,11 @@ if (result?.enabled) {
29
24
 
30
25
  Web
31
26
 
32
- PostHog AI
33
-
34
27
  ```javascript
35
28
  const result = posthog.getFeatureFlagResult('flag-key')
36
29
  if (result?.variant == 'variant-key') { // replace 'variant-key' with the key of your variant
37
30
  // Do something differently for this user
31
+
38
32
  // Optional: fetch the payload from the same evaluation result
39
33
  const matchedFlagPayload = result?.payload
40
34
  }
@@ -46,8 +40,6 @@ You can inspect all currently loaded feature flags with `getAllFeatureFlags()`.
46
40
 
47
41
  Web
48
42
 
49
- PostHog AI
50
-
51
43
  ```javascript
52
44
  for (const flag of posthog.getAllFeatureFlags()) {
53
45
  console.log(flag.key, flag.enabled, flag.variant, flag.payload)
@@ -64,8 +56,6 @@ To handle this, you can use the `onFeatureFlags` callback to wait for the featur
64
56
 
65
57
  Web
66
58
 
67
- PostHog AI
68
-
69
59
  ```javascript
70
60
  posthog.onFeatureFlags(function (flags, flagVariants, { errorsLoading }) {
71
61
  // feature flags are guaranteed to be available at this point
@@ -93,8 +83,6 @@ By default, the JavaScript SDK requests that every eligible feature flag be eval
93
83
 
94
84
  Web
95
85
 
96
- PostHog AI
97
-
98
86
  ```javascript
99
87
  posthog.init('<ph_project_token>', {
100
88
  api_host: 'https://us.i.posthog.com',
@@ -111,8 +99,6 @@ Feature flag values are cached. If something has changed with your user and you'
111
99
 
112
100
  Web
113
101
 
114
- PostHog AI
115
-
116
102
  ```javascript
117
103
  posthog.reloadFeatureFlags()
118
104
  ```
@@ -123,8 +109,6 @@ Sometimes, you might want to evaluate feature flags using properties that haven'
123
109
 
124
110
  Web
125
111
 
126
- PostHog AI
127
-
128
112
  ```javascript
129
113
  posthog.setPersonPropertiesForFlags({'property1': 'value', property2: 'value2'})
130
114
  ```
@@ -135,8 +119,6 @@ Whenever you set these properties, we also trigger a reload of feature flags to
135
119
 
136
120
  Web
137
121
 
138
- PostHog AI
139
-
140
122
  ```javascript
141
123
  posthog.setPersonPropertiesForFlags({'property1': 'value', property2: 'value2'}, false)
142
124
  ```
@@ -145,8 +127,6 @@ At any point, you can reset these properties by calling `resetPersonPropertiesFo
145
127
 
146
128
  Web
147
129
 
148
- PostHog AI
149
-
150
130
  ```javascript
151
131
  posthog.resetPersonPropertiesForFlags()
152
132
  ```
@@ -155,13 +135,13 @@ The same holds for [group](/manual/group-analytics.md) properties:
155
135
 
156
136
  Web
157
137
 
158
- PostHog AI
159
-
160
138
  ```javascript
161
139
  // set properties for a group
162
140
  posthog.setGroupPropertiesForFlags({'company': {'property1': 'value', property2: 'value2'}})
141
+
163
142
  // reset properties for a given group:
164
143
  posthog.resetGroupPropertiesForFlags('company')
144
+
165
145
  // reset properties for all groups:
166
146
  posthog.resetGroupPropertiesForFlags()
167
147
  ```
@@ -194,8 +174,6 @@ You can configure the `feature_flag_request_timeout_ms` parameter when initializ
194
174
 
195
175
  JavaScript
196
176
 
197
- PostHog AI
198
-
199
177
  ```javascript
200
178
  posthog.init('<ph_project_token>', {
201
179
  api_host: 'https://us.i.posthog.com',
@@ -210,8 +188,6 @@ When using the PostHog SDK, it's important to handle potential errors that may o
210
188
 
211
189
  JavaScript
212
190
 
213
- PostHog AI
214
-
215
191
  ```javascript
216
192
  function handleFeatureFlag(client, flagKey, distinctId) {
217
193
  try {
@@ -225,6 +201,7 @@ function handleFeatureFlag(client, flagKey, distinctId) {
225
201
  throw error;
226
202
  }
227
203
  }
204
+
228
205
  // Usage example
229
206
  try {
230
207
  const flagEnabled = handleFeatureFlag(client, 'new-feature', 'user-123');
@@ -253,22 +230,22 @@ PostHog provides several hooks to make it easy to use feature flags in your Reac
253
230
 
254
231
  | Hook | Description |
255
232
  | --- | --- |
256
- | useFeatureFlagEnabled | Returns whether the feature flag is enabled. This sends a $feature_flag_called event. Without a default value, it returns boolean \\\| undefined while flags are loading or absent. Pass an optional default value to return that value instead and narrow the return type to boolean. |
257
- | useFeatureFlagVariantKey | Returns the variant key of the feature flag. This sends a $feature_flag_called event. |
258
- | useActiveFeatureFlags | Returns an array of active feature flags. This does not send a $feature_flag_called event. |
259
- | useFeatureFlagPayload | Returns the payload of the feature flag. This does not send a $feature_flag_called event. Always use this with useFeatureFlagEnabled or useFeatureFlagVariantKey. |
233
+ | `useFeatureFlagEnabled` | Returns whether the feature flag is enabled. This sends a `$feature_flag_called` event. Without a default value, it returns `boolean \| undefined` while flags are loading or absent. Pass an optional default value to return that value instead and narrow the return type to `boolean`. |
234
+ | `useFeatureFlagVariantKey` | Returns the variant key of the feature flag. This sends a `$feature_flag_called` event. |
235
+ | `useActiveFeatureFlags` | Returns an array of active feature flags. This does *not* send a `$feature_flag_called` event. |
236
+ | `useFeatureFlagPayload` | Returns the payload of the feature flag. This does *not* send a `$feature_flag_called` event. Always use this with `useFeatureFlagEnabled` or `useFeatureFlagVariantKey`. |
260
237
 
261
238
  #### Example 1: Using a boolean feature flag
262
239
 
263
240
  React
264
241
 
265
- PostHog AI
266
-
267
242
  ```jsx
268
243
  import { useFeatureFlagEnabled, useFeatureFlagPayload } from '@posthog/react'
244
+
269
245
  function App() {
270
246
  const showWelcomeMessage = useFeatureFlagEnabled('flag-key')
271
247
  const payload = useFeatureFlagPayload('flag-key')
248
+
272
249
  return (
273
250
  <div className="App">
274
251
  {
@@ -287,6 +264,7 @@ function App() {
287
264
  </div>
288
265
  );
289
266
  }
267
+
290
268
  export default App;
291
269
  ```
292
270
 
@@ -294,8 +272,6 @@ To avoid handling `undefined` while flags are loading, pass a default value as t
294
272
 
295
273
  React
296
274
 
297
- PostHog AI
298
-
299
275
  ```jsx
300
276
  const showWelcomeMessage = useFeatureFlagEnabled('flag-key', false)
301
277
  ```
@@ -304,10 +280,9 @@ const showWelcomeMessage = useFeatureFlagEnabled('flag-key', false)
304
280
 
305
281
  React
306
282
 
307
- PostHog AI
308
-
309
283
  ```jsx
310
284
  import { useFeatureFlagVariantKey } from '@posthog/react'
285
+
311
286
  function App() {
312
287
  const variantKey = useFeatureFlagVariantKey('show-welcome-message')
313
288
  let welcomeMessage = ''
@@ -316,6 +291,7 @@ function App() {
316
291
  } else if (variantKey === 'variant-b') {
317
292
  welcomeMessage = 'Welcome to the Beta!'
318
293
  }
294
+
319
295
  return (
320
296
  <div className="App">
321
297
  {
@@ -334,6 +310,7 @@ function App() {
334
310
  </div>
335
311
  );
336
312
  }
313
+
337
314
  export default App;
338
315
  ```
339
316
 
@@ -345,13 +322,13 @@ The `useFeatureFlagPayload` hook does *not* send a [`$feature_flag_called`](http
345
322
 
346
323
  React
347
324
 
348
- PostHog AI
349
-
350
325
  ```jsx
351
326
  import { useFeatureFlagEnabled, useFeatureFlagPayload } from '@posthog/react'
327
+
352
328
  function App() {
353
329
  const variant = useFeatureFlagEnabled('show-welcome-message')
354
330
  const payload = useFeatureFlagPayload('show-welcome-message')
331
+
355
332
  return (
356
333
  <>
357
334
  {
@@ -382,11 +359,11 @@ Here is an example:
382
359
 
383
360
  React
384
361
 
385
- PostHog AI
386
-
387
362
  ```jsx
388
363
  import { PostHogFeature } from '@posthog/react'
364
+
389
365
  function App() {
366
+
390
367
  return (
391
368
  <PostHogFeature flag='show-welcome-message' match={true}>
392
369
  <div>
@@ -410,11 +387,11 @@ If your flag has a payload, you can pass a function to children whose first argu
410
387
 
411
388
  React
412
389
 
413
- PostHog AI
414
-
415
390
  ```jsx
416
391
  import { PostHogFeature } from '@posthog/react'
392
+
417
393
  function App() {
394
+
418
395
  return (
419
396
  <PostHogFeature flag='show-welcome-message' match={true}>
420
397
  {(payload) => {
@@ -436,8 +413,6 @@ You can configure the `feature_flag_request_timeout_ms` parameter when initializ
436
413
 
437
414
  JavaScript
438
415
 
439
- PostHog AI
440
-
441
416
  ```javascript
442
417
  posthog.init('<ph_project_token>', {
443
418
  api_host: 'https://us.i.posthog.com',
@@ -453,8 +428,6 @@ When using the PostHog SDK, it's important to handle potential errors that may o
453
428
 
454
429
  JavaScript
455
430
 
456
- PostHog AI
457
-
458
431
  ```javascript
459
432
  function handleFeatureFlag(client, flagKey, distinctId) {
460
433
  try {
@@ -468,6 +441,7 @@ function handleFeatureFlag(client, flagKey, distinctId) {
468
441
  throw error;
469
442
  }
470
443
  }
444
+
471
445
  // Usage example
472
446
  try {
473
447
  const flagEnabled = handleFeatureFlag(client, 'new-feature', 'user-123');
@@ -495,10 +469,9 @@ Call `client.evaluateFlags()` once for the user, then read values from the retur
495
469
 
496
470
  Node.js
497
471
 
498
- PostHog AI
499
-
500
472
  ```javascript
501
473
  const flags = await client.evaluateFlags('distinct_id_of_your_user')
474
+
502
475
  if (flags.isEnabled('flag-key')) {
503
476
  // Do something differently for this user
504
477
  // Optional: fetch the payload
@@ -510,11 +483,10 @@ if (flags.isEnabled('flag-key')) {
510
483
 
511
484
  Node.js
512
485
 
513
- PostHog AI
514
-
515
486
  ```javascript
516
487
  const flags = await client.evaluateFlags('distinct_id_of_your_user')
517
488
  const enabledVariant = flags.getFlag('flag-key')
489
+
518
490
  if (enabledVariant === 'variant-key') { // replace 'variant-key' with the key of your variant
519
491
  // Do something differently for this user
520
492
  // Optional: fetch the payload
@@ -540,13 +512,13 @@ Pass the same `flags` object that you used for branching. This attaches the exac
540
512
 
541
513
  Node.js
542
514
 
543
- PostHog AI
544
-
545
515
  ```javascript
546
516
  const flags = await client.evaluateFlags('distinct_id_of_your_user')
517
+
547
518
  if (flags.isEnabled('flag-key')) {
548
519
  // Do something differently for this user
549
520
  }
521
+
550
522
  client.capture({
551
523
  distinctId: 'distinct_id_of_your_user',
552
524
  event: 'event_name',
@@ -560,8 +532,6 @@ To reduce event property bloat, pass a filtered snapshot:
560
532
 
561
533
  Node.js
562
534
 
563
- PostHog AI
564
-
565
535
  ```javascript
566
536
  // Attach only flags accessed with isEnabled() or getFlag() before this call
567
537
  client.capture({
@@ -569,6 +539,7 @@ client.capture({
569
539
  event: 'event_name',
570
540
  flags: flags.onlyAccessed(),
571
541
  })
542
+
572
543
  // Attach only specific flags
573
544
  client.capture({
574
545
  distinctId: 'distinct_id_of_your_user',
@@ -585,8 +556,6 @@ In the event properties, include `$feature/feature_flag_name: variant_key`:
585
556
 
586
557
  Node.js
587
558
 
588
- PostHog AI
589
-
590
559
  ```javascript
591
560
  client.capture({
592
561
  distinctId: 'distinct_id_of_your_user',
@@ -604,8 +573,6 @@ By default, `evaluateFlags()` evaluates every flag for the user. If you only nee
604
573
 
605
574
  Node.js
606
575
 
607
- PostHog AI
608
-
609
576
  ```javascript
610
577
  const flags = await client.evaluateFlags('distinct_id_of_your_user', {
611
578
  flagKeys: ['checkout-flow', 'new-dashboard'],
@@ -630,8 +597,6 @@ For example:
630
597
 
631
598
  Node.js
632
599
 
633
- PostHog AI
634
-
635
600
  ```javascript
636
601
  const flags = await client.evaluateFlags('distinct_id_of_the_user', {
637
602
  personProperties: {
@@ -650,6 +615,7 @@ const flags = await client.evaluateFlags('distinct_id_of_the_user', {
650
615
  },
651
616
  },
652
617
  })
618
+
653
619
  if (flags.isEnabled('flag-key')) {
654
620
  // Do something differently for this user
655
621
  }
@@ -688,8 +654,6 @@ You can configure the `featureFlagsRequestTimeoutMs` parameter when initializing
688
654
 
689
655
  JavaScript
690
656
 
691
- PostHog AI
692
-
693
657
  ```javascript
694
658
  const client = new PostHog('<ph_project_token>', {
695
659
  host: 'https://us.i.posthog.com',
@@ -709,10 +673,9 @@ Call `posthog.evaluate_flags()` once for the user, then read values from the ret
709
673
 
710
674
  Python
711
675
 
712
- PostHog AI
713
-
714
676
  ```python
715
677
  flags = posthog.evaluate_flags("distinct_id_of_your_user")
678
+
716
679
  if flags.is_enabled("flag-key"):
717
680
  # Do something differently for this user
718
681
  # Optional: fetch the payload
@@ -723,11 +686,11 @@ if flags.is_enabled("flag-key"):
723
686
 
724
687
  Python
725
688
 
726
- PostHog AI
727
-
728
689
  ```python
729
690
  flags = posthog.evaluate_flags("distinct_id_of_your_user")
691
+
730
692
  enabled_variant = flags.get_flag("flag-key")
693
+
731
694
  if enabled_variant == "variant-key": # replace "variant-key" with the key of your variant
732
695
  # Do something differently for this user
733
696
  # Optional: fetch the payload
@@ -752,13 +715,13 @@ Pass the same `flags` object that you used for branching. This attaches the exac
752
715
 
753
716
  Python
754
717
 
755
- PostHog AI
756
-
757
718
  ```python
758
719
  flags = posthog.evaluate_flags("distinct_id_of_your_user")
720
+
759
721
  if flags.is_enabled("flag-key"):
760
722
  # Do something differently for this user
761
723
  pass
724
+
762
725
  posthog.capture(
763
726
  "event_name",
764
727
  distinct_id="distinct_id_of_your_user",
@@ -772,8 +735,6 @@ To reduce event property bloat, pass a filtered snapshot:
772
735
 
773
736
  Python
774
737
 
775
- PostHog AI
776
-
777
738
  ```python
778
739
  # Attach only flags accessed with is_enabled() or get_flag() before this call
779
740
  posthog.capture(
@@ -781,6 +742,7 @@ posthog.capture(
781
742
  distinct_id="distinct_id_of_your_user",
782
743
  flags=flags.only_accessed(),
783
744
  )
745
+
784
746
  # Attach only specific flags
785
747
  posthog.capture(
786
748
  "event_name",
@@ -797,8 +759,6 @@ In the event properties, include `$feature/feature_flag_name: variant_key`:
797
759
 
798
760
  Python
799
761
 
800
- PostHog AI
801
-
802
762
  ```python
803
763
  posthog.capture(
804
764
  "event_name",
@@ -816,8 +776,6 @@ By default, `posthog.evaluate_flags()` evaluates every flag for the user. If you
816
776
 
817
777
  Python
818
778
 
819
- PostHog AI
820
-
821
779
  ```python
822
780
  flags = posthog.evaluate_flags(
823
781
  "distinct_id_of_your_user",
@@ -843,8 +801,6 @@ For example:
843
801
 
844
802
  Python
845
803
 
846
- PostHog AI
847
-
848
804
  ```python
849
805
  flags = posthog.evaluate_flags(
850
806
  "distinct_id_of_the_user",
@@ -858,6 +814,7 @@ flags = posthog.evaluate_flags(
858
814
  "another_group_type": {"group_property_name": "value"},
859
815
  },
860
816
  )
817
+
861
818
  if flags.is_enabled("flag-key"):
862
819
  # Do something differently for this user
863
820
  ```
@@ -895,8 +852,6 @@ You can configure the `feature_flags_request_timeout_seconds` parameter when ini
895
852
 
896
853
  Python
897
854
 
898
- PostHog AI
899
-
900
855
  ```python
901
856
  posthog = Posthog(
902
857
  "<ph_project_token>",
@@ -917,10 +872,9 @@ Call `PostHog::evaluateFlags()` once for the user, then read values from the ret
917
872
 
918
873
  PHP
919
874
 
920
- PostHog AI
921
-
922
875
  ```php
923
876
  $flags = PostHog::evaluateFlags('distinct_id_of_your_user');
877
+
924
878
  if ($flags->isEnabled('flag-key')) {
925
879
  // Do something differently for this user
926
880
  // Optional: fetch the payload
@@ -932,11 +886,11 @@ if ($flags->isEnabled('flag-key')) {
932
886
 
933
887
  PHP
934
888
 
935
- PostHog AI
936
-
937
889
  ```php
938
890
  $flags = PostHog::evaluateFlags('distinct_id_of_your_user');
891
+
939
892
  $enabledVariant = $flags->getFlag('flag-key');
893
+
940
894
  if ($enabledVariant === 'variant-key') { // replace 'variant-key' with the key of your variant
941
895
  // Do something differently for this user
942
896
  // Optional: fetch the payload
@@ -964,13 +918,13 @@ Pass the same `flags` object that you used for branching. This attaches the exac
964
918
 
965
919
  PHP
966
920
 
967
- PostHog AI
968
-
969
921
  ```php
970
922
  $flags = PostHog::evaluateFlags('distinct_id_of_your_user');
923
+
971
924
  if ($flags->isEnabled('flag-key')) {
972
925
  // Do something differently for this user
973
926
  }
927
+
974
928
  PostHog::capture([
975
929
  'distinctId' => 'distinct_id_of_your_user',
976
930
  'event' => 'event_name',
@@ -984,8 +938,6 @@ To reduce event property bloat, pass a filtered snapshot:
984
938
 
985
939
  PHP
986
940
 
987
- PostHog AI
988
-
989
941
  ```php
990
942
  // Attach only flags accessed with isEnabled() or getFlag() before this call
991
943
  PostHog::capture([
@@ -993,6 +945,7 @@ PostHog::capture([
993
945
  'event' => 'event_name',
994
946
  'flags' => $flags->onlyAccessed(),
995
947
  ]);
948
+
996
949
  // Attach only specific flags
997
950
  PostHog::capture([
998
951
  'distinctId' => 'distinct_id_of_your_user',
@@ -1009,8 +962,6 @@ In the event properties, include `$feature/feature_flag_name: variant_key`:
1009
962
 
1010
963
  PHP
1011
964
 
1012
- PostHog AI
1013
-
1014
965
  ```php
1015
966
  PostHog::capture([
1016
967
  'distinctId' => 'distinct_id_of_your_user',
@@ -1028,8 +979,6 @@ By default, `evaluateFlags()` evaluates every flag for the user. If you only nee
1028
979
 
1029
980
  PHP
1030
981
 
1031
- PostHog AI
1032
-
1033
982
  ```php
1034
983
  $flags = PostHog::evaluateFlags(
1035
984
  distinctId: 'distinct_id_of_your_user',
@@ -1043,8 +992,6 @@ $flags = PostHog::evaluateFlags(
1043
992
 
1044
993
  PHP
1045
994
 
1046
- PostHog AI
1047
-
1048
995
  ```php
1049
996
  $flags = PostHog::evaluateFlags(
1050
997
  distinctId: 'distinct_id_of_your_user',
@@ -1075,8 +1022,6 @@ For example:
1075
1022
 
1076
1023
  PHP
1077
1024
 
1078
- PostHog AI
1079
-
1080
1025
  ```php
1081
1026
  $flags = PostHog::evaluateFlags(
1082
1027
  distinctId: 'distinct_id_of_the_user',
@@ -1090,6 +1035,7 @@ $flags = PostHog::evaluateFlags(
1090
1035
  'another_group_type' => ['group_property_name' => 'value'],
1091
1036
  ],
1092
1037
  );
1038
+
1093
1039
  if ($flags->isEnabled('flag-key')) {
1094
1040
  // Do something differently for this user
1095
1041
  }
@@ -1128,8 +1074,6 @@ You can configure the `feature_flag_request_timeout_ms` parameter when initializ
1128
1074
 
1129
1075
  PHP
1130
1076
 
1131
- PostHog AI
1132
-
1133
1077
  ```php
1134
1078
  PostHog::init("<ph_project_token>",
1135
1079
  [
@@ -1151,10 +1095,9 @@ Call `posthog.evaluate_flags()` once for the user, then read values from the ret
1151
1095
 
1152
1096
  Ruby
1153
1097
 
1154
- PostHog AI
1155
-
1156
1098
  ```ruby
1157
1099
  flags = posthog.evaluate_flags('distinct_id_of_your_user')
1100
+
1158
1101
  if flags.enabled?('flag-key')
1159
1102
  # Do something differently for this user
1160
1103
  # Optional: fetch the payload
@@ -1166,11 +1109,11 @@ end
1166
1109
 
1167
1110
  Ruby
1168
1111
 
1169
- PostHog AI
1170
-
1171
1112
  ```ruby
1172
1113
  flags = posthog.evaluate_flags('distinct_id_of_your_user')
1114
+
1173
1115
  enabled_variant = flags.get_flag('flag-key')
1116
+
1174
1117
  if enabled_variant == 'variant-key' # replace 'variant-key' with the key of your variant
1175
1118
  # Do something differently for this user
1176
1119
  # Optional: fetch the payload
@@ -1196,13 +1139,13 @@ Pass the same `flags` object that you used for branching. This attaches the exac
1196
1139
 
1197
1140
  Ruby
1198
1141
 
1199
- PostHog AI
1200
-
1201
1142
  ```ruby
1202
1143
  flags = posthog.evaluate_flags('distinct_id_of_your_user')
1144
+
1203
1145
  if flags.enabled?('flag-key')
1204
1146
  # Do something differently for this user
1205
1147
  end
1148
+
1206
1149
  posthog.capture({
1207
1150
  distinct_id: 'distinct_id_of_your_user',
1208
1151
  event: 'event_name',
@@ -1216,8 +1159,6 @@ To reduce event property bloat, pass a filtered snapshot:
1216
1159
 
1217
1160
  Ruby
1218
1161
 
1219
- PostHog AI
1220
-
1221
1162
  ```ruby
1222
1163
  # Attach only flags accessed with enabled?() or get_flag() before this call
1223
1164
  posthog.capture({
@@ -1225,6 +1166,7 @@ posthog.capture({
1225
1166
  event: 'event_name',
1226
1167
  flags: flags.only_accessed,
1227
1168
  })
1169
+
1228
1170
  # Attach only specific flags
1229
1171
  posthog.capture({
1230
1172
  distinct_id: 'distinct_id_of_your_user',
@@ -1241,8 +1183,6 @@ In the event properties, include `$feature/feature_flag_name: variant_key`:
1241
1183
 
1242
1184
  Ruby
1243
1185
 
1244
- PostHog AI
1245
-
1246
1186
  ```ruby
1247
1187
  posthog.capture({
1248
1188
  distinct_id: 'distinct_id_of_your_user',
@@ -1260,8 +1200,6 @@ By default, `evaluate_flags()` evaluates every flag for the user. If you only ne
1260
1200
 
1261
1201
  Ruby
1262
1202
 
1263
- PostHog AI
1264
-
1265
1203
  ```ruby
1266
1204
  flags = posthog.evaluate_flags(
1267
1205
  'distinct_id_of_your_user',
@@ -1275,8 +1213,6 @@ If you want to skip the remote `/flags` request and only use locally cached defi
1275
1213
 
1276
1214
  Ruby
1277
1215
 
1278
- PostHog AI
1279
-
1280
1216
  ```ruby
1281
1217
  flags = posthog.evaluate_flags(
1282
1218
  'distinct_id_of_your_user',
@@ -1290,8 +1226,6 @@ Pass `disable_geoip: true` to disable GeoIP lookup for remote flag evaluation:
1290
1226
 
1291
1227
  Ruby
1292
1228
 
1293
- PostHog AI
1294
-
1295
1229
  ```ruby
1296
1230
  flags = posthog.evaluate_flags(
1297
1231
  'distinct_id_of_your_user',
@@ -1317,8 +1251,6 @@ For example:
1317
1251
 
1318
1252
  Ruby
1319
1253
 
1320
- PostHog AI
1321
-
1322
1254
  ```ruby
1323
1255
  flags = posthog.evaluate_flags(
1324
1256
  'distinct_id_of_the_user',
@@ -1338,6 +1270,7 @@ flags = posthog.evaluate_flags(
1338
1270
  },
1339
1271
  },
1340
1272
  )
1273
+
1341
1274
  if flags.enabled?('flag-key')
1342
1275
  # Do something differently for this user
1343
1276
  end
@@ -1376,8 +1309,6 @@ You can configure the `feature_flag_request_timeout_seconds` parameter when init
1376
1309
 
1377
1310
  Ruby
1378
1311
 
1379
- PostHog AI
1380
-
1381
1312
  ```ruby
1382
1313
  posthog = PostHog::Client.new({
1383
1314
  # rest of your configuration...
@@ -1397,8 +1328,6 @@ Call `client.EvaluateFlags()` once for the user, then read values from the retur
1397
1328
 
1398
1329
  Go
1399
1330
 
1400
- PostHog AI
1401
-
1402
1331
  ```go
1403
1332
  flags, err := client.EvaluateFlags(posthog.EvaluateFlagsPayload{
1404
1333
  DistinctId: "distinct_id_of_your_user",
@@ -1406,6 +1335,7 @@ flags, err := client.EvaluateFlags(posthog.EvaluateFlagsPayload{
1406
1335
  if err != nil {
1407
1336
  // Handle error (e.g. capture error and fallback to default behavior)
1408
1337
  }
1338
+
1409
1339
  if flags.IsEnabled("flag-key") {
1410
1340
  // Do something differently for this user
1411
1341
  // Optional: fetch the payload
@@ -1417,8 +1347,6 @@ if flags.IsEnabled("flag-key") {
1417
1347
 
1418
1348
  Go
1419
1349
 
1420
- PostHog AI
1421
-
1422
1350
  ```go
1423
1351
  flags, err := client.EvaluateFlags(posthog.EvaluateFlagsPayload{
1424
1352
  DistinctId: "distinct_id_of_your_user",
@@ -1426,7 +1354,9 @@ flags, err := client.EvaluateFlags(posthog.EvaluateFlagsPayload{
1426
1354
  if err != nil {
1427
1355
  // Handle error (e.g. capture error and fallback to default behavior)
1428
1356
  }
1357
+
1429
1358
  enabledVariant := flags.GetFlag("flag-key")
1359
+
1430
1360
  if enabledVariant == "variant-key" { // replace "variant-key" with the key of your variant
1431
1361
  // Do something differently for this user
1432
1362
  // Optional: fetch the payload
@@ -1452,8 +1382,6 @@ Pass the same `flags` object that you used for branching. This attaches the exac
1452
1382
 
1453
1383
  Go
1454
1384
 
1455
- PostHog AI
1456
-
1457
1385
  ```go
1458
1386
  flags, err := client.EvaluateFlags(posthog.EvaluateFlagsPayload{
1459
1387
  DistinctId: "distinct_id_of_your_user",
@@ -1461,9 +1389,11 @@ flags, err := client.EvaluateFlags(posthog.EvaluateFlagsPayload{
1461
1389
  if err != nil {
1462
1390
  // Handle error
1463
1391
  }
1392
+
1464
1393
  if flags.IsEnabled("flag-key") {
1465
1394
  // Do something differently for this user
1466
1395
  }
1396
+
1467
1397
  client.Enqueue(posthog.Capture{
1468
1398
  DistinctId: "distinct_id_of_your_user",
1469
1399
  Event: "event_name",
@@ -1477,8 +1407,6 @@ To reduce event property bloat, pass a filtered snapshot:
1477
1407
 
1478
1408
  Go
1479
1409
 
1480
- PostHog AI
1481
-
1482
1410
  ```go
1483
1411
  // Attach only flags accessed with IsEnabled() or GetFlag() before this call
1484
1412
  client.Enqueue(posthog.Capture{
@@ -1486,6 +1414,7 @@ client.Enqueue(posthog.Capture{
1486
1414
  Event: "event_name",
1487
1415
  Flags: flags.OnlyAccessed(),
1488
1416
  })
1417
+
1489
1418
  // Attach only specific flags
1490
1419
  client.Enqueue(posthog.Capture{
1491
1420
  DistinctId: "distinct_id_of_your_user",
@@ -1502,8 +1431,6 @@ In the event properties, include `$feature/feature_flag_name: variant_key`:
1502
1431
 
1503
1432
  Go
1504
1433
 
1505
- PostHog AI
1506
-
1507
1434
  ```go
1508
1435
  client.Enqueue(posthog.Capture{
1509
1436
  DistinctId: "distinct_id_of_your_user",
@@ -1519,8 +1446,6 @@ By default, `EvaluateFlags()` evaluates every flag for the user. If you only nee
1519
1446
 
1520
1447
  Go
1521
1448
 
1522
- PostHog AI
1523
-
1524
1449
  ```go
1525
1450
  flags, err := client.EvaluateFlags(posthog.EvaluateFlagsPayload{
1526
1451
  DistinctId: "distinct_id_of_your_user",
@@ -1546,8 +1471,6 @@ For example:
1546
1471
 
1547
1472
  Go
1548
1473
 
1549
- PostHog AI
1550
-
1551
1474
  ```go
1552
1475
  flags, err := client.EvaluateFlags(posthog.EvaluateFlagsPayload{
1553
1476
  DistinctId: "distinct_id_of_the_user",
@@ -1566,6 +1489,7 @@ flags, err := client.EvaluateFlags(posthog.EvaluateFlagsPayload{
1566
1489
  if err != nil {
1567
1490
  // Handle error
1568
1491
  }
1492
+
1569
1493
  if flags.IsEnabled("flag-key") {
1570
1494
  // Do something differently for this user
1571
1495
  }
@@ -1604,10 +1528,9 @@ You can configure the `FeatureFlagRequestTimeout` parameter when initializing yo
1604
1528
 
1605
1529
  Go
1606
1530
 
1607
- PostHog AI
1608
-
1609
1531
  ```go
1610
1532
  // import "time"
1533
+
1611
1534
  client, _ := posthog.NewWithConfig(
1612
1535
  os.Getenv("<ph_project_token>"),
1613
1536
  posthog.Config{
@@ -1631,17 +1554,19 @@ There are two ways to implement feature flags in React Native:
1631
1554
 
1632
1555
  React Native
1633
1556
 
1634
- PostHog AI
1635
-
1636
1557
  ```jsx
1637
1558
  import { useFeatureFlag } from 'posthog-react-native'
1559
+
1638
1560
  const MyComponent = () => {
1639
1561
  const booleanFlag = useFeatureFlag('key-for-your-boolean-flag')
1562
+
1640
1563
  if (booleanFlag === undefined) {
1641
1564
  // the response is undefined if the flags are being loaded
1642
1565
  return null
1643
1566
  }
1567
+
1644
1568
  // Optional use the 'useFeatureFlagWithPayload' hook for fetching the feature flag payload
1569
+
1645
1570
  return booleanFlag ? <Text>Testing feature 😄</Text> : <Text>Not Testing feature 😢</Text>
1646
1571
  }
1647
1572
  ```
@@ -1650,19 +1575,21 @@ const MyComponent = () => {
1650
1575
 
1651
1576
  React Native
1652
1577
 
1653
- PostHog AI
1654
-
1655
1578
  ```jsx
1656
1579
  import { useFeatureFlag } from 'posthog-react-native'
1580
+
1657
1581
  const MyComponent = () => {
1658
1582
  const multiVariantFeature = useFeatureFlag('key-for-your-multivariate-flag')
1583
+
1659
1584
  if (multiVariantFeature === undefined) {
1660
1585
  // the response is undefined if the flags are being loaded
1661
1586
  return null
1662
1587
  } else if (multiVariantFeature === 'variant-name') { // replace 'variant-name' with the name of your variant
1663
1588
  // Do something
1664
1589
  }
1590
+
1665
1591
  // Optional use the 'useFeatureFlagWithPayload' hook for fetching the feature flag payload
1592
+
1666
1593
  return <div/>
1667
1594
  }
1668
1595
  ```
@@ -1671,15 +1598,16 @@ const MyComponent = () => {
1671
1598
 
1672
1599
  React Native
1673
1600
 
1674
- PostHog AI
1675
-
1676
1601
  ```jsx
1677
1602
  // Defaults to undefined if not loaded yet or if there was a problem loading
1678
1603
  posthog.isFeatureEnabled('key-for-your-boolean-flag')
1604
+
1679
1605
  // Defaults to undefined if not loaded yet or if there was a problem loading
1680
1606
  posthog.getFeatureFlag('key-for-your-boolean-flag')
1607
+
1681
1608
  // Multivariant feature flags are returned as a string
1682
1609
  posthog.getFeatureFlag('key-for-your-multivariate-flag')
1610
+
1683
1611
  // Optional: fetch the payload (returns 'JsonType' or undefined if not loaded yet or if there was a problem loading)
1684
1612
  posthog.getFeatureFlagResult('key-for-your-multivariate-flag')?.payload
1685
1613
  ```
@@ -1690,8 +1618,6 @@ You can inspect all currently loaded feature flags with `getAllFeatureFlags()`.
1690
1618
 
1691
1619
  React Native
1692
1620
 
1693
- PostHog AI
1694
-
1695
1621
  ```jsx
1696
1622
  for (const flag of posthog.getAllFeatureFlags()) {
1697
1623
  console.log(flag.key, flag.enabled, flag.variant, flag.payload)
@@ -1708,8 +1634,6 @@ To handle this, you can use the `onFeatureFlags` callback to wait for the featur
1708
1634
 
1709
1635
  React Native
1710
1636
 
1711
- PostHog AI
1712
-
1713
1637
  ```jsx
1714
1638
  posthog.onFeatureFlags((flags) => {
1715
1639
  // feature flags are guaranteed to be available at this point
@@ -1727,8 +1651,6 @@ If want to manually trigger a refresh, you can call `reloadFeatureFlagsAsync()`:
1727
1651
 
1728
1652
  React Native
1729
1653
 
1730
- PostHog AI
1731
-
1732
1654
  ```jsx
1733
1655
  posthog.reloadFeatureFlagsAsync().then((refreshedFlags) => console.log(refreshedFlags))
1734
1656
  ```
@@ -1737,8 +1659,6 @@ Or when you want to trigger the reload, but don't care about the result:
1737
1659
 
1738
1660
  React Native
1739
1661
 
1740
- PostHog AI
1741
-
1742
1662
  ```jsx
1743
1663
  posthog.reloadFeatureFlags()
1744
1664
  ```
@@ -1753,8 +1673,6 @@ To ensure fresh flag values:
1753
1673
 
1754
1674
  React Native
1755
1675
 
1756
- PostHog AI
1757
-
1758
1676
  ```jsx
1759
1677
  // Force refresh on app start
1760
1678
  await posthog.reloadFeatureFlagsAsync()
@@ -1764,8 +1682,6 @@ Or clear cached values for inactive users:
1764
1682
 
1765
1683
  React Native
1766
1684
 
1767
- PostHog AI
1768
-
1769
1685
  ```jsx
1770
1686
  if (lastActiveDate < migrationDate) {
1771
1687
  posthog.reset() // Clears all cached data
@@ -1778,8 +1694,6 @@ You can configure the `featureFlagsRequestTimeoutMs` parameter when initializing
1778
1694
 
1779
1695
  React Native
1780
1696
 
1781
- PostHog AI
1782
-
1783
1697
  ```jsx
1784
1698
  export const posthog = new PostHog('<ph_project_token>', {
1785
1699
  // usually 'https://us.i.posthog.com' or 'https://eu.i.posthog.com'
@@ -1794,8 +1708,6 @@ When using the PostHog SDK, it's important to handle potential errors that may o
1794
1708
 
1795
1709
  React Native
1796
1710
 
1797
- PostHog AI
1798
-
1799
1711
  ```jsx
1800
1712
  function handleFeatureFlag(client, flagKey, distinctId) {
1801
1713
  try {
@@ -1809,6 +1721,7 @@ function handleFeatureFlag(client, flagKey, distinctId) {
1809
1721
  throw error;
1810
1722
  }
1811
1723
  }
1724
+
1812
1725
  // Usage example
1813
1726
  try {
1814
1727
  const flagEnabled = handleFeatureFlag(client, 'new-feature', 'user-123');
@@ -1830,8 +1743,6 @@ Sometimes, you might want to evaluate feature flags using properties that haven'
1830
1743
 
1831
1744
  React Native
1832
1745
 
1833
- PostHog AI
1834
-
1835
1746
  ```jsx
1836
1747
  posthog.setPersonPropertiesForFlags({'property1': 'value', property2: 'value2'})
1837
1748
  ```
@@ -1842,8 +1753,6 @@ Whenever you set these properties, we also trigger a reload of feature flags to
1842
1753
 
1843
1754
  React Native
1844
1755
 
1845
- PostHog AI
1846
-
1847
1756
  ```jsx
1848
1757
  posthog.setPersonPropertiesForFlags({'property1': 'value', property2: 'value2'}, false)
1849
1758
  ```
@@ -1852,8 +1761,6 @@ At any point, you can reset these properties by calling `resetPersonPropertiesFo
1852
1761
 
1853
1762
  React Native
1854
1763
 
1855
- PostHog AI
1856
-
1857
1764
  ```jsx
1858
1765
  posthog.resetPersonPropertiesForFlags()
1859
1766
  ```
@@ -1862,11 +1769,10 @@ The same holds for [group](/docs/product-analytics/group-analytics.md) propertie
1862
1769
 
1863
1770
  React Native
1864
1771
 
1865
- PostHog AI
1866
-
1867
1772
  ```jsx
1868
1773
  // set properties for a group
1869
1774
  posthog.setGroupPropertiesForFlags({'company': {'property1': 'value', property2: 'value2'}})
1775
+
1870
1776
  // reset properties for all groups:
1871
1777
  posthog.resetGroupPropertiesForFlags()
1872
1778
  ```
@@ -1899,13 +1805,13 @@ This enables any geolocation-based flags to work without manually setting these
1899
1805
 
1900
1806
  Kotlin
1901
1807
 
1902
- PostHog AI
1903
-
1904
1808
  ```kotlin
1905
1809
  import com.posthog.PostHog
1810
+
1906
1811
  val result = PostHog.getFeatureFlagResult("flag-key")
1907
1812
  if (result?.enabled == true) {
1908
1813
  // Do something differently for this user
1814
+
1909
1815
  // Optional: fetch the payload from the same evaluation result
1910
1816
  val matchedFlagPayload = result.payload
1911
1817
  }
@@ -1915,13 +1821,13 @@ if (result?.enabled == true) {
1915
1821
 
1916
1822
  Kotlin
1917
1823
 
1918
- PostHog AI
1919
-
1920
1824
  ```kotlin
1921
1825
  import com.posthog.PostHog
1826
+
1922
1827
  val result = PostHog.getFeatureFlagResult("flag-key")
1923
1828
  if (result?.variant == "variant-key") { // replace "variant-key" with the key of your variant
1924
1829
  // Do something differently for this user
1830
+
1925
1831
  // Optional: fetch the payload from the same evaluation result
1926
1832
  val matchedFlagPayload = result.payload
1927
1833
  }
@@ -1933,10 +1839,9 @@ You can inspect all currently loaded feature flags with `PostHog.getAllFeatureFl
1933
1839
 
1934
1840
  Kotlin
1935
1841
 
1936
- PostHog AI
1937
-
1938
1842
  ```kotlin
1939
1843
  import com.posthog.PostHog
1844
+
1940
1845
  PostHog.getAllFeatureFlags()?.forEach { flag ->
1941
1846
  println("${flag.key} ${flag.enabled} ${flag.variant} ${flag.payload}")
1942
1847
  }
@@ -1952,12 +1857,11 @@ To handle this, you can use the `onFeatureFlags` callback to wait for the featur
1952
1857
 
1953
1858
  Kotlin
1954
1859
 
1955
- PostHog AI
1956
-
1957
1860
  ```kotlin
1958
1861
  import com.posthog.PostHog
1959
1862
  import com.posthog.android.PostHogAndroidConfig
1960
1863
  import com.posthog.PostHogOnFeatureFlags
1864
+
1961
1865
  // During SDK initialization
1962
1866
  val config = PostHogAndroidConfig(apiKey = "<ph_project_token>").apply {
1963
1867
  onFeatureFlags = PostHogOnFeatureFlags {
@@ -1966,6 +1870,7 @@ val config = PostHogAndroidConfig(apiKey = "<ph_project_token>").apply {
1966
1870
  }
1967
1871
  }
1968
1872
  }
1873
+
1969
1874
  // And/or after the SDK is initialized
1970
1875
  PostHog.reloadFeatureFlags {
1971
1876
  if (PostHog.isFeatureEnabled("flag-key")) {
@@ -1980,10 +1885,9 @@ Feature flag values are cached. If something has changed with your user and you'
1980
1885
 
1981
1886
  Kotlin
1982
1887
 
1983
- PostHog AI
1984
-
1985
1888
  ```kotlin
1986
1889
  import com.posthog.PostHog
1890
+
1987
1891
  PostHog.reloadFeatureFlags()
1988
1892
  ```
1989
1893
 
@@ -1993,10 +1897,9 @@ To track when someone sees or interacts with a feature, use `captureFeatureView`
1993
1897
 
1994
1898
  Kotlin
1995
1899
 
1996
- PostHog AI
1997
-
1998
1900
  ```kotlin
1999
1901
  import com.posthog.PostHog
1902
+
2000
1903
  PostHog.captureFeatureView("flag-key", flagVariant = "variant-key")
2001
1904
  PostHog.captureFeatureInteraction("flag-key", flagVariant = "variant-key")
2002
1905
  ```
@@ -2007,11 +1910,10 @@ PostHog.captureFeatureInteraction("flag-key", flagVariant = "variant-key")
2007
1910
 
2008
1911
  Swift
2009
1912
 
2010
- PostHog AI
2011
-
2012
1913
  ```swift
2013
1914
  if let result = PostHogSDK.shared.getFeatureFlagResult("flag-key"), result.enabled {
2014
1915
  // Do something differently for this user
1916
+
2015
1917
  // Optional: fetch the payload from the same evaluation result
2016
1918
  let matchedFlagPayload = result.payload
2017
1919
  }
@@ -2021,11 +1923,10 @@ if let result = PostHogSDK.shared.getFeatureFlagResult("flag-key"), result.enabl
2021
1923
 
2022
1924
  Swift
2023
1925
 
2024
- PostHog AI
2025
-
2026
1926
  ```swift
2027
1927
  if let result = PostHogSDK.shared.getFeatureFlagResult("flag-key"), result.variant == "variant-key" { // replace "variant-key" with the key of your variant
2028
1928
  // Do something differently for this user
1929
+
2029
1930
  // Optional: fetch the payload from the same evaluation result
2030
1931
  let matchedFlagPayload = result.payload
2031
1932
  }
@@ -2037,12 +1938,11 @@ If your payload is a JSON object, you can decode it into a `Decodable` type:
2037
1938
 
2038
1939
  Swift
2039
1940
 
2040
- PostHog AI
2041
-
2042
1941
  ```swift
2043
1942
  struct FlagPayload: Decodable {
2044
1943
  let title: String
2045
1944
  }
1945
+
2046
1946
  if let result = PostHogSDK.shared.getFeatureFlagResult("flag-key"),
2047
1947
  let payload = result.payloadAs(FlagPayload.self) {
2048
1948
  // Use payload.title
@@ -2055,8 +1955,6 @@ You can inspect all currently loaded feature flags with `getAllFeatureFlags()`.
2055
1955
 
2056
1956
  Swift
2057
1957
 
2058
- PostHog AI
2059
-
2060
1958
  ```swift
2061
1959
  for flag in PostHogSDK.shared.getAllFeatureFlags() ?? [] {
2062
1960
  print(flag.key, flag.enabled, flag.variant as Any, flag.payload as Any)
@@ -2069,8 +1967,6 @@ Feature flag values are cached. If something has changed with your user and you'
2069
1967
 
2070
1968
  Swift
2071
1969
 
2072
- PostHog AI
2073
-
2074
1970
  ```swift
2075
1971
  PostHogSDK.shared.reloadFeatureFlags()
2076
1972
  ```
@@ -2085,8 +1981,6 @@ To handle this, you can use the `didReceiveFeatureFlags` notification to wait fo
2085
1981
 
2086
1982
  Swift
2087
1983
 
2088
- PostHog AI
2089
-
2090
1984
  ```swift
2091
1985
  class AppDelegate: NSObject, UIApplicationDelegate {
2092
1986
  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
@@ -2097,13 +1991,18 @@ class AppDelegate: NSObject, UIApplicationDelegate {
2097
1991
  name: PostHogSDK.didReceiveFeatureFlags,
2098
1992
  object: nil
2099
1993
  )
1994
+
2100
1995
  let POSTHOG_PROJECT_TOKEN = "<ph_project_token>"
2101
1996
  // usually 'https://us.i.posthog.com' or 'https://eu.i.posthog.com'
2102
1997
  let POSTHOG_HOST = "https://us.i.posthog.com"
1998
+
2103
1999
  let config = PostHogConfig(projectToken: POSTHOG_PROJECT_TOKEN, host: POSTHOG_HOST)
2000
+
2104
2001
  PostHogSDK.shared.setup(config)
2002
+
2105
2003
  return true
2106
2004
  }
2005
+
2107
2006
  // The "receiveFeatureFlags" method will be called when the SDK receives the feature flags from the server.
2108
2007
  @objc func receiveFeatureFlags() {
2109
2008
  print("receiveFeatureFlags called")
@@ -2115,8 +2014,6 @@ Alternatively, you can use the completion block of the `reloadFeatureFlags(_:)`
2115
2014
 
2116
2015
  Swift
2117
2016
 
2118
- PostHog AI
2119
-
2120
2017
  ```swift
2121
2018
  // Reload feature flags and check if a specific feature is enabled
2122
2019
  PostHogSDK.shared.reloadFeatureFlags {
@@ -2132,8 +2029,6 @@ To track when someone sees or interacts with a feature, use `captureFeatureView`
2132
2029
 
2133
2030
  Swift
2134
2031
 
2135
- PostHog AI
2136
-
2137
2032
  ```swift
2138
2033
  PostHogSDK.shared.captureFeatureView(flag: "flag-key", flagVariant: "variant-key")
2139
2034
  PostHogSDK.shared.captureFeatureInteraction(flag: "flag-key", flagVariant: "variant-key")
@@ -2145,12 +2040,11 @@ PostHogSDK.shared.captureFeatureInteraction(flag: "flag-key", flagVariant: "vari
2145
2040
 
2146
2041
  Dart
2147
2042
 
2148
- PostHog AI
2149
-
2150
2043
  ```dart
2151
2044
  final result = await Posthog().getFeatureFlagResult('flag-key');
2152
2045
  if (result != null && result.enabled) {
2153
2046
  // Do something differently for this user
2047
+
2154
2048
  // Optional: fetch the payload from the same evaluation result
2155
2049
  final matchedFlagPayload = result.payload;
2156
2050
  }
@@ -2160,12 +2054,11 @@ if (result != null && result.enabled) {
2160
2054
 
2161
2055
  Dart
2162
2056
 
2163
- PostHog AI
2164
-
2165
2057
  ```dart
2166
2058
  final result = await Posthog().getFeatureFlagResult('flag-key');
2167
2059
  if (result != null && result.variant == 'variant-key') { // replace 'variant-key' with the key of your variant
2168
2060
  // Do something differently for this user
2061
+
2169
2062
  // Optional: fetch the payload from the same evaluation result
2170
2063
  final matchedFlagPayload = result.payload;
2171
2064
  }
@@ -2183,8 +2076,6 @@ To handle this, you can use the `onFeatureFlags` callback in your config to be n
2183
2076
 
2184
2077
  Dart
2185
2078
 
2186
- PostHog AI
2187
-
2188
2079
  ```dart
2189
2080
  final config = PostHogConfig('<ph_project_token>');
2190
2081
  config.host = 'https://us.i.posthog.com';
@@ -2202,8 +2093,6 @@ Feature flag values are cached. If something has changed with your user and you'
2202
2093
 
2203
2094
  Dart
2204
2095
 
2205
- PostHog AI
2206
-
2207
2096
  ```dart
2208
2097
  await Posthog().reloadFeatureFlags();
2209
2098
  ```
@@ -2220,12 +2109,12 @@ Call `posthog.evaluateFlags()` once for the user, then read values from the retu
2220
2109
 
2221
2110
  Java
2222
2111
 
2223
- PostHog AI
2224
-
2225
2112
  ```java
2226
2113
  PostHogFeatureFlagEvaluations flags = posthog.evaluateFlags("distinct_id_of_your_user");
2114
+
2227
2115
  if (flags.isEnabled("flag-key")) {
2228
2116
  // Do something differently for this user
2117
+
2229
2118
  // Optional: fetch the payload
2230
2119
  String matchedFlagPayload = flags.getFlagPayload("flag-key");
2231
2120
  }
@@ -2235,14 +2124,15 @@ if (flags.isEnabled("flag-key")) {
2235
2124
 
2236
2125
  Java
2237
2126
 
2238
- PostHog AI
2239
-
2240
2127
  ```java
2241
2128
  PostHogFeatureFlagEvaluations flags = posthog.evaluateFlags("distinct_id_of_your_user");
2129
+
2242
2130
  Object flagValue = flags.getFlag("flag-key");
2243
2131
  String enabledVariant = flagValue instanceof String ? (String) flagValue : null;
2132
+
2244
2133
  if ("variant-key".equals(enabledVariant)) { // replace "variant-key" with the key of your variant
2245
2134
  // Do something differently for this user
2135
+
2246
2136
  // Optional: fetch the payload
2247
2137
  String matchedFlagPayload = flags.getFlagPayload("flag-key");
2248
2138
  }
@@ -2266,13 +2156,13 @@ Pass the same `flags` object that you used for branching. This attaches the exac
2266
2156
 
2267
2157
  Java
2268
2158
 
2269
- PostHog AI
2270
-
2271
2159
  ```java
2272
2160
  PostHogFeatureFlagEvaluations flags = posthog.evaluateFlags("distinct_id_of_your_user");
2161
+
2273
2162
  if (flags.isEnabled("flag-key")) {
2274
2163
  // Do something differently for this user
2275
2164
  }
2165
+
2276
2166
  posthog.capture(
2277
2167
  "distinct_id_of_your_user",
2278
2168
  "event_name",
@@ -2288,8 +2178,6 @@ To reduce event property bloat, pass a filtered snapshot:
2288
2178
 
2289
2179
  Java
2290
2180
 
2291
- PostHog AI
2292
-
2293
2181
  ```java
2294
2182
  // Attach only flags accessed with isEnabled() or getFlag() before this call
2295
2183
  posthog.capture(
@@ -2299,6 +2187,7 @@ posthog.capture(
2299
2187
  .flags(flags.onlyAccessed())
2300
2188
  .build()
2301
2189
  );
2190
+
2302
2191
  // Attach only specific flags
2303
2192
  posthog.capture(
2304
2193
  "distinct_id_of_your_user",
@@ -2317,8 +2206,6 @@ In the event properties, include `$feature/feature_flag_name: variant_key`:
2317
2206
 
2318
2207
  Java
2319
2208
 
2320
- PostHog AI
2321
-
2322
2209
  ```java
2323
2210
  posthog.capture(
2324
2211
  "distinct_id_of_your_user",
@@ -2335,10 +2222,9 @@ By default, `evaluateFlags()` evaluates every flag for the user. If you only nee
2335
2222
 
2336
2223
  Java
2337
2224
 
2338
- PostHog AI
2339
-
2340
2225
  ```java
2341
2226
  import java.util.Arrays;
2227
+
2342
2228
  PostHogFeatureFlagEvaluations flags = posthog.evaluateFlags(
2343
2229
  "distinct_id_of_your_user",
2344
2230
  PostHogEvaluateFlagsOptions.builder()
@@ -2365,10 +2251,9 @@ For example:
2365
2251
 
2366
2252
  Java
2367
2253
 
2368
- PostHog AI
2369
-
2370
2254
  ```java
2371
2255
  import com.posthog.server.PostHogEvaluateFlagsOptions;
2256
+
2372
2257
  PostHogFeatureFlagEvaluations flags = posthog.evaluateFlags(
2373
2258
  "distinct_id_of_the_user",
2374
2259
  PostHogEvaluateFlagsOptions.builder()
@@ -2379,6 +2264,7 @@ PostHogFeatureFlagEvaluations flags = posthog.evaluateFlags(
2379
2264
  .personProperty("property_name", "value")
2380
2265
  .build()
2381
2266
  );
2267
+
2382
2268
  if (flags.isEnabled("flag-key")) {
2383
2269
  // Do something differently for this user
2384
2270
  }
@@ -2423,14 +2309,14 @@ Call `client.evaluate_flags()` once for the user, then read values from the retu
2423
2309
 
2424
2310
  Rust
2425
2311
 
2426
- PostHog AI
2427
-
2428
2312
  ```rust
2429
2313
  use posthog_rs::EvaluateFlagsOptions;
2314
+
2430
2315
  let flags = client.evaluate_flags(
2431
2316
  "distinct_id_of_your_user",
2432
2317
  EvaluateFlagsOptions::default(),
2433
2318
  ).await.unwrap();
2319
+
2434
2320
  if flags.is_enabled("flag-key") {
2435
2321
  // Do something differently for this user
2436
2322
  // Optional: fetch the payload
@@ -2442,14 +2328,14 @@ if flags.is_enabled("flag-key") {
2442
2328
 
2443
2329
  Rust
2444
2330
 
2445
- PostHog AI
2446
-
2447
2331
  ```rust
2448
2332
  use posthog_rs::{EvaluateFlagsOptions, FlagValue};
2333
+
2449
2334
  let flags = client.evaluate_flags(
2450
2335
  "distinct_id_of_your_user",
2451
2336
  EvaluateFlagsOptions::default(),
2452
2337
  ).await.unwrap();
2338
+
2453
2339
  match flags.get_flag("flag-key") {
2454
2340
  Some(FlagValue::String(variant)) if variant == "variant-key" => {
2455
2341
  // Do something differently for this user
@@ -2478,17 +2364,18 @@ Pass the same `flags` object that you used for branching. This attaches the exac
2478
2364
 
2479
2365
  Rust
2480
2366
 
2481
- PostHog AI
2482
-
2483
2367
  ```rust
2484
2368
  use posthog_rs::{EvaluateFlagsOptions, Event};
2369
+
2485
2370
  let flags = client.evaluate_flags(
2486
2371
  "distinct_id_of_your_user",
2487
2372
  EvaluateFlagsOptions::default(),
2488
2373
  ).await.unwrap();
2374
+
2489
2375
  if flags.is_enabled("flag-key") {
2490
2376
  // Do something differently for this user
2491
2377
  }
2378
+
2492
2379
  let mut event = Event::new("event_name", "distinct_id_of_your_user");
2493
2380
  event.with_flags(&flags);
2494
2381
  client.capture(event);
@@ -2500,13 +2387,12 @@ To reduce event property bloat, pass a filtered snapshot:
2500
2387
 
2501
2388
  Rust
2502
2389
 
2503
- PostHog AI
2504
-
2505
2390
  ```rust
2506
2391
  // Attach only flags accessed with is_enabled() or get_flag() before this call
2507
2392
  let mut event = Event::new("event_name", "distinct_id_of_your_user");
2508
2393
  event.with_flags(&flags.only_accessed());
2509
2394
  client.capture(event);
2395
+
2510
2396
  // Attach only specific flags
2511
2397
  let mut event = Event::new("event_name", "distinct_id_of_your_user");
2512
2398
  event.with_flags(&flags.only(&["checkout-flow", "new-dashboard"]));
@@ -2521,10 +2407,9 @@ In the event properties, include `$feature/feature_flag_name: variant_key`:
2521
2407
 
2522
2408
  Rust
2523
2409
 
2524
- PostHog AI
2525
-
2526
2410
  ```rust
2527
2411
  use posthog_rs::Event;
2412
+
2528
2413
  let mut event = Event::new("event_name", "distinct_id_of_your_user");
2529
2414
  event.insert_prop("$feature/feature-flag-key", "variant-key").unwrap();
2530
2415
  client.capture(event);
@@ -2536,10 +2421,9 @@ By default, `evaluate_flags()` evaluates every flag for the user. If you only ne
2536
2421
 
2537
2422
  Rust
2538
2423
 
2539
- PostHog AI
2540
-
2541
2424
  ```rust
2542
2425
  use posthog_rs::EvaluateFlagsOptions;
2426
+
2543
2427
  let flags = client.evaluate_flags(
2544
2428
  "distinct_id_of_your_user",
2545
2429
  EvaluateFlagsOptions {
@@ -2563,14 +2447,14 @@ If you're using the blocking client (with `default-features = false`), the API i
2563
2447
 
2564
2448
  Rust
2565
2449
 
2566
- PostHog AI
2567
-
2568
2450
  ```rust
2569
2451
  use posthog_rs::EvaluateFlagsOptions;
2452
+
2570
2453
  let flags = client.evaluate_flags(
2571
2454
  "distinct_id_of_your_user",
2572
2455
  EvaluateFlagsOptions::default(),
2573
2456
  ).unwrap();
2457
+
2574
2458
  if flags.is_enabled("flag-key") {
2575
2459
  // Do something differently for this user
2576
2460
  }
@@ -2588,10 +2472,9 @@ Call `PostHog.FeatureFlags.evaluate_flags/1` once for the user, then read values
2588
2472
 
2589
2473
  Elixir
2590
2474
 
2591
- PostHog AI
2592
-
2593
2475
  ```elixir
2594
2476
  {:ok, snapshot} = PostHog.FeatureFlags.evaluate_flags("distinct_id_of_your_user")
2477
+
2595
2478
  if PostHog.FeatureFlags.Evaluations.enabled?(snapshot, "flag-key") do
2596
2479
  # Do something differently for this user
2597
2480
  # Optional: fetch the payload
@@ -2603,11 +2486,11 @@ end
2603
2486
 
2604
2487
  Elixir
2605
2488
 
2606
- PostHog AI
2607
-
2608
2489
  ```elixir
2609
2490
  {:ok, snapshot} = PostHog.FeatureFlags.evaluate_flags("distinct_id_of_your_user")
2491
+
2610
2492
  enabled_variant = PostHog.FeatureFlags.Evaluations.get_flag(snapshot, "flag-key")
2493
+
2611
2494
  if enabled_variant == "variant-key" do
2612
2495
  # Do something differently for this user
2613
2496
  # Optional: fetch the payload
@@ -2633,13 +2516,13 @@ Put the same `snapshot` object that you used for branching into context. Subsequ
2633
2516
 
2634
2517
  Elixir
2635
2518
 
2636
- PostHog AI
2637
-
2638
2519
  ```elixir
2639
2520
  {:ok, snapshot} = PostHog.FeatureFlags.evaluate_flags("distinct_id_of_your_user")
2521
+
2640
2522
  if PostHog.FeatureFlags.Evaluations.enabled?(snapshot, "flag-key") do
2641
2523
  # Do something differently for this user
2642
2524
  end
2525
+
2643
2526
  PostHog.FeatureFlags.set_in_context(snapshot)
2644
2527
  PostHog.capture("event_name", %{distinct_id: "distinct_id_of_your_user"})
2645
2528
  ```
@@ -2650,15 +2533,15 @@ To reduce event property bloat, put a filtered snapshot in context:
2650
2533
 
2651
2534
  Elixir
2652
2535
 
2653
- PostHog AI
2654
-
2655
2536
  ```elixir
2656
2537
  {:ok, snapshot} = PostHog.FeatureFlags.evaluate_flags("distinct_id_of_your_user")
2538
+
2657
2539
  # Attach only flags accessed with enabled?/2 or get_flag/2 before this call
2658
2540
  PostHog.FeatureFlags.Evaluations.enabled?(snapshot, "flag-key")
2659
2541
  PostHog.FeatureFlags.set_in_context(
2660
2542
  PostHog.FeatureFlags.Evaluations.only_accessed(snapshot)
2661
2543
  )
2544
+
2662
2545
  # Or attach only specific flags
2663
2546
  PostHog.FeatureFlags.set_in_context(
2664
2547
  PostHog.FeatureFlags.Evaluations.only(snapshot, ["checkout-flow", "new-dashboard"])
@@ -2673,8 +2556,6 @@ In the event properties, include `$feature/feature_flag_name: variant_key`:
2673
2556
 
2674
2557
  Elixir
2675
2558
 
2676
- PostHog AI
2677
-
2678
2559
  ```elixir
2679
2560
  PostHog.capture("event_name", %{
2680
2561
  "$feature/feature-flag-key" => "variant-key",
@@ -2688,8 +2569,6 @@ By default, `evaluate_flags/1` evaluates every flag for the user. If you only ne
2688
2569
 
2689
2570
  Elixir
2690
2571
 
2691
- PostHog AI
2692
-
2693
2572
  ```elixir
2694
2573
  {:ok, snapshot} =
2695
2574
  PostHog.FeatureFlags.evaluate_flags(%{
@@ -2716,10 +2595,9 @@ Call `EvaluateFlagsAsync()` once for the user, then read values from the returne
2716
2595
 
2717
2596
  C#
2718
2597
 
2719
- PostHog AI
2720
-
2721
2598
  ```csharp
2722
2599
  var flags = await posthog.EvaluateFlagsAsync("distinct_id_of_your_user");
2600
+
2723
2601
  if (flags.IsEnabled("flag-key"))
2724
2602
  {
2725
2603
  // Do something differently for this user
@@ -2732,11 +2610,11 @@ if (flags.IsEnabled("flag-key"))
2732
2610
 
2733
2611
  C#
2734
2612
 
2735
- PostHog AI
2736
-
2737
2613
  ```csharp
2738
2614
  var flags = await posthog.EvaluateFlagsAsync("distinct_id_of_your_user");
2615
+
2739
2616
  var enabledVariant = flags.GetFlag("flag-key")?.VariantKey;
2617
+
2740
2618
  if (enabledVariant == "variant-key") // replace "variant-key" with the key of your variant
2741
2619
  {
2742
2620
  // Do something differently for this user
@@ -2763,14 +2641,14 @@ Pass the same `flags` object that you used for branching. This attaches the exac
2763
2641
 
2764
2642
  C#
2765
2643
 
2766
- PostHog AI
2767
-
2768
2644
  ```csharp
2769
2645
  var flags = await posthog.EvaluateFlagsAsync("distinct_id_of_your_user");
2646
+
2770
2647
  if (flags.IsEnabled("flag-key"))
2771
2648
  {
2772
2649
  // Do something differently for this user
2773
2650
  }
2651
+
2774
2652
  posthog.Capture(
2775
2653
  "distinct_id_of_your_user",
2776
2654
  "event_name",
@@ -2786,8 +2664,6 @@ To reduce event property bloat, pass a filtered snapshot:
2786
2664
 
2787
2665
  C#
2788
2666
 
2789
- PostHog AI
2790
-
2791
2667
  ```csharp
2792
2668
  // Attach only flags accessed with IsEnabled() or GetFlag() before this call
2793
2669
  posthog.Capture(
@@ -2797,6 +2673,7 @@ posthog.Capture(
2797
2673
  groups: null,
2798
2674
  flags: flags.OnlyAccessed()
2799
2675
  );
2676
+
2800
2677
  // Attach only specific flags
2801
2678
  posthog.Capture(
2802
2679
  "distinct_id_of_your_user",
@@ -2813,8 +2690,6 @@ In the event properties, include `$feature/feature_flag_name: variant_key`:
2813
2690
 
2814
2691
  C#
2815
2692
 
2816
- PostHog AI
2817
-
2818
2693
  ```csharp
2819
2694
  posthog.Capture(
2820
2695
  "distinct_id_of_your_user",
@@ -2833,8 +2708,6 @@ By default, `EvaluateFlagsAsync()` evaluates every flag for the user. If you onl
2833
2708
 
2834
2709
  C#
2835
2710
 
2836
- PostHog AI
2837
-
2838
2711
  ```csharp
2839
2712
  var flags = await posthog.EvaluateFlagsAsync(
2840
2713
  "distinct_id_of_your_user",
@@ -2863,8 +2736,6 @@ For example:
2863
2736
 
2864
2737
  C#
2865
2738
 
2866
- PostHog AI
2867
-
2868
2739
  ```csharp
2869
2740
  var flags = await posthog.EvaluateFlagsAsync(
2870
2741
  "distinct_id_of_the_user",
@@ -2887,6 +2758,7 @@ var flags = await posthog.EvaluateFlagsAsync(
2887
2758
  },
2888
2759
  }
2889
2760
  );
2761
+
2890
2762
  if (flags.IsEnabled("flag-key"))
2891
2763
  {
2892
2764
  // Do something differently for this user
@@ -2930,8 +2802,6 @@ There are 3 steps to implement feature flags using the PostHog API:
2930
2802
 
2931
2803
  #### Request
2932
2804
 
2933
- PostHog AI
2934
-
2935
2805
  ### Terminal
2936
2806
 
2937
2807
  ```shell
@@ -2943,6 +2813,7 @@ curl -v -L --header "Content-Type: application/json" -d ' {
2943
2813
  "group_type": "group_id"
2944
2814
  }
2945
2815
  }' "https://us.i.posthog.com/flags?v=2"
2816
+
2946
2817
  # With configuration (flags + PostHog config)
2947
2818
  curl -v -L --header "Content-Type: application/json" -d ' {
2948
2819
  "api_key": "<ph_project_token>",
@@ -2958,6 +2829,7 @@ curl -v -L --header "Content-Type: application/json" -d ' {
2958
2829
  ```python
2959
2830
  import requests
2960
2831
  import json
2832
+
2961
2833
  # Basic request (flags only)
2962
2834
  url = "https://us.i.posthog.com/flags?v=2"
2963
2835
  headers = {
@@ -2972,6 +2844,7 @@ payload = {
2972
2844
  }
2973
2845
  response = requests.post(url, headers=headers, data=json.dumps(payload))
2974
2846
  print(response.json())
2847
+
2975
2848
  # With configuration (flags + PostHog config)
2976
2849
  url_with_config = "https://us.i.posthog.com/flags?v=2&config=true"
2977
2850
  response_with_config = requests.post(url_with_config, headers=headers, data=json.dumps(payload))
@@ -2982,6 +2855,7 @@ print(response_with_config.json())
2982
2855
 
2983
2856
  ```javascript
2984
2857
  import fetch from "node-fetch";
2858
+
2985
2859
  async function sendFlagsRequest() {
2986
2860
  const headers = {
2987
2861
  "Content-Type": "application/json",
@@ -2993,6 +2867,7 @@ async function sendFlagsRequest() {
2993
2867
  group_type: "group_id",
2994
2868
  },
2995
2869
  };
2870
+
2996
2871
  // Basic request (flags only)
2997
2872
  const url = "https://us.i.posthog.com/flags?v=2";
2998
2873
  const response = await fetch(url, {
@@ -3002,6 +2877,7 @@ async function sendFlagsRequest() {
3002
2877
  });
3003
2878
  const data = await response.json();
3004
2879
  console.log(data);
2880
+
3005
2881
  // With configuration (flags + PostHog config)
3006
2882
  const urlWithConfig = "https://us.i.posthog.com/flags?v=2&config=true";
3007
2883
  const responseWithConfig = await fetch(urlWithConfig, {
@@ -3012,6 +2888,7 @@ async function sendFlagsRequest() {
3012
2888
  const dataWithConfig = await responseWithConfig.json();
3013
2889
  console.log(dataWithConfig);
3014
2890
  }
2891
+
3015
2892
  sendFlagsRequest();
3016
2893
  ```
3017
2894
 
@@ -3027,8 +2904,6 @@ To filter flags by evaluation context, include the `evaluation_contexts` field i
3027
2904
 
3028
2905
  > **Note:** The legacy parameter `evaluation_environments` is also supported for backward compatibility.
3029
2906
 
3030
- PostHog AI
3031
-
3032
2907
  ### Terminal
3033
2908
 
3034
2909
  ```shell
@@ -3044,6 +2919,7 @@ curl -v -L --header "Content-Type: application/json" -d ' {
3044
2919
  ```python
3045
2920
  import requests
3046
2921
  import json
2922
+
3047
2923
  url = "https://us.i.posthog.com/flags?v=2"
3048
2924
  headers = {
3049
2925
  "Content-Type": "application/json"
@@ -3103,8 +2979,6 @@ Evaluation runtime (server vs. client) is automatically detected based on your r
3103
2979
 
3104
2980
  JavaScript
3105
2981
 
3106
- PostHog AI
3107
-
3108
2982
  ```javascript
3109
2983
  // Browser fetch - Detected as CLIENT runtime
3110
2984
  // Will receive: client-only flags + "all" flags
@@ -3124,13 +2998,12 @@ const response = await fetch("https://us.i.posthog.com/flags?v=2", {
3124
2998
 
3125
2999
  Python
3126
3000
 
3127
- PostHog AI
3128
-
3129
3001
  ```python
3130
3002
  # Python requests - Detected as SERVER runtime
3131
3003
  # Will receive: server-only flags + "all" flags
3132
3004
  # Won't receive: client-only flags
3133
3005
  import requests
3006
+
3134
3007
  response = requests.post(
3135
3008
  "https://us.i.posthog.com/flags?v=2",
3136
3009
  json={
@@ -3143,8 +3016,6 @@ response = requests.post(
3143
3016
 
3144
3017
  Terminal
3145
3018
 
3146
- PostHog AI
3147
-
3148
3019
  ```shell
3149
3020
  # curl - Detected as SERVER runtime
3150
3021
  # Will receive: server-only flags + "all" flags
@@ -3158,8 +3029,6 @@ curl -v -L --header "Content-Type: application/json" -d '{
3158
3029
 
3159
3030
  JavaScript
3160
3031
 
3161
- PostHog AI
3162
-
3163
3032
  ```javascript
3164
3033
  // Node.js with custom User-Agent - Control runtime detection
3165
3034
  const response = await fetch("https://us.i.posthog.com/flags?v=2", {
@@ -3181,8 +3050,6 @@ Both features work together as sequential filters:
3181
3050
 
3182
3051
  JavaScript
3183
3052
 
3184
- PostHog AI
3185
-
3186
3053
  ```javascript
3187
3054
  // Example: Production web client
3188
3055
  const response = await fetch("https://us.i.posthog.com/flags?v=2", {
@@ -3197,6 +3064,7 @@ const response = await fetch("https://us.i.posthog.com/flags?v=2", {
3197
3064
  evaluation_contexts: ["production", "web"]
3198
3065
  })
3199
3066
  });
3067
+
3200
3068
  // This request will only receive flags that:
3201
3069
  // 1. Have runtime set to "client" OR "all" (due to browser headers)
3202
3070
  // AND
@@ -3218,8 +3086,6 @@ Use this endpoint when you only need to evaluate feature flags. It returns a res
3218
3086
 
3219
3087
  JSON
3220
3088
 
3221
- PostHog AI
3222
-
3223
3089
  ```json
3224
3090
  {
3225
3091
  "flags": {
@@ -3276,8 +3142,6 @@ Use this endpoint when you need both feature flag evaluation and PostHog configu
3276
3142
 
3277
3143
  JSON
3278
3144
 
3279
- PostHog AI
3280
-
3281
3145
  ```json
3282
3146
  {
3283
3147
  "config": {
@@ -3349,8 +3213,6 @@ For basic response (`/flags?v=2`):
3349
3213
 
3350
3214
  JSON
3351
3215
 
3352
- PostHog AI
3353
-
3354
3216
  ```json
3355
3217
  {
3356
3218
  "flags": {},
@@ -3364,8 +3226,6 @@ For full response with configuration (`/flags?v=2&config=true`):
3364
3226
 
3365
3227
  JSON
3366
3228
 
3367
- PostHog AI
3368
-
3369
3229
  ```json
3370
3230
  {
3371
3231
  "config": {
@@ -3398,8 +3258,6 @@ If you want use your feature flag to breakdown or filter events in your [insight
3398
3258
 
3399
3259
  To do this, include the `$feature/feature_flag_name` property in your event:
3400
3260
 
3401
- PostHog AI
3402
-
3403
3261
  ### Terminal
3404
3262
 
3405
3263
  ```shell
@@ -3418,6 +3276,7 @@ curl -v -L --header "Content-Type: application/json" -d ' {
3418
3276
  ```python
3419
3277
  import requests
3420
3278
  import json
3279
+
3421
3280
  url = "https://us.i.posthog.com/i/v0/e/"
3422
3281
  headers = {
3423
3282
  "Content-Type": "application/json"
@@ -3443,8 +3302,6 @@ You need to include two properties with this event:
3443
3302
  1. `$feature_flag_response`: This is the name of the variant the user has been assigned to e.g., "control" or "test"
3444
3303
  2. `$feature_flag`: This is the key of the feature flag in your experiment.
3445
3304
 
3446
- PostHog AI
3447
-
3448
3305
  ### Terminal
3449
3306
 
3450
3307
  ```shell
@@ -3464,6 +3321,7 @@ curl -v -L --header "Content-Type: application/json" -d ' {
3464
3321
  ```python
3465
3322
  import requests
3466
3323
  import json
3324
+
3467
3325
  url = "https://us.i.posthog.com/i/v0/e/"
3468
3326
  headers = {
3469
3327
  "Content-Type": "application/json"
@@ -3489,8 +3347,6 @@ You can provide properties to evaluate the flag with by using the `person proper
3489
3347
 
3490
3348
  For example:
3491
3349
 
3492
- PostHog AI
3493
-
3494
3350
  ### Terminal
3495
3351
 
3496
3352
  ```shell
@@ -3510,6 +3366,7 @@ curl -v -L --header "Content-Type: application/json" -d ' {
3510
3366
  ```python
3511
3367
  import requests
3512
3368
  import json
3369
+
3513
3370
  url = "https://us.i.posthog.com/flags?v=2"
3514
3371
  headers = {
3515
3372
  "Content-Type": "application/json"
@@ -3533,8 +3390,6 @@ By default, a user's GeoIP properties are set using the IP address they use to c
3533
3390
 
3534
3391
  To override the GeoIP properties used to evaluate a feature flag, provide an IP address in the `HTTP_X_FORWARDED_FOR` when making your `/flags` request:
3535
3392
 
3536
- PostHog AI
3537
-
3538
3393
  ### Terminal
3539
3394
 
3540
3395
  ```shell
@@ -3552,6 +3407,7 @@ curl -v -L \
3552
3407
  ```python
3553
3408
  import requests
3554
3409
  import json
3410
+
3555
3411
  url = "https://us.i.posthog.com/flags?v=2"
3556
3412
  headers = {
3557
3413
  "Content-Type": "application/json",