Skip to content

Commit 55e63d1

Browse files
committed
Remove Vercel toolbar
1 parent 94c912f commit 55e63d1

File tree

6 files changed

+77
-697
lines changed

6 files changed

+77
-697
lines changed

AGENTS.md

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,32 @@
55
- `components/` reusable UI primitives (kebab-case files, PascalCase exports).
66
- `hooks/` shared stateful helpers (camelCase named exports).
77
- `lib/` domain utilities and caching (`lib/cache`); import via `@/...` aliases.
8+
- `lib/inngest/` Inngest client and functions for background jobs and scheduled section revalidation.
89
- `server/` backend integrations and tRPC routers; isolate DNS, RDAP/WHOIS, TLS, and header probing services.
9-
- `server/db/` Drizzle ORM schema, migrations, and repository layer for Postgres persistence.
10-
- `server/inngest/` Inngest functions for background jobs and scheduled section revalidation.
10+
- `server/routers/` tRPC router definitions (`_app.ts` and domain-specific routers).
11+
- `server/services/` service layer for domain data fetching (DNS, certificates, headers, hosting, registration, SEO, screenshot, favicon, etc.).
12+
- `lib/db/` Drizzle ORM schema, migrations, and repository layer for Postgres persistence.
1113
- `public/` static assets; Tailwind v4 tokens live in `app/globals.css`. Update `instrumentation-client.ts` when adding analytics.
14+
- `trpc/` tRPC client setup, query client, and error handling.
1215

1316
## Build, Test, and Development Commands
1417
- `pnpm dev` — start dev server at http://localhost:3000.
1518
- `pnpm build` — compile production bundle.
1619
- `pnpm start` — serve compiled output for smoke tests.
20+
- `pnpm docker:up` — start all Dockerized local services (Postgres, Redis, SRH, Inngest) and wait until ready.
21+
- `pnpm docker:down` — stop all Dockerized local services.
1722
- `pnpm lint` — run Biome lint + type-aware checks (`--write` to fix).
1823
- `pnpm format` — apply Biome formatting.
1924
- `pnpm typecheck` — run `tsc --noEmit` for stricter diagnostics.
20-
- `pnpm db:generate` — generate Drizzle migrations.
25+
- `pnpm test` — run Vitest in watch mode.
26+
- `pnpm test:run` — run Vitest once.
27+
- `pnpm test:ui` — open Vitest UI.
28+
- `pnpm test:coverage` — run tests with coverage report.
29+
- `pnpm db:generate` — generate Drizzle migrations from schema.
2130
- `pnpm db:push` — push the current schema to the database.
2231
- `pnpm db:migrate` — apply migrations to the database.
2332
- `pnpm db:studio` — open Drizzle Studio.
24-
- `pnpm db:seed:providers` — seed known provider rules.
33+
- `pnpm db:seed`run seed script (scripts/db/seed.ts).
2534
- Requires Node.js >= 22 (see `package.json` engines).
2635

2736
## Coding Style & Naming Conventions
@@ -37,24 +46,25 @@
3746
## Testing Guidelines
3847
- Use **Vitest** with React Testing Library; config in `vitest.config.ts`.
3948
- Global setup in `vitest.setup.ts`:
40-
- Mocks analytics clients/servers and `server-only`.
49+
- Mocks analytics clients/servers (`@/lib/analytics/server` and `@/lib/analytics/client`).
50+
- Mocks `server-only` module.
4151
- `unstable_cache` mocked as a no-op; caching behavior is not under test.
42-
- Database in tests: Drizzle client is not globally mocked. Replace `@/server/db/client` with a PGlite-backed instance when needed.
52+
- Database in tests: Drizzle client is not globally mocked. Replace `@/server/db/client` with a PGlite-backed instance when needed (`@/lib/db/pglite`).
4353
- Redis in tests: do NOT use globals. Mock per-suite with the in-memory adapter:
4454
- In `beforeAll`: `const { makeInMemoryRedis } = await import("@/lib/redis-mock"); const impl = makeInMemoryRedis(); vi.doMock("@/lib/redis", () => impl);`
4555
- In `beforeEach`/`afterEach`: `const { resetInMemoryRedis } = await import("@/lib/redis-mock"); resetInMemoryRedis();`
4656
- Seed/assert via the mocked client: `const { redis } = await import("@/lib/redis"); await redis.set(key, value);`
4757
- UI tests:
4858
- Do not add direct tests for `components/ui/*` (shadcn).
4959
- Mock Radix primitives (Accordion, Tooltip) when testing domain sections.
50-
- Mock TRPC/React Query for components like `Favicon` and `Screenshot`.
60+
- Mock tRPC/React Query for components like `Favicon` and `Screenshot`.
5161
- Server tests:
5262
- Prefer `vi.hoisted` for ESM module mocks (e.g., `node:tls`).
5363
- Use unique cache keys/domains; call `resetInMemoryRedis()` in `afterEach`.
5464
- Screenshot service (`server/services/screenshot.ts`) uses hoisted mocks for `puppeteer`/`puppeteer-core` and `@sparticuz/chromium`.
5565
- Vercel Blob storage: mock `@vercel/blob` (`put` and `del` functions). Set `BLOB_READ_WRITE_TOKEN` via `vi.stubEnv` in suites that touch uploads/deletes.
5666
- Browser APIs: Mock `URL.createObjectURL`/`revokeObjectURL` with `vi.fn()` in tests that need them.
57-
- Commands: `pnpm test`, `pnpm test:run`, `pnpm test:coverage`.
67+
- Commands: `pnpm test`, `pnpm test:run`, `pnpm test:ui`, `pnpm test:coverage`.
5868

5969
## Commit & Pull Request Guidelines
6070
- Commits: single-focus, imperative, sentence case (e.g., "Add RDAP caching layer").
@@ -66,15 +76,14 @@
6676
- Vercel Blob backs favicon/screenshot storage with automatic public URLs.
6777
- Screenshots (Puppeteer): prefer `puppeteer-core` + `@sparticuz/chromium` on Vercel.
6878
- Persist domain data in Postgres via Drizzle; use Redis for short-lived caching/locks. Apply retry backoff to respect provider limits.
69-
- Background revalidation runs via Inngest functions (scheduled and event-driven).
70-
- Review `server/trpc.ts` when extending procedures to ensure auth/context remain intact.
79+
- Background revalidation runs via Inngest functions (scheduled and event-driven) in `lib/inngest/functions/`.
80+
- Cron jobs trigger Inngest events via `app/api/cron/` endpoints secured with `CRON_SECRET`.
81+
- Review `trpc/init.ts` when extending procedures to ensure auth/context remain intact.
7182

72-
## Feature Flags
73-
- Uses **Vercel Flags SDK** with **Statsig** adapter via Edge Config for server-evaluated feature flags.
74-
- Flag definitions: `flags.ts` at project root exports flag declarations.
75-
- Flags API endpoint: `app/.well-known/vercel/flags/route.ts` for Vercel Toolbar integration.
76-
- Server-side evaluation: Use flags in server components or API routes via `await flagName()`.
77-
- Required env: `FLAGS_SECRET` (for encryption/overrides), `EDGE_CONFIG` (Vercel Edge Config URL).
78-
- Optional env: `STATSIG_CONSOLE_API_KEY` and `STATSIG_PROJECT_ID` for Flags Explorer metadata in Vercel Toolbar.
79-
- Statsig config structure: Dynamic configs return JSON objects (e.g., `{ domains: [...] }`); use adapter's mapping function to extract values.
80-
- Defensive validation: Always validate flag return values with `Array.isArray()` or similar checks before use to handle null/undefined/invalid types gracefully.
83+
## Analytics & Observability
84+
- Uses **PostHog** for analytics and error tracking with reverse proxy via `/_proxy/ingest/*`.
85+
- PostHog sourcemap uploads configured in `next.config.ts` with `@posthog/nextjs-config`.
86+
- OpenTelemetry integration via `@vercel/otel` in `instrumentation.ts`.
87+
- Client-side analytics captured via `posthog-js` and initialized in `instrumentation-client.ts`.
88+
- Server-side analytics captured via `posthog-node` in `lib/analytics/server.ts`.
89+
- Analytics mocked in tests via `vitest.setup.ts`.

