From a189b19b1f4b85509ff55c54589890924f138ce9 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Mon, 13 Feb 2023 18:27:59 +0000 Subject: [PATCH 01/11] feat: Put `abs_path` into stack frame object --- packages/browser/src/stack-parsers.ts | 4 +- .../test/unit/tracekit/chromium.test.ts | 367 +++++++++++-- .../test/unit/tracekit/firefox.test.ts | 346 ++++++++++-- .../browser/test/unit/tracekit/ie.test.ts | 74 ++- .../browser/test/unit/tracekit/misc.test.ts | 24 +- .../browser/test/unit/tracekit/opera.test.ts | 149 +++++- .../test/unit/tracekit/react-native.test.ts | 495 +++++++++++++++--- .../browser/test/unit/tracekit/react.test.ts | 36 +- .../browser/test/unit/tracekit/safari.test.ts | 219 ++++++-- 9 files changed, 1504 insertions(+), 210 deletions(-) diff --git a/packages/browser/src/stack-parsers.ts b/packages/browser/src/stack-parsers.ts index d77bf0d901a2..6419f3660e9d 100644 --- a/packages/browser/src/stack-parsers.ts +++ b/packages/browser/src/stack-parsers.ts @@ -13,9 +13,9 @@ const GECKO_PRIORITY = 50; function createFrame(filename: string, func: string, lineno?: number, colno?: number): StackFrame { const frame: StackFrame = { filename, + abs_path: filename, // As opposed to filename, abs_path is immutable (I can't control your actions but don't touch it!) function: func, - // All browser frames are considered in_app - in_app: true, + in_app: true, // All browser frames are considered in_app }; if (lineno !== undefined) { diff --git a/packages/browser/test/unit/tracekit/chromium.test.ts b/packages/browser/test/unit/tracekit/chromium.test.ts index b0df582ebeef..0d600cc28dd1 100644 --- a/packages/browser/test/unit/tracekit/chromium.test.ts +++ b/packages/browser/test/unit/tracekit/chromium.test.ts @@ -9,7 +9,7 @@ describe('Tracekit - Chrome Tests', () => { expect(ex).toEqual({ value: 'foo', type: 'bar', - stacktrace: { frames: [{ filename: 'native', function: 'Array.forEach', in_app: true }] }, + stacktrace: { frames: [{ filename: 'native', abs_path: 'native', function: 'Array.forEach', in_app: true }] }, }); }); @@ -33,10 +33,38 @@ describe('Tracekit - Chrome Tests', () => { type: 'foo', stacktrace: { frames: [ - { filename: 'http://path/to/file.js', function: '?', lineno: 24, colno: 4, in_app: true }, - { filename: 'http://path/to/file.js', function: 'foo', lineno: 20, colno: 5, in_app: true }, - { filename: 'http://path/to/file.js', function: 'bar', lineno: 16, colno: 5, in_app: true }, - { filename: 'http://path/to/file.js', function: 'bar', lineno: 13, colno: 17, in_app: true }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: '?', + lineno: 24, + colno: 4, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'foo', + lineno: 20, + colno: 5, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'bar', + lineno: 16, + colno: 5, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'bar', + lineno: 13, + colno: 17, + in_app: true, + }, ], }, }); @@ -62,6 +90,7 @@ describe('Tracekit - Chrome Tests', () => { frames: [ { filename: 'http://localhost:8080/file.js', + abs_path: 'http://localhost:8080/file.js', function: 'I.e.fn.(anonymous function) [as index]', lineno: 10, colno: 3651, @@ -69,6 +98,7 @@ describe('Tracekit - Chrome Tests', () => { }, { filename: 'http://localhost:8080/file.js', + abs_path: 'http://localhost:8080/file.js', function: 'HTMLButtonElement.onclick', lineno: 107, colno: 146, @@ -76,6 +106,7 @@ describe('Tracekit - Chrome Tests', () => { }, { filename: 'http://localhost:8080/file.js', + abs_path: 'http://localhost:8080/file.js', function: 'dumpExceptionError', lineno: 41, colno: 27, @@ -108,6 +139,7 @@ describe('Tracekit - Chrome Tests', () => { frames: [ { filename: 'webpack:///./~/react-proxy/modules/createPrototypeProxy.js?', + abs_path: 'webpack:///./~/react-proxy/modules/createPrototypeProxy.js?', function: 'TESTTESTTEST.proxiedMethod', lineno: 44, colno: 30, @@ -115,6 +147,7 @@ describe('Tracekit - Chrome Tests', () => { }, { filename: 'webpack:///./~/react-transform-catch-errors/lib/index.js?', + abs_path: 'webpack:///./~/react-transform-catch-errors/lib/index.js?', function: 'TESTTESTTEST.tryRender', lineno: 34, colno: 31, @@ -122,6 +155,7 @@ describe('Tracekit - Chrome Tests', () => { }, { filename: 'webpack:///./src/components/test/test.jsx?', + abs_path: 'webpack:///./src/components/test/test.jsx?', function: 'TESTTESTTEST.render', lineno: 272, colno: 32, @@ -129,6 +163,7 @@ describe('Tracekit - Chrome Tests', () => { }, { filename: 'webpack:///./src/components/test/test.jsx?', + abs_path: 'webpack:///./src/components/test/test.jsx?', function: 'TESTTESTTEST.eval', lineno: 295, colno: 108, @@ -159,11 +194,46 @@ describe('Tracekit - Chrome Tests', () => { type: 'Error', stacktrace: { frames: [ - { filename: 'http://localhost:8080/file.js', function: '?', lineno: 31, colno: 13, in_app: true }, - { filename: 'http://localhost:8080/file.js', function: 'Object.speak', lineno: 21, colno: 17, in_app: true }, - { filename: 'http://localhost:8080/file.js', function: 'eval', lineno: 21, colno: 17, in_app: true }, - { filename: 'http://localhost:8080/file.js', function: 'foo', lineno: 21, colno: 17, in_app: true }, - { filename: 'http://localhost:8080/file.js', function: 'baz', lineno: 21, colno: 17, in_app: true }, + { + filename: 'http://localhost:8080/file.js', + abs_path: 'http://localhost:8080/file.js', + function: '?', + lineno: 31, + colno: 13, + in_app: true, + }, + { + filename: 'http://localhost:8080/file.js', + abs_path: 'http://localhost:8080/file.js', + function: 'Object.speak', + lineno: 21, + colno: 17, + in_app: true, + }, + { + filename: 'http://localhost:8080/file.js', + abs_path: 'http://localhost:8080/file.js', + function: 'eval', + lineno: 21, + colno: 17, + in_app: true, + }, + { + filename: 'http://localhost:8080/file.js', + abs_path: 'http://localhost:8080/file.js', + function: 'foo', + lineno: 21, + colno: 17, + in_app: true, + }, + { + filename: 'http://localhost:8080/file.js', + abs_path: 'http://localhost:8080/file.js', + function: 'baz', + lineno: 21, + colno: 17, + in_app: true, + }, ], }, }); @@ -193,6 +263,7 @@ describe('Tracekit - Chrome Tests', () => { frames: [ { filename: 'blob:http%3A//localhost%3A8080/abfc40e9-4742-44ed-9dcd-af8f99a29379', + abs_path: 'blob:http%3A//localhost%3A8080/abfc40e9-4742-44ed-9dcd-af8f99a29379', function: 'n.handle', lineno: 7, colno: 2863, @@ -200,6 +271,7 @@ describe('Tracekit - Chrome Tests', () => { }, { filename: 'blob:http%3A//localhost%3A8080/abfc40e9-4742-44ed-9dcd-af8f99a29379', + abs_path: 'blob:http%3A//localhost%3A8080/abfc40e9-4742-44ed-9dcd-af8f99a29379', function: 'n.fire', lineno: 7, colno: 3019, @@ -207,6 +279,7 @@ describe('Tracekit - Chrome Tests', () => { }, { filename: 'blob:http%3A//localhost%3A8080/abfc40e9-4742-44ed-9dcd-af8f99a29379', + abs_path: 'blob:http%3A//localhost%3A8080/abfc40e9-4742-44ed-9dcd-af8f99a29379', function: '?', lineno: 1, colno: 6911, @@ -214,6 +287,7 @@ describe('Tracekit - Chrome Tests', () => { }, { filename: 'blob:http%3A//localhost%3A8080/d4eefe0f-361a-4682-b217-76587d9f712a', + abs_path: 'blob:http%3A//localhost%3A8080/d4eefe0f-361a-4682-b217-76587d9f712a', function: '?', lineno: 15, colno: 10978, @@ -221,6 +295,7 @@ describe('Tracekit - Chrome Tests', () => { }, { filename: 'blob:http%3A//localhost%3A8080/abfc40e9-4742-44ed-9dcd-af8f99a29379', + abs_path: 'blob:http%3A//localhost%3A8080/abfc40e9-4742-44ed-9dcd-af8f99a29379', function: 'Object.d [as add]', lineno: 31, colno: 30039, @@ -228,12 +303,13 @@ describe('Tracekit - Chrome Tests', () => { }, { filename: 'blob:http%3A//localhost%3A8080/abfc40e9-4742-44ed-9dcd-af8f99a29379', + abs_path: 'blob:http%3A//localhost%3A8080/abfc40e9-4742-44ed-9dcd-af8f99a29379', function: 's', lineno: 31, colno: 29146, in_app: true, }, - { filename: 'native', function: 'Error', in_app: true }, + { filename: 'native', abs_path: 'native', function: 'Error', in_app: true }, ], }, }); @@ -256,6 +332,7 @@ describe('Tracekit - Chrome Tests', () => { frames: [ { filename: 'examplescheme://examplehost/cd351f7250857e22ceaa.worker.js', + abs_path: 'examplescheme://examplehost/cd351f7250857e22ceaa.worker.js', function: '?', lineno: 70179, colno: 15, @@ -284,10 +361,31 @@ describe('Tracekit - Chrome Tests', () => { type: 'Error', stacktrace: { frames: [ - { filename: 'http://localhost:5000/test', function: '?', lineno: 24, colno: 7, in_app: true }, - { filename: 'http://localhost:5000/test', function: 'foo', lineno: 19, colno: 19, in_app: true }, - { filename: '', function: 'Array.map', in_app: true }, - { filename: 'http://localhost:5000/test', function: 'fooIterator', lineno: 20, colno: 17, in_app: true }, + { + filename: 'http://localhost:5000/test', + abs_path: 'http://localhost:5000/test', + function: '?', + lineno: 24, + colno: 7, + in_app: true, + }, + { + filename: 'http://localhost:5000/test', + abs_path: 'http://localhost:5000/test', + function: 'foo', + lineno: 19, + colno: 19, + in_app: true, + }, + { filename: '', abs_path: '', function: 'Array.map', in_app: true }, + { + filename: 'http://localhost:5000/test', + abs_path: 'http://localhost:5000/test', + function: 'fooIterator', + lineno: 20, + colno: 17, + in_app: true, + }, ], }, }); @@ -317,16 +415,79 @@ describe('Tracekit - Chrome Tests', () => { type: 'Error', stacktrace: { frames: [ - { filename: 'http://localhost:5000/', function: '?', lineno: 50, colno: 19, in_app: true }, - { filename: 'http://localhost:5000/', function: 'Foo.testMethod', lineno: 44, colno: 7, in_app: true }, - { filename: 'http://localhost:5000/', function: 'aha', lineno: 39, colno: 5, in_app: true }, - { filename: 'http://localhost:5000/', function: 'eval', lineno: 37, colno: 5, in_app: true }, - { filename: 'http://localhost:5000/', function: 'test', lineno: 33, colno: 23, in_app: true }, - { filename: '', function: 'Array.map', in_app: true }, - { filename: 'http://localhost:5000/', function: '?', lineno: 34, colno: 17, in_app: true }, - { filename: 'http://localhost:5000/', function: 'Object.callback', lineno: 25, colno: 7, in_app: true }, - { filename: 'http://localhost:5000/', function: 'callAnotherThing', lineno: 20, colno: 16, in_app: true }, - { filename: 'http://localhost:5000/', function: 'Object.aha', lineno: 19, colno: 13, in_app: true }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: '?', + lineno: 50, + colno: 19, + in_app: true, + }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'Foo.testMethod', + lineno: 44, + colno: 7, + in_app: true, + }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'aha', + lineno: 39, + colno: 5, + in_app: true, + }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'eval', + lineno: 37, + colno: 5, + in_app: true, + }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'test', + lineno: 33, + colno: 23, + in_app: true, + }, + { filename: '', abs_path: '', function: 'Array.map', in_app: true }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: '?', + lineno: 34, + colno: 17, + in_app: true, + }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'Object.callback', + lineno: 25, + colno: 7, + in_app: true, + }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'callAnotherThing', + lineno: 20, + colno: 16, + in_app: true, + }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'Object.aha', + lineno: 19, + colno: 13, + in_app: true, + }, ], }, }); @@ -349,9 +510,30 @@ describe('Tracekit - Chrome Tests', () => { type: 'Error', stacktrace: { frames: [ - { filename: 'http://localhost:5000/', function: 'test', lineno: 33, colno: 23, in_app: true }, - { filename: 'http://localhost:5000/', function: 'Object.callback', lineno: 25, colno: 7, in_app: true }, - { filename: 'http://localhost:5000/', function: 'callAnotherThing', lineno: 20, colno: 16, in_app: true }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'test', + lineno: 33, + colno: 23, + in_app: true, + }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'Object.callback', + lineno: 25, + colno: 7, + in_app: true, + }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'callAnotherThing', + lineno: 20, + colno: 16, + in_app: true, + }, ], }, }); @@ -375,10 +557,31 @@ describe('Tracekit - Chrome Tests', () => { type: 'Error', stacktrace: { frames: [ - { filename: 'http://localhost:5000/test', function: 'Global code', lineno: 24, colno: 7, in_app: true }, - { filename: 'http://localhost:5000/test', function: 'foo', lineno: 19, colno: 9, in_app: true }, - { filename: 'native code', function: 'Array.prototype.map', in_app: true }, - { filename: 'http://localhost:5000/test', function: 'fooIterator', lineno: 20, colno: 11, in_app: true }, + { + filename: 'http://localhost:5000/test', + abs_path: 'http://localhost:5000/test', + function: 'Global code', + lineno: 24, + colno: 7, + in_app: true, + }, + { + filename: 'http://localhost:5000/test', + abs_path: 'http://localhost:5000/test', + function: 'foo', + lineno: 19, + colno: 9, + in_app: true, + }, + { filename: 'native code', abs_path: 'native code', function: 'Array.prototype.map', in_app: true }, + { + filename: 'http://localhost:5000/test', + abs_path: 'http://localhost:5000/test', + function: 'fooIterator', + lineno: 20, + colno: 11, + in_app: true, + }, ], }, }); @@ -408,22 +611,72 @@ describe('Tracekit - Chrome Tests', () => { type: 'Error', stacktrace: { frames: [ - { filename: 'http://localhost:5000/', function: 'Anonymous function', lineno: 50, colno: 8, in_app: true }, { filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'Anonymous function', + lineno: 50, + colno: 8, + in_app: true, + }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', function: 'Foo.prototype.testMethod', lineno: 44, colno: 7, in_app: true, }, - { filename: 'http://localhost:5000/', function: 'aha', lineno: 39, colno: 5, in_app: true }, - { filename: 'eval code', function: 'eval code', lineno: 1, colno: 1, in_app: true }, - { filename: 'http://localhost:5000/', function: 'test', lineno: 33, colno: 5, in_app: true }, - { filename: 'native code', function: 'Array.prototype.map', in_app: true }, - { filename: 'http://localhost:5000/', function: 'Anonymous function', lineno: 34, colno: 7, in_app: true }, - { filename: 'http://localhost:5000/', function: 'callback', lineno: 25, colno: 7, in_app: true }, - { filename: 'http://localhost:5000/', function: 'callAnotherThing', lineno: 18, colno: 6, in_app: true }, - { filename: 'http://localhost:5000/', function: 'aha', lineno: 19, colno: 7, in_app: true }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'aha', + lineno: 39, + colno: 5, + in_app: true, + }, + { filename: 'eval code', abs_path: 'eval code', function: 'eval code', lineno: 1, colno: 1, in_app: true }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'test', + lineno: 33, + colno: 5, + in_app: true, + }, + { filename: 'native code', abs_path: 'native code', function: 'Array.prototype.map', in_app: true }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'Anonymous function', + lineno: 34, + colno: 7, + in_app: true, + }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'callback', + lineno: 25, + colno: 7, + in_app: true, + }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'callAnotherThing', + lineno: 18, + colno: 6, + in_app: true, + }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'aha', + lineno: 19, + colno: 7, + in_app: true, + }, ], }, }); @@ -446,6 +699,7 @@ describe('Tracekit - Chrome Tests', () => { frames: [ { filename: 'C:\\Users\\user\\path\\to\\file.js', + abs_path: 'C:\\Users\\user\\path\\to\\file.js', function: 'TESTTESTTEST.someMethod', lineno: 295, colno: 108, @@ -478,6 +732,7 @@ describe('Tracekit - Chrome Tests', () => { frames: [ { filename: 'react-dom.development.js?f8c1', + abs_path: 'react-dom.development.js?f8c1', function: 'commitLayoutEffects', in_app: true, lineno: 23426, @@ -485,6 +740,7 @@ describe('Tracekit - Chrome Tests', () => { }, { filename: 'react-dom.development.js?f8c1', + abs_path: 'react-dom.development.js?f8c1', function: 'commitLifeCycles', in_app: true, lineno: 20663, @@ -492,6 +748,7 @@ describe('Tracekit - Chrome Tests', () => { }, { filename: 'genericDiscoverQuery.tsx?33f8', + abs_path: 'genericDiscoverQuery.tsx?33f8', function: '_GenericDiscoverQuery.componentDidMount', in_app: true, lineno: 152, @@ -499,6 +756,7 @@ describe('Tracekit - Chrome Tests', () => { }, { filename: 'genericDiscoverQuery.tsx?33f8', + abs_path: 'genericDiscoverQuery.tsx?33f8', function: '_GenericDiscoverQuery.eval [as fetchData]', in_app: true, lineno: 256, @@ -506,6 +764,7 @@ describe('Tracekit - Chrome Tests', () => { }, { filename: 'genericDiscoverQuery.tsx?33f8', + abs_path: 'genericDiscoverQuery.tsx?33f8', function: 'doDiscoverQuery', in_app: true, lineno: 328, @@ -513,6 +772,7 @@ describe('Tracekit - Chrome Tests', () => { }, { filename: 'api.tsx', + abs_path: 'api.tsx', function: 'Client.requestPromise', in_app: true, lineno: 554, @@ -542,9 +802,10 @@ describe('Tracekit - Chrome Tests', () => { type: 'ChunkLoadError', stacktrace: { frames: [ - { filename: '', function: 'Array.reduce', in_app: true }, + { filename: '', abs_path: '', function: 'Array.reduce', in_app: true }, { filename: 'webpack/runtime/ensure chunk', + abs_path: 'webpack/runtime/ensure chunk', function: '?', in_app: true, lineno: 6, @@ -552,6 +813,7 @@ describe('Tracekit - Chrome Tests', () => { }, { filename: 'webpack/runtime/jsonp chunk loading', + abs_path: 'webpack/runtime/jsonp chunk loading', function: 'key', in_app: true, lineno: 27, @@ -559,12 +821,15 @@ describe('Tracekit - Chrome Tests', () => { }, { filename: '/_static/dist/sentry/chunks/app_bootstrap_initializeLocale_tsx.abcdefg.js', + abs_path: '/_static/dist/sentry/chunks/app_bootstrap_initializeLocale_tsx.abcdefg.js', function: '?', in_app: true, }, { filename: 'https://s1.sentry-cdn.com/_static/dist/sentry/chunks/app_bootstrap_initializeLocale_tsx.abcdefg.js', + abs_path: + 'https://s1.sentry-cdn.com/_static/dist/sentry/chunks/app_bootstrap_initializeLocale_tsx.abcdefg.js', function: '?', in_app: true, }, @@ -592,8 +857,22 @@ describe('Tracekit - Chrome Tests', () => { type: 'Error', stacktrace: { frames: [ - { filename: 'http://localhost:5000/', function: '?', lineno: 50, colno: 19, in_app: true }, - { filename: 'http://localhost:5000/', function: 'aha', lineno: 39, colno: 5, in_app: true }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: '?', + lineno: 50, + colno: 19, + in_app: true, + }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'aha', + lineno: 39, + colno: 5, + in_app: true, + }, ], }, }); diff --git a/packages/browser/test/unit/tracekit/firefox.test.ts b/packages/browser/test/unit/tracekit/firefox.test.ts index f75dd7ccf010..ee21f4644648 100644 --- a/packages/browser/test/unit/tracekit/firefox.test.ts +++ b/packages/browser/test/unit/tracekit/firefox.test.ts @@ -26,13 +26,55 @@ describe('Tracekit - Firefox Tests', () => { type: 'TypeError', stacktrace: { frames: [ - { filename: 'http://127.0.0.1:8000/js/file.js', function: '?', lineno: 24, in_app: true }, - { filename: 'http://127.0.0.1:8000/js/file.js', function: 'foo', lineno: 20, in_app: true }, - { filename: 'http://127.0.0.1:8000/js/file.js', function: 'bar', lineno: 16, in_app: true }, - { filename: 'http://127.0.0.1:8000/js/file.js', function: 'bar', lineno: 13, in_app: true }, - { filename: 'http://127.0.0.1:8000/js/stacktrace.js', function: 'printStackTrace', lineno: 18, in_app: true }, - { filename: 'http://127.0.0.1:8000/js/stacktrace.js', function: '?', lineno: 31, in_app: true }, - { filename: 'http://127.0.0.1:8000/js/stacktrace.js', function: '?', lineno: 44, in_app: true }, + { + filename: 'http://127.0.0.1:8000/js/file.js', + abs_path: 'http://127.0.0.1:8000/js/file.js', + function: '?', + lineno: 24, + in_app: true, + }, + { + filename: 'http://127.0.0.1:8000/js/file.js', + abs_path: 'http://127.0.0.1:8000/js/file.js', + function: 'foo', + lineno: 20, + in_app: true, + }, + { + filename: 'http://127.0.0.1:8000/js/file.js', + abs_path: 'http://127.0.0.1:8000/js/file.js', + function: 'bar', + lineno: 16, + in_app: true, + }, + { + filename: 'http://127.0.0.1:8000/js/file.js', + abs_path: 'http://127.0.0.1:8000/js/file.js', + function: 'bar', + lineno: 13, + in_app: true, + }, + { + filename: 'http://127.0.0.1:8000/js/stacktrace.js', + abs_path: 'http://127.0.0.1:8000/js/stacktrace.js', + function: 'printStackTrace', + lineno: 18, + in_app: true, + }, + { + filename: 'http://127.0.0.1:8000/js/stacktrace.js', + abs_path: 'http://127.0.0.1:8000/js/stacktrace.js', + function: '?', + lineno: 31, + in_app: true, + }, + { + filename: 'http://127.0.0.1:8000/js/stacktrace.js', + abs_path: 'http://127.0.0.1:8000/js/stacktrace.js', + function: '?', + lineno: 44, + in_app: true, + }, ], }, }); @@ -62,13 +104,55 @@ describe('Tracekit - Firefox Tests', () => { type: 'foo', stacktrace: { frames: [ - { filename: 'file:///G:/js/file.js', function: '?', lineno: 24, in_app: true }, - { filename: 'file:///G:/js/file.js', function: 'foo', lineno: 20, in_app: true }, - { filename: 'file:///G:/js/file.js', function: 'bar', lineno: 16, in_app: true }, - { filename: 'file:///G:/js/file.js', function: 'bar', lineno: 13, in_app: true }, - { filename: 'file:///G:/js/stacktrace.js', function: 'printStackTrace', lineno: 18, in_app: true }, - { filename: 'file:///G:/js/stacktrace.js', function: '?', lineno: 31, in_app: true }, - { filename: 'file:///G:/js/stacktrace.js', function: '?', lineno: 44, in_app: true }, + { + filename: 'file:///G:/js/file.js', + abs_path: 'file:///G:/js/file.js', + function: '?', + lineno: 24, + in_app: true, + }, + { + filename: 'file:///G:/js/file.js', + abs_path: 'file:///G:/js/file.js', + function: 'foo', + lineno: 20, + in_app: true, + }, + { + filename: 'file:///G:/js/file.js', + abs_path: 'file:///G:/js/file.js', + function: 'bar', + lineno: 16, + in_app: true, + }, + { + filename: 'file:///G:/js/file.js', + abs_path: 'file:///G:/js/file.js', + function: 'bar', + lineno: 13, + in_app: true, + }, + { + filename: 'file:///G:/js/stacktrace.js', + abs_path: 'file:///G:/js/stacktrace.js', + function: 'printStackTrace', + lineno: 18, + in_app: true, + }, + { + filename: 'file:///G:/js/stacktrace.js', + abs_path: 'file:///G:/js/stacktrace.js', + function: '?', + lineno: 31, + in_app: true, + }, + { + filename: 'file:///G:/js/stacktrace.js', + abs_path: 'file:///G:/js/stacktrace.js', + function: '?', + lineno: 44, + in_app: true, + }, ], }, }); @@ -94,9 +178,27 @@ describe('Tracekit - Firefox Tests', () => { type: 'foo', stacktrace: { frames: [ - { filename: 'http://path/to/file.js', function: 'onclick', lineno: 1, in_app: true }, - { filename: 'http://path/to/file.js', function: 'dumpException3', lineno: 52, in_app: true }, - { filename: 'http://path/to/file.js', function: '?', lineno: 48, in_app: true }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'onclick', + lineno: 1, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'dumpException3', + lineno: 52, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: '?', + lineno: 48, + in_app: true, + }, ], }, }); @@ -123,9 +225,30 @@ describe('Tracekit - Firefox Tests', () => { type: 'Error', stacktrace: { frames: [ - { filename: 'http://path/to/file.js', function: '.plugin/e.fn[c]/<', lineno: 1, colno: 1, in_app: true }, - { filename: 'http://path/to/file.js', function: 'bar', lineno: 1, colno: 1, in_app: true }, - { filename: 'http://path/to/file.js', function: 'foo', lineno: 41, colno: 13, in_app: true }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: '.plugin/e.fn[c]/<', + lineno: 1, + colno: 1, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'bar', + lineno: 1, + colno: 1, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'foo', + lineno: 41, + colno: 13, + in_app: true, + }, ], }, }); @@ -158,11 +281,33 @@ describe('Tracekit - Firefox Tests', () => { type: 'NS_ERROR_FAILURE', stacktrace: { frames: [ - { filename: 'file:///path/to/index.html', function: '?', lineno: 23, colno: 1, in_app: true }, - { filename: 'file:///path/to/file.js', function: 'bar', lineno: 20, colno: 3, in_app: true }, - { filename: 'file:///path/to/file.js', function: 'App.prototype.foo', lineno: 15, colno: 2, in_app: true }, + { + filename: 'file:///path/to/index.html', + abs_path: 'file:///path/to/index.html', + function: '?', + lineno: 23, + colno: 1, + in_app: true, + }, + { + filename: 'file:///path/to/file.js', + abs_path: 'file:///path/to/file.js', + function: 'bar', + lineno: 20, + colno: 3, + in_app: true, + }, + { + filename: 'file:///path/to/file.js', + abs_path: 'file:///path/to/file.js', + function: 'App.prototype.foo', + lineno: 15, + colno: 2, + in_app: true, + }, { filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', function: '[2] { frames: [ { filename: 'resource://path/data/content/bundle.js', + abs_path: 'resource://path/data/content/bundle.js', function: 'wrapped', lineno: 7270, colno: 25, @@ -202,6 +348,7 @@ describe('Tracekit - Firefox Tests', () => { }, { filename: 'resource://path/data/content/vendor.bundle.js', + abs_path: 'resource://path/data/content/vendor.bundle.js', function: 'dispatchEvent', lineno: 18, colno: 23028, @@ -209,6 +356,7 @@ describe('Tracekit - Firefox Tests', () => { }, { filename: 'resource://path/data/content/bundle.js', + abs_path: 'resource://path/data/content/bundle.js', function: 'render', lineno: 5529, colno: 16, @@ -241,11 +389,43 @@ describe('Tracekit - Firefox Tests', () => { type: 'foo', stacktrace: { frames: [ - { filename: 'http://localhost:8080/file.js', function: '?', lineno: 33, colno: 9, in_app: true }, - { filename: 'http://localhost:8080/file.js', function: 'speak', lineno: 26, colno: 17, in_app: true }, - { filename: 'http://localhost:8080/file.js', function: 'eval', lineno: 26, in_app: true }, - { filename: 'http://localhost:8080/file.js', function: 'foo', lineno: 26, in_app: true }, - { filename: 'http://localhost:8080/file.js', function: 'baz', lineno: 26, in_app: true }, + { + filename: 'http://localhost:8080/file.js', + abs_path: 'http://localhost:8080/file.js', + function: '?', + lineno: 33, + colno: 9, + in_app: true, + }, + { + filename: 'http://localhost:8080/file.js', + abs_path: 'http://localhost:8080/file.js', + function: 'speak', + lineno: 26, + colno: 17, + in_app: true, + }, + { + filename: 'http://localhost:8080/file.js', + abs_path: 'http://localhost:8080/file.js', + function: 'eval', + lineno: 26, + in_app: true, + }, + { + filename: 'http://localhost:8080/file.js', + abs_path: 'http://localhost:8080/file.js', + function: 'foo', + lineno: 26, + in_app: true, + }, + { + filename: 'http://localhost:8080/file.js', + abs_path: 'http://localhost:8080/file.js', + function: 'baz', + lineno: 26, + in_app: true, + }, ], }, }); @@ -267,9 +447,30 @@ describe('Tracekit - Firefox Tests', () => { type: 'Error', stacktrace: { frames: [ - { filename: 'http://localhost:5000/test', function: '?', lineno: 24, colno: 7, in_app: true }, - { filename: 'http://localhost:5000/test', function: 'foo', lineno: 19, colno: 19, in_app: true }, - { filename: 'http://localhost:5000/test', function: 'fooIterator', lineno: 20, colno: 17, in_app: true }, + { + filename: 'http://localhost:5000/test', + abs_path: 'http://localhost:5000/test', + function: '?', + lineno: 24, + colno: 7, + in_app: true, + }, + { + filename: 'http://localhost:5000/test', + abs_path: 'http://localhost:5000/test', + function: 'foo', + lineno: 19, + colno: 19, + in_app: true, + }, + { + filename: 'http://localhost:5000/test', + abs_path: 'http://localhost:5000/test', + function: 'fooIterator', + lineno: 20, + colno: 17, + in_app: true, + }, ], }, }); @@ -297,15 +498,77 @@ describe('Tracekit - Firefox Tests', () => { type: 'Error', stacktrace: { frames: [ - { filename: 'http://localhost:5000/', function: '?', lineno: 50, colno: 19, in_app: true }, - { filename: 'http://localhost:5000/', function: 'testMethod', lineno: 44, colno: 7, in_app: true }, - { filename: 'http://localhost:5000/', function: 'aha', lineno: 39, colno: 5, in_app: true }, - { filename: 'http://localhost:5000/', function: 'eval', lineno: 39, in_app: true }, - { filename: 'http://localhost:5000/', function: 'test', lineno: 33, colno: 23, in_app: true }, - { filename: 'http://localhost:5000/', function: 'test/<', lineno: 34, colno: 7, in_app: true }, - { filename: 'http://localhost:5000/', function: 'callback', lineno: 25, colno: 7, in_app: true }, - { filename: 'http://localhost:5000/', function: 'callAnotherThing', lineno: 20, colno: 15, in_app: true }, - { filename: 'http://localhost:5000/', function: 'aha', lineno: 19, colno: 13, in_app: true }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: '?', + lineno: 50, + colno: 19, + in_app: true, + }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'testMethod', + lineno: 44, + colno: 7, + in_app: true, + }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'aha', + lineno: 39, + colno: 5, + in_app: true, + }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'eval', + lineno: 39, + in_app: true, + }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'test', + lineno: 33, + colno: 23, + in_app: true, + }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'test/<', + lineno: 34, + colno: 7, + in_app: true, + }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'callback', + lineno: 25, + colno: 7, + in_app: true, + }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'callAnotherThing', + lineno: 20, + colno: 15, + in_app: true, + }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'aha', + lineno: 19, + colno: 13, + in_app: true, + }, ], }, }); @@ -332,6 +595,7 @@ describe('Tracekit - Firefox Tests', () => { { colno: 1018410, filename: 'https://www.random_website.com/main.4a4119c3cdfd10266d84.js', + abs_path: 'https://www.random_website.com/vendor.d1cae9cfc9917df88de7.js', function: 'handleProfileResult', in_app: true, lineno: 146, @@ -339,6 +603,7 @@ describe('Tracekit - Firefox Tests', () => { { colno: 333807, filename: 'https://www.random_website.com/vendor.d1cae9cfc9917df88de7.js', + abs_path: 'https://www.random_website.com/vendor.d1cae9cfc9917df88de7.js', function: 'detectChanges', in_app: true, lineno: 1, @@ -346,6 +611,7 @@ describe('Tracekit - Firefox Tests', () => { { colno: 296021, filename: 'https://www.random_website.com/vendor.d1cae9cfc9917df88de7.js', + abs_path: 'https://www.random_website.com/vendor.d1cae9cfc9917df88de7.js', function: 'us', in_app: true, lineno: 1, diff --git a/packages/browser/test/unit/tracekit/ie.test.ts b/packages/browser/test/unit/tracekit/ie.test.ts index 544542b0dcaf..6417a7043c32 100644 --- a/packages/browser/test/unit/tracekit/ie.test.ts +++ b/packages/browser/test/unit/tracekit/ie.test.ts @@ -23,9 +23,30 @@ describe('Tracekit - IE Tests', () => { type: 'foo', stacktrace: { frames: [ - { filename: 'http://path/to/file.js', function: 'bar', lineno: 82, colno: 1, in_app: true }, - { filename: 'http://path/to/file.js', function: 'foo', lineno: 46, colno: 9, in_app: true }, - { filename: 'http://path/to/file.js', function: 'Anonymous function', lineno: 48, colno: 13, in_app: true }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'bar', + lineno: 82, + colno: 1, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'foo', + lineno: 46, + colno: 9, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'Anonymous function', + lineno: 48, + colno: 13, + in_app: true, + }, ], }, }); @@ -52,9 +73,30 @@ describe('Tracekit - IE Tests', () => { type: 'TypeError', stacktrace: { frames: [ - { filename: 'http://path/to/file.js', function: 'bar', lineno: 108, colno: 1, in_app: true }, - { filename: 'http://path/to/file.js', function: 'foo', lineno: 45, colno: 13, in_app: true }, - { filename: 'http://path/to/file.js', function: 'Anonymous function', lineno: 47, colno: 21, in_app: true }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'bar', + lineno: 108, + colno: 1, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'foo', + lineno: 45, + colno: 13, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'Anonymous function', + lineno: 47, + colno: 21, + in_app: true, + }, ], }, }); @@ -80,9 +122,23 @@ describe('Tracekit - IE Tests', () => { type: 'ReferenceError', stacktrace: { frames: [ - { filename: 'http://path/to/file.js', function: 'bar', lineno: 109, colno: 1, in_app: true }, - { filename: 'http://path/to/file.js', function: 'foo', lineno: 58, colno: 17, in_app: true }, - { filename: 'eval code', function: 'eval code', lineno: 1, colno: 1, in_app: true }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'bar', + lineno: 109, + colno: 1, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'foo', + lineno: 58, + colno: 17, + in_app: true, + }, + { filename: 'eval code', abs_path: 'eval code', function: 'eval code', lineno: 1, colno: 1, in_app: true }, ], }, }); diff --git a/packages/browser/test/unit/tracekit/misc.test.ts b/packages/browser/test/unit/tracekit/misc.test.ts index e9db457ea196..15720ff97374 100644 --- a/packages/browser/test/unit/tracekit/misc.test.ts +++ b/packages/browser/test/unit/tracekit/misc.test.ts @@ -19,9 +19,27 @@ describe('Tracekit - Misc Tests', () => { type: 'foo', stacktrace: { frames: [ - { filename: 'http://path/to/file.js', function: '?', lineno: 4287, in_app: true }, - { filename: 'http://path/to/file.js', function: 'foo', lineno: 4283, in_app: true }, - { filename: 'file:///path/to/file.js', function: '?', lineno: 878, in_app: true }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: '?', + lineno: 4287, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'foo', + lineno: 4283, + in_app: true, + }, + { + filename: 'http:///path/to/file.js', + abs_path: 'http:///path/to/file.js', + function: '?', + lineno: 878, + in_app: true, + }, ], }, }); diff --git a/packages/browser/test/unit/tracekit/opera.test.ts b/packages/browser/test/unit/tracekit/opera.test.ts index e86855dc172a..08d7119fb5bb 100644 --- a/packages/browser/test/unit/tracekit/opera.test.ts +++ b/packages/browser/test/unit/tracekit/opera.test.ts @@ -37,13 +37,55 @@ describe('Tracekit - Opera Tests', () => { type: 'foo', stacktrace: { frames: [ - { filename: 'http://path/to/file.js', function: '?', lineno: 15, in_app: true }, - { filename: 'http://path/to/file.js', function: 'foo', lineno: 11, in_app: true }, - { filename: 'http://path/to/file.js', function: 'bar', lineno: 7, in_app: true }, - { filename: 'http://path/to/file.js', function: 'bar', lineno: 4, in_app: true }, - { filename: 'http://path/to/file.js', function: 'printStackTrace', lineno: 18, in_app: true }, - { filename: 'http://path/to/file.js', function: '?', lineno: 27, in_app: true }, - { filename: 'http://path/to/file.js', function: '?', lineno: 42, in_app: true }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: '?', + lineno: 15, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'foo', + lineno: 11, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'bar', + lineno: 7, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'bar', + lineno: 4, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'printStackTrace', + lineno: 18, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: '?', + lineno: 27, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: '?', + lineno: 42, + in_app: true, + }, ], }, }); @@ -83,13 +125,62 @@ describe('Tracekit - Opera Tests', () => { type: 'foo', stacktrace: { frames: [ - { filename: 'http://path/to/file.js', function: '?', lineno: 15, colno: 3, in_app: true }, - { filename: 'http://path/to/file.js', function: 'foo', lineno: 11, colno: 4, in_app: true }, - { filename: 'http://path/to/file.js', function: 'bar', lineno: 7, colno: 4, in_app: true }, - { filename: 'http://path/to/file.js', function: 'bar', lineno: 4, colno: 5, in_app: true }, - { filename: 'http://path/to/file.js', function: 'printStackTrace', lineno: 18, colno: 4, in_app: true }, - { filename: 'http://path/to/file.js', function: 'run', lineno: 27, colno: 8, in_app: true }, - { filename: 'http://path/to/file.js', function: 'createException', lineno: 42, colno: 12, in_app: true }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: '?', + lineno: 15, + colno: 3, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'foo', + lineno: 11, + colno: 4, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'bar', + lineno: 7, + colno: 4, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'bar', + lineno: 4, + colno: 5, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'printStackTrace', + lineno: 18, + colno: 4, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'run', + lineno: 27, + colno: 8, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'createException', + lineno: 42, + colno: 12, + in_app: true, + }, ], }, }); @@ -122,6 +213,7 @@ describe('Tracekit - Opera Tests', () => { frames: [ { filename: 'http://localhost:8000/ExceptionLab.html', + abs_path: 'http://localhost:8000/ExceptionLab.html', function: '', lineno: 1, colno: 0, @@ -129,6 +221,7 @@ describe('Tracekit - Opera Tests', () => { }, { filename: 'http://localhost:8000/ExceptionLab.html', + abs_path: 'http://localhost:8000/ExceptionLab.html', function: 'dumpException3', lineno: 46, colno: 8, @@ -136,6 +229,7 @@ describe('Tracekit - Opera Tests', () => { }, { filename: 'http://localhost:8000/ExceptionLab.html', + abs_path: 'http://localhost:8000/ExceptionLab.html', function: '', lineno: 48, colno: 12, @@ -164,9 +258,30 @@ describe('Tracekit - Opera Tests', () => { type: 'TypeError', stacktrace: { frames: [ - { filename: 'http://path/to/file.js', function: 'bar', lineno: 108, colno: 168, in_app: true }, - { filename: 'http://path/to/file.js', function: 'foo', lineno: 52, colno: 15, in_app: true }, - { filename: 'http://path/to/file.js', function: '?', lineno: 47, colno: 22, in_app: true }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'bar', + lineno: 108, + colno: 168, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'foo', + lineno: 52, + colno: 15, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: '?', + lineno: 47, + colno: 22, + in_app: true, + }, ], }, }); diff --git a/packages/browser/test/unit/tracekit/react-native.test.ts b/packages/browser/test/unit/tracekit/react-native.test.ts index 9a74e46007b1..7615a27c4afe 100644 --- a/packages/browser/test/unit/tracekit/react-native.test.ts +++ b/packages/browser/test/unit/tracekit/react-native.test.ts @@ -22,18 +22,41 @@ describe('Tracekit - React Native Tests', () => { type: 'Error', stacktrace: { frames: [ - { filename: 'index.android.bundle', function: 'P', lineno: 93, colno: 714, in_app: true }, - { filename: 'index.android.bundle', function: 'Object.y', lineno: 93, colno: 571, in_app: true }, { filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'P', + lineno: 93, + colno: 714, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'Object.y', + lineno: 93, + colno: 571, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', function: 's.touchableHandleResponderRelease', lineno: 198, colno: 5615, in_app: true, }, - { filename: 'index.android.bundle', function: 's._receiveSignal', lineno: 198, colno: 8309, in_app: true }, { filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 's._receiveSignal', + lineno: 198, + colno: 8309, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', function: 's._performSideEffectsForTransition', lineno: 198, colno: 9608, @@ -41,12 +64,20 @@ describe('Tracekit - React Native Tests', () => { }, { filename: 'index.android.bundle', + abs_path: 'index.android.bundle', function: 's.touchableHandlePress', lineno: 214, colno: 2048, in_app: true, }, - { filename: 'index.android.bundle', function: 'Object.onPress', lineno: 2342, colno: 3773, in_app: true }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'Object.onPress', + lineno: 2342, + colno: 3773, + in_app: true, + }, ], }, }); @@ -69,10 +100,12 @@ describe('Tracekit - React Native Tests', () => { type: 'Error', stacktrace: { frames: [ - { filename: '[native code]', function: 'forEach', in_app: true }, + { filename: '[native code]', abs_path: '[native code]', function: 'forEach', in_app: true }, { filename: '/data/user/0/com.sentrytest/files/.expo-internal/bundle-613EDD44F3305B9D75D4679663900F2BCDDDC326F247CA3202A3A4219FD412D3', + abs_path: + '/data/user/0/com.sentrytest/files/.expo-internal/bundle-613EDD44F3305B9D75D4679663900F2BCDDDC326F247CA3202A3A4219FD412D3', function: 'p', lineno: 96, colno: 385, @@ -81,6 +114,8 @@ describe('Tracekit - React Native Tests', () => { { filename: '/data/user/0/com.sentrytest/files/.expo-internal/bundle-613EDD44F3305B9D75D4679663900F2BCDDDC326F247CA3202A3A4219FD412D3', + abs_path: + '/data/user/0/com.sentrytest/files/.expo-internal/bundle-613EDD44F3305B9D75D4679663900F2BCDDDC326F247CA3202A3A4219FD412D3', function: 'onResponderRelease', lineno: 221, colno: 5666, @@ -89,6 +124,8 @@ describe('Tracekit - React Native Tests', () => { { filename: '/data/user/0/com.sentrytest/files/.expo-internal/bundle-613EDD44F3305B9D75D4679663900F2BCDDDC326F247CA3202A3A4219FD412D3', + abs_path: + '/data/user/0/com.sentrytest/files/.expo-internal/bundle-613EDD44F3305B9D75D4679663900F2BCDDDC326F247CA3202A3A4219FD412D3', function: 'value', lineno: 221, colno: 7656, @@ -97,6 +134,8 @@ describe('Tracekit - React Native Tests', () => { { filename: '/data/user/0/com.sentrytest/files/.expo-internal/bundle-613EDD44F3305B9D75D4679663900F2BCDDDC326F247CA3202A3A4219FD412D3', + abs_path: + '/data/user/0/com.sentrytest/files/.expo-internal/bundle-613EDD44F3305B9D75D4679663900F2BCDDDC326F247CA3202A3A4219FD412D3', function: 'onPress', lineno: 595, colno: 658, @@ -133,6 +172,8 @@ describe('Tracekit - React Native Tests', () => { { filename: '/home/username/sample-workspace/sampleapp.collect.react/node_modules/react-native/Libraries/Renderer/src/renderers/native/ReactNativeBaseComponent.js', + abs_path: + '/home/username/sample-workspace/sampleapp.collect.react/node_modules/react-native/Libraries/Renderer/src/renderers/native/ReactNativeBaseComponent.js', function: 'this', lineno: 74, colno: 41, @@ -141,6 +182,8 @@ describe('Tracekit - React Native Tests', () => { { filename: '/home/username/sample-workspace/sampleapp.collect.react/node_modules/react-native/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactMultiChild.js', + abs_path: + '/home/username/sample-workspace/sampleapp.collect.react/node_modules/react-native/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactMultiChild.js', function: 'children', lineno: 264, colno: 10, @@ -149,6 +192,8 @@ describe('Tracekit - React Native Tests', () => { { filename: '/home/username/sample-workspace/sampleapp.collect.react/node_modules/react-native/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactReconciler.js', + abs_path: + '/home/username/sample-workspace/sampleapp.collect.react/node_modules/react-native/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactReconciler.js', function: 'child', lineno: 68, colno: 25, @@ -157,6 +202,8 @@ describe('Tracekit - React Native Tests', () => { { filename: '/home/username/sample-workspace/sampleapp.collect.react/node_modules/react-native/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js', + abs_path: + '/home/username/sample-workspace/sampleapp.collect.react/node_modules/react-native/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js', function: '_currentElement', lineno: 346, colno: 40, @@ -165,6 +212,8 @@ describe('Tracekit - React Native Tests', () => { { filename: '/home/username/sample-workspace/sampleapp.collect.react/node_modules/react-native/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js', + abs_path: + '/home/username/sample-workspace/sampleapp.collect.react/node_modules/react-native/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js', function: 'renderedElement', lineno: 484, colno: 29, @@ -173,6 +222,8 @@ describe('Tracekit - React Native Tests', () => { { filename: '/home/username/sample-workspace/sampleapp.collect.react/node_modules/react-native/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js', + abs_path: + '/home/username/sample-workspace/sampleapp.collect.react/node_modules/react-native/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js', function: '_renderValidatedComponent', lineno: 1075, colno: 15, @@ -181,6 +232,8 @@ describe('Tracekit - React Native Tests', () => { { filename: '/home/username/sample-workspace/sampleapp.collect.react/node_modules/react-native/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js', + abs_path: + '/home/username/sample-workspace/sampleapp.collect.react/node_modules/react-native/Libraries/Renderer/src/renderers/shared/stack/reconciler/ReactCompositeComponent.js', function: '_renderValidatedComponentWithoutOwnerOrContext', lineno: 1050, colno: 29, @@ -188,6 +241,7 @@ describe('Tracekit - React Native Tests', () => { }, { filename: '/home/username/sample-workspace/sampleapp.collect.react/src/components/GpsMonitorScene.js', + abs_path: '/home/username/sample-workspace/sampleapp.collect.react/src/components/GpsMonitorScene.js', function: 'render', lineno: 78, colno: 24, @@ -249,73 +303,260 @@ describe('Tracekit - React Native Tests', () => { type: 'Error', stacktrace: { frames: [ - { filename: '[native code]', function: '?', in_app: true }, - { filename: 'index.android.bundle', function: 'value', lineno: 29, colno: 927, in_app: true }, - { filename: 'index.android.bundle', function: 'value', lineno: 29, colno: 2417, in_app: true }, - { filename: 'index.android.bundle', function: '?', lineno: 29, colno: 955, in_app: true }, - { filename: 'index.android.bundle', function: 'value', lineno: 29, colno: 3016, in_app: true }, - { filename: 'index.android.bundle', function: 'receiveTouches', lineno: 156, colno: 918, in_app: true }, + { filename: '[native code]', abs_path: '[native code]', function: '?', in_app: true }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'value', + lineno: 29, + colno: 927, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'value', + lineno: 29, + colno: 2417, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: '?', + lineno: 29, + colno: 955, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'value', + lineno: 29, + colno: 3016, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'receiveTouches', + lineno: 156, + colno: 918, + in_app: true, + }, { filename: 'index.android.bundle', + abs_path: 'index.android.bundle', function: '_receiveRootNodeIDEvent', lineno: 156, colno: 544, in_app: true, }, - { filename: 'index.android.bundle', function: 'u', lineno: 93, colno: 150, in_app: true }, - { filename: 'index.android.bundle', function: 'i', lineno: 93, colno: 90, in_app: true }, - { filename: 'index.android.bundle', function: 'i', lineno: 176, colno: 358, in_app: true }, - { filename: 'index.android.bundle', function: 'batchedUpdates', lineno: 188, colno: 464, in_app: true }, - { filename: 'index.android.bundle', function: 'perform', lineno: 177, colno: 596, in_app: true }, - { filename: 'index.android.bundle', function: 'c', lineno: 93, colno: 60, in_app: true }, - { filename: 'index.android.bundle', function: 'a', lineno: 93, colno: 276, in_app: true }, - { filename: 'index.android.bundle', function: '?', lineno: 156, colno: 572, in_app: true }, - { filename: 'index.android.bundle', function: 'handleTopLevel', lineno: 157, colno: 174, in_app: true }, - { filename: 'index.android.bundle', function: 's', lineno: 157, colno: 88, in_app: true }, - { filename: 'index.android.bundle', function: 'processEventQueue', lineno: 146, colno: 1432, in_app: true }, - { filename: 'index.android.bundle', function: 'i', lineno: 149, colno: 80, in_app: true }, - { filename: '[native code]', function: 'forEach', in_app: true }, - { filename: 'index.android.bundle', function: 'g', lineno: 146, colno: 604, in_app: true }, - { filename: 'index.android.bundle', function: 'v', lineno: 146, colno: 501, in_app: true }, - { filename: 'index.android.bundle', function: 'a', lineno: 95, colno: 567, in_app: true }, - { filename: 'index.android.bundle', function: 'c', lineno: 95, colno: 365, in_app: true }, { filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'u', + lineno: 93, + colno: 150, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'i', + lineno: 93, + colno: 90, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'i', + lineno: 176, + colno: 358, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'batchedUpdates', + lineno: 188, + colno: 464, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'perform', + lineno: 177, + colno: 596, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'c', + lineno: 93, + colno: 60, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'a', + lineno: 93, + colno: 276, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: '?', + lineno: 156, + colno: 572, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'handleTopLevel', + lineno: 157, + colno: 174, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 's', + lineno: 157, + colno: 88, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'processEventQueue', + lineno: 146, + colno: 1432, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'i', + lineno: 149, + colno: 80, + in_app: true, + }, + { filename: '[native code]', abs_path: '[native code]', function: 'forEach', in_app: true }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'g', + lineno: 146, + colno: 604, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'v', + lineno: 146, + colno: 501, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'a', + lineno: 95, + colno: 567, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'c', + lineno: 95, + colno: 365, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', function: 'invokeGuardedCallbackAndCatchFirstError', lineno: 79, colno: 580, in_app: true, }, - { filename: 'index.android.bundle', function: 'invokeGuardedCallback', lineno: 79, colno: 459, in_app: true }, - { filename: 'index.android.bundle', function: 'u', lineno: 79, colno: 142, in_app: true }, - { filename: '[native code]', function: '?', in_app: true }, { filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'invokeGuardedCallback', + lineno: 79, + colno: 459, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'u', + lineno: 79, + colno: 142, + in_app: true, + }, + { filename: '[native code]', abs_path: '[native code]', function: '?', in_app: true }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', function: 'touchableHandleResponderRelease', lineno: 252, colno: 4735, in_app: true, }, - { filename: '[native code]', function: '?', in_app: true }, - { filename: 'index.android.bundle', function: '_receiveSignal', lineno: 252, colno: 7291, in_app: true }, - { filename: '[native code]', function: '?', in_app: true }, + { filename: '[native code]', abs_path: '[native code]', function: '?', in_app: true }, { filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: '_receiveSignal', + lineno: 252, + colno: 7291, + in_app: true, + }, + { filename: '[native code]', abs_path: '[native code]', function: '?', in_app: true }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', function: '_performSideEffectsForTransition', lineno: 252, colno: 8508, in_app: true, }, - { filename: '[native code]', function: '?', in_app: true }, + { filename: '[native code]', abs_path: '[native code]', function: '?', in_app: true }, { filename: 'index.android.bundle', + abs_path: 'index.android.bundle', function: 'touchableHandlePress', lineno: 258, colno: 1497, in_app: true, }, - { filename: 'index.android.bundle', function: 'onPress', lineno: 12, colno: 2336, in_app: true }, - { filename: 'index.android.bundle', function: 'value', lineno: 12, colno: 1917, in_app: true }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'onPress', + lineno: 12, + colno: 2336, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'value', + lineno: 12, + colno: 1917, + in_app: true, + }, ], }, }); @@ -360,38 +601,168 @@ describe('Tracekit - React Native Tests', () => { type: 'Error', stacktrace: { frames: [ - { filename: 'index.android.bundle', function: 'value', lineno: 1, colno: 31561, in_app: true }, - { filename: 'index.android.bundle', function: 'value', lineno: 1, colno: 32776, in_app: true }, - { filename: 'index.android.bundle', function: 'anonymous', lineno: 1, colno: 31603, in_app: true }, - { filename: 'index.android.bundle', function: 'value', lineno: 1, colno: 33176, in_app: true }, - { filename: 'native', function: 'apply', in_app: true }, - { filename: 'index.android.bundle', function: 'receiveTouches', lineno: 1, colno: 122512, in_app: true }, - { filename: 'index.android.bundle', function: 'Ue', lineno: 1, colno: 77571, in_app: true }, - { filename: 'index.android.bundle', function: 'Ne', lineno: 1, colno: 77238, in_app: true }, - { filename: 'index.android.bundle', function: '_e', lineno: 1, colno: 127755, in_app: true }, - { filename: 'index.android.bundle', function: 'anonymous', lineno: 1, colno: 77747, in_app: true }, - { filename: 'index.android.bundle', function: 'z', lineno: 1, colno: 74642, in_app: true }, - { filename: 'native', function: 'forEach', in_app: true }, - { filename: 'index.android.bundle', function: 'A', lineno: 1, colno: 74709, in_app: true }, - { filename: 'index.android.bundle', function: 'N', lineno: 1, colno: 74267, in_app: true }, - { filename: 'index.android.bundle', function: 'C', lineno: 1, colno: 74126, in_app: true }, - { filename: 'native', function: 'apply', in_app: true }, - { filename: 'index.android.bundle', function: 'k', lineno: 1, colno: 74094, in_app: true }, - { filename: 'native', function: 'apply', in_app: true }, - { filename: 'index.android.bundle', function: 'b', lineno: 1, colno: 74037, in_app: true }, - { filename: 'native', function: 'apply', in_app: true }, - { filename: 'native', function: 'onResponderRelease', in_app: true }, - { filename: 'native', function: 'touchableHandleResponderRelease', in_app: true }, - { filename: 'native', function: '_receiveSignal', in_app: true }, { filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'value', + lineno: 1, + colno: 31561, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'value', + lineno: 1, + colno: 32776, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'anonymous', + lineno: 1, + colno: 31603, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'value', + lineno: 1, + colno: 33176, + in_app: true, + }, + { + filename: 'native', + abs_path: 'native', + function: 'apply', + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'receiveTouches', + lineno: 1, + colno: 122512, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'Ue', + lineno: 1, + colno: 77571, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'Ne', + lineno: 1, + colno: 77238, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: '_e', + lineno: 1, + colno: 127755, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'anonymous', + lineno: 1, + colno: 77747, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'z', + lineno: 1, + colno: 74642, + in_app: true, + }, + { + filename: 'native', + abs_path: 'native', + function: 'forEach', + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'A', + lineno: 1, + colno: 74709, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'N', + lineno: 1, + colno: 74267, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'C', + lineno: 1, + colno: 74126, + in_app: true, + }, + { filename: 'native', abs_path: 'native', function: 'apply', in_app: true }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'k', + lineno: 1, + colno: 74094, + in_app: true, + }, + { filename: 'native', abs_path: 'native', function: 'apply', in_app: true }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'b', + lineno: 1, + colno: 74037, + in_app: true, + }, + { filename: 'native', abs_path: 'native', function: 'apply', in_app: true }, + { filename: 'native', abs_path: 'native', function: 'onResponderRelease', in_app: true }, + { filename: 'native', abs_path: 'native', function: 'touchableHandleResponderRelease', in_app: true }, + { filename: 'native', abs_path: 'native', function: '_receiveSignal', in_app: true }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', function: '_performSideEffectsForTransition', lineno: 1, colno: 230843, in_app: true, }, - { filename: 'index.android.bundle', function: 'anonymous', lineno: 1, colno: 224280, in_app: true }, - { filename: 'index.android.bundle', function: 'onPress', lineno: 1, colno: 452701, in_app: true }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'anonymous', + lineno: 1, + colno: 224280, + in_app: true, + }, + { + filename: 'index.android.bundle', + abs_path: 'index.android.bundle', + function: 'onPress', + lineno: 1, + colno: 452701, + in_app: true, + }, ], }, }); diff --git a/packages/browser/test/unit/tracekit/react.test.ts b/packages/browser/test/unit/tracekit/react.test.ts index d949a4dee0eb..5ebaa602ed06 100644 --- a/packages/browser/test/unit/tracekit/react.test.ts +++ b/packages/browser/test/unit/tracekit/react.test.ts @@ -23,9 +23,17 @@ describe('Tracekit - React Tests', () => { type: 'Invariant Violation', stacktrace: { frames: [ - { filename: 'http://localhost:5000/', function: 'f', lineno: 1, colno: 980, in_app: true }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'f', + lineno: 1, + colno: 980, + in_app: true, + }, { filename: 'http://localhost:5000/static/js/foo.chunk.js', + abs_path: 'http://localhost:5000/static/js/foo.chunk.js', function: 'ho', lineno: 1, colno: 68735, @@ -33,6 +41,7 @@ describe('Tracekit - React Tests', () => { }, { filename: 'http://localhost:5000/static/js/foo.chunk.js', + abs_path: 'http://localhost:5000/static/js/foo.chunk.js', function: 'a', lineno: 1, colno: 21841, @@ -40,6 +49,7 @@ describe('Tracekit - React Tests', () => { }, { filename: 'http://localhost:5000/static/js/foo.chunk.js', + abs_path: 'http://localhost:5000/static/js/foo.chunk.js', function: '?', lineno: 1, colno: 21738, @@ -70,9 +80,17 @@ describe('Tracekit - React Tests', () => { type: 'Error', stacktrace: { frames: [ - { filename: 'http://localhost:5000/', function: 'f', lineno: 1, colno: 980, in_app: true }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'f', + lineno: 1, + colno: 980, + in_app: true, + }, { filename: 'http://localhost:5000/static/js/foo.chunk.js', + abs_path: 'http://localhost:5000/static/js/foo.chunk.js', function: 'ho', lineno: 1, colno: 68735, @@ -80,6 +98,7 @@ describe('Tracekit - React Tests', () => { }, { filename: 'http://localhost:5000/static/js/foo.chunk.js', + abs_path: 'http://localhost:5000/static/js/foo.chunk.js', function: 'a', lineno: 1, colno: 21841, @@ -87,6 +106,7 @@ describe('Tracekit - React Tests', () => { }, { filename: 'http://localhost:5000/static/js/foo.chunk.js', + abs_path: 'http://localhost:5000/static/js/foo.chunk.js', function: '?', lineno: 1, colno: 21738, @@ -118,9 +138,17 @@ describe('Tracekit - React Tests', () => { type: 'Error', stacktrace: { frames: [ - { filename: 'http://localhost:5000/', function: 'f', lineno: 1, colno: 980, in_app: true }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'f', + lineno: 1, + colno: 980, + in_app: true, + }, { filename: 'http://localhost:5000/static/js/foo.chunk.js', + abs_path: 'http://localhost:5000/static/js/foo.chunk.js', function: 'ho', lineno: 1, colno: 68735, @@ -128,6 +156,7 @@ describe('Tracekit - React Tests', () => { }, { filename: 'http://localhost:5000/static/js/foo.chunk.js', + abs_path: 'http://localhost:5000/static/js/foo.chunk.js', function: 'a', lineno: 1, colno: 21841, @@ -135,6 +164,7 @@ describe('Tracekit - React Tests', () => { }, { filename: 'http://localhost:5000/static/js/foo.chunk.js', + abs_path: 'http://localhost:5000/static/js/foo.chunk.js', function: '?', lineno: 1, colno: 21738, diff --git a/packages/browser/test/unit/tracekit/safari.test.ts b/packages/browser/test/unit/tracekit/safari.test.ts index 657ffc7daecc..c2ff37cdfe4c 100644 --- a/packages/browser/test/unit/tracekit/safari.test.ts +++ b/packages/browser/test/unit/tracekit/safari.test.ts @@ -22,10 +22,28 @@ describe('Tracekit - Safari Tests', () => { type: 'foo', stacktrace: { frames: [ - { filename: '[native code]', function: '?', in_app: true }, - { filename: 'http://path/to/file.js', function: 'onclick', lineno: 82, in_app: true }, - { filename: 'http://path/to/file.js', function: 'dumpException3', lineno: 52, in_app: true }, - { filename: 'http://path/to/file.js', function: '?', lineno: 48, in_app: true }, + { filename: '[native code]', abs_path: '[native code]', function: '?', in_app: true }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'onclick', + lineno: 82, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'dumpException3', + lineno: 52, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: '?', + lineno: 48, + in_app: true, + }, ], }, }); @@ -48,9 +66,30 @@ describe('Tracekit - Safari Tests', () => { type: 'TypeError', stacktrace: { frames: [ - { filename: 'http://path/to/file.js', function: 'bar', lineno: 108, colno: 107, in_app: true }, - { filename: 'http://path/to/file.js', function: 'foo', lineno: 52, colno: 15, in_app: true }, - { filename: 'http://path/to/file.js', function: '?', lineno: 48, colno: 22, in_app: true }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'bar', + lineno: 108, + colno: 107, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'foo', + lineno: 52, + colno: 15, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: '?', + lineno: 48, + colno: 22, + in_app: true, + }, ], }, }); @@ -74,9 +113,30 @@ describe('Tracekit - Safari Tests', () => { type: 'TypeError', stacktrace: { frames: [ - { filename: 'http://path/to/file.js', function: 'bar', lineno: 108, colno: 23, in_app: true }, - { filename: 'http://path/to/file.js', function: 'foo', lineno: 52, colno: 15, in_app: true }, - { filename: 'http://path/to/file.js', function: '?', lineno: 47, colno: 22, in_app: true }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'bar', + lineno: 108, + colno: 23, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'foo', + lineno: 52, + colno: 15, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: '?', + lineno: 47, + colno: 22, + in_app: true, + }, ], }, }); @@ -104,9 +164,23 @@ describe('Tracekit - Safari Tests', () => { type: 'ReferenceError', stacktrace: { frames: [ - { filename: 'http://path/to/file.js', function: 'bar', lineno: 109, colno: 91, in_app: true }, - { filename: 'http://path/to/file.js', function: 'foo', lineno: 58, colno: 21, in_app: true }, - { filename: '[native code]', function: 'eval', in_app: true }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'bar', + lineno: 109, + colno: 91, + in_app: true, + }, + { + filename: 'http://path/to/file.js', + abs_path: 'http://path/to/file.js', + function: 'foo', + lineno: 58, + colno: 21, + in_app: true, + }, + { filename: '[native code]', abs_path: '[native code]', function: 'eval', in_app: true }, ], }, }); @@ -131,6 +205,7 @@ describe('Tracekit - Safari Tests', () => { frames: [ { filename: 'safari-extension://3284871F-A480-4FFC-8BC4-3F362C752446/2665fee0/topee-content.js', + abs_path: 'safari-extension://3284871F-A480-4FFC-8BC4-3F362C752446/2665fee0/topee-content.js', function: '?', lineno: 3313, colno: 26, @@ -138,6 +213,7 @@ describe('Tracekit - Safari Tests', () => { }, { filename: 'safari-extension://3284871F-A480-4FFC-8BC4-3F362C752446/2665fee0/commons.js', + abs_path: 'safari-extension://3284871F-A480-4FFC-8BC4-3F362C752446/2665fee0/commons.js', function: 'ClipperError', lineno: 223036, colno: 10, @@ -163,9 +239,10 @@ describe('Tracekit - Safari Tests', () => { type: 'TypeError', stacktrace: { frames: [ - { filename: '[native code]', function: 'promiseReactionJob', in_app: true }, + { filename: '[native code]', abs_path: '[native code]', function: 'promiseReactionJob', in_app: true }, { filename: 'safari-extension://com.grammarly.safari.extension.ext2-W8F64X92K3/ee7759dd/Grammarly.js', + abs_path: 'safari-extension://com.grammarly.safari.extension.ext2-W8F64X92K3/ee7759dd/Grammarly.js', function: '?', lineno: 2, colno: 1588410, @@ -173,6 +250,7 @@ describe('Tracekit - Safari Tests', () => { }, { filename: 'safari-extension://com.grammarly.safari.extension.ext2-W8F64X92K3/ee7759dd/Grammarly.js', + abs_path: 'safari-extension://com.grammarly.safari.extension.ext2-W8F64X92K3/ee7759dd/Grammarly.js', function: 'isClaimed', lineno: 2, colno: 929865, @@ -201,6 +279,7 @@ describe('Tracekit - Safari Tests', () => { frames: [ { filename: 'safari-web-extension://3284871F-A480-4FFC-8BC4-3F362C752446/2665fee0/topee-content.js', + abs_path: 'safari-web-extension://3284871F-A480-4FFC-8BC4-3F362C752446/2665fee0/topee-content.js', function: '?', lineno: 3313, colno: 26, @@ -208,6 +287,7 @@ describe('Tracekit - Safari Tests', () => { }, { filename: 'safari-web-extension://3284871F-A480-4FFC-8BC4-3F362C752446/2665fee0/commons.js', + abs_path: 'safari-web-extension://3284871F-A480-4FFC-8BC4-3F362C752446/2665fee0/commons.js', function: 'ClipperError', lineno: 223036, colno: 10, @@ -233,9 +313,10 @@ describe('Tracekit - Safari Tests', () => { type: 'TypeError', stacktrace: { frames: [ - { filename: '[native code]', function: 'promiseReactionJob', in_app: true }, + { filename: '[native code]', abs_path: '[native code]', function: 'promiseReactionJob', in_app: true }, { filename: 'safari-web-extension://46434E60-F5BD-48A4-80C8-A422C5D16897/scripts/content-script.js', + abs_path: 'safari-web-extension://46434E60-F5BD-48A4-80C8-A422C5D16897/scripts/content-script.js', function: '?', lineno: 29, colno: 56027, @@ -243,6 +324,7 @@ describe('Tracekit - Safari Tests', () => { }, { filename: 'safari-web-extension://46434E60-F5BD-48A4-80C8-A422C5D16897/scripts/content-script.js', + abs_path: 'safari-web-extension://46434E60-F5BD-48A4-80C8-A422C5D16897/scripts/content-script.js', function: 'p_', lineno: 29, colno: 33314, @@ -271,10 +353,31 @@ describe('Tracekit - Safari Tests', () => { type: 'Error', stacktrace: { frames: [ - { filename: 'http://localhost:5000/test', function: 'global code', lineno: 24, colno: 10, in_app: true }, - { filename: 'http://localhost:5000/test', function: 'foo', lineno: 19, colno: 22, in_app: true }, - { filename: '[native code]', function: 'map', in_app: true }, - { filename: 'http://localhost:5000/test', function: 'fooIterator', lineno: 20, colno: 26, in_app: true }, + { + filename: 'http://localhost:5000/test', + abs_path: 'http://localhost:5000/test', + function: 'global code', + lineno: 24, + colno: 10, + in_app: true, + }, + { + filename: 'http://localhost:5000/test', + abs_path: 'http://localhost:5000/test', + function: 'foo', + lineno: 19, + colno: 22, + in_app: true, + }, + { filename: '[native code]', abs_path: '[native code]', function: 'map', in_app: true }, + { + filename: 'http://localhost:5000/test', + abs_path: 'http://localhost:5000/test', + function: 'fooIterator', + lineno: 20, + colno: 26, + in_app: true, + }, ], }, }); @@ -305,17 +408,73 @@ describe('Tracekit - Safari Tests', () => { type: 'Error', stacktrace: { frames: [ - { filename: 'http://localhost:5000/', function: '?', lineno: 50, colno: 29, in_app: true }, - { filename: 'http://localhost:5000/', function: 'testMethod', lineno: 44, colno: 10, in_app: true }, - { filename: 'http://localhost:5000/', function: 'aha', lineno: 39, colno: 9, in_app: true }, - { filename: '[native code]', function: 'eval', in_app: true }, - { filename: 'http://localhost:5000/', function: 'test', lineno: 33, colno: 26, in_app: true }, - { filename: '[native code]', function: 'map', in_app: true }, - { filename: 'http://localhost:5000/', function: '?', lineno: 34, colno: 25, in_app: true }, - { filename: 'http://localhost:5000/', function: 'callback', lineno: 25, colno: 23, in_app: true }, - { filename: 'http://localhost:5000/', function: 'callAnotherThing', lineno: 20, colno: 16, in_app: true }, - { filename: '[native code]', function: 'aha', in_app: true }, - { filename: 'http://localhost:5000/', function: 'aha', lineno: 19, colno: 22, in_app: true }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: '?', + lineno: 50, + colno: 29, + in_app: true, + }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'testMethod', + lineno: 44, + colno: 10, + in_app: true, + }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'aha', + lineno: 39, + colno: 9, + in_app: true, + }, + { filename: '[native code]', abs_path: '[native code]', function: 'eval', in_app: true }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'test', + lineno: 33, + colno: 26, + in_app: true, + }, + { filename: '[native code]', abs_path: '[native code]', function: 'map', in_app: true }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: '?', + lineno: 34, + colno: 25, + in_app: true, + }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'callback', + lineno: 25, + colno: 23, + in_app: true, + }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'callAnotherThing', + lineno: 20, + colno: 16, + in_app: true, + }, + { filename: '[native code]', abs_path: '[native code]', function: 'aha', in_app: true }, + { + filename: 'http://localhost:5000/', + abs_path: 'http://localhost:5000/', + function: 'aha', + lineno: 19, + colno: 22, + in_app: true, + }, ], }, }); From 5ce6d8cc98144e240c884ff72eea12a4bb4fc8e0 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Mon, 13 Feb 2023 19:05:15 +0000 Subject: [PATCH 02/11] feat: Add source map images to `debug_meta` --- .../test/unit/tracekit/firefox.test.ts | 2 +- .../browser/test/unit/tracekit/misc.test.ts | 4 +- packages/core/src/utils/prepareEvent.ts | 53 ++++++++++++++++++- packages/types/src/debugMeta.ts | 18 +++---- packages/types/src/index.ts | 2 +- packages/utils/src/stacktrace.ts | 38 ------------- packages/utils/test/stacktrace.test.ts | 38 ------------- packages/wasm/src/index.ts | 2 +- packages/wasm/src/registry.ts | 10 +++- 9 files changed, 73 insertions(+), 94 deletions(-) diff --git a/packages/browser/test/unit/tracekit/firefox.test.ts b/packages/browser/test/unit/tracekit/firefox.test.ts index ee21f4644648..9a062d0a123b 100644 --- a/packages/browser/test/unit/tracekit/firefox.test.ts +++ b/packages/browser/test/unit/tracekit/firefox.test.ts @@ -595,7 +595,7 @@ describe('Tracekit - Firefox Tests', () => { { colno: 1018410, filename: 'https://www.random_website.com/main.4a4119c3cdfd10266d84.js', - abs_path: 'https://www.random_website.com/vendor.d1cae9cfc9917df88de7.js', + abs_path: 'https://www.random_website.com/main.4a4119c3cdfd10266d84.js', function: 'handleProfileResult', in_app: true, lineno: 146, diff --git a/packages/browser/test/unit/tracekit/misc.test.ts b/packages/browser/test/unit/tracekit/misc.test.ts index 15720ff97374..dbe718c9410f 100644 --- a/packages/browser/test/unit/tracekit/misc.test.ts +++ b/packages/browser/test/unit/tracekit/misc.test.ts @@ -34,8 +34,8 @@ describe('Tracekit - Misc Tests', () => { in_app: true, }, { - filename: 'http:///path/to/file.js', - abs_path: 'http:///path/to/file.js', + filename: 'file:///path/to/file.js', + abs_path: 'file:///path/to/file.js', function: '?', lineno: 878, in_app: true, diff --git a/packages/core/src/utils/prepareEvent.ts b/packages/core/src/utils/prepareEvent.ts index 73a71e138db2..fb6b0b6aba3b 100644 --- a/packages/core/src/utils/prepareEvent.ts +++ b/packages/core/src/utils/prepareEvent.ts @@ -1,5 +1,5 @@ -import type { ClientOptions, Event, EventHint } from '@sentry/types'; -import { dateTimestampInSeconds, normalize, resolvedSyncPromise, truncate, uuid4 } from '@sentry/utils'; +import type { ClientOptions, Event, EventHint, StackParser } from '@sentry/types'; +import { dateTimestampInSeconds, GLOBAL_OBJ, normalize, resolvedSyncPromise, truncate, uuid4 } from '@sentry/utils'; import { Scope } from '../scope'; @@ -36,6 +36,7 @@ export function prepareEvent( applyClientOptions(prepared, options); applyIntegrationsMetadata(prepared, integrations); + applyDebugMetadata(prepared, options.stackParser); // If we have scope given to us, use it as the base for further modifications. // This allows us to prevent unnecessary copying of data if `captureContext` is not provided. @@ -112,6 +113,54 @@ function applyClientOptions(event: Event, options: ClientOptions): void { } } +/** + * Applies debug metadata images to the event in order to apply source maps by looking up their debug ID. + */ +function applyDebugMetadata(event: Event, stackParser: StackParser): void { + const debugIdMap = GLOBAL_OBJ._sentryDebugIds; + if (debugIdMap) { + // Build a map of abs_path -> debug_id + const absPathDebugIdMap: Record = {}; + Object.keys(debugIdMap).forEach(debugIdStackTrace => { + const parsedStack = stackParser(debugIdStackTrace); + for (const stackFrame of parsedStack) { + if (stackFrame.abs_path) { + absPathDebugIdMap[stackFrame.abs_path] = debugIdMap[debugIdStackTrace]; + break; + } + } + }); + + // Get a Set of abs_paths in the stack trace + const errorAbsPaths = new Set(); + if (event && event.exception && event.exception.values) { + event.exception.values.forEach(exception => { + if (exception.stacktrace && exception.stacktrace.frames) { + exception.stacktrace.frames.forEach(frame => { + if (frame.abs_path) { + errorAbsPaths.add(frame.abs_path); + } + }); + } + }); + } + + // Fill debug_meta information + event.debug_meta = event.debug_meta || {}; + event.debug_meta.images = event.debug_meta.images || []; + const images = event.debug_meta.images; + errorAbsPaths.forEach(absPath => { + if (absPathDebugIdMap[absPath]) { + images.push({ + type: 'sourcemap', + source_filename: absPath, + debug_id: absPathDebugIdMap[absPath], + }); + } + }); + } +} + /** * This function adds all used integrations to the SDK info in the event. * @param event The event that will be filled with all integrations. diff --git a/packages/types/src/debugMeta.ts b/packages/types/src/debugMeta.ts index d0cbfeb46118..c8c755cdb788 100644 --- a/packages/types/src/debugMeta.ts +++ b/packages/types/src/debugMeta.ts @@ -5,18 +5,18 @@ export interface DebugMeta { images?: Array; } -/** - * Possible choices for debug images. - */ -export type DebugImageType = 'wasm' | 'macho' | 'elf' | 'pe'; +export type DebugImage = WasmDebugImage | SourceMapDebugImage; -/** - * References to debug images. - */ -export interface DebugImage { - type: DebugImageType; +interface WasmDebugImage { + type: 'wasm'; debug_id: string; code_id?: string | null; code_file: string; debug_file?: string | null; } + +interface SourceMapDebugImage { + type: 'sourcemap'; + source_filename: string; // abs_path + debug_id: string; // uuid +} diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index 0b52fac74e02..06aaba7ff571 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -5,7 +5,7 @@ export type { ClientReport, Outcome, EventDropReason } from './clientreport'; export type { Context, Contexts, DeviceContext, OsContext, AppContext, CultureContext, TraceContext } from './context'; export type { DataCategory } from './datacategory'; export type { DsnComponents, DsnLike, DsnProtocol } from './dsn'; -export type { DebugImage, DebugImageType, DebugMeta } from './debugMeta'; +export type { DebugImage, DebugMeta } from './debugMeta'; export type { AttachmentItem, BaseEnvelopeHeaders, diff --git a/packages/utils/src/stacktrace.ts b/packages/utils/src/stacktrace.ts index 8af1c6f0d1b0..ccf18c64e897 100644 --- a/packages/utils/src/stacktrace.ts +++ b/packages/utils/src/stacktrace.ts @@ -1,14 +1,7 @@ import type { StackFrame, StackLineParser, StackLineParserFn, StackParser } from '@sentry/types'; -import { GLOBAL_OBJ } from './worldwide'; - const STACKTRACE_LIMIT = 50; -type DebugIdFilename = string; -type DebugId = string; - -const debugIdParserCache = new Map>(); - /** * Creates a stack parser with the supplied line parsers * @@ -21,29 +14,6 @@ export function createStackParser(...parsers: StackLineParser[]): StackParser { return (stack: string, skipFirst: number = 0): StackFrame[] => { const frames: StackFrame[] = []; - - for (const parser of sortedParsers) { - let debugIdCache = debugIdParserCache.get(parser); - if (!debugIdCache) { - debugIdCache = new Map(); - debugIdParserCache.set(parser, debugIdCache); - } - - const debugIdMap = GLOBAL_OBJ._sentryDebugIds; - - if (debugIdMap) { - Object.keys(debugIdMap).forEach(debugIdStackTrace => { - debugIdStackTrace.split('\n').forEach(line => { - const frame = parser(line); - if (frame && frame.filename) { - // eslint-disable-next-line @typescript-eslint/no-non-null-assertion - debugIdCache!.set(frame.filename, debugIdMap[debugIdStackTrace]); - } - }); - }); - } - } - for (const line of stack.split('\n').slice(skipFirst)) { // Ignore lines over 1kb as they are unlikely to be stack frames. // Many of the regular expressions use backtracking which results in run time that increases exponentially with @@ -61,14 +31,6 @@ export function createStackParser(...parsers: StackLineParser[]): StackParser { const frame = parser(cleanedLine); if (frame) { - const debugIdCache = debugIdParserCache.get(parser); - if (debugIdCache && frame.filename) { - const cachedDebugId = debugIdCache.get(frame.filename); - if (cachedDebugId) { - frame.debug_id = cachedDebugId; - } - } - frames.push(frame); break; } diff --git a/packages/utils/test/stacktrace.test.ts b/packages/utils/test/stacktrace.test.ts index a2438c687bc4..c5d0d691bacd 100644 --- a/packages/utils/test/stacktrace.test.ts +++ b/packages/utils/test/stacktrace.test.ts @@ -69,41 +69,3 @@ describe('Stacktrace', () => { }); }); }); - -describe('Stack parsers created with createStackParser', () => { - afterEach(() => { - GLOBAL_OBJ._sentryDebugIds = undefined; - }); - - it('put debug ids onto individual frames', () => { - GLOBAL_OBJ._sentryDebugIds = { - 'filename1.js\nfilename1.js': 'aaaaaaaa-aaaa-4aaa-aaaa-aaaaaaaaaa', - 'filename2.js\nfilename2.js': 'bbbbbbbb-bbbb-4bbb-bbbb-bbbbbbbbbb', - }; - - const fakeErrorStack = 'filename1.js\nfilename2.js\nfilename1.js\nfilename3.js'; - const stackParser = createStackParser([0, line => ({ filename: line })]); - - const result = stackParser(fakeErrorStack); - - expect(result[0]).toStrictEqual({ filename: 'filename3.js', function: '?' }); - - expect(result[1]).toStrictEqual({ - filename: 'filename1.js', - function: '?', - debug_id: 'aaaaaaaa-aaaa-4aaa-aaaa-aaaaaaaaaa', - }); - - expect(result[2]).toStrictEqual({ - filename: 'filename2.js', - function: '?', - debug_id: 'bbbbbbbb-bbbb-4bbb-bbbb-bbbbbbbbbb', - }); - - expect(result[3]).toStrictEqual({ - filename: 'filename1.js', - function: '?', - debug_id: 'aaaaaaaa-aaaa-4aaa-aaaa-aaaaaaaaaa', - }); - }); -}); diff --git a/packages/wasm/src/index.ts b/packages/wasm/src/index.ts index 436668e73ac2..8d79586eb1d3 100644 --- a/packages/wasm/src/index.ts +++ b/packages/wasm/src/index.ts @@ -61,7 +61,7 @@ export class Wasm implements Integration { if (haveWasm) { event.debug_meta = event.debug_meta || {}; - event.debug_meta.images = getImages(); + event.debug_meta.images = [...(event.debug_meta.images || []), ...getImages()]; } return event; diff --git a/packages/wasm/src/registry.ts b/packages/wasm/src/registry.ts index f0b1069ed7e9..aad4e34493ee 100644 --- a/packages/wasm/src/registry.ts +++ b/packages/wasm/src/registry.ts @@ -41,7 +41,7 @@ export function getModuleInfo(module: WebAssembly.Module): ModuleInfo { export function registerModule(module: WebAssembly.Module, url: string): void { const { buildId, debugFile } = getModuleInfo(module); if (buildId) { - const oldIdx = IMAGES.findIndex(img => img.code_file === url); + const oldIdx = getImage(url); if (oldIdx >= 0) { IMAGES.splice(oldIdx, 1); } @@ -68,5 +68,11 @@ export function getImages(): Array { * @param url the URL of the WebAssembly module. */ export function getImage(url: string): number { - return IMAGES.findIndex(img => img.code_file === url); + return IMAGES.findIndex(image => { + if (image.type === 'wasm') { + return image.code_file === url; + } else { + return false; + } + }); } From 9c406daa747ac6a195d121f0186ee2967885d259 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Mon, 13 Feb 2023 20:03:24 +0000 Subject: [PATCH 03/11] . --- packages/browser/test/unit/tracekit/firefox.test.ts | 2 +- packages/browser/test/unit/tracekit/misc.test.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/browser/test/unit/tracekit/firefox.test.ts b/packages/browser/test/unit/tracekit/firefox.test.ts index ee21f4644648..9a062d0a123b 100644 --- a/packages/browser/test/unit/tracekit/firefox.test.ts +++ b/packages/browser/test/unit/tracekit/firefox.test.ts @@ -595,7 +595,7 @@ describe('Tracekit - Firefox Tests', () => { { colno: 1018410, filename: 'https://www.random_website.com/main.4a4119c3cdfd10266d84.js', - abs_path: 'https://www.random_website.com/vendor.d1cae9cfc9917df88de7.js', + abs_path: 'https://www.random_website.com/main.4a4119c3cdfd10266d84.js', function: 'handleProfileResult', in_app: true, lineno: 146, diff --git a/packages/browser/test/unit/tracekit/misc.test.ts b/packages/browser/test/unit/tracekit/misc.test.ts index 15720ff97374..dbe718c9410f 100644 --- a/packages/browser/test/unit/tracekit/misc.test.ts +++ b/packages/browser/test/unit/tracekit/misc.test.ts @@ -34,8 +34,8 @@ describe('Tracekit - Misc Tests', () => { in_app: true, }, { - filename: 'http:///path/to/file.js', - abs_path: 'http:///path/to/file.js', + filename: 'file:///path/to/file.js', + abs_path: 'file:///path/to/file.js', function: '?', lineno: 878, in_app: true, From df4a3b238e9e81af0f649d9fe08f006b487d76c0 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Mon, 13 Feb 2023 20:33:02 +0000 Subject: [PATCH 04/11] lint --- packages/utils/test/stacktrace.test.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/utils/test/stacktrace.test.ts b/packages/utils/test/stacktrace.test.ts index c5d0d691bacd..61b44de34366 100644 --- a/packages/utils/test/stacktrace.test.ts +++ b/packages/utils/test/stacktrace.test.ts @@ -1,5 +1,4 @@ -import { createStackParser, stripSentryFramesAndReverse } from '../src/stacktrace'; -import { GLOBAL_OBJ } from '../src/worldwide'; +import { stripSentryFramesAndReverse } from '../src/stacktrace'; describe('Stacktrace', () => { describe('stripSentryFramesAndReverse()', () => { From 81c326e3f1a1d2db885bf2ef08b8804278523671 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Tue, 14 Feb 2023 09:26:13 +0000 Subject: [PATCH 05/11] Code file --- packages/core/src/utils/prepareEvent.ts | 2 +- packages/types/src/debugMeta.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/src/utils/prepareEvent.ts b/packages/core/src/utils/prepareEvent.ts index fb6b0b6aba3b..046731b5f492 100644 --- a/packages/core/src/utils/prepareEvent.ts +++ b/packages/core/src/utils/prepareEvent.ts @@ -153,7 +153,7 @@ function applyDebugMetadata(event: Event, stackParser: StackParser): void { if (absPathDebugIdMap[absPath]) { images.push({ type: 'sourcemap', - source_filename: absPath, + code_file: absPath, debug_id: absPathDebugIdMap[absPath], }); } diff --git a/packages/types/src/debugMeta.ts b/packages/types/src/debugMeta.ts index c8c755cdb788..2a6f201874da 100644 --- a/packages/types/src/debugMeta.ts +++ b/packages/types/src/debugMeta.ts @@ -17,6 +17,6 @@ interface WasmDebugImage { interface SourceMapDebugImage { type: 'sourcemap'; - source_filename: string; // abs_path + code_file: string; // abs_path debug_id: string; // uuid } From 2da12d1e77e5878ffd75213551c3f8327e33b275 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Tue, 14 Feb 2023 11:32:58 +0000 Subject: [PATCH 06/11] Add test --- packages/core/src/utils/prepareEvent.ts | 2 +- packages/core/test/lib/prepareEvent.test.ts | 68 +++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 packages/core/test/lib/prepareEvent.test.ts diff --git a/packages/core/src/utils/prepareEvent.ts b/packages/core/src/utils/prepareEvent.ts index 046731b5f492..7d958eaeeddb 100644 --- a/packages/core/src/utils/prepareEvent.ts +++ b/packages/core/src/utils/prepareEvent.ts @@ -116,7 +116,7 @@ function applyClientOptions(event: Event, options: ClientOptions): void { /** * Applies debug metadata images to the event in order to apply source maps by looking up their debug ID. */ -function applyDebugMetadata(event: Event, stackParser: StackParser): void { +export function applyDebugMetadata(event: Event, stackParser: StackParser): void { const debugIdMap = GLOBAL_OBJ._sentryDebugIds; if (debugIdMap) { // Build a map of abs_path -> debug_id diff --git a/packages/core/test/lib/prepareEvent.test.ts b/packages/core/test/lib/prepareEvent.test.ts new file mode 100644 index 000000000000..b4cac98355e0 --- /dev/null +++ b/packages/core/test/lib/prepareEvent.test.ts @@ -0,0 +1,68 @@ +import type { Event } from '@sentry/types'; +import { createStackParser, GLOBAL_OBJ } from '@sentry/utils'; + +import { applyDebugMetadata } from '../../src/utils/prepareEvent'; + +describe('applyDebugMetadata', () => { + afterEach(() => { + GLOBAL_OBJ._sentryDebugIds = undefined; + }); + + it('should put debug source map images in debug_meta field', () => { + GLOBAL_OBJ._sentryDebugIds = { + 'filename1.js\nfilename1.js': 'aaaaaaaa-aaaa-4aaa-aaaa-aaaaaaaaaa', + 'filename2.js\nfilename2.js': 'bbbbbbbb-bbbb-4bbb-bbbb-bbbbbbbbbb', + 'filename4.js\nfilename4.js': 'cccccccc-cccc-4ccc-cccc-cccccccccc', + }; + + const stackParser = createStackParser([0, line => ({ filename: line, abs_path: line })]); + + const event: Event = { + exception: { + values: [ + { + stacktrace: { + frames: [ + { abs_path: 'filename1.js', filename: 'filename1.js' }, + { abs_path: 'filename2.js', filename: 'filename2.js' }, + { abs_path: 'filename1.js', filename: 'filename1.js' }, + { abs_path: 'filename3.js', filename: 'filename3.js' }, + ], + }, + }, + ], + }, + }; + + applyDebugMetadata(event, stackParser); + + expect(event.debug_meta?.images).toContainEqual({ + type: 'sourcemap', + code_file: 'filename1.js', + debug_id: 'aaaaaaaa-aaaa-4aaa-aaaa-aaaaaaaaaa', + }); + + expect(event.debug_meta?.images).toContainEqual({ + type: 'sourcemap', + code_file: 'filename2.js', + debug_id: 'bbbbbbbb-bbbb-4bbb-bbbb-bbbbbbbbbb', + }); + + // expect not to contain an image for the stack frame that doesn't have a corresponding debug id + expect(event.debug_meta?.images).not.toContainEqual( + expect.objectContaining({ + type: 'sourcemap', + code_file: 'filename3.js', + }), + ); + + // expect not to contain an image for the debug id mapping that isn't contained in the stack trace + expect(event.debug_meta?.images).not.toContainEqual( + expect.objectContaining({ + type: 'sourcemap', + code_file: 'filename4.js', + debug_id: 'cccccccc-cccc-4ccc-cccc-cccccccccc', + }), + ); + }); +}); From 2186c67e2edf81397646953e66c5e492dad7eaec Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Tue, 14 Feb 2023 11:36:32 +0000 Subject: [PATCH 07/11] . --- packages/wasm/src/registry.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/wasm/src/registry.ts b/packages/wasm/src/registry.ts index aad4e34493ee..765b47026f00 100644 --- a/packages/wasm/src/registry.ts +++ b/packages/wasm/src/registry.ts @@ -69,10 +69,6 @@ export function getImages(): Array { */ export function getImage(url: string): number { return IMAGES.findIndex(image => { - if (image.type === 'wasm') { - return image.code_file === url; - } else { - return false; - } + return image.type === 'wasm' && image.code_file === url; }); } From 89eb55b27e1dbf7aed03f5056739ff368b53307d Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Tue, 14 Feb 2023 13:05:59 +0000 Subject: [PATCH 08/11] Early return --- packages/core/src/utils/prepareEvent.ts | 71 +++++++++++++------------ 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/packages/core/src/utils/prepareEvent.ts b/packages/core/src/utils/prepareEvent.ts index 7d958eaeeddb..62a9d05ddd3a 100644 --- a/packages/core/src/utils/prepareEvent.ts +++ b/packages/core/src/utils/prepareEvent.ts @@ -118,47 +118,50 @@ function applyClientOptions(event: Event, options: ClientOptions): void { */ export function applyDebugMetadata(event: Event, stackParser: StackParser): void { const debugIdMap = GLOBAL_OBJ._sentryDebugIds; - if (debugIdMap) { - // Build a map of abs_path -> debug_id - const absPathDebugIdMap: Record = {}; - Object.keys(debugIdMap).forEach(debugIdStackTrace => { - const parsedStack = stackParser(debugIdStackTrace); - for (const stackFrame of parsedStack) { - if (stackFrame.abs_path) { - absPathDebugIdMap[stackFrame.abs_path] = debugIdMap[debugIdStackTrace]; - break; - } - } - }); - // Get a Set of abs_paths in the stack trace - const errorAbsPaths = new Set(); - if (event && event.exception && event.exception.values) { - event.exception.values.forEach(exception => { - if (exception.stacktrace && exception.stacktrace.frames) { - exception.stacktrace.frames.forEach(frame => { - if (frame.abs_path) { - errorAbsPaths.add(frame.abs_path); - } - }); - } - }); + if (!debugIdMap) { + return; + } + + // Build a map of abs_path -> debug_id + const absPathDebugIdMap: Record = {}; + Object.keys(debugIdMap).forEach(debugIdStackTrace => { + const parsedStack = stackParser(debugIdStackTrace); + for (const stackFrame of parsedStack) { + if (stackFrame.abs_path) { + absPathDebugIdMap[stackFrame.abs_path] = debugIdMap[debugIdStackTrace]; + break; + } } + }); - // Fill debug_meta information - event.debug_meta = event.debug_meta || {}; - event.debug_meta.images = event.debug_meta.images || []; - const images = event.debug_meta.images; - errorAbsPaths.forEach(absPath => { - if (absPathDebugIdMap[absPath]) { - images.push({ - type: 'sourcemap', - code_file: absPath, - debug_id: absPathDebugIdMap[absPath], + // Get a Set of abs_paths in the stack trace + const errorAbsPaths = new Set(); + if (event && event.exception && event.exception.values) { + event.exception.values.forEach(exception => { + if (exception.stacktrace && exception.stacktrace.frames) { + exception.stacktrace.frames.forEach(frame => { + if (frame.abs_path) { + errorAbsPaths.add(frame.abs_path); + } }); } }); } + + // Fill debug_meta information + event.debug_meta = event.debug_meta || {}; + event.debug_meta.images = event.debug_meta.images || []; + const images = event.debug_meta.images; + errorAbsPaths.forEach(absPath => { + if (absPathDebugIdMap[absPath]) { + images.push({ + type: 'sourcemap', + code_file: absPath, + debug_id: absPathDebugIdMap[absPath], + }); + } + }); } /** From 485b9810e16f1aa244b83ef3aa3c7ee0d9c3bc77 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Tue, 14 Feb 2023 13:09:56 +0000 Subject: [PATCH 09/11] Add comment explaining sentry debug ids --- packages/utils/src/worldwide.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/utils/src/worldwide.ts b/packages/utils/src/worldwide.ts index 028eba2ac774..7b61814229cf 100644 --- a/packages/utils/src/worldwide.ts +++ b/packages/utils/src/worldwide.ts @@ -29,6 +29,11 @@ export interface InternalGlobal { id?: string; }; SENTRY_SDK_SOURCE?: SdkSource; + /** + * Debug IDs are indirectly injected by Sentry CLI or bundler plugins to directly reference a particular source map + * for resolving of a source file. The injected code will place an entry into the record for each loaded bundle/JS + * file. + */ _sentryDebugIds?: Record; __SENTRY__: { globalEventProcessors: any; From d88199db940f495f18ae69df74ceb89043f687d0 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Tue, 14 Feb 2023 15:28:25 +0000 Subject: [PATCH 10/11] try catch --- packages/core/src/utils/prepareEvent.ts | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/packages/core/src/utils/prepareEvent.ts b/packages/core/src/utils/prepareEvent.ts index 62a9d05ddd3a..112b86f7d1c9 100644 --- a/packages/core/src/utils/prepareEvent.ts +++ b/packages/core/src/utils/prepareEvent.ts @@ -137,16 +137,18 @@ export function applyDebugMetadata(event: Event, stackParser: StackParser): void // Get a Set of abs_paths in the stack trace const errorAbsPaths = new Set(); - if (event && event.exception && event.exception.values) { - event.exception.values.forEach(exception => { - if (exception.stacktrace && exception.stacktrace.frames) { - exception.stacktrace.frames.forEach(frame => { - if (frame.abs_path) { - errorAbsPaths.add(frame.abs_path); - } - }); - } + try { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + event!.exception!.values!.forEach(exception => { + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + exception.stacktrace!.frames!.forEach(frame => { + if (frame.abs_path) { + errorAbsPaths.add(frame.abs_path); + } + }); }); + } catch (e) { + // To save bundle size we're just try catching here instead of checking for the existence of all the different objects. } // Fill debug_meta information From 2fa925c0131ca36974520c3071ce0ebf95a06b40 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Tue, 14 Feb 2023 15:30:17 +0000 Subject: [PATCH 11/11] Use reduce --- packages/core/src/utils/prepareEvent.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core/src/utils/prepareEvent.ts b/packages/core/src/utils/prepareEvent.ts index 112b86f7d1c9..cce907c36446 100644 --- a/packages/core/src/utils/prepareEvent.ts +++ b/packages/core/src/utils/prepareEvent.ts @@ -124,16 +124,16 @@ export function applyDebugMetadata(event: Event, stackParser: StackParser): void } // Build a map of abs_path -> debug_id - const absPathDebugIdMap: Record = {}; - Object.keys(debugIdMap).forEach(debugIdStackTrace => { + const absPathDebugIdMap = Object.keys(debugIdMap).reduce>((acc, debugIdStackTrace) => { const parsedStack = stackParser(debugIdStackTrace); for (const stackFrame of parsedStack) { if (stackFrame.abs_path) { - absPathDebugIdMap[stackFrame.abs_path] = debugIdMap[debugIdStackTrace]; + acc[stackFrame.abs_path] = debugIdMap[debugIdStackTrace]; break; } } - }); + return acc; + }, {}); // Get a Set of abs_paths in the stack trace const errorAbsPaths = new Set();