diff --git a/src/analytics/metrics/types.ts b/src/analytics/metrics/types.ts
index 97b7fcfe09..65f2a5d39f 100644
--- a/src/analytics/metrics/types.ts
+++ b/src/analytics/metrics/types.ts
@@ -875,4 +875,9 @@ export type Events = {
'liveEvents:unhideAllFeedBanners': {
context: LiveEventFeedMetricContext
}
+
+ 'profile:associated:germ:click-to-chat': {}
+ 'profile:associated:germ:click-self-info': {}
+ 'profile:associated:germ:self-disconnect': {}
+ 'profile:associated:germ:self-reconnect': {}
}
diff --git a/src/screens/Profile/components/GermButton.tsx b/src/screens/Profile/components/GermButton.tsx
index 17aefc89b9..24ca5331c0 100644
--- a/src/screens/Profile/components/GermButton.tsx
+++ b/src/screens/Profile/components/GermButton.tsx
@@ -11,7 +11,6 @@ import {useMutation, useQueryClient} from '@tanstack/react-query'
import {until} from '#/lib/async/until'
import {isNetworkError} from '#/lib/strings/errors'
-import {logger} from '#/logger'
import {RQKEY} from '#/state/queries/profile'
import {useAgent, useSession} from '#/state/session'
import {atoms as a, useTheme, web} from '#/alf'
@@ -23,6 +22,7 @@ import {Link} from '#/components/Link'
import {Loader} from '#/components/Loader'
import * as Toast from '#/components/Toast'
import {Text} from '#/components/Typography'
+import {useAnalytics} from '#/analytics'
import type * as bsky from '#/types/bsky'
export function GermButton({
@@ -32,8 +32,9 @@ export function GermButton({
germ: AppBskyActorDefs.ProfileAssociatedGerm
profile: bsky.profile.AnyProfileView
}) {
- const {_} = useLingui()
const t = useTheme()
+ const ax = useAnalytics()
+ const {_} = useLingui()
const {currentAccount} = useSession()
const linkWarningControl = Dialog.useDialogControl()
@@ -63,6 +64,7 @@ export function GermButton({
{
+ ax.metric('profile:associated:germ:click-to-chat', {})
if (isCustomGermDomain(url)) {
evt.preventDefault()
linkWarningControl.open()
@@ -111,10 +113,11 @@ function GermLogo({size}: {size: 'small' | 'large'}) {
}
function GermSelfButton({did}: {did: string}) {
+ const t = useTheme()
+ const ax = useAnalytics()
const {_} = useLingui()
const selfExplanationDialogControl = Dialog.useDialogControl()
const agent = useAgent()
- const t = useTheme()
const queryClient = useQueryClient()
const {mutate: deleteDeclaration, isPending} = useMutation({
@@ -137,6 +140,8 @@ function GermSelfButton({did}: {did: string}) {
return previousRecord
},
onSuccess: previousRecord => {
+ ax.metric('profile:associated:germ:self-disconnect', {})
+
async function undo() {
if (!previousRecord) return
await agent.com.germnetwork.declaration.put(
@@ -150,6 +155,8 @@ function GermSelfButton({did}: {did: string}) {
await queryClient.refetchQueries({queryKey: RQKEY(did)})
Toast.show(_(msg`Germ DM reconnected`))
+
+ ax.metric('profile:associated:germ:self-reconnect', {})
}
selfExplanationDialogControl.close(() => {
@@ -172,9 +179,12 @@ function GermSelfButton({did}: {did: string}) {
onError: error => {
Toast.show(
_(msg`Failed to remove Germ DM link. Error: ${error?.message}`),
+ {
+ type: 'error',
+ },
)
if (!isNetworkError(error)) {
- logger.error('Failed to remove Germ DM link', {safeMessage: error})
+ ax.logger.error('Failed to remove Germ DM link', {safeMessage: error})
}
},
})
@@ -183,7 +193,10 @@ function GermSelfButton({did}: {did: string}) {
<>