Skip to content

Add Mixpanel backend #7

@vklimontovich

Description

@vklimontovich

Summary

Add Mixpanel as a supported analytics backend.

Implementation

Use direct HTTP API via fetch (like segment and posthog backends do).

Why not use a library:

  • mixpanel-browser - client-side only, requires DOM
  • mixpanel (Node.js SDK) - uses native http/https modules. Won't work on Vercel Edge Runtime.

API endpoint: https://api.mixpanel.com/track (or /import for historical data)

Config

mixpanelBackend({
  token: process.env.MIXPANEL_TOKEN!,
  // optional: use EU data residency
  host?: "https://api-eu.mixpanel.com"
})

Event mapping

  • pageView -> Page Viewed event
  • custom events -> pass through as-is
  • anonymousUserId -> $device_id
  • userContext.userId -> $user_id

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions