OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.
Review the current PR by running git diff main...HEAD and examining all changed files. For each category below, report PASS, WARN (minor issue, should fix), or FAIL (must fix before merge) with specific file:line references.
Security
- No SQL injection: ClickHouse and Prisma queries use parameterized inputs — no string interpolation into query bodies
- No raw SQL in Prisma unless absolutely necessary (use Prisma client methods)
- No secrets, tokens, or API keys hardcoded
- No
eval(),dangerouslySetInnerHTML, ortarget="_blank"withoutrel="noopener" - User input validated/sanitized at system boundaries (API entry points only)
Authorization & Data Access
- Every
protectedProceduregets theenforceAccessmiddleware (rpc/base.ts) for free — it reads the raw, top-levelprojectId/organizationIdand callsctx.services.auth, which isshared/access.ts's singlecreateAccessChecksladder, bound once centrally inauth.service.ts(M10-002) - All ClickHouse queries filter by
project_id— no cross-project data leaks - All Prisma queries scope to the authenticated user's org/project — no missing
organizationId/projectIdwhere clauses - No client-provided IDs trusted for authorization without server-side validation
- Note:
enforceAccessonly checksprojectId/organizationIdin input — secondary object ids (reportId, dashboardId, …) need an in-handler check (ADR-011)
Architecture: Service Layer
- Data fetching and mutation logic lives in
packages/core/src/modules/<name>/<name>.service.ts— not inline in tRPC routers or route handlers - tRPC routers should call service functions, not query ClickHouse/Prisma directly
- New job types are declared in the owning module's
<name>.jobs.tsand spread intopackages/core/src/jobs.registry.ts— not inline in app code. A cron schedule is the job's owncronfield (ADR-021), not a second registry
Architecture: Validation
- Zod schemas used by more than one module, or by
apps/start/an SDK, belong in the owning module's<name>.constants.ts(imports only zod, other constants, or types — ADR-008) — not defined locally in a router or component - All tRPC procedures use
.input(zodSchema)for input validation - Schemas used only within a single file can stay local
Code Quality
- No
console.log,debugger, oralertleft in - No
anytypes without a comment explaining why - Error handling is meaningful — no catch-and-rethrow without transformation
- No unused variables or imports
- No N+1 queries — batch with Prisma
findMany+ filter, or use ClickHouse aggregation
General Patterns
- No new barrel files (
index.tsthat re-exports everything from a folder) - No speculative abstractions — helpers/utilities only if used in 2+ places
- No backwards-compat shims for code that was simply removed
Clickhouse
- Queries should be optimized for very large datasets
- Static queries are raw SQL with ClickHouse-native
{name:Type}bound params - Dynamic composition (chart engine, filters, breakdowns) uses
@openpanel/db'ssqltagged template — never${}of a raw value, never hand-rolled string concatenation (ADR-013)
After the checklist, provide a short Summary section: overall risk level (low / medium / high), the most critical issues if any, and whether the PR is ready to merge.