1
- import { useMemo } from 'react' ;
2
1
import styled from '@emotion/styled' ;
3
2
import { Location } from 'history' ;
4
- import moment from 'moment' ;
5
3
6
4
import EmptyStateWarning from 'sentry/components/emptyStateWarning' ;
7
5
import { DataSection } from 'sentry/components/events/styles' ;
@@ -16,6 +14,7 @@ import {Tooltip} from 'sentry/components/tooltip';
16
14
import { t , tct } from 'sentry/locale' ;
17
15
import { Event , Organization } from 'sentry/types' ;
18
16
import { defined } from 'sentry/utils' ;
17
+ import { useRelativeDateTime } from 'sentry/utils/profiling/hooks/useRelativeDateTime' ;
19
18
import { useApiQuery } from 'sentry/utils/queryClient' ;
20
19
import { useLocation } from 'sentry/utils/useLocation' ;
21
20
import useOrganization from 'sentry/utils/useOrganization' ;
@@ -197,17 +196,17 @@ function renderBodyCell({
197
196
function AggregateSpanDiff ( { event, projectId} : { event : Event ; projectId : string } ) {
198
197
const location = useLocation ( ) ;
199
198
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 ?? { } ;
206
200
const breakpointTimestamp = new Date ( breakpoint * 1000 ) . toISOString ( ) ;
201
+
202
+ const { start, end} = useRelativeDateTime ( {
203
+ anchor : breakpoint ,
204
+ relativeDays : 7 ,
205
+ } ) ;
207
206
const { data, isLoading, isError} = useFetchAdvancedAnalysis ( {
208
207
transaction,
209
- start,
210
- end,
208
+ start : ( start as Date ) . toISOString ( ) ,
209
+ end : ( end as Date ) . toISOString ( ) ,
211
210
breakpoint : breakpointTimestamp ,
212
211
projectId,
213
212
} ) ;
@@ -247,8 +246,8 @@ function AggregateSpanDiff({event, projectId}: {event: Event; projectId: string}
247
246
transaction,
248
247
projectId,
249
248
location,
250
- start,
251
- end,
249
+ start : ( start as Date ) . toISOString ( ) ,
250
+ end : ( end as Date ) . toISOString ( ) ,
252
251
} ) ,
253
252
} }
254
253
/>
0 commit comments