---
name: bijection-posthog
description: "Evaluate and integrate the PostHog component with Bijection."
---

# PostHog

Product analytics and feature flags

- Package: @bijectionhq/posthog
- Category: Analytics
- Status: Preview
- License: MIT
- Bijection source (repository access required): https://github.com/bijectionhq/posthog/tree/5fcadbc07c351596f783d27070d556a46658de67/packages/convex
- Upstream: https://github.com/PostHog/posthog-js/tree/3ddaa65402896c91dcb7b04cfe433e0b1d2f3313/packages/convex
- Documentation: https://docs.bijection.com/components/using
- Directory: https://bijection.com/components/posthog

## Get the source

Bijection repository access is required. Request access at https://bijection.com/contact.

```sh
git clone https://github.com/bijectionhq/posthog.git
cd posthog
git checkout 5fcadbc07c351596f783d27070d556a46658de67
cd packages/convex
```

## Before using this component

Read the package README at the recorded revision for setup, dependencies, and API examples. Upstream documentation describes the original package and may differ from the Bijection adaptation. This is a source candidate for evaluation. Catalog inclusion does not establish npm availability or runtime qualification. Check compatibility with your SDK and deployment before adoption. External providers run their own compute.

## Integration workflow

1. Read the source README and package manifest at the recorded revision.
2. Confirm the required SDK, dependency availability, and runtime compatibility.
3. Follow the component's documented setup and configuration. Never invent an npm install command from a catalog package name.
4. Keep credentials in the project's existing secret store.
5. Follow the project's execution rules for verification and report what was actually checked.

## Original upstream skill

The following guidance describes @posthog/convex. Its installation commands and APIs refer to the upstream package. Evaluate compatibility with the Bijection source separately.


> Agents: read this skill fully before writing code that uses PostHog. Follow the installation and configuration steps exactly.

# PostHog

## Instructions

The PostHog Convex package integrates PostHog analytics and feature flags directly into your Convex backend. It enables event tracking, product analytics, and feature flag evaluation from within Convex functions without requiring client-side instrumentation for backend events. This is the official PostHog library for Convex, maintained by the PostHog team.

### Installation

```bash
npm install @posthog/convex
```

Current npm version: `@posthog/convex@2.1.5`

## Use cases

- Tracking server-side events from Convex mutations and actions, such as user signups, purchases, or data changes, without relying on client-side tracking
- Evaluating PostHog feature flags inside Convex functions to gate backend logic or return different data based on flag state
- Capturing analytics for LLM or AI workflows running in Convex actions, where client-side SDKs cannot reach
- Sending structured logs and error tracking data from Convex backend functions to PostHog for observability
- Instrumenting multi-step backend pipelines with product analytics events to understand funnel performance at the server level

## How it works

Install the package with `npm install @posthog/convex` and configure it with your PostHog project API key. The library is designed to be used inside Convex functions, including queries, mutations, and actions, giving you access to PostHog's event capture and feature flag APIs from the server context.

Feature flag evaluation and event capture happen via the PostHog API, which means actions are the appropriate function type when network calls are required, since Convex queries and mutations cannot perform arbitrary fetch requests. The package abstracts the PostHog API surface so you can call it using familiar PostHog SDK patterns without managing HTTP requests manually.

Full SDK usage examples and configuration options are maintained in the official PostHog documentation at posthog.com/docs/libraries/convex, which is kept up to date alongside the package. A working demo is available at the linked example in the PostHog monorepo.

## When NOT to use

- When a simpler built-in solution exists for your specific use case
- If you are not using Convex as your backend
- When the functionality provided by PostHog is not needed

## Resources

- [npm package](https://www.npmjs.com/package/%40posthog%2Fconvex)
- [GitHub repository](https://github.com/PostHog/posthog-js/tree/main/packages/convex)
- [Live demo](https://github.com/PostHog/posthog-js/tree/main/examples/example-convex)
- [Convex Components Directory](https://www.convex.dev/components/posthog/convex)
- [Convex documentation](https://docs.convex.dev)