Contents

Getting started

Requirements

 1# Install PostHog CLI globally
 2cargo install posthog-cli

From the project root directory:

 1# Install deps
 2pnpm install
 3
 4# Build local version of posthog-js
 5pnpm run build-posthog

Sourcemaps management

Commands to test sourcemap upload:

 1# Generate build artifacts and use posthog-cli to inject snippets into sources and sourcemaps
 2VITE_POSTHOG_KEY='<your-project-key>' VITE_POSTHOG_HOST='http://localhost:8010' pnpm run build
 3
 4# For NextJS based app use
 5NEXT_PUBLIC_POSTHOG_KEY='<your-project-key>' NEXT_PUBLIC_POSTHOG_HOST='http://localhost:8010' pnpm run build
 6
 7# Use posthog-cli to inject snippets into sources and sourcemaps
 8pnpm run inject
 9
10# Upload sourcemaps to PostHog
11pnpm run upload
12
13# Run application locally with newly generated minified build and sourcemaps
14# Start sending exceptions to PostHog
15pnpm run preview