we0-analyze-sdk
v0.1.3
Published
Minimal browser analytics SDK for pageview, PV, and UV tracking.
Readme
we0-analyze-sdk
Minimal browser analytics SDK boilerplate for pageview, pageleave, attribution, device, and conversion events.
https://www.npmjs.com/package/we0-analyze-sdk
Install
npm install we0-analyze-sdkUsage
import { init } from 'we0-analyze-sdk'
const we0 = init({
projectId: process.env.PROJECT_ID!,
autoTrackPageview: true,
endpoint: '/api/we0-analyze/events',
})
we0.capture('signup_click', {
source: 'home',
})
we0.conversion('signup')
we0.identify('user_id')
console.log(we0.getMetrics())Run docs/supabase-schema.sql in the Supabase project before enabling database writes. Your server endpoint should write to:
${PROJECT_ID}____we0_pageview${PROJECT_ID}____we0_event
If PROJECT_ID contains -, the SDK replaces it with _ when building table names.
The SDK only sends collected events to your endpoint. Keep Supabase keys on the server, and use a service role key in that endpoint when writing these tables.
Colored console.log output is still kept for local debugging.
