fire web playback failure metric only once

This commit is contained in:
vineyardbovines
2026-07-16 14:40:01 -04:00
parent 8a90310a49
commit a318d81600
@@ -263,7 +263,15 @@ function VideoError({
const errorMessage = error instanceof Error ? error.message : String(error)
const presentation = embed.presentation === 'gif' ? 'gif' : 'video'
const playlist = embed.playlist
/*
* Fire exactly once per failure - the analytics context identity can change
* (session/geolocation updates) while this fallback stays mounted, which
* would otherwise re-run the effect and double-count.
*/
const fired = useRef(false)
useEffect(() => {
if (fired.current) return
fired.current = true
ax.metric('video:playback:failed', {
surface: 'feed',
presentation,