File tree Expand file tree Collapse file tree 1 file changed +30
-1
lines changed
Expand file tree Collapse file tree 1 file changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -13,10 +13,39 @@ export function initErrorTracking() {
1313 }
1414
1515 if ( SENTRY_DSN ) {
16- Sentry . init ( { dsn : SENTRY_DSN , release : packageJson . version } ) ;
16+ Sentry . init ( {
17+ dsn : SENTRY_DSN ,
18+ release : packageJson . version ,
19+ beforeBreadcrumb ( breadcrumb , hint ) {
20+ if ( breadcrumb . category === 'http' ) {
21+ // Almost all HTTP requests sent by the server are actually forwarded HTTP from
22+ // the proxy, so could be very sensitive. We need to ensure errors don't leak data.
23+
24+ // Remove all but the host from the breadcrumb data. The host is fairly safe & often
25+ // useful for context, but the path & query could easily contain sensitive secrets.
26+ if ( breadcrumb . data && breadcrumb . data . url ) {
27+ const url = breadcrumb . data . url as string ;
28+ const hostIndex = url . indexOf ( '://' ) + 3 ;
29+ const pathIndex = url . indexOf ( '/' , hostIndex ) ;
30+ if ( pathIndex !== - 1 ) {
31+ breadcrumb . data . url = url . slice ( 0 , pathIndex ) ;
32+ }
33+ }
34+
35+ if ( hint ) {
36+ // Make sure we don't collect the full HTTP data in hints either.
37+ delete hint . request ;
38+ delete hint . response ;
39+ }
40+ }
41+ return breadcrumb ;
42+ }
43+ } ) ;
44+
1745 Sentry . configureScope ( ( scope ) => {
1846 scope . setTag ( 'platform' , process . platform ) ;
1947 } ) ;
48+
2049 sentryInitialized = true ;
2150 }
2251}
You can’t perform that action at this time.
0 commit comments