Skip to content
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

Merged
merged 12 commits into from
Jan 15, 2024

Conversation

Olwiba
Copy link
Collaborator

@Olwiba Olwiba commented Nov 28, 2023

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

@Olwiba Olwiba changed the title Update bundle tooling & collect INP CWV metric Update bundle tooling & collect INP WV metric Nov 28, 2023
@Olwiba
Copy link
Collaborator Author

Olwiba commented Dec 6, 2023

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);

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.

phillip-haydon
phillip-haydon previously approved these changes Jan 14, 2024
Copy link

@phillip-haydon phillip-haydon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. :shipit:

@@ -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
Copy link
Contributor

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?

Copy link
Contributor

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

Copy link
Collaborator Author

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

Copy link
Contributor

@Hamish-taylor Hamish-taylor left a 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 🙌

Copy link
Contributor

@CmdrKeen CmdrKeen left a 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! :)

@Olwiba Olwiba merged commit d2a269c into master Jan 15, 2024
1 check passed
@Olwiba Olwiba deleted the dm/met-1/use-npm-instead-of-vendor-polyfill-for-cwv branch January 15, 2024 23:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants