Skip to content

Use sanitizeFilepath when logging Sentry breadcrumbs - #95

Merged
dcalhoun merged 1 commit into
trunkfrom
fix/sanitize-userpath-breadcrumb
May 7, 2024
Merged

Use sanitizeFilepath when logging Sentry breadcrumbs#95
dcalhoun merged 1 commit into
trunkfrom
fix/sanitize-userpath-breadcrumb

Conversation

@derekblank

@derekblank derekblank commented May 7, 2024

Copy link
Copy Markdown
Contributor

Related to #78 and https://github.com/Automattic/dotcom-forge/issues/6701
While reviewing Sentry logs, I noted that there is an additional place where filepaths need to be redacted.

Proposed Changes

Adds to the behavior introduced in #78 that sanitizes userpaths in console.log statements. This pr adds the same sanitizeUserpath util to filepath values when logging Sentry breadcrumbs, too.

Testing Instructions

When running locally, log out the value of sanitizeUserpath when Sentry.addBreadcrumb is logged during user data loading:

if ( err instanceof SyntaxError ) {
Sentry.addBreadcrumb( {
data: {
fileContents: sanitizeUnstructuredData( asString ),
filePath: sanitizeUserpath( filePath ),
},
} );
}

The value of filepaths should appear as [REDACTED]. Example error session where console.log events are using sanitizeUserpath, and Sentry.addBreadcrumb events are not (marked "generic" in the event logs).

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?
@derekblank
derekblank requested review from a team and dcalhoun May 7, 2024 09:27
@derekblank derekblank self-assigned this May 7, 2024

@dcalhoun dcalhoun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logged values were now redacted in my testing. Thanks!

@dcalhoun
dcalhoun merged commit 3600d89 into trunk May 7, 2024
@dcalhoun
dcalhoun deleted the fix/sanitize-userpath-breadcrumb branch May 7, 2024 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants