Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/browser
SDK Version
7.119.0
Framework Version
No response
Link to Sentry event
No response
Reproduction Example/SDK Setup
Similarly to #13297, I am using a loader script and moduleMetadataIntegration
seems to be unavailable when using loader script.
I need this integration as advised for micro-frontend environment, and to use that solution I am migrating from Sentry SDK 5.30.0
to 7.119.0
, which is already challenging.
Any reason to not have a dedicated bundle for this integration like other integration have?
This is a necessity for micro-frontend environment so I really hope there's a way to work around it .
Would appreciate your help in the matter. 🙏
Steps to Reproduce
Use loader script for 7.x version.
Have this script above:
<script>
// Configure sentryOnLoad before adding the Loader Script
// https://docs.sentry.io/platforms/javascript/install/loader/#custom-configuration
window.sentryOnLoad = function () {
console.log('sentryOnLoad')
console.log(window.Sentry)
window.Sentry.init({
// moduleMetadataIntegration is a required integration for having the module_metadata available in runtime
integrations: [window.Sentry.moduleMetadataIntegration()],
// Solution for getting the route to the unhandled error.
// This is the recommended solution for micro-frontend environment.
beforeSend: function(event){
if (event?.exception?.values?.[0].stacktrace.frames) {
const frames = event.exception.values[0].stacktrace.frames;
// Find the last frame with module metadata containing a DSN
const framesModuleMetadata = frames
.filter(
(frame) => frame.module_metadata && frame.module_metadata.dsn,
)
.map((v) => v.module_metadata)
const routeTo = framesModuleMetadata.slice(-1); // using top frame only - you may want to customize this according to your needs
if (routeTo.length) {
event.extra = {
...event.extra,
ROUTE_TO: routeTo,
};
}
}
return event;
}
})
}
</script>
Expected Result
Sentry is initialized successfully.
Actual Result
TypeError: Sentry.moduleMetadataIntegration is not a function
Metadata
Metadata
Assignees
Type
Projects
Status