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>
|
||||
|
||||
Reference in New Issue
Block a user