vybekiit 0.7.33 → 0.7.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/dist/bin.js +818 -92
  2. package/dist/global-skills/eas-app-stores/SKILL.md +2 -2
  3. package/dist/global-skills/eas-hosting/SKILL.md +2 -2
  4. package/dist/global-skills/eas-observe/SKILL.md +7 -15
  5. package/dist/global-skills/eas-observe/references/queries.md +51 -10
  6. package/dist/global-skills/eas-observe/references/setup.md +60 -7
  7. package/dist/global-skills/eas-simulator/SKILL.md +2 -2
  8. package/dist/global-skills/eas-simulator/references/run-your-app.md +2 -0
  9. package/dist/global-skills/eas-update/SKILL.md +2 -2
  10. package/dist/global-skills/eas-update-insights/SKILL.md +2 -2
  11. package/dist/global-skills/eas-workflows/SKILL.md +2 -2
  12. package/dist/global-skills/expo-animation/SKILL.md +2 -2
  13. package/dist/global-skills/expo-app-clip/SKILL.md +2 -2
  14. package/dist/global-skills/expo-brownfield/SKILL.md +2 -2
  15. package/dist/global-skills/expo-data-fetching/SKILL.md +2 -2
  16. package/dist/global-skills/expo-design-system/SKILL.md +2 -2
  17. package/dist/global-skills/expo-dev-client/SKILL.md +4 -2
  18. package/dist/global-skills/expo-dom/SKILL.md +2 -2
  19. package/dist/global-skills/expo-examples/SKILL.md +2 -2
  20. package/dist/global-skills/expo-migrate-module/SKILL.md +2 -2
  21. package/dist/global-skills/expo-module/SKILL.md +2 -2
  22. package/dist/global-skills/expo-native-ui/SKILL.md +2 -2
  23. package/dist/global-skills/expo-overview/SKILL.md +9 -4
  24. package/dist/global-skills/expo-overview/references/launch-without-dev-menu.md +24 -0
  25. package/dist/global-skills/expo-project-structure/SKILL.md +2 -2
  26. package/dist/global-skills/expo-router/SKILL.md +2 -2
  27. package/dist/global-skills/expo-ui/SKILL.md +2 -2
  28. package/dist/global-skills/expo-upgrade/SKILL.md +2 -2
  29. package/dist/global-skills/expo-web-to-native/SKILL.md +2 -2
  30. package/dist/global-skills/expo-web-to-native/references/verify-on-device.md +1 -1
  31. package/dist/global-skills/firebase-app-hosting-basics/SKILL.md +16 -3
  32. package/dist/global-skills/firebase-app-hosting-basics/references/cli_commands.md +10 -12
  33. package/dist/global-skills/firebase-app-hosting-basics/references/configuration.md +2 -1
  34. package/dist/global-skills/firebase-basics/SKILL.md +6 -4
  35. package/dist/global-skills/firebase-basics/references/web_setup.md +3 -3
  36. package/dist/global-skills/instrument-feature-flags/references/adding-feature-flag-code.md +81 -333
  37. package/dist/global-skills/instrument-feature-flags/references/android.md +19 -13
  38. package/dist/global-skills/instrument-feature-flags/references/api.md +17 -13
  39. package/dist/global-skills/instrument-feature-flags/references/best-practices.md +35 -35
  40. package/dist/global-skills/instrument-feature-flags/references/django.md +120 -72
  41. package/dist/global-skills/instrument-feature-flags/references/dotnet.md +48 -102
  42. package/dist/global-skills/instrument-feature-flags/references/elixir.md +4 -10
  43. package/dist/global-skills/instrument-feature-flags/references/flask.md +55 -39
  44. package/dist/global-skills/instrument-feature-flags/references/flutter.md +19 -13
  45. package/dist/global-skills/instrument-feature-flags/references/go.md +21 -13
  46. package/dist/global-skills/instrument-feature-flags/references/ios.md +19 -13
  47. package/dist/global-skills/instrument-feature-flags/references/java.md +4 -12
  48. package/dist/global-skills/instrument-feature-flags/references/laravel.md +18 -16
  49. package/dist/global-skills/instrument-feature-flags/references/next-js.md +44 -54
  50. package/dist/global-skills/instrument-feature-flags/references/nodejs.md +21 -13
  51. package/dist/global-skills/instrument-feature-flags/references/php.md +21 -13
  52. package/dist/global-skills/instrument-feature-flags/references/python.md +22 -14
  53. package/dist/global-skills/instrument-feature-flags/references/react-native.md +18 -13
  54. package/dist/global-skills/instrument-feature-flags/references/react.md +21 -14
  55. package/dist/global-skills/instrument-feature-flags/references/ruby-on-rails.md +31 -68
  56. package/dist/global-skills/instrument-feature-flags/references/ruby.md +21 -13
  57. package/dist/global-skills/instrument-feature-flags/references/rust.md +10 -34
  58. package/dist/global-skills/instrument-feature-flags/references/usage.md +94 -114
  59. package/dist/global-skills/instrument-feature-flags/references/web.md +21 -13
  60. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-android.md +7 -7
  61. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-expo.md +2 -2
  62. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-fastapi.md +1 -1
  63. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-flask.md +1 -1
  64. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-laravel.md +2 -2
  65. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-php.md +1 -1
  66. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-python.md +1 -1
  67. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-ruby.md +1 -1
  68. package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-swift.md +4 -4
  69. package/dist/global-skills/instrument-product-analytics/references/android.md +64 -109
  70. package/dist/global-skills/instrument-product-analytics/references/angular.md +32 -28
  71. package/dist/global-skills/instrument-product-analytics/references/astro.md +29 -34
  72. package/dist/global-skills/instrument-product-analytics/references/configuration.md +27 -42
  73. package/dist/global-skills/instrument-product-analytics/references/django.md +120 -72
  74. package/dist/global-skills/instrument-product-analytics/references/dotnet.md +48 -102
  75. package/dist/global-skills/instrument-product-analytics/references/elixir.md +25 -50
  76. package/dist/global-skills/instrument-product-analytics/references/flask.md +55 -39
  77. package/dist/global-skills/instrument-product-analytics/references/flutter.md +94 -96
  78. package/dist/global-skills/instrument-product-analytics/references/go.md +39 -77
  79. package/dist/global-skills/instrument-product-analytics/references/identify-users.md +24 -26
  80. package/dist/global-skills/instrument-product-analytics/references/ios.md +22 -22
  81. package/dist/global-skills/instrument-product-analytics/references/laravel.md +18 -16
  82. package/dist/global-skills/instrument-product-analytics/references/next-js.md +44 -54
  83. package/dist/global-skills/instrument-product-analytics/references/nuxt-js-3-6.md +32 -34
  84. package/dist/global-skills/instrument-product-analytics/references/nuxt-js.md +36 -36
  85. package/dist/global-skills/instrument-product-analytics/references/php.md +42 -87
  86. package/dist/global-skills/instrument-product-analytics/references/posthog-python.md +15 -12
  87. package/dist/global-skills/instrument-product-analytics/references/python.md +106 -154
  88. package/dist/global-skills/instrument-product-analytics/references/react-native.md +97 -176
  89. package/dist/global-skills/instrument-product-analytics/references/react-router-v6.md +29 -40
  90. package/dist/global-skills/instrument-product-analytics/references/react-router-v7-data-mode.md +29 -38
  91. package/dist/global-skills/instrument-product-analytics/references/react-router-v7-declarative-mode.md +29 -40
  92. package/dist/global-skills/instrument-product-analytics/references/react-router-v7-framework-mode.md +32 -37
  93. package/dist/global-skills/instrument-product-analytics/references/ruby-on-rails.md +31 -68
  94. package/dist/global-skills/instrument-product-analytics/references/ruby.md +40 -96
  95. package/dist/global-skills/instrument-product-analytics/references/svelte.md +34 -34
  96. package/dist/global-skills/instrument-product-analytics/references/tanstack-start.md +19 -19
  97. package/dist/global-skills/instrument-product-analytics/references/usage.md +94 -114
  98. package/dist/global-skills/instrument-product-analytics/references/vue-js.md +33 -45
  99. package/dist/global-skills/manifest.json +2 -1
  100. package/dist/global-skills/mongodb-search-and-ai/SKILL.md +40 -22
  101. package/dist/global-skills/mongodb-search-and-ai/references/automated-embedding.md +8 -2
  102. package/dist/global-skills/mongodb-search-and-ai/references/quick-start.md +725 -0
  103. package/dist/global-skills/mongodb-search-and-ai/scripts/quickstart_complete.py +386 -0
  104. package/dist/global-skills/neon/SKILL.md +15 -10
  105. package/dist/global-skills/neon/references/claimable-neon.md +2 -0
  106. package/dist/global-skills/neon-functions/SKILL.md +12 -11
  107. package/dist/global-skills/neon-functions/references/sse.md +2 -2
  108. package/dist/global-skills/neon-object-storage/SKILL.md +5 -4
  109. package/dist/global-skills/neon-postgres/SKILL.md +4 -1
  110. package/dist/global-skills/neon-realtime/SKILL.md +207 -0
  111. package/dist/global-skills/neon-realtime/references/mutations.md +743 -0
  112. package/dist/global-skills/neon-realtime/references/queries.md +509 -0
  113. package/dist/global-skills/neon-realtime/references/reactivity.md +407 -0
  114. package/dist/global-skills/neon-realtime/references/ssr.md +695 -0
  115. package/dist/global-skills/neon-realtime/references/subscribing.md +485 -0
  116. package/dist/global-skills/resend/SKILL.md +4 -2
  117. package/dist/global-skills/resend/references/inboxes.md +377 -0
  118. package/dist/global-skills/resend/references/webhooks.md +9 -0
  119. package/dist/global-skills/stripe-best-practices/SKILL.md +1 -1
  120. package/dist/global-skills/stripe-best-practices/references/connect.md +1 -1
  121. package/dist/global-skills/stripe-best-practices/references/security.md +9 -9
  122. package/dist/global-skills/vybekiitReferences/backend/AGENTS.md +1 -1
  123. package/dist/global-skills/vybekiitReferences/backend/agent/goal-routes.json +303 -18
  124. package/dist/global-skills/vybekiitReferences/extension/AGENTS.md +1 -1
  125. package/dist/global-skills/vybekiitReferences/extension/agent/goal-routes.json +352 -18
  126. package/dist/global-skills/vybekiitReferences/mobile/AGENTS.md +1 -1
  127. package/dist/global-skills/vybekiitReferences/mobile/agent/goal-routes.json +413 -22
  128. package/dist/global-skills/vybekiitReferences/spa/AGENTS.md +1 -1
  129. package/dist/global-skills/vybekiitReferences/spa/agent/goal-routes.json +391 -21
  130. package/dist/global-skills/vybekiitReferences/web/AGENTS.md +14 -2
  131. package/dist/global-skills/vybekiitReferences/web/agent/goal-routes.json +490 -32
  132. package/package.json +8 -8
