You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(webapp): user-based sentry attribution, no middleware DB lookup
Pivot the sentry tenant attribution flow based on review feedback:
- `user.id` is now the real signed-in user cuid, so "Users Impacted"
counts distinct humans. Tenant context (org / project / env slugs,
IDs, env type) moves entirely to tags.
- The Express middleware no longer queries the database. It parses the
URL with a regex and sets an ALS scope with whatever subset of slugs
is present (`/orgs/:o`, `/orgs/:o/projects/:p`, or the full triple).
- `_app/route.tsx` enriches the scope with `userId` for any
authenticated dashboard request — reusing the existing `requireUser`
call. No new query.
- The env layout loader's existing `prisma.project.findFirst` gains two
extra columns in its select (`externalRef`, `organization.id`) and
enriches the scope with the IDs / env type after picking an env. Same
single query, no extra round-trip.
- API routes flow through `tenantContextFromAuthEnvironment`, which
pulls `userId` from `env.orgMember.userId` (already selected by
`authIncludeBase`) and stamps the full tenant set up-front.
Trade-off: errors that fire before the env layout loader's enrich on
env-scoped pages get slugs + `user.id` but no tenant IDs. Realistic
errors after async work get the full set. API requests without an
`orgMember` get tenant tags but no `user.id`.
Out of scope (deferred): background workers, schedule-engine, socket
handlers — those events still ship without tenant attribution.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
0 commit comments