Closed williazz closed 10 months ago
issue: It's not obvious from the PR description what problem this change solves, or how this change solves it. Reviewing this change is difficult without this context.
issue: It's not obvious from the PR description what problem this change solves, or how this change solves it. Reviewing this change is difficult without this context.
Updated the description. Tl; DR: this PR creates the API necessary for linking LCP attribution to related resource and navigation events.
The problem we are trying to solve is to allow NavigationPlugin and ResourcePlugin to share event Ids related to web vitals attribution artifacts (specifically, PerformanceEntry objects) with WebVitalsPlugin. By doing so, events recorded by WebVitalsPlugin can reference events recorded by NavigationPlugin/ResourcePlugin, which are attributed to the web vitals value.
This PR proposes that we generalize this use case to allow any plugin to share the events it records with any other plugin.
I wonder if we should further generalize this use case to allow plugins to share any information. My argument for this would be (1) we don't know the future use case, and (2) a general solution might require less management infrastructure, such as the EventStore currently implemented in this PR.
I suggest considering two models:
Closing for #445
Purpose
We need an event store to link related RUM events. My use case is to link LCP attribution to related RUM events.
Revision 1
EventStore
maps custom keys to RumEvents. Plugins write to store withcontext.record(type, event, key)
and read from store withcontext.getEvent(key)
. LCP attribution can use PerformanceEntry object references as the keys.ResourcePlugin
stores image resource events by reference to the PerformanceResourceTiming entryNavigationPlugin
caches all level 2 events by reference to PerformanceNavigationTiming entry. Level 1 events do not have a related PerformanceEntry, and are therefore ignored.Revision 2
EventStore
eviction policy to "first n" or "last n"Not included in this PR
context.getEvent(key)
.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.