Skip to content

Commit

Permalink
feat: enable listeners to all RUM events, not just the sampled ones
Browse files Browse the repository at this point in the history
  • Loading branch information
iuliag committed Aug 22, 2023
1 parent 4751239 commit 871ede4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions scripts/lib-franklin.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export function sampleRUM(checkpoint, data = {}) {
.filter(({ fnname }) => dfnname === fnname)
.forEach(({ fnname, args }) => sampleRUM[fnname](...args));
});
sampleRUM.always = sampleRUM.always || [];
sampleRUM.always.on = (chkpnt, fn) => { sampleRUM.always[chkpnt] = fn; };
sampleRUM.on = (chkpnt, fn) => { sampleRUM.cases[chkpnt] = fn; };
defer('observe');
defer('cwv');
Expand Down Expand Up @@ -72,6 +74,7 @@ export function sampleRUM(checkpoint, data = {}) {
};
sendPing(data);
if (sampleRUM.cases[checkpoint]) { sampleRUM.cases[checkpoint](); }
if (sampleRUM.always[checkpoint]) { sampleRUM.always[checkpoint](data); }
}
} catch (error) {
// something went wrong
Expand Down

0 comments on commit 871ede4

Please sign in to comment.