diff --git a/src/analytics/metrics/types.ts b/src/analytics/metrics/types.ts index 726b3e5c2..56a55c1d1 100644 --- a/src/analytics/metrics/types.ts +++ b/src/analytics/metrics/types.ts @@ -1553,6 +1553,11 @@ export type Events = { * The profile the link is on, not the viewer. */ profileDid: string + /** + * The link's `app.bsky.actor.link` record, which tells apart two links to + * the same site. Editing a link keeps its record. + */ + linkUri: string | undefined domain: string /** * Name of the recognized support provider, if the link is a support link. @@ -1583,10 +1588,12 @@ export type Events = { * Logged on save, one event per link actually added or removed. */ 'profile:links:add': { + linkUri: string | undefined domain: string supportProvider: string | undefined } 'profile:links:remove': { + linkUri: string | undefined domain: string supportProvider: string | undefined } @@ -1595,8 +1602,10 @@ export type Events = { */ 'profile:links:preview': { profileDid: string + linkUri: string | undefined domain: string supportProvider: string | undefined + isOwnProfile: boolean } /** * A link couldn't be added, e.g. because its site is blocked. diff --git a/src/features/profileLinks/components/ProfileLinks.tsx b/src/features/profileLinks/components/ProfileLinks.tsx index 5d0a05b5a..645b5ded2 100644 --- a/src/features/profileLinks/components/ProfileLinks.tsx +++ b/src/features/profileLinks/components/ProfileLinks.tsx @@ -125,6 +125,7 @@ function ProfileLinksRow({ const logClick = (link: ProfileLink) => { ax.metric('profile:links:click', { profileDid: profile.did, + linkUri: link.uri, domain: getLinkHost(link.url), supportProvider: getSupportProvider(link.url)?.name, isOwnProfile, @@ -134,8 +135,10 @@ function ProfileLinksRow({ const showPreview = (link: ProfileLink) => { ax.metric('profile:links:preview', { profileDid: profile.did, + linkUri: link.uri, domain: getLinkHost(link.url), supportProvider: getSupportProvider(link.url)?.name, + isOwnProfile, }) setActiveLink(link) previewControl.open() diff --git a/src/features/profileLinks/metrics.ts b/src/features/profileLinks/metrics.ts index 85e9faed2..c6f0cb090 100644 --- a/src/features/profileLinks/metrics.ts +++ b/src/features/profileLinks/metrics.ts @@ -4,7 +4,8 @@ import {type ProfileLink} from './types' /** * Logs one event per link actually added or removed between two saved states, - * so edits made and then undone before saving don't count. + * so edits made and then undone before saving don't count. Pass `after` with + * the record URIs from the save, so added links can be told apart. */ export function logProfileLinkChanges( ax: ReturnType, @@ -16,6 +17,7 @@ export function logProfileLinkChanges( for (const link of after) { if (beforeUrls.has(link.url)) continue ax.metric('profile:links:add', { + linkUri: link.uri, domain: getLinkHost(link.url), supportProvider: getSupportProvider(link.url)?.name, }) @@ -23,6 +25,7 @@ export function logProfileLinkChanges( for (const link of before) { if (afterUrls.has(link.url)) continue ax.metric('profile:links:remove', { + linkUri: link.uri, domain: getLinkHost(link.url), supportProvider: getSupportProvider(link.url)?.name, }) diff --git a/src/screens/Profile/Header/EditProfileDialog.tsx b/src/screens/Profile/Header/EditProfileDialog.tsx index ce94c5bf3..483d5b35e 100644 --- a/src/screens/Profile/Header/EditProfileDialog.tsx +++ b/src/screens/Profile/Header/EditProfileDialog.tsx @@ -239,7 +239,11 @@ function DialogInner({ newUserBanner, }) if (nextLinks && written) { - logProfileLinkChanges(ax, storedLinks ?? [], nextLinks) + logProfileLinkChanges( + ax, + storedLinks ?? [], + nextLinks.map((link, i) => ({...link, uri: written.refs[i].uri})), + ) setOwnProfileLinksCache(profile.did, nextLinks, written.refs) await written.deleteRemoved() }