From b830f87dfe18aae0ed99f65a47840010a16f3ed1 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Fri, 24 Mar 2023 11:55:20 +0100 Subject: [PATCH 01/50] ci: Fix CodeQL by skipping tsconfig.json (#7607) --- .github/codeql/codeql-config.yml | 4 ++++ .github/workflows/codeql-analysis.yml | 1 + 2 files changed, 5 insertions(+) create mode 100644 .github/codeql/codeql-config.yml diff --git a/.github/codeql/codeql-config.yml b/.github/codeql/codeql-config.yml new file mode 100644 index 000000000000..d3ccaa70d705 --- /dev/null +++ b/.github/codeql/codeql-config.yml @@ -0,0 +1,4 @@ +paths-ignore: + # Our tsconfig files contain comments, which CodeQL complains about + - '**/tsconfig.json' + - '**/tsconfig.*.json' diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 0f6954bc53eb..db6ba7c55ac5 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -50,6 +50,7 @@ jobs: - name: Initialize CodeQL uses: github/codeql-action/init@v2 with: + config-file: ./.github/codeql/codeql-config.yml languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. # By default, queries listed here will override any specified in a config file. From dce26c91c54d526fee9cf65caf72ef71b453f86f Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Fri, 24 Mar 2023 12:15:49 +0100 Subject: [PATCH 02/50] build(tracing-internal): Remove circular dependency (#7608) No need to depend on @sentry/browser as devDependency, which Nx complains about. I copied the TestClient from Replay, where we had the same issue. --- packages/tracing-internal/package.json | 1 - .../test/browser/backgroundtab.test.ts | 4 +- .../test/browser/browsertracing.test.ts | 9 ++-- .../test/browser/request.test.ts | 4 +- .../tracing-internal/test/utils/TestClient.ts | 44 +++++++++++++++++++ 5 files changed, 53 insertions(+), 9 deletions(-) create mode 100644 packages/tracing-internal/test/utils/TestClient.ts diff --git a/packages/tracing-internal/package.json b/packages/tracing-internal/package.json index 54aec71caa3b..6e88e16aba29 100644 --- a/packages/tracing-internal/package.json +++ b/packages/tracing-internal/package.json @@ -22,7 +22,6 @@ "tslib": "^1.9.3" }, "devDependencies": { - "@sentry/browser": "7.45.0", "@types/express": "^4.17.14" }, "scripts": { diff --git a/packages/tracing-internal/test/browser/backgroundtab.test.ts b/packages/tracing-internal/test/browser/backgroundtab.test.ts index 2c4ca381df3b..0826d5f72884 100644 --- a/packages/tracing-internal/test/browser/backgroundtab.test.ts +++ b/packages/tracing-internal/test/browser/backgroundtab.test.ts @@ -1,10 +1,10 @@ -import { BrowserClient } from '@sentry/browser'; import { Hub, makeMain } from '@sentry/core'; import { JSDOM } from 'jsdom'; import { addExtensionMethods } from '../../../tracing/src'; import { getDefaultBrowserClientOptions } from '../../../tracing/test/testutils'; import { registerBackgroundTabDetection } from '../../src/browser/backgroundtab'; +import { TestClient } from '../utils/TestClient'; describe('registerBackgroundTabDetection', () => { let events: Record = {}; @@ -15,7 +15,7 @@ describe('registerBackgroundTabDetection', () => { global.document = dom.window.document; const options = getDefaultBrowserClientOptions({ tracesSampleRate: 1 }); - hub = new Hub(new BrowserClient(options)); + hub = new Hub(new TestClient(options)); makeMain(hub); // If we do not add extension methods, invoking hub.startTransaction returns undefined diff --git a/packages/tracing-internal/test/browser/browsertracing.test.ts b/packages/tracing-internal/test/browser/browsertracing.test.ts index e599648c2930..01e5f8990e9b 100644 --- a/packages/tracing-internal/test/browser/browsertracing.test.ts +++ b/packages/tracing-internal/test/browser/browsertracing.test.ts @@ -1,4 +1,3 @@ -import { BrowserClient, WINDOW } from '@sentry/browser'; import { Hub, makeMain, TRACING_DEFAULTS } from '@sentry/core'; import * as hubExtensions from '@sentry/core'; import type { BaseTransportOptions, ClientOptions, DsnComponents } from '@sentry/types'; @@ -12,6 +11,8 @@ import type { BrowserTracingOptions } from '../../src/browser/browsertracing'; import { BrowserTracing, getMetaContent } from '../../src/browser/browsertracing'; import { defaultRequestInstrumentationOptions } from '../../src/browser/request'; import { instrumentRoutingWithDefaults } from '../../src/browser/router'; +import { WINDOW } from '../../src/browser/types'; +import { TestClient } from '../utils/TestClient'; let mockChangeHistory: ({ to, from }: { to: string; from?: string }) => void = () => undefined; @@ -61,7 +62,7 @@ describe('BrowserTracing', () => { beforeEach(() => { jest.useFakeTimers(); const options = getDefaultBrowserClientOptions({ tracesSampleRate: 1 }); - hub = new Hub(new BrowserClient(options)); + hub = new Hub(new TestClient(options)); makeMain(hub); document.head.innerHTML = ''; @@ -599,7 +600,7 @@ describe('BrowserTracing', () => { const tracesSampler = jest.fn(); const options = getDefaultBrowserClientOptions({ tracesSampler }); - hub.bindClient(new BrowserClient(options)); + hub.bindClient(new TestClient(options)); // setting up the BrowserTracing integration automatically starts a pageload transaction createBrowserTracing(true); @@ -616,7 +617,7 @@ describe('BrowserTracing', () => { const tracesSampler = jest.fn(); const options = getDefaultBrowserClientOptions({ tracesSampler }); - hub.bindClient(new BrowserClient(options)); + hub.bindClient(new TestClient(options)); // setting up the BrowserTracing integration normally automatically starts a pageload transaction, but that's not // what we're testing here createBrowserTracing(true, { startTransactionOnPageLoad: false }); diff --git a/packages/tracing-internal/test/browser/request.test.ts b/packages/tracing-internal/test/browser/request.test.ts index 4ca971a4947c..5e89ac99f451 100644 --- a/packages/tracing-internal/test/browser/request.test.ts +++ b/packages/tracing-internal/test/browser/request.test.ts @@ -1,4 +1,3 @@ -import { BrowserClient } from '@sentry/browser'; import * as sentryCore from '@sentry/core'; import * as utils from '@sentry/utils'; @@ -7,6 +6,7 @@ import { addExtensionMethods, Span, spanStatusfromHttpCode } from '../../../trac import { getDefaultBrowserClientOptions } from '../../../tracing/test/testutils'; import type { FetchData, XHRData } from '../../src/browser/request'; import { fetchCallback, instrumentOutgoingRequests, shouldAttachHeaders, xhrCallback } from '../../src/browser/request'; +import { TestClient } from '../utils/TestClient'; beforeAll(() => { addExtensionMethods(); @@ -54,7 +54,7 @@ describe('callbacks', () => { beforeAll(() => { const options = getDefaultBrowserClientOptions({ tracesSampleRate: 1 }); - hub = new sentryCore.Hub(new BrowserClient(options)); + hub = new sentryCore.Hub(new TestClient(options)); sentryCore.makeMain(hub); }); diff --git a/packages/tracing-internal/test/utils/TestClient.ts b/packages/tracing-internal/test/utils/TestClient.ts new file mode 100644 index 000000000000..ad39b82084a9 --- /dev/null +++ b/packages/tracing-internal/test/utils/TestClient.ts @@ -0,0 +1,44 @@ +import { BaseClient, createTransport, initAndBind } from '@sentry/core'; +import type { BrowserClientReplayOptions, ClientOptions, Event, SeverityLevel } from '@sentry/types'; +import { resolvedSyncPromise } from '@sentry/utils'; + +export interface TestClientOptions extends ClientOptions, BrowserClientReplayOptions {} + +export class TestClient extends BaseClient { + public constructor(options: TestClientOptions) { + super(options); + } + + public eventFromException(exception: any): PromiseLike { + return resolvedSyncPromise({ + exception: { + values: [ + { + /* eslint-disable @typescript-eslint/no-unsafe-member-access */ + type: exception.name, + value: exception.message, + /* eslint-enable @typescript-eslint/no-unsafe-member-access */ + }, + ], + }, + }); + } + + public eventFromMessage(message: string, level: SeverityLevel = 'info'): PromiseLike { + return resolvedSyncPromise({ message, level }); + } +} + +export function init(options: TestClientOptions): void { + initAndBind(TestClient, options); +} + +export function getDefaultClientOptions(options: Partial = {}): ClientOptions { + return { + integrations: [], + dsn: 'https://username@domain/123', + transport: () => createTransport({ recordDroppedEvent: () => undefined }, _ => resolvedSyncPromise({})), + stackParser: () => [], + ...options, + }; +} From 11704a3271411842e178f07e424d427ca42d01b8 Mon Sep 17 00:00:00 2001 From: Abhijeet Prasad Date: Fri, 24 Mar 2023 13:03:49 +0100 Subject: [PATCH 03/50] feat(sveltekit): Add meta tag for backend -> frontend (#7574) --- packages/sveltekit/src/server/handle.ts | 21 +++++- packages/sveltekit/test/server/handle.test.ts | 71 +++++++++++++++---- 2 files changed, 75 insertions(+), 17 deletions(-) diff --git a/packages/sveltekit/src/server/handle.ts b/packages/sveltekit/src/server/handle.ts index aab69c085048..8020a35c7377 100644 --- a/packages/sveltekit/src/server/handle.ts +++ b/packages/sveltekit/src/server/handle.ts @@ -1,14 +1,15 @@ /* eslint-disable @sentry-internal/sdk/no-optional-chaining */ import type { Span } from '@sentry/core'; -import { trace } from '@sentry/core'; +import { getActiveTransaction, trace } from '@sentry/core'; import { captureException } from '@sentry/node'; import { addExceptionMechanism, baggageHeaderToDynamicSamplingContext, + dynamicSamplingContextToSentryBaggageHeader, extractTraceparentData, objectify, } from '@sentry/utils'; -import type { Handle } from '@sveltejs/kit'; +import type { Handle, ResolveOptions } from '@sveltejs/kit'; import * as domain from 'domain'; function sendErrorToSentry(e: unknown): unknown { @@ -34,6 +35,20 @@ function sendErrorToSentry(e: unknown): unknown { return objectifiedErr; } +export const transformPageChunk: NonNullable = ({ html }) => { + const transaction = getActiveTransaction(); + if (transaction) { + const traceparentData = transaction.toTraceparent(); + const dynamicSamplingContext = dynamicSamplingContextToSentryBaggageHeader(transaction.getDynamicSamplingContext()); + const content = ` + + %sveltekit.head%`; + return html.replace('%sveltekit.head%', content); + } + + return html; +}; + /** * A SvelteKit handle function that wraps the request for Sentry error and * performance monitoring. @@ -68,7 +83,7 @@ export const sentryHandle: Handle = ({ event, resolve }) => { }, }, async (span?: Span) => { - const res = await resolve(event); + const res = await resolve(event, { transformPageChunk }); if (span) { span.setHttpStatus(res.status); } diff --git a/packages/sveltekit/test/server/handle.test.ts b/packages/sveltekit/test/server/handle.test.ts index cf17b56aaa90..f260d2daf310 100644 --- a/packages/sveltekit/test/server/handle.test.ts +++ b/packages/sveltekit/test/server/handle.test.ts @@ -4,7 +4,7 @@ import type { Transaction } from '@sentry/types'; import type { Handle } from '@sveltejs/kit'; import { vi } from 'vitest'; -import { sentryHandle } from '../../src/server/handle'; +import { sentryHandle, transformPageChunk } from '../../src/server/handle'; import { getDefaultNodeClientOptions } from '../utils'; const mockCaptureException = vi.fn(); @@ -94,22 +94,22 @@ function resolve(type: Type, isError: boolean): Parameters[0]['resolve'] let hub: Hub; let client: NodeClient; -describe('handleSentry', () => { - beforeAll(() => { - addTracingExtensions(); - }); +beforeAll(() => { + addTracingExtensions(); +}); - beforeEach(() => { - mockScope = new Scope(); - const options = getDefaultNodeClientOptions({ tracesSampleRate: 1.0 }); - client = new NodeClient(options); - hub = new Hub(client); - makeMain(hub); +beforeEach(() => { + mockScope = new Scope(); + const options = getDefaultNodeClientOptions({ tracesSampleRate: 1.0 }); + client = new NodeClient(options); + hub = new Hub(client); + makeMain(hub); - mockCaptureException.mockClear(); - mockAddExceptionMechanism.mockClear(); - }); + mockCaptureException.mockClear(); + mockAddExceptionMechanism.mockClear(); +}); +describe('handleSentry', () => { describe.each([ // isSync, isError, expectedResponse [Type.Sync, true, undefined], @@ -247,5 +247,48 @@ describe('handleSentry', () => { ); } }); + + it('calls `transformPageChunk`', async () => { + const mockResolve = vi.fn().mockImplementation(resolve(type, isError)); + const event = mockEvent(); + try { + await sentryHandle({ event, resolve: mockResolve }); + } catch (e) { + expect(e).toBeInstanceOf(Error); + expect(e.message).toEqual(type); + } + + expect(mockResolve).toHaveBeenCalledTimes(1); + expect(mockResolve).toHaveBeenCalledWith(event, { transformPageChunk: expect.any(Function) }); + }); + }); +}); + +describe('transformPageChunk', () => { + const html = ` + + + + + + %sveltekit.head% + + +
%sveltekit.body%
+ + `; + + it('does not add meta tags if no active transaction', () => { + const transformed = transformPageChunk({ html, done: true }); + expect(transformed).toEqual(html); + }); + + it('adds meta tags if there is an active transaction', () => { + const transaction = hub.startTransaction({ name: 'test' }); + hub.getScope().setSpan(transaction); + const transformed = transformPageChunk({ html, done: true }) as string; + + expect(transformed.includes(' Date: Fri, 24 Mar 2023 14:10:05 +0100 Subject: [PATCH 04/50] build: Remove `test/tsconfig.json` files (#7606) --- packages/angular/test/tsconfig.json | 8 -------- packages/browser/test/tsconfig.json | 8 -------- packages/core/test/tsconfig.json | 8 -------- packages/gatsby/test/tsconfig.json | 8 -------- packages/hub/test/tsconfig.json | 8 -------- packages/integrations/test/tsconfig.json | 8 -------- packages/nextjs/test/tsconfig.json | 3 --- packages/node-integration-tests/suites/tsconfig.json | 8 -------- packages/node/test/tsconfig.json | 8 -------- packages/react/test/tsconfig.json | 8 -------- packages/remix/test/tsconfig.json | 8 -------- packages/replay-worker/test/tsconfig.json | 7 ------- packages/replay/test/tsconfig.json | 7 ------- packages/serverless/test/tsconfig.json | 8 -------- packages/svelte/test/tsconfig.json | 8 -------- packages/tracing/test/tsconfig.json | 7 ------- packages/utils/test/tsconfig.json | 8 -------- packages/vue/test/tsconfig.json | 8 -------- tsconfig-templates/test/tsconfig.json | 8 -------- 19 files changed, 144 deletions(-) delete mode 100644 packages/angular/test/tsconfig.json delete mode 100644 packages/browser/test/tsconfig.json delete mode 100644 packages/core/test/tsconfig.json delete mode 100644 packages/gatsby/test/tsconfig.json delete mode 100644 packages/hub/test/tsconfig.json delete mode 100644 packages/integrations/test/tsconfig.json delete mode 100644 packages/node-integration-tests/suites/tsconfig.json delete mode 100644 packages/node/test/tsconfig.json delete mode 100644 packages/react/test/tsconfig.json delete mode 100644 packages/remix/test/tsconfig.json delete mode 100644 packages/replay-worker/test/tsconfig.json delete mode 100644 packages/replay/test/tsconfig.json delete mode 100644 packages/serverless/test/tsconfig.json delete mode 100644 packages/svelte/test/tsconfig.json delete mode 100644 packages/tracing/test/tsconfig.json delete mode 100644 packages/utils/test/tsconfig.json delete mode 100644 packages/vue/test/tsconfig.json delete mode 100644 tsconfig-templates/test/tsconfig.json diff --git a/packages/angular/test/tsconfig.json b/packages/angular/test/tsconfig.json deleted file mode 100644 index 074ceb45a9db..000000000000 --- a/packages/angular/test/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -// TODO Once https://github.com/microsoft/TypeScript/issues/33094 is done (if it ever is), this file can disappear, as -// it's purely a placeholder to satisfy VSCode. - -{ - "extends": "../tsconfig.test.json", - - "include": ["./**/*"] -} diff --git a/packages/browser/test/tsconfig.json b/packages/browser/test/tsconfig.json deleted file mode 100644 index 074ceb45a9db..000000000000 --- a/packages/browser/test/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -// TODO Once https://github.com/microsoft/TypeScript/issues/33094 is done (if it ever is), this file can disappear, as -// it's purely a placeholder to satisfy VSCode. - -{ - "extends": "../tsconfig.test.json", - - "include": ["./**/*"] -} diff --git a/packages/core/test/tsconfig.json b/packages/core/test/tsconfig.json deleted file mode 100644 index 074ceb45a9db..000000000000 --- a/packages/core/test/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -// TODO Once https://github.com/microsoft/TypeScript/issues/33094 is done (if it ever is), this file can disappear, as -// it's purely a placeholder to satisfy VSCode. - -{ - "extends": "../tsconfig.test.json", - - "include": ["./**/*"] -} diff --git a/packages/gatsby/test/tsconfig.json b/packages/gatsby/test/tsconfig.json deleted file mode 100644 index 074ceb45a9db..000000000000 --- a/packages/gatsby/test/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -// TODO Once https://github.com/microsoft/TypeScript/issues/33094 is done (if it ever is), this file can disappear, as -// it's purely a placeholder to satisfy VSCode. - -{ - "extends": "../tsconfig.test.json", - - "include": ["./**/*"] -} diff --git a/packages/hub/test/tsconfig.json b/packages/hub/test/tsconfig.json deleted file mode 100644 index 074ceb45a9db..000000000000 --- a/packages/hub/test/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -// TODO Once https://github.com/microsoft/TypeScript/issues/33094 is done (if it ever is), this file can disappear, as -// it's purely a placeholder to satisfy VSCode. - -{ - "extends": "../tsconfig.test.json", - - "include": ["./**/*"] -} diff --git a/packages/integrations/test/tsconfig.json b/packages/integrations/test/tsconfig.json deleted file mode 100644 index c4023463fcbc..000000000000 --- a/packages/integrations/test/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -// TODO Once https://github.com/microsoft/TypeScript/issues/33094 is done (if it ever is), this file can disappear, as -// it's purely a placeholder to satisfy VSCode. - -{ - "extends": "../tsconfig.test.json", - - "include": ["./**/*", "../../replay/test/unit/coreHandlers/extendednetworkbreadcrumbs.test.ts"] -} diff --git a/packages/nextjs/test/tsconfig.json b/packages/nextjs/test/tsconfig.json index fd214f0667a5..5c0c9dfa01bb 100644 --- a/packages/nextjs/test/tsconfig.json +++ b/packages/nextjs/test/tsconfig.json @@ -1,6 +1,3 @@ -// TODO Once https://github.com/microsoft/TypeScript/issues/33094 is done (if it ever is), this file can disappear, as -// it's purely a placeholder to satisfy VSCode. - { "extends": "../tsconfig.test.json", diff --git a/packages/node-integration-tests/suites/tsconfig.json b/packages/node-integration-tests/suites/tsconfig.json deleted file mode 100644 index 074ceb45a9db..000000000000 --- a/packages/node-integration-tests/suites/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -// TODO Once https://github.com/microsoft/TypeScript/issues/33094 is done (if it ever is), this file can disappear, as -// it's purely a placeholder to satisfy VSCode. - -{ - "extends": "../tsconfig.test.json", - - "include": ["./**/*"] -} diff --git a/packages/node/test/tsconfig.json b/packages/node/test/tsconfig.json deleted file mode 100644 index 074ceb45a9db..000000000000 --- a/packages/node/test/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -// TODO Once https://github.com/microsoft/TypeScript/issues/33094 is done (if it ever is), this file can disappear, as -// it's purely a placeholder to satisfy VSCode. - -{ - "extends": "../tsconfig.test.json", - - "include": ["./**/*"] -} diff --git a/packages/react/test/tsconfig.json b/packages/react/test/tsconfig.json deleted file mode 100644 index 074ceb45a9db..000000000000 --- a/packages/react/test/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -// TODO Once https://github.com/microsoft/TypeScript/issues/33094 is done (if it ever is), this file can disappear, as -// it's purely a placeholder to satisfy VSCode. - -{ - "extends": "../tsconfig.test.json", - - "include": ["./**/*"] -} diff --git a/packages/remix/test/tsconfig.json b/packages/remix/test/tsconfig.json deleted file mode 100644 index 074ceb45a9db..000000000000 --- a/packages/remix/test/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -// TODO Once https://github.com/microsoft/TypeScript/issues/33094 is done (if it ever is), this file can disappear, as -// it's purely a placeholder to satisfy VSCode. - -{ - "extends": "../tsconfig.test.json", - - "include": ["./**/*"] -} diff --git a/packages/replay-worker/test/tsconfig.json b/packages/replay-worker/test/tsconfig.json deleted file mode 100644 index 6c6ff4423fde..000000000000 --- a/packages/replay-worker/test/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -// TODO Once https://github.com/microsoft/TypeScript/issues/33094 is done (if it ever is), this file can disappear, as -// it's purely a placeholder to satisfy VSCode. -{ - "extends": "../tsconfig.test.json", - - "include": ["./**/*"] -} diff --git a/packages/replay/test/tsconfig.json b/packages/replay/test/tsconfig.json deleted file mode 100644 index 6c6ff4423fde..000000000000 --- a/packages/replay/test/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -// TODO Once https://github.com/microsoft/TypeScript/issues/33094 is done (if it ever is), this file can disappear, as -// it's purely a placeholder to satisfy VSCode. -{ - "extends": "../tsconfig.test.json", - - "include": ["./**/*"] -} diff --git a/packages/serverless/test/tsconfig.json b/packages/serverless/test/tsconfig.json deleted file mode 100644 index 074ceb45a9db..000000000000 --- a/packages/serverless/test/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -// TODO Once https://github.com/microsoft/TypeScript/issues/33094 is done (if it ever is), this file can disappear, as -// it's purely a placeholder to satisfy VSCode. - -{ - "extends": "../tsconfig.test.json", - - "include": ["./**/*"] -} diff --git a/packages/svelte/test/tsconfig.json b/packages/svelte/test/tsconfig.json deleted file mode 100644 index 074ceb45a9db..000000000000 --- a/packages/svelte/test/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -// TODO Once https://github.com/microsoft/TypeScript/issues/33094 is done (if it ever is), this file can disappear, as -// it's purely a placeholder to satisfy VSCode. - -{ - "extends": "../tsconfig.test.json", - - "include": ["./**/*"] -} diff --git a/packages/tracing/test/tsconfig.json b/packages/tracing/test/tsconfig.json deleted file mode 100644 index 6c6ff4423fde..000000000000 --- a/packages/tracing/test/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -// TODO Once https://github.com/microsoft/TypeScript/issues/33094 is done (if it ever is), this file can disappear, as -// it's purely a placeholder to satisfy VSCode. -{ - "extends": "../tsconfig.test.json", - - "include": ["./**/*"] -} diff --git a/packages/utils/test/tsconfig.json b/packages/utils/test/tsconfig.json deleted file mode 100644 index 074ceb45a9db..000000000000 --- a/packages/utils/test/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -// TODO Once https://github.com/microsoft/TypeScript/issues/33094 is done (if it ever is), this file can disappear, as -// it's purely a placeholder to satisfy VSCode. - -{ - "extends": "../tsconfig.test.json", - - "include": ["./**/*"] -} diff --git a/packages/vue/test/tsconfig.json b/packages/vue/test/tsconfig.json deleted file mode 100644 index 074ceb45a9db..000000000000 --- a/packages/vue/test/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -// TODO Once https://github.com/microsoft/TypeScript/issues/33094 is done (if it ever is), this file can disappear, as -// it's purely a placeholder to satisfy VSCode. - -{ - "extends": "../tsconfig.test.json", - - "include": ["./**/*"] -} diff --git a/tsconfig-templates/test/tsconfig.json b/tsconfig-templates/test/tsconfig.json deleted file mode 100644 index 074ceb45a9db..000000000000 --- a/tsconfig-templates/test/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -// TODO Once https://github.com/microsoft/TypeScript/issues/33094 is done (if it ever is), this file can disappear, as -// it's purely a placeholder to satisfy VSCode. - -{ - "extends": "../tsconfig.test.json", - - "include": ["./**/*"] -} From a2103f37794740573f6fce0f549e24bd06d08cbb Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Fri, 24 Mar 2023 14:11:29 +0100 Subject: [PATCH 05/50] feat(replay): Capture replay mutation breadcrumbs & add experiment (#7568) --- .../largeMutations/defaultOptions/init.js | 16 +++++ .../defaultOptions/template.html | 41 +++++++++++ .../largeMutations/defaultOptions/test.ts | 67 ++++++++++++++++++ .../largeMutations/mutationLimit/init.js | 20 ++++++ .../mutationLimit/template.html | 41 +++++++++++ .../largeMutations/mutationLimit/test.ts | 69 +++++++++++++++++++ packages/replay/src/replay.ts | 53 +++++++++----- packages/replay/src/types.ts | 3 +- 8 files changed, 290 insertions(+), 20 deletions(-) create mode 100644 packages/browser-integration-tests/suites/replay/largeMutations/defaultOptions/init.js create mode 100644 packages/browser-integration-tests/suites/replay/largeMutations/defaultOptions/template.html create mode 100644 packages/browser-integration-tests/suites/replay/largeMutations/defaultOptions/test.ts create mode 100644 packages/browser-integration-tests/suites/replay/largeMutations/mutationLimit/init.js create mode 100644 packages/browser-integration-tests/suites/replay/largeMutations/mutationLimit/template.html create mode 100644 packages/browser-integration-tests/suites/replay/largeMutations/mutationLimit/test.ts diff --git a/packages/browser-integration-tests/suites/replay/largeMutations/defaultOptions/init.js b/packages/browser-integration-tests/suites/replay/largeMutations/defaultOptions/init.js new file mode 100644 index 000000000000..f64b8fff4e50 --- /dev/null +++ b/packages/browser-integration-tests/suites/replay/largeMutations/defaultOptions/init.js @@ -0,0 +1,16 @@ +import * as Sentry from '@sentry/browser'; + +window.Sentry = Sentry; +window.Replay = new Sentry.Replay({ + flushMinDelay: 500, + flushMaxDelay: 500, +}); + +Sentry.init({ + dsn: 'https://public@dsn.ingest.sentry.io/1337', + sampleRate: 0, + replaysSessionSampleRate: 1.0, + replaysOnErrorSampleRate: 0.0, + + integrations: [window.Replay], +}); diff --git a/packages/browser-integration-tests/suites/replay/largeMutations/defaultOptions/template.html b/packages/browser-integration-tests/suites/replay/largeMutations/defaultOptions/template.html new file mode 100644 index 000000000000..331a03a58b92 --- /dev/null +++ b/packages/browser-integration-tests/suites/replay/largeMutations/defaultOptions/template.html @@ -0,0 +1,41 @@ + + + + + + + + + +
    + + + + diff --git a/packages/browser-integration-tests/suites/replay/largeMutations/defaultOptions/test.ts b/packages/browser-integration-tests/suites/replay/largeMutations/defaultOptions/test.ts new file mode 100644 index 000000000000..29d0f3ada164 --- /dev/null +++ b/packages/browser-integration-tests/suites/replay/largeMutations/defaultOptions/test.ts @@ -0,0 +1,67 @@ +import { expect } from '@playwright/test'; + +import { sentryTest } from '../../../../utils/fixtures'; +import { getReplayRecordingContent, shouldSkipReplayTest, waitForReplayRequest } from '../../../../utils/replayHelpers'; + +sentryTest( + 'handles large mutations with default options', + async ({ getLocalTestPath, page, forceFlushReplay, browserName }) => { + if (shouldSkipReplayTest() || ['webkit', 'firefox'].includes(browserName)) { + sentryTest.skip(); + } + + const reqPromise0 = waitForReplayRequest(page, 0); + const reqPromise0b = waitForReplayRequest(page, 1); + + await page.route('https://dsn.ingest.sentry.io/**/*', route => { + return route.fulfill({ + status: 200, + contentType: 'application/json', + body: JSON.stringify({ id: 'test-id' }), + }); + }); + + const url = await getLocalTestPath({ testDir: __dirname }); + + await page.goto(url); + await forceFlushReplay(); + const res0 = await reqPromise0; + await reqPromise0b; + // A second request is sent right after initial snapshot, we want to wait for that to settle before we continue + + const reqPromise1 = waitForReplayRequest(page); + + void page.click('#button-add'); + await forceFlushReplay(); + const res1 = await reqPromise1; + + const reqPromise2 = waitForReplayRequest(page); + + void page.click('#button-modify'); + await forceFlushReplay(); + const res2 = await reqPromise2; + + const reqPromise3 = waitForReplayRequest(page); + + void page.click('#button-remove'); + await forceFlushReplay(); + const res3 = await reqPromise3; + + const replayData0 = getReplayRecordingContent(res0); + const replayData1 = getReplayRecordingContent(res1); + const replayData2 = getReplayRecordingContent(res2); + const replayData3 = getReplayRecordingContent(res3); + + expect(replayData0.fullSnapshots.length).toBe(1); + expect(replayData0.incrementalSnapshots.length).toBe(0); + + expect(replayData1.fullSnapshots.length).toBe(0); + expect(replayData1.incrementalSnapshots.length).toBeGreaterThan(0); + + expect(replayData2.fullSnapshots.length).toBe(0); + expect(replayData2.incrementalSnapshots.length).toBeGreaterThan(0); + + expect(replayData3.fullSnapshots.length).toBe(0); + expect(replayData3.incrementalSnapshots.length).toBeGreaterThan(0); + }, +); diff --git a/packages/browser-integration-tests/suites/replay/largeMutations/mutationLimit/init.js b/packages/browser-integration-tests/suites/replay/largeMutations/mutationLimit/init.js new file mode 100644 index 000000000000..5c30f352959c --- /dev/null +++ b/packages/browser-integration-tests/suites/replay/largeMutations/mutationLimit/init.js @@ -0,0 +1,20 @@ +import * as Sentry from '@sentry/browser'; + +window.Sentry = Sentry; +window.Replay = new Sentry.Replay({ + flushMinDelay: 500, + flushMaxDelay: 500, + _experiments: { + mutationLimit: 250, + }, +}); + +Sentry.init({ + dsn: 'https://public@dsn.ingest.sentry.io/1337', + sampleRate: 0, + replaysSessionSampleRate: 1.0, + replaysOnErrorSampleRate: 0.0, + debug: true, + + integrations: [window.Replay], +}); diff --git a/packages/browser-integration-tests/suites/replay/largeMutations/mutationLimit/template.html b/packages/browser-integration-tests/suites/replay/largeMutations/mutationLimit/template.html new file mode 100644 index 000000000000..331a03a58b92 --- /dev/null +++ b/packages/browser-integration-tests/suites/replay/largeMutations/mutationLimit/template.html @@ -0,0 +1,41 @@ + + + + + + + + + +
      + + + + diff --git a/packages/browser-integration-tests/suites/replay/largeMutations/mutationLimit/test.ts b/packages/browser-integration-tests/suites/replay/largeMutations/mutationLimit/test.ts new file mode 100644 index 000000000000..5d5dbb9d3f93 --- /dev/null +++ b/packages/browser-integration-tests/suites/replay/largeMutations/mutationLimit/test.ts @@ -0,0 +1,69 @@ +import { expect } from '@playwright/test'; + +import { sentryTest } from '../../../../utils/fixtures'; +import { getReplayRecordingContent, shouldSkipReplayTest, waitForReplayRequest } from '../../../../utils/replayHelpers'; + +sentryTest( + 'handles large mutations with _experiments.mutationLimit configured', + async ({ getLocalTestPath, page, forceFlushReplay, browserName }) => { + if (shouldSkipReplayTest() || ['webkit', 'firefox'].includes(browserName)) { + sentryTest.skip(); + } + + const reqPromise0 = waitForReplayRequest(page, 0); + const reqPromise0b = waitForReplayRequest(page, 1); + + await page.route('https://dsn.ingest.sentry.io/**/*', route => { + return route.fulfill({ + status: 200, + contentType: 'application/json', + body: JSON.stringify({ id: 'test-id' }), + }); + }); + + const url = await getLocalTestPath({ testDir: __dirname }); + + await page.goto(url); + const res0 = await reqPromise0; + await reqPromise0b; + // A second request is sent right after initial snapshot, we want to wait for that to settle before we continue + + const reqPromise1 = waitForReplayRequest(page); + + void page.click('#button-add'); + await forceFlushReplay(); + const res1 = await reqPromise1; + + const reqPromise2 = waitForReplayRequest(page); + + void page.click('#button-modify'); + await forceFlushReplay(); + const res2 = await reqPromise2; + + const reqPromise3 = waitForReplayRequest(page); + + void page.click('#button-remove'); + await forceFlushReplay(); + const res3 = await reqPromise3; + + const replayData0 = getReplayRecordingContent(res0); + const replayData1 = getReplayRecordingContent(res1); + const replayData2 = getReplayRecordingContent(res2); + const replayData3 = getReplayRecordingContent(res3); + + expect(replayData0.fullSnapshots.length).toBe(1); + expect(replayData0.incrementalSnapshots.length).toBe(0); + + // This includes both a full snapshot as well as some incremental snapshots + expect(replayData1.fullSnapshots.length).toBe(1); + expect(replayData1.incrementalSnapshots.length).toBeGreaterThan(0); + + // This does not trigger mutations, for whatever reason - so no full snapshot either! + expect(replayData2.fullSnapshots.length).toBe(0); + expect(replayData2.incrementalSnapshots.length).toBeGreaterThan(0); + + // This includes both a full snapshot as well as some incremental snapshots + expect(replayData3.fullSnapshots.length).toBe(1); + expect(replayData3.incrementalSnapshots.length).toBeGreaterThan(0); + }, +); diff --git a/packages/replay/src/replay.ts b/packages/replay/src/replay.ts index df2f3e6c9774..8bb426874442 100644 --- a/packages/replay/src/replay.ts +++ b/packages/replay/src/replay.ts @@ -207,23 +207,7 @@ export class ReplayContainer implements ReplayContainerInterface { // instead, we'll always keep the last 60 seconds of replay before an error happened ...(this.recordingMode === 'error' && { checkoutEveryNms: ERROR_CHECKOUT_TIME }), emit: getHandleRecordingEmit(this), - onMutation: (mutations: unknown[]) => { - if (this._options._experiments.captureMutationSize) { - const count = mutations.length; - - if (count > 500) { - const breadcrumb = createBreadcrumb({ - category: 'replay.mutations', - data: { - count, - }, - }); - this._createCustomBreadcrumb(breadcrumb); - } - } - // `true` means we use the regular mutation handling by rrweb - return true; - }, + onMutation: this._onMutationHandler, }); } catch (err) { this._handleException(err); @@ -622,10 +606,10 @@ export class ReplayContainer implements ReplayContainerInterface { * Trigger rrweb to take a full snapshot which will cause this plugin to * create a new Replay event. */ - private _triggerFullSnapshot(): void { + private _triggerFullSnapshot(checkout = true): void { try { __DEBUG_BUILD__ && logger.log('[Replay] Taking full rrweb snapshot'); - record.takeFullSnapshot(true); + record.takeFullSnapshot(checkout); } catch (err) { this._handleException(err); } @@ -839,4 +823,35 @@ export class ReplayContainer implements ReplayContainerInterface { saveSession(this.session); } } + + /** Handler for rrweb.record.onMutation */ + private _onMutationHandler = (mutations: unknown[]): boolean => { + const count = mutations.length; + + const mutationLimit = this._options._experiments.mutationLimit || 0; + const mutationBreadcrumbLimit = this._options._experiments.mutationBreadcrumbLimit || 1000; + const overMutationLimit = mutationLimit && count > mutationLimit; + + // Create a breadcrumb if a lot of mutations happen at the same time + // We can show this in the UI as an information with potential performance improvements + if (count > mutationBreadcrumbLimit || overMutationLimit) { + const breadcrumb = createBreadcrumb({ + category: 'replay.mutations', + data: { + count, + }, + }); + this._createCustomBreadcrumb(breadcrumb); + } + + if (overMutationLimit) { + // We want to skip doing an incremental snapshot if there are too many mutations + // Instead, we do a full snapshot + this._triggerFullSnapshot(false); + return false; + } + + // `true` means we use the regular mutation handling by rrweb + return true; + }; } diff --git a/packages/replay/src/types.ts b/packages/replay/src/types.ts index 1ea691f3ec4e..c2982eb5d8cb 100644 --- a/packages/replay/src/types.ts +++ b/packages/replay/src/types.ts @@ -110,7 +110,8 @@ export interface ReplayPluginOptions extends SessionOptions { _experiments: Partial<{ captureExceptions: boolean; traceInternals: boolean; - captureMutationSize: boolean; + mutationLimit: number; + mutationBreadcrumbLimit: number; }>; } From 5abe629405a32825cb62fdff5acc9a3ab65a9ef6 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Fri, 24 Mar 2023 14:50:34 +0100 Subject: [PATCH 06/50] ref(sveltekit): Distinguish spans of server-only and universal load functions (#7609) Adjust the span ops of `load` functions to distinguish between spans of server-only and universal `load` functions (`+page.ts` vs `+page.server.ts`): --- packages/sveltekit/src/server/load.ts | 2 +- packages/sveltekit/test/server/load.test.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/sveltekit/src/server/load.ts b/packages/sveltekit/src/server/load.ts index 2d44aad94fef..068a1f4d0f8d 100644 --- a/packages/sveltekit/src/server/load.ts +++ b/packages/sveltekit/src/server/load.ts @@ -58,7 +58,7 @@ export function wrapLoadWithSentry(origLoad: T): T const { traceparentData, dynamicSamplingContext } = getTracePropagationData(event); const traceLoadContext: TransactionContext = { - op: 'function.sveltekit.load', + op: `function.sveltekit${isServerOnlyLoad(event) ? '.server' : ''}.load`, name: routeId ? routeId : event.url.pathname, status: 'ok', metadata: { diff --git a/packages/sveltekit/test/server/load.test.ts b/packages/sveltekit/test/server/load.test.ts index 3b3f308cafcf..69c31a74595d 100644 --- a/packages/sveltekit/test/server/load.test.ts +++ b/packages/sveltekit/test/server/load.test.ts @@ -202,7 +202,7 @@ describe('wrapLoadWithSentry', () => { expect(mockTrace).toHaveBeenCalledTimes(1); expect(mockTrace).toHaveBeenCalledWith( { - op: 'function.sveltekit.load', + op: 'function.sveltekit.server.load', name: '/users/[id]', parentSampled: true, parentSpanId: '1234567890abcdef', @@ -233,7 +233,7 @@ describe('wrapLoadWithSentry', () => { expect(mockTrace).toHaveBeenCalledTimes(1); expect(mockTrace).toHaveBeenCalledWith( { - op: 'function.sveltekit.load', + op: 'function.sveltekit.server.load', name: '/users/[id]', status: 'ok', metadata: { @@ -252,7 +252,7 @@ describe('wrapLoadWithSentry', () => { expect(mockTrace).toHaveBeenCalledTimes(1); expect(mockTrace).toHaveBeenCalledWith( { - op: 'function.sveltekit.load', + op: 'function.sveltekit.server.load', name: '/users/[id]', parentSampled: true, parentSpanId: '1234567890abcdef', From e1af1e6b9b781d55a10ac9df7b7090a59056d895 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Fri, 24 Mar 2023 13:59:40 +0000 Subject: [PATCH 07/50] feat(node): Auto discovery only returns integrations where dependency loads (#7603) Co-authored-by: Abhijeet Prasad --- packages/node/src/tracing/index.ts | 6 ++- packages/tracing-internal/src/index.ts | 1 + .../src/node/integrations/apollo.ts | 50 +++++++++++++------ .../src/node/integrations/graphql.ts | 20 ++++++-- .../src/node/integrations/lazy.ts | 25 +++++++--- .../src/node/integrations/mongo.ts | 19 +++++-- .../src/node/integrations/mysql.ts | 14 ++++-- .../src/node/integrations/postgres.ts | 16 ++++-- 8 files changed, 110 insertions(+), 41 deletions(-) diff --git a/packages/node/src/tracing/index.ts b/packages/node/src/tracing/index.ts index 15c4e2889b3f..2b4be9d41e70 100644 --- a/packages/node/src/tracing/index.ts +++ b/packages/node/src/tracing/index.ts @@ -1,3 +1,4 @@ +import type { LazyLoadedIntegration } from '@sentry-internal/tracing'; import { lazyLoadedNodePerformanceMonitoringIntegrations } from '@sentry-internal/tracing'; import type { Integration } from '@sentry/types'; import { logger } from '@sentry/utils'; @@ -14,11 +15,12 @@ export function autoDiscoverNodePerformanceMonitoringIntegrations(): Integration return undefined; } }) - .filter(integration => !!integration) as Integration[]; + .filter(integration => !!integration) as LazyLoadedIntegration[]; if (loadedIntegrations.length === 0) { logger.warn('Performance monitoring integrations could not be automatically loaded.'); } - return loadedIntegrations; + // Only return integrations where their dependencies loaded successfully. + return loadedIntegrations.filter(integration => !!integration.loadDependency()); } diff --git a/packages/tracing-internal/src/index.ts b/packages/tracing-internal/src/index.ts index c4e17c25294f..da9b94aac666 100644 --- a/packages/tracing-internal/src/index.ts +++ b/packages/tracing-internal/src/index.ts @@ -10,6 +10,7 @@ export { Prisma, lazyLoadedNodePerformanceMonitoringIntegrations, } from './node'; +export type { LazyLoadedIntegration } from './node'; export { BrowserTracing, diff --git a/packages/tracing-internal/src/node/integrations/apollo.ts b/packages/tracing-internal/src/node/integrations/apollo.ts index 3a076444af5e..5a9c0219a00c 100644 --- a/packages/tracing-internal/src/node/integrations/apollo.ts +++ b/packages/tracing-internal/src/node/integrations/apollo.ts @@ -1,7 +1,8 @@ import type { Hub } from '@sentry/core'; -import type { EventProcessor, Integration } from '@sentry/types'; +import type { EventProcessor } from '@sentry/types'; import { arrayify, fill, isThenable, loadModule, logger } from '@sentry/utils'; +import type { LazyLoadedIntegration } from './lazy'; import { shouldDisableAutoInstrumentation } from './utils/node-utils'; interface ApolloOptions { @@ -16,8 +17,24 @@ type ApolloModelResolvers = { [key: string]: ApolloResolverGroup; }; +type GraphQLModule = { + GraphQLFactory: { + prototype: { + create: (resolvers: ApolloModelResolvers[]) => unknown; + }; + }; +}; + +type ApolloModule = { + ApolloServerBase: { + prototype: { + constructSchema: (config: unknown) => unknown; + }; + }; +}; + /** Tracing integration for Apollo */ -export class Apollo implements Integration { +export class Apollo implements LazyLoadedIntegration { /** * @inheritDoc */ @@ -30,6 +47,8 @@ export class Apollo implements Integration { private readonly _useNest: boolean; + private _module?: GraphQLModule & ApolloModule; + /** * @inheritDoc */ @@ -41,6 +60,17 @@ export class Apollo implements Integration { this._useNest = !!options.useNestjs; } + /** @inheritdoc */ + public loadDependency(): (GraphQLModule & ApolloModule) | undefined { + if (this._useNest) { + this._module = this._module || loadModule('@nestjs/graphql'); + } else { + this._module = this._module || loadModule('apollo-server-core'); + } + + return this._module; + } + /** * @inheritDoc */ @@ -51,13 +81,7 @@ export class Apollo implements Integration { } if (this._useNest) { - const pkg = loadModule<{ - GraphQLFactory: { - prototype: { - create: (resolvers: ApolloModelResolvers[]) => unknown; - }; - }; - }>('@nestjs/graphql'); + const pkg = this.loadDependency(); if (!pkg) { __DEBUG_BUILD__ && logger.error('Apollo-NestJS Integration was unable to require @nestjs/graphql package.'); @@ -90,13 +114,7 @@ export class Apollo implements Integration { }, ); } else { - const pkg = loadModule<{ - ApolloServerBase: { - prototype: { - constructSchema: (config: unknown) => unknown; - }; - }; - }>('apollo-server-core'); + const pkg = this.loadDependency(); if (!pkg) { __DEBUG_BUILD__ && logger.error('Apollo Integration was unable to require apollo-server-core package.'); diff --git a/packages/tracing-internal/src/node/integrations/graphql.ts b/packages/tracing-internal/src/node/integrations/graphql.ts index 12f04b7c1e57..027419ae8ce8 100644 --- a/packages/tracing-internal/src/node/integrations/graphql.ts +++ b/packages/tracing-internal/src/node/integrations/graphql.ts @@ -1,11 +1,16 @@ import type { Hub } from '@sentry/core'; -import type { EventProcessor, Integration } from '@sentry/types'; +import type { EventProcessor } from '@sentry/types'; import { fill, isThenable, loadModule, logger } from '@sentry/utils'; +import type { LazyLoadedIntegration } from './lazy'; import { shouldDisableAutoInstrumentation } from './utils/node-utils'; +type GraphQLModule = { + [method: string]: (...args: unknown[]) => unknown; +}; + /** Tracing integration for graphql package */ -export class GraphQL implements Integration { +export class GraphQL implements LazyLoadedIntegration { /** * @inheritDoc */ @@ -16,6 +21,13 @@ export class GraphQL implements Integration { */ public name: string = GraphQL.id; + private _module?: GraphQLModule; + + /** @inheritdoc */ + public loadDependency(): GraphQLModule | undefined { + return (this._module = this._module || loadModule('graphql/execution/execute.js')); + } + /** * @inheritDoc */ @@ -25,9 +37,7 @@ export class GraphQL implements Integration { return; } - const pkg = loadModule<{ - [method: string]: (...args: unknown[]) => unknown; - }>('graphql/execution/execute.js'); + const pkg = this.loadDependency(); if (!pkg) { __DEBUG_BUILD__ && logger.error('GraphQL Integration was unable to require graphql/execution package.'); diff --git a/packages/tracing-internal/src/node/integrations/lazy.ts b/packages/tracing-internal/src/node/integrations/lazy.ts index f53ff756cd48..635f5b082bee 100644 --- a/packages/tracing-internal/src/node/integrations/lazy.ts +++ b/packages/tracing-internal/src/node/integrations/lazy.ts @@ -1,46 +1,55 @@ import type { Integration, IntegrationClass } from '@sentry/types'; import { dynamicRequire } from '@sentry/utils'; -export const lazyLoadedNodePerformanceMonitoringIntegrations: (() => Integration)[] = [ +export interface LazyLoadedIntegration extends Integration { + /** + * Loads the integration's dependency and caches it so it doesn't have to be loaded again. + * + * If this returns undefined, the dependency could not be loaded. + */ + loadDependency(): T | undefined; +} + +export const lazyLoadedNodePerformanceMonitoringIntegrations: (() => LazyLoadedIntegration)[] = [ () => { const integration = dynamicRequire(module, './apollo') as { - Apollo: IntegrationClass; + Apollo: IntegrationClass; }; return new integration.Apollo(); }, () => { const integration = dynamicRequire(module, './apollo') as { - Apollo: IntegrationClass; + Apollo: IntegrationClass; }; return new integration.Apollo({ useNestjs: true }); }, () => { const integration = dynamicRequire(module, './graphql') as { - GraphQL: IntegrationClass; + GraphQL: IntegrationClass; }; return new integration.GraphQL(); }, () => { const integration = dynamicRequire(module, './mongo') as { - Mongo: IntegrationClass; + Mongo: IntegrationClass; }; return new integration.Mongo(); }, () => { const integration = dynamicRequire(module, './mongo') as { - Mongo: IntegrationClass; + Mongo: IntegrationClass; }; return new integration.Mongo({ mongoose: true }); }, () => { const integration = dynamicRequire(module, './mysql') as { - Mysql: IntegrationClass; + Mysql: IntegrationClass; }; return new integration.Mysql(); }, () => { const integration = dynamicRequire(module, './postgres') as { - Postgres: IntegrationClass; + Postgres: IntegrationClass; }; return new integration.Postgres(); }, diff --git a/packages/tracing-internal/src/node/integrations/mongo.ts b/packages/tracing-internal/src/node/integrations/mongo.ts index 37335358c82e..5364f234df8d 100644 --- a/packages/tracing-internal/src/node/integrations/mongo.ts +++ b/packages/tracing-internal/src/node/integrations/mongo.ts @@ -1,7 +1,8 @@ import type { Hub } from '@sentry/core'; -import type { EventProcessor, Integration, SpanContext } from '@sentry/types'; +import type { EventProcessor, SpanContext } from '@sentry/types'; import { fill, isThenable, loadModule, logger } from '@sentry/utils'; +import type { LazyLoadedIntegration } from './lazy'; import { shouldDisableAutoInstrumentation } from './utils/node-utils'; // This allows us to use the same array for both defaults options and the type itself. @@ -98,8 +99,10 @@ function isCursor(maybeCursor: MongoCursor): maybeCursor is MongoCursor { return maybeCursor && typeof maybeCursor === 'object' && maybeCursor.once && typeof maybeCursor.once === 'function'; } +type MongoModule = { Collection: MongoCollection }; + /** Tracing integration for mongo package */ -export class Mongo implements Integration { +export class Mongo implements LazyLoadedIntegration { /** * @inheritDoc */ @@ -114,6 +117,8 @@ export class Mongo implements Integration { private _describeOperations?: boolean | Operation[]; private _useMongoose: boolean; + private _module?: MongoModule; + /** * @inheritDoc */ @@ -123,6 +128,12 @@ export class Mongo implements Integration { this._useMongoose = !!options.useMongoose; } + /** @inheritdoc */ + public loadDependency(): MongoModule | undefined { + const moduleName = this._useMongoose ? 'mongoose' : 'mongodb'; + return (this._module = this._module || loadModule(moduleName)); + } + /** * @inheritDoc */ @@ -132,10 +143,10 @@ export class Mongo implements Integration { return; } - const moduleName = this._useMongoose ? 'mongoose' : 'mongodb'; - const pkg = loadModule<{ Collection: MongoCollection }>(moduleName); + const pkg = this.loadDependency(); if (!pkg) { + const moduleName = this._useMongoose ? 'mongoose' : 'mongodb'; __DEBUG_BUILD__ && logger.error(`Mongo Integration was unable to require \`${moduleName}\` package.`); return; } diff --git a/packages/tracing-internal/src/node/integrations/mysql.ts b/packages/tracing-internal/src/node/integrations/mysql.ts index 6e6a80ac59a6..529e3b859bc2 100644 --- a/packages/tracing-internal/src/node/integrations/mysql.ts +++ b/packages/tracing-internal/src/node/integrations/mysql.ts @@ -1,7 +1,8 @@ import type { Hub } from '@sentry/core'; -import type { EventProcessor, Integration } from '@sentry/types'; +import type { EventProcessor } from '@sentry/types'; import { fill, loadModule, logger } from '@sentry/utils'; +import type { LazyLoadedIntegration } from './lazy'; import { shouldDisableAutoInstrumentation } from './utils/node-utils'; interface MysqlConnection { @@ -9,7 +10,7 @@ interface MysqlConnection { } /** Tracing integration for node-mysql package */ -export class Mysql implements Integration { +export class Mysql implements LazyLoadedIntegration { /** * @inheritDoc */ @@ -20,6 +21,13 @@ export class Mysql implements Integration { */ public name: string = Mysql.id; + private _module?: MysqlConnection; + + /** @inheritdoc */ + public loadDependency(): MysqlConnection | undefined { + return (this._module = this._module || loadModule('mysql/lib/Connection.js')); + } + /** * @inheritDoc */ @@ -29,7 +37,7 @@ export class Mysql implements Integration { return; } - const pkg = loadModule('mysql/lib/Connection.js'); + const pkg = this.loadDependency(); if (!pkg) { __DEBUG_BUILD__ && logger.error('Mysql Integration was unable to require `mysql` package.'); diff --git a/packages/tracing-internal/src/node/integrations/postgres.ts b/packages/tracing-internal/src/node/integrations/postgres.ts index 41ad31b20660..be7e299cf6aa 100644 --- a/packages/tracing-internal/src/node/integrations/postgres.ts +++ b/packages/tracing-internal/src/node/integrations/postgres.ts @@ -1,7 +1,8 @@ import type { Hub } from '@sentry/core'; -import type { EventProcessor, Integration } from '@sentry/types'; +import type { EventProcessor } from '@sentry/types'; import { fill, isThenable, loadModule, logger } from '@sentry/utils'; +import type { LazyLoadedIntegration } from './lazy'; import { shouldDisableAutoInstrumentation } from './utils/node-utils'; interface PgClient { @@ -14,8 +15,10 @@ interface PgOptions { usePgNative?: boolean; } +type PGModule = { Client: PgClient; native: { Client: PgClient } }; + /** Tracing integration for node-postgres package */ -export class Postgres implements Integration { +export class Postgres implements LazyLoadedIntegration { /** * @inheritDoc */ @@ -28,10 +31,17 @@ export class Postgres implements Integration { private _usePgNative: boolean; + private _module?: PGModule; + public constructor(options: PgOptions = {}) { this._usePgNative = !!options.usePgNative; } + /** @inheritdoc */ + public loadDependency(): PGModule | undefined { + return (this._module = this._module || loadModule('pg')); + } + /** * @inheritDoc */ @@ -41,7 +51,7 @@ export class Postgres implements Integration { return; } - const pkg = loadModule<{ Client: PgClient; native: { Client: PgClient } }>('pg'); + const pkg = this.loadDependency(); if (!pkg) { __DEBUG_BUILD__ && logger.error('Postgres Integration was unable to require `pg` package.'); From a2bd1e097720757952415f3b94ef92ba925c775e Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Mon, 27 Mar 2023 09:29:11 +0200 Subject: [PATCH 08/50] test: Try to fix flaky tests? (#7597) --- .../startTransaction/basic_usage/subject.js | 51 ++++++++++--------- .../protocol_fn_identifiers/test.ts | 7 +++ 2 files changed, 35 insertions(+), 23 deletions(-) diff --git a/packages/browser-integration-tests/suites/public-api/startTransaction/basic_usage/subject.js b/packages/browser-integration-tests/suites/public-api/startTransaction/basic_usage/subject.js index c75bd2718326..e46009e46b35 100644 --- a/packages/browser-integration-tests/suites/public-api/startTransaction/basic_usage/subject.js +++ b/packages/browser-integration-tests/suites/public-api/startTransaction/basic_usage/subject.js @@ -1,30 +1,35 @@ -const transaction = Sentry.startTransaction({ name: 'test_transaction_1' }); -const span_1 = transaction.startChild({ - op: 'span_1', - data: { - foo: 'bar', - baz: [1, 2, 3], - }, -}); -for (let i = 0; i < 2000; i++); +async function run() { + const transaction = Sentry.startTransaction({ name: 'test_transaction_1' }); + const span_1 = transaction.startChild({ + op: 'span_1', + data: { + foo: 'bar', + baz: [1, 2, 3], + }, + }); -// span_1 finishes -span_1.finish(); + await new Promise(resolve => setTimeout(resolve, 1)); -// span_2 doesn't finish -const span_2 = transaction.startChild({ op: 'span_2' }); -for (let i = 0; i < 4000; i++); + // span_1 finishes + span_1.finish(); -const span_3 = transaction.startChild({ op: 'span_3' }); -for (let i = 0; i < 4000; i++); + // span_2 doesn't finish + const span_2 = transaction.startChild({ op: 'span_2' }); + await new Promise(resolve => setTimeout(resolve, 1)); -// span_4 is the child of span_3 but doesn't finish. -const span_4 = span_3.startChild({ op: 'span_4', data: { qux: 'quux' } }); + const span_3 = transaction.startChild({ op: 'span_3' }); + await new Promise(resolve => setTimeout(resolve, 1)); -// span_5 is another child of span_3 but finishes. -const span_5 = span_3.startChild({ op: 'span_5' }).finish(); + // span_4 is the child of span_3 but doesn't finish. + const span_4 = span_3.startChild({ op: 'span_4', data: { qux: 'quux' } }); -// span_3 also finishes -span_3.finish(); + // span_5 is another child of span_3 but finishes. + const span_5 = span_3.startChild({ op: 'span_5' }).finish(); -transaction.finish(); + // span_3 also finishes + span_3.finish(); + + transaction.finish(); +} + +run(); diff --git a/packages/browser-integration-tests/suites/stacktraces/protocol_fn_identifiers/test.ts b/packages/browser-integration-tests/suites/stacktraces/protocol_fn_identifiers/test.ts index ce2142169bdc..c4ef75913334 100644 --- a/packages/browser-integration-tests/suites/stacktraces/protocol_fn_identifiers/test.ts +++ b/packages/browser-integration-tests/suites/stacktraces/protocol_fn_identifiers/test.ts @@ -12,6 +12,10 @@ sentryTest( const eventData = await getFirstSentryEnvelopeRequest(page, url); const frames = eventData.exception?.values?.[0].stacktrace?.frames; + expect(eventData).toBeDefined(); + expect(eventData.exception?.values).toBeDefined(); + expect(frames).toBeDefined(); + runInChromium(() => { expect(frames).toMatchObject([ { function: '?' }, @@ -57,6 +61,9 @@ sentryTest( const eventData = await getFirstSentryEnvelopeRequest(page, url); + expect(eventData).toBeDefined(); + expect(eventData.exception?.values).toBeDefined(); + expect(eventData.exception?.values?.[0].stacktrace).toBeDefined(); expect(eventData.exception?.values?.[0].stacktrace?.frames).toMatchObject( Array(7).fill({ filename: expect.stringMatching(/^file:\/?/) }), ); From b589685d5060edd4bc9dc00ee414764f865b2ebf Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Mon, 27 Mar 2023 13:41:47 +0200 Subject: [PATCH 09/50] fix(nextjs): Rewrite `abs_path` frames (#7619) --- packages/nextjs/src/client/index.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/nextjs/src/client/index.ts b/packages/nextjs/src/client/index.ts index ece6bf78db6a..650f0607a2a2 100644 --- a/packages/nextjs/src/client/index.ts +++ b/packages/nextjs/src/client/index.ts @@ -77,21 +77,26 @@ function addClientIntegrations(options: BrowserOptions): void { // Turn `//_next/static/...` into `app:///_next/static/...` iteratee: frame => { try { - const { origin } = new URL(frame.filename as string); - frame.filename = frame.filename?.replace(origin, 'app://').replace(assetPrefixPath, ''); + const { origin: absPathOrigin } = new URL(frame.abs_path as string); + const { origin: filenameOrigin } = new URL(frame.filename as string); + frame.abs_path = frame.abs_path?.replace(absPathOrigin, 'app://').replace(assetPrefixPath, ''); + frame.filename = frame.filename?.replace(filenameOrigin, 'app://').replace(assetPrefixPath, ''); } catch (err) { // Filename wasn't a properly formed URL, so there's nothing we can do } + // We need to URI-decode the filename because Next.js has wildcard routes like "/users/[id].js" which show up as "/users/%5id%5.js" in Error stacktraces. + // The corresponding sources that Next.js generates have proper brackets so we also need proper brackets in the frame so that source map resolving works. if (frame.filename && frame.filename.startsWith('app:///_next')) { - // We need to URI-decode the filename because Next.js has wildcard routes like "/users/[id].js" which show up as "/users/%5id%5.js" in Error stacktraces. - // The corresponding sources that Next.js generates have proper brackets so we also need proper brackets in the frame so that source map resolving works. frame.filename = decodeURI(frame.filename); } + if (frame.abs_path && frame.abs_path.startsWith('app:///_next')) { + frame.abs_path = decodeURI(frame.abs_path); + } if ( - frame.filename && - frame.filename.match( + frame.abs_path && + frame.abs_path.match( /^app:\/\/\/_next\/static\/chunks\/(main-|main-app-|polyfills-|webpack-|framework-|framework\.)[0-9a-f]+\.js$/, ) ) { From 02d065d55160606fab64839fcad063f8ee3520d8 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Mon, 27 Mar 2023 15:46:46 +0200 Subject: [PATCH 10/50] build(cdn): Make integration CDN bundles build in parallel (#7621) --- packages/integrations/package.json | 2 +- packages/integrations/rollup.bundle.config.js | 2 +- packages/integrations/scripts/buildBundles.ts | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/integrations/package.json b/packages/integrations/package.json index 473b81051b1a..a2d6a0e162c1 100644 --- a/packages/integrations/package.json +++ b/packages/integrations/package.json @@ -27,7 +27,7 @@ }, "scripts": { "build": "run-p build:transpile build:types build:bundle", - "build:bundle": "ts-node scripts/buildBundles.ts", + "build:bundle": "ts-node scripts/buildBundles.ts --parallel", "build:dev": "run-p build:transpile build:types", "build:transpile": "rollup -c rollup.npm.config.js", "build:types": "tsc -p tsconfig.types.json", diff --git a/packages/integrations/rollup.bundle.config.js b/packages/integrations/rollup.bundle.config.js index 067a062e17f6..7c4d2d15e2a6 100644 --- a/packages/integrations/rollup.bundle.config.js +++ b/packages/integrations/rollup.bundle.config.js @@ -12,7 +12,7 @@ const baseBundleConfig = makeBaseBundleConfig({ entrypoints: [`src/${file}`], jsVersion, licenseTitle: '@sentry/integrations', - outputFileBase: ({ name: entrypoint }) => `bundles/${entrypoint}${jsVersion === 'ES5' ? '.es5' : ''}`, + outputFileBase: ({ name: entrypoint }) => `bundles/${entrypoint}${jsVersion === 'es5' ? '.es5' : ''}`, }); // TODO We only need `commonjs` for localforage (used in the offline plugin). Once that's fixed, this can come out. diff --git a/packages/integrations/scripts/buildBundles.ts b/packages/integrations/scripts/buildBundles.ts index 82cef7c4b507..98a2a3456300 100644 --- a/packages/integrations/scripts/buildBundles.ts +++ b/packages/integrations/scripts/buildBundles.ts @@ -33,7 +33,7 @@ async function buildBundle(integration: string, jsVersion: string): Promise [...tasks, buildBundle(integration, 'ES5'), buildBundle(integration, 'ES6')], + (tasks, integration) => [...tasks, buildBundle(integration, 'es5'), buildBundle(integration, 'es6')], [] as Promise[], ); @@ -49,8 +49,8 @@ if (runParallel) { } else { void (async () => { for (const integration of getIntegrations()) { - await buildBundle(integration, 'ES5'); - await buildBundle(integration, 'ES6'); + await buildBundle(integration, 'es5'); + await buildBundle(integration, 'es6'); } // eslint-disable-next-line no-console console.log('\nIntegration bundles built successfully'); From 2e5d85010b3a9671d209bc7a74a8d588911a03b8 Mon Sep 17 00:00:00 2001 From: Tim Fish Date: Mon, 27 Mar 2023 15:45:56 +0100 Subject: [PATCH 11/50] chore(browser): Add attribution and licences for stack parsers (#7620) --- packages/browser/src/stack-parsers.ts | 25 ++++++ packages/utils/src/node-stack-trace.ts | 114 +++++++++++++++++++++++++ packages/utils/src/stacktrace.ts | 94 +------------------- 3 files changed, 143 insertions(+), 90 deletions(-) create mode 100644 packages/utils/src/node-stack-trace.ts diff --git a/packages/browser/src/stack-parsers.ts b/packages/browser/src/stack-parsers.ts index 6419f3660e9d..256e7d75fd31 100644 --- a/packages/browser/src/stack-parsers.ts +++ b/packages/browser/src/stack-parsers.ts @@ -1,3 +1,28 @@ +// This was originally forked from https://github.com/csnover/TraceKit, and was largely +// re - written as part of raven - js. +// +// This code was later copied to the JavaScript mono - repo and further modified and +// refactored over the years. + +// Copyright (c) 2013 Onur Can Cakmak onur.cakmak@gmail.com and all TraceKit contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of this +// software and associated documentation files(the 'Software'), to deal in the Software +// without restriction, including without limitation the rights to use, copy, modify, +// merge, publish, distribute, sublicense, and / or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to the following +// conditions: +// +// The above copyright notice and this permission notice shall be included in all copies +// or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF +// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE +// OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + import type { StackFrame, StackLineParser, StackLineParserFn } from '@sentry/types'; import { createStackParser } from '@sentry/utils'; diff --git a/packages/utils/src/node-stack-trace.ts b/packages/utils/src/node-stack-trace.ts new file mode 100644 index 000000000000..7797eb327bbe --- /dev/null +++ b/packages/utils/src/node-stack-trace.ts @@ -0,0 +1,114 @@ +// This code was originally forked from https://github.com/felixge/node-stack-trace +// Since then it has been highly modified to fit our needs. + +// Copyright (c) 2011 Felix Geisendörfer (felix@debuggable.com)// +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions:// +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software.// +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import type { StackLineParserFn } from '@sentry/types'; + +export type GetModuleFn = (filename: string | undefined) => string | undefined; + +/** Node Stack line parser */ +// eslint-disable-next-line complexity +export function node(getModule?: GetModuleFn): StackLineParserFn { + const FILENAME_MATCH = /^\s*[-]{4,}$/; + const FULL_MATCH = /at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/; + + // eslint-disable-next-line complexity + return (line: string) => { + const lineMatch = line.match(FULL_MATCH); + + if (lineMatch) { + let object: string | undefined; + let method: string | undefined; + let functionName: string | undefined; + let typeName: string | undefined; + let methodName: string | undefined; + + if (lineMatch[1]) { + functionName = lineMatch[1]; + + let methodStart = functionName.lastIndexOf('.'); + if (functionName[methodStart - 1] === '.') { + methodStart--; + } + + if (methodStart > 0) { + object = functionName.slice(0, methodStart); + method = functionName.slice(methodStart + 1); + const objectEnd = object.indexOf('.Module'); + if (objectEnd > 0) { + functionName = functionName.slice(objectEnd + 1); + object = object.slice(0, objectEnd); + } + } + typeName = undefined; + } + + if (method) { + typeName = object; + methodName = method; + } + + if (method === '') { + methodName = undefined; + functionName = undefined; + } + + if (functionName === undefined) { + methodName = methodName || ''; + functionName = typeName ? `${typeName}.${methodName}` : methodName; + } + + let filename = lineMatch[2] && lineMatch[2].startsWith('file://') ? lineMatch[2].slice(7) : lineMatch[2]; + const isNative = lineMatch[5] === 'native'; + + if (!filename && lineMatch[5] && !isNative) { + filename = lineMatch[5]; + } + + const isInternal = + isNative || (filename && !filename.startsWith('/') && !filename.startsWith('.') && !filename.includes(':\\')); + + // in_app is all that's not an internal Node function or a module within node_modules + // note that isNative appears to return true even for node core libraries + // see https://github.com/getsentry/raven-node/issues/176 + + const in_app = !isInternal && filename !== undefined && !filename.includes('node_modules/'); + + return { + filename, + module: getModule ? getModule(filename) : undefined, + function: functionName, + lineno: parseInt(lineMatch[3], 10) || undefined, + colno: parseInt(lineMatch[4], 10) || undefined, + in_app, + }; + } + + if (line.match(FILENAME_MATCH)) { + return { + filename: line, + }; + } + + return undefined; + }; +} diff --git a/packages/utils/src/stacktrace.ts b/packages/utils/src/stacktrace.ts index 78eb1c0eba5d..2cce7a7879ae 100644 --- a/packages/utils/src/stacktrace.ts +++ b/packages/utils/src/stacktrace.ts @@ -1,4 +1,7 @@ -import type { StackFrame, StackLineParser, StackLineParserFn, StackParser } from '@sentry/types'; +import type { StackFrame, StackLineParser, StackParser } from '@sentry/types'; + +import type { GetModuleFn } from './node-stack-trace'; +import { node } from './node-stack-trace'; const STACKTRACE_FRAME_LIMIT = 50; // Used to sanitize webpack (error: *) wrapped stack errors @@ -116,95 +119,6 @@ export function getFunctionName(fn: unknown): string { } } -type GetModuleFn = (filename: string | undefined) => string | undefined; - -// eslint-disable-next-line complexity -function node(getModule?: GetModuleFn): StackLineParserFn { - const FILENAME_MATCH = /^\s*[-]{4,}$/; - const FULL_MATCH = /at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/; - - // eslint-disable-next-line complexity - return (line: string) => { - const lineMatch = line.match(FULL_MATCH); - - if (lineMatch) { - let object: string | undefined; - let method: string | undefined; - let functionName: string | undefined; - let typeName: string | undefined; - let methodName: string | undefined; - - if (lineMatch[1]) { - functionName = lineMatch[1]; - - let methodStart = functionName.lastIndexOf('.'); - if (functionName[methodStart - 1] === '.') { - methodStart--; - } - - if (methodStart > 0) { - object = functionName.slice(0, methodStart); - method = functionName.slice(methodStart + 1); - const objectEnd = object.indexOf('.Module'); - if (objectEnd > 0) { - functionName = functionName.slice(objectEnd + 1); - object = object.slice(0, objectEnd); - } - } - typeName = undefined; - } - - if (method) { - typeName = object; - methodName = method; - } - - if (method === '') { - methodName = undefined; - functionName = undefined; - } - - if (functionName === undefined) { - methodName = methodName || ''; - functionName = typeName ? `${typeName}.${methodName}` : methodName; - } - - let filename = lineMatch[2] && lineMatch[2].startsWith('file://') ? lineMatch[2].slice(7) : lineMatch[2]; - const isNative = lineMatch[5] === 'native'; - - if (!filename && lineMatch[5] && !isNative) { - filename = lineMatch[5]; - } - - const isInternal = - isNative || (filename && !filename.startsWith('/') && !filename.startsWith('.') && !filename.includes(':\\')); - - // in_app is all that's not an internal Node function or a module within node_modules - // note that isNative appears to return true even for node core libraries - // see https://github.com/getsentry/raven-node/issues/176 - - const in_app = !isInternal && filename !== undefined && !filename.includes('node_modules/'); - - return { - filename, - module: getModule ? getModule(filename) : undefined, - function: functionName, - lineno: parseInt(lineMatch[3], 10) || undefined, - colno: parseInt(lineMatch[4], 10) || undefined, - in_app, - }; - } - - if (line.match(FILENAME_MATCH)) { - return { - filename: line, - }; - } - - return undefined; - }; -} - /** * Node.js stack line parser * From f6ce5c9bff6db025117f3ee6d974e7a5b7ab82a6 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Mon, 27 Mar 2023 16:54:02 +0200 Subject: [PATCH 12/50] fix(sveltekit): Fix `` tag injection (#7612) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Apparently, the `%sveltekit.head%` placeholder isn't present in the html that's passed to `transformPageChunk`. Hence our `` tag injection logic introduced in #7574 didn't find the anchor point where to inject the tags. This PR fixes the injection, by simply appending it to an open `` tag. It's not pretty but it should do the trick 🤞 (we can revisit if this breaks folks). --- packages/sveltekit/src/server/handle.ts | 8 ++++---- packages/sveltekit/test/server/handle.test.ts | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/sveltekit/src/server/handle.ts b/packages/sveltekit/src/server/handle.ts index 8020a35c7377..23319713bf87 100644 --- a/packages/sveltekit/src/server/handle.ts +++ b/packages/sveltekit/src/server/handle.ts @@ -40,10 +40,10 @@ export const transformPageChunk: NonNullable - - %sveltekit.head%`; - return html.replace('%sveltekit.head%', content); + const content = ` + + `; + return html.replace('', content); } return html; diff --git a/packages/sveltekit/test/server/handle.test.ts b/packages/sveltekit/test/server/handle.test.ts index f260d2daf310..ac94e72dd292 100644 --- a/packages/sveltekit/test/server/handle.test.ts +++ b/packages/sveltekit/test/server/handle.test.ts @@ -271,7 +271,6 @@ describe('transformPageChunk', () => { - %sveltekit.head%
      %sveltekit.body%
      From 0fab403c7a86cac9e7ae5a6bebd7a4c566035ac1 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Mon, 27 Mar 2023 17:35:37 +0200 Subject: [PATCH 13/50] fix(core): Remove `abs_path` from stack trace (reverting #7167) (#7623) --- packages/browser/src/stack-parsers.ts | 1 - .../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 ++------ packages/core/src/utils/prepareEvent.ts | 24 +- packages/core/test/lib/prepareEvent.test.ts | 10 +- .../tests/devErrorSymbolification.test.ts | 1 - packages/nextjs/src/client/index.ts | 13 +- .../devErrorSymbolicationEventProcessor.ts | 2 +- packages/types/src/debugMeta.ts | 2 +- 15 files changed, 231 insertions(+), 1532 deletions(-) diff --git a/packages/browser/src/stack-parsers.ts b/packages/browser/src/stack-parsers.ts index 256e7d75fd31..e4c66755f232 100644 --- a/packages/browser/src/stack-parsers.ts +++ b/packages/browser/src/stack-parsers.ts @@ -38,7 +38,6 @@ 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, in_app: true, // All browser frames are considered in_app }; diff --git a/packages/browser/test/unit/tracekit/chromium.test.ts b/packages/browser/test/unit/tracekit/chromium.test.ts index 0d600cc28dd1..b0df582ebeef 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', abs_path: 'native', function: 'Array.forEach', in_app: true }] }, + stacktrace: { frames: [{ filename: 'native', function: 'Array.forEach', in_app: true }] }, }); }); @@ -33,38 +33,10 @@ describe('Tracekit - Chrome Tests', () => { type: 'foo', stacktrace: { frames: [ - { - 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, - }, + { 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 }, ], }, }); @@ -90,7 +62,6 @@ 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, @@ -98,7 +69,6 @@ describe('Tracekit - Chrome Tests', () => { }, { filename: 'http://localhost:8080/file.js', - abs_path: 'http://localhost:8080/file.js', function: 'HTMLButtonElement.onclick', lineno: 107, colno: 146, @@ -106,7 +76,6 @@ describe('Tracekit - Chrome Tests', () => { }, { filename: 'http://localhost:8080/file.js', - abs_path: 'http://localhost:8080/file.js', function: 'dumpExceptionError', lineno: 41, colno: 27, @@ -139,7 +108,6 @@ 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, @@ -147,7 +115,6 @@ 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, @@ -155,7 +122,6 @@ 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, @@ -163,7 +129,6 @@ 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, @@ -194,46 +159,11 @@ describe('Tracekit - Chrome Tests', () => { type: 'Error', stacktrace: { frames: [ - { - 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, - }, + { 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 }, ], }, }); @@ -263,7 +193,6 @@ 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, @@ -271,7 +200,6 @@ 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, @@ -279,7 +207,6 @@ 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, @@ -287,7 +214,6 @@ 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, @@ -295,7 +221,6 @@ 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, @@ -303,13 +228,12 @@ 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', abs_path: 'native', function: 'Error', in_app: true }, + { filename: 'native', function: 'Error', in_app: true }, ], }, }); @@ -332,7 +256,6 @@ describe('Tracekit - Chrome Tests', () => { frames: [ { filename: 'examplescheme://examplehost/cd351f7250857e22ceaa.worker.js', - abs_path: 'examplescheme://examplehost/cd351f7250857e22ceaa.worker.js', function: '?', lineno: 70179, colno: 15, @@ -361,31 +284,10 @@ describe('Tracekit - Chrome Tests', () => { type: 'Error', stacktrace: { frames: [ - { - 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, - }, + { 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 }, ], }, }); @@ -415,79 +317,16 @@ describe('Tracekit - Chrome Tests', () => { type: 'Error', stacktrace: { frames: [ - { - 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, - }, + { 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 }, ], }, }); @@ -510,30 +349,9 @@ describe('Tracekit - Chrome Tests', () => { type: 'Error', stacktrace: { frames: [ - { - 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, - }, + { 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 }, ], }, }); @@ -557,31 +375,10 @@ describe('Tracekit - Chrome Tests', () => { type: 'Error', stacktrace: { frames: [ - { - 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, - }, + { 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 }, ], }, }); @@ -611,72 +408,22 @@ 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/', - 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, - }, + { 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 }, ], }, }); @@ -699,7 +446,6 @@ 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, @@ -732,7 +478,6 @@ 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, @@ -740,7 +485,6 @@ describe('Tracekit - Chrome Tests', () => { }, { filename: 'react-dom.development.js?f8c1', - abs_path: 'react-dom.development.js?f8c1', function: 'commitLifeCycles', in_app: true, lineno: 20663, @@ -748,7 +492,6 @@ describe('Tracekit - Chrome Tests', () => { }, { filename: 'genericDiscoverQuery.tsx?33f8', - abs_path: 'genericDiscoverQuery.tsx?33f8', function: '_GenericDiscoverQuery.componentDidMount', in_app: true, lineno: 152, @@ -756,7 +499,6 @@ describe('Tracekit - Chrome Tests', () => { }, { filename: 'genericDiscoverQuery.tsx?33f8', - abs_path: 'genericDiscoverQuery.tsx?33f8', function: '_GenericDiscoverQuery.eval [as fetchData]', in_app: true, lineno: 256, @@ -764,7 +506,6 @@ describe('Tracekit - Chrome Tests', () => { }, { filename: 'genericDiscoverQuery.tsx?33f8', - abs_path: 'genericDiscoverQuery.tsx?33f8', function: 'doDiscoverQuery', in_app: true, lineno: 328, @@ -772,7 +513,6 @@ describe('Tracekit - Chrome Tests', () => { }, { filename: 'api.tsx', - abs_path: 'api.tsx', function: 'Client.requestPromise', in_app: true, lineno: 554, @@ -802,10 +542,9 @@ describe('Tracekit - Chrome Tests', () => { type: 'ChunkLoadError', stacktrace: { frames: [ - { filename: '', abs_path: '', function: 'Array.reduce', in_app: true }, + { filename: '', function: 'Array.reduce', in_app: true }, { filename: 'webpack/runtime/ensure chunk', - abs_path: 'webpack/runtime/ensure chunk', function: '?', in_app: true, lineno: 6, @@ -813,7 +552,6 @@ describe('Tracekit - Chrome Tests', () => { }, { filename: 'webpack/runtime/jsonp chunk loading', - abs_path: 'webpack/runtime/jsonp chunk loading', function: 'key', in_app: true, lineno: 27, @@ -821,15 +559,12 @@ 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, }, @@ -857,22 +592,8 @@ describe('Tracekit - Chrome Tests', () => { type: 'Error', stacktrace: { frames: [ - { - 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, - }, + { 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 }, ], }, }); diff --git a/packages/browser/test/unit/tracekit/firefox.test.ts b/packages/browser/test/unit/tracekit/firefox.test.ts index 9a062d0a123b..f75dd7ccf010 100644 --- a/packages/browser/test/unit/tracekit/firefox.test.ts +++ b/packages/browser/test/unit/tracekit/firefox.test.ts @@ -26,55 +26,13 @@ describe('Tracekit - Firefox Tests', () => { type: 'TypeError', stacktrace: { frames: [ - { - 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, - }, + { 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 }, ], }, }); @@ -104,55 +62,13 @@ describe('Tracekit - Firefox Tests', () => { type: 'foo', stacktrace: { frames: [ - { - 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, - }, + { 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 }, ], }, }); @@ -178,27 +94,9 @@ describe('Tracekit - Firefox Tests', () => { type: 'foo', stacktrace: { frames: [ - { - 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, - }, + { 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 }, ], }, }); @@ -225,30 +123,9 @@ describe('Tracekit - Firefox Tests', () => { type: 'Error', stacktrace: { frames: [ - { - 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, - }, + { 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 }, ], }, }); @@ -281,33 +158,11 @@ describe('Tracekit - Firefox Tests', () => { type: 'NS_ERROR_FAILURE', stacktrace: { frames: [ - { - 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: '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: '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, @@ -348,7 +202,6 @@ 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, @@ -356,7 +209,6 @@ 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, @@ -389,43 +241,11 @@ describe('Tracekit - Firefox Tests', () => { type: 'foo', stacktrace: { frames: [ - { - 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, - }, + { 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 }, ], }, }); @@ -447,30 +267,9 @@ describe('Tracekit - Firefox Tests', () => { type: 'Error', stacktrace: { frames: [ - { - 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, - }, + { 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 }, ], }, }); @@ -498,77 +297,15 @@ describe('Tracekit - Firefox Tests', () => { type: 'Error', stacktrace: { frames: [ - { - 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, - }, + { 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 }, ], }, }); @@ -595,7 +332,6 @@ describe('Tracekit - Firefox Tests', () => { { colno: 1018410, filename: 'https://www.random_website.com/main.4a4119c3cdfd10266d84.js', - abs_path: 'https://www.random_website.com/main.4a4119c3cdfd10266d84.js', function: 'handleProfileResult', in_app: true, lineno: 146, @@ -603,7 +339,6 @@ 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, @@ -611,7 +346,6 @@ 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 6417a7043c32..544542b0dcaf 100644 --- a/packages/browser/test/unit/tracekit/ie.test.ts +++ b/packages/browser/test/unit/tracekit/ie.test.ts @@ -23,30 +23,9 @@ describe('Tracekit - IE Tests', () => { type: 'foo', stacktrace: { frames: [ - { - 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, - }, + { 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 }, ], }, }); @@ -73,30 +52,9 @@ describe('Tracekit - IE Tests', () => { type: 'TypeError', stacktrace: { frames: [ - { - 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, - }, + { 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 }, ], }, }); @@ -122,23 +80,9 @@ describe('Tracekit - IE Tests', () => { type: 'ReferenceError', stacktrace: { frames: [ - { - 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 }, + { 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 }, ], }, }); diff --git a/packages/browser/test/unit/tracekit/misc.test.ts b/packages/browser/test/unit/tracekit/misc.test.ts index dbe718c9410f..e9db457ea196 100644 --- a/packages/browser/test/unit/tracekit/misc.test.ts +++ b/packages/browser/test/unit/tracekit/misc.test.ts @@ -19,27 +19,9 @@ describe('Tracekit - Misc Tests', () => { type: 'foo', stacktrace: { frames: [ - { - 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: 'file:///path/to/file.js', - abs_path: 'file:///path/to/file.js', - function: '?', - lineno: 878, - in_app: true, - }, + { 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 }, ], }, }); diff --git a/packages/browser/test/unit/tracekit/opera.test.ts b/packages/browser/test/unit/tracekit/opera.test.ts index 08d7119fb5bb..e86855dc172a 100644 --- a/packages/browser/test/unit/tracekit/opera.test.ts +++ b/packages/browser/test/unit/tracekit/opera.test.ts @@ -37,55 +37,13 @@ describe('Tracekit - Opera Tests', () => { type: 'foo', stacktrace: { frames: [ - { - 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, - }, + { 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 }, ], }, }); @@ -125,62 +83,13 @@ describe('Tracekit - Opera Tests', () => { type: 'foo', stacktrace: { frames: [ - { - 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, - }, + { 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 }, ], }, }); @@ -213,7 +122,6 @@ describe('Tracekit - Opera Tests', () => { frames: [ { filename: 'http://localhost:8000/ExceptionLab.html', - abs_path: 'http://localhost:8000/ExceptionLab.html', function: '', lineno: 1, colno: 0, @@ -221,7 +129,6 @@ describe('Tracekit - Opera Tests', () => { }, { filename: 'http://localhost:8000/ExceptionLab.html', - abs_path: 'http://localhost:8000/ExceptionLab.html', function: 'dumpException3', lineno: 46, colno: 8, @@ -229,7 +136,6 @@ describe('Tracekit - Opera Tests', () => { }, { filename: 'http://localhost:8000/ExceptionLab.html', - abs_path: 'http://localhost:8000/ExceptionLab.html', function: '', lineno: 48, colno: 12, @@ -258,30 +164,9 @@ describe('Tracekit - Opera Tests', () => { type: 'TypeError', stacktrace: { frames: [ - { - 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, - }, + { 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 }, ], }, }); diff --git a/packages/browser/test/unit/tracekit/react-native.test.ts b/packages/browser/test/unit/tracekit/react-native.test.ts index 7615a27c4afe..9a74e46007b1 100644 --- a/packages/browser/test/unit/tracekit/react-native.test.ts +++ b/packages/browser/test/unit/tracekit/react-native.test.ts @@ -22,41 +22,18 @@ 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, @@ -64,20 +41,12 @@ 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', - abs_path: 'index.android.bundle', - function: 'Object.onPress', - lineno: 2342, - colno: 3773, - in_app: true, - }, + { filename: 'index.android.bundle', function: 'Object.onPress', lineno: 2342, colno: 3773, in_app: true }, ], }, }); @@ -100,12 +69,10 @@ describe('Tracekit - React Native Tests', () => { type: 'Error', stacktrace: { frames: [ - { filename: '[native code]', abs_path: '[native code]', function: 'forEach', in_app: true }, + { filename: '[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, @@ -114,8 +81,6 @@ 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, @@ -124,8 +89,6 @@ 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, @@ -134,8 +97,6 @@ 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, @@ -172,8 +133,6 @@ 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, @@ -182,8 +141,6 @@ 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, @@ -192,8 +149,6 @@ 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, @@ -202,8 +157,6 @@ 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, @@ -212,8 +165,6 @@ 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, @@ -222,8 +173,6 @@ 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, @@ -232,8 +181,6 @@ 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, @@ -241,7 +188,6 @@ 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, @@ -303,260 +249,73 @@ describe('Tracekit - React Native Tests', () => { type: 'Error', stacktrace: { frames: [ - { 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: '[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: '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]', abs_path: '[native code]', function: '?', 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: '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]', abs_path: '[native code]', function: '?', in_app: true }, + { filename: '[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', - 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, - }, + { 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 }, ], }, }); @@ -601,168 +360,38 @@ 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', - 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, - }, + { 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 }, ], }, }); diff --git a/packages/browser/test/unit/tracekit/react.test.ts b/packages/browser/test/unit/tracekit/react.test.ts index 5ebaa602ed06..d949a4dee0eb 100644 --- a/packages/browser/test/unit/tracekit/react.test.ts +++ b/packages/browser/test/unit/tracekit/react.test.ts @@ -23,17 +23,9 @@ describe('Tracekit - React Tests', () => { type: 'Invariant Violation', stacktrace: { frames: [ - { - filename: 'http://localhost:5000/', - abs_path: 'http://localhost:5000/', - function: 'f', - lineno: 1, - colno: 980, - in_app: true, - }, + { filename: '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, @@ -41,7 +33,6 @@ 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, @@ -49,7 +40,6 @@ 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, @@ -80,17 +70,9 @@ describe('Tracekit - React Tests', () => { type: 'Error', stacktrace: { frames: [ - { - filename: 'http://localhost:5000/', - abs_path: 'http://localhost:5000/', - function: 'f', - lineno: 1, - colno: 980, - in_app: true, - }, + { filename: '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, @@ -98,7 +80,6 @@ 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, @@ -106,7 +87,6 @@ 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, @@ -138,17 +118,9 @@ describe('Tracekit - React Tests', () => { type: 'Error', stacktrace: { frames: [ - { - filename: 'http://localhost:5000/', - abs_path: 'http://localhost:5000/', - function: 'f', - lineno: 1, - colno: 980, - in_app: true, - }, + { filename: '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, @@ -156,7 +128,6 @@ 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, @@ -164,7 +135,6 @@ 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 c2ff37cdfe4c..657ffc7daecc 100644 --- a/packages/browser/test/unit/tracekit/safari.test.ts +++ b/packages/browser/test/unit/tracekit/safari.test.ts @@ -22,28 +22,10 @@ describe('Tracekit - Safari Tests', () => { type: 'foo', stacktrace: { frames: [ - { 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, - }, + { 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 }, ], }, }); @@ -66,30 +48,9 @@ describe('Tracekit - Safari Tests', () => { type: 'TypeError', stacktrace: { frames: [ - { - 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, - }, + { 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 }, ], }, }); @@ -113,30 +74,9 @@ describe('Tracekit - Safari Tests', () => { type: 'TypeError', stacktrace: { frames: [ - { - 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, - }, + { 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 }, ], }, }); @@ -164,23 +104,9 @@ describe('Tracekit - Safari Tests', () => { type: 'ReferenceError', stacktrace: { frames: [ - { - 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 }, + { 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 }, ], }, }); @@ -205,7 +131,6 @@ 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, @@ -213,7 +138,6 @@ 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, @@ -239,10 +163,9 @@ describe('Tracekit - Safari Tests', () => { type: 'TypeError', stacktrace: { frames: [ - { filename: '[native code]', abs_path: '[native code]', function: 'promiseReactionJob', in_app: true }, + { filename: '[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, @@ -250,7 +173,6 @@ 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, @@ -279,7 +201,6 @@ 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, @@ -287,7 +208,6 @@ 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, @@ -313,10 +233,9 @@ describe('Tracekit - Safari Tests', () => { type: 'TypeError', stacktrace: { frames: [ - { filename: '[native code]', abs_path: '[native code]', function: 'promiseReactionJob', in_app: true }, + { filename: '[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, @@ -324,7 +243,6 @@ 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, @@ -353,31 +271,10 @@ describe('Tracekit - Safari Tests', () => { type: 'Error', stacktrace: { frames: [ - { - 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, - }, + { 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 }, ], }, }); @@ -408,73 +305,17 @@ describe('Tracekit - Safari Tests', () => { type: 'Error', stacktrace: { frames: [ - { - 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, - }, + { 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 }, ], }, }); diff --git a/packages/core/src/utils/prepareEvent.ts b/packages/core/src/utils/prepareEvent.ts index 043dc208bf49..09c6f87dfa8e 100644 --- a/packages/core/src/utils/prepareEvent.ts +++ b/packages/core/src/utils/prepareEvent.ts @@ -124,27 +124,27 @@ export function applyDebugMetadata(event: Event, stackParser: StackParser): void return; } - // Build a map of abs_path -> debug_id - const absPathDebugIdMap = Object.keys(debugIdMap).reduce>((acc, debugIdStackTrace) => { + // Build a map of filename -> debug_id + const filenameDebugIdMap = Object.keys(debugIdMap).reduce>((acc, debugIdStackTrace) => { const parsedStack = stackParser(debugIdStackTrace); for (const stackFrame of parsedStack) { - if (stackFrame.abs_path) { - acc[stackFrame.abs_path] = debugIdMap[debugIdStackTrace]; + if (stackFrame.filename) { + acc[stackFrame.filename] = debugIdMap[debugIdStackTrace]; break; } } return acc; }, {}); - // Get a Set of abs_paths in the stack trace - const errorAbsPaths = new Set(); + // Get a Set of filenames in the stack trace + const errorFileNames = new Set(); 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); + if (frame.filename) { + errorFileNames.add(frame.filename); } }); }); @@ -156,12 +156,12 @@ export function applyDebugMetadata(event: Event, stackParser: StackParser): void 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]) { + errorFileNames.forEach(filename => { + if (filenameDebugIdMap[filename]) { images.push({ type: 'sourcemap', - code_file: absPath, - debug_id: absPathDebugIdMap[absPath], + code_file: filename, + debug_id: filenameDebugIdMap[filename], }); } }); diff --git a/packages/core/test/lib/prepareEvent.test.ts b/packages/core/test/lib/prepareEvent.test.ts index b4cac98355e0..d08b4ace221d 100644 --- a/packages/core/test/lib/prepareEvent.test.ts +++ b/packages/core/test/lib/prepareEvent.test.ts @@ -15,7 +15,7 @@ describe('applyDebugMetadata', () => { 'filename4.js\nfilename4.js': 'cccccccc-cccc-4ccc-cccc-cccccccccc', }; - const stackParser = createStackParser([0, line => ({ filename: line, abs_path: line })]); + const stackParser = createStackParser([0, line => ({ filename: line })]); const event: Event = { exception: { @@ -23,10 +23,10 @@ describe('applyDebugMetadata', () => { { 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' }, + { filename: 'filename1.js' }, + { filename: 'filename2.js' }, + { filename: 'filename1.js' }, + { filename: 'filename3.js' }, ], }, }, diff --git a/packages/e2e-tests/test-applications/nextjs-app-dir/tests/devErrorSymbolification.test.ts b/packages/e2e-tests/test-applications/nextjs-app-dir/tests/devErrorSymbolification.test.ts index 2f7173cee315..f4841c2a6b16 100644 --- a/packages/e2e-tests/test-applications/nextjs-app-dir/tests/devErrorSymbolification.test.ts +++ b/packages/e2e-tests/test-applications/nextjs-app-dir/tests/devErrorSymbolification.test.ts @@ -23,7 +23,6 @@ test.describe('dev mode error symbolification', () => { expect.objectContaining({ function: 'onClick', filename: 'components/client-error-debug-tools.tsx', - abs_path: 'webpack-internal:///(app-client)/./components/client-error-debug-tools.tsx', lineno: 54, colno: 16, in_app: true, diff --git a/packages/nextjs/src/client/index.ts b/packages/nextjs/src/client/index.ts index 650f0607a2a2..d0be07a3c8d0 100644 --- a/packages/nextjs/src/client/index.ts +++ b/packages/nextjs/src/client/index.ts @@ -77,10 +77,8 @@ function addClientIntegrations(options: BrowserOptions): void { // Turn `//_next/static/...` into `app:///_next/static/...` iteratee: frame => { try { - const { origin: absPathOrigin } = new URL(frame.abs_path as string); - const { origin: filenameOrigin } = new URL(frame.filename as string); - frame.abs_path = frame.abs_path?.replace(absPathOrigin, 'app://').replace(assetPrefixPath, ''); - frame.filename = frame.filename?.replace(filenameOrigin, 'app://').replace(assetPrefixPath, ''); + const { origin } = new URL(frame.filename as string); + frame.filename = frame.filename?.replace(origin, 'app://').replace(assetPrefixPath, ''); } catch (err) { // Filename wasn't a properly formed URL, so there's nothing we can do } @@ -90,13 +88,10 @@ function addClientIntegrations(options: BrowserOptions): void { if (frame.filename && frame.filename.startsWith('app:///_next')) { frame.filename = decodeURI(frame.filename); } - if (frame.abs_path && frame.abs_path.startsWith('app:///_next')) { - frame.abs_path = decodeURI(frame.abs_path); - } if ( - frame.abs_path && - frame.abs_path.match( + frame.filename && + frame.filename.match( /^app:\/\/\/_next\/static\/chunks\/(main-|main-app-|polyfills-|webpack-|framework-|framework\.)[0-9a-f]+\.js$/, ) ) { diff --git a/packages/nextjs/src/common/devErrorSymbolicationEventProcessor.ts b/packages/nextjs/src/common/devErrorSymbolicationEventProcessor.ts index 2315f246cc91..7e3fd8baae24 100644 --- a/packages/nextjs/src/common/devErrorSymbolicationEventProcessor.ts +++ b/packages/nextjs/src/common/devErrorSymbolicationEventProcessor.ts @@ -126,7 +126,7 @@ export async function devErrorSymbolicationEventProcessor(event: Event, hint: Ev if (!resolvedFrame || !resolvedFrame.originalStackFrame || !resolvedFrame.originalCodeFrame) { return { ...frame, - platform: frame.abs_path?.startsWith('node:internal') ? 'nodejs' : undefined, // simple hack that will prevent a source mapping error from showing up + platform: frame.filename?.startsWith('node:internal') ? 'nodejs' : undefined, // simple hack that will prevent a source mapping error from showing up in_app: false, }; } diff --git a/packages/types/src/debugMeta.ts b/packages/types/src/debugMeta.ts index 2a6f201874da..da3cf958857b 100644 --- a/packages/types/src/debugMeta.ts +++ b/packages/types/src/debugMeta.ts @@ -17,6 +17,6 @@ interface WasmDebugImage { interface SourceMapDebugImage { type: 'sourcemap'; - code_file: string; // abs_path + code_file: string; // filename debug_id: string; // uuid } From 0ed4f8799233f821852cb4525c696c92a99c3f9d Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Mon, 27 Mar 2023 17:37:38 +0200 Subject: [PATCH 14/50] build(cdn): Move tracing CDN bundle generation to `@sentry/browser` (#7617) --- .github/workflows/build.yml | 21 ++--- .size-limit.js | 6 +- .../browser-integration-tests/package.json | 6 ++ .../startTransaction/basic_usage/test.ts | 10 ++- .../startTransaction/circular_data/test.ts | 6 +- .../startTransaction/setMeasurement/test.ts | 6 +- .../suites/replay/dsc/test.ts | 8 +- .../browserTracingIntegrationShim/test.ts | 7 +- .../suites/tracing/browserTracingShim/test.ts | 7 +- .../backgroundtab-custom/test.ts | 6 +- .../backgroundtab-pageload/test.ts | 4 +- .../browsertracing/interactions/test.ts | 10 ++- .../long-tasks-disabled/test.ts | 4 +- .../browsertracing/long-tasks-enabled/test.ts | 4 +- .../tracing/browsertracing/meta/test.ts | 18 +++- .../tracing/browsertracing/navigation/test.ts | 6 +- .../tracing/browsertracing/pageload/test.ts | 6 +- .../customTargets/test.ts | 5 ++ .../customTargetsAndOrigins/test.ts | 5 ++ .../customTracingOrigins/test.ts | 5 ++ .../defaultTargetsMatch/test.ts | 5 ++ .../defaultTargetsNoMatch/test.ts | 5 ++ .../envelope-header-transaction-name/test.ts | 10 ++- .../suites/tracing/envelope-header/test.ts | 10 ++- .../tracing/metrics/connection-rtt/test.ts | 4 +- .../metrics/pageload-browser-spans/test.ts | 6 +- .../metrics/pageload-resource-spans/test.ts | 6 +- .../tracing/metrics/web-vitals-cls/test.ts | 4 +- .../tracing/metrics/web-vitals-fid/test.ts | 4 +- .../tracing/metrics/web-vitals-fp-fcp/test.ts | 8 +- .../tracing/metrics/web-vitals-lcp/test.ts | 4 +- .../tracing/metrics/web-vitals-ttfb/test.ts | 6 +- .../suites/tracing/request/fetch/test.ts | 10 ++- .../suites/tracing/request/xhr/test.ts | 10 ++- .../utils/generatePlugin.ts | 48 +++++----- .../utils/helpers.ts | 12 +++ packages/browser/package.json | 8 +- packages/browser/rollup.bundle.config.js | 49 ++++++++--- packages/browser/src/exports.ts | 1 - packages/browser/src/index.bundle.replay.ts | 1 + .../src/index.bundle.tracing.replay.ts | 17 ++++ .../src/index.bundle.tracing.ts} | 8 +- packages/browser/src/index.bundle.ts | 1 + packages/browser/src/index.ts | 1 + .../unit/index.bundle.tracing.replay.test.ts} | 4 +- .../test/unit/index.bundle.tracing.test.ts} | 4 +- .../test-apps/booking-app/with-replay.html | 2 +- .../test-apps/booking-app/with-sentry.html | 2 +- .../test-apps/jank/with-replay.html | 2 +- .../test-apps/jank/with-sentry.html | 2 +- packages/tracing/package.json | 7 +- packages/tracing/rollup.bundle.config.js | 28 ------ packages/tracing/src/index.bundle.base.ts | 87 ------------------- packages/tracing/src/index.bundle.replay.ts | 11 --- packages/tracing/tsconfig.types.json | 6 -- 55 files changed, 296 insertions(+), 247 deletions(-) create mode 100644 packages/browser/src/index.bundle.tracing.replay.ts rename packages/{tracing/src/index.bundle.ts => browser/src/index.bundle.tracing.ts} (59%) rename packages/{tracing/test/index.bundle.replay.test.ts => browser/test/unit/index.bundle.tracing.replay.test.ts} (85%) rename packages/{tracing/test/index.bundle.test.ts => browser/test/unit/index.bundle.tracing.test.ts} (87%) delete mode 100644 packages/tracing/rollup.bundle.config.js delete mode 100644 packages/tracing/src/index.bundle.base.ts delete mode 100644 packages/tracing/src/index.bundle.replay.ts diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6004a046f126..4ac4a75e150b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -371,7 +371,6 @@ jobs: path: | ${{ github.workspace }}/packages/browser/build/bundles/** ${{ github.workspace }}/packages/integrations/build/bundles/** - ${{ github.workspace }}/packages/tracing/build/bundles/** ${{ github.workspace }}/packages/replay/build/bundles/** ${{ github.workspace }}/packages/**/*.tgz @@ -482,7 +481,7 @@ jobs: yarn test:integration job_browser_playwright_tests: - name: Playwright (${{ matrix.bundle }})${{ (matrix.tracing_only && ' tracing only') || '' }} Tests + name: Playwright (${{ matrix.bundle }}) Tests needs: [job_get_metadata, job_build] if: needs.job_get_metadata.outputs.changed_browser_integration == 'true' || github.event_name != 'pull_request' runs-on: ubuntu-20.04 @@ -499,16 +498,13 @@ jobs: - bundle_es6_min - bundle_replay_es6 - bundle_replay_es6_min - tracing_only: - - true - - false - exclude: - # `tracing_only` only makes a difference for bundles - tests of the esm and cjs builds always include the - # tracing tests - - bundle: esm - tracing_only: false - - bundle: cjs - tracing_only: false + - bundle_tracing_es5 + - bundle_tracing_es5_min + - bundle_tracing_es6 + - bundle_tracing_es6_min + - bundle_tracing_replay_es6 + - bundle_tracing_replay_es6_min + steps: - name: Check out current commit (${{ needs.job_get_metadata.outputs.commit_label }}) uses: actions/checkout@v3 @@ -543,7 +539,6 @@ jobs: - name: Run Playwright tests env: PW_BUNDLE: ${{ matrix.bundle }} - PW_TRACING_ONLY: ${{ matrix.tracing_only }} run: | cd packages/browser-integration-tests yarn test:ci diff --git a/.size-limit.js b/.size-limit.js index edc8a5466235..863b3628ebb1 100644 --- a/.size-limit.js +++ b/.size-limit.js @@ -53,13 +53,13 @@ module.exports = [ }, { name: '@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified)', - path: 'packages/tracing/build/bundles/bundle.tracing.es5.min.js', + path: 'packages/browser/build/bundles/bundle.tracing.es5.min.js', gzip: true, limit: '37 KB', }, { name: '@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified)', - path: 'packages/tracing/build/bundles/bundle.tracing.min.js', + path: 'packages/browser/build/bundles/bundle.tracing.min.js', gzip: true, limit: '35 KB', }, @@ -80,7 +80,7 @@ module.exports = [ }, { name: '@sentry/browser + @sentry/tracing + @sentry/replay - ES6 CDN Bundle (gzipped + minified)', - path: 'packages/tracing/build/bundles/bundle.tracing.replay.min.js', + path: 'packages/browser/build/bundles/bundle.tracing.replay.min.js', gzip: true, limit: '80 KB', }, diff --git a/packages/browser-integration-tests/package.json b/packages/browser-integration-tests/package.json index 242fe0ce0d5e..9b3c52e62ab0 100644 --- a/packages/browser-integration-tests/package.json +++ b/packages/browser-integration-tests/package.json @@ -25,6 +25,12 @@ "test:bundle:es6:min": "PW_BUNDLE=bundle_es6_min yarn test", "test:bundle:replay:es6": "PW_BUNDLE=bundle_replay_es6 yarn test", "test:bundle:replay:es6:min": "PW_BUNDLE=bundle_replay_es6_min yarn test", + "test:bundle:tracing:es5": "PW_BUNDLE=bundle_tracing_es5 yarn test", + "test:bundle:tracing:es5:min": "PW_BUNDLE=bundle_tracing_es5_min yarn test", + "test:bundle:tracing:es6": "PW_BUNDLE=bundle_tracing_es6 yarn test", + "test:bundle:tracing:es6:min": "PW_BUNDLE=bundle_tracing_es6_min yarn test", + "test:bundle:tracing:replay:es6": "PW_BUNDLE=bundle_tracing_replay_es6 yarn test", + "test:bundle:tracing:replay:es6:min": "PW_BUNDLE=bundle_tracing_replay_es6_min yarn test", "test:cjs": "PW_BUNDLE=cjs yarn test", "test:esm": "PW_BUNDLE=esm yarn test", "test:ci": "playwright test ./suites --browser='all' --reporter='line'", diff --git a/packages/browser-integration-tests/suites/public-api/startTransaction/basic_usage/test.ts b/packages/browser-integration-tests/suites/public-api/startTransaction/basic_usage/test.ts index 7b42d280248d..2fba18b0804b 100644 --- a/packages/browser-integration-tests/suites/public-api/startTransaction/basic_usage/test.ts +++ b/packages/browser-integration-tests/suites/public-api/startTransaction/basic_usage/test.ts @@ -2,9 +2,13 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest('should report a transaction in an envelope', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const transaction = await getFirstSentryEnvelopeRequest(page, url); @@ -13,6 +17,10 @@ sentryTest('should report a transaction in an envelope', async ({ getLocalTestPa }); sentryTest('should report finished spans as children of the root transaction', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const transaction = await getFirstSentryEnvelopeRequest(page, url); diff --git a/packages/browser-integration-tests/suites/public-api/startTransaction/circular_data/test.ts b/packages/browser-integration-tests/suites/public-api/startTransaction/circular_data/test.ts index 88ed63b08864..1870f679b3da 100644 --- a/packages/browser-integration-tests/suites/public-api/startTransaction/circular_data/test.ts +++ b/packages/browser-integration-tests/suites/public-api/startTransaction/circular_data/test.ts @@ -2,9 +2,13 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest('should be able to handle circular data', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const eventData = await getFirstSentryEnvelopeRequest(page, url); diff --git a/packages/browser-integration-tests/suites/public-api/startTransaction/setMeasurement/test.ts b/packages/browser-integration-tests/suites/public-api/startTransaction/setMeasurement/test.ts index fecda098bf43..fe45323474f0 100644 --- a/packages/browser-integration-tests/suites/public-api/startTransaction/setMeasurement/test.ts +++ b/packages/browser-integration-tests/suites/public-api/startTransaction/setMeasurement/test.ts @@ -2,9 +2,13 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest('should attach measurement to transaction', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const event = await getFirstSentryEnvelopeRequest(page, url); diff --git a/packages/browser-integration-tests/suites/replay/dsc/test.ts b/packages/browser-integration-tests/suites/replay/dsc/test.ts index 0819e9f7bf71..f4cca11e2339 100644 --- a/packages/browser-integration-tests/suites/replay/dsc/test.ts +++ b/packages/browser-integration-tests/suites/replay/dsc/test.ts @@ -2,12 +2,16 @@ import { expect } from '@playwright/test'; import type { EventEnvelopeHeaders } from '@sentry/types'; import { sentryTest } from '../../../utils/fixtures'; -import { envelopeHeaderRequestParser, getFirstSentryEnvelopeRequest } from '../../../utils/helpers'; +import { + envelopeHeaderRequestParser, + getFirstSentryEnvelopeRequest, + shouldSkipTracingTest, +} from '../../../utils/helpers'; import { getReplaySnapshot, shouldSkipReplayTest, waitForReplayRunning } from '../../../utils/replayHelpers'; sentryTest('should add replay_id to dsc of transactions', async ({ getLocalTestPath, page, browserName }) => { // This is flaky on webkit, so skipping there... - if (shouldSkipReplayTest() || browserName === 'webkit') { + if (shouldSkipReplayTest() || shouldSkipTracingTest() || browserName === 'webkit') { sentryTest.skip(); } diff --git a/packages/browser-integration-tests/suites/tracing/browserTracingIntegrationShim/test.ts b/packages/browser-integration-tests/suites/tracing/browserTracingIntegrationShim/test.ts index 5d2b96232d16..e37181ee815b 100644 --- a/packages/browser-integration-tests/suites/tracing/browserTracingIntegrationShim/test.ts +++ b/packages/browser-integration-tests/suites/tracing/browserTracingIntegrationShim/test.ts @@ -1,14 +1,13 @@ import { expect } from '@playwright/test'; import { sentryTest } from '../../../utils/fixtures'; +import { shouldSkipTracingTest } from '../../../utils/helpers'; sentryTest( 'exports a shim Integrations.BrowserTracing integration for non-tracing bundles', async ({ getLocalTestPath, page }) => { - const bundle = process.env.PW_BUNDLE; - const tracingOnly = Boolean(process.env.PW_TRACING_ONLY); - - if (!bundle || !bundle.startsWith('bundle_') || tracingOnly) { + // Skip in tracing tests + if (!shouldSkipTracingTest()) { sentryTest.skip(); } diff --git a/packages/browser-integration-tests/suites/tracing/browserTracingShim/test.ts b/packages/browser-integration-tests/suites/tracing/browserTracingShim/test.ts index 74cb8b2fce9f..7b6027694734 100644 --- a/packages/browser-integration-tests/suites/tracing/browserTracingShim/test.ts +++ b/packages/browser-integration-tests/suites/tracing/browserTracingShim/test.ts @@ -1,12 +1,11 @@ import { expect } from '@playwright/test'; import { sentryTest } from '../../../utils/fixtures'; +import { shouldSkipTracingTest } from '../../../utils/helpers'; sentryTest('exports a shim BrowserTracing integration for non-tracing bundles', async ({ getLocalTestPath, page }) => { - const bundle = process.env.PW_BUNDLE; - const tracingOnly = Boolean(process.env.PW_TRACING_ONLY); - - if (!bundle || !bundle.startsWith('bundle_') || tracingOnly) { + // Skip in tracing tests + if (!shouldSkipTracingTest()) { sentryTest.skip(); } diff --git a/packages/browser-integration-tests/suites/tracing/browsertracing/backgroundtab-custom/test.ts b/packages/browser-integration-tests/suites/tracing/browsertracing/backgroundtab-custom/test.ts index 8b201b7d7bbf..eca82197d80c 100644 --- a/packages/browser-integration-tests/suites/tracing/browsertracing/backgroundtab-custom/test.ts +++ b/packages/browser-integration-tests/suites/tracing/browsertracing/backgroundtab-custom/test.ts @@ -3,13 +3,17 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; async function getPropertyValue(handle: JSHandle, prop: string) { return (await handle.getProperty(prop))?.jsonValue(); } sentryTest('should finish a custom transaction when the page goes background', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const pageloadTransaction = await getFirstSentryEnvelopeRequest(page, url); diff --git a/packages/browser-integration-tests/suites/tracing/browsertracing/backgroundtab-pageload/test.ts b/packages/browser-integration-tests/suites/tracing/browsertracing/backgroundtab-pageload/test.ts index af7de77b93f7..17f5920c57de 100644 --- a/packages/browser-integration-tests/suites/tracing/browsertracing/backgroundtab-pageload/test.ts +++ b/packages/browser-integration-tests/suites/tracing/browsertracing/backgroundtab-pageload/test.ts @@ -2,13 +2,13 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest( 'should finish pageload transaction when the page goes background', async ({ browserName, getLocalTestPath, page }) => { // TODO: This is flakey on firefox... trace.status is sometimes undefined - if (['firefox'].includes(browserName)) { + if (shouldSkipTracingTest() || ['firefox'].includes(browserName)) { sentryTest.skip(); } const url = await getLocalTestPath({ testDir: __dirname }); diff --git a/packages/browser-integration-tests/suites/tracing/browsertracing/interactions/test.ts b/packages/browser-integration-tests/suites/tracing/browsertracing/interactions/test.ts index faff888fc2e8..9b161699b9c0 100644 --- a/packages/browser-integration-tests/suites/tracing/browsertracing/interactions/test.ts +++ b/packages/browser-integration-tests/suites/tracing/browsertracing/interactions/test.ts @@ -3,7 +3,11 @@ import { expect } from '@playwright/test'; import type { Event, Span, SpanContext, Transaction } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest, getMultipleSentryEnvelopeRequests } from '../../../../utils/helpers'; +import { + getFirstSentryEnvelopeRequest, + getMultipleSentryEnvelopeRequests, + shouldSkipTracingTest, +} from '../../../../utils/helpers'; type TransactionJSON = ReturnType & { spans: ReturnType[]; @@ -17,7 +21,7 @@ const wait = (time: number) => new Promise(res => setTimeout(res, time)); sentryTest('should capture interaction transaction.', async ({ browserName, getLocalTestPath, page }) => { const supportedBrowsers = ['chromium', 'firefox']; - if (!supportedBrowsers.includes(browserName)) { + if (shouldSkipTracingTest() || !supportedBrowsers.includes(browserName)) { sentryTest.skip(); } @@ -54,7 +58,7 @@ sentryTest('should capture interaction transaction.', async ({ browserName, getL sentryTest('should create only one transaction per interaction', async ({ browserName, getLocalTestPath, page }) => { const supportedBrowsers = ['chromium', 'firefox']; - if (!supportedBrowsers.includes(browserName)) { + if (shouldSkipTracingTest() || !supportedBrowsers.includes(browserName)) { sentryTest.skip(); } diff --git a/packages/browser-integration-tests/suites/tracing/browsertracing/long-tasks-disabled/test.ts b/packages/browser-integration-tests/suites/tracing/browsertracing/long-tasks-disabled/test.ts index c392258570d9..6dab208d1c4e 100644 --- a/packages/browser-integration-tests/suites/tracing/browsertracing/long-tasks-disabled/test.ts +++ b/packages/browser-integration-tests/suites/tracing/browsertracing/long-tasks-disabled/test.ts @@ -3,11 +3,11 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest('should not capture long task when flag is disabled.', async ({ browserName, getLocalTestPath, page }) => { // Long tasks only work on chrome - if (browserName !== 'chromium') { + if (shouldSkipTracingTest() || browserName !== 'chromium') { sentryTest.skip(); } diff --git a/packages/browser-integration-tests/suites/tracing/browsertracing/long-tasks-enabled/test.ts b/packages/browser-integration-tests/suites/tracing/browsertracing/long-tasks-enabled/test.ts index 9ee877e39268..54da1074c1c5 100644 --- a/packages/browser-integration-tests/suites/tracing/browsertracing/long-tasks-enabled/test.ts +++ b/packages/browser-integration-tests/suites/tracing/browsertracing/long-tasks-enabled/test.ts @@ -3,11 +3,11 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest('should capture long task.', async ({ browserName, getLocalTestPath, page }) => { // Long tasks only work on chrome - if (browserName !== 'chromium') { + if (shouldSkipTracingTest() || browserName !== 'chromium') { sentryTest.skip(); } diff --git a/packages/browser-integration-tests/suites/tracing/browsertracing/meta/test.ts b/packages/browser-integration-tests/suites/tracing/browsertracing/meta/test.ts index c447f41c8660..ae89fd383cbb 100644 --- a/packages/browser-integration-tests/suites/tracing/browsertracing/meta/test.ts +++ b/packages/browser-integration-tests/suites/tracing/browsertracing/meta/test.ts @@ -2,11 +2,19 @@ import { expect } from '@playwright/test'; import type { Event, EventEnvelopeHeaders } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { envelopeHeaderRequestParser, getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { + envelopeHeaderRequestParser, + getFirstSentryEnvelopeRequest, + shouldSkipTracingTest, +} from '../../../../utils/helpers'; sentryTest( 'should create a pageload transaction based on `sentry-trace` ', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const eventData = await getFirstSentryEnvelopeRequest(page, url); @@ -24,6 +32,10 @@ sentryTest( sentryTest( 'should pick up `baggage` tag, propagate the content in transaction and not add own data', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const envHeader = await getFirstSentryEnvelopeRequest(page, url, envelopeHeaderRequestParser); @@ -41,6 +53,10 @@ sentryTest( sentryTest( "should create a navigation that's not influenced by `sentry-trace` ", async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const pageloadRequest = await getFirstSentryEnvelopeRequest(page, url); diff --git a/packages/browser-integration-tests/suites/tracing/browsertracing/navigation/test.ts b/packages/browser-integration-tests/suites/tracing/browsertracing/navigation/test.ts index 77157951f494..5a46a65a4392 100644 --- a/packages/browser-integration-tests/suites/tracing/browsertracing/navigation/test.ts +++ b/packages/browser-integration-tests/suites/tracing/browsertracing/navigation/test.ts @@ -2,9 +2,13 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest('should create a navigation transaction on page navigation', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const pageloadRequest = await getFirstSentryEnvelopeRequest(page, url); diff --git a/packages/browser-integration-tests/suites/tracing/browsertracing/pageload/test.ts b/packages/browser-integration-tests/suites/tracing/browsertracing/pageload/test.ts index fc7de0b067b7..7624b26466e5 100644 --- a/packages/browser-integration-tests/suites/tracing/browsertracing/pageload/test.ts +++ b/packages/browser-integration-tests/suites/tracing/browsertracing/pageload/test.ts @@ -2,9 +2,13 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest('should create a pageload transaction', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const eventData = await getFirstSentryEnvelopeRequest(page, url); diff --git a/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTargets/test.ts b/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTargets/test.ts index ca1deada91d0..d7cf60e3e726 100644 --- a/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTargets/test.ts +++ b/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTargets/test.ts @@ -2,10 +2,15 @@ import type { Request } from '@playwright/test'; import { expect } from '@playwright/test'; import { sentryTest } from '../../../../../utils/fixtures'; +import { shouldSkipTracingTest } from '../../../../../utils/helpers'; sentryTest( 'should attach `sentry-trace` and `baggage` header to request matching tracePropagationTargets', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const requests = ( diff --git a/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTargetsAndOrigins/test.ts b/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTargetsAndOrigins/test.ts index 6e3fea23e09b..19c949ad07a7 100644 --- a/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTargetsAndOrigins/test.ts +++ b/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTargetsAndOrigins/test.ts @@ -2,10 +2,15 @@ import type { Request } from '@playwright/test'; import { expect } from '@playwright/test'; import { sentryTest } from '../../../../../utils/fixtures'; +import { shouldSkipTracingTest } from '../../../../../utils/helpers'; sentryTest( '[pre-v8] should prefer custom tracePropagationTargets over tracingOrigins', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const requests = ( diff --git a/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTracingOrigins/test.ts b/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTracingOrigins/test.ts index 0983c53a5622..47c24618492a 100644 --- a/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTracingOrigins/test.ts +++ b/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/customTracingOrigins/test.ts @@ -2,10 +2,15 @@ import type { Request } from '@playwright/test'; import { expect } from '@playwright/test'; import { sentryTest } from '../../../../../utils/fixtures'; +import { shouldSkipTracingTest } from '../../../../../utils/helpers'; sentryTest( '[pre-v8] should attach `sentry-trace` and `baggage` header to request matching tracingOrigins', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const requests = ( diff --git a/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/defaultTargetsMatch/test.ts b/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/defaultTargetsMatch/test.ts index c046912e6621..3edbd3d3c99b 100644 --- a/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/defaultTargetsMatch/test.ts +++ b/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/defaultTargetsMatch/test.ts @@ -2,10 +2,15 @@ import type { Request } from '@playwright/test'; import { expect } from '@playwright/test'; import { sentryTest } from '../../../../../utils/fixtures'; +import { shouldSkipTracingTest } from '../../../../../utils/helpers'; sentryTest( 'should attach `sentry-trace` and `baggage` header to request matching default tracePropagationTargets', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const requests = ( diff --git a/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/defaultTargetsNoMatch/test.ts b/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/defaultTargetsNoMatch/test.ts index 0767ced38bb5..445fa0fdba70 100644 --- a/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/defaultTargetsNoMatch/test.ts +++ b/packages/browser-integration-tests/suites/tracing/browsertracing/tracePropagationTargets/defaultTargetsNoMatch/test.ts @@ -2,10 +2,15 @@ import type { Request } from '@playwright/test'; import { expect } from '@playwright/test'; import { sentryTest } from '../../../../../utils/fixtures'; +import { shouldSkipTracingTest } from '../../../../../utils/helpers'; sentryTest( 'should not attach `sentry-trace` and `baggage` header to request not matching default tracePropagationTargets', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const requests = ( diff --git a/packages/browser-integration-tests/suites/tracing/envelope-header-transaction-name/test.ts b/packages/browser-integration-tests/suites/tracing/envelope-header-transaction-name/test.ts index 8d5b75e4907c..bc94930e0be5 100644 --- a/packages/browser-integration-tests/suites/tracing/envelope-header-transaction-name/test.ts +++ b/packages/browser-integration-tests/suites/tracing/envelope-header-transaction-name/test.ts @@ -2,11 +2,19 @@ import { expect } from '@playwright/test'; import type { EventEnvelopeHeaders } from '@sentry/types'; import { sentryTest } from '../../../utils/fixtures'; -import { envelopeHeaderRequestParser, getFirstSentryEnvelopeRequest } from '../../../utils/helpers'; +import { + envelopeHeaderRequestParser, + getFirstSentryEnvelopeRequest, + shouldSkipTracingTest, +} from '../../../utils/helpers'; sentryTest( 'should only include transaction name if source is better than an unparameterized URL', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const envHeader = await getFirstSentryEnvelopeRequest(page, url, envelopeHeaderRequestParser); diff --git a/packages/browser-integration-tests/suites/tracing/envelope-header/test.ts b/packages/browser-integration-tests/suites/tracing/envelope-header/test.ts index b70ae62b4903..b8df56e72f7c 100644 --- a/packages/browser-integration-tests/suites/tracing/envelope-header/test.ts +++ b/packages/browser-integration-tests/suites/tracing/envelope-header/test.ts @@ -2,11 +2,19 @@ import { expect } from '@playwright/test'; import type { EventEnvelopeHeaders } from '@sentry/types'; import { sentryTest } from '../../../utils/fixtures'; -import { envelopeHeaderRequestParser, getFirstSentryEnvelopeRequest } from '../../../utils/helpers'; +import { + envelopeHeaderRequestParser, + getFirstSentryEnvelopeRequest, + shouldSkipTracingTest, +} from '../../../utils/helpers'; sentryTest( 'should send dynamic sampling context data in trace envelope header of a transaction envelope', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const envHeader = await getFirstSentryEnvelopeRequest(page, url, envelopeHeaderRequestParser); diff --git a/packages/browser-integration-tests/suites/tracing/metrics/connection-rtt/test.ts b/packages/browser-integration-tests/suites/tracing/metrics/connection-rtt/test.ts index 273609e97d15..4dbb8f186d42 100644 --- a/packages/browser-integration-tests/suites/tracing/metrics/connection-rtt/test.ts +++ b/packages/browser-integration-tests/suites/tracing/metrics/connection-rtt/test.ts @@ -3,10 +3,10 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest.beforeEach(({ browserName }) => { - if (browserName !== 'chromium') { + if (shouldSkipTracingTest() || browserName !== 'chromium') { sentryTest.skip(); } }); diff --git a/packages/browser-integration-tests/suites/tracing/metrics/pageload-browser-spans/test.ts b/packages/browser-integration-tests/suites/tracing/metrics/pageload-browser-spans/test.ts index 8b8ca6b0f7b8..b60cdce9703b 100644 --- a/packages/browser-integration-tests/suites/tracing/metrics/pageload-browser-spans/test.ts +++ b/packages/browser-integration-tests/suites/tracing/metrics/pageload-browser-spans/test.ts @@ -2,9 +2,13 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest('should add browser-related spans to pageload transaction', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const eventData = await getFirstSentryEnvelopeRequest(page, url); diff --git a/packages/browser-integration-tests/suites/tracing/metrics/pageload-resource-spans/test.ts b/packages/browser-integration-tests/suites/tracing/metrics/pageload-resource-spans/test.ts index 83ae9580d84d..e98cb5b3d9b2 100644 --- a/packages/browser-integration-tests/suites/tracing/metrics/pageload-resource-spans/test.ts +++ b/packages/browser-integration-tests/suites/tracing/metrics/pageload-resource-spans/test.ts @@ -3,9 +3,13 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest('should add resource spans to pageload transaction', async ({ getLocalTestPath, page, browser }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + // Intercepting asset requests to avoid network-related flakiness and random retries (on Firefox). await page.route('**/path/to/image.svg', (route: Route) => route.fulfill({ path: `${__dirname}/assets/image.svg` })); await page.route('**/path/to/script.js', (route: Route) => route.fulfill({ path: `${__dirname}/assets/script.js` })); diff --git a/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-cls/test.ts b/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-cls/test.ts index a445cc967147..0dee366c75f4 100644 --- a/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-cls/test.ts +++ b/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-cls/test.ts @@ -2,10 +2,10 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest.beforeEach(async ({ browserName, page }) => { - if (browserName !== 'chromium') { + if (shouldSkipTracingTest() || browserName !== 'chromium') { sentryTest.skip(); } diff --git a/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-fid/test.ts b/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-fid/test.ts index 966760096add..55e0b4d0e833 100644 --- a/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-fid/test.ts +++ b/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-fid/test.ts @@ -2,11 +2,11 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest('should capture a FID vital.', async ({ browserName, getLocalTestPath, page }) => { // FID measurement is not generated on webkit - if (browserName === 'webkit') { + if (shouldSkipTracingTest() || browserName === 'webkit') { sentryTest.skip(); } diff --git a/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-fp-fcp/test.ts b/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-fp-fcp/test.ts index b120e580a55c..3a97c62d7f68 100644 --- a/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-fp-fcp/test.ts +++ b/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-fp-fcp/test.ts @@ -2,11 +2,11 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest('should capture FP vital.', async ({ browserName, getLocalTestPath, page }) => { // FP is not generated on webkit or firefox - if (browserName !== 'chromium') { + if (shouldSkipTracingTest() || browserName !== 'chromium') { sentryTest.skip(); } @@ -24,6 +24,10 @@ sentryTest('should capture FP vital.', async ({ browserName, getLocalTestPath, p }); sentryTest('should capture FCP vital.', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const eventData = await getFirstSentryEnvelopeRequest(page, url); diff --git a/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-lcp/test.ts b/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-lcp/test.ts index 7511abf60d09..63bfde0a6c46 100644 --- a/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-lcp/test.ts +++ b/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-lcp/test.ts @@ -3,10 +3,10 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest('should capture a LCP vital with element details.', async ({ browserName, getLocalTestPath, page }) => { - if (browserName !== 'chromium') { + if (shouldSkipTracingTest() || browserName !== 'chromium') { sentryTest.skip(); } diff --git a/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-ttfb/test.ts b/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-ttfb/test.ts index 81d5f1f7430e..0a4b1e6d3da6 100644 --- a/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-ttfb/test.ts +++ b/packages/browser-integration-tests/suites/tracing/metrics/web-vitals-ttfb/test.ts @@ -2,9 +2,13 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest('should capture TTFB vital.', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const eventData = await getFirstSentryEnvelopeRequest(page, url); diff --git a/packages/browser-integration-tests/suites/tracing/request/fetch/test.ts b/packages/browser-integration-tests/suites/tracing/request/fetch/test.ts index a5b8185e20f1..7b374422a2f3 100644 --- a/packages/browser-integration-tests/suites/tracing/request/fetch/test.ts +++ b/packages/browser-integration-tests/suites/tracing/request/fetch/test.ts @@ -3,9 +3,13 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getMultipleSentryEnvelopeRequests } from '../../../../utils/helpers'; +import { getMultipleSentryEnvelopeRequests, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest('should create spans for multiple fetch requests', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); // Because we fetch from http://example.com, fetch will throw a CORS error in firefox and webkit. @@ -38,6 +42,10 @@ sentryTest('should create spans for multiple fetch requests', async ({ getLocalT }); sentryTest('should attach `sentry-trace` header to multiple fetch requests', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const requests = ( diff --git a/packages/browser-integration-tests/suites/tracing/request/xhr/test.ts b/packages/browser-integration-tests/suites/tracing/request/xhr/test.ts index 39b2a37749b8..c1553e495999 100644 --- a/packages/browser-integration-tests/suites/tracing/request/xhr/test.ts +++ b/packages/browser-integration-tests/suites/tracing/request/xhr/test.ts @@ -3,9 +3,13 @@ import { expect } from '@playwright/test'; import type { Event } from '@sentry/types'; import { sentryTest } from '../../../../utils/fixtures'; -import { getFirstSentryEnvelopeRequest } from '../../../../utils/helpers'; +import { getFirstSentryEnvelopeRequest, shouldSkipTracingTest } from '../../../../utils/helpers'; sentryTest('should create spans for multiple XHR requests', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const eventData = await getFirstSentryEnvelopeRequest(page, url); @@ -26,6 +30,10 @@ sentryTest('should create spans for multiple XHR requests', async ({ getLocalTes }); sentryTest('should attach `sentry-trace` header to multiple XHR requests', async ({ getLocalTestPath, page }) => { + if (shouldSkipTracingTest()) { + sentryTest.skip(); + } + const url = await getLocalTestPath({ testDir: __dirname }); const requests = ( diff --git a/packages/browser-integration-tests/utils/generatePlugin.ts b/packages/browser-integration-tests/utils/generatePlugin.ts index 0c37e15b2426..7ca686992bc3 100644 --- a/packages/browser-integration-tests/utils/generatePlugin.ts +++ b/packages/browser-integration-tests/utils/generatePlugin.ts @@ -6,8 +6,9 @@ import type { Compiler } from 'webpack'; const PACKAGES_DIR = '../../packages'; -const tracingOnly = process.env.PW_TRACING_ONLY === 'true'; - +/** + * Possible values: See BUNDLE_PATHS.browser + */ const bundleKey = process.env.PW_BUNDLE; // `esm` and `cjs` builds are modules that can be imported / aliased by webpack @@ -26,16 +27,12 @@ const BUNDLE_PATHS: Record> = { bundle_es6_min: 'build/bundles/bundle.min.js', bundle_replay_es6: 'build/bundles/bundle.replay.js', bundle_replay_es6_min: 'build/bundles/bundle.replay.min.js', - }, - tracing: { - cjs: 'build/npm/cjs/index.js', - esm: 'build/npm/esm/index.js', - bundle_es5: 'build/bundles/bundle.tracing.es5.js', - bundle_es5_min: 'build/bundles/bundle.tracing.es5.min.js', - bundle_es6: 'build/bundles/bundle.tracing.js', - bundle_es6_min: 'build/bundles/bundle.tracing.min.js', - bundle_replay_es6: 'build/bundles/bundle.tracing.replay.js', - bundle_replay_es6_min: 'build/bundles/bundle.tracing.replay.min.js', + bundle_tracing_es5: 'build/bundles/bundle.tracing.es5.js', + bundle_tracing_es5_min: 'build/bundles/bundle.tracing.es5.min.js', + bundle_tracing_es6: 'build/bundles/bundle.tracing.js', + bundle_tracing_es6_min: 'build/bundles/bundle.tracing.min.js', + bundle_tracing_replay_es6: 'build/bundles/bundle.tracing.replay.js', + bundle_tracing_replay_es6_min: 'build/bundles/bundle.tracing.replay.min.js', }, integrations: { cjs: 'build/npm/cjs/index.js', @@ -44,16 +41,12 @@ const BUNDLE_PATHS: Record> = { bundle_es5_min: 'build/bundles/[INTEGRATION_NAME].es5.min.js', bundle_es6: 'build/bundles/[INTEGRATION_NAME].js', bundle_es6_min: 'build/bundles/[INTEGRATION_NAME].min.js', - bundle_replay_es6: 'build/bundles/[INTEGRATION_NAME].js', - bundle_replay_es6_min: 'build/bundles/[INTEGRATION_NAME].min.js', }, wasm: { cjs: 'build/npm/cjs/index.js', esm: 'build/npm/esm/index.js', bundle_es6: 'build/bundles/wasm.js', bundle_es6_min: 'build/bundles/wasm.min.js', - bundle_replay_es6: 'build/bundles/wasm.js', - bundle_replay_es6_min: 'build/bundles/wasm.min.js', }, }; @@ -100,7 +93,6 @@ function generateSentryAlias(): Record { } class SentryScenarioGenerationPlugin { - public requiresTracing: boolean = false; public requiredIntegrations: string[] = []; public requiresWASMIntegration: boolean = false; @@ -114,8 +106,8 @@ class SentryScenarioGenerationPlugin { // To help Webpack resolve Sentry modules in `import` statements in cases where they're provided in bundles rather than in `node_modules` '@sentry/browser': 'Sentry', '@sentry/tracing': 'Sentry', - '@sentry/integrations': 'Sentry.Integrations', '@sentry/replay': 'Sentry', + '@sentry/integrations': 'Sentry.Integrations', '@sentry/wasm': 'Sentry.Integrations', } : {}; @@ -127,9 +119,7 @@ class SentryScenarioGenerationPlugin { parser.hooks.import.tap( this._name, (statement: { specifiers: [{ imported: { name: string } }] }, source: string) => { - if (source === '@sentry/tracing') { - this.requiresTracing = true; - } else if (source === '@sentry/integrations') { + if (source === '@sentry/integrations') { this.requiredIntegrations.push(statement.specifiers[0].imported.name.toLowerCase()); } else if (source === '@sentry/wasm') { this.requiresWASMIntegration = true; @@ -142,10 +132,14 @@ class SentryScenarioGenerationPlugin { compiler.hooks.compilation.tap(this._name, compilation => { HtmlWebpackPlugin.getHooks(compilation).alterAssetTags.tapAsync(this._name, (data, cb) => { if (useBundle && bundleKey) { - const useTracingBundle = tracingOnly || this.requiresTracing; - const bundleName = useTracingBundle ? 'tracing' : 'browser'; + const bundleName = 'browser'; + const bundlePath = BUNDLE_PATHS[bundleName][bundleKey]; + + // Convert e.g. bundle_tracing_es5_min to bundle_es5_min + const integrationBundleKey = bundleKey.replace('_replay', '').replace('_tracing', ''); + const bundleObject = createHtmlTagObject('script', { - src: path.resolve(PACKAGES_DIR, bundleName, BUNDLE_PATHS[bundleName][bundleKey]), + src: path.resolve(PACKAGES_DIR, bundleName, bundlePath), }); this.requiredIntegrations.forEach(integration => { @@ -153,16 +147,16 @@ class SentryScenarioGenerationPlugin { src: path.resolve( PACKAGES_DIR, 'integrations', - BUNDLE_PATHS['integrations'][bundleKey].replace('[INTEGRATION_NAME]', integration), + BUNDLE_PATHS['integrations'][integrationBundleKey].replace('[INTEGRATION_NAME]', integration), ), }); data.assetTags.scripts.unshift(integrationObject); }); - if (this.requiresWASMIntegration && BUNDLE_PATHS['wasm'][bundleKey]) { + if (this.requiresWASMIntegration && BUNDLE_PATHS['wasm'][integrationBundleKey]) { const wasmObject = createHtmlTagObject('script', { - src: path.resolve(PACKAGES_DIR, 'wasm', BUNDLE_PATHS['wasm'][bundleKey]), + src: path.resolve(PACKAGES_DIR, 'wasm', BUNDLE_PATHS['wasm'][integrationBundleKey]), }); data.assetTags.scripts.unshift(wasmObject); diff --git a/packages/browser-integration-tests/utils/helpers.ts b/packages/browser-integration-tests/utils/helpers.ts index 25630ceba2fd..bbdb0c2d0655 100644 --- a/packages/browser-integration-tests/utils/helpers.ts +++ b/packages/browser-integration-tests/utils/helpers.ts @@ -125,6 +125,18 @@ export function waitForErrorRequest(page: Page): Promise { }); } +/** + * We can only test tracing tests in certain bundles/packages: + * - NPM (ESM, CJS) + * - CDN bundles that contain Tracing + * + * @returns `true` if we should skip the tracing test + */ +export function shouldSkipTracingTest(): boolean { + const bundle = process.env.PW_BUNDLE as string | undefined; + return bundle != null && !bundle.includes('tracing') && !bundle.includes('esm') && !bundle.includes('cjs'); +} + /** * Waits until a number of requests matching urlRgx at the given URL arrive. * If the timout option is configured, this function will abort waiting, even if it hasn't reveived the configured diff --git a/packages/browser/package.json b/packages/browser/package.json index 6c04362b76b2..7fff37cdc75f 100644 --- a/packages/browser/package.json +++ b/packages/browser/package.json @@ -49,12 +49,14 @@ "scripts": { "build": "run-p build:transpile build:bundle build:types", "build:dev": "yarn build", - "build:bundle": "rollup --config rollup.bundle.config.js", + "build:bundle": "run-p build:bundle:es5 build:bundle:es6", + "build:bundle:es5": "JS_VERSION=es5 rollup -c rollup.bundle.config.js", + "build:bundle:es6": "JS_VERSION=es6 rollup -c rollup.bundle.config.js", "build:transpile": "rollup -c rollup.npm.config.js", "build:types": "tsc -p tsconfig.types.json", "build:watch": "run-p build:transpile:watch build:bundle:watch build:types:watch", "build:dev:watch": "yarn build:watch", - "build:bundle:watch": "rollup --config rollup.bundle.config.js --watch", + "build:bundle:watch": "rollup -c rollup.bundle.config.js --watch", "build:transpile:watch": "rollup -c rollup.npm.config.js --watch", "build:types:watch": "tsc -p tsconfig.types.json --watch", "build:tarball": "ts-node ../../scripts/prepack.ts --bundles && npm pack ./build/npm", @@ -66,7 +68,7 @@ "lint": "run-s lint:prettier lint:eslint", "lint:eslint": "eslint . --format stylish", "lint:prettier": "prettier --check \"{src,test,scripts}/**/**.ts\"", - "validate:es5": "es-check es5 build/bundles/bundle.es5.js", + "validate:es5": "es-check es5 'build/bundles/*.es5*.js'", "size:check": "run-p size:check:es5 size:check:es6", "size:check:es5": "cat build/bundles/bundle.min.js | gzip -9 | wc -c | awk '{$1=$1/1024; print \"ES5: \",$1,\"kB\";}'", "size:check:es6": "cat build/bundles/bundle.es6.min.js | gzip -9 | wc -c | awk '{$1=$1/1024; print \"ES6: \",$1,\"kB\";}'", diff --git a/packages/browser/rollup.bundle.config.js b/packages/browser/rollup.bundle.config.js index 6ef24dd841a5..3bb87e0c5e7b 100644 --- a/packages/browser/rollup.bundle.config.js +++ b/packages/browser/rollup.bundle.config.js @@ -2,7 +2,13 @@ import { makeBaseBundleConfig, makeBundleConfigVariants } from '../../rollup/ind const builds = []; -['es5', 'es6'].forEach(jsVersion => { +const targets = process.env.JS_VERSION ? [process.env.JS_VERSION] : ['es5', 'es6']; + +if (targets.some(target => target !== 'es5' && target !== 'es6')) { + throw new Error('JS_VERSION must be either "es5" or "es6"'); +} + +targets.forEach(jsVersion => { const baseBundleConfig = makeBaseBundleConfig({ bundleType: 'standalone', entrypoints: ['src/index.bundle.ts'], @@ -11,18 +17,39 @@ const builds = []; outputFileBase: () => `bundles/bundle${jsVersion === 'es5' ? '.es5' : ''}`, }); - builds.push(...makeBundleConfigVariants(baseBundleConfig)); -}); + const tracingBaseBundleConfig = makeBaseBundleConfig({ + bundleType: 'standalone', + entrypoints: ['src/index.bundle.tracing.ts'], + jsVersion, + licenseTitle: '@sentry/browser & @sentry/tracing', + outputFileBase: () => `bundles/bundle.tracing${jsVersion === 'es5' ? '.es5' : ''}`, + }); -// Full bundle incl. replay only available for es6 -const replayBaseBundleConfig = makeBaseBundleConfig({ - bundleType: 'standalone', - entrypoints: ['src/index.bundle.replay.ts'], - jsVersion: 'es6', - licenseTitle: '@sentry/browser & @sentry/replay', - outputFileBase: () => 'bundles/bundle.replay', + builds.push(...makeBundleConfigVariants(baseBundleConfig), ...makeBundleConfigVariants(tracingBaseBundleConfig)); }); -builds.push(...makeBundleConfigVariants(replayBaseBundleConfig)); +if (targets.includes('es6')) { + // Replay bundles only available for es6 + const replayBaseBundleConfig = makeBaseBundleConfig({ + bundleType: 'standalone', + entrypoints: ['src/index.bundle.replay.ts'], + jsVersion: 'es6', + licenseTitle: '@sentry/browser & @sentry/replay', + outputFileBase: () => 'bundles/bundle.replay', + }); + + const tracingReplayBaseBundleConfig = makeBaseBundleConfig({ + bundleType: 'standalone', + entrypoints: ['src/index.bundle.tracing.replay.ts'], + jsVersion: 'es6', + licenseTitle: '@sentry/browser & @sentry/tracing & @sentry/replay', + outputFileBase: () => 'bundles/bundle.tracing.replay', + }); + + builds.push( + ...makeBundleConfigVariants(replayBaseBundleConfig), + ...makeBundleConfigVariants(tracingReplayBaseBundleConfig), + ); +} export default builds; diff --git a/packages/browser/src/exports.ts b/packages/browser/src/exports.ts index 7fdd9ba2d5fe..321ebd2c6c51 100644 --- a/packages/browser/src/exports.ts +++ b/packages/browser/src/exports.ts @@ -9,7 +9,6 @@ export type { // eslint-disable-next-line deprecation/deprecation Severity, SeverityLevel, - Span, StackFrame, Stacktrace, Thread, diff --git a/packages/browser/src/index.bundle.replay.ts b/packages/browser/src/index.bundle.replay.ts index 9a220d0ecca9..affadece35da 100644 --- a/packages/browser/src/index.bundle.replay.ts +++ b/packages/browser/src/index.bundle.replay.ts @@ -11,3 +11,4 @@ Sentry.Integrations.BrowserTracing = BrowserTracing; export * from './index.bundle.base'; export { BrowserTracing, addTracingExtensions, Replay }; +// Note: We do not export a shim for `Span` here, as that is quite complex and would blow up the bundle diff --git a/packages/browser/src/index.bundle.tracing.replay.ts b/packages/browser/src/index.bundle.tracing.replay.ts new file mode 100644 index 000000000000..418aeb61bd18 --- /dev/null +++ b/packages/browser/src/index.bundle.tracing.replay.ts @@ -0,0 +1,17 @@ +import { addExtensionMethods, BrowserTracing, Span } from '@sentry-internal/tracing'; +import { Replay } from '@sentry/replay'; + +import * as Sentry from './index.bundle.base'; + +// TODO (v8): Remove this as it was only needed for backwards compatibility +// We want replay to be available under Sentry.Replay, to be consistent +// with the NPM package version. +Sentry.Integrations.Replay = Replay; + +Sentry.Integrations.BrowserTracing = BrowserTracing; + +// We are patching the global object with our hub extension methods +addExtensionMethods(); + +export { Replay, BrowserTracing, Span, addExtensionMethods }; +export * from './index.bundle.base'; diff --git a/packages/tracing/src/index.bundle.ts b/packages/browser/src/index.bundle.tracing.ts similarity index 59% rename from packages/tracing/src/index.bundle.ts rename to packages/browser/src/index.bundle.tracing.ts index 8169e348b0a7..3aa5d960d19a 100644 --- a/packages/tracing/src/index.bundle.ts +++ b/packages/browser/src/index.bundle.tracing.ts @@ -1,5 +1,6 @@ // This is exported so the loader does not fail when switching off Replay import { Replay } from '@sentry-internal/integration-shims'; +import { addExtensionMethods, BrowserTracing, Span } from '@sentry-internal/tracing'; import * as Sentry from './index.bundle.base'; @@ -8,5 +9,10 @@ import * as Sentry from './index.bundle.base'; // with the NPM package version. Sentry.Integrations.Replay = Replay; -export { Replay }; +Sentry.Integrations.BrowserTracing = BrowserTracing; + +// We are patching the global object with our hub extension methods +addExtensionMethods(); + +export { Replay, BrowserTracing, Span, addExtensionMethods }; export * from './index.bundle.base'; diff --git a/packages/browser/src/index.bundle.ts b/packages/browser/src/index.bundle.ts index d16c008e7575..869139e7e591 100644 --- a/packages/browser/src/index.bundle.ts +++ b/packages/browser/src/index.bundle.ts @@ -10,3 +10,4 @@ Sentry.Integrations.BrowserTracing = BrowserTracing; export * from './index.bundle.base'; export { BrowserTracing, addTracingExtensions, Replay }; +// Note: We do not export a shim for `Span` here, as that is quite complex and would blow up the bundle diff --git a/packages/browser/src/index.ts b/packages/browser/src/index.ts index b3c0e7750bd2..75137f210816 100644 --- a/packages/browser/src/index.ts +++ b/packages/browser/src/index.ts @@ -30,6 +30,7 @@ export { trace, } from '@sentry/core'; export type { SpanStatusType } from '@sentry/core'; +export type { Span } from '@sentry/types'; export { makeBrowserOfflineTransport } from './transports/offline'; export { onProfilingStartRouteTransaction } from './profiling/hubextensions'; export { BrowserProfilingIntegration } from './profiling/integration'; diff --git a/packages/tracing/test/index.bundle.replay.test.ts b/packages/browser/test/unit/index.bundle.tracing.replay.test.ts similarity index 85% rename from packages/tracing/test/index.bundle.replay.test.ts rename to packages/browser/test/unit/index.bundle.tracing.replay.test.ts index b860e6336679..ac951e24445d 100644 --- a/packages/tracing/test/index.bundle.replay.test.ts +++ b/packages/browser/test/unit/index.bundle.tracing.replay.test.ts @@ -1,9 +1,9 @@ import { BrowserTracing } from '@sentry-internal/tracing'; import { Replay } from '@sentry/browser'; -import * as TracingReplayBundle from '../src/index.bundle.replay'; +import * as TracingReplayBundle from '../../src/index.bundle.tracing.replay'; -describe('index.bundle.replay', () => { +describe('index.bundle.tracing.replay', () => { it('has correct exports', () => { Object.keys(TracingReplayBundle.Integrations).forEach(key => { // Skip BrowserTracing because it doesn't have a static id field. diff --git a/packages/tracing/test/index.bundle.test.ts b/packages/browser/test/unit/index.bundle.tracing.test.ts similarity index 87% rename from packages/tracing/test/index.bundle.test.ts rename to packages/browser/test/unit/index.bundle.tracing.test.ts index db1cb7b9f433..1f92a02858ac 100644 --- a/packages/tracing/test/index.bundle.test.ts +++ b/packages/browser/test/unit/index.bundle.tracing.test.ts @@ -1,9 +1,9 @@ import { Replay as ReplayShim } from '@sentry-internal/integration-shims'; import { BrowserTracing } from '@sentry-internal/tracing'; -import * as TracingBundle from '../src/index.bundle'; +import * as TracingBundle from '../../src/index.bundle.tracing'; -describe('index.bundle', () => { +describe('index.bundle.tracing', () => { it('has correct exports', () => { Object.keys(TracingBundle.Integrations).forEach(key => { // Skip BrowserTracing because it doesn't have a static id field. diff --git a/packages/overhead-metrics/test-apps/booking-app/with-replay.html b/packages/overhead-metrics/test-apps/booking-app/with-replay.html index 9c4e0da222a7..7f471cc12c94 100644 --- a/packages/overhead-metrics/test-apps/booking-app/with-replay.html +++ b/packages/overhead-metrics/test-apps/booking-app/with-replay.html @@ -215,7 +215,7 @@

      This is a test app.

      - + - + - + - +