From a62cde975d2634f6811737357eb61acfeeff9088 Mon Sep 17 00:00:00 2001 From: Onur Temizkan Date: Fri, 29 Apr 2022 09:44:32 +0100 Subject: [PATCH 1/5] fix(browser): Set : as a part of gecko protocol regex group. --- packages/browser/src/stack-parsers.ts | 2 +- .../test/unit/tracekit/firefox.test.ts | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/packages/browser/src/stack-parsers.ts b/packages/browser/src/stack-parsers.ts index 0d01878ae7fe..8e387c66fff4 100644 --- a/packages/browser/src/stack-parsers.ts +++ b/packages/browser/src/stack-parsers.ts @@ -67,7 +67,7 @@ export const chromeStackLineParser: StackLineParser = [CHROME_PRIORITY, chrome]; // generates filenames without a prefix like `file://` the filenames in the stacktrace are just 42.js // We need this specific case for now because we want no other regex to match. const geckoREgex = - /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension|capacitor).*?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i; + /^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:file|https?|blob|chrome|webpack|resource|moz-extension|safari-extension|safari-web-extension|capacitor)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i; const geckoEvalRegex = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i; const gecko: StackLineParserFn = line => { diff --git a/packages/browser/test/unit/tracekit/firefox.test.ts b/packages/browser/test/unit/tracekit/firefox.test.ts index a9f8ee2d50cb..f75dd7ccf010 100644 --- a/packages/browser/test/unit/tracekit/firefox.test.ts +++ b/packages/browser/test/unit/tracekit/firefox.test.ts @@ -310,4 +310,50 @@ describe('Tracekit - Firefox Tests', () => { }, }); }); + + it('should parse Firefox errors with `file` inside an identifier', () => { + const FIREFOX_FILE_IN_IDENTIFIER = { + stack: + 'us@https://www.random_website.com/vendor.d1cae9cfc9917df88de7.js:1:296021\n' + + 'detectChanges@https://www.random_website.com/vendor.d1cae9cfc9917df88de7.js:1:333807\n' + + 'handleProfileResult@https://www.random_website.com/main.4a4119c3cdfd10266d84.js:146:1018410\n', + fileName: 'https://www.random_website.com/main.4a4119c3cdfd10266d84.js', + lineNumber: 5529, + columnNumber: 16, + message: 'this.props.raw[this.state.dataSource].rows is undefined', + name: 'TypeError', + }; + + const stacktrace = exceptionFromError(parser, FIREFOX_FILE_IN_IDENTIFIER); + + expect(stacktrace).toEqual({ + stacktrace: { + frames: [ + { + colno: 1018410, + filename: 'https://www.random_website.com/main.4a4119c3cdfd10266d84.js', + function: 'handleProfileResult', + in_app: true, + lineno: 146, + }, + { + colno: 333807, + filename: 'https://www.random_website.com/vendor.d1cae9cfc9917df88de7.js', + function: 'detectChanges', + in_app: true, + lineno: 1, + }, + { + colno: 296021, + filename: 'https://www.random_website.com/vendor.d1cae9cfc9917df88de7.js', + function: 'us', + in_app: true, + lineno: 1, + }, + ], + }, + type: 'TypeError', + value: 'this.props.raw[this.state.dataSource].rows is undefined', + }); + }); }); From ee560ec19956583f08e6f39795bd724124700069 Mon Sep 17 00:00:00 2001 From: Onur Temizkan Date: Sun, 19 Dec 2021 16:11:03 +0000 Subject: [PATCH 2/5] Add integration tests for function identifiers. --- .../suites/stacktraces/init.js | 7 +++ .../subject.js | 27 +++++++++ .../test.ts | 55 +++++++++++++++++++ .../protocol_fn_identifiers/subject.js | 27 +++++++++ .../protocol_fn_identifiers/test.ts | 55 +++++++++++++++++++ .../regular_fn_identifiers/subject.js | 29 ++++++++++ .../regular_fn_identifiers/test.ts | 55 +++++++++++++++++++ .../suites/stacktraces/template.hbs | 11 ++++ 8 files changed, 266 insertions(+) create mode 100644 packages/integration-tests/suites/stacktraces/init.js create mode 100644 packages/integration-tests/suites/stacktraces/protocol_containing_fn_identifiers/subject.js create mode 100644 packages/integration-tests/suites/stacktraces/protocol_containing_fn_identifiers/test.ts create mode 100644 packages/integration-tests/suites/stacktraces/protocol_fn_identifiers/subject.js create mode 100644 packages/integration-tests/suites/stacktraces/protocol_fn_identifiers/test.ts create mode 100644 packages/integration-tests/suites/stacktraces/regular_fn_identifiers/subject.js create mode 100644 packages/integration-tests/suites/stacktraces/regular_fn_identifiers/test.ts create mode 100644 packages/integration-tests/suites/stacktraces/template.hbs diff --git a/packages/integration-tests/suites/stacktraces/init.js b/packages/integration-tests/suites/stacktraces/init.js new file mode 100644 index 000000000000..d8c94f36fdd0 --- /dev/null +++ b/packages/integration-tests/suites/stacktraces/init.js @@ -0,0 +1,7 @@ +import * as Sentry from '@sentry/browser'; + +window.Sentry = Sentry; + +Sentry.init({ + dsn: 'https://public@dsn.ingest.sentry.io/1337', +}); diff --git a/packages/integration-tests/suites/stacktraces/protocol_containing_fn_identifiers/subject.js b/packages/integration-tests/suites/stacktraces/protocol_containing_fn_identifiers/subject.js new file mode 100644 index 000000000000..b9223bc91ac0 --- /dev/null +++ b/packages/integration-tests/suites/stacktraces/protocol_containing_fn_identifiers/subject.js @@ -0,0 +1,27 @@ +function httpsCall() { + webpackDevServer(); +} + +const webpackDevServer = () => { + Response.httpCode(); +}; + +class Response { + constructor() {} + + static httpCode(params) { + throw new Error('test_err'); + } +} + +const decodeBlob = function() { + (function readFile() { + httpsCall(); + })(); +}; + +try { + decodeBlob(); +} catch (err) { + Sentry.captureException(err); +} diff --git a/packages/integration-tests/suites/stacktraces/protocol_containing_fn_identifiers/test.ts b/packages/integration-tests/suites/stacktraces/protocol_containing_fn_identifiers/test.ts new file mode 100644 index 000000000000..a803543ae781 --- /dev/null +++ b/packages/integration-tests/suites/stacktraces/protocol_containing_fn_identifiers/test.ts @@ -0,0 +1,55 @@ +import { expect } from '@playwright/test'; + +import { sentryTest } from '../../../utils/fixtures'; +import { getSentryRequest } from '../../../utils/helpers'; + +sentryTest( + 'should parse function identifiers that contain protocol names correctly', + async ({ getLocalTestPath, page, browserName }) => { + const url = await getLocalTestPath({ testDir: __dirname }); + + const eventData = await getSentryRequest(page, url); + + expect(eventData.exception?.values?.[0].stacktrace?.frames).toMatchObject( + browserName === 'chromium' + ? [ + { function: '?' }, + { function: '?' }, + { function: 'decodeBlob' }, + { function: 'readFile' }, + { function: 'httpsCall' }, + { function: 'webpackDevServer' }, + { function: 'Function.httpCode' }, + ] + : browserName === 'firefox' + ? [ + { function: '?' }, + { function: '?' }, + { function: 'decodeBlob' }, + { function: 'readFile' }, + { function: 'httpsCall' }, + { function: 'webpackDevServer' }, + { function: 'httpCode' }, + ] + : [ + { function: 'global code' }, + { function: '?' }, + { function: 'decodeBlob' }, + { function: 'readFile' }, + { function: 'httpsCall' }, + { function: 'webpackDevServer' }, + { function: 'httpCode' }, + ], + ); + }, +); + +sentryTest('should not add any part of the function identifier inside filename', async ({ getLocalTestPath, page }) => { + const url = await getLocalTestPath({ testDir: __dirname }); + + const eventData = await getSentryRequest(page, url); + + expect(eventData.exception?.values?.[0].stacktrace?.frames).toMatchObject( + Array(7).fill({ filename: expect.stringMatching(/^file:\/?/) }), + ); +}); diff --git a/packages/integration-tests/suites/stacktraces/protocol_fn_identifiers/subject.js b/packages/integration-tests/suites/stacktraces/protocol_fn_identifiers/subject.js new file mode 100644 index 000000000000..d7ca8d22e04c --- /dev/null +++ b/packages/integration-tests/suites/stacktraces/protocol_fn_identifiers/subject.js @@ -0,0 +1,27 @@ +function https() { + webpack(); +} + +const webpack = () => { + File.http(); +}; + +class File { + constructor() {} + + static http(params) { + throw new Error('test_err'); + } +} + +const blob = function() { + (function file() { + https(); + })(); +}; + +try { + blob(); +} catch (err) { + Sentry.captureException(err); +} diff --git a/packages/integration-tests/suites/stacktraces/protocol_fn_identifiers/test.ts b/packages/integration-tests/suites/stacktraces/protocol_fn_identifiers/test.ts new file mode 100644 index 000000000000..5274de415f07 --- /dev/null +++ b/packages/integration-tests/suites/stacktraces/protocol_fn_identifiers/test.ts @@ -0,0 +1,55 @@ +import { expect } from '@playwright/test'; + +import { sentryTest } from '../../../utils/fixtures'; +import { getSentryRequest } from '../../../utils/helpers'; + +sentryTest( + 'should parse function identifiers that are protocol names correctly', + async ({ getLocalTestPath, page, browserName }) => { + const url = await getLocalTestPath({ testDir: __dirname }); + + const eventData = await getSentryRequest(page, url); + + expect(eventData.exception?.values?.[0].stacktrace?.frames).toMatchObject( + browserName === 'chromium' + ? [ + { function: '?' }, + { function: '?' }, + { function: 'blob' }, + { function: 'file' }, + { function: 'https' }, + { function: 'webpack' }, + { function: 'Function.http' }, + ] + : browserName === 'firefox' + ? [ + { function: '?' }, + { function: '?' }, + { function: 'blob' }, + { function: 'file' }, + { function: 'https' }, + { function: 'webpack' }, + { function: 'http' }, + ] + : [ + { function: 'global code' }, + { function: '?' }, + { function: 'blob' }, + { function: 'file' }, + { function: 'https' }, + { function: 'webpack' }, + { function: 'http' }, + ], + ); + }, +); + +sentryTest('should not add any part of the function identifier inside filename', async ({ getLocalTestPath, page }) => { + const url = await getLocalTestPath({ testDir: __dirname }); + + const eventData = await getSentryRequest(page, url); + + expect(eventData.exception?.values?.[0].stacktrace?.frames).toMatchObject( + Array(7).fill({ filename: expect.stringMatching(/^file:\/?/) }), + ); +}); diff --git a/packages/integration-tests/suites/stacktraces/regular_fn_identifiers/subject.js b/packages/integration-tests/suites/stacktraces/regular_fn_identifiers/subject.js new file mode 100644 index 000000000000..ff63abc6f3ca --- /dev/null +++ b/packages/integration-tests/suites/stacktraces/regular_fn_identifiers/subject.js @@ -0,0 +1,29 @@ +function foo() { + bar(); +} + +const bar = () => { + Test.baz(); +}; + +class Test { + constructor() {} + + static baz(params) { + throw new Error('test_err'); + } +} + +const qux = function() { + (() => { + (function() { + foo(); + })(); + })(); +}; + +try { + qux(); +} catch (err) { + Sentry.captureException(err); +} diff --git a/packages/integration-tests/suites/stacktraces/regular_fn_identifiers/test.ts b/packages/integration-tests/suites/stacktraces/regular_fn_identifiers/test.ts new file mode 100644 index 000000000000..632eddb2cb97 --- /dev/null +++ b/packages/integration-tests/suites/stacktraces/regular_fn_identifiers/test.ts @@ -0,0 +1,55 @@ +import { expect } from '@playwright/test'; + +import { sentryTest } from '../../../utils/fixtures'; +import { getSentryRequest } from '../../../utils/helpers'; + +sentryTest('should parse function identifiers correctly', async ({ getLocalTestPath, page, browserName }) => { + const url = await getLocalTestPath({ testDir: __dirname }); + + const eventData = await getSentryRequest(page, url); + + expect(eventData.exception?.values?.[0].stacktrace?.frames).toMatchObject( + browserName === 'chromium' + ? [ + { function: '?' }, + { function: '?' }, + { function: 'qux' }, + { function: '?' }, + { function: '?' }, + { function: 'foo' }, + { function: 'bar' }, + { function: 'Function.baz' }, + ] + : browserName === 'firefox' + ? [ + { function: '?' }, + { function: '?' }, + { function: 'qux' }, + { function: 'qux/<' }, + { function: 'qux/ { + const url = await getLocalTestPath({ testDir: __dirname }); + + const eventData = await getSentryRequest(page, url); + + expect(eventData.exception?.values?.[0].stacktrace?.frames).toMatchObject( + Array(8).fill({ filename: expect.stringMatching(/^file:\/?/) }), + ); +}); diff --git a/packages/integration-tests/suites/stacktraces/template.hbs b/packages/integration-tests/suites/stacktraces/template.hbs new file mode 100644 index 000000000000..a28a09b7b485 --- /dev/null +++ b/packages/integration-tests/suites/stacktraces/template.hbs @@ -0,0 +1,11 @@ + + + + + + + + + + + From f6d32424db311e01e96a872cd5bcbf6565eddd4b Mon Sep 17 00:00:00 2001 From: Onur Temizkan Date: Sun, 19 Dec 2021 20:32:33 +0000 Subject: [PATCH 3/5] Add `runIn*` fixtures for browser-specific logic. --- .../test.ts | 69 ++++++++------- .../protocol_fn_identifiers/test.ts | 69 ++++++++------- .../regular_fn_identifiers/test.ts | 84 ++++++++++--------- packages/integration-tests/utils/fixtures.ts | 34 ++++++-- 4 files changed, 148 insertions(+), 108 deletions(-) diff --git a/packages/integration-tests/suites/stacktraces/protocol_containing_fn_identifiers/test.ts b/packages/integration-tests/suites/stacktraces/protocol_containing_fn_identifiers/test.ts index a803543ae781..9ade70dbd400 100644 --- a/packages/integration-tests/suites/stacktraces/protocol_containing_fn_identifiers/test.ts +++ b/packages/integration-tests/suites/stacktraces/protocol_containing_fn_identifiers/test.ts @@ -5,42 +5,47 @@ import { getSentryRequest } from '../../../utils/helpers'; sentryTest( 'should parse function identifiers that contain protocol names correctly', - async ({ getLocalTestPath, page, browserName }) => { + async ({ getLocalTestPath, page, runInChromium, runInFirefox, runInWebkit }) => { const url = await getLocalTestPath({ testDir: __dirname }); const eventData = await getSentryRequest(page, url); + const frames = eventData.exception?.values?.[0].stacktrace?.frames; - expect(eventData.exception?.values?.[0].stacktrace?.frames).toMatchObject( - browserName === 'chromium' - ? [ - { function: '?' }, - { function: '?' }, - { function: 'decodeBlob' }, - { function: 'readFile' }, - { function: 'httpsCall' }, - { function: 'webpackDevServer' }, - { function: 'Function.httpCode' }, - ] - : browserName === 'firefox' - ? [ - { function: '?' }, - { function: '?' }, - { function: 'decodeBlob' }, - { function: 'readFile' }, - { function: 'httpsCall' }, - { function: 'webpackDevServer' }, - { function: 'httpCode' }, - ] - : [ - { function: 'global code' }, - { function: '?' }, - { function: 'decodeBlob' }, - { function: 'readFile' }, - { function: 'httpsCall' }, - { function: 'webpackDevServer' }, - { function: 'httpCode' }, - ], - ); + runInChromium(() => { + expect(frames).toMatchObject([ + { function: '?' }, + { function: '?' }, + { function: 'decodeBlob' }, + { function: 'readFile' }, + { function: 'httpsCall' }, + { function: 'webpackDevServer' }, + { function: 'Function.httpCode' }, + ]); + }); + + runInFirefox(() => { + expect(frames).toMatchObject([ + { function: '?' }, + { function: '?' }, + { function: 'decodeBlob' }, + { function: 'readFile' }, + { function: 'httpsCall' }, + { function: 'webpackDevServer' }, + { function: 'httpCode' }, + ]); + }); + + runInWebkit(() => { + expect(frames).toMatchObject([ + { function: 'global code' }, + { function: '?' }, + { function: 'decodeBlob' }, + { function: 'readFile' }, + { function: 'httpsCall' }, + { function: 'webpackDevServer' }, + { function: 'httpCode' }, + ]); + }); }, ); diff --git a/packages/integration-tests/suites/stacktraces/protocol_fn_identifiers/test.ts b/packages/integration-tests/suites/stacktraces/protocol_fn_identifiers/test.ts index 5274de415f07..510e13c187bf 100644 --- a/packages/integration-tests/suites/stacktraces/protocol_fn_identifiers/test.ts +++ b/packages/integration-tests/suites/stacktraces/protocol_fn_identifiers/test.ts @@ -5,42 +5,47 @@ import { getSentryRequest } from '../../../utils/helpers'; sentryTest( 'should parse function identifiers that are protocol names correctly', - async ({ getLocalTestPath, page, browserName }) => { + async ({ getLocalTestPath, page, runInChromium, runInFirefox, runInWebkit }) => { const url = await getLocalTestPath({ testDir: __dirname }); const eventData = await getSentryRequest(page, url); + const frames = eventData.exception?.values?.[0].stacktrace?.frames; - expect(eventData.exception?.values?.[0].stacktrace?.frames).toMatchObject( - browserName === 'chromium' - ? [ - { function: '?' }, - { function: '?' }, - { function: 'blob' }, - { function: 'file' }, - { function: 'https' }, - { function: 'webpack' }, - { function: 'Function.http' }, - ] - : browserName === 'firefox' - ? [ - { function: '?' }, - { function: '?' }, - { function: 'blob' }, - { function: 'file' }, - { function: 'https' }, - { function: 'webpack' }, - { function: 'http' }, - ] - : [ - { function: 'global code' }, - { function: '?' }, - { function: 'blob' }, - { function: 'file' }, - { function: 'https' }, - { function: 'webpack' }, - { function: 'http' }, - ], - ); + runInChromium(() => { + expect(frames).toMatchObject([ + { function: '?' }, + { function: '?' }, + { function: 'blob' }, + { function: 'file' }, + { function: 'https' }, + { function: 'webpack' }, + { function: 'Function.http' }, + ]); + }); + + runInFirefox(() => { + expect(frames).toMatchObject([ + { function: '?' }, + { function: '?' }, + { function: 'blob' }, + { function: 'file' }, + { function: 'https' }, + { function: 'webpack' }, + { function: 'http' }, + ]); + }); + + runInWebkit(() => { + expect(frames).toMatchObject([ + { function: 'global code' }, + { function: '?' }, + { function: 'blob' }, + { function: 'file' }, + { function: 'https' }, + { function: 'webpack' }, + { function: 'http' }, + ]); + }); }, ); diff --git a/packages/integration-tests/suites/stacktraces/regular_fn_identifiers/test.ts b/packages/integration-tests/suites/stacktraces/regular_fn_identifiers/test.ts index 632eddb2cb97..2669018691fc 100644 --- a/packages/integration-tests/suites/stacktraces/regular_fn_identifiers/test.ts +++ b/packages/integration-tests/suites/stacktraces/regular_fn_identifiers/test.ts @@ -3,46 +3,54 @@ import { expect } from '@playwright/test'; import { sentryTest } from '../../../utils/fixtures'; import { getSentryRequest } from '../../../utils/helpers'; -sentryTest('should parse function identifiers correctly', async ({ getLocalTestPath, page, browserName }) => { - const url = await getLocalTestPath({ testDir: __dirname }); +sentryTest( + 'should parse function identifiers correctly', + async ({ getLocalTestPath, page, runInChromium, runInFirefox, runInWebkit }) => { + const url = await getLocalTestPath({ testDir: __dirname }); - const eventData = await getSentryRequest(page, url); + const eventData = await getSentryRequest(page, url); + const frames = eventData.exception?.values?.[0].stacktrace?.frames; - expect(eventData.exception?.values?.[0].stacktrace?.frames).toMatchObject( - browserName === 'chromium' - ? [ - { function: '?' }, - { function: '?' }, - { function: 'qux' }, - { function: '?' }, - { function: '?' }, - { function: 'foo' }, - { function: 'bar' }, - { function: 'Function.baz' }, - ] - : browserName === 'firefox' - ? [ - { function: '?' }, - { function: '?' }, - { function: 'qux' }, - { function: 'qux/<' }, - { function: 'qux/ { + expect(frames).toMatchObject([ + { function: '?' }, + { function: '?' }, + { function: 'qux' }, + { function: '?' }, + { function: '?' }, + { function: 'foo' }, + { function: 'bar' }, + { function: 'Function.baz' }, + ]); + }); + + runInFirefox(() => { + expect(frames).toMatchObject([ + { function: '?' }, + { function: '?' }, + { function: 'qux' }, + { function: 'qux/<' }, + { function: 'qux/ { + expect(frames).toMatchObject([ + { function: 'global code' }, + { function: '?' }, + { function: 'qux' }, + { function: '?' }, + { function: '?' }, + { function: 'foo' }, + { function: 'bar' }, + { function: 'baz' }, + ]); + }); + }, +); sentryTest('should not add any part of the function identifier inside filename', async ({ getLocalTestPath, page }) => { const url = await getLocalTestPath({ testDir: __dirname }); diff --git a/packages/integration-tests/utils/fixtures.ts b/packages/integration-tests/utils/fixtures.ts index 845a7637b177..3926bf1f9d74 100644 --- a/packages/integration-tests/utils/fixtures.ts +++ b/packages/integration-tests/utils/fixtures.ts @@ -1,3 +1,4 @@ +/* eslint-disable no-empty-pattern */ import { test as base } from '@playwright/test'; import fs from 'fs'; import path from 'path'; @@ -20,17 +21,20 @@ const getAsset = (assetDir: string, asset: string): string => { return `utils/defaults/${asset}`; }; -export type TestOptions = { - testDir: string; -}; - export type TestFixtures = { testDir: string; - getLocalTestPath: (options: TestOptions) => Promise; + getLocalTestPath: (options: { testDir: string }) => Promise; + runInChromium: (fn: (...args: unknown[]) => unknown, args?: unknown[]) => unknown; + runInFirefox: (fn: (...args: unknown[]) => unknown, args?: unknown[]) => unknown; + runInWebkit: (fn: (...args: unknown[]) => unknown, args?: unknown[]) => unknown; + runInSingleBrowser: ( + browser: 'chromium' | 'firefox' | 'webkit', + fn: (...args: unknown[]) => unknown, + args?: unknown[], + ) => unknown; }; const sentryTest = base.extend({ - // eslint-disable-next-line no-empty-pattern getLocalTestPath: ({}, use, testInfo) => { return use(async ({ testDir }) => { const pagePath = `file:///${path.resolve(testDir, './dist/index.html')}`; @@ -47,6 +51,24 @@ const sentryTest = base.extend({ return pagePath; }); }, + runInChromium: ({ runInSingleBrowser }, use) => { + return use((fn, args) => runInSingleBrowser('chromium', fn, args)); + }, + runInFirefox: ({ runInSingleBrowser }, use) => { + return use((fn, args) => runInSingleBrowser('firefox', fn, args)); + }, + runInWebkit: ({ runInSingleBrowser }, use) => { + return use((fn, args) => runInSingleBrowser('webkit', fn, args)); + }, + runInSingleBrowser: ({ browserName }, use) => { + return use((browser, fn, args = []) => { + if (browserName !== browser) { + return; + } + + return fn(...args); + }); + }, }); export { sentryTest }; From e44bce89ae74d8699fd966b2e87e29a8b168b810 Mon Sep 17 00:00:00 2001 From: Onur Temizkan Date: Fri, 29 Apr 2022 10:00:44 +0100 Subject: [PATCH 4/5] Use new Transports API in stacktrace integration tests. --- .../stacktraces/protocol_containing_fn_identifiers/test.ts | 7 ++++--- .../suites/stacktraces/protocol_fn_identifiers/test.ts | 7 ++++--- .../suites/stacktraces/regular_fn_identifiers/test.ts | 7 ++++--- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/packages/integration-tests/suites/stacktraces/protocol_containing_fn_identifiers/test.ts b/packages/integration-tests/suites/stacktraces/protocol_containing_fn_identifiers/test.ts index 9ade70dbd400..3dbe98286d78 100644 --- a/packages/integration-tests/suites/stacktraces/protocol_containing_fn_identifiers/test.ts +++ b/packages/integration-tests/suites/stacktraces/protocol_containing_fn_identifiers/test.ts @@ -1,14 +1,15 @@ import { expect } from '@playwright/test'; +import { Event } from '@sentry/types'; import { sentryTest } from '../../../utils/fixtures'; -import { getSentryRequest } from '../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest } from '../../../utils/helpers'; sentryTest( 'should parse function identifiers that contain protocol names correctly', async ({ getLocalTestPath, page, runInChromium, runInFirefox, runInWebkit }) => { const url = await getLocalTestPath({ testDir: __dirname }); - const eventData = await getSentryRequest(page, url); + const eventData = await getFirstSentryEnvelopeRequest(page, url); const frames = eventData.exception?.values?.[0].stacktrace?.frames; runInChromium(() => { @@ -52,7 +53,7 @@ sentryTest( sentryTest('should not add any part of the function identifier inside filename', async ({ getLocalTestPath, page }) => { const url = await getLocalTestPath({ testDir: __dirname }); - const eventData = await getSentryRequest(page, url); + const eventData = await getFirstSentryEnvelopeRequest(page, url); expect(eventData.exception?.values?.[0].stacktrace?.frames).toMatchObject( Array(7).fill({ filename: expect.stringMatching(/^file:\/?/) }), diff --git a/packages/integration-tests/suites/stacktraces/protocol_fn_identifiers/test.ts b/packages/integration-tests/suites/stacktraces/protocol_fn_identifiers/test.ts index 510e13c187bf..b9944395edb8 100644 --- a/packages/integration-tests/suites/stacktraces/protocol_fn_identifiers/test.ts +++ b/packages/integration-tests/suites/stacktraces/protocol_fn_identifiers/test.ts @@ -1,14 +1,15 @@ import { expect } from '@playwright/test'; +import { Event } from '@sentry/types'; import { sentryTest } from '../../../utils/fixtures'; -import { getSentryRequest } from '../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest } from '../../../utils/helpers'; sentryTest( 'should parse function identifiers that are protocol names correctly', async ({ getLocalTestPath, page, runInChromium, runInFirefox, runInWebkit }) => { const url = await getLocalTestPath({ testDir: __dirname }); - const eventData = await getSentryRequest(page, url); + const eventData = await getFirstSentryEnvelopeRequest(page, url); const frames = eventData.exception?.values?.[0].stacktrace?.frames; runInChromium(() => { @@ -52,7 +53,7 @@ sentryTest( sentryTest('should not add any part of the function identifier inside filename', async ({ getLocalTestPath, page }) => { const url = await getLocalTestPath({ testDir: __dirname }); - const eventData = await getSentryRequest(page, url); + const eventData = await getFirstSentryEnvelopeRequest(page, url); expect(eventData.exception?.values?.[0].stacktrace?.frames).toMatchObject( Array(7).fill({ filename: expect.stringMatching(/^file:\/?/) }), diff --git a/packages/integration-tests/suites/stacktraces/regular_fn_identifiers/test.ts b/packages/integration-tests/suites/stacktraces/regular_fn_identifiers/test.ts index 2669018691fc..1ad1ce4d2549 100644 --- a/packages/integration-tests/suites/stacktraces/regular_fn_identifiers/test.ts +++ b/packages/integration-tests/suites/stacktraces/regular_fn_identifiers/test.ts @@ -1,14 +1,15 @@ import { expect } from '@playwright/test'; +import { Event } from '@sentry/types'; import { sentryTest } from '../../../utils/fixtures'; -import { getSentryRequest } from '../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest } from '../../../utils/helpers'; sentryTest( 'should parse function identifiers correctly', async ({ getLocalTestPath, page, runInChromium, runInFirefox, runInWebkit }) => { const url = await getLocalTestPath({ testDir: __dirname }); - const eventData = await getSentryRequest(page, url); + const eventData = await getFirstSentryEnvelopeRequest(page, url); const frames = eventData.exception?.values?.[0].stacktrace?.frames; runInChromium(() => { @@ -55,7 +56,7 @@ sentryTest( sentryTest('should not add any part of the function identifier inside filename', async ({ getLocalTestPath, page }) => { const url = await getLocalTestPath({ testDir: __dirname }); - const eventData = await getSentryRequest(page, url); + const eventData = await getFirstSentryEnvelopeRequest(page, url); expect(eventData.exception?.values?.[0].stacktrace?.frames).toMatchObject( Array(8).fill({ filename: expect.stringMatching(/^file:\/?/) }), From 61ea3f67626bc51dd907fe06731c72aac281c801 Mon Sep 17 00:00:00 2001 From: Onur Temizkan Date: Fri, 29 Apr 2022 10:03:58 +0100 Subject: [PATCH 5/5] Update packages/integration-tests/suites/stacktraces/protocol_containing_fn_identifiers/test.ts Co-authored-by: Katie Byers --- .../protocol_containing_fn_identifiers/test.ts | 18 +++++++++++------- .../protocol_fn_identifiers/test.ts | 17 ++++++++++------- .../stacktraces/regular_fn_identifiers/test.ts | 18 +++++++++++------- 3 files changed, 32 insertions(+), 21 deletions(-) diff --git a/packages/integration-tests/suites/stacktraces/protocol_containing_fn_identifiers/test.ts b/packages/integration-tests/suites/stacktraces/protocol_containing_fn_identifiers/test.ts index 3dbe98286d78..191dcdd19385 100644 --- a/packages/integration-tests/suites/stacktraces/protocol_containing_fn_identifiers/test.ts +++ b/packages/integration-tests/suites/stacktraces/protocol_containing_fn_identifiers/test.ts @@ -50,12 +50,16 @@ sentryTest( }, ); -sentryTest('should not add any part of the function identifier inside filename', async ({ getLocalTestPath, page }) => { - const url = await getLocalTestPath({ testDir: __dirname }); +sentryTest( + 'should not add any part of the function identifier to beginning of filename', + async ({ getLocalTestPath, page }) => { + const url = await getLocalTestPath({ testDir: __dirname }); - const eventData = await getFirstSentryEnvelopeRequest(page, url); + const eventData = await getFirstSentryEnvelopeRequest(page, url); - expect(eventData.exception?.values?.[0].stacktrace?.frames).toMatchObject( - Array(7).fill({ filename: expect.stringMatching(/^file:\/?/) }), - ); -}); + expect(eventData.exception?.values?.[0].stacktrace?.frames).toMatchObject( + // specifically, we're trying to avoid values like `Blob@file://path/to/file` in frames with function names like `makeBlob` + Array(7).fill({ filename: expect.stringMatching(/^file:\/?/) }), + ); + }, +); diff --git a/packages/integration-tests/suites/stacktraces/protocol_fn_identifiers/test.ts b/packages/integration-tests/suites/stacktraces/protocol_fn_identifiers/test.ts index b9944395edb8..1d09d68f9f08 100644 --- a/packages/integration-tests/suites/stacktraces/protocol_fn_identifiers/test.ts +++ b/packages/integration-tests/suites/stacktraces/protocol_fn_identifiers/test.ts @@ -50,12 +50,15 @@ sentryTest( }, ); -sentryTest('should not add any part of the function identifier inside filename', async ({ getLocalTestPath, page }) => { - const url = await getLocalTestPath({ testDir: __dirname }); +sentryTest( + 'should not add any part of the function identifier to beginning of filename', + async ({ getLocalTestPath, page }) => { + const url = await getLocalTestPath({ testDir: __dirname }); - const eventData = await getFirstSentryEnvelopeRequest(page, url); + const eventData = await getFirstSentryEnvelopeRequest(page, url); - expect(eventData.exception?.values?.[0].stacktrace?.frames).toMatchObject( - Array(7).fill({ filename: expect.stringMatching(/^file:\/?/) }), - ); -}); + expect(eventData.exception?.values?.[0].stacktrace?.frames).toMatchObject( + Array(7).fill({ filename: expect.stringMatching(/^file:\/?/) }), + ); + }, +); diff --git a/packages/integration-tests/suites/stacktraces/regular_fn_identifiers/test.ts b/packages/integration-tests/suites/stacktraces/regular_fn_identifiers/test.ts index 1ad1ce4d2549..986de9c44bc9 100644 --- a/packages/integration-tests/suites/stacktraces/regular_fn_identifiers/test.ts +++ b/packages/integration-tests/suites/stacktraces/regular_fn_identifiers/test.ts @@ -53,12 +53,16 @@ sentryTest( }, ); -sentryTest('should not add any part of the function identifier inside filename', async ({ getLocalTestPath, page }) => { - const url = await getLocalTestPath({ testDir: __dirname }); +sentryTest( + 'should not add any part of the function identifier to beginning of filename', + async ({ getLocalTestPath, page }) => { + const url = await getLocalTestPath({ testDir: __dirname }); - const eventData = await getFirstSentryEnvelopeRequest(page, url); + const eventData = await getFirstSentryEnvelopeRequest(page, url); - expect(eventData.exception?.values?.[0].stacktrace?.frames).toMatchObject( - Array(8).fill({ filename: expect.stringMatching(/^file:\/?/) }), - ); -}); + expect(eventData.exception?.values?.[0].stacktrace?.frames).toMatchObject( + // specifically, we're trying to avoid values like `Blob@file://path/to/file` in frames with function names like `makeBlob` + Array(8).fill({ filename: expect.stringMatching(/^file:\/?/) }), + ); + }, +);