Skip to content

Commit 9915727

Browse files
fix(replay): fix replay missing banner analytic (#83332)
prevent the replay missing banner analytic from being sent multiple times
1 parent 2cc2a53 commit 9915727

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

static/app/components/events/eventReplay/replayClipPreviewPlayer.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {useEffect} from 'react';
12
import styled from '@emotion/styled';
23

34
import {Alert} from 'sentry/components/alert';
@@ -79,6 +80,15 @@ function ReplayClipPreviewPlayer({
7980
});
8081
const organization = useOrganization();
8182

83+
useEffect(() => {
84+
if (replayReaderResult.fetchError) {
85+
trackAnalytics('replay.render-missing-replay-alert', {
86+
organization,
87+
surface: 'issue details - clip preview',
88+
});
89+
}
90+
}, [organization, replayReaderResult.fetchError]);
91+
8292
if (replayReaderResult.replayRecord?.is_archived) {
8393
return (
8494
<Alert type="warning" data-test-id="replay-error">
@@ -91,10 +101,6 @@ function ReplayClipPreviewPlayer({
91101
}
92102

93103
if (replayReaderResult.fetchError) {
94-
trackAnalytics('replay.render-missing-replay-alert', {
95-
organization,
96-
surface: 'issue details - clip preview',
97-
});
98104
return <MissingReplayAlert orgSlug={orgSlug} />;
99105
}
100106

static/app/components/events/eventReplay/replayPreview.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type {ComponentProps} from 'react';
2-
import {useMemo} from 'react';
2+
import {useEffect, useMemo} from 'react';
33
import styled from '@emotion/styled';
44

55
import {Alert} from 'sentry/components/alert';
@@ -79,6 +79,15 @@ function ReplayPreview({
7979
event_replay_status: getReplayAnalyticsStatus({fetchError, replayRecord}),
8080
});
8181

82+
useEffect(() => {
83+
if (fetchError) {
84+
trackAnalytics('replay.render-missing-replay-alert', {
85+
organization,
86+
surface: 'issue details - old preview',
87+
});
88+
}
89+
}, [organization, fetchError]);
90+
8291
if (replayRecord?.is_archived) {
8392
return (
8493
<Alert type="warning" data-test-id="replay-error">
@@ -91,10 +100,6 @@ function ReplayPreview({
91100
}
92101

93102
if (fetchError) {
94-
trackAnalytics('replay.render-missing-replay-alert', {
95-
organization,
96-
surface: 'issue details - old preview',
97-
});
98103
return <MissingReplayAlert orgSlug={orgSlug} />;
99104
}
100105

0 commit comments

Comments
 (0)