Conversation
_initAnalytics() only checks window.gtag truthiness once at setup; track() then calls window.gtag(...) unguarded on every tracked event (play, pause, volumechange, etc). If gtag becomes non-callable after init - a consent-management tool swapping it out, an ad-blocker, CSP - the next tracked event throws an uncaught TypeError, breaking whatever runs after it (same failure shape as ZD #388711 for the old window.ga integration). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
✅ Deploy Preview for cld-video-player ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
✅ Deploy Preview for cld-vp-esm-pages ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Covers both sides of the track() guard: real gtag calls still fire normally, and a non-callable gtag (consent tool, ad-blocker) no longer errors. Since videojs's event dispatcher catches handler exceptions and logs them via videojs.log.error instead of rethrowing, the non-callable case asserts against that log spy rather than a thrown error. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_initAnalytics()(src/video-player.js) checkswindow.gtagtruthiness once, at setup, and bails with a console error if it's missing.AnalyticsPlugin.track()(src/plugins/analytics/index.js) callswindow.gtag('event', ...)unguarded on every tracked player event (play,pause,volumechange,ended, ...) with no re-check that it's still callable.gtagbecomes non-callable after init — a consent-management tool (OneTrust, Cookiebot) swapping it out after a consent change, an ad-blocker, a CSP block — the next tracked event throws an uncaughtTypeError: window.gtag is not a function. Same failure shape as ZD #388711 (window.gaera), just migrated togtag.Test plan
master:docs/analytics.html, ranwindow.gtag = 'not-a-function'in console, then played/paused/toggled volume — confirmed uncaughtTypeError: window.gtag is not a functionfromAnalyticsPlugin.trackforvolumechange,play,pause.gtag('event', ...)calls /window.dataLayergrowth) still fires normally whengtagis callable.npm run test:unitfor regressions in analytics plugin coverage.🤖 Generated with Claude Code