|
| 1 | +import * as child_process from 'child_process'; |
1 | 2 | import * as Sentry from '@sentry/node'; |
2 | 3 | import { IS_PROD_BUILD } from './util'; |
3 | 4 |
|
@@ -46,6 +47,25 @@ export function initErrorTracking() { |
46 | 47 | scope.setTag('platform', process.platform); |
47 | 48 | }); |
48 | 49 |
|
| 50 | + // Include breadcrumbs for subprocess spawning, to trace interceptor startup details: |
| 51 | + const rawSpawn = child_process.spawn; |
| 52 | + (child_process as any).spawn = function (command: any, args?: any, options?: { [key: string]: string }) { |
| 53 | + const sanitizedOptions = { ...options, |
| 54 | + env: Object.entries((options && options.env) || {}) |
| 55 | + .map(([key, value]) => { |
| 56 | + // Remove all actual env values from this reporting; only included our changed values. |
| 57 | + const realValue = process.env[key]; |
| 58 | + if (value === realValue) return undefined; |
| 59 | + else if (realValue) return [key, value.replace(realValue, '[...]')]; |
| 60 | + else return [key, value]; |
| 61 | + }) |
| 62 | + .filter((entry) => entry !== undefined) |
| 63 | + }; |
| 64 | + |
| 65 | + addBreadcrumb('Spawning process', { data: { command, args, options: sanitizedOptions } }); |
| 66 | + return rawSpawn.apply(this, arguments); |
| 67 | + }; |
| 68 | + |
49 | 69 | sentryInitialized = true; |
50 | 70 | } |
51 | 71 | } |
|
0 commit comments