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

✨ Clear event list on page reload for SDK extension #1825

Merged
merged 8 commits into from
Nov 30, 2022

Conversation

liywjl
Copy link
Contributor

@liywjl liywjl commented Nov 17, 2022

Motivation

Clear events when we refresh page

Testing

  • Local
  • Staging
  • Unit
  • End to end

I have gone over the contributing documentation.

@liywjl liywjl requested a review from a team as a code owner November 17, 2022 15:49
@codecov-commenter
Copy link

codecov-commenter commented Nov 17, 2022

Codecov Report

Merging #1825 (445c11f) into main (eac81e2) will decrease coverage by 0.07%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main    #1825      +/-   ##
==========================================
- Coverage   93.11%   93.03%   -0.08%     
==========================================
  Files         131      131              
  Lines        5081     5081              
  Branches     1138     1138              
==========================================
- Hits         4731     4727       -4     
- Misses        350      354       +4     
Impacted Files Coverage Δ
...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

@amortemousque amortemousque changed the title ✨ Clear event list on page reload ✨ Clear event list on page reload for SDK extension Nov 22, 2022
Comment on lines 34 to 43
if (!preserveEvents) {
const clearCurrentEvents = (details: chrome.webNavigation.WebNavigationTransitionCallbackDetails) => {
if (details.transitionType === 'reload') setEvents([])
}
chrome.webNavigation.onCommitted.addListener(clearCurrentEvents)
return () => {
removeListener()
chrome.webNavigation.onCommitted.removeListener(clearCurrentEvents)
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Because of this early return, the removeListener won't always be called. What about using two useEffect like I suggested here?

@liywjl liywjl merged commit b5bc40d into main Nov 30, 2022
@liywjl liywjl deleted the william/extension-clear-event-list-on-reload branch November 30, 2022 12:36
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