@@ -2,7 +2,26 @@
2
2
 
3
3
  # React Router V7 framework mode (Remix V3)
4
4
 
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).
5
+ Canonical URL: https://posthog.com/docs/libraries/react-router/react-router-v7-framework-mode
6
+
7
+ > **Cloud region:** This page uses US Cloud hosts. For an EU Cloud project, use `https://eu.i.posthog.com` instead of `https://us.i.posthog.com` (ingestion host), and use `https://eu.posthog.com` instead of `https://us.posthog.com` or `https://app.posthog.com` (app host for links).
8
+
9
+ ## On this page
10
+
11
+ - [Install client-side SDKs](#install-client-side-sdks)
12
+ - [Add your environment variables](#add-your-environment-variables)
13
+ - [Add the PostHogProvider to your app](#add-the-posthogprovider-to-your-app)
14
+ - [Verify client-side events are captured](#verify-client-side-events-are-captured)
15
+ - [Access PostHog methods](#access-posthog-methods)
16
+ - [Identify your user](#identify-your-user)
17
+ - [Create an error boundary](#create-an-error-boundary)
18
+ - [Tracking element visibility](#tracking-element-visibility)
19
+ - [Install server-side SDKs](#install-server-side-sdks)
20
+ - [Create a server-side middleware](#create-a-server-side-middleware)
21
+ - [Verify server-side events are captured](#verify-server-side-events-are-captured)
22
+ - [Next steps](#next-steps)
23
+
24
+ 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](https://posthog.com/docs/libraries/react-router.md). If you're using React with another framework, go to the [React integration guide](https://posthog.com/docs/libraries/react.md).
6
25
 
7
26
  1. 1
8
27
 
@@ -44,7 +63,7 @@ This guide walks you through setting up PostHog for React Router V7 in framework
44
63
  > worker-src 'self' blob: data:;
45
64
  > ```
46
65
  >
47
- > `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.
66
+ > `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](https://posthog.com/docs/advanced/content-security-policy.md), or use a [reverse proxy](https://posthog.com/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.
48
67
 
49
68
  In framework mode, you'll also need to set `posthog-js` and `@posthog/react` as external packages in your `vite.config.ts` file to avoid SSR errors.
50
69
 
@@ -116,14 +135,12 @@ This guide walks you through setting up PostHog for React Router V7 in framework
116
135
 
117
136
  To help PostHog track your user sessions across the client and server, you'll need to add the `tracing_headers: ['your-backend-hostname1.com', 'your-backend-hostname2.com', ...]` option to your PostHog initialization. This adds the `X-POSTHOG-DISTINCT-ID` and `X-POSTHOG-SESSION-ID` headers to requests sent to the configured hostnames, which we'll later use on the server-side.
118
137
 
119
- TypeError: Cannot read properties of undefined
138
+ **TypeError: Cannot read properties of undefined**
120
139
 
121
140
  If you see the error `TypeError: Cannot read properties of undefined (reading '...')` this is likely because you tried to call a posthog function when posthog was not initialized (such as during the initial render). On purpose, we still render the children even if PostHog is not initialized so that your app still loads even if PostHog can't load.
122
141
 
123
142
  To fix this error, add a check that posthog has been initialized such as:
124
143
 
125
- React
126
-
127
144
  ```jsx
128
145
  useEffect(() => {
129
146
  posthog?.capture('test') // using optional chaining (recommended)
@@ -142,12 +159,10 @@ This guide walks you through setting up PostHog for React Router V7 in framework
142
159
 
143
160
  *Confirm that you can capture client-side events and see them in your PostHog project*
144
161
 
145
- At this point, you should be able to capture client-side events and see them in your PostHog project. This includes basic events like page views and button clicks that are [autocaptured](/docs/product-analytics/autocapture.md).
162
+ At this point, you should be able to capture client-side events and see them in your PostHog project. This includes basic events like page views and button clicks that are [autocaptured](https://posthog.com/docs/product-analytics/autocapture.md).
146
163
 
147
164
  You can also try to capture a custom event to verify it's working. You can access PostHog in any component using the `usePostHog` hook.
148
165
 
149
- TSX
150
-
151
166
  ```jsx
152
167
  import { usePostHog } from '@posthog/react'
153
168
 
@@ -167,8 +182,6 @@ This guide walks you through setting up PostHog for React Router V7 in framework
167
182
 
168
183
  On the client-side, you can access the PostHog client using the `usePostHog` hook. This hook returns the initialized PostHog client, which you can use to call PostHog methods. For example:
169
184
 
170
- TSX
171
-
172
185
  ```jsx
173
186
  import { usePostHog } from '@posthog/react'
174
187
 
@@ -178,7 +191,7 @@ This guide walks you through setting up PostHog for React Router V7 in framework
178
191
  }
179
192
  ```
180
193
 
181
- For a complete list of available methods, see the [posthog-js documentation](/docs/libraries/js.md).
194
+ For a complete list of available methods, see the [posthog-js documentation](https://posthog.com/docs/libraries/js.md).
182
195
 
183
196
  6. 5
184
197
 
@@ -190,8 +203,6 @@ This guide walks you through setting up PostHog for React Router V7 in framework
190
203
 
191
204
  Generally, you identify users when they log in or when they input some identifiable information (e.g. email, name, etc.). You can identify users by calling the `identify` method on the PostHog client:
192
205
 
193
- TSX
194
-
195
206
  ```jsx
196
207
  export default function Login() {
197
208
  const { user, login } = useAuth();
@@ -262,8 +273,6 @@ This guide walks you through setting up PostHog for React Router V7 in framework
262
273
 
263
274
  **Basic usage:**
264
275
 
265
- React
266
-
267
276
  ```jsx
268
277
  import { PostHogCaptureOnViewed } from '@posthog/react'
269
278
 
@@ -280,8 +289,6 @@ This guide walks you through setting up PostHog for React Router V7 in framework
280
289
 
281
290
  You can include additional properties with the event to provide more context:
282
291
 
283
- React
284
-
285
292
  ```jsx
286
293
  <PostHogCaptureOnViewed
287
294
  name="product-card"
@@ -299,8 +306,6 @@ This guide walks you through setting up PostHog for React Router V7 in framework
299
306
 
300
307
  Use `trackAllChildren` to track each child element separately. This is useful for galleries or lists where you want to know which specific items were viewed:
301
308
 
302
- React
303
-
304
309
  ```jsx
305
310
  <PostHogCaptureOnViewed
306
311
  name="product-gallery"
@@ -319,8 +324,6 @@ This guide walks you through setting up PostHog for React Router V7 in framework
319
324
 
320
325
  You can customize when elements are considered "viewed" by passing options to the `IntersectionObserver`:
321
326
 
322
- React
323
-
324
327
  ```jsx
325
328
  <PostHogCaptureOnViewed
326
329
  name="footer"
@@ -341,7 +344,7 @@ This guide walks you through setting up PostHog for React Router V7 in framework
341
344
 
342
345
  Recommended
343
346
 
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.
347
+ Install the [PostHog Node SDK](https://posthog.com/docs/libraries/node.md) using your package manager. This is the SDK you'll use to capture server-side events.
345
348
 
346
349
  ### npm
347
350
 
@@ -376,7 +379,7 @@ This guide walks you through setting up PostHog for React Router V7 in framework
376
379
  Next, create a server-side middleware to help you capture server-side events. This middleware helps you achieve the following:
377
380
 
378
381
  - Initialize a PostHog client
379
- - Fetch the session and distinct ID from the `X-POSTHOG-SESSION-ID` and `X-POSTHOG-DISTINCT-ID` headers and pass them to your request as a [context](/docs/libraries/node.md#contexts). This automatically identifies the user and session for you in all subsequent event captures.
382
+ - Fetch the session and distinct ID from the `X-POSTHOG-SESSION-ID` and `X-POSTHOG-DISTINCT-ID` headers and pass them to your request as a [context](https://posthog.com/docs/libraries/node.md#contexts). This automatically identifies the user and session for you in all subsequent event captures.
380
383
  - Calls `shutdown()` on the PostHog client to ensure all events are sent before the request is completed.
381
384
 
382
385
  app/lib/posthog-middleware.ts
@@ -466,17 +469,9 @@ This guide walks you through setting up PostHog for React Router V7 in framework
466
469
 
467
470
  To get the most out of PostHog, you should familiarize yourself with the following:
468
471
 
469
- - [PostHog Web SDK docs](/docs/libraries/js.md): Learn more about the PostHog Web SDK and how to use it on the client-side.
470
- - [PostHog Node SDK docs](/docs/libraries/node.md): Learn more about the PostHog Node SDK and how to use it on the server-side.
471
- - [Identify users](/docs/product-analytics/identify.md): Learn more about how to identify users in your app.
472
- - [Group analytics](/docs/product-analytics/group-analytics.md): Learn more about how to use group analytics in your app.
473
- - [PostHog AI](/docs/posthog-ai.md): After capturing events, use PostHog AI to help you understand your data and build insights.
474
- - [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.
475
-
476
- ### Still have questions?
477
-
478
- Ask PostHog AI
479
-
480
- ### Was this page useful?
481
-
482
- HelpfulCould be better
472
+ - [PostHog Web SDK docs](https://posthog.com/docs/libraries/js.md): Learn more about the PostHog Web SDK and how to use it on the client-side.
473
+ - [PostHog Node SDK docs](https://posthog.com/docs/libraries/node.md): Learn more about the PostHog Node SDK and how to use it on the server-side.
474
+ - [Identify users](https://posthog.com/docs/product-analytics/identify.md): Learn more about how to identify users in your app.
475
+ - [Group analytics](https://posthog.com/docs/product-analytics/group-analytics.md): Learn more about how to use group analytics in your app.
476
+ - [PostHog AI](https://posthog.com/docs/posthog-ai.md): After capturing events, use PostHog AI to help you understand your data and build insights.
477
+ - [Feature flags and experiments](https://posthog.com/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.
@@ -2,18 +2,37 @@
2
2
 
3
3
  # Ruby on Rails
4
4
 
5
+ Canonical URL: https://posthog.com/docs/libraries/ruby-on-rails
6
+
7
+ > **Cloud region:** This page uses US Cloud hosts. For an EU Cloud project, use `https://eu.i.posthog.com` instead of `https://us.i.posthog.com` (ingestion host), and use `https://eu.posthog.com` instead of `https://us.posthog.com` (app host for links).
8
+
9
+ ## On this page
10
+
11
+ - [Beta: integration via LLM](#beta-integration-via-llm)
12
+ - [Features](#features)
13
+ - [Installation](#installation)
14
+ - [Identifying users](#identifying-users)
15
+ - [Configuration](#configuration)
16
+ - [Capturing events](#capturing-events)
17
+ - [Request context](#request-context)
18
+ - [Logs](#logs)
19
+ - [Error tracking](#error-tracking)
20
+ - [Feature flags](#feature-flags)
21
+ - [Testing](#testing)
22
+ - [Configuration reference](#configuration-reference)
23
+ - [Troubleshooting](#troubleshooting)
24
+ - [Next steps](#next-steps)
25
+
5
26
  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.
6
27
 
7
28
  This guide walks you through integrating PostHog into your Rails app using the [posthog-rails gem](https://github.com/PostHog/posthog-ruby/tree/main/posthog-rails).
8
29
 
9
30
  ## Beta: integration via LLM
10
31
 
11
- Install PostHog for Rails in seconds with our wizard by running this prompt with [LLM coding agents](/blog/envoy-wizard-llm-agent.md) like Cursor and Bolt, or by running it in your terminal.
32
+ Install PostHog for Rails in seconds with our wizard by running this prompt with [LLM coding agents](https://posthog.com/blog/envoy-wizard-llm-agent.md) like Cursor and Bolt, or by running it in your terminal.
12
33
 
13
34
  `npx @posthog/wizard`
14
35
 
15
- [Learn more](/wizard.md)
16
-
17
36
  Or, to integrate manually, continue with the rest of this guide.
18
37
 
19
38
  ## Features
@@ -24,7 +43,7 @@ Or, to integrate manually, continue with the rest of this guide.
24
43
  - **Smart filtering** – Excludes common Rails exceptions (404s, etc.) by default
25
44
  - **Request context** – Adds request metadata and optional PostHog tracing header identity/session context to captured events
26
45
  - **Rails 7.0+ error reporter** – Integrates with Rails' built-in error reporting
27
- - **Log forwarding** – Optionally forwards `Rails.logger` output to [PostHog Logs](/docs/logs.md) over OpenTelemetry, automatically correlated with request context (Ruby 3.3+)
46
+ - **Log forwarding** – Optionally forwards `Rails.logger` output to [PostHog Logs](https://posthog.com/docs/logs.md) over OpenTelemetry, automatically correlated with request context (Ruby 3.3+)
28
47
 
29
48
  ## Installation
30
49
 
@@ -39,24 +58,20 @@ gem 'posthog-rails'
39
58
 
40
59
  Then run:
41
60
 
42
- Terminal
43
-
44
61
  ```bash
45
62
  bundle install
46
63
  ```
47
64
 
48
65
  ## Identifying users
49
66
 
50
- > **Identifying users is required.** Backend events need a `distinct_id` that matches the ID your frontend uses when calling `posthog.identify()`. Without this, backend events are orphaned — they can't be linked to frontend event captures, [session replays](/docs/session-replay.md), [LLM traces](/docs/ai-engineering.md), or [error tracking](/docs/error-tracking.md).
67
+ > **Identifying users is required.** Backend events need a `distinct_id` that matches the ID your frontend uses when calling `posthog.identify()`. Without this, backend events are orphaned — they can't be linked to frontend event captures, [session replays](https://posthog.com/docs/session-replay.md), [LLM traces](https://posthog.com/docs/ai-engineering.md), or [error tracking](https://posthog.com/docs/error-tracking.md).
51
68
  >
52
- > See our guide on [identifying users](/docs/getting-started/identify-users.md) for how to set this up.
69
+ > See our guide on [identifying users](https://posthog.com/docs/getting-started/identify-users.md) for how to set this up.
53
70
 
54
71
  ### Generate the initializer
55
72
 
56
73
  Run the install generator to create the PostHog initializer:
57
74
 
58
- Terminal
59
-
60
75
  ```bash
61
76
  rails generate posthog:install
62
77
  ```
@@ -130,8 +145,6 @@ You can find your project token and instance address in [your project settings](
130
145
 
131
146
  > **Tip:** Use [`Rails.application.credentials`](https://guides.rubyonrails.org/security.html#custom-credentials) to avoid hardcoding API keys. First, add your keys and then reference them in your initializer:
132
147
  >
133
- > Terminal
134
- >
135
148
  > ```bash
136
149
  > rails credentials:edit
137
150
  > ```
@@ -157,8 +170,6 @@ You can find your project token and instance address in [your project settings](
157
170
 
158
171
  Track custom events anywhere in your Rails app:
159
172
 
160
- Ruby
161
-
162
173
  ```ruby
163
174
  PostHog.capture({
164
175
  distinct_id: current_user.id,
@@ -169,8 +180,6 @@ PostHog.capture({
169
180
 
170
181
  Identify a user and set their person properties:
171
182
 
172
- Ruby
173
-
174
183
  ```ruby
175
184
  PostHog.identify({
176
185
  distinct_id: current_user.id,
@@ -189,32 +198,28 @@ PostHog Rails automatically applies request-scoped context to events captured du
189
198
 
190
199
  When `use_tracing_headers` is enabled, PostHog tracing headers (`X-PostHog-Distinct-Id` and `X-PostHog-Session-Id`) are also used as default `distinct_id` and `$session_id` values. Explicit `distinct_id` and properties passed to `PostHog.capture` always take precedence.
191
200
 
192
- If you're using [PostHog JS](/docs/libraries/js.md) on the frontend, configure [`tracing_headers`](/docs/libraries/js/config.md#tracing-headers) for your Rails backend hostname so browser requests include the session and distinct ID headers.
201
+ If you're using [PostHog JS](https://posthog.com/docs/libraries/js.md) on the frontend, configure [`tracing_headers`](https://posthog.com/docs/libraries/js/config.md#tracing-headers) for your Rails backend hostname so browser requests include the session and distinct ID headers.
193
202
 
194
203
  Tracing headers are client-controlled analytics context, not authentication or authorization. Pass an authenticated `distinct_id` explicitly for security-sensitive server-side decisions.
195
204
 
196
205
  Disable tracing header identity/session capture if you do not want client-supplied tracing headers used for server-side events. Request metadata is still captured:
197
206
 
198
- Ruby
199
-
200
207
  ```ruby
201
208
  PostHog::Rails.config.use_tracing_headers = false
202
209
  ```
203
210
 
204
211
  ## Logs
205
212
 
206
- To set up [PostHog Logs](/docs/logs.md) in your Rails app, follow the [Ruby on Rails logs installation guide](/docs/logs/installation/ruby-on-rails.md). The integration forwards `Rails.logger` output to PostHog Logs over OpenTelemetry, automatically correlated with each request's distinct ID and session ID. Requires Ruby 3.3+.
213
+ To set up [PostHog Logs](https://posthog.com/docs/logs.md) in your Rails app, follow the [Ruby on Rails logs installation guide](https://posthog.com/docs/logs/installation/ruby-on-rails.md). The integration forwards `Rails.logger` output to PostHog Logs over OpenTelemetry, automatically correlated with each request's distinct ID and session ID. Requires Ruby 3.3+.
207
214
 
208
215
  ## Error tracking
209
216
 
210
- For full details on setting up error tracking with Rails, see our [Rails error tracking installation guide](/docs/error-tracking/installation/ruby-on-rails.md).
217
+ For full details on setting up error tracking with Rails, see our [Rails error tracking installation guide](https://posthog.com/docs/error-tracking/installation/ruby-on-rails.md).
211
218
 
212
219
  ### Automatic exception tracking
213
220
 
214
221
  When `auto_capture_exceptions` is enabled, exceptions are automatically captured:
215
222
 
216
- Ruby
217
-
218
223
  ```ruby
219
224
  class PostsController < ApplicationController
220
225
  def show
@@ -230,8 +235,6 @@ end
230
235
 
231
236
  You can also manually capture exceptions:
232
237
 
233
- Ruby
234
-
235
238
  ```ruby
236
239
  PostHog.capture_exception(
237
240
  exception,
@@ -242,8 +245,6 @@ PostHog.capture_exception(
242
245
 
243
246
  If you evaluated feature flags for the request, pass the same snapshot to include matching flag properties on the exception event:
244
247
 
245
- Ruby
246
-
247
248
  ```ruby
248
249
  flags = PostHog.evaluate_flags(current_user.id)
249
250
 
@@ -259,8 +260,6 @@ PostHog.capture_exception(
259
260
 
260
261
  When `auto_instrument_active_job` is enabled, ActiveJob exceptions are automatically captured with job context:
261
262
 
262
- Ruby
263
-
264
263
  ```ruby
265
264
  class EmailJob < ApplicationJob
266
265
  def perform(user_id)
@@ -275,8 +274,6 @@ end
275
274
 
276
275
  By default, PostHog extracts a `distinct_id` from job arguments by looking for a `user_id` key in hash arguments:
277
276
 
278
- Ruby
279
-
280
277
  ```ruby
281
278
  # PostHog will automatically use options[:user_id] as the distinct_id
282
279
  ProcessOrderJob.perform_later(order.id, user_id: current_user.id)
@@ -284,8 +281,6 @@ ProcessOrderJob.perform_later(order.id, user_id: current_user.id)
284
281
 
285
282
  For more control, use the `posthog_distinct_id` class method. The proc or block receives the same arguments as `perform`:
286
283
 
287
- Ruby
288
-
289
284
  ```ruby
290
285
  class SendWelcomeEmailJob < ApplicationJob
291
286
  posthog_distinct_id ->(user, _options) { user.id }
@@ -298,8 +293,6 @@ end
298
293
 
299
294
  You can also use a block:
300
295
 
301
- Ruby
302
-
303
296
  ```ruby
304
297
  class ProcessOrderJob < ApplicationJob
305
298
  posthog_distinct_id do |_order, notify_user_id|
@@ -316,8 +309,6 @@ end
316
309
 
317
310
  PostHog integrates with Rails' built-in error reporting:
318
311
 
319
- Ruby
320
-
321
312
  ```ruby
322
313
  # These errors are automatically sent to PostHog
323
314
  Rails.error.handle do
@@ -335,8 +326,6 @@ PostHog Rails automatically captures authenticated user information from your co
335
326
 
336
327
  If your user method has a different name, configure it:
337
328
 
338
- Ruby
339
-
340
329
  ```ruby
341
330
  PostHog::Rails.config.current_user_method = :logged_in_user
342
331
  ```
@@ -355,16 +344,12 @@ It also checks hash-like users for `id`, `pk`, and `uuid` keys.
355
344
 
356
345
  You can configure a specific method:
357
346
 
358
- Ruby
359
-
360
347
  ```ruby
361
348
  PostHog::Rails.config.user_id_method = :email
362
349
  ```
363
350
 
364
351
  Or define a method on your User model:
365
352
 
366
- Ruby
367
-
368
353
  ```ruby
369
354
  class User < ApplicationRecord
370
355
  def posthog_distinct_id
@@ -393,8 +378,6 @@ The following exceptions are not reported by default (common 4xx errors):
393
378
 
394
379
  Add more with:
395
380
 
396
- Ruby
397
-
398
381
  ```ruby
399
382
  PostHog::Rails.config.excluded_exceptions = ['MyException']
400
383
  ```
@@ -403,8 +386,6 @@ PostHog::Rails.config.excluded_exceptions = ['MyException']
403
386
 
404
387
  Evaluate flags once for the current user, then read values from the returned snapshot:
405
388
 
406
- Ruby
407
-
408
389
  ```ruby
409
390
  class PostsController < ApplicationController
410
391
  def show
@@ -421,8 +402,6 @@ end
421
402
 
422
403
  For multivariate flags and experiments, use `get_flag`:
423
404
 
424
- Ruby
425
-
426
405
  ```ruby
427
406
  flags = PostHog.evaluate_flags(current_user.id)
428
407
  variant = flags.get_flag('checkout-experiment')
@@ -434,8 +413,6 @@ end
434
413
 
435
414
  When capturing an event after branching on a flag, pass the same `flags` snapshot so the event includes the exact flag values used by your code:
436
415
 
437
- Ruby
438
-
439
416
  ```ruby
440
417
  flags = PostHog.evaluate_flags(current_user.id)
441
418
 
@@ -448,13 +425,11 @@ PostHog.capture({
448
425
 
449
426
  For local evaluation, ensure you've set `personal_api_key`:
450
427
 
451
- Ruby
452
-
453
428
  ```ruby
454
429
  config.personal_api_key = Rails.application.credentials.posthog[:personal_api_key]
455
430
  ```
456
431
 
457
- See our [Ruby SDK docs](/docs/libraries/ruby.md#local-evaluation) for details on local evaluation with Puma and Unicorn servers.
432
+ See our [Ruby SDK docs](https://posthog.com/docs/libraries/ruby.md#local-evaluation) for details on local evaluation with Puma and Unicorn servers.
458
433
 
459
434
  > **Note:** `PostHog.is_feature_enabled`, `PostHog.get_feature_flag`, `PostHog.get_feature_flag_result`, `PostHog.get_feature_flag_payload`, and `PostHog.capture({ ..., send_feature_flags: true })` still work during the migration period, but they're deprecated. Prefer `PostHog.evaluate_flags` for new code.
460
435
 
@@ -500,7 +475,7 @@ end
500
475
  | `feature_flag_request_timeout_seconds` | Integer | `3` | Timeout, in seconds, for feature flag requests. |
501
476
  | `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. |
502
477
 
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.
478
+ 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](https://posthog.com/docs/libraries/ruby.md#configuration) for details.
504
479
 
505
480
  ### Rails-specific options
506
481
 
@@ -523,8 +498,6 @@ Configure these via `PostHog::Rails.configure` or `PostHog::Rails.config`:
523
498
 
524
499
  1. Verify PostHog is initialized:
525
500
 
526
- Ruby
527
-
528
501
  ```ruby
529
502
  Rails.console
530
503
  > PostHog.initialized?
@@ -535,8 +508,6 @@ Configure these via `PostHog::Rails.configure` or `PostHog::Rails.config`:
535
508
 
536
509
  3. Verify middleware is installed:
537
510
 
538
- Ruby
539
-
540
511
  ```ruby
541
512
  Rails.application.middleware
542
513
  ```
@@ -553,12 +524,4 @@ Ensure you've set `personal_api_key` in your configuration.
553
524
 
554
525
  ## Next steps
555
526
 
556
- For any technical questions for how to integrate specific PostHog features into Rails (such as analytics, feature flags, A/B testing, etc.), have a look at our [Ruby SDK docs](/docs/libraries/ruby.md).
557
-
558
- ### Still have questions?
559
-
560
- Ask PostHog AI
561
-
562
- ### Was this page useful?
563
-
564
- HelpfulCould be better
527
+ For any technical questions for how to integrate specific PostHog features into Rails (such as analytics, feature flags, A/B testing, etc.), have a look at our [Ruby SDK docs](https://posthog.com/docs/libraries/ruby.md).