Эх сурвалжийг харах

[web] Define `loadPropensityScript` before use (#26813)

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
Antoine Clausse 1 жил өмнө
parent
commit
bb5b9afd0e

+ 4 - 4
services/web/frontend/js/infrastructure/tracking-propensity.ts

@@ -6,10 +6,6 @@ import {
 
 const { propensityId } = getMeta('ol-ExposedSettings')
 
-if (propensityId) {
-  createTrackingLoader(() => loadPropensityScript(propensityId), 'Propensity')
-}
-
 const loadPropensityScript = (id: string) => {
   insertScript({
     src: 'https://cdn.propensity.com/propensity/propensity_analytics.js',
@@ -21,3 +17,7 @@ const loadPropensityScript = (id: string) => {
     },
   })
 }
+
+if (propensityId) {
+  createTrackingLoader(() => loadPropensityScript(propensityId), 'Propensity')
+}