feat(mobile): add login track

This commit is contained in:
DIYgod
2025-03-27 20:27:36 +08:00
parent bf127de547
commit ea4a99d1d5
4 changed files with 48 additions and 3 deletions
+5
View File
@@ -1,3 +1,4 @@
import { tracker } from "@follow/tracker"
import { useMutation } from "@tanstack/react-query"
import { useCallback, useRef } from "react"
import { Alert, Text, TouchableOpacity, View } from "react-native"
@@ -52,6 +53,10 @@ async function onSubmit(values: FormValue) {
.catch((error) => {
Alert.alert(error.message)
})
tracker.userLogin({
type: "email",
})
}
export function EmailLogin() {
+8 -1
View File
@@ -1,3 +1,4 @@
import { tracker } from "@follow/tracker"
import * as AppleAuthentication from "expo-apple-authentication"
import { useColorScheme } from "nativewind"
import { Platform, TouchableOpacity, View } from "react-native"
@@ -70,6 +71,9 @@ export function SocialLogin() {
token: credential.identityToken,
},
})
tracker.userLogin({
type: "social",
})
} else {
throw new Error("No identityToken.")
}
@@ -80,10 +84,13 @@ export function SocialLogin() {
return
}
signIn.social({
await signIn.social({
provider: providerInfo.id as any,
callbackURL: "/",
})
tracker.userLogin({
type: "social",
})
}}
disabled={!data?.[providerInfo.id]}
>
+27
View File
@@ -161,12 +161,39 @@ export class OpenPanel {
}
break
}
case "navigate_entry": {
this.firebaseAnalytics?.logSelectContent({
content_type: "entry",
item_id: `${properties?.feedId}/${properties?.entryId}`,
})
break
}
case "user_login": {
this.firebaseAnalytics?.logLogin({
method: properties?.type as string,
})
break
}
case "register": {
this.firebaseAnalytics?.logSignUp({
method: properties?.type as string,
})
break
}
case "subscribe": {
let group_id
if (properties?.listId) {
group_id = `list/${properties.listId}/${properties.view}`
} else if (properties?.feedId) {
group_id = `feed/${properties.feedId}/${properties.view}`
}
if (group_id) {
this.firebaseAnalytics?.logJoinGroup({
group_id,
})
}
break
}
default: {
this.firebaseAnalytics?.logEvent(name, properties)
}
+8 -2
View File
@@ -79,8 +79,9 @@ export class TrackerPoints {
this.track(TrackerMapper.AppInit, props)
}
userLogin(userId: string) {
this.track(TrackerMapper.UserLogin, { userId })
// this is a special point for firebase analytics, do not change its parameters
userLogin(props: { type: "email" | "social" }) {
this.track(TrackerMapper.UserLogin, props)
}
/**
@@ -90,9 +91,11 @@ export class TrackerPoints {
this.track(TrackerMapper.UiRenderInit, { time: spentTime })
}
// this is a special point for firebase analytics, do not change its parameters
navigateEntry(props: { feedId?: string; entryId?: string; timelineId?: string }) {
this.track(TrackerMapper.NavigateEntry, props)
}
boostSent(props: { amount: string; feedId: string }) {
this.track(TrackerMapper.BoostSent, props)
}
@@ -151,14 +154,17 @@ export class TrackerPoints {
this.track(TrackerMapper.TipSent, props)
}
// this is a special point for firebase analytics, do not change its parameters
register(props: { type: "email" | "social" }) {
this.track(TrackerMapper.Register, props)
}
// this is a special point for firebase analytics, do not change its parameters
onBoarding(props: { step: number; done: boolean }) {
this.track(TrackerMapper.OnBoarding, props)
}
// this is a special point for firebase analytics, do not change its parameters
subscribe(props: { feedId?: string; listId?: string; view?: number }) {
this.track(TrackerMapper.Subscribe, props)
}