From 6349931714063edb9d17cb45b1a200bb04d48d25 Mon Sep 17 00:00:00 2001 From: moonrailgun Date: Sat, 13 Apr 2024 04:09:16 +0800 Subject: [PATCH] feat: add track function --- packages/client-sdk/src/tracker.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/packages/client-sdk/src/tracker.ts b/packages/client-sdk/src/tracker.ts index 27772f5..0d07fa0 100644 --- a/packages/client-sdk/src/tracker.ts +++ b/packages/client-sdk/src/tracker.ts @@ -68,3 +68,27 @@ export async function initTianjiTracker(options: InjectTrackerOptions) { ); }); } + +export function reportEvent(eventName: string, data: Record) { + 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); +}