hotjar / hotjar-js

Bring Hotjar directly to your application
https://hotjar.github.io/hotjar-js/
MIT License
48 stars 8 forks source link

hj.event.signal function error #8

Closed Amilson closed 3 years ago

Amilson commented 3 years ago

Hi folks. I've been facing an issue with hotjar last couple of days.

I contacted the support team (btw always answering me properly, thanks for that) but until now, my problem wasn't solved.

Well, seems that when my clients run my application with "Block third-party" on their browsers, and for that reason some of your bundled scripts are not load properly. image (this is my localhost environment, but also happen in production)

For fix that, I've added some conditions to your static file to prevent this issue to be fired by the browser and also not showing in the console as a error. To my fix run properly I copied this script to my assets.

Take a look in this conditions: image The hj.event.signal('varsLoaded') is not fired if this method is unavailable.

I also will reply to support with this solution and I am looking forward to hear from you. If you need more tests or evidences, I'm here.

arrwhidev commented 3 years ago

Hey @Amilson 👋

Thanks for reaching out.

To help with our investigation into this issue, can you provide us with some example code or a URL so that we can reproduce this issue, please?

Amilson commented 3 years ago

Hey @arrwhidev.

Here a example code: https://stackblitz.com/edit/angular-ivy-yybkpb

And also my application: https://intercement.monkey.exchange/new/authentication/email/login

But, in production I solved by adding the condition "typeof hj.event.signal === 'function'" and load the new script by application assets, and my application doesn't emit this error anymore. take a look at line 277 of assets/hotjar-hjid-hjsv.js

At stackblitz, I replaced the hjid and I also added the hotjar-hjid-hjsv.js example in assets folder.

My environment: Browser: Firefox 90.0.2 (64-bits) OS: Windows 10

Some of my clients environment: 1: image 2: image 3: image

ejulianova commented 3 years ago

Hey @Amilson, thanks for providing all this info. Unfortunately we still didn't manage to repro the issue. Tried the following:

However none of the above resulted in throwing this exception. The fact that hj.event is defined, but hj.event.signal isn't means that the script is not getting blocked, but there might be either:

Can you advise if there are any additional steps to repro the issue? Is there a particular third party plugin that you're using?

Amilson commented 3 years ago

Hey @ejulianova

My application has the following third party plugins:

I only deploy my application to production and during the day I get this errors.

Can you try again?

https://intercement.monkey.exchange/new/authentication/email/login

Today these issues show up again. Take a look: image

ejulianova commented 3 years ago

Hi @Amilson! Apologies for the late response! We've deployed a fix within the tracking code script itself (i.e. no need to update the npm package). Thank you for reporting this issue and all the details. This has been very helpful! 🙂