refactor: centralize non-sensitive config into per-app modules#714
Conversation
Single source of truth for hosts + proxy path, consumed by the client init and the next.config rewrites (sources and destinations). No behavior change: rendered /ingest rewrites are byte-identical.
Add NEXT_PUBLIC_contractId as an optional field on the existing Zod env schema and route both reads through it. Optional (not required) so a missing value stays a graceful runtime 500, not a fail-at-boot throw.
Replace 13 inline LLM_MODEL fallback literals with DEFAULT_MODEL / DEFAULT_MODEL_STABLE. Keeps || so an empty LLM_MODEL still falls back; both defaults preserved, no example changes behavior.
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Code Review
This pull request centralizes configuration settings across multiple applications, specifically introducing a shared PostHog configuration in the docs app and default LLM model constants in the examples app. Additionally, it integrates the optional NEXT_PUBLIC_contractId environment variable into the validated env schema for the shade-agent starter template. The feedback highlights a potential runtime issue in ethAccount.ts where the optional contractId is used without a safety check, recommending a guard clause similar to the one implemented in transaction.ts.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Match transaction.ts: return a 500 'Contract ID not configured' when NEXT_PUBLIC_contractId is unset, instead of relying on the downstream try/catch. Addresses PR review feedback.
Closes #715
Summary
Centralizes scattered non-sensitive config into one source-of-truth module per app, with zero behavior change. Each module reads from
process.envonly where the env var is a documented user knob; otherwise it holds a plain constant.apps/docs/config/posthog.mjs(plain ESM, so both the client init andnext.config.mjscan import it).instrumentation-client.tsand the/ingestrewrites now both build from it, so the proxy path and hosts are defined once. Rendered rewrites verified byte-identical.NEXT_PUBLIC_contractIdadded to the existing Zodenv.tsasz.string().optional()and read viaenvin both routes. Optional (not required) deliberately preserves today's graceful runtime handling instead of failing at boot; route guards retained.apps/examples/src/config.tsexportingDEFAULT_MODEL/DEFAULT_MODEL_STABLE, replacing 13 inlineprocess.env.LLM_MODEL || "<literal>"fallbacks. Both defaults preserved;||kept (not??) so an emptyLLM_MODEL=still falls back.Sensitive keys/tokens are intentionally untouched — they are secrets, not config constants.
Test Plan
/ingestrewrites byte-identical to before (sources + destinations)instrumentation-client.tstype-checks (defaultskept as the posthog-jsConfigDefaultsliteral type)tsc --noEmitclean; contract-id reads route through validatedenvDEFAULT_MODEL, 4 →DEFAULT_MODEL_STABLE; all 13 imports resolve; no inline model literals remainbiome checkclean on all edited files@iqai/adksuite unaffected (554/554 pass)Out of scope (noted, not changed)
apps/docs/app/robots.ts/ingest/literal andshade-agent/src/index.tsPORTdefault not centralized (not part of this change's surface).