Skip to content

Commit 6a7c269

Browse files
author
Luca Forstner
committed
Free docs from @sentry/types
1 parent 1f72538 commit 6a7c269

File tree

3 files changed

+24
-64
lines changed

3 files changed

+24
-64
lines changed

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

Lines changed: 22 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -148,38 +148,28 @@ The example below uses a `feature` tag to determine which Sentry project to
148148
send the event to. If the event does not have a `feature` tag, we send it to the
149149
fallback DSN defined in `Sentry.init`.
150150
151-
```typescript
152-
import { captureException, init, makeFetchTransport } from "@sentry/browser";
153-
import { makeMultiplexedTransport } from "@sentry/core";
154-
import { Envelope, EnvelopeItemType } from "@sentry/types";
155-
156-
interface MatchParam {
157-
/** The envelope to be sent */
158-
envelope: Envelope;
159-
/**
160-
* A function that returns an event from the envelope if one exists. You can optionally pass an array of envelope item
161-
* types to filter by - only envelopes matching the given types will be returned.
162-
*
163-
* @param types Defaults to ['event'] (only error events will be returned)
164-
*/
165-
getEvent(types?: EnvelopeItemType[]): Event | undefined;
166-
}
167-
168-
function dsnFromFeature({ getEvent }: MatchParam) {
169-
const event = getEvent();
170-
switch (event?.tags?.feature) {
171-
case "cart":
172-
return [{ dsn: "__CART_DSN__", release: "[email protected]" }];
173-
case "gallery":
174-
return [{ dsn: "__GALLERY_DSN__", release: "[email protected]" }];
175-
default:
176-
return [];
177-
}
178-
}
151+
```js
152+
import {
153+
captureException,
154+
init,
155+
makeFetchTransport,
156+
makeMultiplexedTransport,
157+
} from "@sentry/browser";
179158

180159
init({
181160
dsn: "__FALLBACK_DSN__",
182-
transport: makeMultiplexedTransport(makeFetchTransport, dsnFromFeature),
161+
transport: makeMultiplexedTransport(makeFetchTransport, ({ getEvent }) => {
162+
const event = getEvent();
163+
164+
// Send to different DSNs, based on the event payload
165+
if (event?.tags?.feature === "cart") {
166+
return [{ dsn: "__CART_DSN__", release: "[email protected]" }];
167+
} else if (event?.tags?.feature === "gallery") {
168+
return [{ dsn: "__GALLERY_DSN__", release: "[email protected]" }];
169+
} else {
170+
return [];
171+
}
172+
}),
183173
});
184174
```
185175
@@ -191,8 +181,9 @@ You can then set tags/contexts on events in individual micro-frontends to decide
191181
<PlatformLink to="/enriching-events/scopes/#local-scopes">
192182
withScope documentation
193183
</PlatformLink>
194-
). Using a global scope e.g. through `Sentry.setTag()` will result in all subsequent
195-
events being routed to the same DSN regardless of where they originate.
184+
). Using a global scope e.g. through `Sentry.setTag()` will result in all
185+
subsequent events being routed to the same DSN regardless of where they
186+
originate.
196187
</Note>
197188
198189
```typescript

docs/platforms/javascript/common/session-replay/privacy.mdx

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -150,32 +150,6 @@ Sentry.addEventProcessor((event) => {
150150
});
151151
```
152152

153-
```typescript
154-
import { Event, ReplayEvent } from "@sentry/types";
155-
156-
Sentry.addEventProcessor((event) => {
157-
// Ensure that we specifically look at replay events
158-
if (!isReplayEvent(event)) {
159-
// Return the event, otherwise the event will be dropped
160-
return event;
161-
}
162-
163-
// Your URL scrubbing function
164-
function urlScrubber(url: string): string {
165-
return url.replace(/([a-z0-9]{3}\.[a-z]{5}\.[a-z]{7})/, "[Filtered]");
166-
}
167-
168-
// Scrub all URLs with your scrubbing function
169-
event.urls = event.urls && event.urls.map(urlScrubber);
170-
171-
return event;
172-
});
173-
174-
function isReplayEvent(event: Event): event is ReplayEvent {
175-
return event.type === "replay_event";
176-
}
177-
```
178-
179153
### Deprecated Options
180154

181155
Note that the privacy API prior to version 7.35.0 has been deprecated and replaced with the options above. Please see the [Replay migration guide](https://github.com/getsentry/sentry-javascript/blob/master/packages/replay/MIGRATION.md#upgrading-replay-from-7340-to-7350---6645) for further information.

includes/javascript-crons-upsert.mdx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ Sentry.withMonitor(
2323
```
2424

2525
```typescript
26-
import { MonitorConfig } from "@sentry/types";
27-
28-
const monitorConfig: MonitorConfig = {
26+
const monitorConfig = {
2927
schedule: {
3028
type: "crontab",
3129
value: "* * * * *",
@@ -81,9 +79,7 @@ Sentry.captureCheckIn(
8179
```
8280

8381
```typescript
84-
import { MonitorConfig } from "@sentry/types";
85-
86-
const monitorConfig: MonitorConfig = {
82+
const monitorConfig = {
8783
schedule: {
8884
type: "crontab",
8985
value: "* * * * *",
@@ -155,7 +151,6 @@ The `tz` where your job is running. This is usually your server's timezone, (suc
155151

156152
</Note>
157153

158-
159154
`failureIssueThreshold`:
160155

161156
_requires SDK version `8.7.0` or higher_

0 commit comments

Comments
 (0)