-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sentry): improve sentry config and add masking
- Loading branch information
1 parent
1384556
commit 8380498
Showing
8 changed files
with
65 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { addSentryBreadcrumb } from './addSentryBreadcrumb' | ||
export { masker } from './masker' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* Masker function to mask sensitive data from form related breadcrumbs. This assumes | ||
* that the object(s) have a field called value that needs to be masked. | ||
* @param value this is the value to be masked, can be an object or an array of | ||
* objects with a value field | ||
* @returns the masked object or array of objects | ||
*/ | ||
export const masker = ( | ||
value: Record<string, any> | Array<Record<string, any>> | ||
): any => { | ||
if (Array.isArray(value)) { | ||
return value.map(masker) | ||
} | ||
|
||
if (typeof value === 'object' && value !== null && value !== undefined) { | ||
return Object.fromEntries( | ||
Object.entries(value).map(([key, value]) => { | ||
if (key !== 'value') { | ||
return [key, value] | ||
} | ||
return [ | ||
key, | ||
typeof value === 'string' || typeof value === 'number' | ||
? '*'.repeat(value.toString().length) | ||
: masker(value), | ||
] | ||
}) | ||
) | ||
} | ||
|
||
return value | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters