about summary refs log tree commit diff
path: root/src/state/queries/post.ts
diff options
context:
space:
mode:
authorAnsh <anshnanda10@gmail.com>2023-12-06 11:45:01 -0600
committerGitHub <noreply@github.com>2023-12-06 09:45:01 -0800
commit8e541d753a0718b85e0a754452c8ffbafb181a81 (patch)
treef9afd09859646cc71e948f391b688d2215107498 /src/state/queries/post.ts
parent7229cda5a52192266d8e0ee202ae3d3fee7c66a3 (diff)
downloadvoidsky-8e541d753a0718b85e0a754452c8ffbafb181a81.tar.zst
Check Analytics (#2106)
* fix sign in event tracking

* add missing analytics events

* add more missing analytics

* fix like and unrepost event tracking

* reset onEndReachedThreshold
Diffstat (limited to 'src/state/queries/post.ts')
-rw-r--r--src/state/queries/post.ts6
1 files changed, 6 insertions, 0 deletions
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')
     },
   })
 }