Skip to content

Commit

Permalink
🐛 [RUMF-791] prevent IE11 performance entry error (#633)
Browse files Browse the repository at this point in the history
* 🐛 [RUMF-791] prevent IE11 performance entry error

toJSON is not available in IE11, prevent execution error

* 👌 different form

Co-authored-by: Benoît Zugmeyer <benoit.zugmeyer@datadoghq.com>

Co-authored-by: Benoît Zugmeyer <benoit.zugmeyer@datadoghq.com>
  • Loading branch information
bcaudan and BenoitZugmeyer committed Nov 24, 2020
1 parent a5c6271 commit 42f589f
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@ export function matchRequestTiming(request: RequestCompleteEvent) {
if (!performance || !('getEntriesByName' in performance)) {
return
}
const candidates = performance
.getEntriesByName(request.url, 'resource')
const sameNameEntries = performance.getEntriesByName(request.url, 'resource')

if (!sameNameEntries.length || !('toJSON' in sameNameEntries[0])) {
return
}

const candidates = sameNameEntries
.map((entry) => entry.toJSON() as RumPerformanceResourceTiming)
.filter(toValidEntry)
.filter((entry) => isBetween(entry, request.startTime, endTime(request)))
Expand Down

0 comments on commit 42f589f

Please sign in to comment.