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-625] make sure view url doesn't change #469

Merged
merged 10 commits into from
Jul 31, 2020
Merged

Conversation

BenoitZugmeyer
Copy link
Member

Motivation

When a SPA changes its URL, the ending view gets updated with the new URL. It should keep its initial URL no matter what.

See https://datadoghq.atlassian.net/browse/RUMF-625

Changes

When formating a RumViewEvent, use the one from the collected View object instead of the ViewContext which already contains the new URL

Testing


I have gone over the contributing documentation.

This commit makes withFakeLocation simpler to use: pass a base URL (or
path) and the whole location will be built automatically. Also, it
allows the test to change the fake location by using the history api.
@BenoitZugmeyer BenoitZugmeyer requested a review from a team as a code owner July 30, 2020 16:34
Copy link
Member

@mquentin mquentin left a comment

Choose a reason for hiding this comment

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

LGTM !

@@ -359,6 +360,7 @@ function trackView(lifeCycle: LifeCycle, handler: (startTime: number, event: Rum
loadingTime: view.loadingTime ? msToNs(view.loadingTime) : undefined,
loadingType: view.loadingType,
measures: view.measures,
url: view.location.href,
Copy link
Contributor

Choose a reason for hiding this comment

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

With this approach, url from ViewContext is still wrong so it can still be wrongly associated to other event types.
What about fixing it there?

Copy link
Member Author

Choose a reason for hiding this comment

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

I wrote a new fix, let me know if it looks right :)

@codecov-commenter
Copy link

codecov-commenter commented Jul 31, 2020

Codecov Report

Merging #469 into master will increase coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #469      +/-   ##
==========================================
+ Coverage   87.57%   87.60%   +0.03%     
==========================================
  Files          32       32              
  Lines        2020     2025       +5     
  Branches      409      409              
==========================================
+ Hits         1769     1774       +5     
  Misses        251      251              
Impacted Files Coverage Δ
packages/rum/src/lifeCycle.ts 100.00% <ø> (ø)
packages/core/src/urlPolyfill.ts 65.85% <100.00%> (ø)
packages/rum/src/parentContexts.ts 98.21% <100.00%> (+0.06%) ⬆️
packages/rum/src/rum.ts 90.90% <100.00%> (ø)
packages/rum/src/viewCollection.ts 95.95% <100.00%> (+0.12%) ⬆️

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 46b8fde...59305bd. 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 7723cd3 into master Jul 31, 2020
@bcaudan bcaudan deleted the benoit/RUMF-625 branch August 5, 2020 08:30
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