Skip to content

feat(academy): speed up the sample route, track it, and add the favicons - #353

Merged
pratyush618 merged 5 commits into
mainfrom
feat/orders-analytics-and-favicons
Sep 19, 2026
Merged

pratyush618 merged 5 commits into
mainfrom
feat/orders-analytics-and-favicons

Conversation

@pratyush618

Copy link
Copy Markdown
Contributor

A sample request came back in 12.19 seconds. Chasing that turned up three separate things, and the favicons went in alongside them.

Why the route was slow

The function was in the wrong hemisphere. apps/academy had no vercel.json, so its functions defaulted to iad1 while Postgres sits in ap-northeast-1. Every query crossed the Pacific, and a cold connection pays five round trips of it before the first row. The console already pins hnd1 for exactly this reason; academy now does too.

The response waited on an email nobody was waiting for. The receipt is sent after the work order, and its failure is logged rather than surfaced — the request is filed and will be delivered either way. So the answer never depended on it, only on a second round trip to Resend finishing first. It moves to after() from next/server, which runs once the response is gone.

That does not add up to twelve seconds on its own, so the rest is measured rather than guessed: submitOrder now logs what each step cost.

[samples] BVA-71DF7F filed — check 120ms, claim 95ms, notify 640ms

Why the logs were useless

console.error("...: %s", cause) on the error drizzle throws prints the query and then [cause]: [Error] — the wrapper, and a promise that the reason is somewhere underneath it. Two different incidents read identically through that hole: a missing table, and a certificate Node would not verify. describe() walks the chain and prints each message with its code.

Analytics

track() joins @byteveda/analytics/vercel, behind the same NEXT_PUBLIC_VERCEL_ENV guard as the sinks — off Vercel there is no endpoint to receive an event, and a local run or the e2e suite should not report a funnel nobody is watching. Deleting that one file is still the whole cost of leaving Vercel.

The sample page sends sample_requested and sample_failed, both with the kind and the duration. Timed in the browser on purpose: that is the wait somebody actually sat through, including their network and any cold start, none of which the function's own timing can see.

Favicons

The ByteVeda mark now covers main, docs, academy and admin as favicon.ico, icon.png and apple-icon.png. Academy and the console had no icon at all; main and docs had a placeholder book mark and no .ico. FlexiQ keeps its own mark — it is a distinct product and already had the full set.

Plain Next file conventions, no metadata.icons anywhere to wire up. Verified in the docs static export:

<link rel="icon" href="/favicon.ico?..." sizes="48x48" type="image/x-icon"/>
<link rel="icon" href="/icon.png?..." sizes="96x96" type="image/png"/>
<link rel="apple-touch-icon" href="/apple-icon.png?..." sizes="180x180" type="image/png"/>

Verification

pnpm typecheck across all ten packages, Biome clean on everything touched, 22 academy unit tests, 51 @byteveda/db tests, 26 academy Playwright tests, and a build of all five apps.

Still outstanding

Academy's DATABASE_URL in Vercel points at port 5432, the session-mode pooler: every connection is pinned for the life of the instance and poolMax drops from five to two. It wants 6543. That is an environment change, not a code one — the migrate step rewrites the port for itself, so migrations are unaffected either way.

Academy and the console had none at all. FlexiQ keeps its own mark.
Functions defaulted to iad1 while Postgres is in ap-northeast-1, so every query crossed the Pacific and a cold connection cost five round trips of it.
"could not reach the database" was printed for a certificate Node would not verify and for a table that did not exist. The wrapper drizzle throws hides both under [cause]: [Error].
The receipt's failure is logged rather than surfaced, so the answer never depended on it — only on a second round trip to Resend finishing first.
Timed in the browser, which is the wait somebody actually sat through: the function's own timing cannot see their network or a cold start.
@vercel

vercel Bot commented Sep 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
byteveda-site Ready Ready Preview Sep 19, 2026 4:49pm UTC
byteveda-site-academy-lycj Ready Ready Preview Sep 19, 2026 4:49pm UTC
byteveda-site-admin Ready Ready Preview Sep 19, 2026 4:49pm UTC
byteveda-site-flexiq Ready Ready Preview Sep 19, 2026 4:49pm UTC

@pratyush618
pratyush618 merged commit d1be485 into main Sep 19, 2026
16 checks passed
@pratyush618
pratyush618 deleted the feat/orders-analytics-and-favicons branch September 19, 2026 16:51

This branch was successfully deployed

4 active deployments
Preview – byteveda-site 9bcf7f1a Deployed Sep 19, 2026 by vercel[bot]
Preview – byteveda-site-admin 9bcf7f1a Deployed Sep 19, 2026 by vercel[bot]
Preview – byteveda-site-academy-lycj 9bcf7f1a Deployed Sep 19, 2026 by vercel[bot]
Preview – byteveda-site-flexiq 9bcf7f1a Deployed Sep 19, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants