Skip to content
Merged
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
4 changes: 4 additions & 0 deletions docs/staging-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ wrangler secret put EMAIL_FROM --name tuvix-api-staging --env staging
# When prompted, enter the full base URL of your staging app (e.g. https://staging.yourdomain.com)
wrangler secret put BASE_URL --name tuvix-api-staging --env staging

# Sentry DSN (required for backend error tracking and tracing)
# When prompted, enter your Sentry DSN from the tuvix-api project
wrangler secret put SENTRY_DSN --name tuvix-api-staging --env staging

# Sentry release (will be set automatically by deployment workflow)
# When prompted, enter the staging release identifier (if you choose to set this manually)
# wrangler secret put SENTRY_RELEASE --name tuvix-api-staging --env staging
Expand Down
59 changes: 52 additions & 7 deletions packages/api/src/hono/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,22 +175,67 @@ export function createHonoApp(config: HonoAppConfig) {
return c.json({ status: "ok", runtime: c.get("runtime") });
});

// Debug Sentry
// Debug Sentry - comprehensive diagnostics
app.get("/debug-sentry", (c) => {
const env = c.get("env");
const sentry = c.get("sentry");
const runtime = c.get("runtime");

const diagnostics = {
runtime,
sentryConfigured: !!env.SENTRY_DSN,
sentryDsnLength: env.SENTRY_DSN?.length || 0,
sentryDsnPrefix: env.SENTRY_DSN?.substring(0, 20) || "not set",
sentryExists: !!sentry,
sentryMethods: sentry
? Object.keys(sentry)
.filter(
(k) =>
typeof (sentry as Record<string, unknown>)[k] === "function"
)
.slice(0, 10)
: [],
environment: env.SENTRY_ENVIRONMENT || env.NODE_ENV || "unknown",
allEnvKeys: Object.keys(env).filter(
(k) => !k.includes("SECRET") && !k.includes("KEY")
),
};

if (!env.SENTRY_DSN) {
return c.json({ message: "Sentry not configured" });
return c.json({
status: "error",
message: "Sentry DSN not configured",
diagnostics,
});
}

const testError = new Error("Test Sentry error!");
const eventId = sentry.captureException(testError, {
tags: { test: "debug-sentry", runtime },
});
// Try to capture an exception
try {
const testError = new Error("Test Sentry error from debug endpoint!");
const eventId = sentry.captureException(testError, {
tags: { test: "debug-sentry", runtime },
});

return c.json({ error: "Test error", eventId, runtime }, 500);
return c.json(
{
status: "success",
message: "Test error and log sent to Sentry",
eventId,
diagnostics,
},
500
);
} catch (error) {
return c.json(
{
status: "error",
message: "Failed to send test error",
error: error instanceof Error ? error.message : String(error),
diagnostics,
},
500
);
}
});

// BetterAuth routes
Expand Down
Loading