about summary refs log tree commit diff
path: root/src/state
diff options
context:
space:
mode:
Diffstat (limited to 'src/state')
-rw-r--r--src/state/muted-threads.tsx3
-rw-r--r--src/state/queries/post.ts6
-rw-r--r--src/state/queries/profile.ts3
-rw-r--r--src/state/session/index.tsx3
4 files changed, 15 insertions, 0 deletions
diff --git a/src/state/muted-threads.tsx b/src/state/muted-threads.tsx
index 2b3a7de6a..84a717eb7 100644
--- a/src/state/muted-threads.tsx
+++ b/src/state/muted-threads.tsx
@@ -1,5 +1,6 @@
 import React from 'react'
 import * as persisted from '#/state/persisted'
+import {track} from '#/lib/analytics/analytics'
 
 type StateContext = persisted.Schema['mutedThreads']
 type ToggleContext = (uri: string) => boolean
@@ -19,9 +20,11 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
         if (arr.includes(uri)) {
           arr = arr.filter(v => v !== uri)
           muted = false
+          track('Post:ThreadUnmute')
         } else {
           arr = arr.concat([uri])
           muted = true
+          track('Post:ThreadMute')
         }
         persisted.write('mutedThreads', arr)
         return arr
diff --git a/src/state/queries/post.ts b/src/state/queries/post.ts
index b31696446..5570f022b 100644
--- a/src/state/queries/post.ts
+++ b/src/state/queries/post.ts
@@ -4,6 +4,7 @@ import {useQuery, useMutation, useQueryClient} from '@tanstack/react-query'
 
 import {getAgent} from '#/state/session'
 import {updatePostShadow} from '#/state/cache/post-shadow'
+import {track} from '#/lib/analytics/analytics'
 
 export const RQKEY = (postUri: string) => ['post', postUri]
 
@@ -73,6 +74,7 @@ export function usePostLikeMutation() {
       updatePostShadow(variables.uri, {
         likeUri: data.uri,
       })
+      track('Post:Like')
     },
     onError(error, variables) {
       // revert the optimistic update
@@ -92,6 +94,7 @@ export function usePostUnlikeMutation() {
   >({
     mutationFn: async ({likeUri}) => {
       await getAgent().deleteLike(likeUri)
+      track('Post:Unlike')
     },
     onMutate(variables) {
       // optimistically update the post-shadow
@@ -129,6 +132,7 @@ export function usePostRepostMutation() {
       updatePostShadow(variables.uri, {
         repostUri: data.uri,
       })
+      track('Post:Repost')
     },
     onError(error, variables) {
       // revert the optimistic update
@@ -148,6 +152,7 @@ export function usePostUnrepostMutation() {
   >({
     mutationFn: async ({repostUri}) => {
       await getAgent().deleteRepost(repostUri)
+      track('Post:Unrepost')
     },
     onMutate(variables) {
       // optimistically update the post-shadow
@@ -173,6 +178,7 @@ export function usePostDeleteMutation() {
     },
     onSuccess(data, variables) {
       updatePostShadow(variables.uri, {isDeleted: true})
+      track('Post:Delete')
     },
   })
 }
diff --git a/src/state/queries/profile.ts b/src/state/queries/profile.ts
index 9435d7ad5..267cf2c5b 100644
--- a/src/state/queries/profile.ts
+++ b/src/state/queries/profile.ts
@@ -21,6 +21,7 @@ import {useToggleMutationQueue} from '#/lib/hooks/useToggleMutationQueue'
 import {RQKEY as RQKEY_MY_MUTED} from './my-muted-accounts'
 import {RQKEY as RQKEY_MY_BLOCKED} from './my-blocked-accounts'
 import {STALE} from '#/state/queries'
+import {track} from '#/lib/analytics/analytics'
 
 export const RQKEY = (did: string) => ['profile', did]
 
@@ -188,6 +189,7 @@ function useProfileFollowMutation() {
         updateProfileShadow(variables.did, {
           followingUri: data.uri,
         })
+        track('Profile:Follow', {username: variables.did})
       }
     },
     onError(error, variables) {
@@ -208,6 +210,7 @@ function useProfileUnfollowMutation() {
     {did: string; followUri: string; skipOptimistic?: boolean}
   >({
     mutationFn: async ({followUri}) => {
+      track('Profile:Unfollow', {username: followUri})
       return await getAgent().deleteFollow(followUri)
     },
     onMutate(variables) {
diff --git a/src/state/session/index.tsx b/src/state/session/index.tsx
index 37454187a..0d52d2521 100644
--- a/src/state/session/index.tsx
+++ b/src/state/session/index.tsx
@@ -10,6 +10,7 @@ import {IS_PROD} from '#/lib/constants'
 import {emitSessionLoaded, emitSessionDropped} from '../events'
 import {useLoggedOutViewControls} from '#/state/shell/logged-out'
 import {useCloseAllActiveElements} from '#/state/util'
+import {track} from '#/lib/analytics/analytics'
 
 let __globalAgent: BskyAgent = PUBLIC_BSKY_AGENT
 
@@ -270,6 +271,8 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
         },
         logger.DebugContext.session,
       )
+
+      track('Sign In', {resumedSession: false})
     },
     [upsertAccount, queryClient],
   )