Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Free docs from @sentry/types #11988

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 22 additions & 31 deletions docs/platforms/javascript/common/best-practices/micro-frontends.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -148,38 +148,28 @@ The example below uses a `feature` tag to determine which Sentry project to
send the event to. If the event does not have a `feature` tag, we send it to the
fallback DSN defined in `Sentry.init`.

```typescript
import { captureException, init, makeFetchTransport } from "@sentry/browser";
import { makeMultiplexedTransport } from "@sentry/core";
import { Envelope, EnvelopeItemType } from "@sentry/types";

interface MatchParam {
/** The envelope to be sent */
envelope: Envelope;
/**
* A function that returns an event from the envelope if one exists. You can optionally pass an array of envelope item
* types to filter by - only envelopes matching the given types will be returned.
*
* @param types Defaults to ['event'] (only error events will be returned)
*/
getEvent(types?: EnvelopeItemType[]): Event | undefined;
}

function dsnFromFeature({ getEvent }: MatchParam) {
const event = getEvent();
switch (event?.tags?.feature) {
case "cart":
return [{ dsn: "__CART_DSN__", release: "cart@1.0.0" }];
case "gallery":
return [{ dsn: "__GALLERY_DSN__", release: "gallery@1.2.0" }];
default:
return [];
}
}
```js
import {
captureException,
init,
makeFetchTransport,
makeMultiplexedTransport,
} from "@sentry/browser";

init({
dsn: "__FALLBACK_DSN__",
transport: makeMultiplexedTransport(makeFetchTransport, dsnFromFeature),
transport: makeMultiplexedTransport(makeFetchTransport, ({ getEvent }) => {
const event = getEvent();

// Send to different DSNs, based on the event payload
if (event?.tags?.feature === "cart") {
return [{ dsn: "__CART_DSN__", release: "cart@1.0.0" }];
} else if (event?.tags?.feature === "gallery") {
return [{ dsn: "__GALLERY_DSN__", release: "gallery@1.2.0" }];
} else {
return [];
}
}),
});
```

Expand All @@ -191,8 +181,9 @@ You can then set tags/contexts on events in individual micro-frontends to decide
<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.
). 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.
</Note>

```typescript
Expand Down
26 changes: 0 additions & 26 deletions docs/platforms/javascript/common/session-replay/privacy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -150,32 +150,6 @@ Sentry.addEventProcessor((event) => {
});
```

```typescript
import { Event, ReplayEvent } from "@sentry/types";

Sentry.addEventProcessor((event) => {
// Ensure that we specifically look at replay events
if (!isReplayEvent(event)) {
// Return the event, otherwise the event will be dropped
return event;
}

// Your URL scrubbing function
function urlScrubber(url: string): string {
return url.replace(/([a-z0-9]{3}\.[a-z]{5}\.[a-z]{7})/, "[Filtered]");
}

// Scrub all URLs with your scrubbing function
event.urls = event.urls && event.urls.map(urlScrubber);

return event;
});

function isReplayEvent(event: Event): event is ReplayEvent {
return event.type === "replay_event";
}
```

### Deprecated Options

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.
59 changes: 0 additions & 59 deletions includes/javascript-crons-upsert.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,6 @@ Sentry.withMonitor(
);
```

```typescript
import { MonitorConfig } from "@sentry/types";

const monitorConfig: MonitorConfig = {
schedule: {
type: "crontab",
value: "* * * * *",
},
checkinMargin: 2, // In minutes. Optional.
maxRuntime: 10, // In minutes. Optional.
timezone: "America/Los_Angeles", // Optional.
};

Sentry.withMonitor(
"<monitor-slug>",
() => {
// Execute your scheduled task here...
},
monitorConfig
);
```

To configure the monitor's check-ins, use `Sentry.captureCheckIn()` and pass in your monitor configuration as a second parameter:

```javascript
Expand Down Expand Up @@ -80,42 +58,6 @@ Sentry.captureCheckIn(
);
```

```typescript
import { MonitorConfig } from "@sentry/types";

const monitorConfig: MonitorConfig = {
schedule: {
type: "crontab",
value: "* * * * *",
},
checkinMargin: 2, // In minutes. Optional.
maxRuntime: 10, // In minutes. Optional.
timezone: "America/Los_Angeles", // Optional.
};

// 🟡 Notify Sentry your job is running:
const checkInId = Sentry.captureCheckIn(
{
monitorSlug: "<monitor-slug>",
status: "in_progress",
},
monitorConfig
);

// Execute your scheduled task here...

// 🟢 Notify Sentry your job has completed successfully:
Sentry.captureCheckIn(
{
// Make sure this variable is named `checkInId`
checkInId,
monitorSlug: "<monitor-slug>",
status: "ok",
},
monitorConfig
);
```

### Monitor Configuration Properties

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

</Note>


`failureIssueThreshold`:

_requires SDK version `8.7.0` or higher_
Expand Down