Omnibus Instrument Integration
PostHogOfficialCreated by PostHog
- Skill
- Tool integration
- Data and AI
- MIT
- Low risk
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured, multi-step procedure for integrating the PostHog SDK into a wide variety of software projects. It guides the agent through detecting the project's framework, installing the appropriate SDK, initializing the client, and configuring environment variables. By leveraging a library of framework-specific reference files, the skill ensures that PostHog is implemented according to best practices for each supported platform, including web, mobile, and backend environments.
What it does
- Detects the project's framework and package manager automatically.
- Installs the correct PostHog SDK for the identified platform.
- Initializes the PostHog client using framework-specific patterns.
- Configures environment variables for API keys and host settings.
- Implements user identification logic for login and signup events.
- Verifies the integration and performs necessary cleanup.
When to use it
- When setting up PostHog in a project for the first time.
- When reviewing pull requests that require PostHog initialization.
- When migrating or adding analytics to an existing codebase.
- When you need to ensure PostHog is configured consistently across different frameworks.
Advantages
- Supports a broad range of frameworks and languages.
- Ensures secure configuration by enforcing the use of environment variables.
- Maintains consistency with existing codebase patterns.
- Reduces manual effort by automating SDK installation and boilerplate setup.
Usage examples
- “Add PostHog to my new Next.js project.”
- The agent will detect the Next.js framework, install the PostHog SDK, and provide the necessary initialization code in the appropriate file, such as instrumentation-client.ts.
- “Help me set up PostHog in our Android app.”
- The agent will identify the Android environment, guide the setup in the Application class, and configure the PostHog instance with the required API keys.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/posthog/omnibus-instrument-integration/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip omnibus-instrument-integration.zip -d .agents/skills
Documentation by PostHog
Add PostHog SDK integration
Use this skill to add the PostHog SDK to an application. Use it when setting up PostHog for the first time, or reviewing PRs that need PostHog initialization. Covers SDK installation, provider setup, and basic configuration. Supports any framework or language.
Supported frameworks: Next.js, React, React Router, Vue, Nuxt, TanStack Start, SvelteKit, Astro, Angular, Django, Flask, FastAPI, Laravel, Ruby on Rails, Android, Swift, React Native, Expo, Node.js, and vanilla JavaScript.
Instructions
Follow these steps IN ORDER:
STEP 1: Analyze the codebase and detect the platform.
Look for dependency files (package.json, requirements.txt, Gemfile, composer.json, go.mod, etc.) to determine the framework and language.
Look for lockfiles (pnpm-lock.yaml, package-lock.json, yarn.lock, bun.lockb) to determine the package manager.
Check for existing PostHog setup. If PostHog is already installed and initialized, do not modify its code. Inform the user and skip to verification.
STEP 2: Research integration. 2.1. Find the reference file below that matches the detected framework — it is the source of truth for SDK initialization, provider setup, and configuration patterns. Read it now. 2.2. If no reference matches, fall back to your general knowledge and web search. Use posthog.com/docs as the primary search source.
STEP 3: Install the PostHog SDK.
Add the PostHog SDK package for the detected platform. Do not manually edit package.json — use the package manager's install command.
Always install packages as a background task. Don't await completion; proceed with other work immediately after starting the installation.
STEP 4: Initialize PostHog.
Follow the framework reference for where and how to initialize. This varies significantly by framework (e.g., instrumentation-client.ts for Next.js 15.3+, AppConfig.ready() for Django, create_app() for Flask).
Set up the PostHog provider/wrapper component if the framework requires one.
STEP 5: Identify users.
Add PostHog
identify()calls on the client side during login and signup events.If both frontend and backend exist, pass the client-side session and distinct ID using
X-POSTHOG-DISTINCT-IDandX-POSTHOG-SESSION-IDheaders to the server-side code.
STEP 6: Set up environment variables.
Store the PostHog API key and host in environment variables (e.g.
.envor framework-specific env files).Reference these environment variables in code instead of hardcoding them.
STEP 7: Verify and clean up.
Check the project for errors. Look for type checking or build scripts in package.json.
Ensure any components created were actually used.
Run any linter or prettier-like scripts found in the package.json.
Reference files
references/EXAMPLE-next-app-router.md- next-app-router example project codereferences/EXAMPLE-next-pages-router.md- next-pages-router example project codereferences/EXAMPLE-react-react-router-6.md- react-react-router-6 example project codereferences/EXAMPLE-react-react-router-7-framework.md- react-react-router-7-framework example project codereferences/EXAMPLE-react-react-router-7-data.md- react-react-router-7-data example project codereferences/EXAMPLE-react-react-router-7-declarative.md- react-react-router-7-declarative example project codereferences/EXAMPLE-react-vite.md- react-vite example project codereferences/EXAMPLE-nuxt-3.6.md- nuxt-3.6 example project codereferences/EXAMPLE-nuxt-4.md- nuxt-4 example project codereferences/EXAMPLE-vue-3.md- vue-3 example project codereferences/EXAMPLE-react-tanstack-router-file-based.md- react-tanstack-router-file-based example project codereferences/EXAMPLE-react-tanstack-router-code-based.md- react-tanstack-router-code-based example project codereferences/EXAMPLE-tanstack-start.md- tanstack-start example project codereferences/EXAMPLE-sveltekit.md- sveltekit example project codereferences/EXAMPLE-astro-static.md- astro-static example project codereferences/EXAMPLE-astro-view-transitions.md- astro-view-transitions example project codereferences/EXAMPLE-astro-ssr.md- astro-ssr example project codereferences/EXAMPLE-astro-hybrid.md- astro-hybrid example project codereferences/EXAMPLE-angular.md- angular example project codereferences/EXAMPLE-javascript-node.md- javascript-node example project codereferences/EXAMPLE-javascript-web.md- javascript-web example project codereferences/EXAMPLE-django.md- django example project codereferences/EXAMPLE-flask.md- flask example project codereferences/EXAMPLE-fastapi.md- fastapi example project codereferences/EXAMPLE-python.md- python example project codereferences/EXAMPLE-laravel.md- laravel example project codereferences/EXAMPLE-ruby-on-rails.md- ruby-on-rails example project codereferences/EXAMPLE-ruby.md- ruby example project codereferences/EXAMPLE-android.md- android example project codereferences/EXAMPLE-swift.md- swift example project codereferences/EXAMPLE-react-native.md- react-native example project codereferences/EXAMPLE-expo.md- expo example project codereferences/next-js.md- Next.js - docsreferences/react.md- React - docsreferences/react-router-v6.md- React router v6 - docsreferences/react-router-v7-framework-mode.md- React router v7 framework mode (remix v3) - docsreferences/react-router-v7-data-mode.md- React router v7 data mode - docsreferences/react-router-v7-declarative-mode.md- React router v7 declarative mode - docsreferences/nuxt-js-3-6.md- Nuxt.js (v3.0 to v3.6) - docsreferences/nuxt-js.md- Nuxt.js - docsreferences/vue-js.md- Vue.js - docsreferences/tanstack-start.md- Tanstack start - docsreferences/svelte.md- Svelte - docsreferences/astro.md- Astro - docsreferences/angular.md- Angular - docsreferences/js.md- JavaScript web - docsreferences/posthog-js.md- PostHog JavaScript web SDKreferences/node.md- Node.js - docsreferences/posthog-node.md- PostHog Node.js SDKreferences/django.md- Django - docsreferences/flask.md- Flask - docsreferences/python.md- Python - docsreferences/posthog-python.md- PostHog python SDKreferences/laravel.md- Laravel - docsreferences/ruby-on-rails.md- Ruby on rails - docsreferences/ruby.md- Ruby - docsreferences/android.md- Android - docsreferences/ios.md- Ios - docsreferences/react-native.md- React native - docsreferences/identify-users.md- Identify users - docs
Each framework reference contains SDK-specific installation, initialization, and usage patterns. Find the one matching the user's stack.
Key principles
Environment variables: Always use environment variables for PostHog keys. Never hardcode them.
Minimal changes: Add PostHog code alongside existing integrations. Don't replace or restructure existing code.
Match the example: Your implementation should follow the example project's patterns as closely as possible.
Analytics contract: Treat event names, property names, and feature flag keys as part of an analytics contract. Reuse existing names and patterns found in the project. When introducing new ones, make them clear, descriptive, and consistent with existing conventions.
Files
- ATTRIBUTION.mdAdded by AutoGineer998 B
- LICENSELicence file added by AutoGineer1.0 KiB
- SKILL.md7.6 KiB
- references/EXAMPLE-android.md49.7 KiB
- references/EXAMPLE-angular.md23.4 KiB
- references/EXAMPLE-astro-hybrid.md26.8 KiB
- references/EXAMPLE-astro-ssr.md26.7 KiB
- references/EXAMPLE-astro-static.md19.4 KiB
- references/EXAMPLE-astro-view-transitions.md23.1 KiB
- references/EXAMPLE-django.md30.0 KiB
- references/EXAMPLE-expo.md35.5 KiB
- references/EXAMPLE-fastapi.md40.9 KiB
- references/EXAMPLE-flask.md32.0 KiB
- references/EXAMPLE-javascript-node.md9.0 KiB
- references/EXAMPLE-javascript-web.md11.7 KiB
- references/EXAMPLE-laravel.md59.5 KiB
- references/EXAMPLE-next-app-router.md17.3 KiB
- references/EXAMPLE-next-pages-router.md18.9 KiB
- references/EXAMPLE-nuxt-3.6.md22.1 KiB
- references/EXAMPLE-nuxt-4.md28.7 KiB
- references/EXAMPLE-python.md11.6 KiB
- references/EXAMPLE-react-native.md46.4 KiB
- references/EXAMPLE-react-react-router-6.md13.5 KiB
- references/EXAMPLE-react-react-router-7-data.md20.1 KiB
- references/EXAMPLE-react-react-router-7-declarative.md15.0 KiB
- references/EXAMPLE-react-react-router-7-framework.md32.2 KiB
- references/EXAMPLE-react-tanstack-router-code-based.md19.2 KiB
- references/EXAMPLE-react-tanstack-router-file-based.md18.0 KiB
- references/EXAMPLE-react-vite.md12.4 KiB
- references/EXAMPLE-ruby-on-rails.md37.6 KiB
- references/EXAMPLE-ruby.md10.3 KiB
- references/EXAMPLE-sveltekit.md18.4 KiB
- references/EXAMPLE-swift.md18.6 KiB
- references/EXAMPLE-tanstack-start.md28.4 KiB
- references/EXAMPLE-vue-3.md17.9 KiB
- references/android.md21.7 KiB
- references/angular.md12.5 KiB
- references/astro.md8.3 KiB
- references/django.md6.7 KiB
- references/flask.md2.9 KiB
- references/identify-users.md8.1 KiB
- references/ios.md5.4 KiB
- references/js.md12.3 KiB
- references/laravel.md2.1 KiB
- references/next-js.md12.5 KiB
- references/node.md28.8 KiB
- references/nuxt-js-3-6.md6.6 KiB
- references/nuxt-js.md7.2 KiB
- references/posthog-js.md42.3 KiB
- references/posthog-node.md23.4 KiB
- references/posthog-python.md31.3 KiB
- references/python.md31.1 KiB
- references/react-native.md43.8 KiB
- references/react-router-v6.md11.6 KiB
- references/react-router-v7-data-mode.md11.4 KiB
- references/react-router-v7-declarative-mode.md11.6 KiB
- references/react-router-v7-framework-mode.md14.9 KiB
- references/react.md18.5 KiB
- references/ruby-on-rails.md10.6 KiB
- references/ruby.md18.9 KiB
- references/svelte.md7.2 KiB
- references/tanstack-start.md5.1 KiB
- references/vue-js.md9.1 KiB
references/vue-js.md
Vue.js - Docs
PostHog makes it easy to get data about usage of your Vue.js app. Integrating PostHog into your app enables analytics about user behavior, custom events capture, session replays, feature flags, and more.
This guide walks you through integrating PostHog into your app for both Vue 2 and Vue 3. We'll use the JavaScript Web SDK for this.
For integrating PostHog into a Nuxt.js app, see our Nuxt guide.
Prerequisites
To follow this guide along, you need:
A running Vue.js app
Setting up PostHog
Start by installing posthog-js using your package manager:
PostHog AI
npm
npm install --save posthog-jsYarn
yarn add posthog-jspnpm
pnpm add posthog-jsBun
bun add posthog-jsNext, depending on your Vue version, we recommend initializing PostHog using the composition API or as a plugin.
Vue 3: Composition API
We use the Composition API as it provides better accessibility, maintainability, and type safety.
PostHog initializes as a singleton, so you can initialize it in your main.ts file before you mount your app. This ensures PostHog is initialized before any other code runs.
src/main.ts
PostHog AI
// src/main.ts
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import router from './router'
import posthog from "posthog-js";
const app = createApp(App);
posthog.init(import.meta.env.VITE_POSTHOG_TOKEN || '<ph_project_token>', {
api_host: import.meta.env.VITE_POSTHOG_HOST || 'https://us.i.posthog.com',
defaults: '2026-01-30',
});
app.use(createPinia())
app.use(router)
app.config.errorHandler = (err, instance, info) => {
posthog.captureException(err)
}
app.mount('#app')Then, you can access PostHog throughout your app just by importing it from posthog-js.
TypeScript
PostHog AI
// src/App.vue
<script setup>
import posthog from 'posthog-js'
const handleClick = () => {
posthog.capture('button_clicked')
}
</script>Once done, PostHog will begin autocapturing events and pageviews (if enabled) and is ready to use throughout your app.
Vue 2: Plugins
Start by creating a plugins folder and adding a posthog.js file to that folder. In posthog.js, initialize PostHog using the install method with your project token and host. You can find these in your project settings.
JavaScript
PostHog AI
// src/plugins/posthog.js
import posthog from 'posthog-js'
export default {
install(Vue) {
posthog.init('<ph_project_token>', {
api_host: 'https://us.i.posthog.com',
defaults: '2026-01-30'
})
Vue.prototype.$posthog = posthog
}
}Next, in main.js, import and use the plugin.
JavaScript
PostHog AI
// src/main.js
import Vue from 'vue'
import App from './App.vue'
import PosthogPlugin from './plugins/posthog'
Vue.config.productionTip = false
Vue.use(PosthogPlugin)
new Vue({
render: h => h(App),
}).$mount('#app')This makes PostHog available as this.$posthog in any Vue component.
Identifying users
Identifying users is required. Call
posthog.identify('your-user-id')after login to link events to a known user. This is what connects frontend event captures, session replays, LLM traces, and error tracking to the same person — and lets backend events link back too.See our guide on identifying users for how to set this up.
Capturing custom events, using feature flags, and more
Once you have PostHog initialized, there is a lot more you can do with it beyond autocapture, pageviews, and pageleaves. You can find the full details in our JavaScript SDK docs, but we'll cover a few examples here.
Vue 3: Composition API
To capture custom events, evaluate feature flags, and use any of the other PostHog features, you can use the posthog object returned from the usePostHog composable like this:
JavaScript
PostHog AI
// src/App.vue
<script setup>
import { RouterView } from 'vue-router'
import { usePostHog } from './composables/usePostHog'
const { posthog } = usePostHog()
const handleClick = () => {
posthog.capture('button_clicked', { location: 'homepage' })
}
</script>
<template>
<div>
<button @click="handleClick">Click me!</button>
</div>
<RouterView />
</template>Feature flags with reactive updates
When using feature flags on pages that users navigate to directly, the flags may not be loaded when the component first renders. To ensure your UI updates reactively when flags load, create a composable that returns a reactive ref:
JavaScript
PostHog AI
// src/composables/usePostHogFeatureFlag.ts
import { ref, type Ref } from 'vue'
import { usePostHog } from './usePostHog'
export function usePostHogFeatureFlag(
feature: string,
): Ref<string | boolean | undefined> {
const { posthog } = usePostHog()
const flag = ref(posthog.getFeatureFlag(feature))
posthog.onFeatureFlags(() => {
flag.value = posthog.getFeatureFlag(feature)
})
return flag
}Then use it in your components:
JavaScript
PostHog AI
// src/App.vue
<script setup>
import { RouterView } from 'vue-router'
import { usePostHog } from './composables/usePostHog'
import { usePostHogFeatureFlag } from './composables/usePostHogFeatureFlag'
const { posthog } = usePostHog()
const isFeatureEnabled = usePostHogFeatureFlag('test-flag')
const handleClick = () => {
posthog.capture('button_clicked', { location: 'homepage' })
}
</script>
<template>
<div>
<button @click="handleClick">Click me!</button>
<p>Is feature flag enabled? {{ isFeatureEnabled ? 'Yes' : 'No' }}</p>
</div>
<RouterView />
</template>This ensures your component will automatically update when feature flags load, even if the page is accessed directly.
Vue 2: Plugins
To capture custom events, evaluate feature flags, and use any of the other PostHog features, you can use the $posthog object returned from the plugin like this:
JavaScript
PostHog AI
// src/components/AboutPage.vue
<template>
<div class="about">
<h1>About Page</h1>
<button @click="handleClick">Test PostHog</button>
<router-link to="/">Go to Home</router-link>
<p>Feature enabled? {{ isFeatureEnabled ? 'Yes' : 'No' }}</p>
</div>
</template>
<script>
export default {
name: 'AboutPage',
data() {
return {
isFeatureEnabled: false
}
},
created() {
this.isFeatureEnabled = this.$posthog.isFeatureEnabled('test-flag')
},
methods: {
handleClick() {
this.$posthog.capture('button_clicked')
}
}
}
</script>Set up a reverse proxy (recommended)
We recommend setting up a reverse proxy, so that events are less likely to be intercepted by tracking blockers.
We have our own managed reverse proxy service, which is free for all PostHog Cloud users, routes through our infrastructure, and makes setting up your proxy easy.
If you don't want to use our managed service then there are several other options for creating a reverse proxy, including using Cloudflare, AWS Cloudfront, and Vercel.
Grouping products in one project (recommended)
If you have multiple customer-facing products (e.g. a marketing website + mobile app + web app), it's best to install PostHog on them all and group them in one project.
This makes it possible to track users across their entire journey (e.g. from visiting your marketing website to signing up for your product), or how they use your product across multiple platforms.
Add IPs to Firewall/WAF allowlists (recommended)
For certain features like heatmaps, your Web Application Firewall (WAF) may be blocking PostHog’s requests to your site. Add these IP addresses to your WAF allowlist or rules to let PostHog access your site.
EU: 3.75.65.221, 18.197.246.42, 3.120.223.253
US: 44.205.89.55, 52.4.194.122, 44.208.188.173
These are public, stable IPs used by PostHog services (e.g., Celery tasks for snapshots).
Next steps
For any technical questions for how to integrate specific PostHog features into Vue (such as analytics, feature flags, A/B testing, or surveys), have a look at our JavaScript Web SDK docs.
Alternatively, the following tutorials can help you get started:
Community questions
Ask a question
Was this page useful?
HelpfulCould be better
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs an API key, Needs Python, Needs Node.js
Security
What our scanner noticed· Low risk
- Instructions that use the network
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- PostHog
- Publisher
- PostHog (Official)
- Source
- PostHog/skills · skills/posthog/all/skills/omnibus-instrument-integration · commit a5d30e7
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by PostHog or PostHog.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download omnibus-instrument-integration.zip