hotjar.ts 639 B

123456789101112131415161718
  1. import getMeta from '@/utils/meta'
  2. import { debugConsole } from '@/utils/debugging'
  3. import { initializeHotjar } from '@/infrastructure/hotjar-snippet'
  4. import { createTrackingLoader } from '@/infrastructure/tracking-loader'
  5. const { hotjarId, hotjarVersion } = getMeta('ol-ExposedSettings')
  6. const shouldLoadHotjar = getMeta('ol-shouldLoadHotjar')
  7. if (hotjarId && hotjarVersion && shouldLoadHotjar) {
  8. if (!/^\d+$/.test(hotjarId) || !/^\d+$/.test(hotjarVersion)) {
  9. debugConsole.error('Invalid Hotjar id or version')
  10. } else {
  11. createTrackingLoader(
  12. () => initializeHotjar(hotjarId, hotjarVersion),
  13. 'Hotjar'
  14. )
  15. }
  16. }