From e82a0293606dc3da2993cd8f1f91f6b738d071ed Mon Sep 17 00:00:00 2001 From: "posthog[bot]" <206114724+posthog[bot]@users.noreply.github.com> Date: Sat, 22 Aug 2026 11:48:24 +0000 Subject: [PATCH] fix(oauth): stop reporting user consent denial as an exception A user who clicks "Deny" on the consent screen returns `access_denied`. The wizard already handles this outcome gracefully, but it also filed it as an error tracking exception. Record a plain analytics event for the cancellation instead, so the deliberate user choice no longer buries the real OAuth failures (invalid_grant, server_error, timeouts) in the same code path. Generated-By: PostHog Desktop Task-Id: 9fc73c23-d66b-4f33-b548-d8fe80ad91bb --- src/utils/oauth.ts | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/src/utils/oauth.ts b/src/utils/oauth.ts index 1f7f8ed75..0692ba993 100644 --- a/src/utils/oauth.ts +++ b/src/utils/oauth.ts @@ -622,16 +622,26 @@ export async function performOAuthFlow( ? 'timeout' : 'unknown'; - analytics.captureException(error, { - step: 'oauth_flow', - oauth_error_code: oauthErrorCode, - oauth_error_description: flowError?.description, - client_id: clientId, - requested_scopes: config.scopes.join(' '), - // Collapse OAuth callback failures of the same kind into one issue - // instead of fragmenting by each user's install path in the stack trace. - $exception_fingerprint: `wizard_oauth_${oauthErrorCode}`, - }); + if (accessDenied) { + // A user who clicks "Deny" made a deliberate choice, not an error. + // Record the cancellation as a plain event so we keep the rate + // without filing an exception for a normal outcome. + analytics.wizardCapture('oauth authorization cancelled', { + client_id: clientId, + requested_scopes: config.scopes.join(' '), + }); + } else { + analytics.captureException(error, { + step: 'oauth_flow', + oauth_error_code: oauthErrorCode, + oauth_error_description: flowError?.description, + client_id: clientId, + requested_scopes: config.scopes.join(' '), + // Collapse OAuth callback failures of the same kind into one issue + // instead of fragmenting by each user's install path in the stack trace. + $exception_fingerprint: `wizard_oauth_${oauthErrorCode}`, + }); + } await abort(); throw error;