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

[REPLAY-149] implement ViewEnd record #711

Merged
merged 6 commits into from
Feb 3, 2021
Merged

Conversation

BenoitZugmeyer
Copy link
Member

Motivation

This is part of multitab tracking strategy. To let the player know a view has ended, a new record is added when the view ends or before unloading the page.

Note

There is some limitations with this strategy:

  • there may be multiple ViewEnd per view because a ViewEnd record is added even if the "beforeunload" event gets cancelled. We may add a way to detect "beforeunload" cancellations in the future
  • there may be no ViewEnd for a view: if the browser fails to send the segment for whatever reason (sendBeacon limitations, connection issues, ...)
  • there may be records or segments added after the ViewEnd record: the "beforeunload" event is triggered when the page starts to unload, and it can take a moment (the browser is waiting for the first byte of the next page response to actually leave the current page)

The player will need to be aware of this and handle it gracefully.

Changes

  • Adapt the recorder "flush" strategy to avoid sideeffects
  • Add a ViewEnd record at the end of views

Testing

Unit + Manual


I have gone over the contributing documentation.

@BenoitZugmeyer BenoitZugmeyer requested a review from a team as a code owner February 2, 2021 11:10
The BEFORE_UNLOAD will have a side effect of generating another record.
Change the strategy to simply expire the event, which shouldn't have any
side effect in the long term.
Recorder tests are skiped on IE, but we still need a syntax-compatible
bundle.
packages/rum-recorder/test/utils.ts Outdated Show resolved Hide resolved
packages/rum-recorder/src/boot/recorder.ts Outdated Show resolved Hide resolved
Also, make sure the ending view id is used in the segment meta instead
of the new view id.
@codecov-io
Copy link

codecov-io commented Feb 2, 2021

Codecov Report

Merging #711 (c45fcbe) into master (353f6dc) will decrease coverage by 0.10%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #711      +/-   ##
==========================================
- Coverage   79.98%   79.88%   -0.11%     
==========================================
  Files          69       69              
  Lines        3433     3440       +7     
  Branches      732      732              
==========================================
+ Hits         2746     2748       +2     
- Misses        687      692       +5     
Impacted Files Coverage Δ
packages/rum-core/src/domain/lifeCycle.ts 100.00% <100.00%> (ø)
.../src/domain/rumEventsCollection/view/trackViews.ts 96.74% <100.00%> (+0.02%) ⬆️
packages/rum-recorder/src/boot/recorder.ts 100.00% <100.00%> (ø)
packages/rum-recorder/src/types.ts 100.00% <100.00%> (ø)
packages/rum-core/src/transport/batch.ts 65.71% <0.00%> (-11.43%) ⬇️
...ckages/core/src/domain/automaticErrorCollection.ts 98.41% <0.00%> (-1.59%) ⬇️

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 353f6dc...c45fcbe. 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.

LGTM

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.

4 participants