mirror of
https://github.com/hanzoai/insights-js.git
synced 2026-10-30 18:34:19 +00:00
Bulk rename across 989 files: - Package names: posthog-js → @hanzo/insights, posthog-node → @hanzo/insights-node, etc. - Repository URLs: posthog/posthog-js → hanzoai/insights-js - Brand names: PostHog → Insights - File renames: 259 reference JSON files, source files, workflow files - Directory rename: eslint-plugin-posthog-js → eslint-plugin-insights Remaining: 8 refs to @posthog/rrweb-* (real npm deps, need fork+publish)
22 lines
624 B
TypeScript
22 lines
624 B
TypeScript
import { Insights } from '@insights/convex'
|
|
import { components } from './_generated/api'
|
|
|
|
export const insights = new Insights(components.insights, {
|
|
// Automatically resolve the current user's identity from Convex auth.
|
|
// Falls back to an explicit distinctId if the user is not signed in.
|
|
identify: async (ctx) => {
|
|
const identity = await ctx.auth?.getUserIdentity()
|
|
if (!identity) return null
|
|
return { distinctId: identity.subject }
|
|
},
|
|
beforeSend: (event) => {
|
|
return {
|
|
...event,
|
|
properties: {
|
|
...event.properties,
|
|
environment: 'example-app',
|
|
},
|
|
}
|
|
},
|
|
})
|