Skip to content

Commit

Permalink
feat(checkpoint): introduce new resource checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
chicharr committed Oct 23, 2023
1 parent 4a53102 commit 2845a20
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,12 @@ document.querySelectorAll('form').forEach((form) => {

window.addEventListener('visibilitychange', ((event) => sampleRUM.leave(event)));
window.addEventListener('pagehide', ((event) => sampleRUM.leave(event)));

const observer = new PerformanceObserver((list) => {
list.getEntries()
.filter((entry) => (entry.responseStatus < 400) && new URL(entry.name).pathname.match('.*(\\.plain\\.html|\\.json)$'))
.forEach((entry) => {
sampleRUM('resource', { source: entry.name, target: Math.round(entry.duration) });
});
});
observer.observe({ type: 'resource', buffered: true });

0 comments on commit 2845a20

Please sign in to comment.