Skip to content

Commit ba92c07

Browse files
committed
Don't save impersonation queries to the history
1 parent d9e10c7 commit ba92c07

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.query/route.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ export const action = async ({ request, params }: ActionFunctionArgs) => {
265265
history: {
266266
source: "DASHBOARD",
267267
userId: user.id,
268+
skip: user.isImpersonating,
268269
},
269270
});
270271

apps/webapp/app/services/queryService.server.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ export type ExecuteQueryOptions<TOut extends z.ZodSchema> = Omit<
7474
source: CustomerQuerySource;
7575
/** User ID (optional, null for API calls) */
7676
userId?: string | null;
77+
/** Skip saving to history (e.g., when impersonating) */
78+
skip?: boolean;
7779
};
7880
/** Custom per-org concurrency limit (overrides default) */
7981
customOrgConcurrencyLimit?: number;
@@ -161,8 +163,8 @@ export async function executeQuery<TOut extends z.ZodSchema>(
161163
});
162164

163165
// If query succeeded and history options provided, save to history
164-
// Skip history for EXPLAIN queries (admin debugging, not billable)
165-
if (result[0] === null && history && !baseOptions.explain) {
166+
// Skip history for EXPLAIN queries (admin debugging) and when explicitly skipped (e.g., impersonating)
167+
if (result[0] === null && history && !history.skip && !baseOptions.explain) {
166168
const stats = result[1].stats;
167169
const byteSeconds = parseFloat(stats.byte_seconds) || 0;
168170
const costInCents = byteSeconds * env.CENTS_PER_QUERY_BYTE_SECOND;

0 commit comments

Comments
 (0)