From 4964771113eaa43571a5e08d123ce89341f26c19 Mon Sep 17 00:00:00 2001 From: Hailey Date: Thu, 29 May 2025 14:42:01 -0700 Subject: [PATCH] feedDescriptor --- src/components/PostControls/index.tsx | 5 +++-- src/logger/metrics.ts | 8 ++++---- src/state/queries/post.ts | 28 +++++++++++++-------------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/components/PostControls/index.tsx b/src/components/PostControls/index.tsx index 2b7e3c9bd3..f871cf3564 100644 --- a/src/components/PostControls/index.tsx +++ b/src/components/PostControls/index.tsx @@ -69,16 +69,17 @@ let PostControls = ({ const {_, i18n} = useLingui() const {gtMobile} = useBreakpoints() const {openComposer} = useOpenComposer() + const {feedDescriptor} = useFeedFeedbackContext() const [queueLike, queueUnlike] = usePostLikeMutationQueue( post, viaRepost, - feedContext, + feedDescriptor, logContext, ) const [queueRepost, queueUnrepost] = usePostRepostMutationQueue( post, viaRepost, - feedContext, + feedDescriptor, logContext, ) const requireAuth = useRequireAuth() diff --git a/src/logger/metrics.ts b/src/logger/metrics.ts index 02147eaccb..cfd77c5a10 100644 --- a/src/logger/metrics.ts +++ b/src/logger/metrics.ts @@ -196,19 +196,19 @@ export type MetricEvents = { likerClout: number | undefined postClout: number | undefined logContext: 'FeedItem' | 'PostThreadItem' | 'Post' | 'ImmersiveVideo' - feedContext?: string + feedDescriptor?: string } 'post:repost': { logContext: 'FeedItem' | 'PostThreadItem' | 'Post' | 'ImmersiveVideo' - feedContext?: string + feedDescriptor?: string } 'post:unlike': { logContext: 'FeedItem' | 'PostThreadItem' | 'Post' | 'ImmersiveVideo' - feedContext?: string + feedDescriptor?: string } 'post:unrepost': { logContext: 'FeedItem' | 'PostThreadItem' | 'Post' | 'ImmersiveVideo' - feedContext?: string + feedDescriptor?: string } 'post:mute': {} 'post:unmute': {} diff --git a/src/state/queries/post.ts b/src/state/queries/post.ts index ea2c9631f3..e92847e75a 100644 --- a/src/state/queries/post.ts +++ b/src/state/queries/post.ts @@ -100,7 +100,7 @@ export function useGetPosts() { export function usePostLikeMutationQueue( post: Shadow, viaRepost: {uri: string; cid: string} | undefined, - feedContext: string | undefined, + feedDescriptor: string | undefined, logContext: LogEvents['post:like']['logContext'] & LogEvents['post:unlike']['logContext'], ) { @@ -108,8 +108,8 @@ export function usePostLikeMutationQueue( const postUri = post.uri const postCid = post.cid const initialLikeUri = post.viewer?.like - const likeMutation = usePostLikeMutation(feedContext, logContext, post) - const unlikeMutation = usePostUnlikeMutation(feedContext, logContext) + const likeMutation = usePostLikeMutation(feedDescriptor, logContext, post) + const unlikeMutation = usePostUnlikeMutation(feedDescriptor, logContext) const queueToggle = useToggleMutationQueue({ initialState: initialLikeUri, @@ -161,7 +161,7 @@ export function usePostLikeMutationQueue( } function usePostLikeMutation( - feedContext: string | undefined, + feedDescriptor: string | undefined, logContext: LogEvents['post:like']['logContext'], post: Shadow, ) { @@ -194,7 +194,7 @@ function usePostLikeMutation( post.replyCount != null ? toClout(post.likeCount + post.repostCount + post.replyCount) : undefined, - feedContext: feedContext, + feedDescriptor: feedDescriptor, }) return agent.like(uri, cid, via) }, @@ -202,13 +202,13 @@ function usePostLikeMutation( } function usePostUnlikeMutation( - feedContext: string | undefined, + feedDescriptor: string | undefined, logContext: LogEvents['post:unlike']['logContext'], ) { const agent = useAgent() return useMutation({ mutationFn: ({likeUri}) => { - logger.metric('post:unlike', {logContext, feedContext: feedContext}) + logger.metric('post:unlike', {logContext, feedDescriptor}) return agent.deleteLike(likeUri) }, }) @@ -217,7 +217,7 @@ function usePostUnlikeMutation( export function usePostRepostMutationQueue( post: Shadow, viaRepost: {uri: string; cid: string} | undefined, - feedContext: string | undefined, + feedDescriptor: string | undefined, logContext: LogEvents['post:repost']['logContext'] & LogEvents['post:unrepost']['logContext'], ) { @@ -225,8 +225,8 @@ export function usePostRepostMutationQueue( const postUri = post.uri const postCid = post.cid const initialRepostUri = post.viewer?.repost - const repostMutation = usePostRepostMutation(feedContext, logContext) - const unrepostMutation = usePostUnrepostMutation(feedContext, logContext) + const repostMutation = usePostRepostMutation(feedDescriptor, logContext) + const unrepostMutation = usePostUnrepostMutation(feedDescriptor, logContext) const queueToggle = useToggleMutationQueue({ initialState: initialRepostUri, @@ -276,7 +276,7 @@ export function usePostRepostMutationQueue( } function usePostRepostMutation( - feedContext: string | undefined, + feedDescriptor: string | undefined, logContext: LogEvents['post:repost']['logContext'], ) { const agent = useAgent() @@ -286,20 +286,20 @@ function usePostRepostMutation( {uri: string; cid: string; via?: {uri: string; cid: string}} // the post's uri and cid, and the repost uri/cid if present >({ mutationFn: ({uri, cid, via}) => { - logger.metric('post:repost', {logContext, feedContext: feedContext}) + logger.metric('post:repost', {logContext, feedDescriptor}) return agent.repost(uri, cid, via) }, }) } function usePostUnrepostMutation( - feedContext: string | undefined, + feedDescriptor: string | undefined, logContext: LogEvents['post:unrepost']['logContext'], ) { const agent = useAgent() return useMutation({ mutationFn: ({repostUri}) => { - logger.metric('post:unrepost', {logContext, feedContext: feedContext}) + logger.metric('post:unrepost', {logContext, feedDescriptor}) return agent.deleteRepost(repostUri) }, })