Skip to content

Commit 4c36bc8

Browse files
committed
feat(sentry): clean up debugging code, add staging docs and enhanced diagnostics
1 parent d5597c8 commit 4c36bc8

3 files changed

Lines changed: 57 additions & 7 deletions

File tree

docs/staging-setup.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ wrangler secret put EMAIL_FROM --name tuvix-api-staging --env staging
8585
# When prompted, enter the full base URL of your staging app (e.g. https://staging.yourdomain.com)
8686
wrangler secret put BASE_URL --name tuvix-api-staging --env staging
8787

88+
# Sentry DSN (required for backend error tracking and tracing)
89+
# When prompted, enter your Sentry DSN from the tuvix-api project
90+
wrangler secret put SENTRY_DSN --name tuvix-api-staging --env staging
91+
8892
# Sentry release (will be set automatically by deployment workflow)
8993
# When prompted, enter the staging release identifier (if you choose to set this manually)
9094
# wrangler secret put SENTRY_RELEASE --name tuvix-api-staging --env staging

packages/api/src/hono/app.ts

Lines changed: 52 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,22 +175,67 @@ export function createHonoApp(config: HonoAppConfig) {
175175
return c.json({ status: "ok", runtime: c.get("runtime") });
176176
});
177177

178-
// Debug Sentry
178+
// Debug Sentry - comprehensive diagnostics
179179
app.get("/debug-sentry", (c) => {
180180
const env = c.get("env");
181181
const sentry = c.get("sentry");
182182
const runtime = c.get("runtime");
183183

184+
const diagnostics = {
185+
runtime,
186+
sentryConfigured: !!env.SENTRY_DSN,
187+
sentryDsnLength: env.SENTRY_DSN?.length || 0,
188+
sentryDsnPrefix: env.SENTRY_DSN?.substring(0, 20) || "not set",
189+
sentryExists: !!sentry,
190+
sentryMethods: sentry
191+
? Object.keys(sentry)
192+
.filter(
193+
(k) =>
194+
typeof (sentry as Record<string, unknown>)[k] === "function"
195+
)
196+
.slice(0, 10)
197+
: [],
198+
environment: env.SENTRY_ENVIRONMENT || env.NODE_ENV || "unknown",
199+
allEnvKeys: Object.keys(env).filter(
200+
(k) => !k.includes("SECRET") && !k.includes("KEY")
201+
),
202+
};
203+
184204
if (!env.SENTRY_DSN) {
185-
return c.json({ message: "Sentry not configured" });
205+
return c.json({
206+
status: "error",
207+
message: "Sentry DSN not configured",
208+
diagnostics,
209+
});
186210
}
187211

188-
const testError = new Error("Test Sentry error!");
189-
const eventId = sentry.captureException(testError, {
190-
tags: { test: "debug-sentry", runtime },
191-
});
212+
// Try to capture an exception
213+
try {
214+
const testError = new Error("Test Sentry error from debug endpoint!");
215+
const eventId = sentry.captureException(testError, {
216+
tags: { test: "debug-sentry", runtime },
217+
});
192218

193-
return c.json({ error: "Test error", eventId, runtime }, 500);
219+
return c.json(
220+
{
221+
status: "success",
222+
message: "Test error and log sent to Sentry",
223+
eventId,
224+
diagnostics,
225+
},
226+
500
227+
);
228+
} catch (error) {
229+
return c.json(
230+
{
231+
status: "error",
232+
message: "Failed to send test error",
233+
error: error instanceof Error ? error.message : String(error),
234+
diagnostics,
235+
},
236+
500
237+
);
238+
}
194239
});
195240

196241
// BetterAuth routes

packages/app/src/main.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ declare module "@tanstack/react-router" {
3636
// Initialize Sentry AFTER router is created (so we can include router integration)
3737
const dsn = import.meta.env.VITE_SENTRY_DSN;
3838
if (dsn && typeof dsn === "string" && dsn.trim().length > 0) {
39+
3940
const environment =
4041
import.meta.env.VITE_SENTRY_ENVIRONMENT ||
4142
import.meta.env.MODE ||

0 commit comments

Comments
 (0)