Skip to content

Commit c5a1d14

Browse files
committed
dont filter xhr & fetch from initial
1 parent ec4010f commit c5a1d14

File tree

1 file changed

+22
-14
lines changed
  • packages/rrweb/src/plugins/network/record

1 file changed

+22
-14
lines changed

packages/rrweb/src/plugins/network/record/index.ts

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -105,20 +105,17 @@ function initPerformanceObserver(
105105
win: IWindow,
106106
options: Required<NetworkRecordOptions>,
107107
) {
108-
const getPerformanceEntries = (entries: PerformanceEntryList) => {
109-
return entries.filter((entry) => {
110-
return (
111-
isNavigationTiming(entry) ||
112-
(isResourceTiming(entry) &&
113-
entry.initiatorType !== 'xmlhttprequest' && // ignore xhr
114-
entry.initiatorType !== 'fetch') // ignore fetch
115-
);
116-
});
117-
};
118108
if (options.recordInitialRequests) {
119-
const initialPerformanceEntries = getPerformanceEntries(
120-
win.performance.getEntries(),
121-
);
109+
const initialPerformanceEntries = win.performance
110+
.getEntries()
111+
.filter(
112+
(entry) =>
113+
isNavigationTiming(entry) ||
114+
(isResourceTiming(entry) &&
115+
options.initiatorTypes.includes(
116+
entry.initiatorType as InitiatorType,
117+
)),
118+
);
122119
cb({
123120
requests: initialPerformanceEntries.map((performanceEntry) => ({
124121
performanceEntry,
@@ -128,7 +125,18 @@ function initPerformanceObserver(
128125
});
129126
}
130127
const observer = new win.PerformanceObserver((entries) => {
131-
const performanceEntries = getPerformanceEntries(entries.getEntries());
128+
const performanceEntries = entries
129+
.getEntries()
130+
.filter(
131+
(entry) =>
132+
isNavigationTiming(entry) ||
133+
(isResourceTiming(entry) &&
134+
options.initiatorTypes.includes(
135+
entry.initiatorType as InitiatorType,
136+
) &&
137+
entry.initiatorType !== 'xmlhttprequest' &&
138+
entry.initiatorType !== 'fetch'),
139+
);
132140
cb({
133141
requests: performanceEntries.map((performanceEntry) => ({
134142
performanceEntry,

0 commit comments

Comments
 (0)