sentry-javascript
sentry-javascript copied to clipboard
Dead clicks are created when users navigate back in a MPA
For MPA, dead clicks are created if users click a link and then navigates back. The bfcache preserves the timer state and resumes it when the user navigates back and the page is restored from bfcache. We should probably clear our dead click timers when the page is restored from bfcache (and maybe even when it begins to enter bfcache).
Would this cause the page that was visited before hitting the back button not to show up in the replay at all?
it should not, but bfcache may be messing things up for us somehow, I guess 🤔
@chargome & @billyvg is this something we see us tackling anytime soon? If there is no priority for this and/or we do not really know how to fix it, I'd close this issue for now!
created a small repro for this: https://github.com/chargome/replay-mpa-deadclick-repro
Would this cause the page that was visited before hitting the back button not to show up in the replay at all?
I think bfcache prevents our init call here completely
Thanks for looking into this. That would make sense if you rely on DOMContentLoaded or anything along those lines. Not sure if it helps, but you may be able to do something like this:
window.addEventListener("pageshow", (event) => {
if (event.persisted) {
// The page was restored from bfcache
reinitializeSentry();
}
});
Thanks for the suggestion @aaronjensen – it is also worth noting that the bfcache behaviour varies across browsers, so this might not be a solution that works consistently. From my tests I saw that you would likely only need to reinitialise in the safari case (or maybe try to start the replay manually in this case)
This issue has gone three weeks without activity. In another week, I will close it.
But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!
"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀
Waiting for community to what? Fix it?
This is just our automatic cleanup bot. This issue is still in our backlog, we just haven't gotten around to actually fixing it, as it is not that straightforward sadly.