ngx-hotjar icon indicating copy to clipboard operation
ngx-hotjar copied to clipboard

Production - error in conosle: this._hj is not a function

Open Svathna opened this issue 3 years ago • 5 comments

Is there anyway to prevent that?

Svathna avatar Apr 20 '21 07:04 Svathna

@Svathna Are you using this package w/ angular universal or something like this? Which version are you using?

maxandriani avatar Apr 26 '21 11:04 maxandriani

Does using this package with angular universal cause issues? I am using it with Scully and get the following error, which is somewhat similar to the issue above:

VM71 hotjar-2029657.js:3 Uncaught ReferenceError: hj is not defined
    at window.hjBootstrap (VM71 hotjar-2029657.js:3)
    at Object.331 (VM71 hotjar-2029657.js:3)
    at n (VM71 hotjar-2029657.js:3)
    at VM71 hotjar-2029657.js:3
    at VM71 hotjar-2029657.js:3

riordache avatar May 26 '21 18:05 riordache

same issue here. not using universal just a standard angular setup. hotjar works in general (script is injected and recordings are made) but apparently the service does not get the hj script.

accessing hj directly in a "dirty" way works:

const hj = (window as any).hj
hj('tagRecording', ['some-tag'])

i have the feeling the script might not be available at the time it is injected into NgxHotjarService

silberjan avatar Jul 27 '21 12:07 silberjan

I had issue with Angular version 13.0.3 and I am using SSR.

I fixed that by placing below script at the top of index.html

<script>
  window.hj=window.hj||function(){(hj.q=hj.q||[]).push(arguments)};
</script>

Santoshah avatar Feb 03 '22 14:02 Santoshah

hi, I receive same error and I noticed that it appear on application not connected to hotjar generally speaking I tried in dev env and it fails, but in prod(connected to hotjar) works as expected

Andrew3005 avatar Mar 22 '22 10:03 Andrew3005