add metrics
This commit is contained in:
@@ -7,6 +7,7 @@ import {useNavigation} from '@react-navigation/native'
|
|||||||
import {type NavigationProp} from '#/lib/routes/types'
|
import {type NavigationProp} from '#/lib/routes/types'
|
||||||
import {sanitizeDisplayName} from '#/lib/strings/display-names'
|
import {sanitizeDisplayName} from '#/lib/strings/display-names'
|
||||||
import {sanitizeHandle} from '#/lib/strings/handles'
|
import {sanitizeHandle} from '#/lib/strings/handles'
|
||||||
|
import {logger} from '#/logger'
|
||||||
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
||||||
import {useListConvosQuery} from '#/state/queries/messages/list-conversations'
|
import {useListConvosQuery} from '#/state/queries/messages/list-conversations'
|
||||||
import {useSession} from '#/state/session'
|
import {useSession} from '#/state/session'
|
||||||
@@ -30,6 +31,7 @@ export function RecentChats({postUri}: {postUri: string}) {
|
|||||||
|
|
||||||
const onSelectChat = (convoId: string) => {
|
const onSelectChat = (convoId: string) => {
|
||||||
control.close(() => {
|
control.close(() => {
|
||||||
|
logger.metric('share:press:recentDm', {}, {statsig: true})
|
||||||
navigation.navigate('MessagesConversation', {
|
navigation.navigate('MessagesConversation', {
|
||||||
conversation: convoId,
|
conversation: convoId,
|
||||||
embed: postUri,
|
embed: postUri,
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {makeProfileLink} from '#/lib/routes/links'
|
|||||||
import {type NavigationProp} from '#/lib/routes/types'
|
import {type NavigationProp} from '#/lib/routes/types'
|
||||||
import {shareText, shareUrl} from '#/lib/sharing'
|
import {shareText, shareUrl} from '#/lib/sharing'
|
||||||
import {toShareUrl} from '#/lib/strings/url-helpers'
|
import {toShareUrl} from '#/lib/strings/url-helpers'
|
||||||
|
import {logger} from '#/logger'
|
||||||
import {useProfileShadow} from '#/state/cache/profile-shadow'
|
import {useProfileShadow} from '#/state/cache/profile-shadow'
|
||||||
import {useSession} from '#/state/session'
|
import {useSession} from '#/state/session'
|
||||||
import * as Toast from '#/view/com/util/Toast'
|
import * as Toast from '#/view/com/util/Toast'
|
||||||
@@ -54,12 +55,14 @@ let ShareMenuItems = ({
|
|||||||
postAuthor.did !== currentAccount?.did && hideInPWI
|
postAuthor.did !== currentAccount?.did && hideInPWI
|
||||||
|
|
||||||
const onSharePost = () => {
|
const onSharePost = () => {
|
||||||
|
logger.metric('share:press:nativeShare', {}, {statsig: true})
|
||||||
const url = toShareUrl(href)
|
const url = toShareUrl(href)
|
||||||
shareUrl(url)
|
shareUrl(url)
|
||||||
onShareProp()
|
onShareProp()
|
||||||
}
|
}
|
||||||
|
|
||||||
const onCopyLink = () => {
|
const onCopyLink = () => {
|
||||||
|
logger.metric('share:press:copyLink', {}, {statsig: true})
|
||||||
const url = toShareUrl(href)
|
const url = toShareUrl(href)
|
||||||
ExpoClipboard.setUrlAsync(url).then(() =>
|
ExpoClipboard.setUrlAsync(url).then(() =>
|
||||||
Toast.show(_(msg`Copied to clipboard`), 'clipboard-check'),
|
Toast.show(_(msg`Copied to clipboard`), 'clipboard-check'),
|
||||||
@@ -93,7 +96,10 @@ let ShareMenuItems = ({
|
|||||||
<Menu.Item
|
<Menu.Item
|
||||||
testID="postDropdownSendViaDMBtn"
|
testID="postDropdownSendViaDMBtn"
|
||||||
label={_(msg`Send via direct message`)}
|
label={_(msg`Send via direct message`)}
|
||||||
onPress={() => sendViaChatControl.open()}>
|
onPress={() => {
|
||||||
|
logger.metric('share:press:openDmSearch', {}, {statsig: true})
|
||||||
|
sendViaChatControl.open()
|
||||||
|
}}>
|
||||||
<Menu.ItemText>
|
<Menu.ItemText>
|
||||||
<Trans>Send via direct message</Trans>
|
<Trans>Send via direct message</Trans>
|
||||||
</Menu.ItemText>
|
</Menu.ItemText>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {makeProfileLink} from '#/lib/routes/links'
|
|||||||
import {type NavigationProp} from '#/lib/routes/types'
|
import {type NavigationProp} from '#/lib/routes/types'
|
||||||
import {shareText, shareUrl} from '#/lib/sharing'
|
import {shareText, shareUrl} from '#/lib/sharing'
|
||||||
import {toShareUrl} from '#/lib/strings/url-helpers'
|
import {toShareUrl} from '#/lib/strings/url-helpers'
|
||||||
|
import {logger} from '#/logger'
|
||||||
import {isWeb} from '#/platform/detection'
|
import {isWeb} from '#/platform/detection'
|
||||||
import {useProfileShadow} from '#/state/cache/profile-shadow'
|
import {useProfileShadow} from '#/state/cache/profile-shadow'
|
||||||
import {useSession} from '#/state/session'
|
import {useSession} from '#/state/session'
|
||||||
@@ -58,13 +59,15 @@ let ShareMenuItems = ({
|
|||||||
const showLoggedOutWarning =
|
const showLoggedOutWarning =
|
||||||
postAuthor.did !== currentAccount?.did && hideInPWI
|
postAuthor.did !== currentAccount?.did && hideInPWI
|
||||||
|
|
||||||
const onSharePost = () => {
|
const onCopyLink = () => {
|
||||||
|
logger.metric('share:press:copyLink', {}, {statsig: true})
|
||||||
const url = toShareUrl(href)
|
const url = toShareUrl(href)
|
||||||
shareUrl(url)
|
shareUrl(url)
|
||||||
onShareProp()
|
onShareProp()
|
||||||
}
|
}
|
||||||
|
|
||||||
const onSelectChatToShareTo = (conversation: string) => {
|
const onSelectChatToShareTo = (conversation: string) => {
|
||||||
|
logger.metric('share:press:dmSelected', {}, {statsig: true})
|
||||||
navigation.navigate('MessagesConversation', {
|
navigation.navigate('MessagesConversation', {
|
||||||
conversation,
|
conversation,
|
||||||
embed: postUri,
|
embed: postUri,
|
||||||
@@ -92,7 +95,7 @@ let ShareMenuItems = ({
|
|||||||
if (showLoggedOutWarning) {
|
if (showLoggedOutWarning) {
|
||||||
loggedOutWarningPromptControl.open()
|
loggedOutWarningPromptControl.open()
|
||||||
} else {
|
} else {
|
||||||
onSharePost()
|
onCopyLink()
|
||||||
}
|
}
|
||||||
}}>
|
}}>
|
||||||
<Menu.ItemText>
|
<Menu.ItemText>
|
||||||
@@ -105,7 +108,10 @@ let ShareMenuItems = ({
|
|||||||
<Menu.Item
|
<Menu.Item
|
||||||
testID="postDropdownSendViaDMBtn"
|
testID="postDropdownSendViaDMBtn"
|
||||||
label={_(msg`Send via direct message`)}
|
label={_(msg`Send via direct message`)}
|
||||||
onPress={() => sendViaChatControl.open()}>
|
onPress={() => {
|
||||||
|
logger.metric('share:press:openDmSearch', {}, {statsig: true})
|
||||||
|
sendViaChatControl.open()
|
||||||
|
}}>
|
||||||
<Menu.ItemText>
|
<Menu.ItemText>
|
||||||
<Trans>Send via direct message</Trans>
|
<Trans>Send via direct message</Trans>
|
||||||
</Menu.ItemText>
|
</Menu.ItemText>
|
||||||
@@ -117,7 +123,10 @@ let ShareMenuItems = ({
|
|||||||
<Menu.Item
|
<Menu.Item
|
||||||
testID="postDropdownEmbedBtn"
|
testID="postDropdownEmbedBtn"
|
||||||
label={_(msg`Embed post`)}
|
label={_(msg`Embed post`)}
|
||||||
onPress={() => embedPostControl.open()}>
|
onPress={() => {
|
||||||
|
logger.metric('share:press:embed', {}, {statsig: true})
|
||||||
|
embedPostControl.open()
|
||||||
|
}}>
|
||||||
<Menu.ItemText>{_(msg`Embed post`)}</Menu.ItemText>
|
<Menu.ItemText>{_(msg`Embed post`)}</Menu.ItemText>
|
||||||
<Menu.ItemIcon icon={CodeBrackets} position="right" />
|
<Menu.ItemIcon icon={CodeBrackets} position="right" />
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
@@ -157,7 +166,7 @@ let ShareMenuItems = ({
|
|||||||
description={_(
|
description={_(
|
||||||
msg`This post is only visible to logged-in users. It won't be visible to people who aren't signed in.`,
|
msg`This post is only visible to logged-in users. It won't be visible to people who aren't signed in.`,
|
||||||
)}
|
)}
|
||||||
onConfirm={onSharePost}
|
onConfirm={onCopyLink}
|
||||||
confirmButtonCta={_(msg`Share anyway`)}
|
confirmButtonCta={_(msg`Share anyway`)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import type React from 'react'
|
|||||||
import {makeProfileLink} from '#/lib/routes/links'
|
import {makeProfileLink} from '#/lib/routes/links'
|
||||||
import {shareUrl} from '#/lib/sharing'
|
import {shareUrl} from '#/lib/sharing'
|
||||||
import {toShareUrl} from '#/lib/strings/url-helpers'
|
import {toShareUrl} from '#/lib/strings/url-helpers'
|
||||||
|
import {logger} from '#/logger'
|
||||||
import {type Shadow} from '#/state/cache/post-shadow'
|
import {type Shadow} from '#/state/cache/post-shadow'
|
||||||
import {EventStopper} from '#/view/com/util/EventStopper'
|
import {EventStopper} from '#/view/com/util/EventStopper'
|
||||||
import {native} from '#/alf'
|
import {native} from '#/alf'
|
||||||
@@ -53,12 +54,19 @@ let ShareMenuButton = ({
|
|||||||
// HACK. We need the state update to be flushed by the time
|
// HACK. We need the state update to be flushed by the time
|
||||||
// menuControl.open() fires but RN doesn't expose flushSync.
|
// menuControl.open() fires but RN doesn't expose flushSync.
|
||||||
setTimeout(menuControl.open)
|
setTimeout(menuControl.open)
|
||||||
|
|
||||||
|
logger.metric(
|
||||||
|
'share:open',
|
||||||
|
{context: big ? 'thread' : 'feed'},
|
||||||
|
{statsig: true},
|
||||||
|
)
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
[menuControl, setHasBeenOpen],
|
[menuControl, setHasBeenOpen, big],
|
||||||
)
|
)
|
||||||
|
|
||||||
const onNativeLongPress = () => {
|
const onNativeLongPress = () => {
|
||||||
|
logger.metric('share:press:nativeShare', {}, {statsig: true})
|
||||||
const urip = new AtUri(post.uri)
|
const urip = new AtUri(post.uri)
|
||||||
const href = makeProfileLink(post.author, 'post', urip.rkey)
|
const href = makeProfileLink(post.author, 'post', urip.rkey)
|
||||||
const url = toShareUrl(href)
|
const url = toShareUrl(href)
|
||||||
|
|||||||
@@ -395,4 +395,12 @@ export type MetricEvents = {
|
|||||||
'live:card:openProfile': {subject: string}
|
'live:card:openProfile': {subject: string}
|
||||||
'live:view:profile': {subject: string}
|
'live:view:profile': {subject: string}
|
||||||
'live:view:post': {subject: string; feed?: string}
|
'live:view:post': {subject: string; feed?: string}
|
||||||
|
|
||||||
|
'share:open': {context: 'feed' | 'thread'}
|
||||||
|
'share:press:copyLink': {}
|
||||||
|
'share:press:nativeShare': {}
|
||||||
|
'share:press:openDmSearch': {}
|
||||||
|
'share:press:dmSelected': {}
|
||||||
|
'share:press:recentDm': {}
|
||||||
|
'share:press:embed': {}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user