PostHog

PostHog is an all-in-one platform for product analytics, session replays, and feature flags. It is unique because it can be self-hosted and offers deep, “autocapture” capabilities for web applications.

How I Set It Up

I integrated PostHog into my Digital Brain using a “PostHog Agent” (Wizard). This was a multi-layer integration covering both the backend build process and the frontend user experience.

1. The Build & CLI Layer (Server-Side)

The posthog-node SDK was instrumented into the core Quartz logic:

  • Build Monitoring: Tracks successful and failed builds in quartz/build.ts.
  • CLI Telemetry: Tracks sync and update commands in quartz/cli/handlers.js.
  • Environment: Managed via POSTHOG_API_KEY and POSTHOG_HOST variables.

2. The User Layer (Client-Side)

Enabled via quartz.config.ts to track public visitors on Cloudflare:

  • Page Views: Monitors which notes are most read.
  • Session Replays: Allows for visual debugging of the user journey.
  • Autocapture: Records clicks on UI elements like the Graph View.

Technical Configuration

Quartz Configuration

// quartz.config.ts
analytics: {
  provider: "posthog",
  apiKey: "phc_...",
  host: "https://us.i.posthog.com",
}

Environment Variables (Cloudflare)

To track build completions, the following secrets must be added to the Cloudflare Pages environment:

  • POSTHOG_API_KEY
  • POSTHOG_HOST

Insights & Value

By using PostHog, I can see the “Knowledge Velocity” of my brain—how often I’m updating notes and which technical domains are resonating most with my audience. It transforms a static digital garden into a living, measurable product.


References: