@@ -77,6 +77,7 @@ type Headers = Record<string, string>;
7777
7878type NetworkRequest = {
7979 performanceEntry : PerformanceEntry ;
80+ requestMethod : string ;
8081 requestHeaders ?: Headers ;
8182 requestBody ?: string | null ;
8283 responseHeaders ?: Headers ;
@@ -127,6 +128,7 @@ function initPerformanceObserver(
127128 cb ( {
128129 requests : initialPerformanceEntries . map ( ( performanceEntry ) => ( {
129130 performanceEntry,
131+ requestMethod : 'GET' ,
130132 } ) ) ,
131133 isInitial : true ,
132134 } ) ;
@@ -136,6 +138,7 @@ function initPerformanceObserver(
136138 cb ( {
137139 requests : performanceEntries . map ( ( performanceEntry ) => ( {
138140 performanceEntry,
141+ requestMethod : 'GET' ,
139142 } ) ) ,
140143 } ) ;
141144 } ) ;
@@ -195,8 +198,8 @@ function initFetchObserver(
195198 const wrappedFetch : typeof fetch = async function ( url , init ) {
196199 let performanceEntry : PerformanceResourceTiming | undefined ;
197200 const networkRequest : Partial < NetworkRequest > = { } ;
201+ const req = new Request ( url , init ) ;
198202 try {
199- const req = new Request ( url , init ) ;
200203 if ( recordRequestHeaders ) {
201204 networkRequest . requestHeaders = { } ;
202205 req . headers . forEach ( ( value , key ) => {
@@ -254,7 +257,15 @@ function initFetchObserver(
254257 throw cause ;
255258 } finally {
256259 if ( performanceEntry ) {
257- cb ( { requests : [ { performanceEntry, ...networkRequest } ] } ) ;
260+ cb ( {
261+ requests : [
262+ {
263+ performanceEntry,
264+ requestMethod : req . method ,
265+ ...networkRequest ,
266+ } ,
267+ ] ,
268+ } ) ;
258269 }
259270 }
260271 } ;
0 commit comments