Refactor photo embed analytics to post:photoEmbed:* namespace (#10784)
Co-authored-by: Eric Bailey <git@esb.lol> Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -8,7 +8,10 @@ import {atoms as a, tokens} from '#/alf'
|
||||
import {AutoSizedImage} from '#/components/images/AutoSizedImage'
|
||||
import {Gallery} from '#/components/images/Gallery'
|
||||
import {ImageLayoutGrid} from '#/components/images/ImageLayoutGrid'
|
||||
import {useLightboxControls} from '#/components/Lightbox/state'
|
||||
import {
|
||||
type LightboxMetricsContext,
|
||||
useLightboxControls,
|
||||
} from '#/components/Lightbox/state'
|
||||
import {type Dimensions} from '#/components/Lightbox/types'
|
||||
import {ImageContextMenu} from '#/components/Post/Embed/ImageContextMenu'
|
||||
import {PostEmbedViewContext} from '#/components/Post/Embed/types'
|
||||
@@ -40,6 +43,20 @@ export function ImageEmbed({
|
||||
? images.length > MAX_GRID_IMAGES
|
||||
: ax.features.enabled(ax.features.PostGalleryEmbedEnable)
|
||||
|
||||
const layout: 'single' | 'grid' | 'carousel' =
|
||||
images.length === 1 ? 'single' : useExpandedLayout ? 'carousel' : 'grid'
|
||||
|
||||
const postContext = rest.post
|
||||
? {
|
||||
postUri: rest.post.uri,
|
||||
postAuthorDid: rest.post.author.did,
|
||||
feedDescriptor: rest.feedDescriptor,
|
||||
}
|
||||
: undefined
|
||||
const metricsContext: LightboxMetricsContext | undefined = postContext
|
||||
? {layout, ...postContext}
|
||||
: undefined
|
||||
|
||||
// Captured from AutoSizedImage so the peek-commit handler can reuse the same
|
||||
// ref + dims that a tap would — keeps the lightbox's return animation intact.
|
||||
const singleContainerRef = useRef<AnimatedRef<any> | null>(null)
|
||||
@@ -57,6 +74,14 @@ export function ImageEmbed({
|
||||
refs: AnimatedRef<any>[],
|
||||
fetchedDims: (Dimensions | null)[],
|
||||
) => {
|
||||
if (postContext) {
|
||||
ax.metric('post:photoEmbed:open', {
|
||||
layout,
|
||||
fromImage: index + 1,
|
||||
totalImages: images.length,
|
||||
...postContext,
|
||||
})
|
||||
}
|
||||
openLightbox({
|
||||
images: items.map((item, i) => ({
|
||||
...item,
|
||||
@@ -67,6 +92,7 @@ export function ImageEmbed({
|
||||
type: 'image',
|
||||
})),
|
||||
index,
|
||||
metricsContext,
|
||||
})
|
||||
}
|
||||
const onPressIn = (_: number) => {
|
||||
@@ -132,6 +158,7 @@ export function ImageEmbed({
|
||||
onPressIn={onPressIn}
|
||||
viewContext={rest.viewContext}
|
||||
isWithinQuote={rest.isWithinQuote}
|
||||
metricsPostContext={postContext}
|
||||
/>
|
||||
</View>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user