Address video analytics review feedback
This commit is contained in:
committed by
Samuel Newman
parent
41c31abfd4
commit
d8915e7b8b
@@ -26,7 +26,7 @@ interface Props {
|
||||
post?: app.bsky.feed.defs.PostView
|
||||
}
|
||||
|
||||
export function VideoEmbed({embed}: Props) {
|
||||
export function VideoEmbed({embed, post}: Props) {
|
||||
const [key, setKey] = useState(0)
|
||||
|
||||
const renderError = useCallback(
|
||||
@@ -53,7 +53,7 @@ export function VideoEmbed({embed}: Props) {
|
||||
|
||||
const contents = (
|
||||
<ErrorBoundary renderError={renderError} key={key}>
|
||||
<InnerWrapper embed={embed} />
|
||||
<InnerWrapper embed={embed} post={post} />
|
||||
</ErrorBoundary>
|
||||
)
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ export function VideoEmbed({
|
||||
currentActiveView,
|
||||
} = useActiveVideoWeb()
|
||||
const [onScreen, setOnScreen] = useState(false)
|
||||
const [meaningfullyVisible, setMeaningfullyVisible] = useState(false)
|
||||
const [isFullscreen] = useFullscreen()
|
||||
const lastKnownTime = useRef<number | undefined>(undefined)
|
||||
const impressionTrackedRef = useRef(false)
|
||||
@@ -64,7 +65,7 @@ export function VideoEmbed({
|
||||
const active = isGif || activeFromContext
|
||||
|
||||
useEffect(() => {
|
||||
if (!onScreen || impressionTrackedRef.current) return
|
||||
if (!meaningfullyVisible || impressionTrackedRef.current) return
|
||||
impressionTrackedRef.current = true
|
||||
ax.metric('video:impression', {
|
||||
postUri: post?.uri,
|
||||
@@ -72,7 +73,7 @@ export function VideoEmbed({
|
||||
context: 'embed',
|
||||
presentation: isGif ? 'gif' : 'video',
|
||||
})
|
||||
}, [ax, isGif, onScreen, post?.author.did, post?.uri])
|
||||
}, [ax, isGif, meaningfullyVisible, post?.author.did, post?.uri])
|
||||
|
||||
useEffect(() => {
|
||||
if (!ref.current) return
|
||||
@@ -81,7 +82,10 @@ export function VideoEmbed({
|
||||
entries => {
|
||||
const entry = entries[0]
|
||||
if (!entry) return
|
||||
setOnScreen(entry.isIntersecting && entry.intersectionRatio >= 0.5)
|
||||
setOnScreen(entry.isIntersecting)
|
||||
setMeaningfullyVisible(
|
||||
entry.isIntersecting && entry.intersectionRatio >= 0.5,
|
||||
)
|
||||
// GIFs don't send position - they don't compete to be the active video
|
||||
if (!isGif) {
|
||||
sendPosition(
|
||||
|
||||
Reference in New Issue
Block a user