-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(node): ANR fixes and additions (#9998)
This PR makes a few fixes and additions to the ANR feature. - Stops passing the `sdk` property with the event since `enhanceEventWithSdkInfo` results in duplicate integrations/packages being sent! - Allows the passings of `staticTags` to attach to ANR events - Required by Electron SDK to tag the source `process/origin/environment` - Could also be useful for other users - Optionally enable normalising of stack frame paths to the app root - Required for Electron - Soon required for Node with #9072 The path normalisation code (and tests) are from the Electron SDK and is well tested on all platforms. However, it will only be called when `appRootPath` is supplied. If/when we add path normalisation to Node, it will have a default which can be overridden. The Electron SDK will then wrap the Node Anr integration something like this: ```ts class Anr extends NodeAnr { public constructor(options: Partial<Options> = {}) { super({ ...options, staticTags: { 'event.environment': 'javascript', 'event.origin': 'electron', 'event.process': 'browser', ...options.tags, }, appRootPath: app.getAppPath(), }); } } ```
- Loading branch information
Showing
5 changed files
with
134 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { normalizeUrlToBase } from '../src/normalize'; | ||
|
||
describe('normalizeUrlToBase()', () => { | ||
it('Example app on Windows', () => { | ||
const base = 'c:/Users/Username/sentry-electron/example'; | ||
|
||
expect(normalizeUrlToBase('C:\\Users\\Username\\sentry-electron\\example\\renderer.js', base)).toEqual( | ||
'app:///renderer.js', | ||
); | ||
|
||
expect( | ||
normalizeUrlToBase('C:\\Users\\Username\\sentry-electron\\example\\sub-directory\\renderer.js', base), | ||
).toEqual('app:///sub-directory/renderer.js'); | ||
|
||
expect(normalizeUrlToBase('file:///C:/Users/Username/sentry-electron/example/index.html', base)).toEqual( | ||
'app:///index.html', | ||
); | ||
}); | ||
|
||
it('Example app with parentheses', () => { | ||
const base = 'c:/Users/Username/sentry-electron (beta)/example'; | ||
|
||
expect(normalizeUrlToBase('C:\\Users\\Username\\sentry-electron%20(beta)\\example\\renderer.js', base)).toEqual( | ||
'app:///renderer.js', | ||
); | ||
|
||
expect( | ||
normalizeUrlToBase('C:\\Users\\Username\\sentry-electron%20(beta)\\example\\sub-directory\\renderer.js', base), | ||
).toEqual('app:///sub-directory/renderer.js'); | ||
|
||
expect(normalizeUrlToBase('file:///C:/Users/Username/sentry-electron%20(beta)/example/index.html', base)).toEqual( | ||
'app:///index.html', | ||
); | ||
}); | ||
|
||
it('Asar packaged app in Windows Program Files', () => { | ||
const base = 'C:/Program Files/My App/resources/app.asar'; | ||
|
||
expect(normalizeUrlToBase('/C:/Program%20Files/My%20App/resources/app.asar/dist/bundle-app.js', base)).toEqual( | ||
'app:///dist/bundle-app.js', | ||
); | ||
|
||
expect(normalizeUrlToBase('file:///C:/Program%20Files/My%20App/resources/app.asar/index.html', base)).toEqual( | ||
'app:///index.html', | ||
); | ||
|
||
expect(normalizeUrlToBase('file:///C:/Program%20Files/My%20App/resources/app.asar/a/index.html', base)).toEqual( | ||
'app:///a/index.html', | ||
); | ||
}); | ||
|
||
it('Webpack builds', () => { | ||
const base = '/home/haza/Desktop/foo/app/'; | ||
expect( | ||
normalizeUrlToBase('/home/haza/Desktop/foo/app/webpack:/electron/src/common/models/ipc-request.ts', base), | ||
).toEqual('app:///electron/src/common/models/ipc-request.ts'); | ||
}); | ||
|
||
it('Only modifies file URLS', () => { | ||
const base = 'c:/Users/Username/sentry-electron/example'; | ||
expect(normalizeUrlToBase('https://some.host/index.html', base)).toEqual('https://some.host/index.html'); | ||
expect(normalizeUrlToBase('http://localhost:43288/index.html', base)).toEqual('http://localhost:43288/index.html'); | ||
}); | ||
}); |