Skip to content

Commit

Permalink
fix: when capturing without performance entry we can capture manual i…
Browse files Browse the repository at this point in the history
…nitiator type
  • Loading branch information
pauldambra committed Sep 17, 2024
1 parent 2f093d3 commit 9e1616a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/entrypoints/recorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ function initXhrObserver(cb: networkCallback, win: IWindow, options: Required<Ne
start,
end,
url: url.toString(),
initiatorType: 'xmlhttprequest',
})
cb({ requests })
})
Expand Down Expand Up @@ -355,6 +356,7 @@ function prepareRequest({
start,
end,
url,
initiatorType,
}: {
entry: PerformanceResourceTiming | null
method: string | undefined
Expand All @@ -363,8 +365,10 @@ function prepareRequest({
isInitial?: boolean
start?: number
end?: number
// if there is no entry, we still need to know the url
// if there is no performance observer entry, we still need to know the url
url?: string
// if there is no performance observer entry, we can provide the initiatorType
initiatorType?: string
}): CapturedNetworkRequest[] {
start = entry ? entry.startTime : start
end = entry ? entry.responseEnd : end
Expand All @@ -389,7 +393,7 @@ function prepareRequest({
timeOrigin,
timestamp,
method: method,
initiatorType: entry ? (entry.initiatorType as InitiatorType) : undefined,
initiatorType: entry ? (entry.initiatorType as InitiatorType) : initiatorType,
status,
requestHeaders: networkRequest.requestHeaders,
requestBody: networkRequest.requestBody,
Expand Down Expand Up @@ -583,6 +587,7 @@ function initFetchObserver(
start,
end,
url: req.url,
initiatorType: 'fetch',
})
cb({ requests })
})
Expand Down

0 comments on commit 9e1616a

Please sign in to comment.