Skip to content

Commit 13e453f

Browse files
authored
Actually pass through Sentry env vars to production deployment (#178)
I had observed that no production events were being ingested into Sentry, which is definitely not correct. This should resolve it, and will log configuration details so we can inspect what's happening
1 parent b6baf91 commit 13e453f

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

.github/workflows/node.js.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ jobs:
141141
--from-literal=DISCORD_SECRET=${{ secrets.DISCORD_SECRET }} \
142142
--from-literal=DISCORD_HASH=${{ secrets.DISCORD_HASH }} \
143143
--from-literal=DISCORD_TEST_GUILD=${{ secrets.DISCORD_TEST_GUILD }} \
144+
--from-literal=SENTRY_INGEST=${{ secrets.SENTRY_INGEST }} \
145+
--from-literal=SENTRY_RELEASES=${{ secrets.SENTRY_RELEASES }} \
144146
--from-literal=DATABASE_URL=${{ secrets.DATABASE_URL }}
145147
kubectl apply -k .
146148

app/helpers/env.server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ export const discordSecret = getEnv("DISCORD_SECRET");
3434
export const applicationId = getEnv("DISCORD_APP_ID");
3535
export const discordToken = getEnv("DISCORD_HASH");
3636
export const testGuild = getEnv("DISCORD_TEST_GUILD");
37+
export const sentryIngest = getEnv("SENTRY_INGEST");
38+
export const sentryReleases = getEnv("SENTRY_RELEASES");
3739

3840
export const amplitudeKey = getEnv("AMPLITUDE_API_KEY", true);
3941

app/helpers/sentry.server.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import * as Sentry from "@sentry/node";
2-
import { isProd } from "#~/helpers/env.server";
2+
import { isProd, sentryIngest } from "#~/helpers/env.server";
33

4-
Sentry.init({
5-
dsn: process.env.SENTRY_INGEST,
6-
environment: process.env.NODE_ENV || "development",
4+
const sentryOptions = {
5+
dsn: sentryIngest,
6+
environment: isProd() ? "production" : "development",
77
integrations: [
88
new Sentry.Integrations.OnUncaughtException(),
99
new Sentry.Integrations.OnUnhandledRejection(),
@@ -14,6 +14,10 @@ Sentry.init({
1414
// We recommend adjusting this value in production
1515
tracesSampleRate: isProd() ? 0.2 : 1,
1616
sendDefaultPii: true,
17-
});
17+
};
18+
19+
console.log("Sentry initialized:", sentryOptions);
20+
21+
Sentry.init(sentryOptions);
1822

1923
export default Sentry;

app/models/session.server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
applicationId,
2323
discordSecret,
2424
sessionSecret,
25+
isProd,
2526
} from "#~/helpers/env.server";
2627

2728
export type Sessions = DB["sessions"];
@@ -57,7 +58,7 @@ const {
5758
path: "/",
5859
sameSite: "lax",
5960
secrets: [sessionSecret],
60-
secure: process.env.NODE_ENV === "production",
61+
secure: isProd(),
6162
},
6263
});
6364
export type CookieSession = Awaited<ReturnType<typeof getCookieSession>>;

0 commit comments

Comments
 (0)