Skip to content

Commit 6eba335

Browse files
committed
Use Sentry error and release tracking
1 parent 7da31ec commit 6eba335

File tree

6 files changed

+296
-1
lines changed

6 files changed

+296
-1
lines changed

.github/workflows/node.js.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,10 @@ jobs:
165165
--from-literal=DISCORD_SECRET=${{ secrets.DISCORD_SECRET }} \
166166
--from-literal=DISCORD_HASH=${{ secrets.DISCORD_HASH }}
167167
kubectl apply -k .
168+
169+
- name: Set Sentry release
170+
run: |
171+
curl ${{secrets.SENTRY_RELEASES}} \
172+
-X POST \
173+
-H 'Content-Type: application/json' \
174+
-d '{"version": ${{github.sha}}}'

app/discord/gateway.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import Sentry from "~/helpers/sentry";
2+
13
import onboardCommand, { handler as onboardHandler } from "~/commands/setup";
24
import reportCommand, { handler as reportHandler } from "~/commands/report";
35

@@ -44,6 +46,7 @@ export default function init() {
4446
});
4547

4648
const errorHandler = (error: unknown) => {
49+
Sentry.captureException(error);
4750
if (error instanceof Error) {
4851
console.log("ERROR", error.message);
4952
} else if (typeof error === "string") {

app/helpers/sentry.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import * as Sentry from "@sentry/node";
2+
// import * as Tracing from "@sentry/tracing";
3+
4+
Sentry.init({
5+
dsn: process.env.SENTRY_URL,
6+
integrations: [
7+
// enable HTTP calls tracing
8+
new Sentry.Integrations.Http({ tracing: true }),
9+
// enable Express.js middleware tracing
10+
// new Tracing.Integrations.Express({ app }),
11+
],
12+
13+
// Set tracesSampleRate to 1.0 to capture 100%
14+
// of transactions for performance monitoring.
15+
// We recommend adjusting this value in production
16+
tracesSampleRate: 1.0,
17+
});
18+
19+
export default Sentry;

app/index.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@ import express from "express";
22
import { createRequestHandler } from "@remix-run/express";
33
import path from "path";
44
import * as build from "@remix-run/dev/server-build";
5+
6+
import Sentry from "~/helpers/sentry";
57
import discordBot from "~/discord/gateway";
68

79
const app = express();
810

9-
app.use(express.static(path.join(__dirname, "..", "public")));
11+
// RequestHandler creates a separate execution context using domains, so that
12+
// every transaction/span/breadcrumb is attached to its own Hub instance
13+
app.use(Sentry.Handlers.requestHandler());
14+
// TracingHandler creates a trace for every incoming request
15+
// app.use(Sentry.Handlers.tracingHandler());
1016

1117
/**
1218
Route handlers and static hosting
@@ -31,6 +37,12 @@ app.all(
3137
}),
3238
);
3339

40+
/** ERROR TRACKING
41+
Must go after route handlers
42+
*/
43+
app.use(Sentry.Handlers.errorHandler());
44+
45+
/** Init app */
3446
app.listen(process.env.PORT || "3000");
3547

3648
discordBot();

package-lock.json

Lines changed: 252 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)