about summary refs log tree commit diff
path: root/src/state/models/content/profile.ts
diff options
context:
space:
mode:
authorAnsh <anshnanda10@gmail.com>2023-06-27 08:11:05 -0700
committerGitHub <noreply@github.com>2023-06-27 10:11:05 -0500
commita8bbaa06c7266c73f6a71b5e9223c11c96995947 (patch)
treebae43bbbd724ceb513aa29339273418623b8d7f4 /src/state/models/content/profile.ts
parentbfaa6d73f37f251259c521befa9e9ee8ea877560 (diff)
downloadvoidsky-a8bbaa06c7266c73f6a71b5e9223c11c96995947.tar.zst
[APP-705] Metrics revamp pt2 (#896)
* export track function from analytics.tsx

* fix create account tracking

* fix tracking sign in

* add custom feed events

* fix type errors

* refactor create post event

* add profile follow & unfollow events

* refactor PostsFeedSliceModel into its own file

* refactor PostThreadItemModel into its own file

* reorganize code a lil bit

* refactor post-thread-item to use post-feed-item model under the hood

* add post events

* add post reply tracking

* track custom feed load more

* track list subscribe and unsubscribe
Diffstat (limited to 'src/state/models/content/profile.ts')
-rw-r--r--src/state/models/content/profile.ts9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/state/models/content/profile.ts b/src/state/models/content/profile.ts
index 9d8378f79..34b2ea28e 100644
--- a/src/state/models/content/profile.ts
+++ b/src/state/models/content/profile.ts
@@ -18,6 +18,7 @@ import {
   filterAccountLabels,
   filterProfileLabels,
 } from 'lib/labeling/helpers'
+import {track} from 'lib/analytics/analytics'
 
 export class ProfileViewerModel {
   muted?: boolean
@@ -127,19 +128,27 @@ export class ProfileModel {
     }
 
     if (followUri) {
+      // unfollow
       await this.rootStore.agent.deleteFollow(followUri)
       runInAction(() => {
         this.followersCount--
         this.viewer.following = undefined
         this.rootStore.me.follows.removeFollow(this.did)
       })
+      track('Profile:Unfollow', {
+        username: this.handle,
+      })
     } else {
+      // follow
       const res = await this.rootStore.agent.follow(this.did)
       runInAction(() => {
         this.followersCount++
         this.viewer.following = res.uri
         this.rootStore.me.follows.addFollow(this.did, res.uri)
       })
+      track('Profile:Follow', {
+        username: this.handle,
+      })
     }
   }