Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
feat(web,email-worker): add logging to OTP email sending and notifyWeb fallback
Gener49fd60e88d0d
diff --git a/src/email-worker/src/index.ts b/src/email-worker/src/index.tsindex 9b014f039..8c8b05870 100644--- a/src/email-worker/src/index.ts+++ b/src/email-worker/src/index.ts@@ -23,7 +23,8 @@ async function notifyWeb(env: EmailEnv, payload: Record<string, unknown>, traceIbody,})if (!res.ok) throw new Error(`WEB_SERVICE responded ${res.status}`)- } catch {+ } catch (err) {+ log.warn("WEB_SERVICE notify failed, falling back to DEV_WEB_URL", { err })await fetch(`${DEV_WEB_URL}/api/email/notify`, {method: "POST",headers,diff --git a/src/web/src/lib/auth.ts b/src/web/src/lib/auth.tsindex 4164de4ba..d5f922b44 100644--- a/src/web/src/lib/auth.ts+++ b/src/web/src/lib/auth.ts@@ -1,8 +1,10 @@import { betterAuth } from "better-auth"import { emailOTP } from "better-auth/plugins"+import { createLogger } from "@alook/shared"import { getOtpSubject, renderOtpEmail } from "./email-templates"const isProd = process.env.NODE_ENV === "production"+const log = createLogger({ service: "auth" })export function createAuth(env: Env) {return betterAuth({@@ -27,12 +29,19 @@ export function createAuth(env: Env) {? [emailOTP({async sendVerificationOTP({ email, otp, type }) {- await env.SEND_EMAIL.send({- from: "[email protected]",- to: email,- subject: getOtpSubject(type),- html: renderOtpEmail(otp, type),- })+ log.info("sending OTP email", { to: email, type })+ try {+ await env.SEND_EMAIL.send({+ from: "[email protected]",+ to: email,+ subject: getOtpSubject(type),+ html: renderOtpEmail(otp, type),+ })+ log.info("OTP email sent", { to: email, type })+ } catch (err) {+ log.error("OTP email failed", { to: email, type, err })+ throw err+ }},}),]