-
Notifications
You must be signed in to change notification settings - Fork 29
Add video playback observer #1721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for content-scope-scripts ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Temporary Branch UpdateThe temporary branch has been updated with the latest changes. Below are the details:
Please use the above install command to update to the latest version. |
[Beta] Generated file diffTime updated: Wed, 16 Jul 2025 16:12:58 GMT Android
File has changed Chrome-mv3
File has changed Firefox
File has changed Integration
File has changed Windows
File has changed Apple
File has changed |
@jonathanKingston Are there specific testing steps that should be used for this PR? I haven’t reviewed C-S-S changes before, so just checking what I should be watching out for here from an Apple perspective. (Also, the title says this is a WIP, is that intentional?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Video Telemetry Bugs: Deduplication and API Compatibility
The WebTelemetry
feature has two issues:
- Incomplete Video Deduplication: Telemetry events for videos without a discernible URL are not properly deduplicated. The
fireTelemetryForVideo
method checks fornull
in theseenVideoUrls
set but never addsnull
to it, causing repeated telemetry events for the same video. - API Compatibility Error: Accessing
navigator.userActivation.isActive
without checking for theuserActivation
API's availability can cause a runtime error in unsupported environments, breaking telemetry.
injected/src/features/web-telemetry.js#L33-L48
content-scope-scripts/injected/src/features/web-telemetry.js
Lines 33 to 48 in fbdd18a
fireTelemetryForVideo(video) { | |
const videoUrl = this.getVideoUrl(video); | |
if (this.seenVideoUrls.has(videoUrl)) { | |
return; | |
} | |
// If we have a URL, store it just to deduplicate | |
// This will clear on page change and isn't sent to native/server. | |
if (videoUrl) { | |
this.seenVideoUrls.add(videoUrl); | |
} | |
const message = { | |
userInteraction: navigator.userActivation.isActive, | |
}; | |
this.messaging.notify(MSG_VIDEO_PLAYBACK, message); | |
} |
Was this report helpful? Give feedback by reacting with 👍 or 👎
* Add video playback observer * Enable webCompat on Windows * Call on document load * Move to telemetry * Fix comment that was stolen * Add PoC test case * Add video listener * Listen earlier, dedupe messages * Check for presence of node * Make observer use documentElement as a fallback for a listener * Use notify as a fire and forget * Call messaging in the correct scope * Simplify * Use once listeners instead * add args to constructor * Add play watch on start * Fix scope * Cleanup * Rename to web-telemetry * Account for video tag reuse by deduping against URL instead * Bail out on seen urls --------- Co-authored-by: Jonathan Kingston <jkingston@duckduckgo.com> Co-authored-by: Jonathan Kingston <jonathan@jooped.co.uk>
Asana Task/Github Issue: https://app.asana.com/1/137249556945/project/1163321984198618/task/1210574035464142?focus=true
Description
Watches for video plays so they can be counted on the native side.
Relevant config change: duckduckgo/privacy-configuration#3452
Testing Steps
Checklist
Please tick all that apply: