Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion packages/common/src/models/Analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,10 @@ export enum Name {
// Chat
CREATE_CHAT_SUCCESS = 'Create Chat: Success',
CREATE_CHAT_FAILURE = 'Create Chat: Failure',
CHAT_BLAST_CTA_CLICKED = 'Chat Blast: CTA Clicked',
CREATE_CHAT_BLAST_SUCCESS = 'Chat Blast: Create - Success',
CREATE_CHAT_BLAST_FAILURE = 'Chat Blast: Create - Failure',
CHAT_BLAST_MESSAGE_SENT = 'Chat Blast: Message Sent',
SEND_MESSAGE_SUCCESS = 'Send Message: Success',
SEND_MESSAGE_FAILURE = 'Send Message: Failure',
DELETE_CHAT_SUCCESS = 'Delete Chat: Success',
Expand Down Expand Up @@ -2295,6 +2299,10 @@ type ConnectWalletError = {
error: string
}

type ChatBlastCTAClicked = {
eventName: Name.CHAT_BLAST_CTA_CLICKED
}

type CreateChatSuccess = {
eventName: Name.CREATE_CHAT_SUCCESS
}
Expand All @@ -2303,6 +2311,29 @@ type CreateChatFailure = {
eventName: Name.CREATE_CHAT_FAILURE
}

type CreateChatBlastSuccess = {
eventName: Name.CREATE_CHAT_BLAST_SUCCESS
audience: string
audienceContentType?: string
audienceContentId?: ID
sentBy: ID
}

type CreateChatBlastFailure = {
eventName: Name.CREATE_CHAT_BLAST_FAILURE
audience: string
audienceContentType?: string
audienceContentId?: ID
sentBy?: ID
}

type ChatBlastMessageSent = {
eventName: Name.CHAT_BLAST_MESSAGE_SENT
audience: string
audienceContentType?: string
audienceContentId?: ID
}

type SendMessageSuccess = {
eventName: Name.SEND_MESSAGE_SUCCESS
}
Expand Down Expand Up @@ -2743,9 +2774,12 @@ export type AllTrackingEvents =
| ConnectWalletAlreadyAssociated
| ConnectWalletAssociationError
| ConnectWalletError
| SendMessageSuccess
| ChatBlastCTAClicked
| ChatBlastMessageSent
| CreateChatSuccess
| CreateChatFailure
| CreateChatBlastSuccess
| CreateChatBlastFailure
| SendMessageSuccess
| SendMessageFailure
| DeleteChatSuccess
Expand Down
35 changes: 32 additions & 3 deletions packages/common/src/store/pages/chat/sagas.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
ChatBlast,
HashId,
type ChatMessage,
type TypedCommsResponse,
type UserChat,
Expand Down Expand Up @@ -464,8 +465,8 @@ function* doCreateChatBlast(action: ReturnType<typeof createChatBlast>) {
} = action.payload

const { track, make } = yield* getContext('analytics')
const currentUserId = yield* select(getUserId)
try {
const currentUserId = yield* select(getUserId)
if (!currentUserId) {
throw new Error('User not found')
}
Expand Down Expand Up @@ -499,7 +500,16 @@ function* doCreateChatBlast(action: ReturnType<typeof createChatBlast>) {
chat: newBlast
})
)
yield* call(track, make({ eventName: Name.CREATE_CHAT_SUCCESS }))
yield* call(
track,
make({
eventName: Name.CREATE_CHAT_BLAST_SUCCESS,
audience,
audienceContentType,
audienceContentId,
sentBy: currentUserId
})
)
}
} catch (e) {
console.error('createChatBlastFailed', e)
Expand All @@ -519,7 +529,17 @@ function* doCreateChatBlast(action: ReturnType<typeof createChatBlast>) {
audienceContentType
}
})
yield* call(track, make({ eventName: Name.CREATE_CHAT_FAILURE }))

yield* call(
track,
make({
eventName: Name.CREATE_CHAT_BLAST_FAILURE,
audience,
audienceContentType,
audienceContentId,
sentBy: currentUserId ?? undefined
})
)
}
}

Expand Down Expand Up @@ -599,6 +619,15 @@ function* doSendMessage(action: ReturnType<typeof sendMessage>) {
blastId: messageIdToUse,
message
})
yield* call(
track,
make({
eventName: Name.CHAT_BLAST_MESSAGE_SENT,
audience: chat.audience,
audienceContentType: chat.audience_content_type,
audienceContentId: HashId.parse(chat.audience_content_id)
})
)
} else {
yield* call([sdk.chats, sdk.chats.message], {
chatId,
Expand Down
3 changes: 3 additions & 0 deletions packages/mobile/src/screens/chat-screen/ChatBlastCTA.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useCallback } from 'react'

import { useCanSendChatBlast } from '@audius/common/hooks'
import { Name } from '@audius/common/models'
import { TouchableHighlight } from 'react-native-gesture-handler'

import {
Expand All @@ -12,6 +13,7 @@ import {
} from '@audius/harmony-native'
import { KeyboardAvoidingView } from 'app/components/core'
import { PLAY_BAR_HEIGHT } from 'app/components/now-playing-drawer/constants'
import { make, track } from 'app/services/analytics'

import { useAppDrawerNavigation } from '../app-drawer-screen'

Expand All @@ -32,6 +34,7 @@ export const ChatBlastCTA = () => {

const handleClick = useCallback(() => {
navigation.navigate('CreateChatBlast')
track(make({ eventName: Name.CHAT_BLAST_CTA_CLICKED }))
}, [navigation])

const userMeetsRequirements = useCanSendChatBlast()
Expand Down
3 changes: 3 additions & 0 deletions packages/web/src/pages/chat-page/components/ChatBlastCTA.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useCallback } from 'react'

import { useCanSendChatBlast } from '@audius/common/hooks'
import { Name } from '@audius/common/models'
import { useChatBlastModal } from '@audius/common/src/store'
import {
Box,
Expand All @@ -13,6 +14,7 @@ import {
IconTokenBronze
} from '@audius/harmony'

import { make, track } from 'services/analytics'
const messages = {
title: 'Send a Message Blast',
description: 'Send messages to your fans in bulk.',
Expand All @@ -32,6 +34,7 @@ export const ChatBlastCTA = (props: ChatBlastCTAProps) => {
const handleClick = useCallback(() => {
onClick()
openChatBlastModal()
track(make({ eventName: Name.CHAT_BLAST_CTA_CLICKED }))
}, [onClick, openChatBlastModal])

const userMeetsRequirements = useCanSendChatBlast()
Expand Down