henk-badenhorst / vue-hotjar

A NPM package to easily integrate Hotjar to any Vue 2 Project
https://www.npmjs.com/package/vue-hotjar
MIT License
27 stars 3 forks source link

Vue2 application "window is not defined error" during SSR #26

Open jmrodriguez opened 4 months ago

jmrodriguez commented 4 months ago

Hi!

I was giving this library a try as the documentation is very straightforward. I followed the instructions, added the library, then the code as shown below

Screenshot 2024-07-26 at 14 21 32

and started the application. However, when I loaded the application homepage I got the next error in the terminal window and in the browser console:

Screenshot 2024-07-26 at 14 27 09

Screenshot 2024-07-26 at 14 27 31

I understand the error is being thrown during SSR because the window object is not available during SSR as it runs on the server, and the window object is only available on the client side.

The hotjar script is added to the head of the page and I have access to the variables on the developer console, which means it works, but I'm concerned the error might break something else (and gives you the feeling that something is broken)

Any thoughts on this one?

Thanks in advance for any assistance you can provide.

henk-badenhorst commented 4 months ago

Hi, Thanks for reporting. I will need to look into this and try and replicate the issue in Nuxt. I will get back to you on this.