Skip to content

Commit 14f6fbb

Browse files
author
Luca Forstner
authored
Free docs from @sentry/types (#11988)
1 parent 1f72538 commit 14f6fbb

File tree

3 files changed

+22
-116
lines changed

3 files changed

+22
-116
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: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,6 @@ Sentry.withMonitor(
2222
);
2323
```
2424

25-
```typescript
26-
import { MonitorConfig } from "@sentry/types";
27-
28-
const monitorConfig: MonitorConfig = {
29-
schedule: {
30-
type: "crontab",
31-
value: "* * * * *",
32-
},
33-
checkinMargin: 2, // In minutes. Optional.
34-
maxRuntime: 10, // In minutes. Optional.
35-
timezone: "America/Los_Angeles", // Optional.
36-
};
37-
38-
Sentry.withMonitor(
39-
"<monitor-slug>",
40-
() => {
41-
// Execute your scheduled task here...
42-
},
43-
monitorConfig
44-
);
45-
```
46-
4725
To configure the monitor's check-ins, use `Sentry.captureCheckIn()` and pass in your monitor configuration as a second parameter:
4826

4927
```javascript
@@ -80,42 +58,6 @@ Sentry.captureCheckIn(
8058
);
8159
```
8260

83-
```typescript
84-
import { MonitorConfig } from "@sentry/types";
85-
86-
const monitorConfig: MonitorConfig = {
87-
schedule: {
88-
type: "crontab",
89-
value: "* * * * *",
90-
},
91-
checkinMargin: 2, // In minutes. Optional.
92-
maxRuntime: 10, // In minutes. Optional.
93-
timezone: "America/Los_Angeles", // Optional.
94-
};
95-
96-
// 🟡 Notify Sentry your job is running:
97-
const checkInId = Sentry.captureCheckIn(
98-
{
99-
monitorSlug: "<monitor-slug>",
100-
status: "in_progress",
101-
},
102-
monitorConfig
103-
);
104-
105-
// Execute your scheduled task here...
106-
107-
// 🟢 Notify Sentry your job has completed successfully:
108-
Sentry.captureCheckIn(
109-
{
110-
// Make sure this variable is named `checkInId`
111-
checkInId,
112-
monitorSlug: "<monitor-slug>",
113-
status: "ok",
114-
},
115-
monitorConfig
116-
);
117-
```
118-
11961
### Monitor Configuration Properties
12062

12163
The following are available monitor configuration properties:
@@ -155,7 +97,6 @@ The `tz` where your job is running. This is usually your server's timezone, (suc
15597

15698
</Note>
15799

158-
159100
`failureIssueThreshold`:
160101

161102
_requires SDK version `8.7.0` or higher_

0 commit comments

Comments
 (0)