Skip to content

Commit 8bcc14c

Browse files
committed
fix: avoid empty catch blocks in analytics
1 parent 9e7e113 commit 8bcc14c

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

src/social-share-button.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -763,14 +763,18 @@ class SocialShareButton {
763763
});
764764
const el = this._getContainer();
765765
(el || document).dispatchEvent(domEvent);
766-
} catch (_) {}
766+
} catch (_) {
767+
// Ignore DOM event errors; analytics is best-effort.
768+
}
767769
}
768770

769771
// Path 2 — onAnalytics callback (direct, single-consumer hook)
770772
if (typeof this.options.onAnalytics === "function") {
771773
try {
772774
this.options.onAnalytics(payload);
773-
} catch (_) {}
775+
} catch (_) {
776+
// Ignore analytics handler errors to avoid breaking share flow.
777+
}
774778
}
775779

776780
// Path 3 — plugin / adapter registry (supports multiple simultaneous consumers)
@@ -779,7 +783,9 @@ class SocialShareButton {
779783
if (plugin && typeof plugin.track === "function") {
780784
try {
781785
plugin.track(payload);
782-
} catch (_) {}
786+
} catch (_) {
787+
// Ignore plugin errors to keep analytics best-effort.
788+
}
783789
}
784790
}
785791
}

0 commit comments

Comments
 (0)