1- import { useRef } from 'react' ;
1+ import { useCallback , useRef } from 'react' ;
22import { css } from '@emotion/react' ;
33import styled from '@emotion/styled' ;
44
@@ -14,10 +14,12 @@ import {useReplayContext} from 'sentry/components/replays/replayContext';
1414import { IconAdd , IconSubtract } from 'sentry/icons' ;
1515import { t } from 'sentry/locale' ;
1616import { space } from 'sentry/styles/space' ;
17+ import { trackAnalytics } from 'sentry/utils/analytics' ;
1718import useTimelineScale , {
1819 TimelineScaleContextProvider ,
1920} from 'sentry/utils/replays/hooks/useTimelineScale' ;
2021import { useReplayPrefs } from 'sentry/utils/replays/playback/providers/replayPreferencesContext' ;
22+ import useOrganization from 'sentry/utils/useOrganization' ;
2123
2224type TimeAndScrubberGridProps = {
2325 isCompact ?: boolean ;
@@ -27,18 +29,35 @@ type TimeAndScrubberGridProps = {
2729
2830function TimelineSizeBar ( { isLoading} : { isLoading ?: boolean } ) {
2931 const { replay} = useReplayContext ( ) ;
32+ const organization = useOrganization ( ) ;
3033 const [ timelineScale , setTimelineScale ] = useTimelineScale ( ) ;
3134 const durationMs = replay ?. getDurationMs ( ) ;
3235 const maxScale = durationMs ? Math . ceil ( durationMs / 60000 ) : 10 ;
3336
37+ const handleZoomOut = useCallback ( ( ) => {
38+ const newScale = Math . max ( timelineScale - 1 , 1 ) ;
39+ setTimelineScale ( newScale ) ;
40+ trackAnalytics ( 'replay.timeline.zoom-out' , {
41+ organization,
42+ } ) ;
43+ } , [ timelineScale , setTimelineScale , organization ] ) ;
44+
45+ const handleZoomIn = useCallback ( ( ) => {
46+ const newScale = Math . min ( timelineScale + 1 , maxScale ) ;
47+ setTimelineScale ( newScale ) ;
48+ trackAnalytics ( 'replay.timeline.zoom-in' , {
49+ organization,
50+ } ) ;
51+ } , [ timelineScale , maxScale , setTimelineScale , organization ] ) ;
52+
3453 return (
3554 < ButtonBar gap = { 0.5 } >
3655 < Button
3756 size = "xs"
3857 title = { t ( 'Zoom out' ) }
3958 icon = { < IconSubtract /> }
4059 borderless
41- onClick = { ( ) => setTimelineScale ( Math . max ( timelineScale - 1 , 1 ) ) }
60+ onClick = { handleZoomOut }
4261 aria-label = { t ( 'Zoom out' ) }
4362 disabled = { timelineScale === 1 || isLoading }
4463 />
@@ -51,7 +70,7 @@ function TimelineSizeBar({isLoading}: {isLoading?: boolean}) {
5170 title = { t ( 'Zoom in' ) }
5271 icon = { < IconAdd /> }
5372 borderless
54- onClick = { ( ) => setTimelineScale ( Math . min ( timelineScale + 1 , maxScale ) ) }
73+ onClick = { handleZoomIn }
5574 aria-label = { t ( 'Zoom in' ) }
5675 disabled = { timelineScale === maxScale || isLoading }
5776 />
0 commit comments