vybekiit 0.7.3 → 0.7.7

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 (203) hide show
  1. package/dist/bin.js +16607 -7527
  2. package/dist/global-skills/aws-cdk/SKILL.md +2 -1
  3. package/dist/global-skills/aws-cloudformation/SKILL.md +2 -1
  4. package/dist/global-skills/aws-serverless/SKILL.md +45 -44
  5. package/dist/global-skills/aws-serverless/assets/powertools-handler.py +2 -1
  6. package/dist/global-skills/aws-serverless/references/api-gateway.md +50 -470
  7. package/dist/global-skills/aws-serverless/references/architecture.md +47 -186
  8. package/dist/global-skills/aws-serverless/references/concurrency.md +44 -158
  9. package/dist/global-skills/aws-serverless/references/deployment.md +1 -1
  10. package/dist/global-skills/aws-serverless/references/event-sources.md +72 -391
  11. package/dist/global-skills/aws-serverless/references/lambda.md +69 -428
  12. package/dist/global-skills/aws-serverless/references/orchestration.md +65 -384
  13. package/dist/global-skills/aws-serverless/references/production.md +78 -415
  14. package/dist/global-skills/aws-serverless/references/troubleshooting.md +92 -619
  15. package/dist/global-skills/claimable-postgres/SKILL.md +60 -49
  16. package/dist/global-skills/design-my-data/SKILL.md +2 -0
  17. package/dist/global-skills/eas-app-stores/SKILL.md +8 -0
  18. package/dist/global-skills/eas-app-stores/references/play-store.md +2 -0
  19. package/dist/global-skills/eas-hosting/SKILL.md +8 -0
  20. package/dist/global-skills/eas-observe/SKILL.md +30 -8
  21. package/dist/global-skills/eas-observe/agents/openai.yaml +1 -1
  22. package/dist/global-skills/eas-observe/references/metrics.md +54 -3
  23. package/dist/global-skills/eas-observe/references/queries.md +78 -17
  24. package/dist/global-skills/eas-observe/references/setup.md +164 -5
  25. package/dist/global-skills/eas-observe/references/third-party.md +136 -0
  26. package/dist/global-skills/eas-simulator/SKILL.md +63 -11
  27. package/dist/global-skills/eas-simulator/references/controllers.md +21 -2
  28. package/dist/global-skills/eas-simulator/references/run-your-app.md +16 -11
  29. package/dist/global-skills/eas-simulator/references/troubleshooting.md +8 -5
  30. package/dist/global-skills/eas-update-insights/SKILL.md +8 -0
  31. package/dist/global-skills/eas-workflows/SKILL.md +15 -10
  32. package/dist/global-skills/eas-workflows/scripts/package.json +2 -7
  33. package/dist/global-skills/email-best-practices/.github/workflows/sync-skills.yml +30 -0
  34. package/dist/global-skills/email-best-practices/README.md +63 -0
  35. package/dist/global-skills/email-best-practices/references/accessibility.md +189 -0
  36. package/dist/global-skills/email-best-practices/references/compliance.md +125 -0
  37. package/dist/global-skills/email-best-practices/references/deliverability.md +121 -0
  38. package/dist/global-skills/email-best-practices/references/email-capture.md +129 -0
  39. package/dist/global-skills/email-best-practices/references/email-types.md +173 -0
  40. package/dist/global-skills/email-best-practices/references/list-management.md +157 -0
  41. package/dist/global-skills/email-best-practices/references/marketing-emails.md +115 -0
  42. package/dist/global-skills/email-best-practices/references/sending-reliability.md +155 -0
  43. package/dist/global-skills/email-best-practices/references/transactional-email-catalog.md +418 -0
  44. package/dist/global-skills/email-best-practices/references/transactional-emails.md +92 -0
  45. package/dist/global-skills/email-best-practices/references/webhooks-events.md +167 -0
  46. package/dist/global-skills/email-best-practices/tests/README.md +35 -0
  47. package/dist/global-skills/email-best-practices/tests/scenarios/01-spam-deliverability.md +46 -0
  48. package/dist/global-skills/email-best-practices/tests/scenarios/02-multi-region-compliance.md +48 -0
  49. package/dist/global-skills/email-best-practices/tests/scenarios/03-retry-idempotency.md +36 -0
  50. package/dist/global-skills/email-best-practices/tests/scenarios/04-webhook-bounce-handling.md +52 -0
  51. package/dist/global-skills/email-best-practices/tests/scenarios/05-new-saas-email-plan.md +51 -0
  52. package/dist/global-skills/expo-animation/LICENSE +21 -0
  53. package/dist/global-skills/expo-animation/RECIPES.md +385 -0
  54. package/dist/global-skills/expo-animation/SKILL.md +267 -0
  55. package/dist/global-skills/expo-animation/agents/openai.yaml +4 -0
  56. package/dist/global-skills/expo-app-clip/SKILL.md +8 -0
  57. package/dist/global-skills/expo-brownfield/SKILL.md +8 -0
  58. package/dist/global-skills/expo-brownfield/references/brownfield-isolated.md +53 -4
  59. package/dist/global-skills/expo-data-fetching/SKILL.md +8 -0
  60. package/dist/global-skills/expo-design-system/SKILL.md +356 -0
  61. package/dist/global-skills/expo-design-system/agents/openai.yaml +4 -0
  62. package/dist/global-skills/expo-design-system/references/audit.md +185 -0
  63. package/dist/global-skills/expo-dev-client/SKILL.md +8 -0
  64. package/dist/global-skills/expo-dom/SKILL.md +8 -0
  65. package/dist/global-skills/expo-examples/SKILL.md +8 -0
  66. package/dist/global-skills/expo-migrate-module/SKILL.md +113 -0
  67. package/dist/global-skills/expo-migrate-module/agents/openai.yaml +4 -0
  68. package/dist/global-skills/expo-migrate-module/references/compatibility.md +73 -0
  69. package/dist/global-skills/expo-migrate-module/references/example.md +212 -0
  70. package/dist/global-skills/expo-migrate-module/references/migration-map.md +306 -0
  71. package/dist/global-skills/expo-module/SKILL.md +11 -1
  72. package/dist/global-skills/expo-native-ui/SKILL.md +8 -0
  73. package/dist/global-skills/expo-project-structure/SKILL.md +114 -0
  74. package/dist/global-skills/expo-project-structure/agents/openai.yaml +4 -0
  75. package/dist/global-skills/expo-router/SKILL.md +8 -0
  76. package/dist/global-skills/expo-skill-feedback/SKILL.md +66 -33
  77. package/dist/global-skills/expo-skill-feedback/agents/openai.yaml +2 -2
  78. package/dist/global-skills/expo-tailwind-setup/SKILL.md +8 -0
  79. package/dist/global-skills/expo-ui/SKILL.md +8 -0
  80. package/dist/global-skills/expo-upgrade/SKILL.md +15 -1
  81. package/dist/global-skills/expo-web-to-native/SKILL.md +8 -0
  82. package/dist/global-skills/extension-to-functions-codebase/SKILL.md +129 -0
  83. package/dist/global-skills/extension-to-functions-codebase/references/configuration-migration.md +161 -0
  84. package/dist/global-skills/extension-to-functions-codebase/references/destructuring-shim.md +122 -0
  85. package/dist/global-skills/extension-to-functions-codebase/references/signature-mapping.md +84 -0
  86. package/dist/global-skills/firebase-ai-logic-basics/SKILL.md +61 -19
  87. package/dist/global-skills/firebase-ai-logic-basics/references/flutter_setup.md +6 -3
  88. package/dist/global-skills/firebase-app-hosting-basics/SKILL.md +5 -1
  89. package/dist/global-skills/firebase-auth-basics/SKILL.md +4 -2
  90. package/dist/global-skills/firebase-basics/SKILL.md +5 -5
  91. package/dist/global-skills/firebase-crashlytics/SKILL.md +2 -0
  92. package/dist/global-skills/firebase-data-connect/SKILL.md +2 -0
  93. package/dist/global-skills/firebase-firestore/SKILL.md +3 -6
  94. package/dist/global-skills/firebase-hosting-basics/SKILL.md +4 -1
  95. package/dist/global-skills/firebase-remote-config-basics/SKILL.md +5 -1
  96. package/dist/global-skills/firebase-security-rules-auditor/SKILL.md +4 -1
  97. package/dist/global-skills/harden/SKILL.md +2 -1
  98. package/dist/global-skills/instrument-feature-flags/SKILL.md +1 -0
  99. package/dist/global-skills/instrument-feature-flags/references/COMMANDMENTS.md +5 -0
  100. package/dist/global-skills/instrument-feature-flags/references/adding-feature-flag-code.md +6 -4
  101. package/dist/global-skills/instrument-feature-flags/references/android.md +6 -4
  102. package/dist/global-skills/instrument-feature-flags/references/api.md +6 -4
  103. package/dist/global-skills/instrument-feature-flags/references/best-practices.md +6 -4
  104. package/dist/global-skills/instrument-feature-flags/references/django.md +38 -5
  105. package/dist/global-skills/instrument-feature-flags/references/dotnet.md +10 -4
  106. package/dist/global-skills/instrument-feature-flags/references/elixir.md +6 -4
  107. package/dist/global-skills/instrument-feature-flags/references/flask.md +17 -5
  108. package/dist/global-skills/instrument-feature-flags/references/flutter.md +7 -5
  109. package/dist/global-skills/instrument-feature-flags/references/go.md +6 -4
  110. package/dist/global-skills/instrument-feature-flags/references/ios.md +6 -4
  111. package/dist/global-skills/instrument-feature-flags/references/java.md +6 -4
  112. package/dist/global-skills/instrument-feature-flags/references/laravel.md +6 -4
  113. package/dist/global-skills/instrument-feature-flags/references/next-js.md +74 -8
  114. package/dist/global-skills/instrument-feature-flags/references/nodejs.md +6 -4
  115. package/dist/global-skills/instrument-feature-flags/references/php.md +6 -4
  116. package/dist/global-skills/instrument-feature-flags/references/python.md +6 -4
  117. package/dist/global-skills/instrument-feature-flags/references/react-native.md +6 -4
  118. package/dist/global-skills/instrument-feature-flags/references/react.md +6 -4
  119. package/dist/global-skills/instrument-feature-flags/references/ruby-on-rails.md +6 -4
  120. package/dist/global-skills/instrument-feature-flags/references/ruby.md +6 -4
  121. package/dist/global-skills/instrument-feature-flags/references/rust.md +6 -4
  122. package/dist/global-skills/instrument-feature-flags/references/usage.md +41 -4
  123. package/dist/global-skills/instrument-feature-flags/references/web.md +7 -5
  124. package/dist/global-skills/instrument-product-analytics/SKILL.md +2 -1
  125. package/dist/global-skills/instrument-product-analytics/references/COMMANDMENTS.md +5 -0
  126. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-astro-hybrid.md +12 -14
  127. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-astro-ssr.md +25 -21
  128. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-django.md +75 -55
  129. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-fastapi.md +3 -6
  130. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-flask.md +26 -16
  131. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-nuxt-3-6.md +8 -5
  132. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-nuxt-4.md +4 -4
  133. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-react-react-router-7-framework.md +3 -3
  134. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-ruby-on-rails.md +8 -4
  135. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-tanstack-start.md +20 -8
  136. package/dist/global-skills/instrument-product-analytics/references/android.md +46 -4
  137. package/dist/global-skills/instrument-product-analytics/references/angular.md +41 -5
  138. package/dist/global-skills/instrument-product-analytics/references/astro.md +41 -5
  139. package/dist/global-skills/instrument-product-analytics/references/configuration.md +7 -4
  140. package/dist/global-skills/instrument-product-analytics/references/django.md +38 -5
  141. package/dist/global-skills/instrument-product-analytics/references/dotnet.md +10 -4
  142. package/dist/global-skills/instrument-product-analytics/references/elixir.md +6 -4
  143. package/dist/global-skills/instrument-product-analytics/references/flask.md +17 -5
  144. package/dist/global-skills/instrument-product-analytics/references/flutter.md +49 -4
  145. package/dist/global-skills/instrument-product-analytics/references/go.md +6 -4
  146. package/dist/global-skills/instrument-product-analytics/references/identify-users.md +38 -7
  147. package/dist/global-skills/instrument-product-analytics/references/ios.md +14 -4
  148. package/dist/global-skills/instrument-product-analytics/references/laravel.md +6 -4
  149. package/dist/global-skills/instrument-product-analytics/references/next-js.md +74 -8
  150. package/dist/global-skills/instrument-product-analytics/references/nuxt-js-3-6.md +39 -7
  151. package/dist/global-skills/instrument-product-analytics/references/nuxt-js.md +40 -4
  152. package/dist/global-skills/instrument-product-analytics/references/php.md +6 -4
  153. package/dist/global-skills/instrument-product-analytics/references/posthog-python.md +21 -17
  154. package/dist/global-skills/instrument-product-analytics/references/python.md +15 -5
  155. package/dist/global-skills/instrument-product-analytics/references/react-native.md +41 -7
  156. package/dist/global-skills/instrument-product-analytics/references/react-router-v6.md +18 -4
  157. package/dist/global-skills/instrument-product-analytics/references/react-router-v7-data-mode.md +18 -4
  158. package/dist/global-skills/instrument-product-analytics/references/react-router-v7-declarative-mode.md +18 -4
  159. package/dist/global-skills/instrument-product-analytics/references/react-router-v7-framework-mode.md +18 -4
  160. package/dist/global-skills/instrument-product-analytics/references/ruby-on-rails.md +6 -4
  161. package/dist/global-skills/instrument-product-analytics/references/ruby.md +6 -4
  162. package/dist/global-skills/instrument-product-analytics/references/svelte.md +42 -6
  163. package/dist/global-skills/instrument-product-analytics/references/tanstack-start.md +31 -7
  164. package/dist/global-skills/instrument-product-analytics/references/usage.md +41 -4
  165. package/dist/global-skills/instrument-product-analytics/references/vue-js.md +42 -6
  166. package/dist/global-skills/manifest.json +6 -1
  167. package/dist/global-skills/neon/SKILL.md +235 -121
  168. package/dist/global-skills/neon-ai-gateway/SKILL.md +95 -16
  169. package/dist/global-skills/neon-functions/SKILL.md +242 -152
  170. package/dist/global-skills/neon-functions/references/ai-sdk.md +9 -3
  171. package/dist/global-skills/neon-functions/references/mastra-studio.md +1 -1
  172. package/dist/global-skills/neon-functions/references/mcp.md +13 -4
  173. package/dist/global-skills/neon-functions/references/sentry.md +165 -52
  174. package/dist/global-skills/neon-functions/references/sse.md +23 -6
  175. package/dist/global-skills/neon-object-storage/SKILL.md +40 -16
  176. package/dist/global-skills/neon-postgres/SKILL.md +63 -262
  177. package/dist/global-skills/neon-postgres-branches/SKILL.md +61 -50
  178. package/dist/global-skills/neon-postgres-egress-optimizer/SKILL.md +22 -3
  179. package/dist/global-skills/resend/SKILL.md +6 -6
  180. package/dist/global-skills/resend/references/automations.md +2 -2
  181. package/dist/global-skills/resend/references/broadcasts.md +11 -3
  182. package/dist/global-skills/resend/references/domains.md +25 -3
  183. package/dist/global-skills/resend/references/installation.md +7 -7
  184. package/dist/global-skills/setup-payments/SKILL.md +4 -5
  185. package/dist/global-skills/stripe-best-practices/SKILL.md +32 -7
  186. package/dist/global-skills/stripe-best-practices/references/billing.md +11 -1
  187. package/dist/global-skills/stripe-best-practices/references/payments.md +23 -2
  188. package/dist/global-skills/stripe-best-practices/references/security.md +21 -11
  189. package/dist/global-skills/stripe-best-practices/references/tax.md +116 -11
  190. package/dist/global-skills/supabase/CHANGELOG.md +25 -0
  191. package/dist/global-skills/supabase/SKILL.md +5 -1
  192. package/dist/global-skills/supabase-postgres-best-practices/CHANGELOG.md +30 -0
  193. package/dist/global-skills/supabase-postgres-best-practices/SKILL.md +1 -1
  194. package/dist/global-skills/use-kit-mcp/SKILL.md +5 -5
  195. package/dist/global-skills/use-railway/SKILL.md +4 -4
  196. package/dist/global-skills/use-railway/references/iac.md +206 -57
  197. package/dist/global-skills/use-railway/scripts/railway-api.sh +7 -2
  198. package/dist/global-skills/xcode-project-setup/SKILL.md +2 -0
  199. package/package.json +12 -9
  200. package/LICENSE.md +0 -47
  201. package/dist/global-skills/eas-workflows/scripts/validate.js +0 -84
  202. package/dist/global-skills/expo-skill-feedback/scripts/skill-feedback.cjs +0 -118
  203. package/dist/global-skills/neon-functions/references/hono-websockets.md +0 -145
