Skip to content

Commit 7b5ef20

Browse files
authored
ref(replays): Read from the rrweb saved config to see if replay network details is setup (#48967)
Fixes #48733 See also: getsentry/sentry-docs#6943
1 parent df4e9fc commit 7b5ef20

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

static/app/utils/replays/replayReader.tsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
} from 'sentry/utils/replays/replayDataUtils';
1616
import type {
1717
RecordingEvent,
18+
RecordingOptions,
1819
ReplayError,
1920
ReplayRecord,
2021
ReplaySpan,
@@ -151,11 +152,26 @@ export default class ReplayReader {
151152

152153
getMemorySpans = memoize(() => this.sortedSpans.filter(isMemorySpan));
153154

154-
isNetworkDetailsSetup = memoize(() =>
155-
this.getNetworkSpans().some(
155+
sdkConfig = memoize(() => {
156+
const found = this.rrwebEvents.find(
157+
event => event.type === 5 && event.data.tag === 'options'
158+
) as undefined | RecordingOptions;
159+
return found?.data?.payload;
160+
});
161+
162+
isNetworkDetailsSetup = memoize(() => {
163+
const config = this.sdkConfig();
164+
if (config) {
165+
return this.sdkConfig()?.networkDetailHasUrls;
166+
}
167+
168+
// Network data was added in JS SDK 7.50.0 while sdkConfig was added in v7.51.1
169+
// So even if we don't have the config object, we should still fallback and
170+
// look for spans with network data, as that means things are setup!
171+
return this.getNetworkSpans().some(
156172
span =>
157173
Object.keys(span.data.request?.headers || {}).length ||
158174
Object.keys(span.data.response?.headers || {}).length
159-
)
160-
);
175+
);
176+
});
161177
}

static/app/views/replays/types.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type {eventWithTime} from '@sentry-internal/rrweb/typings/types';
1+
import type {customEvent, eventWithTime} from '@sentry-internal/rrweb/typings/types';
22
import type {Duration} from 'moment';
33

44
import type {RawCrumb} from 'sentry/types/breadcrumbs';
@@ -155,6 +155,19 @@ export interface Highlight {
155155
}
156156

157157
export type RecordingEvent = eventWithTime;
158+
export type RecordingOptions = customEvent<{
159+
blockAllMedia: boolean;
160+
errorSampleRate: number;
161+
maskAllInputs: boolean;
162+
maskAllText: boolean;
163+
networkCaptureBodies: boolean;
164+
networkDetailHasUrls: boolean;
165+
networkRequestHasHeaders: boolean;
166+
networkResponseHasHeaders: boolean;
167+
sessionSampleRate: number;
168+
useCompression: boolean;
169+
useCompressionOption: boolean;
170+
}>;
158171

159172
export interface ReplaySpan<T = Record<string, any>> {
160173
data: T;

0 commit comments

Comments
 (0)