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