mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-02 13:49:00 +02:00
551428ee37
Support user limits on split test variants, add Hotjar editor support GitOrigin-RevId: c5df831436c2b7d7e242cf4d3ff00899aba77886
36 lines
996 B
TypeScript
36 lines
996 B
TypeScript
import getMeta from '@/utils/meta'
|
|
import { debugConsole } from '@/utils/debugging'
|
|
import { initializeHotjar } from '@/infrastructure/hotjar-snippet'
|
|
import { createTrackingLoader } from '@/infrastructure/tracking-loader'
|
|
import grammarlyExtensionPresent from '@/shared/utils/grammarly'
|
|
|
|
const { hotjarId, hotjarVersion } = getMeta('ol-ExposedSettings')
|
|
const shouldLoadHotjar = getMeta('ol-shouldLoadHotjar')
|
|
|
|
function attemptHotjarLoad() {
|
|
if (!hotjarId || !hotjarVersion) {
|
|
return
|
|
}
|
|
|
|
if (!/^\d+$/.test(hotjarId) || !/^\d+$/.test(hotjarVersion)) {
|
|
debugConsole.error('Invalid Hotjar id or version')
|
|
return
|
|
}
|
|
|
|
if (grammarlyExtensionPresent()) {
|
|
return
|
|
}
|
|
|
|
createTrackingLoader(
|
|
() => initializeHotjar(hotjarId, hotjarVersion),
|
|
'Hotjar'
|
|
)
|
|
}
|
|
|
|
if (hotjarId && hotjarVersion && shouldLoadHotjar) {
|
|
document.addEventListener('DOMContentLoaded', () => {
|
|
// add delay to allow extensions to inject shadow DOM
|
|
setTimeout(attemptHotjarLoad, 1000)
|
|
})
|
|
}
|