Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

11.4 KB
Raw Blame
import {
    APIInstallation,
    AndroidInstallation,
    AngularInstallation,
    AstroInstallation,
    BubbleInstallation,
    DjangoInstallation,
    DocusaurusInstallation,
    DotNetInstallation,
    ElixirInstallation,
    FlutterInstallation,
    FramerInstallation,
    GoInstallation,
    GoogleTagManagerInstallation,
    HeliconeInstallation,
    IOSInstallation,
    KMPInstallation,
    LangfuseInstallation,
    LaravelInstallation,
    MoEngageInstallation,
    N8nInstallation,
    NextJSInstallation,
    NodeEventCapture,
    NodeJSInstallation,
    NuxtInstallation,
    PHPInstallation,
    PythonEventCapture,
    PythonInstallation,
    ReactInstallation,
    ReactNativeInstallation,
    ReactRouterInstallation,
    RemixInstallation,
    RetoolInstallation,
    RubyInstallation,
    RubyOnRailsInstallation,
    RudderstackInstallation,
    SegmentInstallation,
    SentryInstallation,
    ShopifyInstallation,
    SvelteInstallation,
    TanStackInstallation,
    TraceloopInstallation,
    VueInstallation,
    WebflowInstallation,
    WordpressInstallation,
    ZapierInstallation,
    WebInstallation,
} from '@posthog/shared-onboarding/product-analytics'

import { JS_WEB_SNIPPETS } from 'scenes/onboarding/shared/jsWebSnippets'

import { SDKInstructionsMap, SDKKey, SDKTag, SDKTagOverrides } from '~/types'

import { withMobileReplay, withOnboardingDocsWrapper } from '../shared/onboardingWrappers'

const NODE_SNIPPETS = {
    NodeEventCapture,
}

const PYTHON_SNIPPETS = {
    PythonEventCapture,
}

// Mobile SDKs with AdvertiseMobileReplay
const ProductAnalyticsAndroidInstructionsWrapper = withMobileReplay({
    Installation: AndroidInstallation,
    sdkKey: SDKKey.ANDROID,
    onboardingContext: 'product-analytics-onboarding',
    wizardIntegrationName: 'Android',
})
const ProductAnalyticsIOSInstructionsWrapper = withMobileReplay({
    Installation: IOSInstallation,
    sdkKey: SDKKey.IOS,
    onboardingContext: 'product-analytics-onboarding',
    wizardIntegrationName: 'Swift',
})
const ProductAnalyticsFlutterInstructionsWrapper = withMobileReplay({
    Installation: FlutterInstallation,
    sdkKey: SDKKey.FLUTTER,
    onboardingContext: 'product-analytics-onboarding',
})
const ProductAnalyticsKMPInstructionsWrapper = withMobileReplay({
    Installation: KMPInstallation,
    sdkKey: SDKKey.KMP,
    onboardingContext: 'product-analytics-onboarding',
})
const ProductAnalyticsRNInstructionsWrapper = withMobileReplay({
    Installation: ReactNativeInstallation,
    sdkKey: SDKKey.REACT_NATIVE,
    onboardingContext: 'product-analytics-onboarding',
    wizardIntegrationName: 'React Native',
})

// JS Web SDKs
const ProductAnalyticsWebInstructionsWrapper = withOnboardingDocsWrapper({
    Installation: WebInstallation,
    snippets: JS_WEB_SNIPPETS,
})

