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

✨ [RUMF-780] implement track first hidden #621

Merged
merged 18 commits into from
Nov 19, 2020

Conversation

BenoitZugmeyer
Copy link
Member

Motivation

Currently, we are tracking particular performance entries only if the page is not hidden when initializing the SDK (see #361 ). The issue with this strategy is: if the page is visible when initializing RUM, but it gets hidden before the first-contentful-paint is produced, the metric will be incorrect.

We want to replace this strategy with something similar to web-vitals. It'll provide stronger guarantees that the page was not hidden prior to the observed performance entry.

Changes

  • Add an utility function to add global event listeners
  • Move and split the function to track view timings: while quite concise for now, it'll grow in the near future when we add more metrics to it.
  • Add a few tests
  • Implement trackFirstHidden
  • Use trackFirstHidden when collecting FCP

Testing


I have gone over the contributing documentation.

@BenoitZugmeyer BenoitZugmeyer requested a review from a team as a code owner November 16, 2020 14:36
@BenoitZugmeyer BenoitZugmeyer changed the title ✨ [RUMF-780] implement track first hidden ✨ [RUMF-780] implement track first hidden Nov 16, 2020
packages/core/src/tools/utils.ts Outdated Show resolved Hide resolved
packages/core/src/tools/utils.ts Outdated Show resolved Hide resolved
According to review:
* restore prod behavior for passive events listeners
* support custom emitter, allowing to add listeners on `document` (for
`visibilitychange` event) and any mocked object or element (for unit
test)
* add documentation
* rename the function since it's not 'global' anymore
@codecov-io
Copy link

codecov-io commented Nov 17, 2020

Codecov Report

Merging #621 (f054f54) into master (21670fe) will decrease coverage by 0.65%.
The diff coverage is 87.93%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #621      +/-   ##
==========================================
- Coverage   88.89%   88.23%   -0.66%     
==========================================
  Files          54       56       +2     
  Lines        2503     2525      +22     
  Branches      541      546       +5     
==========================================
+ Hits         2225     2228       +3     
- Misses        278      297      +19     
Impacted Files Coverage Δ
packages/core/src/transport/transport.ts 91.66% <0.00%> (+0.94%) ⬆️
packages/rum/src/browser/performanceCollection.ts 23.07% <0.00%> (-42.64%) ⬇️
packages/rum/src/types.ts 100.00% <ø> (ø)
packages/core/src/domain/sessionManagement.ts 100.00% <100.00%> (ø)
packages/core/src/tools/utils.ts 86.66% <100.00%> (+1.23%) ⬆️
.../domain/rumEventsCollection/action/trackActions.ts 100.00% <100.00%> (+2.00%) ⬆️
...omain/rumEventsCollection/view/trackFirstHidden.ts 100.00% <100.00%> (ø)
...rc/domain/rumEventsCollection/view/trackTimings.ts 100.00% <100.00%> (ø)
.../src/domain/rumEventsCollection/view/trackViews.ts 96.22% <100.00%> (-0.11%) ⬇️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 21670fe...f054f54. Read the comment docs.

Copy link
Contributor

@bcaudan bcaudan left a comment

Choose a reason for hiding this comment

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

👍

@BenoitZugmeyer BenoitZugmeyer merged commit de06363 into master Nov 19, 2020
@BenoitZugmeyer BenoitZugmeyer deleted the benoit/implement-track-first-hidden branch November 19, 2020 08:59
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.

3 participants