sentry-javascript icon indicating copy to clipboard operation
sentry-javascript copied to clipboard

Dead clicks are created when users navigate back in a MPA

Open billyvg opened this issue 1 year ago • 9 comments

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).

billyvg avatar Jun 26 '24 22:06 billyvg

Would this cause the page that was visited before hitting the back button not to show up in the replay at all?

aaronjensen avatar Jun 28 '24 12:06 aaronjensen

it should not, but bfcache may be messing things up for us somehow, I guess 🤔

mydea avatar Jul 01 '24 08:07 mydea

@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!

mydea avatar Mar 18 '25 09:03 mydea

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

chargome avatar Apr 22 '25 13:04 chargome

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();
  }
});

aaronjensen avatar Apr 22 '25 13:04 aaronjensen

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)

chargome avatar Apr 23 '25 08:04 chargome

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 🥀

getsantry[bot] avatar May 22 '25 07:05 getsantry[bot]

Waiting for community to what? Fix it?

aaronjensen avatar May 22 '25 14:05 aaronjensen

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.

mydea avatar May 23 '25 07:05 mydea