Summary
Add Amplitude as a supported analytics backend.
Implementation
Use direct HTTP V2 API via fetch.
Why not use a library:
@amplitude/analytics-node - uses native http module. Fails on Vercel Edge with "Can't resolve 'http'".
Confirmed in Amplitude community.
@amplitude/analytics-browser - client-side only, requires DOM
API endpoint: https://api2.amplitude.com/2/httpapi
Config
amplitudeBackend({
apiKey: process.env.AMPLITUDE_API_KEY!,
// optional: use EU data residency
host?: "https://api.eu.amplitude.com"
})
Event mapping
pageView -> Page Viewed event
- custom events -> pass through as-is
anonymousUserId -> device_id
userContext.userId -> user_id
serverContext.ip -> ip
- client context ->
platform, os_name, device_model, etc.
Summary
Add Amplitude as a supported analytics backend.
Implementation
Use direct HTTP V2 API via fetch.
Why not use a library:
@amplitude/analytics-node- uses nativehttpmodule. Fails on Vercel Edge with "Can't resolve 'http'".Confirmed in Amplitude community.
@amplitude/analytics-browser- client-side only, requires DOMAPI endpoint:
https://api2.amplitude.com/2/httpapiConfig
Event mapping
pageView->Page ViewedeventanonymousUserId->device_iduserContext.userId->user_idserverContext.ip->ipplatform,os_name,device_model, etc.