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

♻️ Base foreground computation on page lifecycle states #2253

Merged
merged 6 commits into from
Jun 28, 2023

Conversation

amortemousque
Copy link
Collaborator

Motivation

Follow up of #2229: Base foreground computation on page lifecycle states

Changes

  • Add pageStateHistory.isActiveAt() to replace foregroundContexts.isInForegroundAt()
  • Base foreground computation on pageStateHistory (implement mapToForegroundPeriods())

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 May 17, 2023 09:09
})
})

it('should not record anything after reaching the maximum number of focus periods', () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've removed this test that is now covered by the ValueHistory used in pageStateHistory.ts

@codecov-commenter
Copy link

codecov-commenter commented May 17, 2023

Codecov Report

Merging #2253 (91ccc08) into main (afd2b17) will decrease coverage by 0.08%.
The diff coverage is 96.55%.

@@            Coverage Diff             @@
##             main    #2253      +/-   ##
==========================================
- Coverage   94.23%   94.16%   -0.08%     
==========================================
  Files         206      206              
  Lines        6180     6118      -62     
  Branches     1368     1354      -14     
==========================================
- Hits         5824     5761      -63     
- Misses        356      357       +1     
Impacted Files Coverage Δ
packages/rum-core/test/testSetupBuilder.ts 97.29% <80.00%> (+1.24%) ⬆️
packages/rum-core/src/boot/startRum.ts 91.66% <100.00%> (-0.34%) ⬇️
...rum-core/src/domain/contexts/foregroundContexts.ts 100.00% <100.00%> (+1.53%) ⬆️
...s/rum-core/src/domain/contexts/pageStateHistory.ts 93.47% <100.00%> (+0.45%) ⬆️
...ain/rumEventsCollection/action/actionCollection.ts 94.73% <100.00%> (-0.72%) ⬇️
...omain/rumEventsCollection/error/errorCollection.ts 100.00% <100.00%> (ø)
.../domain/rumEventsCollection/view/viewCollection.ts 100.00% <100.00%> (ø)

... and 3 files with indirect coverage changes

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

Copy link
Member

@BenoitZugmeyer BenoitZugmeyer left a comment

Choose a reason for hiding this comment

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

Great work!

Comment on lines +98 to +102
view: { in_foreground: pageStateHistory.isInActivePageStateAt(action.startClocks.relative) },
},
autoActionProperties
)
const inForeground = foregroundContexts.isInForegroundAt(action.startClocks.relative)
if (inForeground !== undefined) {
actionEvent.view = { in_foreground: inForeground }
}

Copy link
Contributor

Choose a reason for hiding this comment

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

💬 suggestion: ‏what about keeping the same logic of not adding the view.in_foreground if there is no active page state?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The previous foregroundContexts.isInForegroundAt(action.startClocks.relative) always return a boolean so inForeground !== undefined is always true

@amortemousque amortemousque merged commit 6b96671 into main Jun 28, 2023
@amortemousque amortemousque deleted the aymeric/foreground-based-on-page-lifecycle branch June 28, 2023 07: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.

4 participants