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,18 +2,32 @@
2
2
 
3
3
  # Go
4
4
 
5
+ Canonical URL: https://posthog.com/docs/libraries/go
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).
8
+
9
+ ## On this page
10
+
11
+ - [Installation](#installation)
12
+ - [Identifying users](#identifying-users)
13
+ - [Capturing events](#capturing-events)
14
+ - [Person profiles and properties](#person-profiles-and-properties)
15
+ - [Alias](#alias)
16
+ - [Request context](#request-context)
17
+ - [Feature flags](#feature-flags)
18
+ - [Experiments (A/B tests)](#experiments-ab-tests)
19
+ - [Error tracking](#error-tracking)
20
+ - [Group analytics](#group-analytics)
21
+ - [Thank you](#thank-you)
22
+
5
23
  This library uses an internal queue to make calls fast and non-blocking. It also batches requests and flushes asynchronously, making it perfect to use in any part of your web app or other server-side application that needs performance.
6
24
 
7
25
  ## Installation
8
26
 
9
- Terminal
10
-
11
27
  ```bash
12
28
  go get github.com/posthog/posthog-go
13
29
  ```
14
30
 
15
- Go
16
-
17
31
  ```go
18
32
  package main
19
33
 
@@ -37,16 +51,14 @@ func main() {
37
51
 
38
52
  ## Identifying users
39
53
 
40
- > **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).
54
+ > **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).
41
55
  >
42
- > See our guide on [identifying users](/docs/getting-started/identify-users.md) for how to set this up.
56
+ > See our guide on [identifying users](https://posthog.com/docs/getting-started/identify-users.md) for how to set this up.
43
57
 
44
58
  ## Capturing events
45
59
 
46
60
  You can send custom events using `capture`:
47
61
 
48
- Go
49
-
50
62
  ```go
51
63
  client.Enqueue(posthog.Capture{
52
64
  DistinctId: "distinct_id_of_the_user",
@@ -56,13 +68,11 @@ client.Enqueue(posthog.Capture{
56
68
 
57
69
  > **Tip:** We recommend using a `[object] [verb]` format for your event names, where `[object]` is the entity that the behavior relates to, and `[verb]` is the behavior itself. For example, `project created`, `user signed up`, or `invite sent`.
58
70
 
59
- > **Tip:** You can define event schemas with typed properties and generate type-safe code using [schema management](/docs/product-analytics/schema-management.md).
71
+ > **Tip:** You can define event schemas with typed properties and generate type-safe code using [schema management](https://posthog.com/docs/product-analytics/schema-management.md).
60
72
 
61
73
  ### Setting event properties
62
74
 
63
- Optionally, you can include additional information with the event by including a [properties](/docs/data/events.md#event-properties) object:
64
-
65
- Go
75
+ Optionally, you can include additional information with the event by including a [properties](https://posthog.com/docs/data/events.md#event-properties) object:
66
76
 
67
77
  ```go
68
78
  client.Enqueue(posthog.Capture{
@@ -78,8 +88,6 @@ client.Enqueue(posthog.Capture{
78
88
 
79
89
  If you're aiming for a backend-only implementation of PostHog and won't be capturing events from your frontend, you can send `pageviews` from your backend like so:
80
90
 
81
- Go
82
-
83
91
  ```go
84
92
  client.Enqueue(posthog.Capture{
85
93
  DistinctId: "distinct_id_of_the_user",
@@ -91,9 +99,7 @@ client.Enqueue(posthog.Capture{
91
99
 
92
100
  ## Person profiles and properties
93
101
 
94
- For backward compatibility, the Go SDK captures identified events by default. These create [person profiles](/docs/data/persons.md). To set [person properties](/docs/product-analytics/person-properties.md) in these profiles, include them when capturing an event:
95
-
96
- Go
102
+ For backward compatibility, the Go SDK captures identified events by default. These create [person profiles](https://posthog.com/docs/data/persons.md). To set [person properties](https://posthog.com/docs/product-analytics/person-properties.md) in these profiles, include them when capturing an event:
97
103
 
98
104
  ```go
99
105
  client.Enqueue(posthog.Capture{
@@ -110,11 +116,9 @@ client.Enqueue(posthog.Capture{
110
116
  })
111
117
  ```
112
118
 
113
- For more details on the difference between `$set` and `$set_once`, see our [person properties docs](/docs/product-analytics/person-properties.md#what-is-the-difference-between-set-and-set_once).
119
+ For more details on the difference between `$set` and `$set_once`, see our [person properties docs](https://posthog.com/docs/product-analytics/person-properties.md#what-is-the-difference-between-set-and-set_once).
114
120
 
115
- To capture [anonymous events](/docs/data/anonymous-vs-identified-events.md) without person profiles, set the event's `$process_person_profile` property to `false`:
116
-
117
- Go
121
+ To capture [anonymous events](https://posthog.com/docs/data/anonymous-vs-identified-events.md) without person profiles, set the event's `$process_person_profile` property to `false`:
118
122
 
119
123
  ```go
120
124
  client.Enqueue(posthog.Capture{
@@ -132,8 +136,6 @@ Sometimes, you want to assign multiple distinct IDs to a single user. This is he
132
136
 
133
137
  In this case, you can use `alias` to assign another distinct ID to the same user.
134
138
 
135
- Go
136
-
137
139
  ```go
138
140
  client.Enqueue(posthog.Alias{
139
141
  DistinctId: "distinct_id",
@@ -141,15 +143,13 @@ client.Enqueue(posthog.Alias{
141
143
  })
142
144
  ```
143
145
 
144
- We strongly recommend reading our docs on [alias](/docs/product-analytics/identify.md#alias-assigning-multiple-distinct-ids-to-the-same-user) to best understand how to correctly use this method.
146
+ We strongly recommend reading our docs on [alias](https://posthog.com/docs/product-analytics/identify.md#alias-assigning-multiple-distinct-ids-to-the-same-user) to best understand how to correctly use this method.
145
147
 
146
148
  ## Request context
147
149
 
148
150
  Use request context to apply a distinct ID, session ID, and common request properties to capture and exception events inside a `net/http` request. This is useful when connecting frontend activity to backend events, session replay, error tracking, and feature flag evaluation.
149
151
 
150
- 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 Go backend hostname so browser requests include the session and distinct ID headers. Then wrap your handler with `NewRequestContextMiddleware` and use the context-aware helpers:
151
-
152
- Go
152
+ 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 Go backend hostname so browser requests include the session and distinct ID headers. Then wrap your handler with `NewRequestContextMiddleware` and use the context-aware helpers:
153
153
 
154
154
  ```go
155
155
  handler := posthog.NewRequestContextMiddleware(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
@@ -168,12 +168,10 @@ handler := posthog.NewRequestContextMiddleware(http.HandlerFunc(func(w http.Resp
168
168
 
169
169
  The middleware adds `$current_url`, `$request_method`, `$request_path`, `$user_agent`, and `$ip` properties. By default, it also reads `X-PostHog-Distinct-Id` and `X-PostHog-Session-Id` as request-scoped defaults. Explicit `DistinctId` values and `$session_id` properties passed to captures take precedence over request context.
170
170
 
171
- If request context is attached but no distinct ID is available, capture and exception events are sent as [personless events](/docs/data/anonymous-vs-identified-events.md) with an auto-generated UUID and `$process_person_profile: false`. Calls to `Enqueue` without request context still require `DistinctId`. `EvaluateFlagsWithContext` uses the request-scoped distinct ID when `EvaluateFlagsPayload.DistinctId` is empty, but it never generates personless IDs and returns `ErrNoDistinctID` when no distinct ID is available.
171
+ If request context is attached but no distinct ID is available, capture and exception events are sent as [personless events](https://posthog.com/docs/data/anonymous-vs-identified-events.md) with an auto-generated UUID and `$process_person_profile: false`. Calls to `Enqueue` without request context still require `DistinctId`. `EvaluateFlagsWithContext` uses the request-scoped distinct ID when `EvaluateFlagsPayload.DistinctId` is empty, but it never generates personless IDs and returns `ErrNoDistinctID` when no distinct ID is available.
172
172
 
173
173
  Tracing headers are client-controlled analytics context, not authentication or authorization. For security-sensitive server-side decisions, pass an authenticated `DistinctId` explicitly or attach one to the request context:
174
174
 
175
- Go
176
-
177
175
  ```go
178
176
  ctx := posthog.WithRequestContext(r.Context(), posthog.RequestContext{
179
177
  DistinctId: user.ID,
@@ -182,8 +180,6 @@ ctx := posthog.WithRequestContext(r.Context(), posthog.RequestContext{
182
180
 
183
181
  To ignore tracing headers while keeping request metadata, disable tracing header capture:
184
182
 
185
- Go
186
-
187
183
  ```go
188
184
  handler := posthog.NewRequestContextMiddleware(
189
185
  next,
@@ -193,7 +189,7 @@ handler := posthog.NewRequestContextMiddleware(
193
189
 
194
190
  ## Feature flags
195
191
 
196
- PostHog's [feature flags](/docs/feature-flags.md) enable you to safely deploy and roll back new features as well as target specific users and groups with them.
192
+ PostHog's [feature flags](https://posthog.com/docs/feature-flags.md) enable you to safely deploy and roll back new features as well as target specific users and groups with them.
197
193
 
198
194
  There are two steps to implement feature flags in Go:
199
195
 
@@ -203,8 +199,6 @@ Call `client.EvaluateFlags()` once for the user, then read values from the retur
203
199
 
204
200
  #### Boolean feature flags
205
201
 
206
- Go
207
-
208
202
  ```go
209
203
  flags, err := client.EvaluateFlags(posthog.EvaluateFlagsPayload{
210
204
  DistinctId: "distinct_id_of_your_user",
@@ -222,8 +216,6 @@ if flags.IsEnabled("flag-key") {
222
216
 
223
217
  #### Multivariate feature flags
224
218
 
225
- Go
226
-
227
219
  ```go
228
220
  flags, err := client.EvaluateFlags(posthog.EvaluateFlagsPayload{
229
221
  DistinctId: "distinct_id_of_your_user",
@@ -247,9 +239,9 @@ if enabledVariant == "variant-key" { // replace "variant-key" with the key of yo
247
239
 
248
240
  ### Step 2: Include feature flag information when capturing events
249
241
 
250
- If you want use your feature flag to breakdown or filter events in your [insights](/docs/product-analytics/insights.md), you'll need to include feature flag information in those events. This ensures that the feature flag value is attributed correctly to the event.
242
+ If you want use your feature flag to breakdown or filter events in your [insights](https://posthog.com/docs/product-analytics/insights.md), you'll need to include feature flag information in those events. This ensures that the feature flag value is attributed correctly to the event.
251
243
 
252
- > **Note:** This step is only required for events captured using our server-side SDKs or [API](/docs/api.md).
244
+ > **Note:** This step is only required for events captured using our server-side SDKs or [API](https://posthog.com/docs/api.md).
253
245
 
254
246
  There are two methods you can use to include feature flag information in your events:
255
247
 
@@ -257,8 +249,6 @@ There are two methods you can use to include feature flag information in your ev
257
249
 
258
250
  Pass the same `flags` object that you used for branching. This attaches the exact flag values from that evaluation and doesn't make another `/flags` request.
259
251
 
260
- Go
261
-
262
252
  ```go
263
253
  flags, err := client.EvaluateFlags(posthog.EvaluateFlagsPayload{
264
254
  DistinctId: "distinct_id_of_your_user",
@@ -282,8 +272,6 @@ By default, this attaches every flag in the snapshot using `$feature/<flag-key>`
282
272
 
283
273
  To reduce event property bloat, pass a filtered snapshot:
284
274
 
285
- Go
286
-
287
275
  ```go
288
276
  // Attach only flags accessed with IsEnabled() or GetFlag() before this call
289
277
  client.Enqueue(posthog.Capture{
@@ -306,8 +294,6 @@ client.Enqueue(posthog.Capture{
306
294
 
307
295
  In the event properties, include `$feature/feature_flag_name: variant_key`:
308
296
 
309
- Go
310
-
311
297
  ```go
312
298
  client.Enqueue(posthog.Capture{
313
299
  DistinctId: "distinct_id_of_your_user",
@@ -321,8 +307,6 @@ client.Enqueue(posthog.Capture{
321
307
 
322
308
  By default, `EvaluateFlags()` evaluates every flag for the user. If you only need a few flags, pass `FlagKeys` to request only those flags:
323
309
 
324
- Go
325
-
326
310
  ```go
327
311
  flags, err := client.EvaluateFlags(posthog.EvaluateFlagsPayload{
328
312
  DistinctId: "distinct_id_of_your_user",
@@ -332,7 +316,7 @@ flags, err := client.EvaluateFlags(posthog.EvaluateFlagsPayload{
332
316
 
333
317
  ### Sending `$feature_flag_called` events
334
318
 
335
- Capturing `$feature_flag_called` events enables PostHog to know when a flag was accessed by a user and provide [analytics and insights](/docs/product-analytics/insights.md) on the flag. With `EvaluateFlags()`, the SDK sends this event when you call `flags.IsEnabled()` or `flags.GetFlag()` for a flag.
319
+ Capturing `$feature_flag_called` events enables PostHog to know when a flag was accessed by a user and provide [analytics and insights](https://posthog.com/docs/product-analytics/insights.md) on the flag. With `EvaluateFlags()`, the SDK sends this event when you call `flags.IsEnabled()` or `flags.GetFlag()` for a flag.
336
320
 
337
321
  The SDK deduplicates these events per `(distinct_id, flag, value)` in a local cache. If you reinitialize the PostHog client, the cache resets and `$feature_flag_called` events may be sent again. PostHog handles duplicates, so duplicate `$feature_flag_called` events don't affect your analytics.
338
322
 
@@ -340,14 +324,12 @@ The SDK deduplicates these events per `(distinct_id, flag, value)` in a local ca
340
324
 
341
325
  ### Advanced: Overriding server properties
342
326
 
343
- Sometimes, you may want to evaluate feature flags using [person properties](/docs/product-analytics/person-properties.md), [groups](/docs/product-analytics/group-analytics.md), or group properties that haven't been ingested yet, or were set incorrectly earlier.
327
+ Sometimes, you may want to evaluate feature flags using [person properties](https://posthog.com/docs/product-analytics/person-properties.md), [groups](https://posthog.com/docs/product-analytics/group-analytics.md), or group properties that haven't been ingested yet, or were set incorrectly earlier.
344
328
 
345
329
  You can provide properties to evaluate the flag with by using the `person properties`, `groups`, and `group properties` arguments. PostHog will then use these values to evaluate the flag, instead of any properties currently stored on your PostHog server.
346
330
 
347
331
  For example:
348
332
 
349
- Go
350
-
351
333
  ```go
352
334
  flags, err := client.EvaluateFlags(posthog.EvaluateFlagsPayload{
353
335
  DistinctId: "distinct_id_of_the_user",
@@ -403,8 +385,6 @@ Simply include any of these properties in the `person_properties` parameter alon
403
385
 
404
386
  You can configure the `FeatureFlagRequestTimeout` parameter when initializing your PostHog client to set a flag request timeout. This helps prevent your code from being blocked if PostHog's servers are too slow to respond. By default, this is set to 3 seconds.
405
387
 
406
- Go
407
-
408
388
  ```go
409
389
  // import "time"
410
390
 
@@ -424,13 +404,11 @@ Evaluating feature flags requires making a request to PostHog for each flag. How
424
404
 
425
405
  It is best practice to use local evaluation flags when possible, since this enables you to resolve flags faster and with fewer API calls.
426
406
 
427
- For details on how to implement local evaluation, see our [local evaluation guide](/docs/feature-flags/local-evaluation.md).
407
+ For details on how to implement local evaluation, see our [local evaluation guide](https://posthog.com/docs/feature-flags/local-evaluation.md).
428
408
 
429
409
  ## Experiments (A/B tests)
430
410
 
431
- Since [experiments](/docs/experiments/start-here.md) use feature flags, the code for running an experiment is very similar to the feature flags code:
432
-
433
- Go
411
+ Since [experiments](https://posthog.com/docs/experiments/start-here.md) use feature flags, the code for running an experiment is very similar to the feature flags code:
434
412
 
435
413
  ```go
436
414
  flags, err := client.EvaluateFlags(posthog.EvaluateFlagsPayload{
@@ -446,7 +424,7 @@ if variant == "variant-name" {
446
424
  }
447
425
  ```
448
426
 
449
- It's also possible to [run experiments without using feature flags](/docs/experiments/running-experiments-without-feature-flags.md).
427
+ It's also possible to [run experiments without using feature flags](https://posthog.com/docs/experiments/running-experiments-without-feature-flags.md).
450
428
 
451
429
  ## Error tracking
452
430
 
@@ -454,8 +432,6 @@ You can capture exceptions and errors using the Go SDK. There are two approaches
454
432
 
455
433
  **Direct capture** using `NewDefaultException`, which automatically generates a stack trace:
456
434
 
457
- Go
458
-
459
435
  ```go
460
436
  exception := posthog.NewDefaultException(
461
437
  time.Now(),
@@ -468,8 +444,6 @@ client.Enqueue(exception)
468
444
 
469
445
  **Automatic capture** using the `SlogCaptureHandler`, which wraps Go's `log/slog` and sends log records at warning level and above as exceptions:
470
446
 
471
- Go
472
-
473
447
  ```go
474
448
  baseHandler := slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{
475
449
  Level: slog.LevelInfo,
@@ -484,18 +458,16 @@ logger := slog.New(posthog.NewSlogCaptureHandler(baseHandler, client,
484
458
  logger.Warn("Something broke", "error", fmt.Errorf("connection refused"))
485
459
  ```
486
460
 
487
- For the full setup guide, see the [Go error tracking installation docs](/docs/error-tracking/installation/go.md).
461
+ For the full setup guide, see the [Go error tracking installation docs](https://posthog.com/docs/error-tracking/installation/go.md).
488
462
 
489
463
  ## Group analytics
490
464
 
491
- Group analytics allows you to associate an event with a group (e.g. teams, organizations, etc.). Read the [Group Analytics](/docs/user-guides/group-analytics.md) guide for more information.
465
+ Group analytics allows you to associate an event with a group (e.g. teams, organizations, etc.). Read the [Group Analytics](https://posthog.com/docs/user-guides/group-analytics.md) guide for more information.
492
466
 
493
- > **Note:** This is a paid feature and is not available on the open-source or free cloud plan. Learn more on the [pricing page](/pricing.md).
467
+ > **Note:** This is a paid feature and is not available on the open-source or free cloud plan. Learn more on the [pricing page](https://posthog.com/pricing.md).
494
468
 
495
469
  - Send an event associated with a group
496
470
 
497
- Go
498
-
499
471
  ```go
500
472
  client.Enqueue(posthog.Capture{
501
473
  DistinctId: "user_distinct_id",
@@ -507,8 +479,6 @@ client.Enqueue(posthog.Capture{
507
479
 
508
480
  - Update properties on a group
509
481
 
510
- Go
511
-
512
482
  ```go
513
483
  client.Enqueue(posthog.GroupIdentify{
514
484
  Type: "company",
@@ -524,11 +494,3 @@ The `name` is a special property which is used in the PostHog UI for the name of
524
494
  ## Thank you
525
495
 
526
496
  This library is largely based on the `analytics-go` package.
527
-
528
- ### Still have questions?
529
-
530
- Ask PostHog AI
531
-
532
- ### Was this page useful?
533
-
534
- HelpfulCould be better
@@ -2,11 +2,21 @@
2
2
 
3
3
  # Identify users
4
4
 
5
+ Canonical URL: https://posthog.com/docs/getting-started/identify-users
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).
8
+
9
+ ## On this page
10
+
11
+ - [How identify works](#how-identify-works)
12
+ - [Best practices when using identify](#best-practices-when-using-identify)
13
+ - [Further reading](#further-reading)
14
+
5
15
  Linking events to specific users enables you to build a full picture of how they're using your product across different sessions, devices, and platforms.
6
16
 
7
- This is straightforward to do when [capturing backend events](/docs/product-analytics/capture-events?tab=Node.js.md), as you associate events to a specific user using a `distinct_id`, which is a required argument.
17
+ This is straightforward to do when [capturing backend events](https://posthog.com/docs/product-analytics/capture-events?tab=Node.js.md), as you associate events to a specific user using a `distinct_id`, which is a required argument.
8
18
 
9
- However, in the frontend of a [web](/docs/libraries/js/usage.md#capturing-events) or [mobile app](/docs/libraries/ios.md#capturing-events), a `distinct_id` is not a required argument — PostHog's SDKs will generate an anonymous `distinct_id` for you automatically and you can capture events anonymously, provided you use the appropriate [configuration](/docs/libraries/js/usage.md#capturing-anonymous-events).
19
+ However, in the frontend of a [web](https://posthog.com/docs/libraries/js/usage.md#capturing-events) or [mobile app](https://posthog.com/docs/libraries/ios.md#capturing-events), a `distinct_id` is not a required argument — PostHog's SDKs will generate an anonymous `distinct_id` for you automatically and you can capture events anonymously, provided you use the appropriate [configuration](https://posthog.com/docs/libraries/js/usage.md#capturing-anonymous-events).
10
20
 
11
21
  To link events to specific users, call `identify`:
12
22
 
@@ -68,7 +78,7 @@ Due to the cost of processing them, anonymous events can be up to 4x cheaper tha
68
78
 
69
79
  When a user starts browsing your website or app, PostHog automatically assigns them an **anonymous ID**, which is stored locally.
70
80
 
71
- Provided you've [configured persistence](/docs/libraries/js/persistence.md) to use cookies or `localStorage`, this enables us to track anonymous users – even across different sessions.
81
+ Provided you've [configured persistence](https://posthog.com/docs/libraries/js/persistence.md) to use cookies or `localStorage`, this enables us to track anonymous users – even across different sessions.
72
82
 
73
83
  By calling `identify` with a `distinct_id` of your choice (usually the user's ID in your database, or their email), you link the anonymous ID and distinct ID together.
74
84
 
@@ -76,7 +86,7 @@ Thus, all past and future events made with that anonymous ID are now associated
76
86
 
77
87
  This enables you to do things like associate events with a user from before they log in for the first time, or associate their events across different devices or platforms.
78
88
 
79
- Using identify in the backend
89
+ **Using identify in the backend**
80
90
 
81
91
  Although you can call `identify` using our backend SDKs, it is used most in frontends. This is because there is no concept of anonymous sessions in the backend SDKs, so calling `identify` only updates person profiles.
82
92
 
@@ -96,9 +106,7 @@ If you call `identify` multiple times with the same data without reloading the p
96
106
 
97
107
  #### Identify users when the web SDK loads
98
108
 
99
- If your app already knows the signed-in user when you initialize the JavaScript web SDK, the [`loaded` callback](/docs/libraries/js/config.md) is a convenient place to call `identify`. This identifies the user as soon as the SDK has loaded:
100
-
101
- Web
109
+ If your app already knows the signed-in user when you initialize the JavaScript web SDK, the [`loaded` callback](https://posthog.com/docs/libraries/js/config.md) is a convenient place to call `identify`. This identifies the user as soon as the SDK has loaded:
102
110
 
103
111
  ```javascript
104
112
  posthog.init('<ph_project_token>', {
@@ -168,8 +176,6 @@ await Posthog().reset();
168
176
 
169
177
  If you *also* want to reset the `device_id` so that the device will be considered a new device in future events, you can pass `true` as an argument:
170
178
 
171
- Web
172
-
173
179
  ```javascript
174
180
  posthog.reset(true)
175
181
  ```
@@ -178,17 +184,17 @@ posthog.reset(true)
178
184
 
179
185
  You'll notice that one of the parameters in the `identify` method is a `properties` object.
180
186
 
181
- This enables you to set [person properties](/docs/product-analytics/person-properties.md).
187
+ This enables you to set [person properties](https://posthog.com/docs/product-analytics/person-properties.md).
182
188
 
183
189
  Whenever possible, we recommend passing in all person properties you have available each time you call identify, as this ensures their person profile on PostHog is up to date.
184
190
 
185
191
  Person properties can also be set being adding a `$set` property to a event `capture` call.
186
192
 
187
- **\`$set\` and \`$set\_once\` aren't stored on events**
193
+ **`$set` and `$set_once` aren't stored on events**
188
194
 
189
- These properties only tell PostHog how to update person data during ingestion — they aren't kept on the stored event, so you can't filter, break down, or query events by them. To query the values you set, use [person properties](/docs/product-analytics/person-properties.md) instead.
195
+ These properties only tell PostHog how to update person data during ingestion — they aren't kept on the stored event, so you can't filter, break down, or query events by them. To query the values you set, use [person properties](https://posthog.com/docs/product-analytics/person-properties.md) instead.
190
196
 
191
- See our [person properties docs](/docs/product-analytics/person-properties.md) for more details on how to work with them and best practices.
197
+ See our [person properties docs](https://posthog.com/docs/product-analytics/person-properties.md) for more details on how to work with them and best practices.
192
198
 
193
199
  ### 5\. Use deep links between platforms
194
200
 
@@ -206,8 +212,8 @@ In these cases, you can use a [deep link](https://developer.android.com/training
206
212
  2. Add the distinct ID to the deep link as query parameters, along with other properties like UTM parameters.
207
213
  3. When the user is redirected to the app, parse the deep link and handle the following cases:
208
214
 
209
- - The mobile app is already authenticated. In this case, call [`posthog.alias()`](/docs/libraries/js/usage.md#alias) with the distinct ID from the web. This associates the two distinct IDs as a single person.
210
- - The mobile app is unauthenticated. In this case, call [`posthog.identify()`](/docs/libraries/js/usage.md#identifying-users) with the distinct ID from the web so pre-login mobile events stay connected to the web session. When the user later logs in on mobile, call `identify()` again with your canonical user ID.
215
+ - The mobile app is already authenticated. In this case, call [`posthog.alias()`](https://posthog.com/docs/libraries/js/usage.md#alias) with the distinct ID from the web. This associates the two distinct IDs as a single person.
216
+ - The mobile app is unauthenticated. In this case, call [`posthog.identify()`](https://posthog.com/docs/libraries/js/usage.md#identifying-users) with the distinct ID from the web so pre-login mobile events stay connected to the web session. When the user later logs in on mobile, call `identify()` again with your canonical user ID.
211
217
 
212
218
  As long as you associate the distinct IDs with `posthog.identify()` or `posthog.alias()`, you can track events generated across platforms.
213
219
 
@@ -294,14 +300,6 @@ object DeepLinkIdentityManager {
294
300
 
295
301
  ## Further reading
296
302
 
297
- - [Identifying users docs](/docs/product-analytics/identify.md)
298
- - [How person processing works](/docs/how-posthog-works/ingestion-pipeline.md#2-person-processing)
299
- - [An introductory guide to identifying users in PostHog](/tutorials/identifying-users-guide.md)
300
-
301
- ### Still have questions?
302
-
303
- Ask PostHog AI
304
-
305
- ### Was this page useful?
306
-
307
- HelpfulCould be better
303
+ - [Identifying users docs](https://posthog.com/docs/product-analytics/identify.md)
304
+ - [How person processing works](https://posthog.com/docs/how-posthog-works/ingestion-pipeline.md#2-person-processing)
305
+ - [An introductory guide to identifying users in PostHog](https://posthog.com/tutorials/identifying-users-guide.md)
@@ -2,9 +2,21 @@
2
2
 
3
3
  # iOS
4
4
 
5
+ Canonical URL: https://posthog.com/docs/libraries/ios
6
+
7
+ ## On this page
8
+
9
+ - [Installation](#installation)
10
+ - [Identifying users](#identifying-users)
11
+ - [Offline behavior](#offline-behavior)
12
+ - [Using PostHog with application extensions](#using-posthog-with-application-extensions)
13
+ - [Method swizzling](#method-swizzling)
14
+ - [Push notifications](#push-notifications)
15
+ - [Next steps](#next-steps)
16
+
5
17
  The PostHog iOS SDK is a library that you can use to track events, identify users, record session replays, evaluate feature flags, run experiments, build surveys, and more.
6
18
 
7
- This page shows you how to install the SDK and get started with it. If you've already installed the SDK, you can skip ahead to learn about [using the features](/docs/libraries/ios/usage.md) and [configuring the SDK](/docs/libraries/ios/configuration.md).
19
+ This page shows you how to install the SDK and get started with it. If you've already installed the SDK, you can skip ahead to learn about [using the features](https://posthog.com/docs/libraries/ios/usage.md) and [configuring the SDK](https://posthog.com/docs/libraries/ios/configuration.md).
8
20
 
9
21
  ## Installation
10
22
 
@@ -46,12 +58,10 @@ Package.swift
46
58
 
47
59
  Configuration is done through the `PostHogConfig` object. Here's a basic configuration example to get you started.
48
60
 
49
- You can find more advanced configuration options in the [configuration page](/docs/libraries/ios/configuration.md).
61
+ You can find more advanced configuration options in the [configuration page](https://posthog.com/docs/libraries/ios/configuration.md).
50
62
 
51
63
  ## UIKit
52
64
 
53
- Swift
54
-
55
65
  ```swift
56
66
  import Foundation
57
67
  import PostHog
@@ -73,8 +83,6 @@ class AppDelegate: NSObject, UIApplicationDelegate {
73
83
 
74
84
  ## SwiftUI
75
85
 
76
- Swift
77
-
78
86
  ```swift
79
87
  import SwiftUI
80
88
  import PostHog
@@ -106,13 +114,13 @@ struct YourGreatApp: App {
106
114
 
107
115
  ## Identifying users
108
116
 
109
- > **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.
117
+ > **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](https://posthog.com/docs/session-replay.md), [LLM traces](https://posthog.com/docs/ai-engineering.md), and [error tracking](https://posthog.com/docs/error-tracking.md) to the same person — and lets backend events link back too.
110
118
  >
111
119
  > 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.
112
120
  >
113
121
  > Call `posthog.reset()` on logout, so the next person to use the browser doesn't inherit the last one's identity.
114
122
  >
115
- > See our guide on [identifying users](/docs/getting-started/identify-users.md) for how to set this up.
123
+ > See our guide on [identifying users](https://posthog.com/docs/getting-started/identify-users.md) for how to set this up.
116
124
 
117
125
  ## Offline behavior
118
126
 
@@ -122,7 +130,7 @@ The PostHog iOS SDK will continue to capture events when the device is offline.
122
130
  - When the queue is full, the oldest event is deleted first.
123
131
  - The queue is flushed only when the device is online.
124
132
 
125
- You can find the options for configuring the offline behavior in the [configuration page](/docs/libraries/ios/configuration.md#all-configuration-options).
133
+ You can find the options for configuring the offline behavior in the [configuration page](https://posthog.com/docs/libraries/ios/configuration.md#all-configuration-options).
126
134
 
127
135
  ## Using PostHog with application extensions
128
136
 
@@ -134,7 +142,7 @@ By default, each iOS app target stores its data in its own sandboxed directory.
134
142
  - Fragmented user journeys
135
143
  - Difficulty tracking feature adoption across your app ecosystem
136
144
 
137
- [Learn more about setting up app groups](/docs/libraries/ios/configuration.md#setting-up-app-groups).
145
+ [Learn more about setting up app groups](https://posthog.com/docs/libraries/ios/configuration.md#setting-up-app-groups).
138
146
 
139
147
  ## Method swizzling
140
148
 
@@ -142,23 +150,15 @@ The PostHog iOS SDK uses method swizzling to intercept and modify method calls a
142
150
 
143
151
  Method swizzling is particularly important for accurate session metrics tracking. When disabled, the SDK cannot capture optimal session metrics.
144
152
 
145
- You can learn more about configuring method swizzling in the [configuration page](/docs/libraries/ios/configuration.md#method-swizzling).
153
+ You can learn more about configuring method swizzling in the [configuration page](https://posthog.com/docs/libraries/ios/configuration.md#method-swizzling).
146
154
 
147
155
  ## Push notifications
148
156
 
149
- The iOS 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, and identity verification, see [Push notifications](/docs/workflows/push-notifications.md).
157
+ The iOS SDK can register a device for [Workflows](https://posthog.com/docs/workflows.md) push notifications and capture when a user opens one. For setup, including automatic and manual registration, capturing opens, and identity verification, see [Push notifications](https://posthog.com/docs/workflows/push-notifications.md).
150
158
 
151
159
  ## Next steps
152
160
 
153
161
  Now that you've installed the SDK, explore the configuration and usage options:
154
162
 
155
- - [Learn about using all of the features of PostHog with iOS SDK](/docs/libraries/ios/usage.md)
156
- - [Learn about configuration options for the iOS SDK](/docs/libraries/ios/configuration.md)
157
-
158
- ### Still have questions?
159
-
160
- Ask PostHog AI
161
-
162
- ### Was this page useful?
163
-
164
- HelpfulCould be better
163
+ - [Learn about using all of the features of PostHog with iOS SDK](https://posthog.com/docs/libraries/ios/usage.md)
164
+ - [Learn about configuration options for the iOS SDK](https://posthog.com/docs/libraries/ios/configuration.md)
@@ -2,11 +2,23 @@
2
2
 
3
3
  # Laravel
4
4
 
5
- PostHog integrates with Laravel through the [PostHog PHP SDK](/docs/libraries/php.md). This page covers Laravel-specific setup. For SDK features such as event capture, identifying users, feature flags, group analytics, and configuration options, see the [PHP SDK docs](/docs/libraries/php.md).
5
+ Canonical URL: https://posthog.com/docs/libraries/laravel
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).
8
+
9
+ ## On this page
10
+
11
+ - [Installation](#installation)
12
+ - [Request context middleware](#request-context-middleware)
13
+ - [Error tracking in Laravel](#error-tracking-in-laravel)
14
+ - [Long-running processes](#long-running-processes)
15
+ - [Next steps](#next-steps)
16
+
17
+ PostHog integrates with Laravel through the [PostHog PHP SDK](https://posthog.com/docs/libraries/php.md). This page covers Laravel-specific setup. For SDK features such as event capture, identifying users, feature flags, group analytics, and configuration options, see the [PHP SDK docs](https://posthog.com/docs/libraries/php.md).
6
18
 
7
19
  ## Installation
8
20
 
9
- Install the PHP SDK as described in the [PHP installation guide](/docs/libraries/php.md#installation), then add your project token and host to `.env`:
21
+ Install the PHP SDK as described in the [PHP installation guide](https://posthog.com/docs/libraries/php.md#installation), then add your project token and host to `.env`:
10
22
 
11
23
  .env
12
24
 
@@ -58,9 +70,9 @@ class AppServiceProvider extends ServiceProvider
58
70
 
59
71
  ## Request context middleware
60
72
 
61
- Client SDKs such as [PostHog JS](/docs/libraries/js.md) can send tracing headers to your Laravel backend. Configure [`tracing_headers`](/docs/libraries/js/config.md#tracing-headers) for your Laravel backend hostname so browser requests include the session and distinct ID headers.
73
+ Client SDKs such as [PostHog JS](https://posthog.com/docs/libraries/js.md) can send tracing headers to your Laravel backend. Configure [`tracing_headers`](https://posthog.com/docs/libraries/js/config.md#tracing-headers) for your Laravel backend hostname so browser requests include the session and distinct ID headers.
62
74
 
63
- The PHP SDK can read `X-PostHog-Distinct-Id` and `X-PostHog-Session-Id` headers and apply them to events captured during the request. Tracing headers are client-controlled analytics context, not authentication or authorization. For security-sensitive server-side events or decisions, pass an authenticated `distinctId` explicitly, such as `auth()->id()`. For the lower-level context APIs, see the [PHP request context docs](/docs/libraries/php.md#request-context).
75
+ The PHP SDK can read `X-PostHog-Distinct-Id` and `X-PostHog-Session-Id` headers and apply them to events captured during the request. Tracing headers are client-controlled analytics context, not authentication or authorization. For security-sensitive server-side events or decisions, pass an authenticated `distinctId` explicitly, such as `auth()->id()`. For the lower-level context APIs, see the [PHP request context docs](https://posthog.com/docs/libraries/php.md#request-context).
64
76
 
65
77
  Add middleware like this:
66
78
 
@@ -110,7 +122,7 @@ Register this middleware using your Laravel version's normal middleware registra
110
122
 
111
123
  ## Error tracking in Laravel
112
124
 
113
- The PHP SDK supports [error tracking](/docs/libraries/php.md#error-tracking), but Laravel handles most request exceptions before they become uncaught PHP exceptions. Capture Laravel-reported exceptions explicitly.
125
+ The PHP SDK supports [error tracking](https://posthog.com/docs/libraries/php.md#error-tracking), but Laravel handles most request exceptions before they become uncaught PHP exceptions. Capture Laravel-reported exceptions explicitly.
114
126
 
115
127
  In Laravel 11 and later, add a report callback in `bootstrap/app.php`:
116
128
 
@@ -147,8 +159,6 @@ In normal PHP request lifecycles, queued events flush when the client is destroy
147
159
 
148
160
  If you prefer immediate delivery in queue workers, configure the PHP SDK with `batch_size` set to `1` for those workers:
149
161
 
150
- PHP
151
-
152
162
  ```php
153
163
  PostHog::init(
154
164
  '<ph_project_token>',
@@ -161,12 +171,4 @@ PostHog::init(
161
171
 
162
172
  ## Next steps
163
173
 
164
- See the [PHP SDK docs](/docs/libraries/php.md) for usage examples and the full API reference.
165
-
166
- ### Still have questions?
167
-
168
- Ask PostHog AI
169
-
170
- ### Was this page useful?
171
-
172
- HelpfulCould be better
174
+ See the [PHP SDK docs](https://posthog.com/docs/libraries/php.md) for usage examples and the full API reference.