mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2025-07-29 05:00:06 +02:00

This prevents the bug "ReferenceError: Cannot access uninitialized variable" for users who don't have `window.requestIdleCallback`. Fixes https://overleaf.sentry.io/issues/6724866295 GitOrigin-RevId: 129dcb72f24dc901ad600253bab7c58673e44321
23 lines
579 B
TypeScript
23 lines
579 B
TypeScript
import getMeta from '@/utils/meta'
|
|
import {
|
|
createTrackingLoader,
|
|
insertScript,
|
|
} from '@/infrastructure/tracking-loader'
|
|
|
|
const { propensityId } = getMeta('ol-ExposedSettings')
|
|
|
|
const loadPropensityScript = (id: string) => {
|
|
insertScript({
|
|
src: 'https://cdn.propensity.com/propensity/propensity_analytics.js',
|
|
crossorigin: 'anonymous',
|
|
onload: () => {
|
|
if (typeof window.propensity !== 'undefined') {
|
|
window.propensity(id)
|
|
}
|
|
},
|
|
})
|
|
}
|
|
|
|
if (propensityId) {
|
|
createTrackingLoader(() => loadPropensityScript(propensityId), 'Propensity')
|
|
}
|