-
Notifications
You must be signed in to change notification settings - Fork 60
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
Update bundle tooling & collect INP WV metric #512
Update bundle tooling & collect INP WV metric #512
Conversation
…dbeacon with fallback
This PR makes this one redundant: #510 |
self.stopCollectingMetrics = true; | ||
}.bind(_private); | ||
|
||
if (window.addEventListener) { | ||
window.addEventListener('click', clickHandler); | ||
document.addEventListener('visibilitychange', visibilityChangeHandler); | ||
window.addEventListener('beforeunload', unloadHandler); | ||
window.addEventListener('popstate', urlChangeHandler); |
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.
https://caniuse.com/?search=window%20popstate
Looks like this is widely supported so don't see any issues.
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.
Looks good.
@@ -499,8 +505,27 @@ var raygunRumFactory = function (window, $, Raygun) { | |||
} | |||
|
|||
function sendCoreWebVitalTimings(performanceData) { | |||
// Core web vital timing metrics need to be sent to the API immediately, if they are queued then they may not be sent if a virtual page timing event occurs before they are tracked |
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.
Is the issue of a virtual page occurring resolved with this new approach?
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.
Yes, we changed how Core web vitals are sent by creating a new handler specifically for them. This avoids any potential queuing race conditions with other events so CWV will always be sent immediately when they occur
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.
Hamish covered this one above - to add some extra context the new behaviour will attempt to send all web vital events using the send beacon API from inside this function. This is to mitigate the browser cancelling events when a request is fired at the same time the browser is attempting to navigate (causing all incomplete events to cancel at the time of navigation). We added additional fallbacks so that if sendBeacon
is unavailable just use the regular queued approach to provide some level of backwards compatibility support based on the previous functionality
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.
Everything looks good to me, I also have not found any issues in our apps that have been using this version since December so I am confident in the changes 🙌
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've discussed this with Ollie and appreciate the answers to questions earlier (thanks Hamish!).
Overall this appears safe to my eye. Much of the code is around re-structuring and modernizing the setup, and the code that's not seems relatively small and safe. Correct me if wrong.
I'm happy with @Olwiba's plan to release this in the AM tomorrow to the CDN, see how we track and release to the package managers later in the day.
Let's go! :)
Update bundle tooling & collect INP WV metric 📊
This implements a new tool in the build pipeline to allow importing modules using require().
Following this upgrade, we have reimplemented our web-vitals approach. This is to follow best practices provided by the Google team.
This PR also adds the collection of the new INP web vital metric.
🛠 Updates
👉 Added browserify
👉 Updated grunt
👉 Updated web-vitals internals