Logging and metrics

This commit is contained in:
Eric Bailey
2026-02-11 10:26:14 -06:00
parent c5f68d01af
commit 496a54b469
2 changed files with 23 additions and 5 deletions
+5
View File
@@ -875,4 +875,9 @@ export type Events = {
'liveEvents:unhideAllFeedBanners': { 'liveEvents:unhideAllFeedBanners': {
context: LiveEventFeedMetricContext context: LiveEventFeedMetricContext
} }
'profile:associated:germ:click-to-chat': {}
'profile:associated:germ:click-self-info': {}
'profile:associated:germ:self-disconnect': {}
'profile:associated:germ:self-reconnect': {}
} }
+18 -5
View File
@@ -11,7 +11,6 @@ import {useMutation, useQueryClient} from '@tanstack/react-query'
import {until} from '#/lib/async/until' import {until} from '#/lib/async/until'
import {isNetworkError} from '#/lib/strings/errors' import {isNetworkError} from '#/lib/strings/errors'
import {logger} from '#/logger'
import {RQKEY} from '#/state/queries/profile' import {RQKEY} from '#/state/queries/profile'
import {useAgent, useSession} from '#/state/session' import {useAgent, useSession} from '#/state/session'
import {atoms as a, useTheme, web} from '#/alf' import {atoms as a, useTheme, web} from '#/alf'
@@ -23,6 +22,7 @@ import {Link} from '#/components/Link'
import {Loader} from '#/components/Loader' import {Loader} from '#/components/Loader'
import * as Toast from '#/components/Toast' import * as Toast from '#/components/Toast'
import {Text} from '#/components/Typography' import {Text} from '#/components/Typography'
import {useAnalytics} from '#/analytics'
import type * as bsky from '#/types/bsky' import type * as bsky from '#/types/bsky'
export function GermButton({ export function GermButton({
@@ -32,8 +32,9 @@ export function GermButton({
germ: AppBskyActorDefs.ProfileAssociatedGerm germ: AppBskyActorDefs.ProfileAssociatedGerm
profile: bsky.profile.AnyProfileView profile: bsky.profile.AnyProfileView
}) { }) {
const {_} = useLingui()
const t = useTheme() const t = useTheme()
const ax = useAnalytics()
const {_} = useLingui()
const {currentAccount} = useSession() const {currentAccount} = useSession()
const linkWarningControl = Dialog.useDialogControl() const linkWarningControl = Dialog.useDialogControl()
@@ -63,6 +64,7 @@ export function GermButton({
<Link <Link
to={url} to={url}
onPress={evt => { onPress={evt => {
ax.metric('profile:associated:germ:click-to-chat', {})
if (isCustomGermDomain(url)) { if (isCustomGermDomain(url)) {
evt.preventDefault() evt.preventDefault()
linkWarningControl.open() linkWarningControl.open()
@@ -111,10 +113,11 @@ function GermLogo({size}: {size: 'small' | 'large'}) {
} }
function GermSelfButton({did}: {did: string}) { function GermSelfButton({did}: {did: string}) {
const t = useTheme()
const ax = useAnalytics()
const {_} = useLingui() const {_} = useLingui()
const selfExplanationDialogControl = Dialog.useDialogControl() const selfExplanationDialogControl = Dialog.useDialogControl()
const agent = useAgent() const agent = useAgent()
const t = useTheme()
const queryClient = useQueryClient() const queryClient = useQueryClient()
const {mutate: deleteDeclaration, isPending} = useMutation({ const {mutate: deleteDeclaration, isPending} = useMutation({
@@ -137,6 +140,8 @@ function GermSelfButton({did}: {did: string}) {
return previousRecord return previousRecord
}, },
onSuccess: previousRecord => { onSuccess: previousRecord => {
ax.metric('profile:associated:germ:self-disconnect', {})
async function undo() { async function undo() {
if (!previousRecord) return if (!previousRecord) return
await agent.com.germnetwork.declaration.put( await agent.com.germnetwork.declaration.put(
@@ -150,6 +155,8 @@ function GermSelfButton({did}: {did: string}) {
await queryClient.refetchQueries({queryKey: RQKEY(did)}) await queryClient.refetchQueries({queryKey: RQKEY(did)})
Toast.show(_(msg`Germ DM reconnected`)) Toast.show(_(msg`Germ DM reconnected`))
ax.metric('profile:associated:germ:self-reconnect', {})
} }
selfExplanationDialogControl.close(() => { selfExplanationDialogControl.close(() => {
@@ -172,9 +179,12 @@ function GermSelfButton({did}: {did: string}) {
onError: error => { onError: error => {
Toast.show( Toast.show(
_(msg`Failed to remove Germ DM link. Error: ${error?.message}`), _(msg`Failed to remove Germ DM link. Error: ${error?.message}`),
{
type: 'error',
},
) )
if (!isNetworkError(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}) {
<> <>
<Button <Button
label={_(msg`Learn more about your Germ DM link`)} label={_(msg`Learn more about your Germ DM link`)}
onPress={selfExplanationDialogControl.open} onPress={() => {
ax.metric('profile:associated:germ:click-self-info', {})
selfExplanationDialogControl.open()
}}
style={[ style={[
t.atoms.bg_contrast_50, t.atoms.bg_contrast_50,
a.rounded_full, a.rounded_full,