Add link-click metrics (#6934)

* Add link-click metrics

* Fix conditional
This commit is contained in:
Paul Frazee
2024-12-03 15:03:22 -08:00
committed by GitHub
parent 79f807dc4f
commit 0c71f8196f
2 changed files with 14 additions and 0 deletions
+10
View File
@@ -2,10 +2,13 @@ import {useCallback} from 'react'
import {Linking} from 'react-native' import {Linking} from 'react-native'
import * as WebBrowser from 'expo-web-browser' import * as WebBrowser from 'expo-web-browser'
import {logEvent} from '#/lib/statsig/statsig'
import { import {
createBskyAppAbsoluteUrl, createBskyAppAbsoluteUrl,
isBskyAppUrl,
isBskyRSSUrl, isBskyRSSUrl,
isRelativeUrl, isRelativeUrl,
toNiceDomain,
} from '#/lib/strings/url-helpers' } from '#/lib/strings/url-helpers'
import {isNative} from '#/platform/detection' import {isNative} from '#/platform/detection'
import {useModalControls} from '#/state/modals' import {useModalControls} from '#/state/modals'
@@ -25,6 +28,13 @@ export function useOpenLink() {
url = createBskyAppAbsoluteUrl(url) url = createBskyAppAbsoluteUrl(url)
} }
if (!isBskyAppUrl(url)) {
logEvent('link:clicked', {
domain: toNiceDomain(url),
url,
})
}
if (isNative && !url.startsWith('mailto:')) { if (isNative && !url.startsWith('mailto:')) {
if (override === undefined && enabled === undefined) { if (override === undefined && enabled === undefined) {
openModal({ openModal({
+4
View File
@@ -211,6 +211,10 @@ export type LogEvents = {
'starterPack:opened': { 'starterPack:opened': {
starterPack: string starterPack: string
} }
'link:clicked': {
url: string
domain: string
}
'feed:interstitial:profileCard:press': {} 'feed:interstitial:profileCard:press': {}
'feed:interstitial:feedCard:press': {} 'feed:interstitial:feedCard:press': {}