Skip to content

Commit

Permalink
Merge pull request #82 from iuliag/samplerum-always
Browse files Browse the repository at this point in the history
feat: enable listeners to all RUM events, not just the sampled ones
  • Loading branch information
trieloff authored Aug 22, 2023
2 parents 98eebdb + 26d9b2e commit 7aeb5d9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ logs
.DS_Store
test-results.xml
.env
.idea
7 changes: 7 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ 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;
};
Expand Down Expand Up @@ -82,6 +86,9 @@ export function sampleRUM(checkpoint, data = {}) {
sampleRUM.cases[checkpoint]();
}
}
if (sampleRUM.always[checkpoint]) {
sampleRUM.always[checkpoint](data);
}
} catch (error) {
// something went wrong
}
Expand Down

0 comments on commit 7aeb5d9

Please sign in to comment.