vybekiit 0.7.26 → 0.7.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +3910 -1300
- package/dist/global-guidance/language.md +443 -0
- package/dist/global-skills/add-ai/SKILL.md +1 -1
- package/dist/global-skills/add-analytics/SKILL.md +1 -1
- package/dist/global-skills/add-blog/SKILL.md +1 -1
- package/dist/global-skills/add-crud/SKILL.md +1 -1
- package/dist/global-skills/add-files/SKILL.md +1 -1
- package/dist/global-skills/add-images/SKILL.md +1 -1
- package/dist/global-skills/add-language/SKILL.md +1 -1
- package/dist/global-skills/add-notifications/SKILL.md +1 -1
- package/dist/global-skills/add-realtime/SKILL.md +1 -1
- package/dist/global-skills/add-route/SKILL.md +1 -1
- package/dist/global-skills/add-search/SKILL.md +1 -1
- package/dist/global-skills/add-signin/SKILL.md +1 -1
- package/dist/global-skills/add-teams/SKILL.md +1 -1
- package/dist/global-skills/add-upload/SKILL.md +1 -1
- package/dist/global-skills/aws-cdk/SKILL.md +19 -5
- package/dist/global-skills/aws-cdk/references/fast-deployments.md +191 -0
- package/dist/global-skills/aws-cdk/references/troubleshooting-deployment.md +16 -0
- package/dist/global-skills/aws-cloudformation/SKILL.md +16 -26
- package/dist/global-skills/aws-cloudformation/references/check-cloudformation-template-compliance.script.md +7 -3
- package/dist/global-skills/aws-cloudformation/references/cloudformation-language-server.md +177 -0
- package/dist/global-skills/aws-cloudformation/references/cloudformation-pre-deploy-validation.script.md +8 -2
- package/dist/global-skills/aws-cloudformation/references/persist-template-context.script.md +5 -8
- package/dist/global-skills/aws-cloudformation/references/retrieve-template-context.script.md +1 -1
- package/dist/global-skills/aws-cloudformation/references/security-considerations.md +51 -0
- package/dist/global-skills/aws-cloudformation/references/troubleshoot-failed-stack.script.md +138 -0
- package/dist/global-skills/aws-cloudformation/references/{validate-cloudformation-template.script.md → validate-with-cfn-lint.script.md} +15 -27
- package/dist/global-skills/aws-cloudformation/references/validate-with-cloudformation-validate.script.md +181 -0
- package/dist/global-skills/aws-cloudformation/references/validation-tool-selection.md +44 -0
- package/dist/global-skills/aws-serverless/SKILL.md +9 -1
- package/dist/global-skills/aws-serverless/references/architecture.md +3 -1
- package/dist/global-skills/aws-serverless/references/lambda.md +3 -1
- package/dist/global-skills/aws-serverless/references/orchestration.md +1 -0
- package/dist/global-skills/back-up-my-code/SKILL.md +1 -1
- package/dist/global-skills/better-auth-best-practices/SKILL.md +18 -8
- package/dist/global-skills/buy-domain/SKILL.md +1 -1
- package/dist/global-skills/check-safety/SKILL.md +1 -1
- package/dist/global-skills/configure-capabilities/SKILL.md +1 -1
- package/dist/global-skills/connect-account/SKILL.md +1 -1
- package/dist/global-skills/connect-account-backend/SKILL.md +1 -1
- package/dist/global-skills/design-my-data/SKILL.md +1 -1
- package/dist/global-skills/doctor/SKILL.md +1 -1
- package/dist/global-skills/eas-app-stores/SKILL.md +31 -15
- package/dist/global-skills/eas-app-stores/agents/openai.yaml +2 -2
- package/dist/global-skills/eas-app-stores/references/ios-app-store.md +37 -32
- package/dist/global-skills/eas-app-stores/references/native-ios.md +167 -0
- package/dist/global-skills/eas-app-stores/references/play-store.md +3 -7
- package/dist/global-skills/eas-app-stores/references/testflight.md +39 -35
- package/dist/global-skills/eas-simulator/SKILL.md +48 -26
- package/dist/global-skills/eas-simulator/references/controllers.md +32 -3
- package/dist/global-skills/eas-simulator/references/run-your-app.md +34 -4
- package/dist/global-skills/eas-simulator/references/troubleshooting.md +8 -4
- package/dist/global-skills/eas-update/SKILL.md +146 -0
- package/dist/global-skills/eas-update/agents/openai.yaml +4 -0
- package/dist/global-skills/expo-animation/RECIPES.md +2 -2
- package/dist/global-skills/expo-animation/SKILL.md +9 -2
- package/dist/global-skills/expo-brownfield/SKILL.md +18 -11
- package/dist/global-skills/expo-brownfield/agents/openai.yaml +2 -2
- package/dist/global-skills/expo-brownfield/references/brownfield-integrated.md +94 -69
- package/dist/global-skills/expo-brownfield/references/brownfield-isolated.md +40 -42
- package/dist/global-skills/expo-brownfield/references/comparison.md +5 -5
- package/dist/global-skills/expo-brownfield/references/feature-integration.md +163 -0
- package/dist/global-skills/expo-brownfield/references/troubleshooting.md +17 -17
- package/dist/global-skills/expo-brownfield/references/version-compatibility.md +40 -0
- package/dist/global-skills/expo-data-fetching/SKILL.md +27 -6
- package/dist/global-skills/expo-design-system/SKILL.md +27 -7
- package/dist/global-skills/expo-design-system/references/audit.md +7 -2
- package/dist/global-skills/expo-design-system/references/native-slop.md +74 -0
- package/dist/global-skills/expo-examples/SKILL.md +0 -1
- package/dist/global-skills/expo-examples/references/catalog.md +1 -1
- package/dist/global-skills/expo-migrate-module/SKILL.md +21 -10
- package/dist/global-skills/expo-migrate-module/references/compatibility.md +80 -23
- package/dist/global-skills/expo-migrate-module/references/migration-map.md +162 -11
- package/dist/global-skills/expo-native-ui/SKILL.md +25 -16
- package/dist/global-skills/expo-native-ui/agents/openai.yaml +2 -2
- package/dist/global-skills/expo-native-ui/references/controls.md +5 -46
- package/dist/global-skills/expo-native-ui/references/icons.md +21 -2
- package/dist/global-skills/expo-native-ui/references/media.md +15 -20
- package/dist/global-skills/expo-native-ui/references/visual-effects.md +12 -11
- package/dist/global-skills/expo-overview/SKILL.md +17 -12
- package/dist/global-skills/expo-router/SKILL.md +5 -3
- package/dist/global-skills/expo-router/references/tabs.md +5 -5
- package/dist/global-skills/expo-upgrade/SKILL.md +3 -1
- package/dist/global-skills/expo-web-to-native/references/false-friends.md +2 -2
- package/dist/global-skills/expo-web-to-native/references/native-patterns.md +1 -1
- package/dist/global-skills/firebase-ai-logic-basics/SKILL.md +13 -16
- package/dist/global-skills/firebase-ai-logic-basics/references/ios_setup.md +4 -5
- package/dist/global-skills/firebase-ai-logic-basics/references/usage_patterns_android.md +4 -4
- package/dist/global-skills/firebase-ai-logic-basics/references/usage_patterns_web.md +3 -3
- package/dist/global-skills/firebase-auth-basics/SKILL.md +11 -6
- package/dist/global-skills/firebase-auth-basics/references/client_sdk_android.md +4 -5
- package/dist/global-skills/firebase-auth-basics/references/client_sdk_web.md +3 -3
- package/dist/global-skills/firebase-auth-basics/references/flutter_setup.md +24 -25
- package/dist/global-skills/firebase-auth-basics/references/security_rules.md +4 -2
- package/dist/global-skills/firebase-crashlytics/references/android_setup.md +7 -4
- package/dist/global-skills/firebase-crashlytics/references/ios_setup.md +2 -3
- package/dist/global-skills/firebase-data-connect/SKILL.md +2 -1
- package/dist/global-skills/firebase-data-connect/examples.md +4 -4
- package/dist/global-skills/firebase-data-connect/reference/config.md +5 -4
- package/dist/global-skills/firebase-data-connect/reference/realtime.md +1 -2
- package/dist/global-skills/firebase-data-connect/reference/sdk_flutter.md +2 -2
- package/dist/global-skills/firebase-data-connect/reference/sdk_ios.md +2 -2
- package/dist/global-skills/firebase-data-connect/reference/sdk_web.md +17 -6
- package/dist/global-skills/firebase-data-connect/reference/security.md +5 -5
- package/dist/global-skills/firebase-data-connect/templates.md +2 -1
- package/dist/global-skills/firebase-firestore/SKILL.md +20 -8
- package/dist/global-skills/firebase-firestore/references/enterprise/android_sdk_usage.md +5 -4
- package/dist/global-skills/firebase-firestore/references/enterprise/data_model.md +12 -3
- package/dist/global-skills/firebase-firestore/references/enterprise/indexes.md +16 -18
- package/dist/global-skills/firebase-firestore/references/enterprise/provisioning.md +1 -1
- package/dist/global-skills/firebase-firestore/references/enterprise/python_sdk_usage.md +5 -1
- package/dist/global-skills/firebase-firestore/references/enterprise/web_sdk_usage.md +7 -7
- package/dist/global-skills/firebase-firestore/references/standard/android_sdk_usage.md +5 -5
- package/dist/global-skills/firebase-firestore/references/standard/flutter_setup.md +4 -4
- package/dist/global-skills/firebase-firestore/references/standard/indexes.md +16 -18
- package/dist/global-skills/firebase-firestore/references/standard/provisioning.md +1 -1
- package/dist/global-skills/firebase-remote-config-basics/SKILL.md +0 -5
- package/dist/global-skills/firebase-remote-config-basics/references/android_setup.md +36 -8
- package/dist/global-skills/firebase-remote-config-basics/references/ios_setup.md +1 -7
- package/dist/global-skills/firebase-security-rules-auditor/SKILL.md +17 -6
- package/dist/global-skills/{firebase-firestore/references/standard/security_rules.md → firestore-rules-creation/SKILL.md} +24 -13
- package/dist/global-skills/go-live/SKILL.md +1 -1
- package/dist/global-skills/grow-my-customers/SKILL.md +23 -0
- package/dist/global-skills/harden/SKILL.md +1 -1
- package/dist/global-skills/instrument-feature-flags/SKILL.md +25 -25
- package/dist/global-skills/instrument-feature-flags/references/adding-feature-flag-code.md +141 -285
- package/dist/global-skills/instrument-feature-flags/references/android.md +6 -15
- package/dist/global-skills/instrument-feature-flags/references/api.md +4 -11
- package/dist/global-skills/instrument-feature-flags/references/best-practices.md +1 -13
- package/dist/global-skills/instrument-feature-flags/references/django.md +14 -27
- package/dist/global-skills/instrument-feature-flags/references/dotnet.md +20 -79
- package/dist/global-skills/instrument-feature-flags/references/elixir.md +1 -9
- package/dist/global-skills/instrument-feature-flags/references/flask.md +13 -13
- package/dist/global-skills/instrument-feature-flags/references/flutter.md +3 -24
- package/dist/global-skills/instrument-feature-flags/references/go.md +3 -15
- package/dist/global-skills/instrument-feature-flags/references/ios.md +4 -17
- package/dist/global-skills/instrument-feature-flags/references/java.md +5 -13
- package/dist/global-skills/instrument-feature-flags/references/laravel.md +13 -17
- package/dist/global-skills/instrument-feature-flags/references/next-js.md +25 -32
- package/dist/global-skills/instrument-feature-flags/references/nodejs.md +8 -15
- package/dist/global-skills/instrument-feature-flags/references/php.md +1 -15
- package/dist/global-skills/instrument-feature-flags/references/python.md +2 -15
- package/dist/global-skills/instrument-feature-flags/references/react-native.md +13 -15
- package/dist/global-skills/instrument-feature-flags/references/react.md +17 -21
- package/dist/global-skills/instrument-feature-flags/references/ruby-on-rails.md +37 -83
- package/dist/global-skills/instrument-feature-flags/references/ruby.md +2 -15
- package/dist/global-skills/instrument-feature-flags/references/rust.md +13 -25
- package/dist/global-skills/instrument-feature-flags/references/usage.md +14 -63
- package/dist/global-skills/instrument-feature-flags/references/web.md +9 -14
- package/dist/global-skills/instrument-product-analytics/SKILL.md +29 -29
- package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-astro-hybrid.md +3 -1
- package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-astro-ssr.md +3 -1
- package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-astro-static.md +3 -1
- package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-astro-view-transitions.md +3 -1
- package/dist/global-skills/instrument-product-analytics/references/EXAMPLE-ruby-on-rails.md +3 -1
- package/dist/global-skills/instrument-product-analytics/references/android.md +72 -107
- package/dist/global-skills/instrument-product-analytics/references/angular.md +26 -28
- package/dist/global-skills/instrument-product-analytics/references/astro.md +13 -24
- package/dist/global-skills/instrument-product-analytics/references/configuration.md +45 -63
- package/dist/global-skills/instrument-product-analytics/references/django.md +14 -27
- package/dist/global-skills/instrument-product-analytics/references/dotnet.md +20 -79
- package/dist/global-skills/instrument-product-analytics/references/elixir.md +47 -49
- package/dist/global-skills/instrument-product-analytics/references/flask.md +13 -13
- package/dist/global-skills/instrument-product-analytics/references/flutter.md +60 -90
- package/dist/global-skills/instrument-product-analytics/references/go.md +17 -56
- package/dist/global-skills/instrument-product-analytics/references/identify-users.md +15 -15
- package/dist/global-skills/instrument-product-analytics/references/ios.md +11 -15
- package/dist/global-skills/instrument-product-analytics/references/laravel.md +13 -17
- package/dist/global-skills/instrument-product-analytics/references/next-js.md +25 -32
- package/dist/global-skills/instrument-product-analytics/references/nuxt-js-3-6.md +13 -27
- package/dist/global-skills/instrument-product-analytics/references/nuxt-js.md +14 -28
- package/dist/global-skills/instrument-product-analytics/references/php.md +33 -84
- package/dist/global-skills/instrument-product-analytics/references/posthog-python.md +229 -9
- package/dist/global-skills/instrument-product-analytics/references/python.md +415 -106
- package/dist/global-skills/instrument-product-analytics/references/react-native.md +161 -155
- package/dist/global-skills/instrument-product-analytics/references/react-router-v6.md +12 -33
- package/dist/global-skills/instrument-product-analytics/references/react-router-v7-data-mode.md +15 -33
- package/dist/global-skills/instrument-product-analytics/references/react-router-v7-declarative-mode.md +12 -33
- package/dist/global-skills/instrument-product-analytics/references/react-router-v7-framework-mode.md +26 -41
- package/dist/global-skills/instrument-product-analytics/references/ruby-on-rails.md +37 -83
- package/dist/global-skills/instrument-product-analytics/references/ruby.md +48 -108
- package/dist/global-skills/instrument-product-analytics/references/svelte.md +18 -24
- package/dist/global-skills/instrument-product-analytics/references/tanstack-start.md +17 -19
- package/dist/global-skills/instrument-product-analytics/references/usage.md +14 -63
- package/dist/global-skills/instrument-product-analytics/references/vue-js.md +29 -28
- package/dist/global-skills/manifest.json +8 -2
- package/dist/global-skills/mongodb-search-and-ai/SKILL.md +28 -37
- package/dist/global-skills/mongodb-search-and-ai/references/automated-embedding.md +438 -0
- package/dist/global-skills/mongodb-search-and-ai/references/hybrid-search.md +60 -4
- package/dist/global-skills/mongodb-search-and-ai/references/vector-search.md +46 -108
- package/dist/global-skills/neon/SKILL.md +207 -213
- package/dist/global-skills/neon/references/auth.md +12 -0
- package/dist/global-skills/neon/references/claimable-neon.md +10 -14
- package/dist/global-skills/neon/references/function-triggers.md +53 -0
- package/dist/global-skills/neon/references/logs-loki.md +61 -0
- package/dist/global-skills/neon/references/parse-env.md +32 -0
- package/dist/global-skills/neon/references/sdk.md +7 -0
- package/dist/global-skills/neon-ai-gateway/SKILL.md +14 -16
- package/dist/global-skills/neon-auth/SKILL.md +155 -0
- package/dist/global-skills/neon-auth/references/managed-auth.md +173 -0
- package/dist/global-skills/neon-auth/references/self-managed.md +25 -0
- package/dist/global-skills/neon-functions/SKILL.md +159 -84
- package/dist/global-skills/neon-functions/references/ai-sdk.md +4 -6
- package/dist/global-skills/neon-functions/references/function-triggers.md +249 -0
- package/dist/global-skills/neon-functions/references/mastra-studio.md +3 -3
- package/dist/global-skills/neon-functions/references/mcp.md +1 -1
- package/dist/global-skills/neon-functions/references/production-hardening.md +340 -0
- package/dist/global-skills/neon-functions/references/sse.md +8 -5
- package/dist/global-skills/neon-object-storage/SKILL.md +10 -11
- package/dist/global-skills/neon-postgres/SKILL.md +120 -17
- package/dist/global-skills/neon-postgres/references/full-text-search.md +99 -0
- package/dist/global-skills/neon-postgres/references/hybrid-search.md +90 -0
- package/dist/global-skills/neon-postgres/references/lakebase-search-drizzle.md +172 -0
- package/dist/global-skills/neon-postgres/references/vector-search.md +137 -0
- package/dist/global-skills/neon-postgres-branches/SKILL.md +3 -3
- package/dist/global-skills/neon-postgres-egress-optimizer/SKILL.md +1 -1
- package/dist/global-skills/onboarding/SKILL.md +16 -14
- package/dist/global-skills/plan-my-idea/SKILL.md +1 -1
- package/dist/global-skills/publish-app/SKILL.md +1 -1
- package/dist/global-skills/publish-extension/SKILL.md +1 -1
- package/dist/global-skills/resend/SKILL.md +4 -2
- package/dist/global-skills/resend/references/broadcasts.md +6 -1
- package/dist/global-skills/resend/references/receiving.md +29 -10
- package/dist/global-skills/resend/references/sending/email-management.md +14 -4
- package/dist/global-skills/resend/references/topics.md +9 -6
- package/dist/global-skills/resend/references/usage.md +117 -0
- package/dist/global-skills/resend/references/webhooks.md +59 -2
- package/dist/global-skills/reset-password/SKILL.md +1 -1
- package/dist/global-skills/save-data/SKILL.md +1 -1
- package/dist/global-skills/setup-email/SKILL.md +1 -1
- package/dist/global-skills/setup-payments/SKILL.md +1 -1
- package/dist/global-skills/setup-sms/SKILL.md +1 -1
- package/dist/global-skills/sign-in-with-email-link/SKILL.md +1 -1
- package/dist/global-skills/sign-in-with-google/SKILL.md +1 -1
- package/dist/global-skills/sign-in-with-phone/SKILL.md +1 -1
- package/dist/global-skills/stripe-best-practices/SKILL.md +35 -29
- package/dist/global-skills/stripe-best-practices/references/billing.md +9 -2
- package/dist/global-skills/stripe-best-practices/references/payments.md +4 -2
- package/dist/global-skills/stripe-best-practices/references/security.md +3 -1
- package/dist/global-skills/stripe-best-practices/references/tax.md +39 -20
- package/dist/global-skills/supabase/SKILL.md +6 -0
- package/dist/global-skills/track-errors/SKILL.md +1 -1
- package/dist/global-skills/update-kit/SKILL.md +1 -1
- package/dist/global-skills/use-railway/SKILL.md +42 -22
- package/dist/global-skills/use-railway/references/analyze-db.md +7 -6
- package/dist/global-skills/use-railway/references/cloud-agents.md +70 -0
- package/dist/global-skills/use-railway/references/configure.md +17 -2
- package/dist/global-skills/use-railway/references/databases.md +107 -0
- package/dist/global-skills/use-railway/references/deploy.md +5 -5
- package/dist/global-skills/use-railway/references/feature-flags.md +25 -13
- package/dist/global-skills/use-railway/references/iac.md +66 -77
- package/dist/global-skills/use-railway/references/operate.md +26 -3
- package/dist/global-skills/use-railway/references/request.md +31 -23
- package/dist/global-skills/use-railway/references/setup.md +16 -5
- package/dist/global-skills/use-railway/references/tracing.md +261 -0
- package/dist/global-skills/use-railway/references/usage.md +52 -0
- package/dist/global-skills/validate-my-idea/SKILL.md +54 -0
- package/dist/global-skills/{feedback → vybekiit-feedback}/SKILL.md +17 -13
- package/dist/global-skills/watch-my-app/SKILL.md +53 -0
- package/dist/global-skills/wire-auth/SKILL.md +1 -1
- package/dist/global-skills/wire-database/SKILL.md +1 -1
- package/dist/global-skills/wire-email/SKILL.md +1 -1
- package/dist/global-skills/wire-payments/SKILL.md +1 -1
- package/dist/global-skills/workers-best-practices/SKILL.md +36 -103
- package/dist/global-skills/workers-best-practices/references/configuration.md +139 -0
- package/dist/global-skills/workers-best-practices/references/platform-apis.md +51 -0
- package/dist/global-skills/workers-best-practices/references/{rules.md → runtime-patterns.md} +13 -137
- package/dist/global-skills/wrangler/SKILL.md +48 -901
- package/dist/global-skills/xcode-project-setup/scripts/xcode_spm_setup/Sources/main.swift +19 -15
- package/package.json +9 -8
- package/dist/global-skills/expo-native-ui/references/animations.md +0 -220
- package/dist/global-skills/firebase-firestore/references/enterprise/security_rules.md +0 -577
- package/dist/global-skills/workers-best-practices/references/review.md +0 -174
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
> AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt
|
|
2
2
|
|
|
3
|
-
# Ruby
|
|
4
|
-
|
|
5
|
-
Copy page
|
|
6
|
-
|
|
7
|
-
# Ruby - Docs
|
|
3
|
+
# Ruby
|
|
8
4
|
|
|
9
5
|
The `posthog-ruby` library provides tracking functionality on the server-side for applications built in Ruby.
|
|
10
6
|
|
|
@@ -18,8 +14,6 @@ Add this to your `Gemfile`:
|
|
|
18
14
|
|
|
19
15
|
Terminal
|
|
20
16
|
|
|
21
|
-
PostHog AI
|
|
22
|
-
|
|
23
17
|
```bash
|
|
24
18
|
gem "posthog-ruby"
|
|
25
19
|
```
|
|
@@ -28,10 +22,9 @@ In your app, set your API key **before** making any calls. If setting a custom `
|
|
|
28
22
|
|
|
29
23
|
Ruby
|
|
30
24
|
|
|
31
|
-
PostHog AI
|
|
32
|
-
|
|
33
25
|
```ruby
|
|
34
26
|
require 'posthog'
|
|
27
|
+
|
|
35
28
|
posthog = PostHog::Client.new({
|
|
36
29
|
api_key: "<ph_project_token>",
|
|
37
30
|
host: "https://us.i.posthog.com",
|
|
@@ -47,10 +40,9 @@ Initialize the client with your project token before making any calls:
|
|
|
47
40
|
|
|
48
41
|
Ruby
|
|
49
42
|
|
|
50
|
-
PostHog AI
|
|
51
|
-
|
|
52
43
|
```ruby
|
|
53
44
|
require 'posthog'
|
|
45
|
+
|
|
54
46
|
posthog = PostHog::Client.new({
|
|
55
47
|
api_key: '<ph_project_token>',
|
|
56
48
|
host: 'https://us.i.posthog.com',
|
|
@@ -62,20 +54,20 @@ Available client options:
|
|
|
62
54
|
|
|
63
55
|
| Option | Type | Default | Description |
|
|
64
56
|
| --- | --- | --- | --- |
|
|
65
|
-
| api_key | String | required | Your PostHog project token. |
|
|
66
|
-
| host | String | https://us.i.posthog.com | Fully qualified PostHog API host. Include the protocol, for example https://us.i.posthog.com or https://eu.i.posthog.com
|
|
67
|
-
| personal_api_key | String | nil | Personal API key. Required for local feature flag evaluation and remote config payloads. |
|
|
68
|
-
| max_queue_size | Integer | 10000 | Maximum number of events to keep in the async queue before dropping new events. |
|
|
69
|
-
| batch_size | Integer | 100 | Maximum number of events to send in one async batch. |
|
|
70
|
-
| test_mode | Boolean | false | Keep events queued and do not send them. Useful for tests. |
|
|
71
|
-
| sync_mode | Boolean | false | Send events synchronously on the calling thread. Useful in forking environments like Sidekiq and Resque. |
|
|
72
|
-
| on_error | Proc | no-op | Callback called as on_error.call(status, error) for API or serialization errors. |
|
|
73
|
-
| feature_flags_polling_interval | Integer | 30 | Seconds between local feature flag definition polls. |
|
|
74
|
-
| feature_flag_request_timeout_seconds | Integer | 3 | Timeout, in seconds, for feature flag requests. |
|
|
75
|
-
| before_send | Proc | nil | Callback that receives the event hash before it is queued or sent. Return a modified event hash, or nil to drop the event. |
|
|
76
|
-
| disable_singleton_warning | Boolean | false | Suppress warnings about multiple clients with the same API key. Use only when you intentionally need multiple clients. |
|
|
77
|
-
| skip_ssl_verification | Boolean | false | Disable SSL certificate verification. Intended only for local development or custom deployments. |
|
|
78
|
-
| flag_definition_cache_provider | Object | nil | Provider for distributed feature flag definition caching. See [distributed flag definition caching](#distributed-flag-definition-caching). |
|
|
57
|
+
| `api_key` | String | **required** | Your PostHog project token. |
|
|
58
|
+
| `host` | String | `https://us.i.posthog.com` | Fully qualified PostHog API host. Include the protocol, for example `https://us.i.posthog.com` or `https://eu.i.posthog.com`. |
|
|
59
|
+
| `personal_api_key` | String | `nil` | Personal API key. Required for local feature flag evaluation and remote config payloads. |
|
|
60
|
+
| `max_queue_size` | Integer | `10000` | Maximum number of events to keep in the async queue before dropping new events. |
|
|
61
|
+
| `batch_size` | Integer | `100` | Maximum number of events to send in one async batch. |
|
|
62
|
+
| `test_mode` | Boolean | `false` | Keep events queued and do not send them. Useful for tests. |
|
|
63
|
+
| `sync_mode` | Boolean | `false` | Send events synchronously on the calling thread. Useful in forking environments like Sidekiq and Resque. |
|
|
64
|
+
| `on_error` | Proc | no-op | Callback called as `on_error.call(status, error)` for API or serialization errors. |
|
|
65
|
+
| `feature_flags_polling_interval` | Integer | `30` | Seconds between local feature flag definition polls. |
|
|
66
|
+
| `feature_flag_request_timeout_seconds` | Integer | `3` | Timeout, in seconds, for feature flag requests. |
|
|
67
|
+
| `before_send` | Proc | `nil` | Callback that receives the event hash before it is queued or sent. Return a modified event hash, or `nil` to drop the event. |
|
|
68
|
+
| `disable_singleton_warning` | Boolean | `false` | Suppress warnings about multiple clients with the same API key. Use only when you intentionally need multiple clients. |
|
|
69
|
+
| `skip_ssl_verification` | Boolean | `false` | Disable SSL certificate verification. Intended only for local development or custom deployments. |
|
|
70
|
+
| `flag_definition_cache_provider` | Object | `nil` | Provider for distributed feature flag definition caching. See [distributed flag definition caching](#distributed-flag-definition-caching). |
|
|
79
71
|
|
|
80
72
|
### Filtering or modifying events before sending
|
|
81
73
|
|
|
@@ -83,14 +75,13 @@ Use `before_send` to add, modify, or drop events immediately before the SDK queu
|
|
|
83
75
|
|
|
84
76
|
Ruby
|
|
85
77
|
|
|
86
|
-
PostHog AI
|
|
87
|
-
|
|
88
78
|
```ruby
|
|
89
79
|
posthog = PostHog::Client.new({
|
|
90
80
|
api_key: '<ph_project_token>',
|
|
91
81
|
before_send: Proc.new do |event|
|
|
92
82
|
event[:properties] ||= {}
|
|
93
83
|
event[:properties]['environment'] = ENV['RACK_ENV']
|
|
84
|
+
|
|
94
85
|
# Return nil to drop the event
|
|
95
86
|
event[:properties]['internal_user'] == true ? nil : event
|
|
96
87
|
end
|
|
@@ -103,8 +94,6 @@ For short-lived scripts, call `flush` before the process exits. Call `shutdown`
|
|
|
103
94
|
|
|
104
95
|
Ruby
|
|
105
96
|
|
|
106
|
-
PostHog AI
|
|
107
|
-
|
|
108
97
|
```ruby
|
|
109
98
|
posthog.capture({ distinct_id: 'user_123', event: 'script_finished' })
|
|
110
99
|
posthog.flush
|
|
@@ -121,8 +110,6 @@ Identify a user and set their person properties with `identify`:
|
|
|
121
110
|
|
|
122
111
|
Ruby
|
|
123
112
|
|
|
124
|
-
PostHog AI
|
|
125
|
-
|
|
126
113
|
```ruby
|
|
127
114
|
posthog.identify({
|
|
128
115
|
distinct_id: 'distinct_id_of_your_user',
|
|
@@ -139,8 +126,6 @@ You can send custom events using `capture`:
|
|
|
139
126
|
|
|
140
127
|
Ruby
|
|
141
128
|
|
|
142
|
-
PostHog AI
|
|
143
|
-
|
|
144
129
|
```ruby
|
|
145
130
|
posthog.capture({
|
|
146
131
|
distinct_id: 'distinct_id_of_the_user',
|
|
@@ -156,8 +141,6 @@ Optionally, you can include additional information with the event by including a
|
|
|
156
141
|
|
|
157
142
|
Ruby
|
|
158
143
|
|
|
159
|
-
PostHog AI
|
|
160
|
-
|
|
161
144
|
```ruby
|
|
162
145
|
posthog.capture({
|
|
163
146
|
distinct_id: 'distinct_id_of_the_user',
|
|
@@ -175,8 +158,6 @@ If you're aiming for a backend-only implementation of PostHog and won't be captu
|
|
|
175
158
|
|
|
176
159
|
Ruby
|
|
177
160
|
|
|
178
|
-
PostHog AI
|
|
179
|
-
|
|
180
161
|
```ruby
|
|
181
162
|
posthog.capture({
|
|
182
163
|
distinct_id: 'distinct_id_of_the_user',
|
|
@@ -191,24 +172,22 @@ posthog.capture({
|
|
|
191
172
|
|
|
192
173
|
| Field | Type | Description |
|
|
193
174
|
| --- | --- | --- |
|
|
194
|
-
| distinct_id | String | The user ID. If omitted, framework integrations can provide request context; otherwise the SDK generates a UUID and marks the event as personless. |
|
|
195
|
-
| event | String | Event name. Required. |
|
|
196
|
-
| properties | Hash | Event properties. |
|
|
197
|
-
| groups | Hash | Group analytics mapping from group type to group key. |
|
|
198
|
-
| timestamp | Time | When the event occurred. Defaults to the current time. |
|
|
199
|
-
| message_id | String | Optional message ID. |
|
|
200
|
-
| uuid | String | Optional event UUID used for deduplication. Must be a valid UUID. |
|
|
201
|
-
| flags | PostHog::FeatureFlagEvaluations | Snapshot returned by evaluate_flags
|
|
202
|
-
| send_feature_flags | Boolean, Hash, or PostHog::SendFeatureFlagsOptions | Deprecated. Prefer passing flags
|
|
175
|
+
| `distinct_id` | String | The user ID. If omitted, framework integrations can provide request context; otherwise the SDK generates a UUID and marks the event as personless. |
|
|
176
|
+
| `event` | String | Event name. Required. |
|
|
177
|
+
| `properties` | Hash | Event properties. |
|
|
178
|
+
| `groups` | Hash | Group analytics mapping from group type to group key. |
|
|
179
|
+
| `timestamp` | Time | When the event occurred. Defaults to the current time. |
|
|
180
|
+
| `message_id` | String | Optional message ID. |
|
|
181
|
+
| `uuid` | String | Optional event UUID used for deduplication. Must be a valid UUID. |
|
|
182
|
+
| `flags` | `PostHog::FeatureFlagEvaluations` | Snapshot returned by `evaluate_flags`. Adds `$feature/<key>` and `$active_feature_flags` properties without another `/flags` request. |
|
|
183
|
+
| `send_feature_flags` | Boolean, Hash, or `PostHog::SendFeatureFlagsOptions` | Deprecated. Prefer passing `flags:` from `evaluate_flags`. |
|
|
203
184
|
|
|
204
185
|
## Person profiles and properties
|
|
205
186
|
|
|
206
|
-
The Ruby SDK captures identified events by default. These create [person profiles](/docs/data/persons.md). To set [person properties](/docs/
|
|
187
|
+
The Ruby 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:
|
|
207
188
|
|
|
208
189
|
Ruby
|
|
209
190
|
|
|
210
|
-
PostHog AI
|
|
211
|
-
|
|
212
191
|
```ruby
|
|
213
192
|
posthog.capture({
|
|
214
193
|
distinct_id: 'distinct_id',
|
|
@@ -220,14 +199,12 @@ posthog.capture({
|
|
|
220
199
|
})
|
|
221
200
|
```
|
|
222
201
|
|
|
223
|
-
For more details on the difference between `$set` and `$set_once`, see our [person properties docs](/docs/
|
|
202
|
+
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).
|
|
224
203
|
|
|
225
204
|
To capture [anonymous events](/docs/data/anonymous-vs-identified-events.md) without person profiles, set the event's `$process_person_profile` property to `false`:
|
|
226
205
|
|
|
227
206
|
Ruby
|
|
228
207
|
|
|
229
|
-
PostHog AI
|
|
230
|
-
|
|
231
208
|
```ruby
|
|
232
209
|
posthog.capture({
|
|
233
210
|
distinct_id: 'distinct_id',
|
|
@@ -246,8 +223,6 @@ In this case, you can use `alias` to assign another distinct ID to the same user
|
|
|
246
223
|
|
|
247
224
|
Ruby
|
|
248
225
|
|
|
249
|
-
PostHog AI
|
|
250
|
-
|
|
251
226
|
```ruby
|
|
252
227
|
posthog.alias({
|
|
253
228
|
distinct_id: 'distinct_id',
|
|
@@ -255,7 +230,7 @@ posthog.alias({
|
|
|
255
230
|
})
|
|
256
231
|
```
|
|
257
232
|
|
|
258
|
-
We strongly recommend reading our docs on [alias](/docs/
|
|
233
|
+
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.
|
|
259
234
|
|
|
260
235
|
## Feature flags
|
|
261
236
|
|
|
@@ -271,10 +246,9 @@ Call `posthog.evaluate_flags()` once for the user, then read values from the ret
|
|
|
271
246
|
|
|
272
247
|
Ruby
|
|
273
248
|
|
|
274
|
-
PostHog AI
|
|
275
|
-
|
|
276
249
|
```ruby
|
|
277
250
|
flags = posthog.evaluate_flags('distinct_id_of_your_user')
|
|
251
|
+
|
|
278
252
|
if flags.enabled?('flag-key')
|
|
279
253
|
# Do something differently for this user
|
|
280
254
|
# Optional: fetch the payload
|
|
@@ -286,11 +260,11 @@ end
|
|
|
286
260
|
|
|
287
261
|
Ruby
|
|
288
262
|
|
|
289
|
-
PostHog AI
|
|
290
|
-
|
|
291
263
|
```ruby
|
|
292
264
|
flags = posthog.evaluate_flags('distinct_id_of_your_user')
|
|
265
|
+
|
|
293
266
|
enabled_variant = flags.get_flag('flag-key')
|
|
267
|
+
|
|
294
268
|
if enabled_variant == 'variant-key' # replace 'variant-key' with the key of your variant
|
|
295
269
|
# Do something differently for this user
|
|
296
270
|
# Optional: fetch the payload
|
|
@@ -316,13 +290,13 @@ Pass the same `flags` object that you used for branching. This attaches the exac
|
|
|
316
290
|
|
|
317
291
|
Ruby
|
|
318
292
|
|
|
319
|
-
PostHog AI
|
|
320
|
-
|
|
321
293
|
```ruby
|
|
322
294
|
flags = posthog.evaluate_flags('distinct_id_of_your_user')
|
|
295
|
+
|
|
323
296
|
if flags.enabled?('flag-key')
|
|
324
297
|
# Do something differently for this user
|
|
325
298
|
end
|
|
299
|
+
|
|
326
300
|
posthog.capture({
|
|
327
301
|
distinct_id: 'distinct_id_of_your_user',
|
|
328
302
|
event: 'event_name',
|
|
@@ -336,8 +310,6 @@ To reduce event property bloat, pass a filtered snapshot:
|
|
|
336
310
|
|
|
337
311
|
Ruby
|
|
338
312
|
|
|
339
|
-
PostHog AI
|
|
340
|
-
|
|
341
313
|
```ruby
|
|
342
314
|
# Attach only flags accessed with enabled?() or get_flag() before this call
|
|
343
315
|
posthog.capture({
|
|
@@ -345,6 +317,7 @@ posthog.capture({
|
|
|
345
317
|
event: 'event_name',
|
|
346
318
|
flags: flags.only_accessed,
|
|
347
319
|
})
|
|
320
|
+
|
|
348
321
|
# Attach only specific flags
|
|
349
322
|
posthog.capture({
|
|
350
323
|
distinct_id: 'distinct_id_of_your_user',
|
|
@@ -361,8 +334,6 @@ In the event properties, include `$feature/feature_flag_name: variant_key`:
|
|
|
361
334
|
|
|
362
335
|
Ruby
|
|
363
336
|
|
|
364
|
-
PostHog AI
|
|
365
|
-
|
|
366
337
|
```ruby
|
|
367
338
|
posthog.capture({
|
|
368
339
|
distinct_id: 'distinct_id_of_your_user',
|
|
@@ -380,8 +351,6 @@ By default, `evaluate_flags()` evaluates every flag for the user. If you only ne
|
|
|
380
351
|
|
|
381
352
|
Ruby
|
|
382
353
|
|
|
383
|
-
PostHog AI
|
|
384
|
-
|
|
385
354
|
```ruby
|
|
386
355
|
flags = posthog.evaluate_flags(
|
|
387
356
|
'distinct_id_of_your_user',
|
|
@@ -395,8 +364,6 @@ If you want to skip the remote `/flags` request and only use locally cached defi
|
|
|
395
364
|
|
|
396
365
|
Ruby
|
|
397
366
|
|
|
398
|
-
PostHog AI
|
|
399
|
-
|
|
400
367
|
```ruby
|
|
401
368
|
flags = posthog.evaluate_flags(
|
|
402
369
|
'distinct_id_of_your_user',
|
|
@@ -410,8 +377,6 @@ Pass `disable_geoip: true` to disable GeoIP lookup for remote flag evaluation:
|
|
|
410
377
|
|
|
411
378
|
Ruby
|
|
412
379
|
|
|
413
|
-
PostHog AI
|
|
414
|
-
|
|
415
380
|
```ruby
|
|
416
381
|
flags = posthog.evaluate_flags(
|
|
417
382
|
'distinct_id_of_your_user',
|
|
@@ -437,8 +402,6 @@ For example:
|
|
|
437
402
|
|
|
438
403
|
Ruby
|
|
439
404
|
|
|
440
|
-
PostHog AI
|
|
441
|
-
|
|
442
405
|
```ruby
|
|
443
406
|
flags = posthog.evaluate_flags(
|
|
444
407
|
'distinct_id_of_the_user',
|
|
@@ -458,6 +421,7 @@ flags = posthog.evaluate_flags(
|
|
|
458
421
|
},
|
|
459
422
|
},
|
|
460
423
|
)
|
|
424
|
+
|
|
461
425
|
if flags.enabled?('flag-key')
|
|
462
426
|
# Do something differently for this user
|
|
463
427
|
end
|
|
@@ -496,8 +460,6 @@ You can configure the `feature_flag_request_timeout_seconds` parameter when init
|
|
|
496
460
|
|
|
497
461
|
Ruby
|
|
498
462
|
|
|
499
|
-
PostHog AI
|
|
500
|
-
|
|
501
463
|
```ruby
|
|
502
464
|
posthog = PostHog::Client.new({
|
|
503
465
|
# rest of your configuration...
|
|
@@ -511,11 +473,11 @@ The following methods are still available during the migration period, but are d
|
|
|
511
473
|
|
|
512
474
|
| Method | Replacement |
|
|
513
475
|
| --- | --- |
|
|
514
|
-
| posthog.is_feature_enabled(flag_key, distinct_id, ...) | posthog.evaluate_flags(distinct_id, ...).enabled?(flag_key) |
|
|
515
|
-
| posthog.get_feature_flag(flag_key, distinct_id, ...) | posthog.evaluate_flags(distinct_id, ...).get_flag(flag_key) |
|
|
516
|
-
| posthog.get_feature_flag_payload(flag_key, distinct_id, ...) | posthog.evaluate_flags(distinct_id, ...).get_flag_payload(flag_key) |
|
|
517
|
-
| posthog.get_feature_flag_result(flag_key, distinct_id, ...) | posthog.evaluate_flags(distinct_id, ...) and read get_flag / get_flag_payload |
|
|
518
|
-
| posthog.capture({ ..., send_feature_flags: true }) | posthog.capture({ ..., flags: flags }) |
|
|
476
|
+
| `posthog.is_feature_enabled(flag_key, distinct_id, ...)` | `posthog.evaluate_flags(distinct_id, ...).enabled?(flag_key)` |
|
|
477
|
+
| `posthog.get_feature_flag(flag_key, distinct_id, ...)` | `posthog.evaluate_flags(distinct_id, ...).get_flag(flag_key)` |
|
|
478
|
+
| `posthog.get_feature_flag_payload(flag_key, distinct_id, ...)` | `posthog.evaluate_flags(distinct_id, ...).get_flag_payload(flag_key)` |
|
|
479
|
+
| `posthog.get_feature_flag_result(flag_key, distinct_id, ...)` | `posthog.evaluate_flags(distinct_id, ...)` and read `get_flag` / `get_flag_payload` |
|
|
480
|
+
| `posthog.capture({ ..., send_feature_flags: true })` | `posthog.capture({ ..., flags: flags })` |
|
|
519
481
|
|
|
520
482
|
### Local Evaluation
|
|
521
483
|
|
|
@@ -531,8 +493,6 @@ If you have `preload_app true` in your unicorn config, you can use the [`after_f
|
|
|
531
493
|
|
|
532
494
|
Ruby
|
|
533
495
|
|
|
534
|
-
PostHog AI
|
|
535
|
-
|
|
536
496
|
```ruby
|
|
537
497
|
after_fork do |_server, _worker|
|
|
538
498
|
$posthog = PostHog::Client.new({
|
|
@@ -550,8 +510,6 @@ If you use Puma with multiple workers, you can use the `on_worker_boot` hook (wh
|
|
|
550
510
|
|
|
551
511
|
Ruby
|
|
552
512
|
|
|
553
|
-
PostHog AI
|
|
554
|
-
|
|
555
513
|
```ruby
|
|
556
514
|
on_worker_boot do
|
|
557
515
|
$posthog = PostHog::Client.new({
|
|
@@ -574,8 +532,6 @@ end
|
|
|
574
532
|
|
|
575
533
|
Ruby
|
|
576
534
|
|
|
577
|
-
PostHog AI
|
|
578
|
-
|
|
579
535
|
```ruby
|
|
580
536
|
posthog = PostHog::Client.new({
|
|
581
537
|
api_key: '<ph_project_token>',
|
|
@@ -590,8 +546,6 @@ Use `get_remote_config_payload` to fetch the decrypted remote config payload for
|
|
|
590
546
|
|
|
591
547
|
Ruby
|
|
592
548
|
|
|
593
|
-
PostHog AI
|
|
594
|
-
|
|
595
549
|
```ruby
|
|
596
550
|
payload = posthog.get_remote_config_payload('flag-key')
|
|
597
551
|
```
|
|
@@ -602,11 +556,10 @@ Since [experiments](/docs/experiments/start-here.md) use feature flags, the code
|
|
|
602
556
|
|
|
603
557
|
Ruby
|
|
604
558
|
|
|
605
|
-
PostHog AI
|
|
606
|
-
|
|
607
559
|
```ruby
|
|
608
560
|
flags = posthog.evaluate_flags('user_distinct_id')
|
|
609
561
|
variant = flags.get_flag('experiment-feature-flag-key')
|
|
562
|
+
|
|
610
563
|
if variant == 'variant-name'
|
|
611
564
|
# Do something
|
|
612
565
|
end
|
|
@@ -624,8 +577,6 @@ Capture an event and associate it with a group:
|
|
|
624
577
|
|
|
625
578
|
Ruby
|
|
626
579
|
|
|
627
|
-
PostHog AI
|
|
628
|
-
|
|
629
580
|
```ruby
|
|
630
581
|
posthog.capture({
|
|
631
582
|
distinct_id: 'distinct_id_of_the_user',
|
|
@@ -644,8 +595,6 @@ Update properties on a group:
|
|
|
644
595
|
|
|
645
596
|
Ruby
|
|
646
597
|
|
|
647
|
-
PostHog AI
|
|
648
|
-
|
|
649
598
|
```ruby
|
|
650
599
|
posthog.group_identify({
|
|
651
600
|
group_type: 'company',
|
|
@@ -672,8 +621,6 @@ For non-Rails Ruby applications, you can manually capture exceptions with `captu
|
|
|
672
621
|
|
|
673
622
|
Ruby
|
|
674
623
|
|
|
675
|
-
PostHog AI
|
|
676
|
-
|
|
677
624
|
```ruby
|
|
678
625
|
begin
|
|
679
626
|
# Code that might raise an exception
|
|
@@ -693,17 +640,15 @@ The `capture_exception` method accepts the following parameters:
|
|
|
693
640
|
|
|
694
641
|
| Parameter | Type | Description |
|
|
695
642
|
| --- | --- | --- |
|
|
696
|
-
| exception | Exception
|
|
697
|
-
| distinct_id | String | The distinct ID of the user. Optional; request context can provide a default, otherwise the SDK generates a UUID. |
|
|
698
|
-
| additional_properties | Hash | Additional properties to attach to the exception event. Optional. |
|
|
699
|
-
| flags | PostHog::FeatureFlagEvaluations | Optional keyword argument. Adds the same feature flag properties as capture({ flags: flags })
|
|
643
|
+
| `exception` | `Exception`, `String`, or exception-like object | The exception to capture. Required. |
|
|
644
|
+
| `distinct_id` | `String` | The distinct ID of the user. Optional; request context can provide a default, otherwise the SDK generates a UUID. |
|
|
645
|
+
| `additional_properties` | `Hash` | Additional properties to attach to the exception event. Optional. |
|
|
646
|
+
| `flags` | `PostHog::FeatureFlagEvaluations` | Optional keyword argument. Adds the same feature flag properties as `capture({ flags: flags })`. |
|
|
700
647
|
|
|
701
648
|
You can also override the [fingerprint](/docs/error-tracking/fingerprints.md) to customize how exceptions are grouped into issues:
|
|
702
649
|
|
|
703
650
|
Ruby
|
|
704
651
|
|
|
705
|
-
PostHog AI
|
|
706
|
-
|
|
707
652
|
```ruby
|
|
708
653
|
posthog.capture_exception(
|
|
709
654
|
e,
|
|
@@ -720,8 +665,6 @@ The Ruby SDK logs warnings by default. You can change the log level to `DEBUG` t
|
|
|
720
665
|
|
|
721
666
|
Ruby
|
|
722
667
|
|
|
723
|
-
PostHog AI
|
|
724
|
-
|
|
725
668
|
```ruby
|
|
726
669
|
posthog.logger.level = Logger::DEBUG
|
|
727
670
|
```
|
|
@@ -730,8 +673,6 @@ You can also replace the SDK logger globally:
|
|
|
730
673
|
|
|
731
674
|
Ruby
|
|
732
675
|
|
|
733
|
-
PostHog AI
|
|
734
|
-
|
|
735
676
|
```ruby
|
|
736
677
|
PostHog::Logging.logger = Rails.logger
|
|
737
678
|
```
|
|
@@ -742,11 +683,10 @@ When `test_mode: true`, events remain queued. You can inspect and clear the queu
|
|
|
742
683
|
|
|
743
684
|
Ruby
|
|
744
685
|
|
|
745
|
-
PostHog AI
|
|
746
|
-
|
|
747
686
|
```ruby
|
|
748
687
|
posthog = PostHog::Client.new({ api_key: '<ph_project_token>', test_mode: true })
|
|
749
688
|
posthog.capture({ distinct_id: 'user_123', event: 'test_event' })
|
|
689
|
+
|
|
750
690
|
posthog.queued_messages
|
|
751
691
|
posthog.dequeue_last_message
|
|
752
692
|
posthog.clear
|
|
@@ -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
|
-
# Svelte
|
|
4
|
-
|
|
5
|
-
Copy page
|
|
6
|
-
|
|
7
|
-
# Svelte - Docs
|
|
3
|
+
# Svelte
|
|
8
4
|
|
|
9
5
|
PostHog makes it easy to get data about traffic and usage of your [Svelte](https://svelte.dev/) app. Integrating PostHog into your site enables analytics about user behavior, custom events capture, session recordings, feature flags, and more.
|
|
10
6
|
|
|
@@ -24,8 +20,6 @@ Or, to integrate manually, continue with the rest of this guide.
|
|
|
24
20
|
|
|
25
21
|
Install `posthog-js` using your package manager:
|
|
26
22
|
|
|
27
|
-
PostHog AI
|
|
28
|
-
|
|
29
23
|
### npm
|
|
30
24
|
|
|
31
25
|
```bash
|
|
@@ -52,8 +46,6 @@ bun add posthog-js
|
|
|
52
46
|
|
|
53
47
|
> **If your site sets a Content-Security-Policy**, it needs to allow PostHog. This applies to the snippet and to package installs alike: the SDK lazy-loads extra bundles (session replay, surveys) from PostHog's CDN, and sends events to the ingestion host. PostHog serves from subdomains of `posthog.com` that change over time, so allow the wildcard:
|
|
54
48
|
>
|
|
55
|
-
> PostHog AI
|
|
56
|
-
>
|
|
57
49
|
> ```
|
|
58
50
|
> script-src 'self' https://*.posthog.com;
|
|
59
51
|
> connect-src 'self' https://*.posthog.com;
|
|
@@ -66,11 +58,10 @@ Then, if you haven't created a root [layout](https://kit.svelte.dev/docs/routing
|
|
|
66
58
|
|
|
67
59
|
routes/+layout.js
|
|
68
60
|
|
|
69
|
-
PostHog AI
|
|
70
|
-
|
|
71
61
|
```javascript
|
|
72
62
|
import posthog from 'posthog-js'
|
|
73
63
|
import { browser } from '$app/environment';
|
|
64
|
+
|
|
74
65
|
export const load = async () => {
|
|
75
66
|
if (browser) {
|
|
76
67
|
posthog.init('<ph_project_token>', {
|
|
@@ -78,6 +69,7 @@ export const load = async () => {
|
|
|
78
69
|
defaults: '2026-05-30',
|
|
79
70
|
})
|
|
80
71
|
}
|
|
72
|
+
|
|
81
73
|
return
|
|
82
74
|
};
|
|
83
75
|
```
|
|
@@ -96,8 +88,6 @@ If your app calls your own backend, `tracing_headers` adds `X-POSTHOG-DISTINCT-I
|
|
|
96
88
|
|
|
97
89
|
JavaScript
|
|
98
90
|
|
|
99
|
-
PostHog AI
|
|
100
|
-
|
|
101
91
|
```javascript
|
|
102
92
|
posthog.init('<ph_project_token>', {
|
|
103
93
|
api_host: 'https://us.i.posthog.com',
|
|
@@ -134,14 +124,16 @@ For certain features like [heatmaps](/docs/toolbar/heatmaps.md), your Web Applic
|
|
|
134
124
|
|
|
135
125
|
**US**: `44.205.89.55`, `52.4.194.122`, `44.208.188.173`
|
|
136
126
|
|
|
137
|
-
These are public, stable IPs used by PostHog services
|
|
127
|
+
These are public, stable IPs used by PostHog services.
|
|
128
|
+
|
|
129
|
+
PostHog captures heatmap screenshots using [Browserless](https://www.browserless.io), which has its own IP addresses. Browserless [publishes the current list here](https://docs.browserless.io/baas/troubleshooting/whitelisting-ips).
|
|
130
|
+
|
|
131
|
+
An allowlist does not help when your app has a private address. For apps on an internal network, see [internal and intranet applications](/docs/session-replay/troubleshooting.md#internal-and-intranet-applications).
|
|
138
132
|
|
|
139
133
|
## Server-side setup
|
|
140
134
|
|
|
141
135
|
Install `posthog-node` using your package manager:
|
|
142
136
|
|
|
143
|
-
PostHog AI
|
|
144
|
-
|
|
145
137
|
### npm
|
|
146
138
|
|
|
147
139
|
```bash
|
|
@@ -170,16 +162,17 @@ Then, initialize the PostHog Node client where you'd like to use it on the serve
|
|
|
170
162
|
|
|
171
163
|
routes/+page.server.js
|
|
172
164
|
|
|
173
|
-
PostHog AI
|
|
174
|
-
|
|
175
165
|
```javascript
|
|
176
166
|
import { PostHog } from 'posthog-node';
|
|
167
|
+
|
|
177
168
|
export async function load() {
|
|
178
169
|
const posthog = new PostHog('<ph_project_token>', { host: 'https://us.i.posthog.com' });
|
|
170
|
+
|
|
179
171
|
posthog.capture({
|
|
180
172
|
distinctId: 'distinct_id_of_the_user',
|
|
181
173
|
event: 'event_name',
|
|
182
174
|
})
|
|
175
|
+
|
|
183
176
|
await posthog.shutdown()
|
|
184
177
|
}
|
|
185
178
|
```
|
|
@@ -192,20 +185,21 @@ To use client-side feature flags, import PostHog into your Svelte component and
|
|
|
192
185
|
|
|
193
186
|
routes/+page.svelte
|
|
194
187
|
|
|
195
|
-
PostHog AI
|
|
196
|
-
|
|
197
188
|
```javascript
|
|
198
189
|
<script>
|
|
199
190
|
import posthog from 'posthog-js'
|
|
200
191
|
import { browser } from '$app/environment'
|
|
201
192
|
import { onMount } from 'svelte'
|
|
193
|
+
|
|
202
194
|
let coolFeature = $state(false)
|
|
195
|
+
|
|
203
196
|
onMount(() => {
|
|
204
197
|
if (browser) {
|
|
205
198
|
coolFeature = posthog.isFeatureEnabled('cool-feature')
|
|
206
199
|
}
|
|
207
200
|
})
|
|
208
201
|
</script>
|
|
202
|
+
|
|
209
203
|
{#if coolFeature}
|
|
210
204
|
<p>Welcome to the cool feature!</p>
|
|
211
205
|
{/if}
|
|
@@ -215,20 +209,22 @@ To use server-side feature flags, import PostHog into your SvelteKit `load` func
|
|
|
215
209
|
|
|
216
210
|
routes/+page.server.js
|
|
217
211
|
|
|
218
|
-
PostHog AI
|
|
219
|
-
|
|
220
212
|
```javascript
|
|
221
213
|
import { PostHog } from 'posthog-node';
|
|
214
|
+
|
|
222
215
|
const client = new PostHog(
|
|
223
216
|
'<ph_project_token>',
|
|
224
217
|
{ host: 'https://us.i.posthog.com' }
|
|
225
218
|
);
|
|
219
|
+
|
|
226
220
|
export async function load() {
|
|
227
221
|
const distinctId = 'distinct_id_of_the_user';
|
|
222
|
+
|
|
228
223
|
const megaFeature = await client.isFeatureEnabled(
|
|
229
224
|
'mega-feature',
|
|
230
225
|
distinctId
|
|
231
226
|
);
|
|
227
|
+
|
|
232
228
|
return {
|
|
233
229
|
megaFeature
|
|
234
230
|
};
|
|
@@ -245,8 +241,6 @@ To fix this, set the config to not use relative paths in `svelte.config.js`:
|
|
|
245
241
|
|
|
246
242
|
JavaScript
|
|
247
243
|
|
|
248
|
-
PostHog AI
|
|
249
|
-
|
|
250
244
|
```javascript
|
|
251
245
|
kit: {
|
|
252
246
|
paths: {
|