vybekiit 0.7.26 → 0.7.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +3891 -1301
- 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/better-auth-best-practices/SKILL.md +18 -8
- 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/grow-my-customers/SKILL.md +23 -0
- 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 +8 -6
- 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/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/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 +16 -12
- package/dist/global-skills/watch-my-app/SKILL.md +53 -0
- 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
|
@@ -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
|
-
# Go
|
|
4
|
-
|
|
5
|
-
Copy page
|
|
6
|
-
|
|
7
|
-
# Go - Docs
|
|
3
|
+
# Go
|
|
8
4
|
|
|
9
5
|
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.
|
|
10
6
|
|
|
@@ -12,22 +8,20 @@ This library uses an internal queue to make calls fast and non-blocking. It also
|
|
|
12
8
|
|
|
13
9
|
Terminal
|
|
14
10
|
|
|
15
|
-
PostHog AI
|
|
16
|
-
|
|
17
11
|
```bash
|
|
18
12
|
go get github.com/posthog/posthog-go
|
|
19
13
|
```
|
|
20
14
|
|
|
21
15
|
Go
|
|
22
16
|
|
|
23
|
-
PostHog AI
|
|
24
|
-
|
|
25
17
|
```go
|
|
26
18
|
package main
|
|
19
|
+
|
|
27
20
|
import (
|
|
28
21
|
"os"
|
|
29
22
|
"github.com/posthog/posthog-go"
|
|
30
23
|
)
|
|
24
|
+
|
|
31
25
|
func main() {
|
|
32
26
|
client, _ := posthog.NewWithConfig(
|
|
33
27
|
os.Getenv("POSTHOG_API_KEY"),
|
|
@@ -53,8 +47,6 @@ You can send custom events using `capture`:
|
|
|
53
47
|
|
|
54
48
|
Go
|
|
55
49
|
|
|
56
|
-
PostHog AI
|
|
57
|
-
|
|
58
50
|
```go
|
|
59
51
|
client.Enqueue(posthog.Capture{
|
|
60
52
|
DistinctId: "distinct_id_of_the_user",
|
|
@@ -72,8 +64,6 @@ Optionally, you can include additional information with the event by including a
|
|
|
72
64
|
|
|
73
65
|
Go
|
|
74
66
|
|
|
75
|
-
PostHog AI
|
|
76
|
-
|
|
77
67
|
```go
|
|
78
68
|
client.Enqueue(posthog.Capture{
|
|
79
69
|
DistinctId: "distinct_id_of_the_user",
|
|
@@ -90,8 +80,6 @@ If you're aiming for a backend-only implementation of PostHog and won't be captu
|
|
|
90
80
|
|
|
91
81
|
Go
|
|
92
82
|
|
|
93
|
-
PostHog AI
|
|
94
|
-
|
|
95
83
|
```go
|
|
96
84
|
client.Enqueue(posthog.Capture{
|
|
97
85
|
DistinctId: "distinct_id_of_the_user",
|
|
@@ -103,12 +91,10 @@ client.Enqueue(posthog.Capture{
|
|
|
103
91
|
|
|
104
92
|
## Person profiles and properties
|
|
105
93
|
|
|
106
|
-
For backward compatibility, the Go SDK captures identified events by default. These create [person profiles](/docs/data/persons.md). To set [person properties](/docs/
|
|
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:
|
|
107
95
|
|
|
108
96
|
Go
|
|
109
97
|
|
|
110
|
-
PostHog AI
|
|
111
|
-
|
|
112
98
|
```go
|
|
113
99
|
client.Enqueue(posthog.Capture{
|
|
114
100
|
DistinctId: "distinct_id",
|
|
@@ -124,14 +110,12 @@ client.Enqueue(posthog.Capture{
|
|
|
124
110
|
})
|
|
125
111
|
```
|
|
126
112
|
|
|
127
|
-
For more details on the difference between `$set` and `$set_once`, see our [person properties docs](/docs/
|
|
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).
|
|
128
114
|
|
|
129
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`:
|
|
130
116
|
|
|
131
117
|
Go
|
|
132
118
|
|
|
133
|
-
PostHog AI
|
|
134
|
-
|
|
135
119
|
```go
|
|
136
120
|
client.Enqueue(posthog.Capture{
|
|
137
121
|
DistinctId: "distinct_id",
|
|
@@ -150,8 +134,6 @@ In this case, you can use `alias` to assign another distinct ID to the same user
|
|
|
150
134
|
|
|
151
135
|
Go
|
|
152
136
|
|
|
153
|
-
PostHog AI
|
|
154
|
-
|
|
155
137
|
```go
|
|
156
138
|
client.Enqueue(posthog.Alias{
|
|
157
139
|
DistinctId: "distinct_id",
|
|
@@ -159,7 +141,7 @@ client.Enqueue(posthog.Alias{
|
|
|
159
141
|
})
|
|
160
142
|
```
|
|
161
143
|
|
|
162
|
-
We strongly recommend reading our docs on [alias](/docs/
|
|
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.
|
|
163
145
|
|
|
164
146
|
## Request context
|
|
165
147
|
|
|
@@ -169,8 +151,6 @@ If you're using [PostHog JS](/docs/libraries/js.md) on the frontend, configure [
|
|
|
169
151
|
|
|
170
152
|
Go
|
|
171
153
|
|
|
172
|
-
PostHog AI
|
|
173
|
-
|
|
174
154
|
```go
|
|
175
155
|
handler := posthog.NewRequestContextMiddleware(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
176
156
|
flags, err := posthog.EvaluateFlagsWithContext(r.Context(), client, posthog.EvaluateFlagsPayload{})
|
|
@@ -178,6 +158,7 @@ handler := posthog.NewRequestContextMiddleware(http.HandlerFunc(func(w http.Resp
|
|
|
178
158
|
// If neither the request context nor payload has a distinct ID,
|
|
179
159
|
// err is posthog.ErrNoDistinctID.
|
|
180
160
|
}
|
|
161
|
+
|
|
181
162
|
_ = posthog.EnqueueWithContext(r.Context(), client, posthog.Capture{
|
|
182
163
|
Event: "checkout started",
|
|
183
164
|
Flags: flags,
|
|
@@ -193,8 +174,6 @@ Tracing headers are client-controlled analytics context, not authentication or a
|
|
|
193
174
|
|
|
194
175
|
Go
|
|
195
176
|
|
|
196
|
-
PostHog AI
|
|
197
|
-
|
|
198
177
|
```go
|
|
199
178
|
ctx := posthog.WithRequestContext(r.Context(), posthog.RequestContext{
|
|
200
179
|
DistinctId: user.ID,
|
|
@@ -205,8 +184,6 @@ To ignore tracing headers while keeping request metadata, disable tracing header
|
|
|
205
184
|
|
|
206
185
|
Go
|
|
207
186
|
|
|
208
|
-
PostHog AI
|
|
209
|
-
|
|
210
187
|
```go
|
|
211
188
|
handler := posthog.NewRequestContextMiddleware(
|
|
212
189
|
next,
|
|
@@ -228,8 +205,6 @@ Call `client.EvaluateFlags()` once for the user, then read values from the retur
|
|
|
228
205
|
|
|
229
206
|
Go
|
|
230
207
|
|
|
231
|
-
PostHog AI
|
|
232
|
-
|
|
233
208
|
```go
|
|
234
209
|
flags, err := client.EvaluateFlags(posthog.EvaluateFlagsPayload{
|
|
235
210
|
DistinctId: "distinct_id_of_your_user",
|
|
@@ -237,6 +212,7 @@ flags, err := client.EvaluateFlags(posthog.EvaluateFlagsPayload{
|
|
|
237
212
|
if err != nil {
|
|
238
213
|
// Handle error (e.g. capture error and fallback to default behavior)
|
|
239
214
|
}
|
|
215
|
+
|
|
240
216
|
if flags.IsEnabled("flag-key") {
|
|
241
217
|
// Do something differently for this user
|
|
242
218
|
// Optional: fetch the payload
|
|
@@ -248,8 +224,6 @@ if flags.IsEnabled("flag-key") {
|
|
|
248
224
|
|
|
249
225
|
Go
|
|
250
226
|
|
|
251
|
-
PostHog AI
|
|
252
|
-
|
|
253
227
|
```go
|
|
254
228
|
flags, err := client.EvaluateFlags(posthog.EvaluateFlagsPayload{
|
|
255
229
|
DistinctId: "distinct_id_of_your_user",
|
|
@@ -257,7 +231,9 @@ flags, err := client.EvaluateFlags(posthog.EvaluateFlagsPayload{
|
|
|
257
231
|
if err != nil {
|
|
258
232
|
// Handle error (e.g. capture error and fallback to default behavior)
|
|
259
233
|
}
|
|
234
|
+
|
|
260
235
|
enabledVariant := flags.GetFlag("flag-key")
|
|
236
|
+
|
|
261
237
|
if enabledVariant == "variant-key" { // replace "variant-key" with the key of your variant
|
|
262
238
|
// Do something differently for this user
|
|
263
239
|
// Optional: fetch the payload
|
|
@@ -283,8 +259,6 @@ Pass the same `flags` object that you used for branching. This attaches the exac
|
|
|
283
259
|
|
|
284
260
|
Go
|
|
285
261
|
|
|
286
|
-
PostHog AI
|
|
287
|
-
|
|
288
262
|
```go
|
|
289
263
|
flags, err := client.EvaluateFlags(posthog.EvaluateFlagsPayload{
|
|
290
264
|
DistinctId: "distinct_id_of_your_user",
|
|
@@ -292,9 +266,11 @@ flags, err := client.EvaluateFlags(posthog.EvaluateFlagsPayload{
|
|
|
292
266
|
if err != nil {
|
|
293
267
|
// Handle error
|
|
294
268
|
}
|
|
269
|
+
|
|
295
270
|
if flags.IsEnabled("flag-key") {
|
|
296
271
|
// Do something differently for this user
|
|
297
272
|
}
|
|
273
|
+
|
|
298
274
|
client.Enqueue(posthog.Capture{
|
|
299
275
|
DistinctId: "distinct_id_of_your_user",
|
|
300
276
|
Event: "event_name",
|
|
@@ -308,8 +284,6 @@ To reduce event property bloat, pass a filtered snapshot:
|
|
|
308
284
|
|
|
309
285
|
Go
|
|
310
286
|
|
|
311
|
-
PostHog AI
|
|
312
|
-
|
|
313
287
|
```go
|
|
314
288
|
// Attach only flags accessed with IsEnabled() or GetFlag() before this call
|
|
315
289
|
client.Enqueue(posthog.Capture{
|
|
@@ -317,6 +291,7 @@ client.Enqueue(posthog.Capture{
|
|
|
317
291
|
Event: "event_name",
|
|
318
292
|
Flags: flags.OnlyAccessed(),
|
|
319
293
|
})
|
|
294
|
+
|
|
320
295
|
// Attach only specific flags
|
|
321
296
|
client.Enqueue(posthog.Capture{
|
|
322
297
|
DistinctId: "distinct_id_of_your_user",
|
|
@@ -333,8 +308,6 @@ In the event properties, include `$feature/feature_flag_name: variant_key`:
|
|
|
333
308
|
|
|
334
309
|
Go
|
|
335
310
|
|
|
336
|
-
PostHog AI
|
|
337
|
-
|
|
338
311
|
```go
|
|
339
312
|
client.Enqueue(posthog.Capture{
|
|
340
313
|
DistinctId: "distinct_id_of_your_user",
|
|
@@ -350,8 +323,6 @@ By default, `EvaluateFlags()` evaluates every flag for the user. If you only nee
|
|
|
350
323
|
|
|
351
324
|
Go
|
|
352
325
|
|
|
353
|
-
PostHog AI
|
|
354
|
-
|
|
355
326
|
```go
|
|
356
327
|
flags, err := client.EvaluateFlags(posthog.EvaluateFlagsPayload{
|
|
357
328
|
DistinctId: "distinct_id_of_your_user",
|
|
@@ -377,8 +348,6 @@ For example:
|
|
|
377
348
|
|
|
378
349
|
Go
|
|
379
350
|
|
|
380
|
-
PostHog AI
|
|
381
|
-
|
|
382
351
|
```go
|
|
383
352
|
flags, err := client.EvaluateFlags(posthog.EvaluateFlagsPayload{
|
|
384
353
|
DistinctId: "distinct_id_of_the_user",
|
|
@@ -397,6 +366,7 @@ flags, err := client.EvaluateFlags(posthog.EvaluateFlagsPayload{
|
|
|
397
366
|
if err != nil {
|
|
398
367
|
// Handle error
|
|
399
368
|
}
|
|
369
|
+
|
|
400
370
|
if flags.IsEnabled("flag-key") {
|
|
401
371
|
// Do something differently for this user
|
|
402
372
|
}
|
|
@@ -435,10 +405,9 @@ You can configure the `FeatureFlagRequestTimeout` parameter when initializing yo
|
|
|
435
405
|
|
|
436
406
|
Go
|
|
437
407
|
|
|
438
|
-
PostHog AI
|
|
439
|
-
|
|
440
408
|
```go
|
|
441
409
|
// import "time"
|
|
410
|
+
|
|
442
411
|
client, _ := posthog.NewWithConfig(
|
|
443
412
|
os.Getenv("<ph_project_token>"),
|
|
444
413
|
posthog.Config{
|
|
@@ -463,8 +432,6 @@ Since [experiments](/docs/experiments/start-here.md) use feature flags, the code
|
|
|
463
432
|
|
|
464
433
|
Go
|
|
465
434
|
|
|
466
|
-
PostHog AI
|
|
467
|
-
|
|
468
435
|
```go
|
|
469
436
|
flags, err := client.EvaluateFlags(posthog.EvaluateFlagsPayload{
|
|
470
437
|
DistinctId: "user_distinct_id",
|
|
@@ -473,6 +440,7 @@ if err != nil {
|
|
|
473
440
|
// Handle error (e.g. capture error and fallback to default behavior)
|
|
474
441
|
}
|
|
475
442
|
variant := flags.GetFlag("experiment-feature-flag-key")
|
|
443
|
+
|
|
476
444
|
if variant == "variant-name" {
|
|
477
445
|
// Do something
|
|
478
446
|
}
|
|
@@ -488,8 +456,6 @@ You can capture exceptions and errors using the Go SDK. There are two approaches
|
|
|
488
456
|
|
|
489
457
|
Go
|
|
490
458
|
|
|
491
|
-
PostHog AI
|
|
492
|
-
|
|
493
459
|
```go
|
|
494
460
|
exception := posthog.NewDefaultException(
|
|
495
461
|
time.Now(),
|
|
@@ -504,8 +470,6 @@ client.Enqueue(exception)
|
|
|
504
470
|
|
|
505
471
|
Go
|
|
506
472
|
|
|
507
|
-
PostHog AI
|
|
508
|
-
|
|
509
473
|
```go
|
|
510
474
|
baseHandler := slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{
|
|
511
475
|
Level: slog.LevelInfo,
|
|
@@ -515,6 +479,7 @@ logger := slog.New(posthog.NewSlogCaptureHandler(baseHandler, client,
|
|
|
515
479
|
return "user_distinct_id"
|
|
516
480
|
}),
|
|
517
481
|
))
|
|
482
|
+
|
|
518
483
|
// Automatically captured as an exception in PostHog
|
|
519
484
|
logger.Warn("Something broke", "error", fmt.Errorf("connection refused"))
|
|
520
485
|
```
|
|
@@ -531,8 +496,6 @@ Group analytics allows you to associate an event with a group (e.g. teams, organ
|
|
|
531
496
|
|
|
532
497
|
Go
|
|
533
498
|
|
|
534
|
-
PostHog AI
|
|
535
|
-
|
|
536
499
|
```go
|
|
537
500
|
client.Enqueue(posthog.Capture{
|
|
538
501
|
DistinctId: "user_distinct_id",
|
|
@@ -546,8 +509,6 @@ client.Enqueue(posthog.Capture{
|
|
|
546
509
|
|
|
547
510
|
Go
|
|
548
511
|
|
|
549
|
-
PostHog AI
|
|
550
|
-
|
|
551
512
|
```go
|
|
552
513
|
client.Enqueue(posthog.GroupIdentify{
|
|
553
514
|
Type: "company",
|
|
@@ -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
|
-
# Identify users
|
|
4
|
-
|
|
5
|
-
Copy page
|
|
6
|
-
|
|
7
|
-
# Identify users - Docs
|
|
3
|
+
# Identify users
|
|
8
4
|
|
|
9
5
|
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.
|
|
10
6
|
|
|
@@ -14,8 +10,6 @@ However, in the frontend of a [web](/docs/libraries/js/usage.md#capturing-events
|
|
|
14
10
|
|
|
15
11
|
To link events to specific users, call `identify`:
|
|
16
12
|
|
|
17
|
-
PostHog AI
|
|
18
|
-
|
|
19
13
|
### Web
|
|
20
14
|
|
|
21
15
|
```javascript
|
|
@@ -106,8 +100,6 @@ If your app already knows the signed-in user when you initialize the JavaScript
|
|
|
106
100
|
|
|
107
101
|
Web
|
|
108
102
|
|
|
109
|
-
PostHog AI
|
|
110
|
-
|
|
111
103
|
```javascript
|
|
112
104
|
posthog.init('<ph_project_token>', {
|
|
113
105
|
api_host: 'https://us.i.posthog.com',
|
|
@@ -144,8 +136,6 @@ This is important if your users are sharing a computer, as otherwise all of thos
|
|
|
144
136
|
|
|
145
137
|
You can do that like so:
|
|
146
138
|
|
|
147
|
-
PostHog AI
|
|
148
|
-
|
|
149
139
|
### Web
|
|
150
140
|
|
|
151
141
|
```javascript
|
|
@@ -180,8 +170,6 @@ If you *also* want to reset the `device_id` so that the device will be considere
|
|
|
180
170
|
|
|
181
171
|
Web
|
|
182
172
|
|
|
183
|
-
PostHog AI
|
|
184
|
-
|
|
185
173
|
```javascript
|
|
186
174
|
posthog.reset(true)
|
|
187
175
|
```
|
|
@@ -225,20 +213,22 @@ As long as you associate the distinct IDs with `posthog.identify()` or `posthog.
|
|
|
225
213
|
|
|
226
214
|
Here's an example implementation for handling deep links from web to mobile:
|
|
227
215
|
|
|
228
|
-
PostHog AI
|
|
229
|
-
|
|
230
216
|
### iOS
|
|
231
217
|
|
|
232
218
|
```swift
|
|
233
219
|
import PostHog
|
|
220
|
+
|
|
234
221
|
class DeepLinkIdentityManager {
|
|
235
222
|
static let shared = DeepLinkIdentityManager()
|
|
223
|
+
|
|
236
224
|
// MARK: - Deep Link Received
|
|
225
|
+
|
|
237
226
|
func handleDeepLink(_ url: URL, isAuthenticatedOnMobile: Bool) {
|
|
238
227
|
guard let webDistinctId = URLComponents(url: url, resolvingAgainstBaseURL: true)?
|
|
239
228
|
.queryItems?.first(where: { $0.name == "ph_distinct_id" })?.value else {
|
|
240
229
|
return
|
|
241
230
|
}
|
|
231
|
+
|
|
242
232
|
if isAuthenticatedOnMobile {
|
|
243
233
|
// The mobile app already knows the current user.
|
|
244
234
|
// Alias the incoming web distinct ID to that user.
|
|
@@ -248,13 +238,16 @@ class DeepLinkIdentityManager {
|
|
|
248
238
|
PostHogSDK.shared.identify(webDistinctId)
|
|
249
239
|
}
|
|
250
240
|
}
|
|
241
|
+
|
|
251
242
|
// MARK: - Login/Signup
|
|
243
|
+
|
|
252
244
|
func handleLogin(canonicalUserId: String) {
|
|
253
245
|
// Switch from the web distinct ID (or a mobile anon ID)
|
|
254
246
|
// to your canonical user ID.
|
|
255
247
|
PostHogSDK.shared.identify(canonicalUserId)
|
|
256
248
|
// Set user properties, track signup event, etc.
|
|
257
249
|
}
|
|
250
|
+
|
|
258
251
|
func handleLogout() {
|
|
259
252
|
PostHogSDK.shared.reset()
|
|
260
253
|
}
|
|
@@ -266,10 +259,14 @@ class DeepLinkIdentityManager {
|
|
|
266
259
|
```kotlin
|
|
267
260
|
import android.net.Uri
|
|
268
261
|
import com.posthog.PostHog
|
|
262
|
+
|
|
269
263
|
object DeepLinkIdentityManager {
|
|
264
|
+
|
|
270
265
|
// Deep Link Received
|
|
266
|
+
|
|
271
267
|
fun handleDeepLink(uri: Uri, isAuthenticatedOnMobile: Boolean) {
|
|
272
268
|
val webDistinctId = uri.getQueryParameter("ph_distinct_id") ?: return
|
|
269
|
+
|
|
273
270
|
if (isAuthenticatedOnMobile) {
|
|
274
271
|
// The mobile app already knows the current user.
|
|
275
272
|
// Alias the incoming web distinct ID to that user.
|
|
@@ -279,13 +276,16 @@ object DeepLinkIdentityManager {
|
|
|
279
276
|
PostHog.identify(webDistinctId)
|
|
280
277
|
}
|
|
281
278
|
}
|
|
279
|
+
|
|
282
280
|
// Login/Signup
|
|
281
|
+
|
|
283
282
|
fun handleLogin(canonicalUserId: String) {
|
|
284
283
|
// Switch from the web distinct ID (or a mobile anon ID)
|
|
285
284
|
// to your canonical user ID.
|
|
286
285
|
PostHog.identify(canonicalUserId)
|
|
287
286
|
// Set user properties, track signup event, etc.
|
|
288
287
|
}
|
|
288
|
+
|
|
289
289
|
fun handleLogout() {
|
|
290
290
|
PostHog.reset()
|
|
291
291
|
}
|
|
@@ -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
|
-
# iOS
|
|
4
|
-
|
|
5
|
-
Copy page
|
|
6
|
-
|
|
7
|
-
# iOS - Docs
|
|
3
|
+
# iOS
|
|
8
4
|
|
|
9
5
|
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.
|
|
10
6
|
|
|
@@ -18,8 +14,6 @@ PostHog is available through [CocoaPods](http://cocoapods.org) or you can add it
|
|
|
18
14
|
|
|
19
15
|
Podfile
|
|
20
16
|
|
|
21
|
-
PostHog AI
|
|
22
|
-
|
|
23
17
|
```ruby
|
|
24
18
|
pod "PostHog", "~> 3.59.3"
|
|
25
19
|
```
|
|
@@ -32,8 +26,6 @@ For a Swift Package Manager based project, add PostHog as a dependency in your `
|
|
|
32
26
|
|
|
33
27
|
Package.swift
|
|
34
28
|
|
|
35
|
-
PostHog AI
|
|
36
|
-
|
|
37
29
|
```swift
|
|
38
30
|
dependencies: [
|
|
39
31
|
.package(url: "https://github.com/PostHog/posthog-ios.git", from: "3.59.3")
|
|
@@ -44,8 +36,6 @@ and then as a dependency for the Package target utilizing PostHog:
|
|
|
44
36
|
|
|
45
37
|
Package.swift
|
|
46
38
|
|
|
47
|
-
PostHog AI
|
|
48
|
-
|
|
49
39
|
```swift
|
|
50
40
|
.target(
|
|
51
41
|
name: "myApp",
|
|
@@ -62,19 +52,20 @@ You can find more advanced configuration options in the [configuration page](/do
|
|
|
62
52
|
|
|
63
53
|
Swift
|
|
64
54
|
|
|
65
|
-
PostHog AI
|
|
66
|
-
|
|
67
55
|
```swift
|
|
68
56
|
import Foundation
|
|
69
57
|
import PostHog
|
|
70
58
|
import UIKit
|
|
59
|
+
|
|
71
60
|
class AppDelegate: NSObject, UIApplicationDelegate {
|
|
72
61
|
func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
|
|
73
62
|
let POSTHOG_PROJECT_TOKEN = "<ph_project_token>"
|
|
74
63
|
// usually 'https://us.i.posthog.com' or 'https://eu.i.posthog.com'
|
|
75
64
|
let POSTHOG_HOST = "https://us.i.posthog.com"
|
|
65
|
+
|
|
76
66
|
let config = PostHogConfig(projectToken: POSTHOG_PROJECT_TOKEN, host: POSTHOG_HOST)
|
|
77
67
|
PostHogSDK.shared.setup(config)
|
|
68
|
+
|
|
78
69
|
return true
|
|
79
70
|
}
|
|
80
71
|
}
|
|
@@ -84,22 +75,27 @@ class AppDelegate: NSObject, UIApplicationDelegate {
|
|
|
84
75
|
|
|
85
76
|
Swift
|
|
86
77
|
|
|
87
|
-
PostHog AI
|
|
88
|
-
|
|
89
78
|
```swift
|
|
90
79
|
import SwiftUI
|
|
91
80
|
import PostHog
|
|
81
|
+
|
|
92
82
|
@main
|
|
93
83
|
struct YourGreatApp: App {
|
|
84
|
+
|
|
94
85
|
// Add PostHog to your app's initializer.
|
|
95
86
|
// If using UIApplicationDelegateAdaptor, see the UIKit tab.
|
|
87
|
+
|
|
96
88
|
init() {
|
|
89
|
+
|
|
97
90
|
let POSTHOG_PROJECT_TOKEN = "<ph_project_token>"
|
|
98
91
|
// usually 'https://us.i.posthog.com' or 'https://eu.i.posthog.com'
|
|
99
92
|
let POSTHOG_HOST = "https://us.i.posthog.com"
|
|
93
|
+
|
|
100
94
|
let config = PostHogConfig(projectToken: POSTHOG_PROJECT_TOKEN, host: POSTHOG_HOST)
|
|
101
95
|
PostHogSDK.shared.setup(config)
|
|
96
|
+
|
|
102
97
|
}
|
|
98
|
+
|
|
103
99
|
var body: some Scene {
|
|
104
100
|
WindowGroup {
|
|
105
101
|
ContentView()
|
|
@@ -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
|
-
# Laravel
|
|
4
|
-
|
|
5
|
-
Copy page
|
|
6
|
-
|
|
7
|
-
# Laravel - Docs
|
|
3
|
+
# Laravel
|
|
8
4
|
|
|
9
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).
|
|
10
6
|
|
|
@@ -14,8 +10,6 @@ Install the PHP SDK as described in the [PHP installation guide](/docs/libraries
|
|
|
14
10
|
|
|
15
11
|
.env
|
|
16
12
|
|
|
17
|
-
PostHog AI
|
|
18
|
-
|
|
19
13
|
```bash
|
|
20
14
|
POSTHOG_API_KEY=<ph_project_token>
|
|
21
15
|
POSTHOG_HOST=https://us.i.posthog.com
|
|
@@ -25,8 +19,6 @@ Add PostHog to Laravel's services config:
|
|
|
25
19
|
|
|
26
20
|
config/services.php
|
|
27
21
|
|
|
28
|
-
PostHog AI
|
|
29
|
-
|
|
30
22
|
```php
|
|
31
23
|
'posthog' => [
|
|
32
24
|
'api_key' => env('POSTHOG_API_KEY'),
|
|
@@ -38,13 +30,14 @@ Initialize PostHog in the `boot` method of `app/Providers/AppServiceProvider.php
|
|
|
38
30
|
|
|
39
31
|
app/Providers/AppServiceProvider.php
|
|
40
32
|
|
|
41
|
-
PostHog AI
|
|
42
|
-
|
|
43
33
|
```php
|
|
44
34
|
<?php
|
|
35
|
+
|
|
45
36
|
namespace App\Providers;
|
|
37
|
+
|
|
46
38
|
use Illuminate\Support\ServiceProvider;
|
|
47
39
|
use PostHog\PostHog;
|
|
40
|
+
|
|
48
41
|
class AppServiceProvider extends ServiceProvider
|
|
49
42
|
{
|
|
50
43
|
public function boot(): void
|
|
@@ -52,6 +45,7 @@ class AppServiceProvider extends ServiceProvider
|
|
|
52
45
|
if (! config('services.posthog.api_key')) {
|
|
53
46
|
return;
|
|
54
47
|
}
|
|
48
|
+
|
|
55
49
|
PostHog::init(
|
|
56
50
|
config('services.posthog.api_key'),
|
|
57
51
|
[
|
|
@@ -72,15 +66,16 @@ Add middleware like this:
|
|
|
72
66
|
|
|
73
67
|
app/Http/Middleware/PostHogRequestContext.php
|
|
74
68
|
|
|
75
|
-
PostHog AI
|
|
76
|
-
|
|
77
69
|
```php
|
|
78
70
|
<?php
|
|
71
|
+
|
|
79
72
|
namespace App\Http\Middleware;
|
|
73
|
+
|
|
80
74
|
use Closure;
|
|
81
75
|
use Illuminate\Http\Request;
|
|
82
76
|
use PostHog\PostHog;
|
|
83
77
|
use Symfony\Component\HttpFoundation\Response;
|
|
78
|
+
|
|
84
79
|
final class PostHogRequestContext
|
|
85
80
|
{
|
|
86
81
|
public function handle(Request $request, Closure $next): Response
|
|
@@ -88,7 +83,9 @@ final class PostHogRequestContext
|
|
|
88
83
|
if (! config('services.posthog.api_key')) {
|
|
89
84
|
return $next($request);
|
|
90
85
|
}
|
|
86
|
+
|
|
91
87
|
$context = PostHog::contextFromHeaders($request->headers->all());
|
|
88
|
+
|
|
92
89
|
$context['properties'] = array_merge(
|
|
93
90
|
$context['properties'] ?? [],
|
|
94
91
|
array_filter([
|
|
@@ -99,6 +96,7 @@ final class PostHogRequestContext
|
|
|
99
96
|
'$ip' => $request->ip(),
|
|
100
97
|
], static fn ($value): bool => $value !== null && $value !== '')
|
|
101
98
|
);
|
|
99
|
+
|
|
102
100
|
return PostHog::withContext(
|
|
103
101
|
$context,
|
|
104
102
|
static fn (): Response => $next($request),
|
|
@@ -118,17 +116,17 @@ In Laravel 11 and later, add a report callback in `bootstrap/app.php`:
|
|
|
118
116
|
|
|
119
117
|
bootstrap/app.php
|
|
120
118
|
|
|
121
|
-
PostHog AI
|
|
122
|
-
|
|
123
119
|
```php
|
|
124
120
|
use Illuminate\Foundation\Configuration\Exceptions;
|
|
125
121
|
use PostHog\PostHog;
|
|
126
122
|
use Throwable;
|
|
123
|
+
|
|
127
124
|
->withExceptions(function (Exceptions $exceptions): void {
|
|
128
125
|
$exceptions->report(function (Throwable $e): void {
|
|
129
126
|
if (! config('services.posthog.api_key')) {
|
|
130
127
|
return;
|
|
131
128
|
}
|
|
129
|
+
|
|
132
130
|
PostHog::captureException(
|
|
133
131
|
$e,
|
|
134
132
|
auth()->id() !== null ? (string) auth()->id() : null,
|
|
@@ -151,8 +149,6 @@ If you prefer immediate delivery in queue workers, configure the PHP SDK with `b
|
|
|
151
149
|
|
|
152
150
|
PHP
|
|
153
151
|
|
|
154
|
-
PostHog AI
|
|
155
|
-
|
|
156
152
|
```php
|
|
157
153
|
PostHog::init(
|
|
158
154
|
'<ph_project_token>',
|