vybekiit 0.7.26 → 0.7.28
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.
- package/dist/bin.js +3910 -1300
- package/dist/global-guidance/language.md +443 -0
- package/dist/global-skills/add-ai/SKILL.md +1 -1
- package/dist/global-skills/add-analytics/SKILL.md +1 -1
- package/dist/global-skills/add-blog/SKILL.md +1 -1
- package/dist/global-skills/add-crud/SKILL.md +1 -1
- package/dist/global-skills/add-files/SKILL.md +1 -1
- package/dist/global-skills/add-images/SKILL.md +1 -1
- package/dist/global-skills/add-language/SKILL.md +1 -1
- package/dist/global-skills/add-notifications/SKILL.md +1 -1
- package/dist/global-skills/add-realtime/SKILL.md +1 -1
- package/dist/global-skills/add-route/SKILL.md +1 -1
- package/dist/global-skills/add-search/SKILL.md +1 -1
- package/dist/global-skills/add-signin/SKILL.md +1 -1
- package/dist/global-skills/add-teams/SKILL.md +1 -1
- package/dist/global-skills/add-upload/SKILL.md +1 -1
- package/dist/global-skills/aws-cdk/SKILL.md +19 -5
- package/dist/global-skills/aws-cdk/references/fast-deployments.md +191 -0
- package/dist/global-skills/aws-cdk/references/troubleshooting-deployment.md +16 -0
- package/dist/global-skills/aws-cloudformation/SKILL.md +16 -26
- package/dist/global-skills/aws-cloudformation/references/check-cloudformation-template-compliance.script.md +7 -3
- package/dist/global-skills/aws-cloudformation/references/cloudformation-language-server.md +177 -0
- package/dist/global-skills/aws-cloudformation/references/cloudformation-pre-deploy-validation.script.md +8 -2
- package/dist/global-skills/aws-cloudformation/references/persist-template-context.script.md +5 -8
- package/dist/global-skills/aws-cloudformation/references/retrieve-template-context.script.md +1 -1
- package/dist/global-skills/aws-cloudformation/references/security-considerations.md +51 -0
- package/dist/global-skills/aws-cloudformation/references/troubleshoot-failed-stack.script.md +138 -0
- package/dist/global-skills/aws-cloudformation/references/{validate-cloudformation-template.script.md → validate-with-cfn-lint.script.md} +15 -27
- package/dist/global-skills/aws-cloudformation/references/validate-with-cloudformation-validate.script.md +181 -0
- package/dist/global-skills/aws-cloudformation/references/validation-tool-selection.md +44 -0
- package/dist/global-skills/aws-serverless/SKILL.md +9 -1
- package/dist/global-skills/aws-serverless/references/architecture.md +3 -1
- package/dist/global-skills/aws-serverless/references/lambda.md +3 -1
- package/dist/global-skills/aws-serverless/references/orchestration.md +1 -0
- package/dist/global-skills/back-up-my-code/SKILL.md +1 -1
- package/dist/global-skills/better-auth-best-practices/SKILL.md +18 -8
- package/dist/global-skills/buy-domain/SKILL.md +1 -1
- package/dist/global-skills/check-safety/SKILL.md +1 -1
- package/dist/global-skills/configure-capabilities/SKILL.md +1 -1
- package/dist/global-skills/connect-account/SKILL.md +1 -1
- package/dist/global-skills/connect-account-backend/SKILL.md +1 -1
- package/dist/global-skills/design-my-data/SKILL.md +1 -1
- package/dist/global-skills/doctor/SKILL.md +1 -1
- package/dist/global-skills/eas-app-stores/SKILL.md +31 -15
- package/dist/global-skills/eas-app-stores/agents/openai.yaml +2 -2
- package/dist/global-skills/eas-app-stores/references/ios-app-store.md +37 -32
- package/dist/global-skills/eas-app-stores/references/native-ios.md +167 -0
- package/dist/global-skills/eas-app-stores/references/play-store.md +3 -7
- package/dist/global-skills/eas-app-stores/references/testflight.md +39 -35
- package/dist/global-skills/eas-simulator/SKILL.md +48 -26
- package/dist/global-skills/eas-simulator/references/controllers.md +32 -3
- package/dist/global-skills/eas-simulator/references/run-your-app.md +34 -4
- package/dist/global-skills/eas-simulator/references/troubleshooting.md +8 -4
- package/dist/global-skills/eas-update/SKILL.md +146 -0
- package/dist/global-skills/eas-update/agents/openai.yaml +4 -0
- package/dist/global-skills/expo-animation/RECIPES.md +2 -2
- package/dist/global-skills/expo-animation/SKILL.md +9 -2
- package/dist/global-skills/expo-brownfield/SKILL.md +18 -11
- package/dist/global-skills/expo-brownfield/agents/openai.yaml +2 -2
- package/dist/global-skills/expo-brownfield/references/brownfield-integrated.md +94 -69
- package/dist/global-skills/expo-brownfield/references/brownfield-isolated.md +40 -42
- package/dist/global-skills/expo-brownfield/references/comparison.md +5 -5
- package/dist/global-skills/expo-brownfield/references/feature-integration.md +163 -0
- package/dist/global-skills/expo-brownfield/references/troubleshooting.md +17 -17
- package/dist/global-skills/expo-brownfield/references/version-compatibility.md +40 -0
- package/dist/global-skills/expo-data-fetching/SKILL.md +27 -6
- package/dist/global-skills/expo-design-system/SKILL.md +27 -7
- package/dist/global-skills/expo-design-system/references/audit.md +7 -2
- package/dist/global-skills/expo-design-system/references/native-slop.md +74 -0
- package/dist/global-skills/expo-examples/SKILL.md +0 -1
- package/dist/global-skills/expo-examples/references/catalog.md +1 -1
- package/dist/global-skills/expo-migrate-module/SKILL.md +21 -10
- package/dist/global-skills/expo-migrate-module/references/compatibility.md +80 -23
- package/dist/global-skills/expo-migrate-module/references/migration-map.md +162 -11
- package/dist/global-skills/expo-native-ui/SKILL.md +25 -16
- package/dist/global-skills/expo-native-ui/agents/openai.yaml +2 -2
- package/dist/global-skills/expo-native-ui/references/controls.md +5 -46
- package/dist/global-skills/expo-native-ui/references/icons.md +21 -2
- package/dist/global-skills/expo-native-ui/references/media.md +15 -20
- package/dist/global-skills/expo-native-ui/references/visual-effects.md +12 -11
- package/dist/global-skills/expo-overview/SKILL.md +17 -12
- package/dist/global-skills/expo-router/SKILL.md +5 -3
- package/dist/global-skills/expo-router/references/tabs.md +5 -5
- package/dist/global-skills/expo-upgrade/SKILL.md +3 -1
- package/dist/global-skills/expo-web-to-native/references/false-friends.md +2 -2
- package/dist/global-skills/expo-web-to-native/references/native-patterns.md +1 -1
- package/dist/global-skills/firebase-ai-logic-basics/SKILL.md +13 -16
- package/dist/global-skills/firebase-ai-logic-basics/references/ios_setup.md +4 -5
- package/dist/global-skills/firebase-ai-logic-basics/references/usage_patterns_android.md +4 -4
- package/dist/global-skills/firebase-ai-logic-basics/references/usage_patterns_web.md +3 -3
- package/dist/global-skills/firebase-auth-basics/SKILL.md +11 -6
- package/dist/global-skills/firebase-auth-basics/references/client_sdk_android.md +4 -5
- package/dist/global-skills/firebase-auth-basics/references/client_sdk_web.md +3 -3
- package/dist/global-skills/firebase-auth-basics/references/flutter_setup.md +24 -25
- package/dist/global-skills/firebase-auth-basics/references/security_rules.md +4 -2
- package/dist/global-skills/firebase-crashlytics/references/android_setup.md +7 -4
- package/dist/global-skills/firebase-crashlytics/references/ios_setup.md +2 -3
- package/dist/global-skills/firebase-data-connect/SKILL.md +2 -1
- package/dist/global-skills/firebase-data-connect/examples.md +4 -4
- package/dist/global-skills/firebase-data-connect/reference/config.md +5 -4
- package/dist/global-skills/firebase-data-connect/reference/realtime.md +1 -2
- package/dist/global-skills/firebase-data-connect/reference/sdk_flutter.md +2 -2
- package/dist/global-skills/firebase-data-connect/reference/sdk_ios.md +2 -2
- package/dist/global-skills/firebase-data-connect/reference/sdk_web.md +17 -6
- package/dist/global-skills/firebase-data-connect/reference/security.md +5 -5
- package/dist/global-skills/firebase-data-connect/templates.md +2 -1
- package/dist/global-skills/firebase-firestore/SKILL.md +20 -8
- package/dist/global-skills/firebase-firestore/references/enterprise/android_sdk_usage.md +5 -4
- package/dist/global-skills/firebase-firestore/references/enterprise/data_model.md +12 -3
- package/dist/global-skills/firebase-firestore/references/enterprise/indexes.md +16 -18
- package/dist/global-skills/firebase-firestore/references/enterprise/provisioning.md +1 -1
- package/dist/global-skills/firebase-firestore/references/enterprise/python_sdk_usage.md +5 -1
- package/dist/global-skills/firebase-firestore/references/enterprise/web_sdk_usage.md +7 -7
- package/dist/global-skills/firebase-firestore/references/standard/android_sdk_usage.md +5 -5
- package/dist/global-skills/firebase-firestore/references/standard/flutter_setup.md +4 -4
- package/dist/global-skills/firebase-firestore/references/standard/indexes.md +16 -18
- package/dist/global-skills/firebase-firestore/references/standard/provisioning.md +1 -1
- package/dist/global-skills/firebase-remote-config-basics/SKILL.md +0 -5
- package/dist/global-skills/firebase-remote-config-basics/references/android_setup.md +36 -8
- package/dist/global-skills/firebase-remote-config-basics/references/ios_setup.md +1 -7
- package/dist/global-skills/firebase-security-rules-auditor/SKILL.md +17 -6
- package/dist/global-skills/{firebase-firestore/references/standard/security_rules.md → firestore-rules-creation/SKILL.md} +24 -13
- package/dist/global-skills/go-live/SKILL.md +1 -1
- package/dist/global-skills/grow-my-customers/SKILL.md +23 -0
- package/dist/global-skills/harden/SKILL.md +1 -1
- package/dist/global-skills/instrument-feature-flags/SKILL.md +25 -25
- package/dist/global-skills/instrument-feature-flags/references/adding-feature-flag-code.md +141 -285
- package/dist/global-skills/instrument-feature-flags/references/android.md +6 -15
- package/dist/global-skills/instrument-feature-flags/references/api.md +4 -11
- package/dist/global-skills/instrument-feature-flags/references/best-practices.md +1 -13
- package/dist/global-skills/instrument-feature-flags/references/django.md +14 -27
- package/dist/global-skills/instrument-feature-flags/references/dotnet.md +20 -79
- package/dist/global-skills/instrument-feature-flags/references/elixir.md +1 -9
- package/dist/global-skills/instrument-feature-flags/references/flask.md +13 -13
- package/dist/global-skills/instrument-feature-flags/references/flutter.md +3 -24
- package/dist/global-skills/instrument-feature-flags/references/go.md +3 -15
- package/dist/global-skills/instrument-feature-flags/references/ios.md +4 -17
- package/dist/global-skills/instrument-feature-flags/references/java.md +5 -13
- package/dist/global-skills/instrument-feature-flags/references/laravel.md +13 -17
- package/dist/global-skills/instrument-feature-flags/references/next-js.md +25 -32
- package/dist/global-skills/instrument-feature-flags/references/nodejs.md +8 -15
- package/dist/global-skills/instrument-feature-flags/references/php.md +1 -15
- package/dist/global-skills/instrument-feature-flags/references/python.md +2 -15
- package/dist/global-skills/instrument-feature-flags/references/react-native.md +13 -15
- package/dist/global-skills/instrument-feature-flags/references/react.md +17 -21
- package/dist/global-skills/instrument-feature-flags/references/ruby-on-rails.md +37 -83
- package/dist/global-skills/instrument-feature-flags/references/ruby.md +2 -15
- package/dist/global-skills/instrument-feature-flags/references/rust.md +13 -25
- package/dist/global-skills/instrument-feature-flags/references/usage.md +14 -63
- package/dist/global-skills/instrument-feature-flags/references/web.md +9 -14
- package/dist/global-skills/instrument-product-analytics/SKILL.md +29 -29
- package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-astro-hybrid.md +3 -1
- package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-astro-ssr.md +3 -1
- package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-astro-static.md +3 -1
- package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-astro-view-transitions.md +3 -1
- package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-ruby-on-rails.md +3 -1
- package/dist/global-skills/instrument-product-analytics/references/android.md +72 -107
- package/dist/global-skills/instrument-product-analytics/references/angular.md +26 -28
- package/dist/global-skills/instrument-product-analytics/references/astro.md +13 -24
- package/dist/global-skills/instrument-product-analytics/references/configuration.md +45 -63
- package/dist/global-skills/instrument-product-analytics/references/django.md +14 -27
- package/dist/global-skills/instrument-product-analytics/references/dotnet.md +20 -79
- package/dist/global-skills/instrument-product-analytics/references/elixir.md +47 -49
- package/dist/global-skills/instrument-product-analytics/references/flask.md +13 -13
- package/dist/global-skills/instrument-product-analytics/references/flutter.md +60 -90
- package/dist/global-skills/instrument-product-analytics/references/go.md +17 -56
- package/dist/global-skills/instrument-product-analytics/references/identify-users.md +15 -15
- package/dist/global-skills/instrument-product-analytics/references/ios.md +11 -15
- package/dist/global-skills/instrument-product-analytics/references/laravel.md +13 -17
- package/dist/global-skills/instrument-product-analytics/references/next-js.md +25 -32
- package/dist/global-skills/instrument-product-analytics/references/nuxt-js-3-6.md +13 -27
- package/dist/global-skills/instrument-product-analytics/references/nuxt-js.md +14 -28
- package/dist/global-skills/instrument-product-analytics/references/php.md +33 -84
- package/dist/global-skills/instrument-product-analytics/references/posthog-python.md +229 -9
- package/dist/global-skills/instrument-product-analytics/references/python.md +415 -106
- package/dist/global-skills/instrument-product-analytics/references/react-native.md +161 -155
- package/dist/global-skills/instrument-product-analytics/references/react-router-v6.md +12 -33
- package/dist/global-skills/instrument-product-analytics/references/react-router-v7-data-mode.md +15 -33
- package/dist/global-skills/instrument-product-analytics/references/react-router-v7-declarative-mode.md +12 -33
- package/dist/global-skills/instrument-product-analytics/references/react-router-v7-framework-mode.md +26 -41
- package/dist/global-skills/instrument-product-analytics/references/ruby-on-rails.md +37 -83
- package/dist/global-skills/instrument-product-analytics/references/ruby.md +48 -108
- package/dist/global-skills/instrument-product-analytics/references/svelte.md +18 -24
- package/dist/global-skills/instrument-product-analytics/references/tanstack-start.md +17 -19
- package/dist/global-skills/instrument-product-analytics/references/usage.md +14 -63
- package/dist/global-skills/instrument-product-analytics/references/vue-js.md +29 -28
- package/dist/global-skills/manifest.json +8 -2
- package/dist/global-skills/mongodb-search-and-ai/SKILL.md +28 -37
- package/dist/global-skills/mongodb-search-and-ai/references/automated-embedding.md +438 -0
- package/dist/global-skills/mongodb-search-and-ai/references/hybrid-search.md +60 -4
- package/dist/global-skills/mongodb-search-and-ai/references/vector-search.md +46 -108
- package/dist/global-skills/neon/SKILL.md +207 -213
- package/dist/global-skills/neon/references/auth.md +12 -0
- package/dist/global-skills/neon/references/claimable-neon.md +10 -14
- package/dist/global-skills/neon/references/function-triggers.md +53 -0
- package/dist/global-skills/neon/references/logs-loki.md +61 -0
- package/dist/global-skills/neon/references/parse-env.md +32 -0
- package/dist/global-skills/neon/references/sdk.md +7 -0
- package/dist/global-skills/neon-ai-gateway/SKILL.md +14 -16
- package/dist/global-skills/neon-auth/SKILL.md +155 -0
- package/dist/global-skills/neon-auth/references/managed-auth.md +173 -0
- package/dist/global-skills/neon-auth/references/self-managed.md +25 -0
- package/dist/global-skills/neon-functions/SKILL.md +159 -84
- package/dist/global-skills/neon-functions/references/ai-sdk.md +4 -6
- package/dist/global-skills/neon-functions/references/function-triggers.md +249 -0
- package/dist/global-skills/neon-functions/references/mastra-studio.md +3 -3
- package/dist/global-skills/neon-functions/references/mcp.md +1 -1
- package/dist/global-skills/neon-functions/references/production-hardening.md +340 -0
- package/dist/global-skills/neon-functions/references/sse.md +8 -5
- package/dist/global-skills/neon-object-storage/SKILL.md +10 -11
- package/dist/global-skills/neon-postgres/SKILL.md +120 -17
- package/dist/global-skills/neon-postgres/references/full-text-search.md +99 -0
- package/dist/global-skills/neon-postgres/references/hybrid-search.md +90 -0
- package/dist/global-skills/neon-postgres/references/lakebase-search-drizzle.md +172 -0
- package/dist/global-skills/neon-postgres/references/vector-search.md +137 -0
- package/dist/global-skills/neon-postgres-branches/SKILL.md +3 -3
- package/dist/global-skills/neon-postgres-egress-optimizer/SKILL.md +1 -1
- package/dist/global-skills/onboarding/SKILL.md +16 -14
- package/dist/global-skills/plan-my-idea/SKILL.md +1 -1
- package/dist/global-skills/publish-app/SKILL.md +1 -1
- package/dist/global-skills/publish-extension/SKILL.md +1 -1
- package/dist/global-skills/resend/SKILL.md +4 -2
- package/dist/global-skills/resend/references/broadcasts.md +6 -1
- package/dist/global-skills/resend/references/receiving.md +29 -10
- package/dist/global-skills/resend/references/sending/email-management.md +14 -4
- package/dist/global-skills/resend/references/topics.md +9 -6
- package/dist/global-skills/resend/references/usage.md +117 -0
- package/dist/global-skills/resend/references/webhooks.md +59 -2
- package/dist/global-skills/reset-password/SKILL.md +1 -1
- package/dist/global-skills/save-data/SKILL.md +1 -1
- package/dist/global-skills/setup-email/SKILL.md +1 -1
- package/dist/global-skills/setup-payments/SKILL.md +1 -1
- package/dist/global-skills/setup-sms/SKILL.md +1 -1
- package/dist/global-skills/sign-in-with-email-link/SKILL.md +1 -1
- package/dist/global-skills/sign-in-with-google/SKILL.md +1 -1
- package/dist/global-skills/sign-in-with-phone/SKILL.md +1 -1
- package/dist/global-skills/stripe-best-practices/SKILL.md +35 -29
- package/dist/global-skills/stripe-best-practices/references/billing.md +9 -2
- package/dist/global-skills/stripe-best-practices/references/payments.md +4 -2
- package/dist/global-skills/stripe-best-practices/references/security.md +3 -1
- package/dist/global-skills/stripe-best-practices/references/tax.md +39 -20
- package/dist/global-skills/supabase/SKILL.md +6 -0
- package/dist/global-skills/track-errors/SKILL.md +1 -1
- package/dist/global-skills/update-kit/SKILL.md +1 -1
- package/dist/global-skills/use-railway/SKILL.md +42 -22
- package/dist/global-skills/use-railway/references/analyze-db.md +7 -6
- package/dist/global-skills/use-railway/references/cloud-agents.md +70 -0
- package/dist/global-skills/use-railway/references/configure.md +17 -2
- package/dist/global-skills/use-railway/references/databases.md +107 -0
- package/dist/global-skills/use-railway/references/deploy.md +5 -5
- package/dist/global-skills/use-railway/references/feature-flags.md +25 -13
- package/dist/global-skills/use-railway/references/iac.md +66 -77
- package/dist/global-skills/use-railway/references/operate.md +26 -3
- package/dist/global-skills/use-railway/references/request.md +31 -23
- package/dist/global-skills/use-railway/references/setup.md +16 -5
- package/dist/global-skills/use-railway/references/tracing.md +261 -0
- package/dist/global-skills/use-railway/references/usage.md +52 -0
- package/dist/global-skills/validate-my-idea/SKILL.md +54 -0
- package/dist/global-skills/{feedback → vybekiit-feedback}/SKILL.md +17 -13
- package/dist/global-skills/watch-my-app/SKILL.md +53 -0
- package/dist/global-skills/wire-auth/SKILL.md +1 -1
- package/dist/global-skills/wire-database/SKILL.md +1 -1
- package/dist/global-skills/wire-email/SKILL.md +1 -1
- package/dist/global-skills/wire-payments/SKILL.md +1 -1
- package/dist/global-skills/workers-best-practices/SKILL.md +36 -103
- package/dist/global-skills/workers-best-practices/references/configuration.md +139 -0
- package/dist/global-skills/workers-best-practices/references/platform-apis.md +51 -0
- package/dist/global-skills/workers-best-practices/references/{rules.md → runtime-patterns.md} +13 -137
- package/dist/global-skills/wrangler/SKILL.md +48 -901
- package/dist/global-skills/xcode-project-setup/scripts/xcode_spm_setup/Sources/main.swift +19 -15
- package/package.json +9 -8
- package/dist/global-skills/expo-native-ui/references/animations.md +0 -220
- package/dist/global-skills/firebase-firestore/references/enterprise/security_rules.md +0 -577
- package/dist/global-skills/workers-best-practices/references/review.md +0 -174
package/dist/global-skills/instrument-product-analytics/references/react-router-v7-framework-mode.md
CHANGED
|
@@ -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
|
-
# React Router V7 framework mode (Remix V3)
|
|
4
|
-
|
|
5
|
-
Copy page
|
|
6
|
-
|
|
7
|
-
# React Router V7 framework mode (Remix V3) - Docs
|
|
3
|
+
# React Router V7 framework mode (Remix V3)
|
|
8
4
|
|
|
9
5
|
This guide walks you through setting up PostHog for React Router V7 in framework mode. If you're using React Router in another mode, 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).
|
|
10
6
|
|
|
@@ -16,8 +12,6 @@ This guide walks you through setting up PostHog for React Router V7 in framework
|
|
|
16
12
|
|
|
17
13
|
First, you'll need to install [`posthog-js`](https://github.com/posthog/posthog-js) and `@posthog/react` using your package manager. These packages allow you to capture **client-side** events.
|
|
18
14
|
|
|
19
|
-
PostHog AI
|
|
20
|
-
|
|
21
15
|
### npm
|
|
22
16
|
|
|
23
17
|
```bash
|
|
@@ -44,8 +38,6 @@ This guide walks you through setting up PostHog for React Router V7 in framework
|
|
|
44
38
|
|
|
45
39
|
> **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
40
|
>
|
|
47
|
-
> PostHog AI
|
|
48
|
-
>
|
|
49
41
|
> ```
|
|
50
42
|
> script-src 'self' https://*.posthog.com;
|
|
51
43
|
> connect-src 'self' https://*.posthog.com;
|
|
@@ -58,10 +50,9 @@ This guide walks you through setting up PostHog for React Router V7 in framework
|
|
|
58
50
|
|
|
59
51
|
vite.config.ts
|
|
60
52
|
|
|
61
|
-
PostHog AI
|
|
62
|
-
|
|
63
53
|
```typescript
|
|
64
54
|
// ... imports
|
|
55
|
+
|
|
65
56
|
export default defineConfig({
|
|
66
57
|
plugins: [tailwindcss(), reactRouter(), tsconfigPaths()],
|
|
67
58
|
ssr: {
|
|
@@ -80,8 +71,6 @@ This guide walks you through setting up PostHog for React Router V7 in framework
|
|
|
80
71
|
|
|
81
72
|
.env.local
|
|
82
73
|
|
|
83
|
-
PostHog AI
|
|
84
|
-
|
|
85
74
|
```shell
|
|
86
75
|
VITE_POSTHOG_PROJECT_TOKEN=<ph_project_token>
|
|
87
76
|
VITE_POSTHOG_HOST=https://us.i.posthog.com
|
|
@@ -97,19 +86,21 @@ This guide walks you through setting up PostHog for React Router V7 in framework
|
|
|
97
86
|
|
|
98
87
|
app/entry.client.tsx
|
|
99
88
|
|
|
100
|
-
PostHog AI
|
|
101
|
-
|
|
102
89
|
```jsx
|
|
103
90
|
import { startTransition, StrictMode } from "react";
|
|
104
91
|
import { hydrateRoot } from "react-dom/client";
|
|
105
92
|
import { HydratedRouter } from "react-router/dom";
|
|
93
|
+
|
|
106
94
|
import posthog from 'posthog-js';
|
|
107
95
|
import { PostHogProvider } from '@posthog/react'
|
|
96
|
+
|
|
108
97
|
posthog.init(import.meta.env.VITE_POSTHOG_PROJECT_TOKEN, {
|
|
109
98
|
api_host: import.meta.env.VITE_POSTHOG_HOST,
|
|
110
99
|
defaults: '2026-05-30',
|
|
111
100
|
tracing_headers: [ window.location.hostname, 'localhost' ],
|
|
112
101
|
});
|
|
102
|
+
|
|
103
|
+
|
|
113
104
|
startTransition(() => {
|
|
114
105
|
hydrateRoot(
|
|
115
106
|
document,
|
|
@@ -133,11 +124,10 @@ This guide walks you through setting up PostHog for React Router V7 in framework
|
|
|
133
124
|
|
|
134
125
|
React
|
|
135
126
|
|
|
136
|
-
PostHog AI
|
|
137
|
-
|
|
138
127
|
```jsx
|
|
139
128
|
useEffect(() => {
|
|
140
129
|
posthog?.capture('test') // using optional chaining (recommended)
|
|
130
|
+
|
|
141
131
|
if (posthog) {
|
|
142
132
|
posthog.capture('test') // using an if statement
|
|
143
133
|
}
|
|
@@ -158,10 +148,9 @@ This guide walks you through setting up PostHog for React Router V7 in framework
|
|
|
158
148
|
|
|
159
149
|
TSX
|
|
160
150
|
|
|
161
|
-
PostHog AI
|
|
162
|
-
|
|
163
151
|
```jsx
|
|
164
152
|
import { usePostHog } from '@posthog/react'
|
|
153
|
+
|
|
165
154
|
function App() {
|
|
166
155
|
const posthog = usePostHog()
|
|
167
156
|
return <button onClick={() => posthog?.capture('button_clicked')}>Click me</button>
|
|
@@ -180,10 +169,9 @@ This guide walks you through setting up PostHog for React Router V7 in framework
|
|
|
180
169
|
|
|
181
170
|
TSX
|
|
182
171
|
|
|
183
|
-
PostHog AI
|
|
184
|
-
|
|
185
172
|
```jsx
|
|
186
173
|
import { usePostHog } from '@posthog/react'
|
|
174
|
+
|
|
187
175
|
function App() {
|
|
188
176
|
const posthog = usePostHog()
|
|
189
177
|
return <button onClick={() => posthog?.capture('button_clicked')}>Click me</button>
|
|
@@ -204,15 +192,15 @@ This guide walks you through setting up PostHog for React Router V7 in framework
|
|
|
204
192
|
|
|
205
193
|
TSX
|
|
206
194
|
|
|
207
|
-
PostHog AI
|
|
208
|
-
|
|
209
195
|
```jsx
|
|
210
196
|
export default function Login() {
|
|
211
197
|
const { user, login } = useAuth();
|
|
212
198
|
const posthog = usePostHog();
|
|
199
|
+
|
|
213
200
|
const handleLogin = async (e: React.FormEvent) => {
|
|
214
201
|
// existing code to handle login...
|
|
215
202
|
const user = await login({ email, password });
|
|
203
|
+
|
|
216
204
|
posthog?.identify(user.email,
|
|
217
205
|
{
|
|
218
206
|
email: user.email,
|
|
@@ -221,6 +209,7 @@ This guide walks you through setting up PostHog for React Router V7 in framework
|
|
|
221
209
|
);
|
|
222
210
|
posthog?.capture('user_logged_in');
|
|
223
211
|
};
|
|
212
|
+
|
|
224
213
|
return (
|
|
225
214
|
<div>
|
|
226
215
|
{/* ... existing code ... */}
|
|
@@ -242,13 +231,13 @@ This guide walks you through setting up PostHog for React Router V7 in framework
|
|
|
242
231
|
|
|
243
232
|
app/root.tsx
|
|
244
233
|
|
|
245
|
-
PostHog AI
|
|
246
|
-
|
|
247
234
|
```jsx
|
|
248
235
|
import { usePostHog } from '@posthog/react'
|
|
236
|
+
|
|
249
237
|
export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) {
|
|
250
238
|
const posthog = usePostHog();
|
|
251
239
|
posthog?.captureException(error);
|
|
240
|
+
|
|
252
241
|
// other error handling code...
|
|
253
242
|
return (
|
|
254
243
|
<div>
|
|
@@ -275,10 +264,9 @@ This guide walks you through setting up PostHog for React Router V7 in framework
|
|
|
275
264
|
|
|
276
265
|
React
|
|
277
266
|
|
|
278
|
-
PostHog AI
|
|
279
|
-
|
|
280
267
|
```jsx
|
|
281
268
|
import { PostHogCaptureOnViewed } from '@posthog/react'
|
|
269
|
+
|
|
282
270
|
function App() {
|
|
283
271
|
return (
|
|
284
272
|
<PostHogCaptureOnViewed name="hero-banner">
|
|
@@ -294,8 +282,6 @@ This guide walks you through setting up PostHog for React Router V7 in framework
|
|
|
294
282
|
|
|
295
283
|
React
|
|
296
284
|
|
|
297
|
-
PostHog AI
|
|
298
|
-
|
|
299
285
|
```jsx
|
|
300
286
|
<PostHogCaptureOnViewed
|
|
301
287
|
name="product-card"
|
|
@@ -315,8 +301,6 @@ This guide walks you through setting up PostHog for React Router V7 in framework
|
|
|
315
301
|
|
|
316
302
|
React
|
|
317
303
|
|
|
318
|
-
PostHog AI
|
|
319
|
-
|
|
320
304
|
```jsx
|
|
321
305
|
<PostHogCaptureOnViewed
|
|
322
306
|
name="product-gallery"
|
|
@@ -337,8 +321,6 @@ This guide walks you through setting up PostHog for React Router V7 in framework
|
|
|
337
321
|
|
|
338
322
|
React
|
|
339
323
|
|
|
340
|
-
PostHog AI
|
|
341
|
-
|
|
342
324
|
```jsx
|
|
343
325
|
<PostHogCaptureOnViewed
|
|
344
326
|
name="footer"
|
|
@@ -361,8 +343,6 @@ This guide walks you through setting up PostHog for React Router V7 in framework
|
|
|
361
343
|
|
|
362
344
|
Install the [PostHog Node SDK](/docs/libraries/node.md) using your package manager. This is the SDK you'll use to capture server-side events.
|
|
363
345
|
|
|
364
|
-
PostHog AI
|
|
365
|
-
|
|
366
346
|
### npm
|
|
367
347
|
|
|
368
348
|
```bash
|
|
@@ -401,29 +381,34 @@ This guide walks you through setting up PostHog for React Router V7 in framework
|
|
|
401
381
|
|
|
402
382
|
app/lib/posthog-middleware.ts
|
|
403
383
|
|
|
404
|
-
PostHog AI
|
|
405
|
-
|
|
406
384
|
```typescript
|
|
407
385
|
import { PostHog } from "posthog-node";
|
|
408
386
|
import type { RouterContextProvider } from "react-router";
|
|
409
387
|
import type { Route } from "../+types/root";
|
|
388
|
+
|
|
410
389
|
export interface PostHogContext extends RouterContextProvider {
|
|
411
390
|
posthog?: PostHog;
|
|
412
391
|
}
|
|
392
|
+
|
|
413
393
|
export const posthogMiddleware: Route.MiddlewareFunction = async ({ request, context }, next) => {
|
|
414
394
|
const posthog = new PostHog(process.env.VITE_POSTHOG_PROJECT_TOKEN!, {
|
|
415
395
|
host: process.env.VITE_POSTHOG_HOST!,
|
|
416
396
|
flushAt: 1,
|
|
417
397
|
flushInterval: 0,
|
|
418
398
|
});
|
|
399
|
+
|
|
419
400
|
const sessionId = request.headers.get('X-POSTHOG-SESSION-ID');
|
|
420
401
|
const distinctId = request.headers.get('X-POSTHOG-DISTINCT-ID');
|
|
402
|
+
|
|
421
403
|
(context as PostHogContext).posthog = posthog;
|
|
404
|
+
|
|
422
405
|
const response = await posthog.withContext(
|
|
423
406
|
{ sessionId: sessionId ?? undefined, distinctId: distinctId ?? undefined },
|
|
424
407
|
next
|
|
425
408
|
);
|
|
409
|
+
|
|
426
410
|
await posthog.shutdown().catch(() => {});
|
|
411
|
+
|
|
427
412
|
return response;
|
|
428
413
|
};
|
|
429
414
|
```
|
|
@@ -432,10 +417,9 @@ This guide walks you through setting up PostHog for React Router V7 in framework
|
|
|
432
417
|
|
|
433
418
|
app/root.tsx
|
|
434
419
|
|
|
435
|
-
PostHog AI
|
|
436
|
-
|
|
437
420
|
```jsx
|
|
438
421
|
import { posthogMiddleware } from './lib/posthog-middleware';
|
|
422
|
+
|
|
439
423
|
export const middleware: Route.MiddlewareFunction[] = [
|
|
440
424
|
posthogMiddleware,
|
|
441
425
|
// other middlewares...
|
|
@@ -454,16 +438,17 @@ This guide walks you through setting up PostHog for React Router V7 in framework
|
|
|
454
438
|
|
|
455
439
|
app/routes/api.checkout.ts
|
|
456
440
|
|
|
457
|
-
PostHog AI
|
|
458
|
-
|
|
459
441
|
```jsx
|
|
460
442
|
import type { PostHogContext } from "../lib/posthog-middleware";
|
|
443
|
+
|
|
461
444
|
export async function action({ request, context }: Route.ActionArgs) {
|
|
462
445
|
const body = await request.json();
|
|
463
446
|
// ... existing code ...
|
|
447
|
+
|
|
464
448
|
// Access the PostHog client from the context and capture an event
|
|
465
449
|
const posthog = (context as PostHogContext).posthog;
|
|
466
450
|
posthog?.capture({ event: 'checkout_completed' });
|
|
451
|
+
|
|
467
452
|
return Response.json({
|
|
468
453
|
success: true,
|
|
469
454
|
// ... existing code ...
|
|
@@ -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
|
-
# Ruby on Rails
|
|
4
|
-
|
|
5
|
-
Copy page
|
|
6
|
-
|
|
7
|
-
# Ruby on Rails - Docs
|
|
3
|
+
# Ruby on Rails
|
|
8
4
|
|
|
9
5
|
PostHog makes it easy to get data about traffic and usage of your Ruby on Rails app. Integrating PostHog enables analytics, custom event capture, feature flags, and automatic exception tracking.
|
|
10
6
|
|
|
@@ -36,8 +32,6 @@ Add both gems to your Gemfile:
|
|
|
36
32
|
|
|
37
33
|
Gemfile
|
|
38
34
|
|
|
39
|
-
PostHog AI
|
|
40
|
-
|
|
41
35
|
```ruby
|
|
42
36
|
gem 'posthog-ruby', require: 'posthog'
|
|
43
37
|
gem 'posthog-rails'
|
|
@@ -47,8 +41,6 @@ Then run:
|
|
|
47
41
|
|
|
48
42
|
Terminal
|
|
49
43
|
|
|
50
|
-
PostHog AI
|
|
51
|
-
|
|
52
44
|
```bash
|
|
53
45
|
bundle install
|
|
54
46
|
```
|
|
@@ -65,8 +57,6 @@ Run the install generator to create the PostHog initializer:
|
|
|
65
57
|
|
|
66
58
|
Terminal
|
|
67
59
|
|
|
68
|
-
PostHog AI
|
|
69
|
-
|
|
70
60
|
```bash
|
|
71
61
|
rails generate posthog:install
|
|
72
62
|
```
|
|
@@ -81,8 +71,6 @@ The generated initializer includes the most common options:
|
|
|
81
71
|
|
|
82
72
|
config/initializers/posthog.rb
|
|
83
73
|
|
|
84
|
-
PostHog AI
|
|
85
|
-
|
|
86
74
|
```ruby
|
|
87
75
|
# Rails-specific configuration
|
|
88
76
|
PostHog::Rails.configure do |config|
|
|
@@ -93,35 +81,46 @@ PostHog::Rails.configure do |config|
|
|
|
93
81
|
config.capture_user_context = true # Include authenticated user info in exceptions (default: true)
|
|
94
82
|
config.current_user_method = :current_user # Method to get current user (default: :current_user)
|
|
95
83
|
config.user_id_method = nil # Method to get ID from user object (default: auto-detect)
|
|
84
|
+
|
|
96
85
|
# Add additional exceptions to ignore
|
|
97
86
|
config.excluded_exceptions = ['MyCustomError']
|
|
98
87
|
end
|
|
88
|
+
|
|
99
89
|
# Core PostHog client initialization
|
|
100
90
|
PostHog.init do |config|
|
|
101
91
|
# Required: Your PostHog project API key
|
|
102
92
|
config.api_key = '<ph_project_token>'
|
|
93
|
+
|
|
103
94
|
# Optional: Your PostHog instance URL
|
|
104
95
|
config.host = 'https://us.i.posthog.com'
|
|
96
|
+
|
|
105
97
|
# Optional: Personal API key for feature flags
|
|
106
98
|
config.personal_api_key = 'phx_xxxxxxxxx'
|
|
99
|
+
|
|
107
100
|
# Maximum number of events to queue before dropping (default: 10000)
|
|
108
101
|
config.max_queue_size = 10_000
|
|
102
|
+
|
|
109
103
|
# Send events synchronously on the calling thread (default: false)
|
|
110
104
|
config.sync_mode = false
|
|
105
|
+
|
|
111
106
|
# Feature flags polling interval in seconds (default: 30)
|
|
112
107
|
config.feature_flags_polling_interval = 30
|
|
108
|
+
|
|
113
109
|
# Feature flag request timeout in seconds (default: 3)
|
|
114
110
|
config.feature_flag_request_timeout_seconds = 3
|
|
111
|
+
|
|
115
112
|
# Error callback to detect misconfiguration
|
|
116
113
|
config.on_error = proc { |status, msg|
|
|
117
114
|
Rails.logger.error("PostHog error: #{msg}")
|
|
118
115
|
}
|
|
116
|
+
|
|
119
117
|
# Before-send callback to modify or drop events
|
|
120
118
|
config.before_send = proc { |event|
|
|
121
119
|
event[:properties] ||= {}
|
|
122
120
|
event[:properties]['environment'] = Rails.env
|
|
123
121
|
event
|
|
124
122
|
}
|
|
123
|
+
|
|
125
124
|
# Disable network calls in test mode
|
|
126
125
|
config.test_mode = true if Rails.env.test?
|
|
127
126
|
end
|
|
@@ -133,16 +132,12 @@ You can find your project token and instance address in [your project settings](
|
|
|
133
132
|
>
|
|
134
133
|
> Terminal
|
|
135
134
|
>
|
|
136
|
-
> PostHog AI
|
|
137
|
-
>
|
|
138
135
|
> ```bash
|
|
139
136
|
> rails credentials:edit
|
|
140
137
|
> ```
|
|
141
138
|
>
|
|
142
139
|
> config/credentials.yml.enc
|
|
143
140
|
>
|
|
144
|
-
> PostHog AI
|
|
145
|
-
>
|
|
146
141
|
> ```yaml
|
|
147
142
|
> posthog:
|
|
148
143
|
> api_key: <ph_project_token>
|
|
@@ -152,8 +147,6 @@ You can find your project token and instance address in [your project settings](
|
|
|
152
147
|
>
|
|
153
148
|
> config/initializers/posthog.rb
|
|
154
149
|
>
|
|
155
|
-
> PostHog AI
|
|
156
|
-
>
|
|
157
150
|
> ```ruby
|
|
158
151
|
> config.api_key = Rails.application.credentials.posthog[:api_key]
|
|
159
152
|
> config.host = Rails.application.credentials.posthog[:host]
|
|
@@ -166,8 +159,6 @@ Track custom events anywhere in your Rails app:
|
|
|
166
159
|
|
|
167
160
|
Ruby
|
|
168
161
|
|
|
169
|
-
PostHog AI
|
|
170
|
-
|
|
171
162
|
```ruby
|
|
172
163
|
PostHog.capture({
|
|
173
164
|
distinct_id: current_user.id,
|
|
@@ -180,8 +171,6 @@ Identify a user and set their person properties:
|
|
|
180
171
|
|
|
181
172
|
Ruby
|
|
182
173
|
|
|
183
|
-
PostHog AI
|
|
184
|
-
|
|
185
174
|
```ruby
|
|
186
175
|
PostHog.identify({
|
|
187
176
|
distinct_id: current_user.id,
|
|
@@ -208,8 +197,6 @@ Disable tracing header identity/session capture if you do not want client-suppli
|
|
|
208
197
|
|
|
209
198
|
Ruby
|
|
210
199
|
|
|
211
|
-
PostHog AI
|
|
212
|
-
|
|
213
200
|
```ruby
|
|
214
201
|
PostHog::Rails.config.use_tracing_headers = false
|
|
215
202
|
```
|
|
@@ -228,8 +215,6 @@ When `auto_capture_exceptions` is enabled, exceptions are automatically captured
|
|
|
228
215
|
|
|
229
216
|
Ruby
|
|
230
217
|
|
|
231
|
-
PostHog AI
|
|
232
|
-
|
|
233
218
|
```ruby
|
|
234
219
|
class PostsController < ApplicationController
|
|
235
220
|
def show
|
|
@@ -247,8 +232,6 @@ You can also manually capture exceptions:
|
|
|
247
232
|
|
|
248
233
|
Ruby
|
|
249
234
|
|
|
250
|
-
PostHog AI
|
|
251
|
-
|
|
252
235
|
```ruby
|
|
253
236
|
PostHog.capture_exception(
|
|
254
237
|
exception,
|
|
@@ -261,10 +244,9 @@ If you evaluated feature flags for the request, pass the same snapshot to includ
|
|
|
261
244
|
|
|
262
245
|
Ruby
|
|
263
246
|
|
|
264
|
-
PostHog AI
|
|
265
|
-
|
|
266
247
|
```ruby
|
|
267
248
|
flags = PostHog.evaluate_flags(current_user.id)
|
|
249
|
+
|
|
268
250
|
PostHog.capture_exception(
|
|
269
251
|
exception,
|
|
270
252
|
current_user.id,
|
|
@@ -279,8 +261,6 @@ When `auto_instrument_active_job` is enabled, ActiveJob exceptions are automatic
|
|
|
279
261
|
|
|
280
262
|
Ruby
|
|
281
263
|
|
|
282
|
-
PostHog AI
|
|
283
|
-
|
|
284
264
|
```ruby
|
|
285
265
|
class EmailJob < ApplicationJob
|
|
286
266
|
def perform(user_id)
|
|
@@ -297,8 +277,6 @@ By default, PostHog extracts a `distinct_id` from job arguments by looking for a
|
|
|
297
277
|
|
|
298
278
|
Ruby
|
|
299
279
|
|
|
300
|
-
PostHog AI
|
|
301
|
-
|
|
302
280
|
```ruby
|
|
303
281
|
# PostHog will automatically use options[:user_id] as the distinct_id
|
|
304
282
|
ProcessOrderJob.perform_later(order.id, user_id: current_user.id)
|
|
@@ -308,11 +286,10 @@ For more control, use the `posthog_distinct_id` class method. The proc or block
|
|
|
308
286
|
|
|
309
287
|
Ruby
|
|
310
288
|
|
|
311
|
-
PostHog AI
|
|
312
|
-
|
|
313
289
|
```ruby
|
|
314
290
|
class SendWelcomeEmailJob < ApplicationJob
|
|
315
291
|
posthog_distinct_id ->(user, _options) { user.id }
|
|
292
|
+
|
|
316
293
|
def perform(user, options = {})
|
|
317
294
|
UserMailer.welcome(user).deliver_now
|
|
318
295
|
end
|
|
@@ -323,13 +300,12 @@ You can also use a block:
|
|
|
323
300
|
|
|
324
301
|
Ruby
|
|
325
302
|
|
|
326
|
-
PostHog AI
|
|
327
|
-
|
|
328
303
|
```ruby
|
|
329
304
|
class ProcessOrderJob < ApplicationJob
|
|
330
305
|
posthog_distinct_id do |_order, notify_user_id|
|
|
331
306
|
notify_user_id
|
|
332
307
|
end
|
|
308
|
+
|
|
333
309
|
def perform(order, notify_user_id)
|
|
334
310
|
# Process the order...
|
|
335
311
|
end
|
|
@@ -342,13 +318,12 @@ PostHog integrates with Rails' built-in error reporting:
|
|
|
342
318
|
|
|
343
319
|
Ruby
|
|
344
320
|
|
|
345
|
-
PostHog AI
|
|
346
|
-
|
|
347
321
|
```ruby
|
|
348
322
|
# These errors are automatically sent to PostHog
|
|
349
323
|
Rails.error.handle do
|
|
350
324
|
# Code that might raise an error
|
|
351
325
|
end
|
|
326
|
+
|
|
352
327
|
Rails.error.record(exception, context: { user_id: current_user.id })
|
|
353
328
|
```
|
|
354
329
|
|
|
@@ -362,8 +337,6 @@ If your user method has a different name, configure it:
|
|
|
362
337
|
|
|
363
338
|
Ruby
|
|
364
339
|
|
|
365
|
-
PostHog AI
|
|
366
|
-
|
|
367
340
|
```ruby
|
|
368
341
|
PostHog::Rails.config.current_user_method = :logged_in_user
|
|
369
342
|
```
|
|
@@ -384,8 +357,6 @@ You can configure a specific method:
|
|
|
384
357
|
|
|
385
358
|
Ruby
|
|
386
359
|
|
|
387
|
-
PostHog AI
|
|
388
|
-
|
|
389
360
|
```ruby
|
|
390
361
|
PostHog::Rails.config.user_id_method = :email
|
|
391
362
|
```
|
|
@@ -394,8 +365,6 @@ Or define a method on your User model:
|
|
|
394
365
|
|
|
395
366
|
Ruby
|
|
396
367
|
|
|
397
|
-
PostHog AI
|
|
398
|
-
|
|
399
368
|
```ruby
|
|
400
369
|
class User < ApplicationRecord
|
|
401
370
|
def posthog_distinct_id
|
|
@@ -426,8 +395,6 @@ Add more with:
|
|
|
426
395
|
|
|
427
396
|
Ruby
|
|
428
397
|
|
|
429
|
-
PostHog AI
|
|
430
|
-
|
|
431
398
|
```ruby
|
|
432
399
|
PostHog::Rails.config.excluded_exceptions = ['MyException']
|
|
433
400
|
```
|
|
@@ -438,12 +405,11 @@ Evaluate flags once for the current user, then read values from the returned sna
|
|
|
438
405
|
|
|
439
406
|
Ruby
|
|
440
407
|
|
|
441
|
-
PostHog AI
|
|
442
|
-
|
|
443
408
|
```ruby
|
|
444
409
|
class PostsController < ApplicationController
|
|
445
410
|
def show
|
|
446
411
|
flags = PostHog.evaluate_flags(current_user.id)
|
|
412
|
+
|
|
447
413
|
if flags.enabled?('new-post-design')
|
|
448
414
|
render 'posts/show_new'
|
|
449
415
|
else
|
|
@@ -457,11 +423,10 @@ For multivariate flags and experiments, use `get_flag`:
|
|
|
457
423
|
|
|
458
424
|
Ruby
|
|
459
425
|
|
|
460
|
-
PostHog AI
|
|
461
|
-
|
|
462
426
|
```ruby
|
|
463
427
|
flags = PostHog.evaluate_flags(current_user.id)
|
|
464
428
|
variant = flags.get_flag('checkout-experiment')
|
|
429
|
+
|
|
465
430
|
if variant == 'test'
|
|
466
431
|
# Do something differently
|
|
467
432
|
end
|
|
@@ -471,10 +436,9 @@ When capturing an event after branching on a flag, pass the same `flags` snapsho
|
|
|
471
436
|
|
|
472
437
|
Ruby
|
|
473
438
|
|
|
474
|
-
PostHog AI
|
|
475
|
-
|
|
476
439
|
```ruby
|
|
477
440
|
flags = PostHog.evaluate_flags(current_user.id)
|
|
441
|
+
|
|
478
442
|
PostHog.capture({
|
|
479
443
|
distinct_id: current_user.id,
|
|
480
444
|
event: 'checkout_started',
|
|
@@ -486,8 +450,6 @@ For local evaluation, ensure you've set `personal_api_key`:
|
|
|
486
450
|
|
|
487
451
|
Ruby
|
|
488
452
|
|
|
489
|
-
PostHog AI
|
|
490
|
-
|
|
491
453
|
```ruby
|
|
492
454
|
config.personal_api_key = Rails.application.credentials.posthog[:personal_api_key]
|
|
493
455
|
```
|
|
@@ -502,8 +464,6 @@ In your test environment, disable network calls with test mode:
|
|
|
502
464
|
|
|
503
465
|
config/environments/test.rb
|
|
504
466
|
|
|
505
|
-
PostHog AI
|
|
506
|
-
|
|
507
467
|
```ruby
|
|
508
468
|
PostHog.init do |config|
|
|
509
469
|
config.api_key = '<ph_project_token>'
|
|
@@ -515,8 +475,6 @@ Or in your specs:
|
|
|
515
475
|
|
|
516
476
|
spec/rails\_helper.rb
|
|
517
477
|
|
|
518
|
-
PostHog AI
|
|
519
|
-
|
|
520
478
|
```ruby
|
|
521
479
|
RSpec.configure do |config|
|
|
522
480
|
config.before(:each) do
|
|
@@ -531,16 +489,16 @@ end
|
|
|
531
489
|
|
|
532
490
|
| Option | Type | Default | Description |
|
|
533
491
|
| --- | --- | --- | --- |
|
|
534
|
-
| api_key | String | required | Your PostHog project token. |
|
|
535
|
-
| host | String | https://us.i.posthog.com | Fully qualified PostHog API host. |
|
|
536
|
-
| personal_api_key | String | nil | Personal API key for local feature flag evaluation and remote config payloads. |
|
|
537
|
-
| max_queue_size | Integer | 10000 | Maximum number of events to keep in the async queue before dropping new events. |
|
|
538
|
-
| test_mode | Boolean | false | Keep events queued and do not send them. Useful for tests. |
|
|
539
|
-
| sync_mode | Boolean | false | Send events synchronously on the calling thread. |
|
|
540
|
-
| on_error | Proc | no-op | Callback called as on_error.call(status, error)
|
|
541
|
-
| feature_flags_polling_interval | Integer | 30 | Seconds between local feature flag definition polls. |
|
|
542
|
-
| feature_flag_request_timeout_seconds | Integer | 3 | Timeout, in seconds, for feature flag requests. |
|
|
543
|
-
| before_send | Proc | nil | Callback that receives the event hash before it is queued or sent. Return a modified event hash, or nil to drop the event. |
|
|
492
|
+
| `api_key` | String | **required** | Your PostHog project token. |
|
|
493
|
+
| `host` | String | `https://us.i.posthog.com` | Fully qualified PostHog API host. |
|
|
494
|
+
| `personal_api_key` | String | `nil` | Personal API key for local feature flag evaluation and remote config payloads. |
|
|
495
|
+
| `max_queue_size` | Integer | `10000` | Maximum number of events to keep in the async queue before dropping new events. |
|
|
496
|
+
| `test_mode` | Boolean | `false` | Keep events queued and do not send them. Useful for tests. |
|
|
497
|
+
| `sync_mode` | Boolean | `false` | Send events synchronously on the calling thread. |
|
|
498
|
+
| `on_error` | Proc | no-op | Callback called as `on_error.call(status, error)`. |
|
|
499
|
+
| `feature_flags_polling_interval` | Integer | `30` | Seconds between local feature flag definition polls. |
|
|
500
|
+
| `feature_flag_request_timeout_seconds` | Integer | `3` | Timeout, in seconds, for feature flag requests. |
|
|
501
|
+
| `before_send` | Proc | `nil` | Callback that receives the event hash before it is queued or sent. Return a modified event hash, or `nil` to drop the event. |
|
|
544
502
|
|
|
545
503
|
The `PostHog.init` block supports the options above. Less common core options like `batch_size`, `disable_singleton_warning`, `skip_ssl_verification`, and `flag_definition_cache_provider` can be passed as an options hash to `PostHog.init(...)`; see the [Ruby SDK docs](/docs/libraries/ruby.md#configuration) for details.
|
|
546
504
|
|
|
@@ -550,14 +508,14 @@ Configure these via `PostHog::Rails.configure` or `PostHog::Rails.config`:
|
|
|
550
508
|
|
|
551
509
|
| Option | Type | Default | Description |
|
|
552
510
|
| --- | --- | --- | --- |
|
|
553
|
-
| auto_capture_exceptions | Boolean | false | Automatically capture exceptions. |
|
|
554
|
-
| report_rescued_exceptions | Boolean | false | Report exceptions Rails rescues. |
|
|
555
|
-
| auto_instrument_active_job | Boolean | false | Capture ActiveJob exceptions with job context. |
|
|
556
|
-
| excluded_exceptions | Array | [] | Additional exception class names to ignore. |
|
|
557
|
-
| use_tracing_headers | Boolean | true | Use X-PostHog-Distinct-Id and X-PostHog-Session-Id as request-scoped defaults. |
|
|
558
|
-
| capture_user_context | Boolean | true | Include authenticated user info in exceptions. |
|
|
559
|
-
| current_user_method | Symbol |
|
|
560
|
-
| user_id_method | Symbol | nil | Method used to extract the distinct ID from the user object. Auto-detects when nil. |
|
|
511
|
+
| `auto_capture_exceptions` | Boolean | `false` | Automatically capture exceptions. |
|
|
512
|
+
| `report_rescued_exceptions` | Boolean | `false` | Report exceptions Rails rescues. |
|
|
513
|
+
| `auto_instrument_active_job` | Boolean | `false` | Capture ActiveJob exceptions with job context. |
|
|
514
|
+
| `excluded_exceptions` | Array | `[]` | Additional exception class names to ignore. |
|
|
515
|
+
| `use_tracing_headers` | Boolean | `true` | Use `X-PostHog-Distinct-Id` and `X-PostHog-Session-Id` as request-scoped defaults. |
|
|
516
|
+
| `capture_user_context` | Boolean | `true` | Include authenticated user info in exceptions. |
|
|
517
|
+
| `current_user_method` | Symbol | `:current_user` | Controller method used to fetch the current user. |
|
|
518
|
+
| `user_id_method` | Symbol | `nil` | Method used to extract the distinct ID from the user object. Auto-detects when nil. |
|
|
561
519
|
|
|
562
520
|
## Troubleshooting
|
|
563
521
|
|
|
@@ -567,8 +525,6 @@ Configure these via `PostHog::Rails.configure` or `PostHog::Rails.config`:
|
|
|
567
525
|
|
|
568
526
|
Ruby
|
|
569
527
|
|
|
570
|
-
PostHog AI
|
|
571
|
-
|
|
572
528
|
```ruby
|
|
573
529
|
Rails.console
|
|
574
530
|
> PostHog.initialized?
|
|
@@ -581,8 +537,6 @@ Configure these via `PostHog::Rails.configure` or `PostHog::Rails.config`:
|
|
|
581
537
|
|
|
582
538
|
Ruby
|
|
583
539
|
|
|
584
|
-
PostHog AI
|
|
585
|
-
|
|
586
540
|
```ruby
|
|
587
541
|
Rails.application.middleware
|
|
588
542
|
```
|