diff --git a/apps/webapp/app/routes/api.v1.add.tsx b/apps/webapp/app/routes/api.v1.add.tsx index 481625fd..b8767c2a 100644 --- a/apps/webapp/app/routes/api.v1.add.tsx +++ b/apps/webapp/app/routes/api.v1.add.tsx @@ -2,6 +2,7 @@ import { json } from "@remix-run/node"; import { createHybridActionApiRoute } from "~/services/routeBuilders/apiBuilder.server"; import { addToQueue } from "~/lib/ingest.server"; +import { logger } from "~/services/logger.service"; import { IngestBodyRequest } from "~/trigger/ingest/ingest"; const { action, loader } = createHybridActionApiRoute( @@ -14,8 +15,26 @@ const { action, loader } = createHybridActionApiRoute( corsStrategy: "all", }, async ({ body, authentication }) => { - const response = await addToQueue(body, authentication.userId, authentication?.workspaceId as string); - return json({ success: true, id: response.id }); + try { + const response = await addToQueue( + body, + authentication.userId, + authentication?.workspaceId as string, + ); + return json({ success: true, id: response.id }); + } catch (error) { + logger.error("api.v1.add addToQueue failed", { + userId: authentication.userId, + workspaceId: authentication?.workspaceId, + source: (body as { source?: unknown })?.source, + episodeBodyKeys: body ? Object.keys(body as Record) : [], + error: + error instanceof Error + ? { name: error.name, message: error.message, stack: error.stack } + : String(error), + }); + throw error; + } }, ); diff --git a/apps/webapp/app/routes/auth.google.callback.tsx b/apps/webapp/app/routes/auth.google.callback.tsx index fc8f96d6..6d980750 100644 --- a/apps/webapp/app/routes/auth.google.callback.tsx +++ b/apps/webapp/app/routes/auth.google.callback.tsx @@ -15,23 +15,42 @@ export let loader: LoaderFunction = async ({ request }) => { redirectTo, }); - const authuser = await authenticator.authenticate("google", request); - const headers = await saveSession(request, authuser); + try { + const authuser = await authenticator.authenticate("google", request); + const headers = await saveSession(request, authuser); - logger.debug("auth.google.callback authuser", { - authuser, - }); + logger.debug("auth.google.callback authuser", { + authuser, + }); - const user = await getUserById(authuser.userId); - if (user && !user.onboardingComplete && !redirectTo.startsWith("/onboarding")) { - const onboardingUrl = - redirectTo && redirectTo !== "/" - ? `/onboarding?redirectTo=${encodeURIComponent(redirectTo)}` - : "/onboarding"; - return redirect(onboardingUrl, { headers }); - } + const user = await getUserById(authuser.userId); + if ( + user && + !user.onboardingComplete && + !redirectTo.startsWith("/onboarding") + ) { + const onboardingUrl = + redirectTo && redirectTo !== "/" + ? `/onboarding?redirectTo=${encodeURIComponent(redirectTo)}` + : "/onboarding"; + return redirect(onboardingUrl, { headers }); + } - return redirect(redirectTo, { - headers, - }); + return redirect(redirectTo, { + headers, + }); + } catch (error) { + const url = new URL(request.url); + logger.error("auth.google.callback failed", { + redirectTo, + hasCode: url.searchParams.has("code"), + hasState: url.searchParams.has("state"), + scope: url.searchParams.get("scope"), + error: + error instanceof Error + ? { name: error.name, message: error.message, stack: error.stack } + : String(error), + }); + throw error; + } }; diff --git a/apps/webapp/app/routes/settings.billing.tsx b/apps/webapp/app/routes/settings.billing.tsx index c287ec94..80f39c53 100644 --- a/apps/webapp/app/routes/settings.billing.tsx +++ b/apps/webapp/app/routes/settings.billing.tsx @@ -665,7 +665,7 @@ export default function BillingSettings() {