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
23 changes: 21 additions & 2 deletions apps/webapp/app/routes/api.v1.add.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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<string, unknown>) : [],
error:
error instanceof Error
? { name: error.name, message: error.message, stack: error.stack }
: String(error),
});
throw error;
}
},
);

Expand Down
51 changes: 35 additions & 16 deletions apps/webapp/app/routes/auth.google.callback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};
2 changes: 1 addition & 1 deletion apps/webapp/app/routes/settings.billing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ export default function BillingSettings() {
</div>
<ul className="mb-6 space-y-2 text-sm">
<li className="flex items-start gap-2">
<span>Credits: 15k/mo</span>
<span>Credits: 10k/mo</span>
</li>
<li className="flex items-start gap-2">
<span>Top up any time · credits never expire</span>
Expand Down