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
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 DOMmixpanel(Node.js SDK) - uses nativehttp/httpsmodules. Won't work on Vercel Edge Runtime.API endpoint:
https://api.mixpanel.com/track(or/importfor historical data)Config
Event mapping
pageView->Page ViewedeventanonymousUserId->$device_iduserContext.userId->$user_id