Commit 4961137
feat(core): Make \
The `matcher` parameter in `makeMultiplexedTransport` is now optional with a
sensible default. This makes it much easier to use the multiplexed transport for
sending events to multiple DSNs based on runtime configuration.
**Before:**
```javascript
import { makeFetchTransport, makeMultiplexedTransport } from '@sentry/browser';
const EXTRA_KEY = 'ROUTE_TO';
const transport = makeMultiplexedTransport(makeFetchTransport, args => {
const event = args.getEvent();
if (event?.extra?.[EXTRA_KEY] && Array.isArray(event.extra[EXTRA_KEY])) {
return event.extra[EXTRA_KEY];
}
return [];
});
Sentry.init({
transport,
// ... other options
});
// Capture events with routing info
Sentry.captureException(error, {
extra: {
[EXTRA_KEY]: [
{ dsn: 'https://[email protected]/project1', release: 'v1.0.0' },
{ dsn: 'https://[email protected]/project2' },
],
},
});
```
**After:**
```javascript
import {
makeFetchTransport,
makeMultiplexedTransport,
MULTIPLEXED_TRANSPORT_EXTRA_KEY
} from '@sentry/browser';
// Just pass the transport generator - the default matcher handles the rest!
Sentry.init({
transport: makeMultiplexedTransport(makeFetchTransport),
// ... other options
});
// Capture events with routing info using the exported constant
Sentry.captureException(error, {
extra: {
[MULTIPLEXED_TRANSPORT_EXTRA_KEY]: [
{ dsn: 'https://[email protected]/project1', release: 'v1.0.0' },
{ dsn: 'https://[email protected]/project2' },
],
},
});
```
The default matcher looks for routing information in
`event.extra[MULTIPLEXED_TRANSPORT_EXTRA_KEY]`. You can still provide a custom
matcher function for advanced use cases.matcher\ parameter optional in \makeMultiplexedTransport\
1 parent cabb611 commit 4961137
1 file changed
+24
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
151 | 151 | | |
152 | 152 | | |
153 | 153 | | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
0 commit comments