@@ -105,20 +105,17 @@ function initPerformanceObserver(
105
105
win : IWindow ,
106
106
options : Required < NetworkRecordOptions > ,
107
107
) {
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
- } ;
118
108
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
+ ) ;
122
119
cb ( {
123
120
requests : initialPerformanceEntries . map ( ( performanceEntry ) => ( {
124
121
performanceEntry,
@@ -128,7 +125,18 @@ function initPerformanceObserver(
128
125
} ) ;
129
126
}
130
127
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
+ ) ;
132
140
cb ( {
133
141
requests : performanceEntries . map ( ( performanceEntry ) => ( {
134
142
performanceEntry,
0 commit comments