-
Notifications
You must be signed in to change notification settings - Fork 52
Description
Environment
"@sentry/webpack-plugin": "^2.10.1",
"@sentry/react": "^7.77.0",
"@nx/webpack": "17.0.3",
Problem
I have a react micro front-end project that I set up with Nx and module federation.
I have four different micro front-end projects: header, category, product, and footer. I want to track errors via Sentry. I am initiating the sentry in my header micro front-end project. I use sentryWebpackPlugin to understand which project the errors occur in. As shown below, I installed the sentryWebpack plugin separately for each project.
import { composePlugins, withNx } from '@nx/webpack';
import { withReact } from '@nx/react';
import { withModuleFederation } from '@nx/react/module-federation';
import { sentryWebpackPlugin } from '@sentry/webpack-plugin';
import { merge } from 'webpack-merge';
import baseConfig from './module-federation.config';
const mfConfig = {
...baseConfig,
};
module.exports = composePlugins(
withNx(),
withReact(),
async (config, { options, context }) => {
const federatedModules = await withModuleFederation(mfConfig);
const config = merge(federatedModules(config, { options, context }), {
devtool: 'source-map',
plugins: [
sentryWebpackPlugin({
_experiments: {
moduleMetadata: ({ release }) => ({
dsn: 'MY_DSN',
release,
}),
},
}),
],
});
return config;
}
);
I include my header and footer micro projects in the host (shell) project. I imported my product project into my header project and category project into my product project as shown below.
host/app.tsx
const Header = React.lazy(() => import('header/Module'));
const Footer = React.lazy(() => import('footer/Module'));
export function App() {
return (
<React.Suspense fallback={null}>
<Header />
<Footer />
</React.Suspense>
);
}
header/app.tsx
const Product = React.lazy(() => import('product/Module'));
export function App() {
return (
<React.Suspense fallback={null}>
<ChakraProvider>
...
<Routes>
<Route path="/product" element={<Product />} />
</Routes>
</ChakraProvider>
</React.Suspense>
);
}
product/app.tsx
const Category = React.lazy(() => import('category/Module'));
export function App() {
return (
<div>
<Category />
...
</div>
);
}
For errors occurring in the product and category project, the sentry webpack plugin sets the DSN information of header DSN information. This causes errors to be sent to the wrong project.(Errors occurring in product and category projects are sent to the issue list of the header project.) How can I overcome this situation?
Metadata
Metadata
Assignees
Labels
Projects
Status
Status