Skip to content

Commit 4cff528

Browse files
author
Luca Forstner
authored
Stabilize module metadata in MFE docs (#10414)
1 parent e845e13 commit 4cff528

File tree

1 file changed

+26
-21
lines changed

1 file changed

+26
-21
lines changed

docs/platforms/javascript/common/best-practices/micro-frontends.mdx

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ different release cycles, you may want to identify these or route events to spec
2828
Below we offer two approaches.
2929

3030
<Note>
31-
In all cases `Sentry.init()` must never be called more than once, doing so will result in undefined behavior.
31+
In all cases `Sentry.init()` must never be called more than once, doing so
32+
will result in undefined behavior.
3233
</Note>
3334

3435
## Automatically Route Errors to Different Projects Depending on Module
@@ -38,20 +39,19 @@ events to different Sentry projects based on the module where the error
3839
occurred.
3940

4041
<Note>
41-
<ul>
42-
<li>
43-
Requires version `2.5.0` or higher of `@sentry/webpack-plugin` or version
44-
`2.7.0` or higher of `@sentry/rollup-plugin`, `@sentry/vite-plugin` or `@sentry/esbuild-plugin`.
45-
</li>
46-
<li>
47-
Requires SDK version `7.59.0` or higher.
48-
</li>
49-
</ul>
42+
<ul>
43+
<li>
44+
Requires version `2.18.0` or higher of `@sentry/webpack-plugin`,
45+
`@sentry/rollup-plugin`, `@sentry/vite-plugin` or
46+
`@sentry/esbuild-plugin`.
47+
</li>
48+
<li>Requires SDK version `7.59.0` or higher.</li>
49+
</ul>
5050
</Note>
5151

5252
First, to identify the source of an error, you must inject metadata that helps identify
5353
which bundles were responsible for the error. You can do this with any of the
54-
Sentry bundler plugins by enabling the `_experiments.moduleMetadata` option. The example
54+
Sentry bundler plugins by enabling the `moduleMetadata` option. The example
5555
below is for Webpack, but this is also supported in Vite, Rollup, and esbuild.
5656

5757
```javascript
@@ -62,10 +62,7 @@ module.exports = {
6262
devtool: "source-map",
6363
plugins: [
6464
sentryWebpackPlugin({
65-
/* Other plugin config */
66-
_experiments: {
67-
moduleMetadata: ({ release }) => ({ dsn: "__MODULE_DSN__", release }),
68-
},
65+
moduleMetadata: ({ release }) => ({ dsn: "__MODULE_DSN__", release }),
6966
}),
7067
],
7168
};
@@ -82,7 +79,12 @@ for the multiplexed transport to reference for routing.
8279
In practice, here is what your Sentry initialization should look like:
8380

8481
```javascript
85-
import { init, makeFetchTransport, moduleMetadataIntegration, makeMultiplexedTransport } from "@sentry/browser";
82+
import {
83+
init,
84+
makeFetchTransport,
85+
moduleMetadataIntegration,
86+
makeMultiplexedTransport,
87+
} from "@sentry/browser";
8688

8789
const EXTRA_KEY = "ROUTE_TO";
8890

@@ -127,16 +129,13 @@ init({
127129
128130
Once this is set up, errors - both handled and unhandled - will be automatically routed to the right project.
129131
130-
131132
## Manually Route Errors to Different Projects
132133
133134
If, however, you would like to have more control over the routing of errors to the point
134135
where you explicitly specify the destination for each individual `captureException`,
135136
you can do that with the more advanced interface multiplexed transport offers.
136137
137-
<Note>
138-
Requires SDK version `7.59.0` or higher.
139-
</Note>
138+
<Note>Requires SDK version `7.59.0` or higher.</Note>
140139
141140
The example below uses a `feature` tag to determine which Sentry project to
142141
send the event to. If the event does not have a `feature` tag, we send it to the
@@ -180,7 +179,13 @@ init({
180179
You can then set tags/contexts on events in individual micro-frontends to decide which Sentry project to send the event to as follows:
181180
182181
<Note>
183-
It is important to always use a local scope when setting the tag (either as shown below or using <PlatformLink to="/enriching-events/scopes/#local-scopes">withScope documentation</PlatformLink>). Using a global scope e.g. through `Sentry.setTag()` will result in all subsequent events being routed to the same DSN regardless of where they originate.
182+
It is important to always use a local scope when setting the tag (either as
183+
shown below or using{" "}
184+
<PlatformLink to="/enriching-events/scopes/#local-scopes">
185+
withScope documentation
186+
</PlatformLink>
187+
). Using a global scope e.g. through `Sentry.setTag()` will result in all subsequent
188+
events being routed to the same DSN regardless of where they originate.
184189
</Note>
185190
186191
```

0 commit comments

Comments
 (0)