fullstory-browser-sdk icon indicating copy to clipboard operation
fullstory-browser-sdk copied to clipboard

Failure Detection Handler

Open amcdnl opened this issue 4 years ago • 4 comments

Problem

If a user is using a ad blocker, sometimes it will not start up fullstory. I would like the ability to catch if the error occurs and handle it.

Proposal

You could do something like make Fullstory.init return a Promise and error if it fails, so you could do:

(async () => {
   try {
      await Fullstory.init({ orgId: 'asdf' });
   } catch (e) {
        alert('Kindly turn that ad blocker off');
   }
}();

amcdnl avatar Dec 01 '20 19:12 amcdnl

Hey Austin! Thanks for proposing this, sorry for the delayed reply. Let me circle back with some other folks on my team to review.

patrick-fs avatar Dec 07 '20 21:12 patrick-fs

I ended up using this: https://www.npmjs.com/package/use-ad-block-detection - would be nice to have this built in though.

amcdnl avatar Dec 08 '20 19:12 amcdnl

The way these ad blockers typically work is blocking the URL pattern to the recording script fs.js. It would be useful to have even a naive timeout on whether FS is ever loaded into the window. Another use case is content-security-policy that could also block fs.js. Thanks for bringing it up.

van-fs avatar Dec 11 '20 22:12 van-fs

@van-fs - Yup - the ad block hook I demonstrated above just tries to request the script and when it fails it handles the exception. This of course causes duplicate calls ( though cached ) so it would be grat to handle this in the lib itself.

amcdnl avatar Dec 13 '20 18:12 amcdnl