Skip to content

Commit 978b4e5

Browse files
d-csclaude
andcommitted
fix(webapp): address sentry tenant attribution review
- Add SENTRY_DSN to env.server.ts schema and read it via env (not process.env) to match repo conventions. - Wrap multi-method API handlers in tenantContext.run too — they were missed in the initial pass and would have shipped without tenant tags. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 84c381b commit 978b4e5

3 files changed

Lines changed: 14 additions & 9 deletions

File tree

apps/webapp/app/entry.server.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ process.on("uncaughtException", (error, origin) => {
291291
singleton("RunEngineEventBusHandlers", registerRunEngineEventBusHandlers);
292292
singleton("SetupBatchQueueCallbacks", setupBatchQueueCallbacks);
293293

294-
if (process.env.SENTRY_DSN) {
294+
if (env.SENTRY_DSN) {
295295
Sentry.addEventProcessor(addTenantContextToEvent);
296296
}
297297

apps/webapp/app/env.server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ const EnvironmentSchema = z
134134
ELECTRIC_ORIGIN_SHARDS: z.string().optional(),
135135
APP_ENV: z.string().default(process.env.NODE_ENV),
136136
SERVICE_NAME: z.string().default("trigger.dev webapp"),
137+
SENTRY_DSN: z.string().optional(),
137138
POSTHOG_PROJECT_KEY: z.string().default("phc_LFH7kJiGhdIlnO22hTAKgHpaKhpM8gkzWAFvHmf5vfS"),
138139
TRIGGER_TELEMETRY_DISABLED: z.string().optional(),
139140
AUTH_GITHUB_CLIENT_ID: z.string().optional(),

apps/webapp/app/services/routeBuilders/apiBuilder.server.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,14 +1168,18 @@ export function createMultiMethodApiRoute<
11681168
}
11691169

11701170
// Dispatch to method handler
1171-
const result = await methodConfig.handler({
1172-
params: parsedParams,
1173-
searchParams: parsedSearchParams,
1174-
headers: parsedHeaders,
1175-
body: parsedBody,
1176-
authentication: authenticationResult,
1177-
request,
1178-
});
1171+
const result = await tenantContext.run(
1172+
tenantContextFromAuthEnvironment(authenticationResult.environment),
1173+
() =>
1174+
methodConfig.handler({
1175+
params: parsedParams,
1176+
searchParams: parsedSearchParams,
1177+
headers: parsedHeaders,
1178+
body: parsedBody,
1179+
authentication: authenticationResult,
1180+
request,
1181+
})
1182+
);
11791183
return await wrapResponse(request, result, corsStrategy !== "none");
11801184
} catch (error) {
11811185
try {

0 commit comments

Comments
 (0)