Update Analytics (#1743)

zio/stable
Ansh 2023-10-26 08:37:14 -07:00 committed by GitHub
parent c13b6946ba
commit 927cee18d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 18 deletions

View File

@ -51,10 +51,10 @@ export function init(store: RootStoreModel) {
store.onSessionLoaded(() => { store.onSessionLoaded(() => {
const sess = store.session.currentSession const sess = store.session.currentSession
if (sess) { if (sess) {
if (sess.email) { if (sess.did) {
const did_hashed = sha256(sess.did)
segmentClient.identify(did_hashed, {did_hashed})
store.log.debug('Ping w/hash') store.log.debug('Ping w/hash')
const email_hashed = sha256(sess.email)
segmentClient.identify(email_hashed, {email_hashed})
} else { } else {
store.log.debug('Ping w/o hash') store.log.debug('Ping w/o hash')
segmentClient.identify() segmentClient.identify()

View File

@ -46,10 +46,10 @@ export function init(store: RootStoreModel) {
store.onSessionLoaded(() => { store.onSessionLoaded(() => {
const sess = store.session.currentSession const sess = store.session.currentSession
if (sess) { if (sess) {
if (sess.email) { if (sess.did) {
const did_hashed = sha256(sess.did)
segmentClient.identify(did_hashed, {did_hashed})
store.log.debug('Ping w/hash') store.log.debug('Ping w/hash')
const email_hashed = sha256(sess.email)
segmentClient.identify(email_hashed, {email_hashed})
} else { } else {
store.log.debug('Ping w/o hash') store.log.debug('Ping w/o hash')
segmentClient.identify() segmentClient.identify()

View File

@ -116,6 +116,7 @@ export class PostsFeedItemModel {
}, },
() => this.rootStore.agent.deleteLike(url), () => this.rootStore.agent.deleteLike(url),
) )
track('Post:Unlike')
} else { } else {
// like // like
await updateDataOptimistically( await updateDataOptimistically(
@ -129,11 +130,10 @@ export class PostsFeedItemModel {
this.post.viewer!.like = res.uri this.post.viewer!.like = res.uri
}, },
) )
track('Post:Like')
} }
} catch (error) { } catch (error) {
this.rootStore.log.error('Failed to toggle like', error) this.rootStore.log.error('Failed to toggle like', error)
} finally {
track(this.post.viewer.like ? 'Post:Unlike' : 'Post:Like')
} }
} }
@ -141,6 +141,7 @@ export class PostsFeedItemModel {
this.post.viewer = this.post.viewer || {} this.post.viewer = this.post.viewer || {}
try { try {
if (this.post.viewer?.repost) { if (this.post.viewer?.repost) {
// unrepost
const url = this.post.viewer.repost const url = this.post.viewer.repost
await updateDataOptimistically( await updateDataOptimistically(
this.post, this.post,
@ -150,7 +151,9 @@ export class PostsFeedItemModel {
}, },
() => this.rootStore.agent.deleteRepost(url), () => this.rootStore.agent.deleteRepost(url),
) )
track('Post:Unrepost')
} else { } else {
// repost
await updateDataOptimistically( await updateDataOptimistically(
this.post, this.post,
() => { () => {
@ -162,11 +165,10 @@ export class PostsFeedItemModel {
this.post.viewer!.repost = res.uri this.post.viewer!.repost = res.uri
}, },
) )
track('Post:Repost')
} }
} catch (error) { } catch (error) {
this.rootStore.log.error('Failed to toggle repost', error) this.rootStore.log.error('Failed to toggle repost', error)
} finally {
track(this.post.viewer.repost ? 'Post:Unrepost' : 'Post:Repost')
} }
} }
@ -174,13 +176,13 @@ export class PostsFeedItemModel {
try { try {
if (this.isThreadMuted) { if (this.isThreadMuted) {
this.rootStore.mutedThreads.uris.delete(this.rootUri) this.rootStore.mutedThreads.uris.delete(this.rootUri)
track('Post:ThreadUnmute')
} else { } else {
this.rootStore.mutedThreads.uris.add(this.rootUri) this.rootStore.mutedThreads.uris.add(this.rootUri)
track('Post:ThreadMute')
} }
} catch (error) { } catch (error) {
this.rootStore.log.error('Failed to toggle thread mute', error) this.rootStore.log.error('Failed to toggle thread mute', error)
} finally {
track(this.isThreadMuted ? 'Post:ThreadUnmute' : 'Post:ThreadMute')
} }
} }

View File

@ -132,20 +132,19 @@ const ProfileHeaderLoaded = observer(function ProfileHeaderLoadedImpl({
}, [store, view]) }, [store, view])
const onPressToggleFollow = React.useCallback(() => { const onPressToggleFollow = React.useCallback(() => {
track(
view.viewer.following
? 'ProfileHeader:FollowButtonClicked'
: 'ProfileHeader:UnfollowButtonClicked',
)
view?.toggleFollowing().then( view?.toggleFollowing().then(
() => { () => {
setShowSuggestedFollows(Boolean(view.viewer.following)) setShowSuggestedFollows(Boolean(view.viewer.following))
Toast.show( Toast.show(
`${ `${
view.viewer.following ? 'Following' : 'No longer following' view.viewer.following ? 'Following' : 'No longer following'
} ${sanitizeDisplayName(view.displayName || view.handle)}`, } ${sanitizeDisplayName(view.displayName || view.handle)}`,
) )
track(
view.viewer.following
? 'ProfileHeader:FollowButtonClicked'
: 'ProfileHeader:UnfollowButtonClicked',
)
}, },
err => store.log.error('Failed to toggle follow', err), err => store.log.error('Failed to toggle follow', err),
) )