Skip to content
Skip to content
Goodspeed

Connect PostHog to your Goodspeed app

Product analytics, session recording, and feature flags, all GDPR-compliant and consent-gated from day one. Goodspeed wires PostHog into every app that needs it at generation time, so you start with a working integration, not a blank config and a documentation tab.

WHAT GETS WIRED IN

Built into every PostHog build

Every app Goodspeed generates with PostHog includes these wired integrations from the first build. No manual setup required.

ItemDescriptionStrength
Lazy singleton initialization: the PostHog client is only created after analytics consent is granted, matching a GDPR opt-out postureLazy singleton initialization: the PostHog client is only created after analytics consent is granted, matching a GDPR opt-out posture01
identifyPostHogUser() called on login and signup with optional traits including subscription tieridentifyPostHogUser() called on login and signup with optional traits including subscription tier02
resetPostHogUser() called on logout to clear user identity from the sessionresetPostHogUser() called on logout to clear user identity from the session03
captureEvent() helper used throughout the template for auth, purchase, navigation, and error eventscaptureEvent() helper used throughout the template for auth, purchase, navigation, and error events04
Session recording enabled via the $session_recording_enabled property when configured in gasConfigSession recording enabled via the $session_recording_enabled property when configured in gasConfig05
Feature flag checks via posthog.isFeatureEnabled in hooks/useFeatureFlag.ts for A/B testing UI variantsFeature flag checks via posthog.isFeatureEnabled in hooks/useFeatureFlag.ts for A/B testing UI variants06

Source: gas-template repository · analytics/feature-flags

REAL GENERATED CODE

A snippet from a PostHog integration the pipeline ships

This pattern comes directly from the gas-template codebase. The studio generates PostHog integration code like this for every app that includes it, not a placeholder you have to fill in yourself.

  1. Consent-aware init

    // lib/posthog.ts
    let _posthog: PostHog | null = null;
    
    export async function getPostHog(): Promise<PostHog | null> {
      if (_posthog) return _posthog;
      const granted = await checkAnalyticsConsent();
      if (!granted) return null;
      if (!apiKey) return null;
      _posthog = new PostHog(apiKey, {
        host,
        persistence: 'memory',
        bootstrap: { distinctId: await getAnonymousId() },
      });
      return _posthog;
    }
GDaily Allergens

Today's log

Gluten
Tree nuts
Shellfish
Dairy
HomeScanLogProfile

START WITH POSTHOG

Your PostHog integration, generated