Merge pull request #14882 from overleaf/tm-compile-time-warning-would-display

Fix unreachable 'compile time warning would display' event

GitOrigin-RevId: 3734ef69062d11cdde851447c657a58259d00acf
This commit is contained in:
Thomas 2023-09-19 15:09:33 +02:00 committed by Copybot
parent ab4f0d6c5f
commit 31e4e16c0b
2 changed files with 27 additions and 10 deletions

View file

@ -6,7 +6,7 @@ import StartFreeTrialButton from '../../../shared/components/start-free-trial-bu
import { useDetachCompileContext } from '../../../shared/context/detach-compile-context'
import usePersistedState from '../../../shared/hooks/use-persisted-state'
const ONE_DAY = 24 * 60 * 60 * 24 * 1000
const TWENTY_FOUR_DAYS = 24 * 60 * 60 * 24 * 1000
function CompileTimeWarning() {
const { t } = useTranslation()
@ -17,14 +17,36 @@ function CompileTimeWarning() {
true
)
const { showCompileTimeWarning, setShowCompileTimeWarning } =
useDetachCompileContext()
const {
showCompileTimeWarning,
setShowCompileTimeWarning,
deliveryLatencies,
isProjectOwner,
} = useDetachCompileContext()
useEffect(() => {
if (deliveryLatencies && deliveryLatencies.compileTimeServerE2E) {
window.sl_console.log(
`[compileTimeout] compiledTimeServerE2E ${
deliveryLatencies.compileTimeServerE2E / 1000
}s`
)
// compile-timeout-20s test
if (deliveryLatencies.compileTimeServerE2E > 10000) {
eventTracking.sendMB('compile-time-warning-would-display', {
time: 10,
newCompileTimeout: 'control',
isProjectOwner,
})
}
}
}, [deliveryLatencies, isProjectOwner])
useEffect(() => {
if (showCompileTimeWarning) {
if (
displayStatus &&
Date.now() - displayStatus.lastDisplayTime < ONE_DAY
Date.now() - displayStatus.lastDisplayTime < TWENTY_FOUR_DAYS
) {
return
}

View file

@ -26,7 +26,7 @@ function CompileTimeoutMessages() {
const segmentation = useMemo(() => {
return {
newCompileTimeout: showNewCompileTimeoutUI || 'control',
newCompileTimeout: showNewCompileTimeoutUI,
isProjectOwner,
}
}, [showNewCompileTimeoutUI, isProjectOwner])
@ -59,11 +59,6 @@ function CompileTimeoutMessages() {
...segmentation,
})
}
} else {
eventTracking.sendMB('compile-time-warning-would-display', {
time: 10,
...segmentation,
})
}
}
},