Skip to content

Commit 480bb06

Browse files
author
Luca Forstner
authored
Add crons documentation for full-stack JS frameworks (#7212)
1 parent 4d39fc7 commit 480bb06

File tree

12 files changed

+100
-58
lines changed

12 files changed

+100
-58
lines changed

src/docs/product/crons/getting-started/index.mdx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ To set up Sentry Crons, use the links below for supported SDKs or the Sentry CLI
1515
- [Python](/platforms/python/crons/)
1616
- [Celery](/platforms/python/guides/celery/crons/)
1717
- [Node](/platforms/node/crons/)
18+
- [Next.js](/platforms/javascript/guides/nextjs/crons/)
19+
- [SvelteKit](/platforms/javascript/guides/sveltekit/crons/)
20+
- [Remix](/platforms/javascript/guides/remix/crons/)
1821

1922
<Alert level="note" title="Don't see your platform?">
2023

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
Check-in monitoring allows you to track a job's progress by completing two check-ins: one at the start of your job and another at the end of your job. This two-step process allows Sentry to notify you if your job didn't start when expected (missed) or if it exceeded its maximum runtime (failed).
2+
3+
```javascript
4+
// 🟡 Notify Sentry your job is running:
5+
const checkInId = Sentry.captureCheckIn({
6+
monitorSlug: "<monitor-slug>",
7+
status: "in_progress",
8+
});
9+
10+
// Execute your scheduled task here...
11+
12+
// 🟢 Notify Sentry your job has completed successfully:
13+
Sentry.captureCheckIn({
14+
checkInId,
15+
monitorSlug: "<monitor-slug>",
16+
status: "ok",
17+
});
18+
```
19+
20+
If your job execution fails, you can notify Sentry about the failure:
21+
22+
```javascript
23+
// 🔴 Notify Sentry your job has failed:
24+
Sentry.captureCheckIn({
25+
checkInId,
26+
monitorSlug: "<monitor-slug>",
27+
status: "error",
28+
});
29+
```
30+
31+
## Heartbeat
32+
33+
Heartbeat monitoring notifies Sentry of a job's status through one check-in. This setup will only notify you if your job didn't start when expected (missed). If you need to track a job to see if it exceeded its maximum runtime (failed), use check-ins instead.
34+
35+
```javascript
36+
// Execute your scheduled task...
37+
38+
// 🟢 Notify Sentry your job completed successfully:
39+
Sentry.captureCheckIn({
40+
monitorSlug: "<monitor-slug>",
41+
status: "ok",
42+
});
43+
```
44+
45+
If your job execution fails, you can:
46+
47+
```javascript
48+
// 🔴 Notify Sentry your job has failed:
49+
Sentry.captureCheckIn({
50+
monitorSlug: "<monitor-slug>",
51+
status: "error",
52+
});
53+
```
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
```javascript
2+
Sentry.configureScope(function (scope) {
3+
scope.setContext("monitor", {
4+
slug: "<monitor-slug>",
5+
});
6+
});
7+
```
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- Use our <PlatformLink to="/">getting started</PlatformLink> guide to install and configure the Sentry SDK (version `7.51.1` or newer) for your recurring job.
2+
- [Create and configure](https://sentry.io/crons/create/) your first Monitor.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
- Use our <PlatformLink to="/">getting started</PlatformLink> guide to install and configure the Sentry Node SDK (min v7.51.1) for your recurring job.
1+
- Use our <PlatformLink to="/">getting started</PlatformLink> guide to install and configure the Sentry SDK (version `7.51.1` or newer) for your recurring job.
22
- [Create and configure](https://sentry.io/crons/create/) your first Monitor.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
## Check-Ins (Recommended)
2+
3+
<Include name="javascript-crons-checkins.mdx" />
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## Automatic Check-Ins (Vercel Only)
2+
3+
If you are hosting your Next.js application on Vercel and you are using [Vercel's Cron Jobs feature](https://vercel.com/docs/cron-jobs), the Next.js SDK will automatically create Check-Ins for you.
4+
See <PlatformLink to="/manual-setup/#opt-out-of-auto-instrumentation-of-vercel-cron-jobs">Manual Setup</PlatformLink> if you want to opt out of this behaviour.
5+
6+
## Check-Ins
7+
8+
<Include name="javascript-crons-checkins.mdx" />
Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,3 @@
11
## Check-Ins (Recommended)
22

3-
Check-in monitoring allows you to track a job's progress by completing two check-ins: one at the start of your job and another at the end of your job. This two-step process allows Sentry to notify you if your job didn't start when expected (missed) or if it exceeded its maximum runtime (failed).
4-
5-
```javascript
6-
// 🟡 Notify Sentry your job is running:
7-
const checkInId = Sentry.captureCheckIn({
8-
monitorSlug: "<monitor-slug>",
9-
status: "in_progress",
10-
});
11-
12-
// Execute your scheduled task here...
13-
14-
// 🟢 Notify Sentry your job has completed successfully:
15-
Sentry.captureCheckIn({
16-
checkInId,
17-
monitorSlug: "<monitor-slug>",
18-
status: "ok",
19-
});
20-
```
21-
22-
If your job execution fails, you can notify Sentry about the failure:
23-
24-
```javascript
25-
// 🔴 Notify Sentry your job has failed:
26-
Sentry.captureCheckIn({
27-
checkInId,
28-
monitorSlug: "<monitor-slug>",
29-
status: "error",
30-
});
31-
```
32-
33-
## Heartbeat
34-
35-
Heartbeat monitoring notifies Sentry of a job's status through one check-in. This setup will only notify you if your job didn't start when expected (missed). If you need to track a job to see if it exceeded its maximum runtime (failed), use check-ins instead.
36-
37-
```javascript
38-
// Execute your scheduled task...
39-
40-
// 🟢 Notify Sentry your job completed successfully:
41-
Sentry.captureCheckIn({
42-
monitorSlug: "<monitor-slug>",
43-
status: "ok",
44-
});
45-
```
46-
47-
If your job execution fails, you can:
48-
49-
```javascript
50-
// 🔴 Notify Sentry your job has failed:
51-
Sentry.captureCheckIn({
52-
monitorSlug: "<monitor-slug>",
53-
status: "error",
54-
});
55-
```
3+
<Include name="javascript-crons-checkins.mdx" />
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### How Do I Send an Attachment With a Check-in (Such as a Log Output)?
2+
3+
Attachments aren't supported by the SDK yet. For now, you can use the [check-in attachments API](/product/crons/getting-started/http/#check-in-attachment-optional).
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
### How Do I Send an Attachment With a Check-in (Such as a Log Output)?
22

3-
Attachments aren't supported by our Node SDK yet. For now, you can use the [check-in attachments API](/product/crons/getting-started/http/#check-in-attachment-optional).
3+
Attachments aren't supported by the SDK yet. For now, you can use the [check-in attachments API](/product/crons/getting-started/http/#check-in-attachment-optional).

0 commit comments

Comments
 (0)