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
feat(Page): Support Page.getMetrics and metrics event. #939
Conversation
Provides access to the current page performance metrics. Allows to push page metrics from the page JavaScript with console.timeStamp()
Thanks Alexei! Let's list the metric names explicitly so that it's easier to consume. |
test/test.js
Outdated
checkMetrics(metrics.metrics); | ||
})); | ||
function checkMetrics(metrics) { | ||
expect(metrics['Timestamp']).toBeGreaterThan(0); |
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.
can we also check that there are no other fields beyond these? this would allow us to update docs when something new is added
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.
There are other fields coming over the protocol. But we don't want to document/expose those in puppeteer.
lib/Page.js
Outdated
_buildMetricsObject(metrics) { | ||
const result = {}; | ||
for (const metric of metrics || []) | ||
result[metric.name] = metric.value; |
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.
since we don't want to expose certain numbers, can we white-list properties that we copy (instead of copying everything)?
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.
Done
Provides access to the current page performance metrics. Allows to push page metrics from the page JavaScript with console.timeStamp() Fixes puppeteer#309
Provides access to the current page performance metrics.
Allows to push page metrics from the page JavaScript with
console.timeStamp()
Fixes #309