You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If your frontend includes JavaScript bundles from multiple sources with
15
15
different release cycles, you may want to identify these or route events to specific projects. This is especially useful if you've set up [module federation](https://module-federation.github.io/) or a similar frontend architecture.
16
16
17
-
## Identifying the source of errors
17
+
Below we offer two approaches.
18
18
19
-
To identify the source of an error, you must inject metadata that helps identify
20
-
which bundles were responsible for the error. You can do this with any of the
21
-
Sentry bundler plugins by enabling the `_experiments.moduleMetadata` option.
19
+
<Note>
20
+
In all cases `Sentry.init()` must never be called more than once, doing so will result in undefined behavior.
21
+
</Note>
22
+
23
+
## Automatically Route Errors to Different Projects Depending on Module
24
+
25
+
`ModuleMetadata` and `makeMultiplexedTransport` can be used together to automatically route
26
+
events to different Sentry projects based on the module where the error
27
+
occurred.
22
28
29
+
<Note>
30
+
<ul>
31
+
<li>
23
32
Requires version `2.5.0` or higher of `@sentry/webpack-plugin` or version
24
33
`2.7.0` or higher of `@sentry/rollup-plugin`, `@sentry/vite-plugin` or `@sentry/esbuild-plugin`.
34
+
</li>
35
+
<li>
36
+
Requires SDK version `7.59.0` or higher.
37
+
</li>
38
+
</ul>
39
+
</Note>
25
40
26
-
`moduleMetadata` can be any serializable data or alternatively a function that
27
-
returns serializable data. If you supply a function, it will be passed an object
28
-
containing the `org`, `project`, and `release` strings.
41
+
First, to identify the source of an error, you must inject metadata that helps identify
42
+
which bundles were responsible for the error. You can do this with any of the
43
+
Sentry bundler plugins by enabling the `_experiments.moduleMetadata` option. The example
44
+
below is for Webpack, but this is also supported in Vite, Rollup, and esbuild.
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.
0 commit comments