-
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 POC code to inject web vital js script #657
Conversation
This POC tests to see how viable it to inject Google's Web Vital JS script into each website that we navigate to.
This will hopefully help us distinguish the different Web Vital metrics from different pages.
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.
Nice research, thanks!
I haven't looked at the code deeply, and skimmed it, but it looks fine.
I believe that this is likely to be the solution we go with, at least in the short term. It gives us what we need for now, we just need to fine tune it so that it's concise, simple to understand and all the information they need is displayed.
Looks like so! 👍
Some areas that need further investigation and input from product/users:
- We probably need our own metric type, instead of using
metrics.Trend
.
Yes, it might be better to wrap it in a higher type. Maybe even other metrics too.
- How do we display the rating in the summary in a concise way?
I believe this is something we need to discuss with the product team (@markjmeier @dgzlopes) and @mdcruz. And then decide what the result should look like.
- We need to tidy up and move this JS injection code within the code somewhere, possibly with the other injected script.
Yes, we can embed it as another script once for each frame.
- We probably don't want to aggregate the web vitals for all pages that are navigated, but instead split them up based on the frame and sub frame.
When we send the metrics to k6, it will do grouping etc. for us. (Update: You explained later that it won't work with the async APIs 😮💨 ).
- There's a limitation to this library in that it doesn't work for sub frames, so we would have to inject this library into the sub frame and display them separately. I don't think aggregating the root frames and the sub frames is going to be straight forward.
Since we'll be injecting the script for each frame, we can collect data from every frame?
- Can we use the Web Vitals with SPAs?
🤷 We don't have a strong SPA support at the moment anyway :-]
We would likely need to bundle this script with the binary:
- Allows us to use this library in a locked down test environment that may not have access to all of the internet.
- Avoids XSS issues.
Grafana Faro also uses this.
👍
Yep, that's correct, so might not be such a big deal. We will need to think about how we can display it the summary though, or maybe we combine all the results from each frame for a single page. This will require some further investigation. |
Meaning Good/Needs Improvement/Poor? First and foremost, lets not overcomplicate the summary. Summary is just that - a summary. For k6 tests this is a test wide aggregation. Perhaps we take the same approach here - multiple page loads so an aggregation of vitals for them all:
But maybe this isn't clear that there could be multiple pages - right? What if the pattern was something like:
thoughts? CC: @dgzlopes |
This was a POC, so closing it. |
Closes: #653
This POC tests to see how viable it is to inject Google's Web Vital JS script into each website that is navigated to.
Result
When testing the following test:
This is the output that we're interested in:
Analysis
The results are positive as we can retrieve the measurements for all of the Core Web Vitals, as well as three others which could be useful now or in the future. We should probably concentrate on the core Web Vitals and get a good understanding of those.
Some areas that need further investigation and input from product/users:
metrics.Trend
.group
doesn't work with async calls well k6#2728.Measurement Results And Comparison
Conclusion
I believe that this is likely to be the solution we go with, at least in the short term. It gives us what we need for now, we just need to fine tune it so that it's concise, simple to understand and all the information they need is displayed.