Skip to content

Commit 800274c

Browse files
committed
[PAY-1695] DMs: Entrypoint Analytics (#3862)
1 parent ffcfb76 commit 800274c

File tree

9 files changed

+39
-8
lines changed

9 files changed

+39
-8
lines changed

apps/audius-client/packages/common/src/models/Analytics.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,8 @@ export enum Name {
347347
MESSAGE_UNFURL_TRACK = 'Message Unfurl: Track',
348348
MESSAGE_UNFURL_PLAYLIST = 'Message Unfurl: Playlist',
349349
TIP_UNLOCKED_CHAT = 'Unlocked Chat: Tip',
350-
CHAT_REPORT_USER = 'Report User: Chat'
350+
CHAT_REPORT_USER = 'Report User: Chat',
351+
CHAT_ENTRY_POINT = 'Chat Entry Point'
351352
}
352353

353354
type PageView = {
@@ -1647,6 +1648,11 @@ type ChatReportUser = {
16471648
reportedUserId: ID
16481649
}
16491650

1651+
type ChatEntryPoint = {
1652+
eventName: Name.CHAT_ENTRY_POINT
1653+
source: 'banner' | 'navmenu' | 'share' | 'profile'
1654+
}
1655+
16501656
export type BaseAnalyticsEvent = { type: typeof ANALYTICS_TRACK_EVENT }
16511657

16521658
export type AllTrackingEvents =
@@ -1871,3 +1877,4 @@ export type AllTrackingEvents =
18711877
| DeveloperAppCreateError
18721878
| DeveloperAppDeleteSuccess
18731879
| DeveloperAppDeleteError
1880+
| ChatEntryPoint

apps/audius-client/packages/mobile/src/components/share-drawer/ShareDrawer.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
accountSelectors,
55
collectionsSocialActions,
66
FeatureFlags,
7+
Name,
78
shareModalUISelectors,
89
shareSoundToTiktokModalActions,
910
tracksSocialActions,
@@ -25,6 +26,7 @@ import { useNavigation } from 'app/hooks/useNavigation'
2526
import { useFeatureFlag } from 'app/hooks/useRemoteConfig'
2627
import { useToast } from 'app/hooks/useToast'
2728
import type { AppTabScreenParamList } from 'app/screens/app-screen'
29+
import { make, track } from 'app/services/analytics'
2830
import { makeStyles } from 'app/styles'
2931
import { useThemeColors } from 'app/utils/theme'
3032

@@ -109,6 +111,7 @@ export const ShareDrawer = () => {
109111
navigation.navigate('ChatUserList', {
110112
presetMessage: getContentUrl(content)
111113
})
114+
track(make({ eventName: Name.CHAT_ENTRY_POINT, source: 'share' }))
112115
}, [content, navigation])
113116

114117
const handleShareToTwitter = useCallback(async () => {

apps/audius-client/packages/mobile/src/screens/app-drawer-screen/left-nav-drawer/LeftNavDrawer.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import {
44
StringKeys,
55
accountSelectors,
66
useAccountHasClaimableRewards,
7-
chatSelectors
7+
chatSelectors,
8+
Name
89
} from '@audius/common'
910
import type { DrawerContentComponentProps } from '@react-navigation/drawer'
1011
import { DrawerContentScrollView } from '@react-navigation/drawer'
@@ -18,6 +19,7 @@ import IconSettings from 'app/assets/images/iconSettings.svg'
1819
import IconUpload from 'app/assets/images/iconUpload.svg'
1920
import IconUser from 'app/assets/images/iconUser.svg'
2021
import { useFeatureFlag, useRemoteVar } from 'app/hooks/useRemoteConfig'
22+
import { make, track } from 'app/services/analytics'
2123
import { makeStyles } from 'app/styles'
2224
import { spacing } from 'app/styles/spacing'
2325

@@ -88,6 +90,9 @@ const WrappedLeftNavDrawer = () => {
8890
label={'Messages'}
8991
to='ChatList'
9092
params={{}}
93+
onPress={() => {
94+
track(make({ eventName: Name.CHAT_ENTRY_POINT, source: 'navmenu' }))
95+
}}
9196
>
9297
{hasUnreadMessages ? (
9398
<View style={styles.notificationBubble} />

apps/audius-client/packages/mobile/src/screens/app-drawer-screen/left-nav-drawer/LeftNavLink.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ type LeftNavLinkProps<Screen extends keyof AppTabScreenParamList> = {
4444
label: string
4545
labelProps?: TextProps
4646
children?: ReactNode
47+
onPress?: () => void
4748
}
4849

4950
export const LeftNavLink = <Screen extends keyof AppTabScreenParamList>(
@@ -56,7 +57,8 @@ export const LeftNavLink = <Screen extends keyof AppTabScreenParamList>(
5657
params,
5758
label,
5859
labelProps,
59-
children
60+
children,
61+
onPress
6062
} = props
6163
const styles = useStyles()
6264
const { neutral } = useThemeColors()
@@ -67,7 +69,8 @@ export const LeftNavLink = <Screen extends keyof AppTabScreenParamList>(
6769
// @ts-expect-error navigation not smart enough here
6870
navigation.navigate(to, { fromAppDrawer: true, ...params })
6971
drawerHelpers.closeDrawer()
70-
}, [navigation, to, params, drawerHelpers])
72+
onPress?.()
73+
}, [navigation, to, params, drawerHelpers, onPress])
7174

7275
return (
7376
<TouchableOpacity style={styles.accountListItem} onPress={handlePress}>

apps/audius-client/packages/mobile/src/screens/profile-screen/MessageButton.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { useCallback } from 'react'
22

33
import type { User } from '@audius/common'
4-
import { chatActions } from '@audius/common'
4+
import { Name, chatActions } from '@audius/common'
55
import { useDispatch } from 'react-redux'
66

77
import IconMessage from 'app/assets/images/iconMessage.svg'
88
import { Button } from 'app/components/core'
9+
import { make, track } from 'app/services/analytics'
910
import { makeStyles } from 'app/styles'
1011

1112
const { createChat } = chatActions
@@ -36,6 +37,7 @@ export const MessageButton = (props: MessageButtonProps) => {
3637

3738
const handlePress = useCallback(() => {
3839
dispatch(createChat({ userIds: [user_id] }))
40+
track(make({ eventName: Name.CHAT_ENTRY_POINT, source: 'profile' }))
3941
}, [dispatch, user_id])
4042

4143
return (

apps/audius-client/packages/web/src/components/banner/DirectMessagesBanner.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { useCallback, useState } from 'react'
22

3-
import { Client, accountSelectors } from '@audius/common'
3+
import { Client, Name, accountSelectors } from '@audius/common'
44
import { push as pushRoute } from 'connected-react-router'
55
import { useDispatch } from 'react-redux'
66

77
import { useSelector } from 'common/hooks/useSelector'
8+
import { make } from 'common/store/analytics/actions'
89
import { getClient } from 'utils/clientUtil'
910
import { CHATS_PAGE } from 'utils/route'
1011

@@ -43,6 +44,7 @@ export const DirectMessagesBanner = () => {
4344
}, [])
4445

4546
const handleAccept = useCallback(() => {
47+
dispatch(make(Name.CHAT_ENTRY_POINT, { source: 'banner' }))
4648
dispatch(pushRoute(CHATS_PAGE))
4749
handleClose()
4850
}, [dispatch, handleClose])

apps/audius-client/packages/web/src/components/nav/desktop/NavPopupMenu.tsx

+9-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import {
22
removeNullable,
33
accountSelectors,
44
FeatureFlags,
5-
chatSelectors
5+
chatSelectors,
6+
Name
67
} from '@audius/common'
78
import {
89
IconCrown,
@@ -14,8 +15,10 @@ import {
1415
PopupPosition
1516
} from '@audius/stems'
1617
import cn from 'classnames'
18+
import { useDispatch } from 'react-redux'
1719

1820
import { ReactComponent as IconKebabHorizontal } from 'assets/img/iconKebabHorizontalAlt.svg'
21+
import { make } from 'common/store/analytics/actions'
1922
import { Icon } from 'components/Icon'
2023
import { NotificationDot } from 'components/notification-dot'
2124
import { useNavigateToPage } from 'hooks/useNavigateToPage'
@@ -44,6 +47,7 @@ const useAccountHasTracks = () => {
4447
}
4548

4649
const NavPopupMenu = () => {
50+
const dispatch = useDispatch()
4751
const navigate = useNavigateToPage()
4852
const hasTracks = useAccountHasTracks()
4953
const hasUnreadMessages = useSelector(chatSelectors.getHasUnreadMessages)
@@ -62,7 +66,10 @@ const NavPopupMenu = () => {
6266
isChatEnabled
6367
? {
6468
text: messagesItemText,
65-
onClick: () => navigate(CHATS_PAGE),
69+
onClick: () => {
70+
navigate(CHATS_PAGE)
71+
dispatch(make(Name.CHAT_ENTRY_POINT, { source: 'navmenu' }))
72+
},
6673
icon: <IconMessage />,
6774
iconClassName: styles.menuItemIcon
6875
}

apps/audius-client/packages/web/src/components/share-modal/ShareModal.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export const ShareModal = () => {
6565
onCancelAction: setVisibility({ modal: 'Share', visible: true })
6666
})
6767
)
68+
dispatch(make(Name.CHAT_ENTRY_POINT, { source: 'share' }))
6869
}, [dispatch, onClose, content])
6970

7071
const handleShareToTwitter = useCallback(async () => {

apps/audius-client/packages/web/src/pages/profile-page/ProfilePageProvider.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,7 @@ function mapDispatchToProps(dispatch: Dispatch, props: RouteComponentProps) {
12101210
},
12111211
onMessage: (userId: ID) => {
12121212
dispatch(createChat({ userIds: [userId] }))
1213+
dispatch(make(Name.CHAT_ENTRY_POINT, { source: 'profile' }))
12131214
},
12141215
onBlock: (userId: ID) => {
12151216
dispatch(blockUser({ userId }))

0 commit comments

Comments
 (0)