Bluesky app fork with some witchin' additions 💫

Add more client events to profile followers/following pages (#9466)

* Add more client events to profile followers/following pages

* Remove unneeded logContext attribute

authored by Alex Benzer and committed by GitHub 6686ebc2 d3878bf0

Changed files
+91 -1
src
+18
src/logger/metrics.ts
··· 301 301 | 'ExploreSuggestedAccounts' 302 302 | 'OnboardingSuggestedAccounts' 303 303 } 304 + 'profile:followers:view': { 305 + contextProfileDid: string 306 + isOwnProfile: boolean 307 + } 308 + 'profile:followers:paginate': { 309 + contextProfileDid: string 310 + itemCount: number 311 + page: number 312 + } 313 + 'profile:following:view': { 314 + contextProfileDid: string 315 + isOwnProfile: boolean 316 + } 317 + 'profile:following:paginate': { 318 + contextProfileDid: string 319 + itemCount: number 320 + page: number 321 + } 304 322 'profileCard:seen': { 305 323 contextProfileDid?: string 306 324 profileDid: string
+36
src/view/com/profile/ProfileFollowers.tsx
··· 71 71 return [] 72 72 }, [data]) 73 73 74 + // Track pagination events - fire for page 3+ (pages 1-2 may auto-load) 75 + const paginationTrackingRef = React.useRef<{ 76 + did: string | undefined 77 + page: number 78 + }>({did: undefined, page: 0}) 79 + React.useEffect(() => { 80 + const currentPageCount = data?.pages?.length || 0 81 + // Reset tracking when profile changes 82 + if (paginationTrackingRef.current.did !== resolvedDid) { 83 + paginationTrackingRef.current = {did: resolvedDid, page: currentPageCount} 84 + return 85 + } 86 + if ( 87 + resolvedDid && 88 + currentPageCount >= 3 && 89 + currentPageCount > paginationTrackingRef.current.page 90 + ) { 91 + logger.metric('profile:followers:paginate', { 92 + contextProfileDid: resolvedDid, 93 + itemCount: followers.length, 94 + page: currentPageCount, 95 + }) 96 + } 97 + paginationTrackingRef.current.page = currentPageCount 98 + }, [data?.pages?.length, resolvedDid, followers.length]) 99 + 74 100 const onRefresh = React.useCallback(async () => { 75 101 setIsPTRing(true) 76 102 try { ··· 95 121 renderItem({item, index, contextProfileDid: resolvedDid}), 96 122 [resolvedDid], 97 123 ) 124 + 125 + // track pageview 126 + React.useEffect(() => { 127 + if (resolvedDid) { 128 + logger.metric('profile:followers:view', { 129 + contextProfileDid: resolvedDid, 130 + isOwnProfile: isMe, 131 + }) 132 + } 133 + }, [resolvedDid, isMe]) 98 134 99 135 // track seen items 100 136 const seenItemsRef = React.useRef<Set<string>>(new Set())
+37 -1
src/view/com/profile/ProfileFollows.tsx
··· 82 82 return [] 83 83 }, [data]) 84 84 85 + // Track pagination events - fire for page 3+ (pages 1-2 may auto-load) 86 + const paginationTrackingRef = React.useRef<{ 87 + did: string | undefined 88 + page: number 89 + }>({did: undefined, page: 0}) 90 + React.useEffect(() => { 91 + const currentPageCount = data?.pages?.length || 0 92 + // Reset tracking when profile changes 93 + if (paginationTrackingRef.current.did !== resolvedDid) { 94 + paginationTrackingRef.current = {did: resolvedDid, page: currentPageCount} 95 + return 96 + } 97 + if ( 98 + resolvedDid && 99 + currentPageCount >= 3 && 100 + currentPageCount > paginationTrackingRef.current.page 101 + ) { 102 + logger.metric('profile:following:paginate', { 103 + contextProfileDid: resolvedDid, 104 + itemCount: follows.length, 105 + page: currentPageCount, 106 + }) 107 + } 108 + paginationTrackingRef.current.page = currentPageCount 109 + }, [data?.pages?.length, resolvedDid, follows.length]) 110 + 85 111 const onRefresh = React.useCallback(async () => { 86 112 setIsPTRing(true) 87 113 try { ··· 99 125 } catch (err) { 100 126 logger.error('Failed to load more follows', {error: err}) 101 127 } 102 - }, [error, fetchNextPage, hasNextPage, isFetchingNextPage]) 128 + }, [isFetchingNextPage, hasNextPage, error, fetchNextPage]) 103 129 104 130 const renderItemWithContext = React.useCallback( 105 131 ({item, index}: {item: ActorDefs.ProfileView; index: number}) => 106 132 renderItem({item, index, contextProfileDid: resolvedDid}), 107 133 [resolvedDid], 108 134 ) 135 + 136 + // track pageview 137 + React.useEffect(() => { 138 + if (resolvedDid) { 139 + logger.metric('profile:following:view', { 140 + contextProfileDid: resolvedDid, 141 + isOwnProfile: isMe, 142 + }) 143 + } 144 + }, [resolvedDid, isMe]) 109 145 110 146 // track seen items 111 147 const seenItemsRef = React.useRef<Set<string>>(new Set())