Bluesky app fork with some witchin' additions ๐Ÿ’ซ
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[๐Ÿด] Add new chat metrics (#4130)

* remove a comment

* add types for event, add log to profile button

* add `chat:open`

* add to chat list items

* fix types

* oops

* oops 2.0

authored by

Hailey and committed by
GitHub
516eb696 22522090

+44 -17
+13 -4
src/components/dms/MessageProfileButton.tsx
··· 5 5 import {useLingui} from '@lingui/react' 6 6 7 7 import {useMaybeConvoForUser} from '#/state/queries/messages/get-convo-for-members' 8 + import {logEvent} from 'lib/statsig/statsig' 8 9 import {atoms as a, useTheme} from '#/alf' 9 10 import {Message_Stroke2_Corner0_Rounded as Message} from '../icons/Message' 10 11 import {Link} from '../Link' ··· 18 19 const {_} = useLingui() 19 20 const t = useTheme() 20 21 21 - const {data: convoId, isPending} = useMaybeConvoForUser(profile.did) 22 + const {data: convo, isPending} = useMaybeConvoForUser(profile.did) 23 + 24 + const onPress = React.useCallback(() => { 25 + if (convo && !convo.lastMessage) { 26 + logEvent('chat:create', {logContext: 'ProfileHeader'}) 27 + } 28 + logEvent('chat:open', {logContext: 'ProfileHeader'}) 29 + }, [convo]) 22 30 23 31 if (isPending) { 24 32 // show pending state based on declaration ··· 48 56 } 49 57 } 50 58 51 - if (convoId) { 59 + if (convo) { 52 60 return ( 53 61 <Link 54 62 testID="dmBtn" ··· 57 65 variant="solid" 58 66 shape="round" 59 67 label={_(msg`Message ${profile.handle}`)} 60 - to={`/messages/${convoId}`} 61 - style={[a.justify_center, {width: 36, height: 36}]}> 68 + to={`/messages/${convo.id}`} 69 + style={[a.justify_center, {width: 36, height: 36}]} 70 + onPress={onPress}> 62 71 <Message 63 72 style={[t.atoms.text, {marginLeft: 1, marginBottom: 1}]} 64 73 size="md"
+6
src/components/dms/NewChatDialog/index.tsx
··· 19 19 import {useGetConvoForMembers} from '#/state/queries/messages/get-convo-for-members' 20 20 import {useProfileFollowsQuery} from '#/state/queries/profile-follows' 21 21 import {useSession} from '#/state/session' 22 + import {logEvent} from 'lib/statsig/statsig' 22 23 import {useActorAutocompleteQuery} from 'state/queries/actor-autocomplete' 23 24 import {FAB} from '#/view/com/util/fab/FAB' 24 25 import * as Toast from '#/view/com/util/Toast' ··· 69 70 const {mutate: createChat} = useGetConvoForMembers({ 70 71 onSuccess: data => { 71 72 onNewChat(data.convo.id) 73 + 74 + if (!data.convo.lastMessage) { 75 + logEvent('chat:create', {logContext: 'NewChatDialog'}) 76 + } 77 + logEvent('chat:open', {logContext: 'NewChatDialog'}) 72 78 }, 73 79 onError: error => { 74 80 Toast.show(error.message)
+7
src/lib/statsig/events.ts
··· 125 125 | 'ProfileHeaderSuggestedFollows' 126 126 | 'ProfileMenu' 127 127 | 'ProfileHoverCard' 128 + | 'Chat' 129 + } 130 + 'chat:create': { 131 + logContext: 'ProfileHeader' | 'NewChatDialog' 132 + } 133 + 'chat:open': { 134 + logContext: 'ProfileHeader' | 'NewChatDialog' | 'ChatsList' 128 135 } 129 136 130 137 'test:all:always': {}
-1
src/screens/Messages/Conversation/MessageInput.tsx
··· 46 46 const {height: keyboardHeight} = useReanimatedKeyboardAnimation() 47 47 const maxHeight = useSharedValue<undefined | number>(undefined) 48 48 const isInputScrollable = useSharedValue(false) 49 - // const [isInputScrollable, setIsInputScrollable] = React.useState(false) 50 49 51 50 const inputStyles = useSharedInputStyles() 52 51 const [isFocused, setIsFocused] = React.useState(false)
+17 -11
src/screens/Messages/List/ChatListItem.tsx
··· 1 1 import React, {useCallback, useState} from 'react' 2 - import {View} from 'react-native' 2 + import {GestureResponderEvent, View} from 'react-native' 3 3 import { 4 4 AppBskyActorDefs, 5 5 ChatBskyConvoDefs, ··· 13 13 import {useProfileShadow} from '#/state/cache/profile-shadow' 14 14 import {useModerationOpts} from '#/state/preferences/moderation-opts' 15 15 import {useSession} from '#/state/session' 16 + import {logEvent} from 'lib/statsig/statsig' 16 17 import {sanitizeDisplayName} from 'lib/strings/display-names' 17 18 import {TimeElapsed} from '#/view/com/util/TimeElapsed' 18 19 import {UserAvatar} from '#/view/com/util/UserAvatar' ··· 120 121 setShowActions(true) 121 122 }, []) 122 123 124 + const onPress = useCallback( 125 + (e: GestureResponderEvent) => { 126 + if (isDeletedAccount) { 127 + e.preventDefault() 128 + return false 129 + } else { 130 + logEvent('chat:open', {logContext: 'ChatsList'}) 131 + } 132 + }, 133 + [isDeletedAccount], 134 + ) 135 + 123 136 const onLongPress = useCallback(() => { 124 137 menuControl.open() 125 138 }, [menuControl]) ··· 148 161 ] 149 162 : undefined 150 163 } 164 + onPress={onPress} 165 + onLongPress={isNative ? menuControl.open : undefined} 151 166 onAccessibilityAction={onLongPress} 152 - onPress={ 153 - isDeletedAccount 154 - ? e => { 155 - e.preventDefault() 156 - return false 157 - } 158 - : undefined 159 - } 160 167 style={[ 161 168 web({ 162 169 cursor: isDeletedAccount ? 'default' : 'pointer', 163 170 }), 164 - ]} 165 - onLongPress={isNative ? menuControl.open : undefined}> 171 + ]}> 166 172 {({hovered, pressed, focused}) => ( 167 173 <View 168 174 style={[
+1 -1
src/state/queries/messages/get-convo-for-members.ts
··· 57 57 .catch(() => ({success: null})) 58 58 59 59 if (convo.success) { 60 - return convo.data.convo.id 60 + return convo.data.convo 61 61 } else { 62 62 return null 63 63 }