Skip to content

Commit

Permalink
Merge pull request #83 from chicharr/resource-checkpoint
Browse files Browse the repository at this point in the history
feat(checkpoint): introduce new resource checkpoint
  • Loading branch information
chicharr authored Oct 31, 2023
2 parents 76b96f9 + 8464d7d commit 7737e32
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,15 @@ document.querySelectorAll('form').forEach((form) => {

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

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

0 comments on commit 7737e32

Please sign in to comment.