@@ -1,3 +1,9 @@
1
+ > AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt
2
+
3
+ # Next.js - Docs
4
+
5
+ Copy page
6
+
1
7
  # Next.js - Docs
2
8
 
3
9
  PostHog makes it easy to get data about traffic and usage of your [Next.js](https://nextjs.org/) app. Integrating PostHog into your site enables analytics about user behavior, custom events capture, session recordings, feature flags, and more.
@@ -57,6 +63,18 @@ pnpm add posthog-js
57
63
  bun add posthog-js
58
64
  ```
59
65
 
66
+ > **If your site sets a Content-Security-Policy**, it needs to allow PostHog. This applies to the snippet and to package installs alike: the SDK lazy-loads extra bundles (session replay, surveys) from PostHog's CDN, and sends events to the ingestion host. PostHog serves from subdomains of `posthog.com` that change over time, so allow the wildcard:
67
+ >
68
+ > PostHog AI
69
+ >
70
+ > ```
71
+ > script-src 'self' https://*.posthog.com;
72
+ > connect-src 'self' https://*.posthog.com;
73
+ > worker-src 'self' blob: data:;
74
+ > ```
75
+ >
76
+ > `script-src` covers the snippet and the lazy-loaded bundles, `connect-src` covers event ingestion and feature flags, and `worker-src` covers session replay. The [toolbar needs a few more](/docs/advanced/content-security-policy.md), or use a [reverse proxy](/docs/advanced/proxy.md) so everything is first-party. Failing to do so causes silent failures where `capture` and `identify` calls never send, so the integration looks complete while zero events arrive. Remember `connect-src` falls back to `default-src`, so `default-src 'self'` blocks event delivery even when the script itself is bundled.
77
+
60
78
  Add your environment variables to your `.env.local` file and to your hosting provider (e.g. Vercel, Netlify, AWS). You can find your project token in your [project settings](https://app.posthog.com/project/settings).
61
79
 
62
80
  .env.local
@@ -113,8 +131,34 @@ See the [bootstrapping guide](/docs/feature-flags/bootstrapping.md) for more inf
113
131
 
114
132
  > **Identifying users is required.** Call `posthog.identify('your-user-id')` after login to link events to a known user. This is what connects frontend event captures, [session replays](/docs/session-replay.md), [LLM traces](/docs/ai-engineering.md), and [error tracking](/docs/error-tracking.md) to the same person — and lets backend events link back too.
115
133
  >
134
+ > Use a stable ID from your auth system when possible, not an email or display name. Send those as person properties instead. If your app has no other stable key, email works as a fallback if they are unique. Never a shared literal like `"anonymous"` or `"user"`, which pools many people onto one person and corrupts their data. When no ID is available at all, skip the identify and retain the anonymous distinct ID that's automatically assigned.
135
+ >
136
+ > Call `posthog.reset()` on logout, so the next person to use the browser doesn't inherit the last one's identity.
137
+ >
116
138
  > See our guide on [identifying users](/docs/getting-started/identify-users.md) for how to set this up.
117
139
 
140
+ ### Linking client and server events
141
+
142
+ Next.js apps usually capture on both sides. To keep them on the same person, use the same distinct ID in both, and let the browser tell your server which one that is.
143
+
144
+ If your app calls your own backend, `tracing_headers` adds `X-POSTHOG-DISTINCT-ID` and `X-POSTHOG-SESSION-ID` to matching `fetch` and `XMLHttpRequest` requests. This lets server-side SDKs link backend events, errors, and LLM traces back to frontend sessions and replays. Use hostnames only, without protocols or paths.
145
+
146
+ JavaScript
147
+
148
+ PostHog AI
149
+
150
+ ```javascript
151
+ posthog.init('<ph_project_token>', {
152
+ api_host: 'https://us.i.posthog.com',
153
+ // Optional: send PostHog session/user context to your backend
154
+ tracing_headers: ['api.example.com'],
155
+ })
156
+ ```
157
+
158
+ This works in local development too, but match on the hostname alone: use `'localhost'`, not `'localhost:3000'`. Ports are never part of a hostname, so a value with one in it never matches anything. `localhost` and `127.0.0.1` are also different hostnames — use whichever your app actually calls.
159
+
160
+ Tracing headers help you attribute events across front and backend consistently. When this isn't available, use your server-side stable IDs to deduce the matching `distinctId`, and pass it in when capturing the event.
161
+
118
162
  Set up a reverse proxy (recommended)
119
163
 
120
164
  We recommend [setting up a reverse proxy](/docs/advanced/proxy.md), so that events are less likely to be intercepted by tracking blockers.
@@ -183,7 +227,7 @@ See the [React SDK docs](/docs/libraries/react.md) for examples of how to use:
183
227
  - [`posthog-js` functions like custom event capture, user identification, and more.](/docs/libraries/react.md#using-posthog-js-functions)
184
228
  - [Feature flags including variants and payloads.](/docs/libraries/react.md#feature-flags)
185
229
 
186
- You can also read [the full `posthog-js` documentation](/docs/libraries/js/features.md) for all the usable functions.
230
+ You can also read [the full `posthog-js` documentation](/docs/libraries/js/usage.md) for all the usable functions.
187
231
 
188
232
  ## Server-side analytics
189
233
 
@@ -288,6 +332,7 @@ PostHog AI
288
332
  // pages/posts/[id].js
289
333
  import { useContext, useEffect, useState } from 'react'
290
334
  import { getServerSession } from "next-auth/next"
335
+ import { authOptions } from '@/lib/auth'
291
336
  import { PostHog } from 'posthog-node'
292
337
  export default function Post({ post, flags }) {
293
338
  const [ctaState, setCtaState] = useState()
@@ -309,7 +354,8 @@ export default function Post({ post, flags }) {
309
354
  )
310
355
  }
311
356
  export async function getServerSideProps(ctx) {
312
- const session = await getServerSession(ctx.req, ctx.res)
357
+ // Pass authOptions, or your session callbacks don't run.
358
+ const session = await getServerSession(ctx.req, ctx.res, authOptions)
313
359
  let flags = null
314
360
  if (session) {
315
361
  const client = new PostHog(
@@ -318,9 +364,11 @@ export async function getServerSideProps(ctx) {
318
364
  host: process.env.NEXT_PUBLIC_POSTHOG_HOST,
319
365
  }
320
366
  )
321
- flags = await client.getAllFlags(session.user.email);
367
+ // A stable ID from your auth system, not an email. See the note below.
368
+ const distinctId = session.user.id
369
+ flags = await client.getAllFlags(distinctId);
322
370
  client.capture({
323
- distinctId: session.user.email,
371
+ distinctId,
324
372
  event: 'loaded blog article',
325
373
  properties: {
326
374
  $current_url: ctx.req.url,
@@ -339,6 +387,28 @@ export async function getServerSideProps(ctx) {
339
387
  }
340
388
  ```
341
389
 
390
+ > **Note**: next-auth doesn't put a user ID on the session by default. Its session is `{ name, email, image }`, so `session.user.id` is `undefined` until you add it yourself with a session callback in your `authOptions`:
391
+ >
392
+ > JavaScript
393
+ >
394
+ > PostHog AI
395
+ >
396
+ > ```javascript
397
+ > // lib/auth.js
398
+ > export const authOptions = {
399
+ > callbacks: {
400
+ > session({ session, token, user }) {
401
+ > // JWT sessions (the default) carry the user ID in token.sub.
402
+ > // Database sessions get it from user.id instead.
403
+ > session.user.id = token?.sub ?? user.id
404
+ > return session
405
+ > },
406
+ > },
407
+ > }
408
+ > ```
409
+ >
410
+ > Capturing with an `undefined` distinct ID creates events that belong to nobody, so check that the ID arrives before relying on it.
411
+
342
412
  > **Note**: Make sure to *always* call `await client.shutdown()` after sending events from the server-side. PostHog queues events into larger batches, and this call forces all batched events to be flushed immediately.
343
413
 
344
414
  ### Server-side configuration
@@ -374,10 +444,6 @@ To improve the reliability of client-side tracking and make requests less likely
374
444
  - [How to set up Next.js pages router analytics, feature flags, and more](/tutorials/nextjs-pages-analytics.md)
375
445
  - [How to set up Next.js A/B tests](/tutorials/nextjs-ab-tests.md)
376
446
 
377
- ### Community questions
378
-
379
- Ask a question
380
-
381
447
  ### Was this page useful?
382
448
 
383
449
  HelpfulCould be better
@@ -1,3 +1,9 @@
1
+ > AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt
2
+
3
+ # Nuxt.js (v3.0 to v3.6) - Docs
4
+
5
+ Copy page
6
+
1
7
  # Nuxt.js (v3.0 to v3.6) - Docs
2
8
 
3
9
  PostHog makes it easy to get data about usage of your [Nuxt.js](https://nuxt.com/) app. Integrating PostHog into your app enables analytics about user behavior, custom events capture, session replays, feature flags, and more.
@@ -34,6 +40,18 @@ pnpm add posthog-js
34
40
  bun add posthog-js
35
41
  ```
36
42
 
43
+ > **If your site sets a Content-Security-Policy**, it needs to allow PostHog. This applies to the snippet and to package installs alike: the SDK lazy-loads extra bundles (session replay, surveys) from PostHog's CDN, and sends events to the ingestion host. PostHog serves from subdomains of `posthog.com` that change over time, so allow the wildcard:
44
+ >
45
+ > PostHog AI
46
+ >
47
+ > ```
48
+ > script-src 'self' https://*.posthog.com;
49
+ > connect-src 'self' https://*.posthog.com;
50
+ > worker-src 'self' blob: data:;
51
+ > ```
52
+ >
53
+ > `script-src` covers the snippet and the lazy-loaded bundles, `connect-src` covers event ingestion and feature flags, and `worker-src` covers session replay. The [toolbar needs a few more](/docs/advanced/content-security-policy.md), or use a [reverse proxy](/docs/advanced/proxy.md) so everything is first-party. Failing to do so causes silent failures where `capture` and `identify` calls never send, so the integration looks complete while zero events arrive. Remember `connect-src` falls back to `default-src`, so `default-src 'self'` blocks event delivery even when the script itself is bundled.
54
+
37
55
  2. Store your PostHog key and host in environment variables rather than hard-coding them. Add them to a `.env` file (and to your hosting provider). You can find these in [your project settings](https://us.posthog.com/settings/project).
38
56
 
39
57
  .env
@@ -113,10 +131,28 @@ PostHog AI
113
131
  </script>
114
132
  ```
115
133
 
116
- See the [JavaScript SDK docs](/docs/libraries/js/features.md) for all usable functions, such as:
134
+ See the [JavaScript SDK docs](/docs/libraries/js/usage.md) for all usable functions, such as:
117
135
 
118
- - [Capture custom event capture, identify users, and more.](/docs/libraries/js/features.md#capturing-events)
119
- - [Feature flags including variants and payloads.](/docs/libraries/js/features.md#feature-flags)
136
+ - [Capture custom event capture, identify users, and more.](/docs/libraries/js/usage.md#capturing-events)
137
+ - [Feature flags including variants and payloads.](/docs/libraries/js/usage.md#feature-flags)
138
+
139
+ If your app calls your own backend, `tracing_headers` adds `X-POSTHOG-DISTINCT-ID` and `X-POSTHOG-SESSION-ID` to matching `fetch` and `XMLHttpRequest` requests. This lets server-side SDKs link backend events, errors, and LLM traces back to frontend sessions and replays. Use hostnames only, without protocols or paths.
140
+
141
+ JavaScript
142
+
143
+ PostHog AI
144
+
145
+ ```javascript
146
+ posthog.init('<ph_project_token>', {
147
+ api_host: 'https://us.i.posthog.com',
148
+ // Optional: send PostHog session/user context to your backend
149
+ tracing_headers: ['api.example.com'],
150
+ })
151
+ ```
152
+
153
+ This works in local development too, but match on the hostname alone: use `'localhost'`, not `'localhost:3000'`. Ports are never part of a hostname, so a value with one in it never matches anything. `localhost` and `127.0.0.1` are also different hostnames — use whichever your app actually calls.
154
+
155
+ Tracing headers help you attribute events across front and backend consistently. When this isn't available, use your server-side stable IDs to deduce the matching `distinctId`, and pass it in when capturing the event.
120
156
 
121
157
  Set up a reverse proxy (recommended)
122
158
 
@@ -235,10 +271,6 @@ Alternatively, the following tutorials can help you get started:
235
271
  - [How to set up A/B tests in Nuxt](/tutorials/nuxtjs-ab-tests.md)
236
272
  - [How to set up surveys in Nuxt](/tutorials/nuxt-surveys.md)
237
273
 
238
- ### Community questions
239
-
240
- Ask a question
241
-
242
274
  ### Was this page useful?
243
275
 
244
276
  HelpfulCould be better
@@ -1,3 +1,9 @@
1
+ > AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt
2
+
3
+ # Nuxt.js - Docs
4
+
5
+ Copy page
6
+
1
7
  # Nuxt.js - Docs
2
8
 
3
9
  PostHog makes it easy to get data about usage of your [Nuxt.js](https://nuxt.com/) app. Integrating PostHog into your app enables analytics about user behavior, custom events capture, session replays, feature flags, and more.
@@ -45,12 +51,46 @@ pnpm add @posthog/nuxt
45
51
  bun add @posthog/nuxt
46
52
  ```
47
53
 
54
+ > **If your site sets a Content-Security-Policy**, it needs to allow PostHog. This applies to the snippet and to package installs alike: the SDK lazy-loads extra bundles (session replay, surveys) from PostHog's CDN, and sends events to the ingestion host. PostHog serves from subdomains of `posthog.com` that change over time, so allow the wildcard:
55
+ >
56
+ > PostHog AI
57
+ >
58
+ > ```
59
+ > script-src 'self' https://*.posthog.com;
60
+ > connect-src 'self' https://*.posthog.com;
61
+ > worker-src 'self' blob: data:;
62
+ > ```
63
+ >
64
+ > `script-src` covers the snippet and the lazy-loaded bundles, `connect-src` covers event ingestion and feature flags, and `worker-src` covers session replay. The [toolbar needs a few more](/docs/advanced/content-security-policy.md), or use a [reverse proxy](/docs/advanced/proxy.md) so everything is first-party. Failing to do so causes silent failures where `capture` and `identify` calls never send, so the integration looks complete while zero events arrive. Remember `connect-src` falls back to `default-src`, so `default-src 'self'` blocks event delivery even when the script itself is bundled.
65
+
48
66
  ## Identifying users
49
67
 
50
68
  > **Identifying users is required.** Call `posthog.identify('your-user-id')` after login to link events to a known user. This is what connects frontend event captures, [session replays](/docs/session-replay.md), [LLM traces](/docs/ai-engineering.md), and [error tracking](/docs/error-tracking.md) to the same person — and lets backend events link back too.
51
69
  >
70
+ > Use a stable ID from your auth system when possible, not an email or display name. Send those as person properties instead. If your app has no other stable key, email works as a fallback if they are unique. Never a shared literal like `"anonymous"` or `"user"`, which pools many people onto one person and corrupts their data. When no ID is available at all, skip the identify and retain the anonymous distinct ID that's automatically assigned.
71
+ >
72
+ > Call `posthog.reset()` on logout, so the next person to use the browser doesn't inherit the last one's identity.
73
+ >
52
74
  > See our guide on [identifying users](/docs/getting-started/identify-users.md) for how to set this up.
53
75
 
76
+ If your app calls your own backend, `tracing_headers` adds `X-POSTHOG-DISTINCT-ID` and `X-POSTHOG-SESSION-ID` to matching `fetch` and `XMLHttpRequest` requests. This lets server-side SDKs link backend events, errors, and LLM traces back to frontend sessions and replays. Use hostnames only, without protocols or paths.
77
+
78
+ JavaScript
79
+
80
+ PostHog AI
81
+
82
+ ```javascript
83
+ posthog.init('<ph_project_token>', {
84
+ api_host: 'https://us.i.posthog.com',
85
+ // Optional: send PostHog session/user context to your backend
86
+ tracing_headers: ['api.example.com'],
87
+ })
88
+ ```
89
+
90
+ This works in local development too, but match on the hostname alone: use `'localhost'`, not `'localhost:3000'`. Ports are never part of a hostname, so a value with one in it never matches anything. `localhost` and `127.0.0.1` are also different hostnames — use whichever your app actually calls.
91
+
92
+ Tracing headers help you attribute events across front and backend consistently. When this isn't available, use your server-side stable IDs to deduce the matching `distinctId`, and pass it in when capturing the event.
93
+
54
94
  ## Configuration
55
95
 
56
96
  Store your PostHog keys in environment variables rather than hard-coding them. Add them to a `.env` file (and to your hosting provider). You can find these values in [your project settings](https://us.posthog.com/settings/project).
@@ -244,10 +284,6 @@ Alternatively, the following tutorials can help you get started:
244
284
  - [How to set up A/B tests in Nuxt](/tutorials/nuxtjs-ab-tests.md)
245
285
  - [How to set up surveys in Nuxt](/tutorials/nuxt-surveys.md)
246
286
 
247
- ### Community questions
248
-
249
- Ask a question
250
-
251
287
  ### Was this page useful?
252
288
 
253
289
  HelpfulCould be better
@@ -1,3 +1,9 @@
1
+ > AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt
2
+
3
+ # PHP - Docs
4
+
5
+ Copy page
6
+
1
7
  # PHP - Docs
2
8
 
3
9
  This is an optional library you can install if you're working with PHP. It uses an internal queue to batch requests, flushes at the end of the request, and optionally does so in an async manner.
@@ -637,10 +643,6 @@ PostHog::init(
637
643
 
638
644
  This library is largely based on the `analytics-php` package.
639
645
 
640
- ### Community questions
641
-
642
- Ask a question
643
-
644
646
  ### Was this page useful?
645
647
 
646
648
  HelpfulCould be better
@@ -1,6 +1,8 @@
1
+ > AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt
2
+
1
3
  # PostHog Python SDK
2
4
 
3
- **SDK Version:** 7.22.1
5
+ **SDK Version:** 7.38.4
4
6
 
5
7
  Integrate PostHog into any python application.
6
8
 
@@ -34,11 +36,11 @@ Initialize a new PostHog client instance.
34
36
  - **`debug`** (`bool`) - Enable verbose SDK logging and re-raise errors from public API methods.
35
37
  - **`max_queue_size`** (`int`) - Maximum number of events buffered before upload.
36
38
  - **`send`** (`bool`) - If False, queueing succeeds but events are not sent.
37
- - **`on_error`** (`any`) - Optional callback invoked by background consumers when an upload fails.
39
+ - **`on_error`** (`any`) - Optional callback invoked by background consumers when an upload fails. Keep it short and non-blocking. Calling lifecycle methods directly is safe and deferred, but do not start another thread or task that calls ``flush()``, ``join()``, or ``shutdown()`` and then wait for it from the callback.
38
40
  - **`flush_at`** (`int`) - Number of queued events that triggers a batch upload.
39
41
  - **`flush_interval`** (`float`) - Maximum seconds a background consumer waits before flushing a partial batch.
40
42
  - **`gzip`** (`bool`) - Whether to gzip event upload payloads.
41
- - **`max_retries`** (`int`) - Number of upload retries for background consumers.
43
+ - **`max_retries`** (`int`) - Number of upload retries. Values below 0 are treated as 0.
42
44
  - **`sync_mode`** (`bool`) - If True, send each event synchronously instead of using background worker threads.
43
45
  - **`timeout`** (`int`) - HTTP request timeout in seconds for event uploads.
44
46
  - **`thread`** (`int`) - Number of background consumer threads.
@@ -72,7 +74,9 @@ Initialize a new PostHog client instance.
72
74
  - **`capture_mode`** (`CaptureMode`) - Capture wire protocol to use. Defaults to ``CaptureMode.V0`` (legacy ``/batch/``). Set ``CaptureMode.V1`` (or pass the string ``"v1"``) to opt into ``/i/v1/analytics/events``. When omitted, the ``POSTHOG_CAPTURE_MODE`` env var is consulted, then ``V0``.
73
75
  - **`capture_compression`** (`CaptureCompression`) - Request-body compression for capture-v1 uploads (ignored in V0, which uses ``gzip``). ``CaptureCompression.GZIP`` or ``DEFLATE`` (or the strings ``"gzip"``/``"deflate"``). When omitted, the ``POSTHOG_CAPTURE_COMPRESSION`` env var is consulted, then the legacy ``gzip`` flag, then no compression.
74
76
  - **`secret_key`** (`any`) - A Personal API Key or Project Secret API Key, used to authenticate local feature flag evaluation, remote config payloads, and decrypted flag payloads. Example:: posthog.Client(project_api_key, secret_key="phx_...")
75
- - **`_dedicated_ai_endpoint`** (`bool`)
77
+ - **`metrics?`** (`dict`)
78
+ - **`_use_ai_lane`** (`bool`)
79
+ - **`_enable_multimodal_capture`** (`bool`)
76
80
 
77
81
  ### Returns
78
82
 
@@ -98,8 +102,8 @@ Create an alias between two distinct IDs.
98
102
 
99
103
  ### Parameters
100
104
 
101
- - **`previous_id?`** (`str`) - The previous distinct ID.
102
- - **`distinct_id?`** (`str`) - The new distinct ID to alias to.
105
+ - **`previous_id?`** (`Number`) - The previous distinct ID. Required - the call is dropped with a warning if it is missing or empty.
106
+ - **`distinct_id?`** (`str`) - The new distinct ID to alias to. Falls back to the context distinct ID; the call is dropped with a warning if neither is available.
103
107
  - **`timestamp`** (`datetime`) - The timestamp of the event.
104
108
  - **`uuid?`** (`str`) - A unique identifier for the event. If provided, it must be a valid UUID string or uuid.UUID instance; invalid values are ignored and replaced with a newly generated UUID.
105
109
  - **`disable_geoip?`** (`bool`) - Whether to disable GeoIP for this event.
@@ -124,8 +128,8 @@ Identify a group and set its properties.
124
128
 
125
129
  ### Parameters
126
130
 
127
- - **`group_type?`** (`str`) - The type of group (e.g., 'company', 'team').
128
- - **`group_key?`** (`str`) - The unique identifier for the group.
131
+ - **`group_type?`** (`str`) - The type of group (e.g., 'company', 'team'). Required - the call is dropped with a warning if it is missing or empty.
132
+ - **`group_key?`** (`str`) - The unique identifier for the group. Required - the call is dropped with a warning if it is missing or empty.
129
133
  - **`properties?`** (`dict[str, Any]`) - A dictionary of properties to set on the group.
130
134
  - **`timestamp`** (`datetime`) - The timestamp of the event.
131
135
  - **`uuid`** (`str`) - A unique identifier for the event. If provided, it must be a valid UUID string or uuid.UUID instance; invalid values are ignored and replaced with a newly generated UUID.
@@ -259,7 +263,7 @@ posthog.capture('$pageview', distinct_id="distinct_id_of_the_user", properties={
259
263
 
260
264
  **Release Tag:** public
261
265
 
262
- Capture an exception for error tracking.
266
+ Capture an exception for error tracking. When OpenTelemetry is installed and a valid span is active, its trace and span IDs are added as ``$trace_id`` and ``$span_id`` event properties.
263
267
 
264
268
  ### Parameters
265
269
 
@@ -696,7 +700,7 @@ if flag_result and flag_result.get_value() == 'variant-key':
696
700
 
697
701
  **Release Tag:** public
698
702
 
699
- End the consumer thread once the queue is empty. Do not use directly, call `shutdown()` instead.
703
+ Attempt to process queued events and end the consumer threads. Do not use directly, call `shutdown()` instead. Failed or undrainable events may be dropped and reported through logging or ``on_error``; returning does not guarantee server receipt. Lifecycle cleanup is attempted once, and cleanup failures are logged without retry.
700
704
 
701
705
  ### Returns
702
706
 
@@ -714,7 +718,7 @@ posthog.join()
714
718
 
715
719
  **Release Tag:** public
716
720
 
717
- Flush all messages and cleanly shutdown the client. Call this before the process ends in serverless environments to avoid data loss.
721
+ Flush all messages and cleanly shutdown the client. Call this before the process ends in serverless environments to avoid data loss. Normally this method blocks until queued events have been attempted and cleanup finishes. Failed or undrainable events may be dropped and reported through logging or ``on_error``; returning does not guarantee server receipt. Lifecycle cleanup is attempted once, and cleanup failures are logged without retry. When called directly from an SDK callback such as ``on_error``, shutdown is deferred to avoid blocking the worker that invoked the callback. If the callback must coordinate a blocking shutdown, have it signal an application-owned thread and return before that thread calls shutdown. Do not wait inside the callback for another thread or task that calls a lifecycle method.
718
722
 
719
723
  ### Returns
720
724
 
@@ -867,7 +871,7 @@ To marry up whatever a user does before they sign up or log in with what they do
867
871
 
868
872
  ### Parameters
869
873
 
870
- - **`previous_id?`** (`str`) - The unique ID of the user before
874
+ - **`previous_id?`** (`Number`) - The unique ID of the user before
871
875
  - **`distinct_id?`** (`str`) - The current unique id
872
876
  - **`timestamp?`** (`datetime`) - Optional timestamp for the event
873
877
  - **`uuid?`** (`str`) - Optional UUID for the event
@@ -895,8 +899,8 @@ Set properties on a group.
895
899
 
896
900
  ### Parameters
897
901
 
898
- - **`group_type?`** (`str`) - Type of your group
899
- - **`group_key?`** (`str`) - Unique identifier of the group
902
+ - **`group_type?`** (`str`) - Type of your group. Required - the call is dropped with a warning if it is missing or empty.
903
+ - **`group_key?`** (`str`) - Unique identifier of the group. Required - the call is dropped with a warning if it is missing or empty.
900
904
  - **`properties?`** (`dict[str, Any]`) - Properties to set on the group
901
905
  - **`timestamp?`** (`datetime`) - Optional timestamp for the event
902
906
  - **`uuid?`** (`str`) - Optional UUID for the event
@@ -1366,7 +1370,7 @@ flush()
1366
1370
 
1367
1371
  **Release Tag:** public
1368
1372
 
1369
- Block program until the client clears the queue. Used during program shutdown. You should use `shutdown()` directly in most cases.
1373
+ Attempt to process queued events and stop the client's background workers. Use `shutdown()` directly in most cases. Failed or undrainable events may be dropped and reported through logging or ``on_error``; returning does not guarantee server receipt. Lifecycle cleanup is attempted once, and cleanup failures are logged without retry.
1370
1374
 
1371
1375
  ### Returns
1372
1376
 
@@ -1385,7 +1389,7 @@ join()
1385
1389
 
1386
1390
  **Release Tag:** public
1387
1391
 
1388
- Flush all messages and cleanly shutdown the client.
1392
+ Flush all messages and cleanly shutdown the client. This normally blocks until queued events have been attempted and cleanup finishes. Failed or undrainable events may be dropped and reported through logging or ``on_error``; returning does not guarantee server receipt. Lifecycle cleanup is attempted once, and cleanup failures are logged without retry. Calls made directly from SDK callbacks such as ``on_error`` are deferred to avoid deadlocking the worker. If blocking completion is required, signal an application-owned thread, return from the callback, and call ``shutdown()`` from that thread. Do not wait inside a callback for another thread or task calling a lifecycle method.
1389
1393
 
1390
1394
  ### Returns
1391
1395
 
@@ -1666,7 +1670,7 @@ tag("user_id", "123")
1666
1670
 
1667
1671
  **Release Tag:** public
1668
1672
 
1669
- Create or return the global PostHog client configured by module settings. Most applications should either instantiate ``Posthog`` directly or set ``posthog.api_key``/other module settings before calling top-level helpers. ``setup()`` is called automatically by global APIs such as ``capture()``. Returns: The global ``Client`` instance. If ``api_key`` is missing or blank, the client is disabled and module-level calls become no-ops.
1673
+ Create or return the global PostHog client configured by module settings. Most applications should either instantiate ``Posthog`` directly or set ``posthog.api_key``/other module settings before calling top-level helpers. ``setup()`` is called automatically by global APIs such as ``capture()``. Returns: The global ``Client`` instance. If both ``api_key`` and ``project_api_key`` are missing or blank, the client is disabled and module-level calls become no-ops.
1670
1674
 
1671
1675
  ### Returns
1672
1676
 
@@ -1,10 +1,14 @@
1
+ > AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt
2
+
1
3
  # Python - Docs
2
4
 
3
- The Python SDK makes it easy to capture events, evaluate feature flags, track errors, and more in your Python apps.
5
+ Copy page
6
+
7
+ # Python - Docs
4
8
 
5
- **Python 3.9 and lower**
9
+ The Python SDK makes it easy to capture events, evaluate feature flags, track errors, and more in your Python apps.
6
10
 
7
- Python 3.9 is no longer supported for PostHog Python SDK versions `7.x.x` and higher.
11
+ > These docs cover version `7.x` of the Python SDK, which requires Python 3.10 or higher. On Python 3.9? See [supported versions](#supported-versions).
8
12
 
9
13
  ## Installation
10
14
 
@@ -54,6 +58,8 @@ You can find your project token and instance address in the [project settings](h
54
58
  > capture("foo_viewed")
55
59
  > return {"status": "ok"}
56
60
  > ```
61
+ >
62
+ > When possible, write a small piece of **middleware** that resolves your authenticated user, wrap a context around the request, and identifies it. Every `capture()` downstream is then attributed *automatically*. The SDK's Django middleware does this automatically and you can replicate it when using the plain Python SDK.
57
63
 
58
64
  ## Capturing events
59
65
 
@@ -889,9 +895,13 @@ As our open source project [PostHog](https://github.com/PostHog/posthog) shares
889
895
 
890
896
  This library is largely based on the `analytics-python` package.
891
897
 
892
- ### Community questions
898
+ ## Supported versions
899
+
900
+ These docs cover version `7.x` of the PostHog Python SDK, which requires Python 3.10 or higher. Python 3.9 is no longer supported on `7.x.x` and higher — pin to the 6.x line with `pip install 'posthog<7'`, where `6.9.3` is the final release.
901
+
902
+ Everything on this page works the same way on `6.9.3`. Event capture, the context API (`new_context`, `identify_context`, `set_context_session`), and `PosthogContextMiddleware` are identical on `6.9.3` and `7.0.0` — `7.0.0` only dropped Python 3.9 and bumped the optional LLM provider SDKs. That includes the middleware identifying the request context from the `X-POSTHOG-DISTINCT-ID` header and falling back to the authenticated user, which behaves the same across both lines.
893
903
 
894
- Ask a question
904
+ Later `7.x` releases add what the 6.x line does not receive, such as the Celery integration, tracing header sanitization, and `set_context_device_id`. They also changed the middleware's own captured properties: `7.x` sends the request IP as `$ip`, where `6.9.3` sends it as `$ip_address`, and `7.x` additionally captures `$request_path`, `$raw_user_agent`, and the authenticated user's `email`.
895
905
 
896
906
  ### Was this page useful?
897
907
 
@@ -1,3 +1,9 @@
1
+ > AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt
2
+
3
+ # React Native - Docs
4
+
5
+ Copy page
6
+
1
7
  # React Native - Docs
2
8
 
3
9
  ## Installation
@@ -159,7 +165,7 @@ You can further customize how PostHog works through its configuration on initial
159
165
  | defaultOptInType: BooleanDefault: true | If set to false, the SDK will not track until the optIn() function is called. |
160
166
  | sendFeatureFlagEventType: BooleanDefault: true | Whether to track that getFeatureFlag was called (used by experiments). |
161
167
  | preloadFeatureFlagsType: BooleanDefault: true | Whether to load feature flags when initialized or not. |
162
- | bootstrapType: ObjectDefault: {} | An object containing the distinctId, isIdentifiedId, featureFlags, and featureFlagPayloads keys. distinctId is a string, and featureFlags and featureFlagPayloads are objects of key-value pairs. Used to ensure data is available as soon as the SDK loads. |
168
+ | bootstrapType: ObjectDefault: {} | Seeds identity (distinctId, isIdentifiedId) and feature flag state (featureFlags, featureFlagPayloads) during initialization. See [SDK bootstrapping](/docs/libraries/bootstrapping.md). |
163
169
  | disableRemoteFeatureFlagsType: BooleanDefault: false | When true, the SDK never fetches or evaluates feature flags from PostHog, and identify(), group(), and reset() stop triggering /flags requests. Supply flag values yourself via bootstrap (at startup) and updateFlags() (at runtime). Available in version 4.49.0+. |
164
170
  | fetchRetryCountType: NumberDefault: 3 | How many times HTTP requests will be retried. |
165
171
  | fetchRetryDelayType: NumberDefault: 3000 | The delay between HTTP request retries. |
@@ -177,6 +183,9 @@ You can further customize how PostHog works through its configuration on initial
177
183
  | evaluationContextsType: Array of StringsDefault: undefined | Evaluation context tags that constrain which feature flags are evaluated. When set, only flags with matching evaluation context tags (or no evaluation context tags) will be returned. This helps reduce unnecessary flag evaluations and improves performance. See [evaluation contexts documentation](/docs/feature-flags/evaluation-contexts.md) for more details. Available in version 4.21.0+. The legacy parameter evaluationEnvironments (version 4.10.0+) is also supported for backward compatibility. |
178
184
  | addTracingHeadersType: Array of StringsDefault: undefined | Hostnames for which PostHog should add tracing headers to outgoing fetch requests. Matching requests include X-POSTHOG-DISTINCT-ID and X-POSTHOG-SESSION-ID, which lets backend events, errors, and LLM traces link back to frontend sessions and replays. Use hostnames only, without the protocol or path. |
179
185
  | before_sendType: FunctionDefault: undefined | A callback function that is called before each event is sent to PostHog. You can use it to modify, filter, or suppress events. Return null to drop the event, or return the modified event to send it. See [customizing exception capture](#customizing-exception-capture-with-before_send) for details. |
186
+ | capturePushNotificationSubscriptionsType: BooleanDefault: true | Whether to automatically register this device's push token so [Workflows](/docs/workflows.md) can target it. Requires @posthog/react-native-plugin. See [push notifications](#push-notifications). Available in version 4.62.0+. |
187
+ | capturePushNotificationOpenedType: BooleanDefault: true | Whether to automatically capture $push_notification_opened when the user taps a push notification. Requires @posthog/react-native-plugin. See [push notifications](#push-notifications). Available in version 4.62.0+. |
188
+ | pushIdentityProviderType: FunctionDefault: undefined | Supplies a signed identity-verification token for push subscription requests. Only needed when your push channel requires identity verification. See [identity verification](#identity-verification). Available in version 4.62.0+. |
180
189
 
181
190
  ### Tracing headers
182
191
 
@@ -1050,13 +1059,38 @@ The list of properties that this overrides:
1050
1059
 
1051
1060
  This enables any geolocation-based flags to work without manually setting these properties.
1052
1061
 
1053
- ### Bootstrapping Flags
1062
+ ### Bootstrapping flags
1054
1063
 
1055
1064
  Since there is a delay between initializing PostHog and fetching feature flags, feature flags are not always available immediately. This makes them unusable if you want to do something like redirecting a user to a different page based on a feature flag.
1056
1065
 
1057
1066
  To have your feature flags available immediately, you can initialize PostHog with precomputed values until it has had a chance to fetch them. This is called bootstrapping. After the SDK fetches feature flags from PostHog, it will use those flag values instead of bootstrapped ones.
1058
1067
 
1059
- For details on how to implement bootstrapping, see our [bootstrapping guide](/docs/feature-flags/bootstrapping.md).
1068
+ Pass `bootstrap` in the initialization options to seed identity and flag values:
1069
+
1070
+ React Native
1071
+
1072
+ PostHog AI
1073
+
1074
+ ```jsx
1075
+ <PostHogProvider
1076
+ apiKey="<ph_project_token>"
1077
+ options={{
1078
+ host: 'https://us.i.posthog.com',
1079
+ bootstrap: {
1080
+ distinctId: 'distinct_id_of_your_user',
1081
+ isIdentifiedId: true,
1082
+ featureFlags: {
1083
+ 'flag-1': true,
1084
+ 'variant-flag': 'control',
1085
+ },
1086
+ },
1087
+ }}
1088
+ >
1089
+ <MyComponent />
1090
+ </PostHogProvider>
1091
+ ```
1092
+
1093
+ See [bootstrapping Feature Flags](/docs/feature-flags/bootstrapping.md) for server-side evaluation and flag lifecycle, and [SDK bootstrapping](/docs/libraries/bootstrapping.md) for cross-SDK identity behavior.
1060
1094
 
1061
1095
  ### Supplying flags from your own backend
1062
1096
 
@@ -1208,6 +1242,10 @@ To set up surveys, follow the [additional installation instructions for React Na
1208
1242
 
1209
1243
  > Note: URL and CSS selector targeting are not supported in React Native. Surveys that rely on these conditions will not appear.
1210
1244
 
1245
+ ## Push notifications
1246
+
1247
+ The React Native SDK can register a device for [Workflows](/docs/workflows.md) push notifications and capture when a user opens one. For setup, including automatic and manual registration, capturing opens, opting out, and identity verification, see [Push notifications](/docs/workflows/push-notifications.md).
1248
+
1211
1249
  ## Debug mode
1212
1250
 
1213
1251
  If you're not seeing the expected events being captured, the feature flags being evaluated, or the surveys being shown, you can enable debug mode to see what's happening.
@@ -1329,10 +1367,6 @@ posthog.setPersonPropertiesForFlags(...) // instead of `personProperties`
1329
1367
  posthog.setGroupPropertiesForFlags(...) // instead of `groupProperties`
1330
1368
  ```
1331
1369
 
1332
- ### Community questions
1333
-
1334
- Ask a question
1335
-
1336
1370
  ### Was this page useful?
1337
1371
 
1338
1372
  HelpfulCould be better
@@ -1,3 +1,9 @@
1
+ > AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt
2
+
3
+ # React Router V6 - Docs
4
+
5
+ Copy page
6
+
1
7
  # React Router V6 - Docs
2
8
 
3
9
  This guide walks you through setting up PostHog for React Router V6. If you're using React Router v7, find the guide for that mode in the [React Router page](/docs/libraries/react-router.md). If you're using React with another framework, go to the [React integration guide](/docs/libraries/react.md).
@@ -36,6 +42,18 @@ This guide walks you through setting up PostHog for React Router V6. If you're u
36
42
  bun add posthog-js @posthog/react
37
43
  ```
38
44
 
45
+ > **If your site sets a Content-Security-Policy**, it needs to allow PostHog. This applies to the snippet and to package installs alike: the SDK lazy-loads extra bundles (session replay, surveys) from PostHog's CDN, and sends events to the ingestion host. PostHog serves from subdomains of `posthog.com` that change over time, so allow the wildcard:
46
+ >
47
+ > PostHog AI
48
+ >
49
+ > ```
50
+ > script-src 'self' https://*.posthog.com;
51
+ > connect-src 'self' https://*.posthog.com;
52
+ > worker-src 'self' blob: data:;
53
+ > ```
54
+ >
55
+ > `script-src` covers the snippet and the lazy-loaded bundles, `connect-src` covers event ingestion and feature flags, and `worker-src` covers session replay. The [toolbar needs a few more](/docs/advanced/content-security-policy.md), or use a [reverse proxy](/docs/advanced/proxy.md) so everything is first-party. Failing to do so causes silent failures where `capture` and `identify` calls never send, so the integration looks complete while zero events arrive. Remember `connect-src` falls back to `default-src`, so `default-src 'self'` blocks event delivery even when the script itself is bundled.
56
+
39
57
  2. 2
40
58
 
41
59
  ## Add your environment variables
@@ -367,10 +385,6 @@ This guide walks you through setting up PostHog for React Router V6. If you're u
367
385
  - [PostHog AI](/docs/posthog-ai.md): After capturing events, use PostHog AI to help you understand your data and build insights.
368
386
  - [Feature flags and experiments](/docs/libraries/react.md#feature-flags): Feature flag and experiment setup is the same as React. You can find more details in the React integration guide.
369
387
 
370
- ### Community questions
371
-
372
- Ask a question
373
-
374
388
  ### Was this page useful?
375
389
 
376
390
  HelpfulCould be better