feat: add attributable page analytics

This commit is contained in:
john
2026-07-20 20:49:44 +08:00
parent d479e89fc7
commit 1c82b34ad9
12 changed files with 144 additions and 11 deletions
+6
View File
@@ -5,8 +5,10 @@ type AnalyticsIdentity = {
distinctId: string;
username: string;
ownerSegment: string;
planType: string;
channel: string;
surface: 'product';
identityMode: 'raw' | 'pseudonymous';
};
type ProductAnalyticsContext = {
@@ -160,6 +162,8 @@ function trackProductEvent(
route_name: resolveProductRouteName(window.location.pathname),
channel: identity?.channel || 'h5',
owner_segment: identity?.ownerSegment || 'anonymous',
plan_type: identity?.planType || 'anonymous',
identity_mode: identity?.identityMode || 'anonymous',
...data,
},
}));
@@ -203,8 +207,10 @@ export function useProductAnalytics(userId?: string | null) {
void window.umami?.identify(identity.distinctId, {
username: identity.username,
owner_segment: identity.ownerSegment,
plan_type: identity.planType,
channel: identity.channel,
surface: identity.surface,
identity_mode: identity.identityMode,
});
}
} else if (lastIdentityKey) {