From a0cad9c9cad610760874822b4418335c819d0b47 Mon Sep 17 00:00:00 2001 From: Evan Purkhiser Date: Wed, 8 Oct 2025 15:34:02 -0400 Subject: [PATCH] fix(uptime): Recompute uptime timeWindowConfig on interval Just refetching the monitor stats won't work, since we compute the stats from the time the timeWindowConfig was instantiated. --- .../alerts/rules/uptime/detailsTimeline.tsx | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/static/app/views/alerts/rules/uptime/detailsTimeline.tsx b/static/app/views/alerts/rules/uptime/detailsTimeline.tsx index 88fc95ffbe32d6..16d99ef0892691 100644 --- a/static/app/views/alerts/rules/uptime/detailsTimeline.tsx +++ b/static/app/views/alerts/rules/uptime/detailsTimeline.tsx @@ -29,18 +29,16 @@ export function DetailsTimeline({uptimeDetector, onStatsLoaded}: Props) { const {width: containerWidth} = useDimensions({elementRef}); const timelineWidth = useDebouncedValue(containerWidth, 500); - const timeWindowConfig = useTimeWindowConfig({timelineWidth}); + const timeWindowConfig = useTimeWindowConfig({ + timelineWidth, + recomputeInterval: 60_000, + recomputeOnWindowFocus: true, + }); - const {data: uptimeStats} = useUptimeMonitorStats( - { - detectorIds: [String(uptimeDetector.id)], - timeWindowConfig, - }, - { - refetchOnWindowFocus: true, - refetchInterval: 60_000, - } - ); + const {data: uptimeStats} = useUptimeMonitorStats({ + detectorIds: [String(uptimeDetector.id)], + timeWindowConfig, + }); useEffect( () => uptimeStats?.[id] && onStatsLoaded?.(uptimeStats[id]),