// Frontend frameworks with wizard support where applicable
const ProductAnalyticsReactInstructionsWrapper = withOnboardingDocsWrapper({
    Installation: ReactInstallation,
    snippets: JS_WEB_SNIPPETS,
    wizardIntegrationName: 'React',
})
const ProductAnalyticsNextJSInstructionsWrapper = withOnboardingDocsWrapper({
    Installation: NextJSInstallation,
    snippets: JS_WEB_SNIPPETS,
    wizardIntegrationName: 'Next.js',
})
const ProductAnalyticsSvelteInstructionsWrapper = withOnboardingDocsWrapper({
    Installation: SvelteInstallation,
    snippets: JS_WEB_SNIPPETS,
    wizardIntegrationName: 'Svelte',
})
const ProductAnalyticsAstroInstructionsWrapper = withOnboardingDocsWrapper({
    Installation: AstroInstallation,
    snippets: JS_WEB_SNIPPETS,
    wizardIntegrationName: 'Astro',
})
const ProductAnalyticsTanStackInstructionsWrapper = withOnboardingDocsWrapper({
    Installation: TanStackInstallation,
    snippets: JS_WEB_SNIPPETS,
    wizardIntegrationName: 'TanStack Start',
})
const ProductAnalyticsAngularInstructionsWrapper = withOnboardingDocsWrapper({
    Installation: AngularInstallation,
    snippets: JS_WEB_SNIPPETS,
    wizardIntegrationName: 'Angular',
})
const ProductAnalyticsVueInstructionsWrapper = withOnboardingDocsWrapper({
    Installation: VueInstallation,
    snippets: JS_WEB_SNIPPETS,
    wizardIntegrationName: 'Vue',
})
const ProductAnalyticsNuxtJSInstructionsWrapper = withOnboardingDocsWrapper({
    Installation: NuxtInstallation,
    snippets: JS_WEB_SNIPPETS,
    wizardIntegrationName: 'Nuxt',
})
const ProductAnalyticsReactRouterInstructionsWrapper = withOnboardingDocsWrapper({
    Installation: ReactRouterInstallation,
    snippets: JS_WEB_SNIPPETS,
    wizardIntegrationName: 'React Router',
})
const ProductAnalyticsRemixJSInstructionsWrapper = withOnboardingDocsWrapper({
    Installation: RemixInstallation,
    snippets: JS_WEB_SNIPPETS,
    wizardIntegrationName: 'React Router',
})
const ProductAnalyticsBubbleInstructionsWrapper = withOnboardingDocsWrapper({
    Installation: BubbleInstallation,
    snippets: JS_WEB_SNIPPETS,
})
const ProductAnalyticsFramerInstructionsWrapper = withOnboardingDocsWrapper({
    Installation: FramerInstallation,
    snippets: JS_WEB_SNIPPETS,
})
const ProductAnalyticsWebflowInstructionsWrapper = withOnboardingDocsWrapper({
    Installation: WebflowInstallation,
    snippets: JS_WEB_SNIPPETS,
})
const ProductAnalyticsDocusaurusInstructionsWrapper = withOnboardingDocsWrapper({
    Installation: DocusaurusInstallation,
})
const ProductAnalyticsGoogleTagManagerInstructionsWrapper = withOnboardingDocsWrapper({
    Installation: GoogleTagManagerInstallation,
    snippets: JS_WEB_SNIPPETS,
})

// Server-side SDKs
const ProductAnalyticsNodeInstructionsWrapper = withOnboardingDocsWrapper({
    Installation: NodeJSInstallation,
    snippets: NODE_SNIPPETS,
})
const ProductAnalyticsPythonInstructionsWrapper = withOnboardingDocsWrapper({
    Installation: PythonInstallation,
    snippets: PYTHON_SNIPPETS,
    wizardIntegrationName: 'Python',
})
const ProductAnalyticsDjangoInstructionsWrapper = withOnboardingDocsWrapper({
    Installation: DjangoInstallation,
    snippets: PYTHON_SNIPPETS,
    wizardIntegrationName: 'Django',
})
const ProductAnalyticsGoInstructionsWrapper = withOnboardingDocsWrapper({ Installation: GoInstallation })
const ProductAnalyticsDotNetInstructionsWrapper = withOnboardingDocsWrapper({ Installation: DotNetInstallation })
const ProductAnalyticsPHPInstructionsWrapper = withOnboardingDocsWrapper({ Installation: PHPInstallation })
const ProductAnalyticsLaravelInstructionsWrapper = withOnboardingDocsWrapper({
    Installation: LaravelInstallation,
    wizardIntegrationName: 'Laravel',
})
const ProductAnalyticsRubyInstructionsWrapper = withOnboardingDocsWrapper({
    Installation: RubyInstallation,
    wizardIntegrationName: 'Ruby',
})
const ProductAnalyticsRubyOnRailsInstructionsWrapper = withOnboardingDocsWrapper({
    Installation: RubyOnRailsInstallation,
    wizardIntegrationName: 'Ruby on Rails',
})
const ProductAnalyticsElixirInstructionsWrapper = withOnboardingDocsWrapper({ Installation: ElixirInstallation })

// API
const ProductAnalyticsAPIInstructionsWrapper = withOnboardingDocsWrapper({ Installation: APIInstallation })

// Integrations
const ProductAnalyticsSegmentInstructionsWrapper = withOnboardingDocsWrapper({ Installation: SegmentInstallation })
const ProductAnalyticsRudderstackInstructionsWrapper = withOnboardingDocsWrapper({
    Installation: RudderstackInstallation,
})
const ProductAnalyticsSentryInstructionsWrapper = withOnboardingDocsWrapper({ Installation: SentryInstallation })
const ProductAnalyticsRetoolInstructionsWrapper = withOnboardingDocsWrapper({ Installation: RetoolInstallation })
const ProductAnalyticsShopifyInstructionsWrapper = withOnboardingDocsWrapper({ Installation: ShopifyInstallation })
const ProductAnalyticsWordpressInstructionsWrapper = withOnboardingDocsWrapper({ Installation: WordpressInstallation })
const ProductAnalyticsZapierInstructionsWrapper = withOnboardingDocsWrapper({ Installation: ZapierInstallation })
const ProductAnalyticsN8nInstructionsWrapper = withOnboardingDocsWrapper({ Installation: N8nInstallation })
const ProductAnalyticsMoEngageInstructionsWrapper = withOnboardingDocsWrapper({ Installation: MoEngageInstallation })