README.md

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,17 @@
1818

1919
## 🛠️ Tech Stack
2020

21-
- **Next.js 15** (App Router) + **React 19** + **TypeScript**
21+
- **Next.js 16** (App Router) + **React 19** + **TypeScript**
2222
- **Tailwind CSS v4**
2323
- **tRPC** API
2424
- **Postgres** + **Drizzle ORM**
2525
- **Inngest** for background jobs and scheduled revalidation
2626
- **Upstash Redis** for caching, rate limits, and locks
2727
- **Vercel Blob** for favicon/screenshot storage
28-
- **Vercel Flags SDK** + **Statsig** for feature flags (via Edge Config)
2928
- [**rdapper**](https://github.com/jakejarvis/rdapper) for RDAP lookups with WHOIS fallback
3029
- **Puppeteer** (with `@sparticuz/chromium` on server) for screenshots
3130
- **Mapbox** for IP geolocation maps
32-
- **PostHog** analytics
31+
- **PostHog** analytics with sourcemap uploads
3332
- **Vitest** for testing and **Biome** for lint/format
3433

3534
---
@@ -46,27 +45,46 @@ pnpm install
4645

4746
### 2. Configure environment variables
4847

49-
Create `.env.local` (used by `pnpm dev`):
48+
Create `.env.local` (see `.env.example` for full details):
5049

5150
```env
51+
# --- PostHog Analytics ---
52+
NEXT_PUBLIC_POSTHOG_HOST=
53+
NEXT_PUBLIC_POSTHOG_KEY=
54+
POSTHOG_API_KEY=
55+
POSTHOG_ENV_ID=
56+
5257
# --- Database (local) ---
5358
# TCP URL used by Drizzle CLI & direct TCP usage
5459
DATABASE_URL=postgres://postgres:postgres@localhost:5432/main
5560
5661
# --- Redis (local via SRH) ---
57-
# SRH mimics Upstash REST locally; point your apps Upstash client here.
62+
# SRH mimics Upstash REST locally; point your app's Upstash client here.
5863
KV_REST_API_URL=http://localhost:8079
5964
KV_REST_API_TOKEN=dev-token
6065
6166
# --- Inngest Dev Server ---
6267
INNGEST_DEV=1
6368
INNGEST_BASE_URL=http://localhost:8288
64-
# If your Inngest handler lives at a custom route, set:
6569
INNGEST_SERVE_PATH=/api/inngest
70+
# Production: set INNGEST_EVENT_KEY and INNGEST_SIGNING_KEY
6671
6772
# --- Vercel Blob Storage ---
6873
# Obtain from Vercel dashboard or use test token locally
6974
BLOB_READ_WRITE_TOKEN=your-token-here
75+
# Production: set BLOB_SIGNING_SECRET for blob key hashing
76+
77+
# --- Vercel Cron ---
78+
# Required for authenticating scheduled tasks
79+
CRON_SECRET=
80+
81+
# --- Mapbox ---
82+
# Public token for react-map-gl
83+
NEXT_PUBLIC_MAPBOX_TOKEN=
84+
85+
# --- Optional ---
86+
# Override user agent sent with upstream requests
87+
EXTERNAL_USER_AGENT=
7088
```
7189

7290
### 3. Start local dev services (Docker)
@@ -102,7 +120,7 @@ pnpm docker:down
102120
```bash
103121
pnpm db:generate # generate SQL from schema
104122
pnpm db:migrate # apply migrations to local Postgres
105-
pnpm db:seed:providers # seed known providers in lib/providers/rules/
123+
pnpm db:seed # seed database (if needed)
106124
```
107125
108126
### 5. Start the Next.js dev server
@@ -123,15 +141,22 @@ Open [http://localhost:3000](http://localhost:3000)
123141
pnpm dev # start Next.js dev server
124142
pnpm docker:up # start Dockerized local services and wait until ready
125143
pnpm docker:down # stop all Dockerized local services (docker compose down)
144+
pnpm build # compile production bundle
145+
pnpm start # serve compiled output for smoke tests
126146
pnpm lint # Biome lint/format checks
147+
pnpm format # apply Biome formatting
127148
pnpm typecheck # tsc --noEmit
128-
pnpm test:run # Vitest
149+
pnpm test # Vitest (watch mode)
150+
pnpm test:run # Vitest (single run)
151+
pnpm test:ui # Vitest UI
152+
pnpm test:coverage # Vitest with coverage report
129153
130154
# Drizzle
131-
pnpm db:generate # generate SQL migrations from schema
132-
pnpm db:migrate # apply db migrations
133-
pnpm db:studio # open Drizzle Studio against your current env URL
134-
pnpm db:seed:providers
155+
pnpm db:generate # generate SQL migrations from schema
156+
pnpm db:push # push the current schema to the database
157+
pnpm db:migrate # apply migrations to the database
158+
pnpm db:studio # open Drizzle Studio
159+
pnpm db:seed # run seed script (scripts/db/seed.ts)
135160
```
136161
137162
---

app/layout.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Analytics } from "@vercel/analytics/next";
2-
import { VercelToolbar } from "@vercel/toolbar/next";
32
import { GeistMono } from "geist/font/mono";
43
import { GeistSans } from "geist/font/sans";
54
import type { Metadata } from "next";
@@ -47,7 +46,6 @@ export default function RootLayout({
4746
<Toaster />
4847
</Providers>
4948
<Analytics />
50-
{process.env.NODE_ENV === "development" && <VercelToolbar />}
5149
</body>
5250
</html>
5351
);

next.config.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { withPostHogConfig } from "@posthog/nextjs-config";
2-
import withVercelToolbar from "@vercel/toolbar/plugins/next";
32
import type { NextConfig } from "next";
43

54
const nextConfig: NextConfig = {
@@ -38,13 +37,11 @@ const nextConfig: NextConfig = {
3837
skipTrailingSlashRedirect: true,
3938
};
4039

41-
export default withVercelToolbar()(
42-
withPostHogConfig(nextConfig, {
43-
personalApiKey: process.env.POSTHOG_API_KEY as string,
44-
envId: process.env.POSTHOG_ENV_ID as string,
45-
host: process.env.NEXT_PUBLIC_POSTHOG_HOST || "https://us.i.posthog.com",
46-
sourcemaps: {
47-
enabled: true,
48-
},
49-
}),
50-
);
40+
export default withPostHogConfig(nextConfig, {
41+
personalApiKey: process.env.POSTHOG_API_KEY as string,
42+
envId: process.env.POSTHOG_ENV_ID as string,
43+
host: process.env.NEXT_PUBLIC_POSTHOG_HOST || "https://us.i.posthog.com",
44+
sourcemaps: {
45+
enabled: true,
46+
},
47+
});

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
"@vercel/blob": "^2.0.0",
4949
"@vercel/functions": "^3.1.4",
5050
"@vercel/otel": "^2.1.0",
51-
"@vercel/toolbar": "^0.1.41",
5251
"cheerio": "^1.1.2",
5352
"class-variance-authority": "^0.7.1",
5453
"clsx": "^2.1.1",

0 commit comments

Comments
 (0)