One of the upcoming metrics in Core Web Vitals that we miss out on today is interaction to next paint, it is a better version to measure lag for the users than first input delay. We should start measuring it so we can keep track of it.
Instead of storing the data in the navtiming schema as in T264032 and sending the data when we fetch Navigation Timing data, we want to push it throughout the page lifecycle to a new schema (like we done before with some other metrics).
The instrumentation of getting the interaction to next paint is a little bit more complicated than the other metrics we collect, we can find some inspiration on how to do it in https://github.com/GoogleChrome/web-vitals/blob/main/src/onINP.ts
To collect the metric we need to do a couple of things (you can see the full picture at https://wikitech.wikimedia.org/wiki/Performance#/media/File:WMF_Performance_Team_infrastructure_2022.png):
- Add the collection of the actual metric in the navigation timing extension https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/NavigationTiming/+/refs/heads/master - you need to pull up Mediawiki and do the changes in the extension, add tests for it and run the tests.
- Then we need to make sure that the data is stored in a new schema https://gerrit.wikimedia.org/r/plugins/gitiles/schemas/event/secondary/+/refs/heads/master/jsonschema/analytics/legacy
- And then we need to take care of data when it arrives and send it to Graphite/Prometheus. That happens in navtiming.py: https://gerrit.wikimedia.org/r/plugins/gitiles/performance/navtiming/
- When the data has started to arrive we can make a new dashboard/graph in Grafana where we can look at the new metric.