Add new analytics events for group chats (#10830)
This commit is contained in:
@@ -35,6 +35,7 @@ import {EditBig_Stroke2_Corner2_Rounded as EditIcon} from '#/components/icons/Ed
|
||||
import {Loader} from '#/components/Loader'
|
||||
import * as Toast from '#/components/Toast'
|
||||
import {Text} from '#/components/Typography'
|
||||
import {useAnalytics} from '#/analytics'
|
||||
import {IS_WEB} from '#/env'
|
||||
import {CopyTextButton} from './CopyTextButton'
|
||||
import {EditTextButton} from './EditTextButton'
|
||||
@@ -63,6 +64,9 @@ export function InviteLinkDialog({
|
||||
}) {
|
||||
const t = useTheme()
|
||||
const {t: l, i18n} = useLingui()
|
||||
const ax = useAnalytics()
|
||||
|
||||
const convoId = convo.view.id
|
||||
|
||||
const ownerName = createSanitizedDisplayName(
|
||||
owner,
|
||||
@@ -92,9 +96,10 @@ export function InviteLinkDialog({
|
||||
const {openComposer} = useOpenComposer()
|
||||
|
||||
const {mutate: createJoinLink, isPending: isCreating} = useCreateJoinLink(
|
||||
convo.view.id,
|
||||
convoId,
|
||||
{
|
||||
onSuccess: () => {
|
||||
ax.metric('groupchat:owner:inviteLink:create', {convoId})
|
||||
setStep(Step.MANAGE)
|
||||
},
|
||||
onError: () => {
|
||||
@@ -105,7 +110,7 @@ export function InviteLinkDialog({
|
||||
},
|
||||
)
|
||||
const {mutate: editJoinLink, isPending: isEditing} = useEditJoinLink(
|
||||
convo.view.id,
|
||||
convoId,
|
||||
{
|
||||
onSuccess: () => {
|
||||
setStep(Step.MANAGE)
|
||||
@@ -118,8 +123,11 @@ export function InviteLinkDialog({
|
||||
},
|
||||
)
|
||||
const {mutate: disableJoinLink, isPending: isDisabling} = useDisableJoinLink(
|
||||
convo.view.id,
|
||||
convoId,
|
||||
{
|
||||
onSuccess: () => {
|
||||
ax.metric('groupchat:owner:inviteLink:disable', {convoId})
|
||||
},
|
||||
onError: () => {
|
||||
Toast.show(l`Failed to disable invite link`, {
|
||||
type: 'error',
|
||||
@@ -128,7 +136,7 @@ export function InviteLinkDialog({
|
||||
},
|
||||
)
|
||||
const {mutate: enableJoinLink, isPending: isEnabling} = useEnableJoinLink(
|
||||
convo.view.id,
|
||||
convoId,
|
||||
{
|
||||
onError: () => {
|
||||
Toast.show(l`Failed to enable invite link`, {
|
||||
@@ -325,7 +333,13 @@ export function InviteLinkDialog({
|
||||
<CopyTextButton
|
||||
disabled={linkDisabled || !joinLink?.code}
|
||||
label={l`Invite link`}
|
||||
value={joinLinkURI}>
|
||||
value={joinLinkURI}
|
||||
onPress={() => {
|
||||
ax.metric('groupchat:inviteLink:shareButton:press', {
|
||||
convoId,
|
||||
method: 'copy',
|
||||
})
|
||||
}}>
|
||||
<Text
|
||||
numberOfLines={1}
|
||||
style={[
|
||||
@@ -385,6 +399,10 @@ export function InviteLinkDialog({
|
||||
color="primary_subtle"
|
||||
style={[a.flex_1, a.rounded_full]}
|
||||
onPress={() => {
|
||||
ax.metric('groupchat:inviteLink:shareButton:press', {
|
||||
convoId,
|
||||
method: 'post',
|
||||
})
|
||||
control.close(() => {
|
||||
openComposer({
|
||||
text: joinLinkURI,
|
||||
@@ -401,6 +419,10 @@ export function InviteLinkDialog({
|
||||
color="primary_subtle"
|
||||
style={[a.flex_1, a.rounded_full]}
|
||||
onPress={() => {
|
||||
ax.metric('groupchat:inviteLink:shareButton:press', {
|
||||
convoId,
|
||||
method: 'native',
|
||||
})
|
||||
void shareUrl(joinLinkURI)
|
||||
}}>
|
||||
<Trans>Share</Trans>
|
||||
|
||||
@@ -135,7 +135,7 @@ export function MessagesList({
|
||||
const ax = useAnalytics()
|
||||
const convoState = useConvoActive()
|
||||
const agent = useAgent()
|
||||
const {hasSession} = useSession()
|
||||
const {hasSession, currentAccount} = useSession()
|
||||
const getPost = useGetPost()
|
||||
const getJoinLinkPreview = useGetJoinLinkPreview()
|
||||
const {embed: messageEmbed, setEmbed} = useMessageEmbed()
|
||||
@@ -471,6 +471,13 @@ export function MessagesList({
|
||||
},
|
||||
embedView,
|
||||
)
|
||||
|
||||
if (convoState.convo.kind === 'group') {
|
||||
ax.metric('groupchat:message:send', {
|
||||
convoId: convoState.convo.view.id,
|
||||
isOwner: convoState.convo.primaryMember?.did === currentAccount?.did,
|
||||
})
|
||||
}
|
||||
},
|
||||
[
|
||||
agent,
|
||||
@@ -481,6 +488,8 @@ export function MessagesList({
|
||||
hasSession,
|
||||
hasScrolled,
|
||||
setHasScrolled,
|
||||
ax,
|
||||
currentAccount?.did,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import {ChainLink_Stroke2_Corner0_Rounded as ChainLinkIcon} from '#/components/i
|
||||
import {PersonPlus_Stroke2_Corner0_Rounded as PersonPlusIcon} from '#/components/icons/Person'
|
||||
import * as Toast from '#/components/Toast'
|
||||
import {Text} from '#/components/Typography'
|
||||
import {useAnalytics} from '#/analytics'
|
||||
import {InviteLinkDialog} from './InviteLinkDialog'
|
||||
|
||||
export function MessagesListGroupInfoPanel({
|
||||
@@ -25,6 +26,7 @@ export function MessagesListGroupInfoPanel({
|
||||
}) {
|
||||
const t = useTheme()
|
||||
const {t: l} = useLingui()
|
||||
const ax = useAnalytics()
|
||||
const moderationOpts = useModerationOpts()
|
||||
const convoId = convo.view.id
|
||||
|
||||
@@ -35,6 +37,7 @@ export function MessagesListGroupInfoPanel({
|
||||
|
||||
const {mutate: addGroupMembers} = useAddGroupMembers(convoId, {
|
||||
onSuccess: () => {
|
||||
ax.metric('groupchat:owner:inviteMember', {convoId})
|
||||
addMembersControl.close()
|
||||
},
|
||||
onError: e => {
|
||||
|
||||
Reference in New Issue
Block a user