-
Notifications
You must be signed in to change notification settings - Fork 41
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
Add web vital metrics #836
Merged
Merged
Changes from 12 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
9372a00
Add the downloaded web vital js library
ankur22 840cc51
Refactor to use helper gojaValueExists
ankur22 ebce769
Add error to the method signatures
ankur22 519211a
Add implementation to page.evaluateOnNewDocument
ankur22 206f1fb
Add method on bCtx so page can apply init scripts
ankur22 e06b4d1
Add binding which will be used for web vitals
ankur22 af0baf4
Refactor NewBrowserContext to return error
ankur22 ff51716
Update to add web vital script via AddInitScript
ankur22 688616e
Add web vital init script
ankur22 90f9a53
Add the web vital metrics to the metrics registry
ankur22 a6bfe60
Add parse & emit of web vital metrics
ankur22 bd370fa
Remove first contentful paint cdp metric
ankur22 2ade4fb
Refactor error formatting
ankur22 3e7471c
Refactor the binding function name
ankur22 09a4050
Add a comment on why CLS uses the default metric
ankur22 54c094d
Remove the import of the wv module
ankur22 e4d42e3
Add test to check web vital scripts added
ankur22 65ab80a
Add custom metric sample chan in tests
ankur22 2eb7085
Add a web vital integration test
ankur22 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package js | ||
|
||
import ( | ||
_ "embed" | ||
) | ||
|
||
// WebVitalIIFEScript was downloaded from | ||
// https://unpkg.com/web-vitals@3/dist/web-vitals.iife.js. | ||
// Repo: https://github.com/GoogleChrome/web-vitals | ||
// | ||
//go:embed web_vital_iife.js | ||
var WebVitalIIFEScript string | ||
|
||
// WebVitalInitScript uses WebVitalIIFEScript | ||
// and applies it to the current website that | ||
// this init script is used against. | ||
// | ||
//go:embed web_vital_init.js | ||
var WebVitalInitScript string |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
function print(metric) { | ||
const m = { | ||
id: metric.id, | ||
name: metric.name, | ||
value: metric.value, | ||
rating: metric.rating, | ||
delta: metric.delta, | ||
numEntries: metric.entries.length, | ||
navigationType: metric.navigationType, | ||
url: window.location.href, | ||
} | ||
window.sendWebVitalMetric(JSON.stringify(m)) | ||
} | ||
|
||
async function load() { | ||
let { | ||
onCLS, onFID, onLCP, onFCP, onINP, onTTFB | ||
} = await import('https://unpkg.com/web-vitals@3?module'); | ||
inancgumus marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
onCLS(print); | ||
onFID(print); | ||
onLCP(print); | ||
|
||
onFCP(print); | ||
onINP(print); | ||
onTTFB(print); | ||
} | ||
|
||
load(); |
Oops, something went wrong.
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.
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.
It's better to fixate on a single version rather than breaking our code when the original webvital js lib gets updated. So, to me, it's an upside :)