-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Average Scroll Depth Metric: extracted tracker changes #4826
Conversation
// also accounted for. | ||
var count = 0 | ||
var interval = setInterval(function () { | ||
currentDocumentHeight = getDocumentHeight() |
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.
I wonder if we should also update maxScrollDepthPx here as well to account for any weird reflows.
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.
Makes sense, but it's tricky to optimise our script for this - a reflow might both increase and decrease maxScrollDepthPx
(meaning that we would have to keep re-initialising it), but the user can already scroll during those three seconds, so that information might get lost when we blindly reset it.
I would leave it be for now. In worst case, the maxScrollDepthPx
will be smaller than it really is, resulting in a lower percentage. But even the very first viewport height after DOMContentLoaded should be a sensible initial value for maxScrollDepthPx. If it turns out to be an issue, we can come back to it later.
await page.evaluate(() => window.scrollBy(0, document.body.scrollHeight)) | ||
|
||
// Wait until documentHeight gets increased by the fixture JS | ||
await page.waitForSelector('#more-content') |
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.
Note: It might have been simpler to evaluate JS on the page appending a div/img rather than rely on timers which might be slightly finnicky.
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.
Good note! The timeout in the test fixture was intended only for debugging. I've removed it now. It now actually works by simply appending a 2000px div to the document.
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.
Small notes but 👍
Changes
This PR extracts the tracker changes from #4791, and addresses tracker related feedback as well.
Tests
Changelog
Documentation
Dark mode