TurboJet
Analytics

Overview

Track page views and custom events with PostHog via @repo/analytics.

TurboJet ships a small analytics package that integrates PostHog for page views and custom events on the marketing and docs apps.

Helpers live in @repo/analytics (and @repo/analytics/client). There is no multi-provider switch — PostHog is the only backend today.

How it loads

Each app initializes PostHog from Next.js client instrumentation:

apps/marketing/src/instrumentation-client.ts
import { initPostHogClient } from "@repo/analytics/client";

initPostHogClient();

The docs app does the same in apps/docs/src/instrumentation-client.ts. When PostHog is active, initPostHogClient enables automatic pageview and pageleave capture.

Client only

Do not import @repo/analytics/client from edge or server instrumentation. Helpers no-op when PostHog is disabled or the project token is empty.

Track custom events

Import captureEvent and call it from client code:

import { captureEvent } from "@repo/analytics";

export function YourComponent() {
	return (
		<button
			type="button"
			onClick={() => captureEvent("button-clicked", { value: "asdf" })}
		>
			Click me
		</button>
	);
}
ArgumentDescription
eventEvent name (string)
propertiesOptional object of extra event data

Identify users

When a user signs in, call identifyUser. On sign-out, call resetUser:

import { identifyUser, resetUser } from "@repo/analytics";

identifyUser({ id: user.id, email: user.email, name: user.name });
// ...
resetUser();

These helpers are exported from @repo/analytics but are not wired into auth UI by default — call them from your session lifecycle when you need person profiles.

Setup

Env keys and feature flag details are in Environment. Provider walkthrough:

On this page