// LLM Integrations
const ProductAnalyticsHeliconeInstructionsWrapper = withOnboardingDocsWrapper({ Installation: HeliconeInstallation })
const ProductAnalyticsLangfuseInstructionsWrapper = withOnboardingDocsWrapper({ Installation: LangfuseInstallation })
const ProductAnalyticsTraceloopInstructionsWrapper = withOnboardingDocsWrapper({ Installation: TraceloopInstallation })

export const ProductAnalyticsSDKTagOverrides: SDKTagOverrides = {
    [SDKKey.HELICONE]: [SDKTag.LLM],
}

export const ProductAnalyticsSDKInstructions: SDKInstructionsMap = {
    [SDKKey.JS_WEB]: ProductAnalyticsWebInstructionsWrapper,
    [SDKKey.ANDROID]: ProductAnalyticsAndroidInstructionsWrapper,
    [SDKKey.ANGULAR]: ProductAnalyticsAngularInstructionsWrapper,
    [SDKKey.API]: ProductAnalyticsAPIInstructionsWrapper,
    [SDKKey.ASTRO]: ProductAnalyticsAstroInstructionsWrapper,
    [SDKKey.BUBBLE]: ProductAnalyticsBubbleInstructionsWrapper,
    [SDKKey.DJANGO]: ProductAnalyticsDjangoInstructionsWrapper,
    [SDKKey.DOCUSAURUS]: ProductAnalyticsDocusaurusInstructionsWrapper,
    [SDKKey.DOTNET]: ProductAnalyticsDotNetInstructionsWrapper,
    [SDKKey.ELIXIR]: ProductAnalyticsElixirInstructionsWrapper,
    [SDKKey.FLUTTER]: ProductAnalyticsFlutterInstructionsWrapper,
    [SDKKey.FRAMER]: ProductAnalyticsFramerInstructionsWrapper,
    [SDKKey.GO]: ProductAnalyticsGoInstructionsWrapper,
    [SDKKey.GOOGLE_TAG_MANAGER]: ProductAnalyticsGoogleTagManagerInstructionsWrapper,
    [SDKKey.HELICONE]: ProductAnalyticsHeliconeInstructionsWrapper,
    [SDKKey.IOS]: ProductAnalyticsIOSInstructionsWrapper,
    [SDKKey.KMP]: ProductAnalyticsKMPInstructionsWrapper,
    [SDKKey.LANGFUSE]: ProductAnalyticsLangfuseInstructionsWrapper,
    [SDKKey.LARAVEL]: ProductAnalyticsLaravelInstructionsWrapper,
    [SDKKey.MOENGAGE]: ProductAnalyticsMoEngageInstructionsWrapper,
    [SDKKey.N8N]: ProductAnalyticsN8nInstructionsWrapper,
    [SDKKey.NEXT_JS]: ProductAnalyticsNextJSInstructionsWrapper,
    [SDKKey.NODE_JS]: ProductAnalyticsNodeInstructionsWrapper,
    [SDKKey.NUXT_JS]: ProductAnalyticsNuxtJSInstructionsWrapper,
    [SDKKey.PHP]: ProductAnalyticsPHPInstructionsWrapper,
    [SDKKey.PYTHON]: ProductAnalyticsPythonInstructionsWrapper,
    [SDKKey.REACT]: ProductAnalyticsReactInstructionsWrapper,
    [SDKKey.REACT_NATIVE]: ProductAnalyticsRNInstructionsWrapper,
    [SDKKey.REACT_ROUTER]: ProductAnalyticsReactRouterInstructionsWrapper,
    [SDKKey.REMIX]: ProductAnalyticsRemixJSInstructionsWrapper,
    [SDKKey.RETOOL]: ProductAnalyticsRetoolInstructionsWrapper,
    [SDKKey.RUBY]: ProductAnalyticsRubyInstructionsWrapper,
    [SDKKey.RUBY_ON_RAILS]: ProductAnalyticsRubyOnRailsInstructionsWrapper,
    [SDKKey.RUDDERSTACK]: ProductAnalyticsRudderstackInstructionsWrapper,
    [SDKKey.SEGMENT]: ProductAnalyticsSegmentInstructionsWrapper,
    [SDKKey.SENTRY]: ProductAnalyticsSentryInstructionsWrapper,
    [SDKKey.SHOPIFY]: ProductAnalyticsShopifyInstructionsWrapper,
    [SDKKey.SVELTE]: ProductAnalyticsSvelteInstructionsWrapper,
    [SDKKey.TANSTACK_START]: ProductAnalyticsTanStackInstructionsWrapper,
    [SDKKey.TRACELOOP]: ProductAnalyticsTraceloopInstructionsWrapper,
    [SDKKey.VITE]: ProductAnalyticsReactInstructionsWrapper,
    [SDKKey.VUE_JS]: ProductAnalyticsVueInstructionsWrapper,
    [SDKKey.WEBFLOW]: ProductAnalyticsWebflowInstructionsWrapper,
    [SDKKey.WORDPRESS]: ProductAnalyticsWordpressInstructionsWrapper,
    [SDKKey.ZAPIER]: ProductAnalyticsZapierInstructionsWrapper,
}