Skip to content

Commit 4dd1e14

Browse files
authored
fix(stat-detectors): Use 7 days for span analysis (#58096)
Sets the time range for analysis to be +/- 7 days from the breakpoint
1 parent f18a2cd commit 4dd1e14

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

static/app/components/events/eventStatisticalDetector/aggregateSpanDiff.tsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
import {useMemo} from 'react';
21
import styled from '@emotion/styled';
32
import {Location} from 'history';
4-
import moment from 'moment';
53

64
import EmptyStateWarning from 'sentry/components/emptyStateWarning';
75
import {DataSection} from 'sentry/components/events/styles';
@@ -16,6 +14,7 @@ import {Tooltip} from 'sentry/components/tooltip';
1614
import {t, tct} from 'sentry/locale';
1715
import {Event, Organization} from 'sentry/types';
1816
import {defined} from 'sentry/utils';
17+
import {useRelativeDateTime} from 'sentry/utils/profiling/hooks/useRelativeDateTime';
1918
import {useApiQuery} from 'sentry/utils/queryClient';
2019
import {useLocation} from 'sentry/utils/useLocation';
2120
import useOrganization from 'sentry/utils/useOrganization';
@@ -197,17 +196,17 @@ function renderBodyCell({
197196
function AggregateSpanDiff({event, projectId}: {event: Event; projectId: string}) {
198197
const location = useLocation();
199198
const organization = useOrganization();
200-
const now = useMemo(() => Date.now(), []);
201-
const retentionPeriodMs = moment().subtract(90, 'days').valueOf();
202-
const {transaction, dataStart, breakpoint} = event?.occurrence?.evidenceData ?? {};
203-
204-
const start = new Date(Math.max(dataStart * 1000, retentionPeriodMs)).toISOString();
205-
const end = new Date(now).toISOString();
199+
const {transaction, breakpoint} = event?.occurrence?.evidenceData ?? {};
206200
const breakpointTimestamp = new Date(breakpoint * 1000).toISOString();
201+
202+
const {start, end} = useRelativeDateTime({
203+
anchor: breakpoint,
204+
relativeDays: 7,
205+
});
207206
const {data, isLoading, isError} = useFetchAdvancedAnalysis({
208207
transaction,
209-
start,
210-
end,
208+
start: (start as Date).toISOString(),
209+
end: (end as Date).toISOString(),
211210
breakpoint: breakpointTimestamp,
212211
projectId,
213212
});
@@ -247,8 +246,8 @@ function AggregateSpanDiff({event, projectId}: {event: Event; projectId: string}
247246
transaction,
248247
projectId,
249248
location,
250-
start,
251-
end,
249+
start: (start as Date).toISOString(),
250+
end: (end as Date).toISOString(),
252251
}),
253252
}}
254253
/>

0 commit comments

Comments
 (0)