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-1445] Check if the page was discarded before a resource #1945

Merged
merged 2 commits into from
Jan 12, 2023

Conversation

amortemousque
Copy link
Contributor

@amortemousque amortemousque commented Jan 12, 2023

Motivation

To investigate resource with long duration, check if the page has been discarded by the browser.

Changes

Add the document.wasDiscarded in resources

Testing

  • Local
  • Staging
  • Unit
  • End to end

I have gone over the contributing documentation.

@amortemousque amortemousque requested a review from a team as a code owner January 12, 2023 08:48
@amortemousque amortemousque force-pushed the aymeric/observe-discarded-page-on-resources branch from 9b5861a to 2ddb840 Compare January 12, 2023 08:49
@codecov-commenter
Copy link

Codecov Report

Merging #1945 (2ddb840) into main (353193c) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1945      +/-   ##
==========================================
- Coverage   93.14%   93.12%   -0.02%     
==========================================
  Files         142      142              
  Lines        5396     5395       -1     
  Branches     1222     1222              
==========================================
- Hits         5026     5024       -2     
- Misses        370      371       +1     
Impacted Files Coverage Δ
...s/rum-core/src/domain/contexts/pageStateHistory.ts 80.48% <ø> (+5.48%) ⬆️
...rumEventsCollection/resource/resourceCollection.ts 100.00% <100.00%> (ø)
...rum-core/src/domain/contexts/foregroundContexts.ts 90.76% <0.00%> (-6.16%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

return {
_dd: {
page_states: pageStateHistory.findAll(startClocks.relative, duration),
page_was_discarded: (document as any).wasDiscarded,
Copy link
Member

Choose a reason for hiding this comment

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

💬 suggestion: ‏maybe String((document as any).wasDiscarded) so you can differentiate between true/false/undefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see the point of getting undefined. true and false should be okay but maybe I'm missing something?

Copy link
Member

Choose a reason for hiding this comment

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

Not all browsers are supporting this API, so when it doesn't, the page_was_discarded property would be missing, and it would be a bit less trivial to know whether this property is missing because an older SDK has been used, because the FF was not enabled or because the browser don't support it.

That's why I think it might help if you had an explicit undefined value here.

@amortemousque amortemousque merged commit 402837f into main Jan 12, 2023
@amortemousque amortemousque deleted the aymeric/observe-discarded-page-on-resources branch January 12, 2023 14:53
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