Skip to content
New issue

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

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

Already on GitHub? # to your account

Action testing #11

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
7 changes: 7 additions & 0 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ jobs:
rm -rf /tmp/.buildx-cache
mv /tmp/.buildx-cache-new /tmp/.buildx-cache

- name: Set Sentry release
run: |
curl ${{secrets.SENTRY_RELEASES}} \
-X POST \
-H 'Content-Type: application/json' \
-d '{"version": "${{github.sha}}"}'

deployment:
needs: build
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/feature/actions'
Expand Down
5 changes: 3 additions & 2 deletions app/discord/gateway.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import Sentry from "~/helpers/sentry.server";

import onboardCommand, { handler as onboardHandler } from "~/commands/setup";
import reportCommand, { handler as reportHandler } from "~/commands/report";

Expand Down Expand Up @@ -44,6 +46,7 @@ export default function init() {
});

const errorHandler = (error: unknown) => {
Sentry.captureException(error);
if (error instanceof Error) {
console.log("ERROR", error.message);
} else if (typeof error === "string") {
Expand All @@ -52,6 +55,4 @@ export default function init() {
};

client.on("error", errorHandler);
process.on("uncaughtException", errorHandler);
process.on("unhandledRejection", errorHandler);
}
24 changes: 24 additions & 0 deletions app/helpers/sentry.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import * as Sentry from "@sentry/node";
// import * as Tracing from "@sentry/tracing";

console.log(process.env.SENTRY_INGEST);

Sentry.init({
dsn: process.env.SENTRY_INGEST,
environment: process.env.NODE_ENV,
integrations: [
// enable HTTP calls tracing
// new Sentry.Integrations.Http({ tracing: true }),
new Sentry.Integrations.OnUncaughtException(),
new Sentry.Integrations.OnUnhandledRejection(),
// enable Express.js middleware tracing
// new Tracing.Integrations.Express({ app }),
],

// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 0.2,
});

export default Sentry;
34 changes: 30 additions & 4 deletions app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,23 @@ import express from "express";
import { createRequestHandler } from "@remix-run/express";
import path from "path";
import * as build from "@remix-run/dev/server-build";

import Sentry from "~/helpers/sentry.server";
import discordBot from "~/discord/gateway";

const app = express();

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

app.get("/butts", (req, res) => {
res.send("butts");
});
/**
Route handlers and static hosting
*/

app.use(express.static(path.join(__dirname, "..", "public")));

// needs to handle all verbs (GET, POST, etc.)
app.all(
Expand All @@ -29,6 +37,24 @@ app.all(
}),
);

/** ERROR TRACKING
Must go after route handlers
*/
app.use(Sentry.Handlers.errorHandler());

/** Init app */
app.listen(process.env.PORT || "3000");

discordBot();

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

process.on("uncaughtException", errorHandler);
process.on("unhandledRejection", errorHandler);
Loading