feat: add track function

This commit is contained in:
moonrailgun 2024-04-13 04:09:16 +08:00
parent a1e4a26758
commit 6349931714

View File

@ -68,3 +68,27 @@ export async function initTianjiTracker(options: InjectTrackerOptions) {
); );
}); });
} }
export function reportEvent(eventName: string, data: Record<string, any>) {
const tianji = (window as any).tianji;
if (!tianji) {
return;
}
tianji.report(eventName, data);
}
interface IdentifyPayload {
email?: string;
username?: string;
avatar?: string;
[key: string]: any;
}
export function identify(data: IdentifyPayload) {
const tianji = (window as any).tianji;
if (!tianji) {
return;
}
tianji.identify(data);
}