aws-observability / aws-rum-web

Amazon CloudWatch RUM Web Client
Apache License 2.0
114 stars 65 forks source link

feat: capture all W3C fields in NavigationEvents #494

Closed williazz closed 5 months ago

williazz commented 5 months ago

Update the Navigation schema to exactly match PerformanceNavigationTiming in aws-rum-web 2.0. I have also cleaned up some tech debt, as highlighted in the comments.

Some callouts:

  1. Remove check for load event because the PerformanceObserver checks the buffer. I kept the tests in case there's a regression.
  2. Remove support for Level1 because the level2 support is very good and very few users use Safari <v15
  3. Decision to keep non-W3C initiatorType=route_change, at least for this PR.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

williazz commented 5 months ago

Final changes:

  1. Require field initiatorType because we are always manually setting the value navigation or route_change
  2. Add documentation for (1)
  3. Remove value requirement startTime=0 because the route changes created by VirtualPageLoadTimer can have startTimes >= 0.
  4. Restore enum for field type
  5. Add runtime check to prevent initializing an observer if PerformanceNavigationTiming is not supported

Issue(non-blocking): currently, RUM will break if PerformanceAPI adds new accepted values the field type because it has a strict enum. To prevent data loss, a future PR should add a type 'other', either here or via enrichment during ingestion.

It's necessary to keep the enums for data validation to keep cardinality low. Also, the same problem exists with initiatorType for PerformanceResourceTiming.