Skip to content

Commit a37f99f

Browse files
feat(replay): Add analytics to timeline zoom buttons (#93910)
Also fixed `replay.view_html` -> `replay.view-html` --------- Co-authored-by: Michelle Zhang <[email protected]>
1 parent 4f92a94 commit a37f99f

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

static/app/components/replays/breadcrumbs/breadcrumbItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ function BreadcrumbItem({
111111
onShowSnippet();
112112
e.preventDefault();
113113
e.stopPropagation();
114-
trackAnalytics('replay.view_html', {
114+
trackAnalytics('replay.view-html', {
115115
organization,
116116
breadcrumb_type: 'category' in frame ? frame.category : 'unknown',
117117
});

static/app/components/replays/timeAndScrubberGrid.tsx

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {useRef} from 'react';
1+
import {useCallback, useRef} from 'react';
22
import {css} from '@emotion/react';
33
import styled from '@emotion/styled';
44

@@ -14,10 +14,12 @@ import {useReplayContext} from 'sentry/components/replays/replayContext';
1414
import {IconAdd, IconSubtract} from 'sentry/icons';
1515
import {t} from 'sentry/locale';
1616
import {space} from 'sentry/styles/space';
17+
import {trackAnalytics} from 'sentry/utils/analytics';
1718
import useTimelineScale, {
1819
TimelineScaleContextProvider,
1920
} from 'sentry/utils/replays/hooks/useTimelineScale';
2021
import {useReplayPrefs} from 'sentry/utils/replays/playback/providers/replayPreferencesContext';
22+
import useOrganization from 'sentry/utils/useOrganization';
2123

2224
type TimeAndScrubberGridProps = {
2325
isCompact?: boolean;
@@ -27,18 +29,35 @@ type TimeAndScrubberGridProps = {
2729

2830
function 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
/>

static/app/utils/analytics/replayAnalyticsEvents.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ export type ReplayEventParameters = {
113113
'replay.search': {
114114
search_keys: string;
115115
};
116+
'replay.timeline.zoom-in': Record<string, unknown>;
117+
'replay.timeline.zoom-out': Record<string, unknown>;
116118
'replay.toggle-fullscreen': {
117119
context: string;
118120
fullscreen: boolean;
@@ -153,6 +155,8 @@ export const replayEventMap: Record<ReplayEventKey, string | null> = {
153155
'replay.render-issues-group-list': 'Render Issues Detail Replay List',
154156
'replay.render-missing-replay-alert': 'Render Missing Replay Alert',
155157
'replay.search': 'Searched Replay',
158+
'replay.timeline.zoom-in': 'Zoomed In Replay Timeline',
159+
'replay.timeline.zoom-out': 'Zoomed Out Replay Timeline',
156160
'replay.toggle-fullscreen': 'Toggled Replay Fullscreen',
157161
'replay.view-html': 'Clicked "View HTML" in Replay Breadcrumb',
158162
};

0 commit comments

Comments
 (0)