Bluesky app fork with some witchin' additions 💫

Improved client events for feed interactions (#9695)

authored by

Alex Benzer and committed by
GitHub
e684c215 226b19ae

+40 -8
+8
src/logger/metrics.ts
··· 244 244 isReply: boolean 245 245 } 246 246 'post:like': { 247 + uri: string 248 + authorDid: string 247 249 doesLikerFollowPoster: boolean | undefined 248 250 doesPosterFollowLiker: boolean | undefined 249 251 likerClout: number | undefined ··· 252 254 feedDescriptor?: string 253 255 } 254 256 'post:repost': { 257 + uri: string 258 + authorDid: string 255 259 logContext: 'FeedItem' | 'PostThreadItem' | 'Post' | 'ImmersiveVideo' 256 260 feedDescriptor?: string 257 261 } 258 262 'post:unlike': { 263 + uri: string 264 + authorDid: string 259 265 logContext: 'FeedItem' | 'PostThreadItem' | 'Post' | 'ImmersiveVideo' 260 266 feedDescriptor?: string 261 267 } 262 268 'post:unrepost': { 269 + uri: string 270 + authorDid: string 263 271 logContext: 'FeedItem' | 'PostThreadItem' | 'Post' | 'ImmersiveVideo' 264 272 feedDescriptor?: string 265 273 }
+32 -8
src/state/queries/post.ts
··· 111 111 const postCid = post.cid 112 112 const initialLikeUri = post.viewer?.like 113 113 const likeMutation = usePostLikeMutation(feedDescriptor, logContext, post) 114 - const unlikeMutation = usePostUnlikeMutation(feedDescriptor, logContext) 114 + const unlikeMutation = usePostUnlikeMutation(feedDescriptor, logContext, post) 115 115 116 116 const queueToggle = useToggleMutationQueue({ 117 117 initialState: initialLikeUri, ··· 182 182 ownProfile = findProfileQueryData(queryClient, currentAccount.did) 183 183 } 184 184 logger.metric('post:like', { 185 + uri, 186 + authorDid: postAuthor.did, 185 187 logContext, 186 188 doesPosterFollowLiker: postAuthor.viewer 187 189 ? Boolean(postAuthor.viewer.followedBy) ··· 206 208 function usePostUnlikeMutation( 207 209 feedDescriptor: string | undefined, 208 210 logContext: LogEvents['post:unlike']['logContext'], 211 + post: Shadow<AppBskyFeedDefs.PostView>, 209 212 ) { 210 213 const agent = useAgent() 211 214 return useMutation<void, Error, {postUri: string; likeUri: string}>({ 212 - mutationFn: ({likeUri}) => { 213 - logger.metric('post:unlike', {logContext, feedDescriptor}) 215 + mutationFn: ({postUri, likeUri}) => { 216 + logger.metric('post:unlike', { 217 + uri: postUri, 218 + authorDid: post.author.did, 219 + logContext, 220 + feedDescriptor, 221 + }) 214 222 return agent.deleteLike(likeUri) 215 223 }, 216 224 }) ··· 227 235 const postUri = post.uri 228 236 const postCid = post.cid 229 237 const initialRepostUri = post.viewer?.repost 230 - const repostMutation = usePostRepostMutation(feedDescriptor, logContext) 231 - const unrepostMutation = usePostUnrepostMutation(feedDescriptor, logContext) 238 + const repostMutation = usePostRepostMutation(feedDescriptor, logContext, post) 239 + const unrepostMutation = usePostUnrepostMutation( 240 + feedDescriptor, 241 + logContext, 242 + post, 243 + ) 232 244 233 245 const queueToggle = useToggleMutationQueue({ 234 246 initialState: initialRepostUri, ··· 280 292 function usePostRepostMutation( 281 293 feedDescriptor: string | undefined, 282 294 logContext: LogEvents['post:repost']['logContext'], 295 + post: Shadow<AppBskyFeedDefs.PostView>, 283 296 ) { 284 297 const agent = useAgent() 285 298 return useMutation< ··· 288 301 {uri: string; cid: string; via?: {uri: string; cid: string}} // the post's uri and cid, and the repost uri/cid if present 289 302 >({ 290 303 mutationFn: ({uri, cid, via}) => { 291 - logger.metric('post:repost', {logContext, feedDescriptor}) 304 + logger.metric('post:repost', { 305 + uri, 306 + authorDid: post.author.did, 307 + logContext, 308 + feedDescriptor, 309 + }) 292 310 return agent.repost(uri, cid, via) 293 311 }, 294 312 }) ··· 297 315 function usePostUnrepostMutation( 298 316 feedDescriptor: string | undefined, 299 317 logContext: LogEvents['post:unrepost']['logContext'], 318 + post: Shadow<AppBskyFeedDefs.PostView>, 300 319 ) { 301 320 const agent = useAgent() 302 321 return useMutation<void, Error, {postUri: string; repostUri: string}>({ 303 - mutationFn: ({repostUri}) => { 304 - logger.metric('post:unrepost', {logContext, feedDescriptor}) 322 + mutationFn: ({postUri, repostUri}) => { 323 + logger.metric('post:unrepost', { 324 + uri: postUri, 325 + authorDid: post.author.did, 326 + logContext, 327 + feedDescriptor, 328 + }) 305 329 return agent.deleteRepost(repostUri) 306 330 }, 307 331 })