Skip to content

Commit

Permalink
chore: catch errors thrown from inject and log to console (#120)
Browse files Browse the repository at this point in the history
  • Loading branch information
bgiori authored Aug 22, 2024
1 parent 367bdba commit a9e47dc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/experiment-tag/src/experiment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,14 @@ const handleInject = (action, key: string, variant: Variant) => {
const utils = getInjectUtils();
const js = action.data.js;
appliedInjections.add(id);
inject(js, html, utils, id);
try {
inject(js, html, utils, id);
} catch (e) {
console.error(
`Experiment inject failed for ${key} variant ${variant.key}. Reason:`,
e,
);
}
// Push mutation to remove CSS and any custom state cleanup set in utils.
appliedMutations.push({
revert: () => {
Expand Down

0 comments on commit a9e47dc

Please sign in to comment.