Issue
I added a pluggable integration to my JavaScript SDK configuration while using the Loader Script, and the integration does not run as expected.
Applies To
All SaaS Customers and Self-Hosted Users
JavaScript SDK
Loader Script
SDK Setup
Resolution
Pluggable integrations are not included in the default Loader Script bundle. Add them with Sentry.lazyLoadIntegration (Loader v8 and later), or install with npm or a full CDN bundle.
Confirm you are using the Loader Script from Project Settings > Client Keys (DSN) > Loader Script.
In
window.sentryOnLoad, callSentry.init, then lazy-load the integration and add it.If lazy-loading fails (for example because of an ad blocker), handle the rejected promise and fall back to npm or a CDN install.
Example for Loader v8 and later with captureConsoleIntegration:
<script>
window.sentryOnLoad = function () {
Sentry.init({}); Sentry.lazyLoadIntegration("captureConsoleIntegration").then(
(integration) => {
Sentry.addIntegration(integration());
},
);
};
</script>
Common pluggable integrations that need this pattern include:
captureConsoleIntegrationcontextLinesIntegrationhttpClientIntegrationreportingObserverIntegrationrewriteFramesIntegration
See the full lazy-load list on the JavaScript integrations page.
You can also install and initialize the SDK with npm or a CDN bundle, then add the integration in Sentry.init.
For another Loader lazy-load example, see How do I use User Feedback with the JavaScript Loader Script?.
