From ea20d8db38f334f01e7c1581ddc0ded16c3bbb27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Peer=20St=C3=B6cklmair?= Date: Tue, 4 Nov 2025 16:54:07 +0100 Subject: [PATCH 01/12] test(node-core): Proof that withMonitor doesn't create a new trace (#18057) In #18029 the expectation is that the `withMonitor` is creating a new trace. Currently it is not reflected in the docs what is expected when `withMonitor` is executed. This test proofs that this is the case. --- .../test/integration/transactions.test.ts | 64 ++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/packages/node-core/test/integration/transactions.test.ts b/packages/node-core/test/integration/transactions.test.ts index 7b13a400dedb..e00cbc8580d1 100644 --- a/packages/node-core/test/integration/transactions.test.ts +++ b/packages/node-core/test/integration/transactions.test.ts @@ -1,5 +1,5 @@ import { context, trace, TraceFlags } from '@opentelemetry/api'; -import type { TransactionEvent } from '@sentry/core'; +import type { ErrorEvent, TransactionEvent } from '@sentry/core'; import { debug, SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SEMANTIC_ATTRIBUTE_SENTRY_SOURCE } from '@sentry/core'; import { afterEach, describe, expect, it, vi } from 'vitest'; import * as Sentry from '../../src'; @@ -9,6 +9,7 @@ describe('Integration | Transactions', () => { afterEach(() => { vi.restoreAllMocks(); cleanupOtel(); + vi.useRealTimers(); }); it('correctly creates transaction & spans', async () => { @@ -674,4 +675,65 @@ describe('Integration | Transactions', () => { expect(spans).toContainEqual(expect.objectContaining({ description: 'inner span 1' })); expect(spans).toContainEqual(expect.objectContaining({ description: 'inner span 2' })); }); + + it('withMonitor should use the same traces for each monitor', async () => { + const sendEvents: ErrorEvent[] = []; + const transactionEvents: TransactionEvent[] = []; + const beforeSendTransaction = vi.fn((event: TransactionEvent) => { + transactionEvents.push(event); + return null; + }); + const beforeSend = vi.fn((event: ErrorEvent) => { + sendEvents.push(event); + return null; + }); + + mockSdkInit({ + tracesSampleRate: 1, + beforeSendTransaction, + beforeSend, + debug: true, + }); + + const client = Sentry.getClient(); + const errorMessage = 'Error outside withMonitor'; + + Sentry.startSpan({ name: 'span outside error' }, () => { + Sentry.withMonitor('cron-job-1', () => Sentry.startSpan({ name: 'inner span 1' }, () => undefined)); + + try { + throw new Error(errorMessage); + } catch (e) { + Sentry.startSpan({ name: 'span inside error' }, () => undefined); + Sentry.captureException(e); + } + + Sentry.withMonitor('cron-job-2', () => { + Sentry.startSpan({ name: 'inner span 2' }, () => undefined); + }); + }); + + await client?.flush(); + + const transactionTraceId = transactionEvents[0]?.contexts?.trace?.trace_id; + const errorTraceId = sendEvents[0]?.contexts?.trace?.trace_id; + + expect(beforeSendTransaction).toHaveBeenCalledTimes(1); + expect(beforeSend).toHaveBeenCalledTimes(1); + expect(transactionEvents).toHaveLength(1); + expect(transactionTraceId).toBe(errorTraceId); + expect(transactionEvents[0]?.spans).toHaveLength(3); + expect(transactionEvents).toMatchObject([ + { + spans: [{ description: 'inner span 1' }, { description: 'span inside error' }, { description: 'inner span 2' }], + }, + ]); + expect(sendEvents).toMatchObject([ + { + exception: { + values: [{ value: errorMessage }], + }, + }, + ]); + }); }); From 6360009e8ec3888b7835b8ec2980bae020b9bd91 Mon Sep 17 00:00:00 2001 From: Billy Vong Date: Wed, 5 Nov 2025 18:14:07 -0500 Subject: [PATCH 02/12] feat(replay): ignore `background-image` when `blockAllMedia` is enabled (#18019) Pass `ignoreCSSAttributes` with `background-imgae` to ignore background images when `blockAllMedia` is enabled. `ignoreCSSAttributes` was expanded in [this PR](https://github.com/getsentry/rrweb/pull/252) so that it also works for inline styles. --- .size-limit.js | 2 +- packages/replay-canvas/package.json | 2 +- packages/replay-internal/package.json | 4 +- packages/replay-internal/src/integration.ts | 1 + .../test/integration/rrweb.test.ts | 9 ++++ yarn.lock | 42 +++++++++---------- 6 files changed, 35 insertions(+), 25 deletions(-) diff --git a/.size-limit.js b/.size-limit.js index cada598de81b..c3f0e79d35fa 100644 --- a/.size-limit.js +++ b/.size-limit.js @@ -197,7 +197,7 @@ module.exports = [ path: createCDNPath('bundle.tracing.replay.min.js'), gzip: false, brotli: false, - limit: '240 KB', + limit: '245 KB', }, { name: 'CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed', diff --git a/packages/replay-canvas/package.json b/packages/replay-canvas/package.json index a03b3e2fa712..02e80ec8f265 100644 --- a/packages/replay-canvas/package.json +++ b/packages/replay-canvas/package.json @@ -66,7 +66,7 @@ }, "homepage": "https://docs.sentry.io/platforms/javascript/session-replay/", "devDependencies": { - "@sentry-internal/rrweb": "2.37.0" + "@sentry-internal/rrweb": "2.40.0" }, "dependencies": { "@sentry-internal/replay": "10.23.0", diff --git a/packages/replay-internal/package.json b/packages/replay-internal/package.json index f069f9e02d29..4dfa1171ea8d 100644 --- a/packages/replay-internal/package.json +++ b/packages/replay-internal/package.json @@ -82,8 +82,8 @@ "devDependencies": { "@babel/core": "^7.27.7", "@sentry-internal/replay-worker": "10.23.0", - "@sentry-internal/rrweb": "2.37.0", - "@sentry-internal/rrweb-snapshot": "2.37.0", + "@sentry-internal/rrweb": "2.40.0", + "@sentry-internal/rrweb-snapshot": "2.40.0", "fflate": "0.8.2", "jest-matcher-utils": "^29.0.0", "jsdom-worker": "^0.3.0", diff --git a/packages/replay-internal/src/integration.ts b/packages/replay-internal/src/integration.ts index 41c5966b88c5..17129bd57445 100644 --- a/packages/replay-internal/src/integration.ts +++ b/packages/replay-internal/src/integration.ts @@ -187,6 +187,7 @@ export class Replay implements Integration { this._recordingOptions.blockSelector = !this._recordingOptions.blockSelector ? MEDIA_SELECTORS : `${this._recordingOptions.blockSelector},${MEDIA_SELECTORS}`; + this._recordingOptions.ignoreCSSAttributes = new Set(['background-image']); } if (this._isInitialized && isBrowser()) { diff --git a/packages/replay-internal/test/integration/rrweb.test.ts b/packages/replay-internal/test/integration/rrweb.test.ts index 7dafb3574a31..8e889f53da52 100644 --- a/packages/replay-internal/test/integration/rrweb.test.ts +++ b/packages/replay-internal/test/integration/rrweb.test.ts @@ -28,6 +28,9 @@ describe('Integration | rrweb', () => { "collectFonts": true, "emit": [Function], "errorHandler": [Function], + "ignoreCSSAttributes": Set { + "background-image", + }, "ignoreSelector": ".sentry-test-ignore,.sentry-ignore,[data-sentry-ignore],input[type="file"]", "inlineImages": false, "inlineStylesheet": true, @@ -69,6 +72,9 @@ describe('Integration | rrweb', () => { "collectFonts": true, "emit": [Function], "errorHandler": [Function], + "ignoreCSSAttributes": Set { + "background-image", + }, "ignoreSelector": ".sentry-ignore,[data-sentry-ignore],input[type="file"]", "inlineImages": false, "inlineStylesheet": true, @@ -121,6 +127,9 @@ describe('Integration | rrweb', () => { "collectFonts": true, "emit": [Function], "errorHandler": [Function], + "ignoreCSSAttributes": Set { + "background-image", + }, "ignoreSelector": ".sentry-ignore,[data-sentry-ignore],input[type="file"]", "inlineImages": false, "inlineStylesheet": true, diff --git a/yarn.lock b/yarn.lock index 0142b73605c8..a94b2263b7f1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6951,22 +6951,22 @@ dependencies: "@sentry-internal/rrweb-snapshot" "2.34.0" -"@sentry-internal/rrdom@2.37.0": - version "2.37.0" - resolved "https://registry.yarnpkg.com/@sentry-internal/rrdom/-/rrdom-2.37.0.tgz#1aaf382eb7b543d7c256d31b73868e81e6649fbb" - integrity sha512-Wj6W4HP6kVYL1oenYq+Ec7QKtsq1Btk/acFLfZ/O7fygLVeAM0KZ4JZirPWdJmpeNNIk1YN7a8C7CfCiM014Ag== +"@sentry-internal/rrdom@2.40.0": + version "2.40.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/rrdom/-/rrdom-2.40.0.tgz#2afd76ab6695a63e7b000cb3c101029cd2ccd48b" + integrity sha512-QBnn2F0qi4Lx7TZW41CdRek/vWWLZCDx1Ywc1SimBX+byuVmNP84qvnVI4wKMoDvU6AcQiWHAgX2tGoa3Ol8pw== dependencies: - "@sentry-internal/rrweb-snapshot" "2.37.0" + "@sentry-internal/rrweb-snapshot" "2.40.0" "@sentry-internal/rrweb-snapshot@2.34.0": version "2.34.0" resolved "https://registry.yarnpkg.com/@sentry-internal/rrweb-snapshot/-/rrweb-snapshot-2.34.0.tgz#79c2049b6c887e3c128d5fa80d6f745a61dd0e68" integrity sha512-9Tb8jwVufn5GLV0d/CTuoZWo2O06ZB+xWeTJdEkbtJ6PAmO/Q7GQI3uNIx0pfFEnXP+0Km8CKKxpwkEM0z2m6w== -"@sentry-internal/rrweb-snapshot@2.37.0": - version "2.37.0" - resolved "https://registry.yarnpkg.com/@sentry-internal/rrweb-snapshot/-/rrweb-snapshot-2.37.0.tgz#2081d1827a108a08cab219234952744e6e79c06b" - integrity sha512-fu2/Fd5J5gJrAgQgl9WykVPQkMjo+9MVFy4Y88STTP3WWsLu1u75YAQM6Lr1/tLEykoQ4NecmNDdcz/DiB/nNg== +"@sentry-internal/rrweb-snapshot@2.40.0": + version "2.40.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/rrweb-snapshot/-/rrweb-snapshot-2.40.0.tgz#873e9be9967d7e4b6518beb7d9dfbdf5bbe043ac" + integrity sha512-uxYlYUIiybRqcyp5go46G5lcOswTFfeen8PelYVQsiLX34I7eugNfLgFchpBdiWv1FXwsautBWyOsZlxCPc3Zw== "@sentry-internal/rrweb-types@2.34.0": version "2.34.0" @@ -6976,12 +6976,12 @@ "@sentry-internal/rrweb-snapshot" "2.34.0" "@types/css-font-loading-module" "0.0.7" -"@sentry-internal/rrweb-types@2.37.0": - version "2.37.0" - resolved "https://registry.yarnpkg.com/@sentry-internal/rrweb-types/-/rrweb-types-2.37.0.tgz#edc91ee032896788fa9a6f96c76f1f6dd7c9f538" - integrity sha512-ydtHzfGFO6Tyw4n7yOLUrdaNKmRdyaVfqNgObEbEgO/qobzxBV5zf8eNApTayy6SOji3NrF8PpJzm55OX/ChNA== +"@sentry-internal/rrweb-types@2.40.0": + version "2.40.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/rrweb-types/-/rrweb-types-2.40.0.tgz#0c16376b83d264548f67e757dc28ae01d2e46991" + integrity sha512-d4MB1NI7KeomX0vRy0E7OQJHI+WvbeKvwAHqG/xV94A4ZscKkF7DoAQUvyeBsFf3tED/SuwV75HNEnq2uwk/cQ== dependencies: - "@sentry-internal/rrweb-snapshot" "2.37.0" + "@sentry-internal/rrweb-snapshot" "2.40.0" "@types/css-font-loading-module" "0.0.7" "@sentry-internal/rrweb@2.34.0": @@ -6998,14 +6998,14 @@ fflate "^0.4.4" mitt "^3.0.0" -"@sentry-internal/rrweb@2.37.0": - version "2.37.0" - resolved "https://registry.yarnpkg.com/@sentry-internal/rrweb/-/rrweb-2.37.0.tgz#8ea0eb906e194060c60f4a6af4a0d3a16d52cdec" - integrity sha512-erN53M1WSPGpsMw+iVX6qWhI4id41+2AXcnALoB2JIyL/Q1W8f2loq/a4PxWkhaaq7mtGiHTmNTbks8Qgrsl9g== +"@sentry-internal/rrweb@2.40.0": + version "2.40.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/rrweb/-/rrweb-2.40.0.tgz#9d60899800f21f061f38b1b62ddc64df1ff525bb" + integrity sha512-niFva5QmCTfavotLvIeFSvO0rfzbJwW04igcPaWAqTDATi+Xife27iBeVMBmjpHEWygGYkBaGyBQUUi8zUdAyg== dependencies: - "@sentry-internal/rrdom" "2.37.0" - "@sentry-internal/rrweb-snapshot" "2.37.0" - "@sentry-internal/rrweb-types" "2.37.0" + "@sentry-internal/rrdom" "2.40.0" + "@sentry-internal/rrweb-snapshot" "2.40.0" + "@sentry-internal/rrweb-types" "2.40.0" "@types/css-font-loading-module" "0.0.7" "@xstate/fsm" "^1.4.0" base64-arraybuffer "^1.0.1" From de5c5cbe177b4334386e747857225eec36a91ea1 Mon Sep 17 00:00:00 2001 From: Sigrid Huemer <32902192+s1gr1d@users.noreply.github.com> Date: Thu, 6 Nov 2025 10:48:41 +0100 Subject: [PATCH 03/12] feat(core): Include all exception object keys instead of truncating (#18044) The exception keys can be left without truncation to leave this decision on Relay. part of https://github.com/getsentry/sentry-javascript/issues/17389 --- packages/core/src/utils/object.ts | 26 ++------------- packages/core/test/lib/utils/object.test.ts | 35 ++++++++++----------- 2 files changed, 18 insertions(+), 43 deletions(-) diff --git a/packages/core/src/utils/object.ts b/packages/core/src/utils/object.ts index e212b9f3b833..06f80e12d7f7 100644 --- a/packages/core/src/utils/object.ts +++ b/packages/core/src/utils/object.ts @@ -4,7 +4,6 @@ import type { WrappedFunction } from '../types-hoist/wrappedfunction'; import { htmlTreeAsString } from './browser'; import { debug } from './debug-logger'; import { isElement, isError, isEvent, isInstanceOf, isPrimitive } from './is'; -import { truncate } from './string'; /** * Replace a method in an object with a wrapped version of itself. @@ -176,32 +175,11 @@ function getOwnProperties(obj: unknown): { [key: string]: unknown } { * and truncated list that will be used inside the event message. * eg. `Non-error exception captured with keys: foo, bar, baz` */ -export function extractExceptionKeysForMessage(exception: Record, maxLength: number = 40): string { +export function extractExceptionKeysForMessage(exception: Record): string { const keys = Object.keys(convertToPlainObject(exception)); keys.sort(); - const firstKey = keys[0]; - - if (!firstKey) { - return '[object has no keys]'; - } - - if (firstKey.length >= maxLength) { - return truncate(firstKey, maxLength); - } - - for (let includedKeys = keys.length; includedKeys > 0; includedKeys--) { - const serialized = keys.slice(0, includedKeys).join(', '); - if (serialized.length > maxLength) { - continue; - } - if (includedKeys === keys.length) { - return serialized; - } - return truncate(serialized, maxLength); - } - - return ''; + return !keys[0] ? '[object has no keys]' : keys.join(', '); } /** diff --git a/packages/core/test/lib/utils/object.test.ts b/packages/core/test/lib/utils/object.test.ts index bc8c7611abb8..a4d2a4b56ea3 100644 --- a/packages/core/test/lib/utils/object.test.ts +++ b/packages/core/test/lib/utils/object.test.ts @@ -142,29 +142,26 @@ describe('fill()', () => { describe('extractExceptionKeysForMessage()', () => { test('no keys', () => { - expect(extractExceptionKeysForMessage({}, 10)).toEqual('[object has no keys]'); + expect(extractExceptionKeysForMessage({})).toEqual('[object has no keys]'); }); - test('one key should be returned as a whole if not over the length limit', () => { - expect(extractExceptionKeysForMessage({ foo: '_' }, 10)).toEqual('foo'); - expect(extractExceptionKeysForMessage({ foobarbazx: '_' }, 10)).toEqual('foobarbazx'); + test('one key should be returned as a whole', () => { + expect(extractExceptionKeysForMessage({ foo: '_' })).toEqual('foo'); + expect(extractExceptionKeysForMessage({ foobarbazx: '_' })).toEqual('foobarbazx'); }); - test('one key should be appended with ... and truncated when over the limit', () => { - expect(extractExceptionKeysForMessage({ foobarbazqux: '_' }, 10)).toEqual('foobarbazq...'); - }); - - test('multiple keys should be sorted and joined as a whole if not over the length limit', () => { - expect(extractExceptionKeysForMessage({ foo: '_', bar: '_' }, 10)).toEqual('bar, foo'); - }); - - test('multiple keys should include only as much keys as can fit into the limit', () => { - expect(extractExceptionKeysForMessage({ foo: '_', bar: '_', baz: '_' }, 10)).toEqual('bar, baz'); - expect(extractExceptionKeysForMessage({ footoolong: '_', verylongkey: '_', baz: '_' }, 10)).toEqual('baz'); - }); - - test('multiple keys should truncate first key if its too long', () => { - expect(extractExceptionKeysForMessage({ barbazquxfoo: '_', baz: '_', qux: '_' }, 10)).toEqual('barbazquxf...'); + test('multiple keys should be sorted and joined as a whole (without truncating)', () => { + const exception = { + property1: 'a', + thisIsAnExtremelyLongPropertyNameThatExceedsFortyCharacters: 'b', + barbazquxfooabc: 'x', + property3: 'c', + property4: 'd', + property5: 'e', + }; + expect(extractExceptionKeysForMessage(exception)).toEqual( + 'barbazquxfooabc, property1, property3, property4, property5, thisIsAnExtremelyLongPropertyNameThatExceedsFortyCharacters', + ); }); }); From 1a7189dd1d8784c60273f4ed9a6854fb7e70f6e8 Mon Sep 17 00:00:00 2001 From: Sigrid Huemer <32902192+s1gr1d@users.noreply.github.com> Date: Thu, 6 Nov 2025 13:19:20 +0100 Subject: [PATCH 04/12] chore(eslint): Add eslint-plugin-regexp rule (dev-packages) (#18063) Enabling eslint rules for RegEx in `dev-packages`. This is a part of this (now closed) PR: https://github.com/getsentry/sentry-javascript/pull/18053 The first commit contains all changes that were automatically made with `--fix`, the second commit contains the manual changes. --- .../browser-integration-tests/.eslintrc.js | 4 +- .../browser-integration-tests/package.json | 1 + .../manual-client/browser-context/test.ts | 2 +- .../test.ts | 8 +-- .../test.ts | 6 +- .../standalone-mixed-transaction/test.ts | 8 +-- .../public-api/startSpan/standalone/test.ts | 4 +- .../suites/replay/dsc/test.ts | 12 ++-- .../http-timings/test.ts | 2 +- .../consistent-sampling/meta-negative/test.ts | 2 +- .../meta-precedence/test.ts | 2 +- .../tracesSampler-precedence/test.ts | 4 +- .../linked-traces/negatively-sampled/test.ts | 6 +- .../twp-errors-meta/test.ts | 4 +- .../twp-errors/test.ts | 8 +-- .../tracing/dsc-txn-name-update/test.ts | 8 +-- .../envelope-header-transaction-name/test.ts | 2 +- .../suites/tracing/envelope-header/test.ts | 2 +- .../metrics/pageload-resource-spans/test.ts | 6 +- .../web-vitals-cls-standalone-spans/test.ts | 46 ++++++------- .../metrics/web-vitals-inp-late/test.ts | 4 +- .../metrics/web-vitals-inp-navigate/test.ts | 8 +-- .../web-vitals-inp-parametrized-late/test.ts | 4 +- .../web-vitals-inp-parametrized/test.ts | 6 +- .../tracing/metrics/web-vitals-inp/test.ts | 6 +- .../web-vitals-lcp-standalone-spans/test.ts | 14 ++-- .../tracing/request/fetch-immediate/test.ts | 2 +- .../fetch-propagateTraceparent/test.ts | 4 +- .../request/fetch-relative-url/test.ts | 8 +-- .../fetch-strip-query-and-fragment/test.ts | 8 +-- .../test.ts | 4 +- .../request/fetch-tracing-unsampled/test.ts | 6 +- .../test.ts | 4 +- .../fetch-tracing-without-performance/test.ts | 6 +- .../suites/tracing/request/fetch/test.ts | 8 +-- .../request/xhr-propagateTraceparent/test.ts | 4 +- .../tracing/request/xhr-relative-url/test.ts | 8 +-- .../xhr-strip-query-and-fragment/test.ts | 8 +-- .../request/xhr-tracing-unsampled/test.ts | 6 +- .../test.ts | 4 +- .../xhr-tracing-without-performance/test.ts | 6 +- .../suites/tracing/request/xhr/test.ts | 8 +-- .../tracing/setSpanActive/default/test.ts | 2 +- .../nested-parentAlwaysRoot/test.ts | 4 +- .../tracing/setSpanActive/nested/test.ts | 4 +- .../tracing/trace-lifetime/navigation/test.ts | 34 +++++----- .../trace-lifetime/pageload-meta/test.ts | 24 +++---- .../tracing/trace-lifetime/pageload/test.ts | 34 +++++----- .../trace-lifetime/startNewTrace/test.ts | 12 ++-- .../startNewTraceSampling/test.ts | 8 +-- .../test.ts | 9 +-- .../tracing-without-performance/test.ts | 18 ++--- .../utils/replayHelpers.ts | 7 +- .../bundle-analyzer-scenarios/package.json | 3 + .../clear-cache-gh-action/.eslintrc.cjs | 4 +- .../clear-cache-gh-action/package.json | 3 + .../cloudflare-integration-tests/.eslintrc.js | 4 +- .../cloudflare-integration-tests/expect.ts | 6 +- .../cloudflare-integration-tests/package.json | 1 + dev-packages/e2e-tests/.eslintrc.js | 4 +- dev-packages/e2e-tests/package.json | 1 + .../aws-serverless/package.json | 1 + .../.eslintrc.cjs | 4 +- .../external-contributor-gh-action/index.mjs | 2 +- .../package.json | 3 + .../node-core-integration-tests/.eslintrc.js | 4 +- .../node-core-integration-tests/package.json | 1 + .../suites/anr/test.ts | 4 +- .../suites/cron/cron/test.ts | 16 ++--- .../suites/cron/node-cron/test.ts | 16 ++--- .../suites/cron/node-schedule/test.ts | 16 ++--- .../tracing/dsc-txn-name-update/test.ts | 16 ++--- .../error-active-span-unsampled/test.ts | 2 +- .../envelope-header/error-active-span/test.ts | 2 +- .../tracing/envelope-header/error/test.ts | 2 +- .../envelope-header/transaction-route/test.ts | 2 +- .../envelope-header/transaction-url/test.ts | 2 +- .../envelope-header/transaction/test.ts | 2 +- .../tracing/meta-tags-twp-errors/test.ts | 12 ++-- .../suites/tracing/meta-tags/test.ts | 4 +- .../fetch-no-tracing-no-spans/test.ts | 4 +- .../tracing/requests/fetch-no-tracing/test.ts | 4 +- .../fetch-sampled-no-active-span/test.ts | 4 +- .../tracing/requests/fetch-unsampled/test.ts | 4 +- .../requests/http-no-tracing-no-spans/test.ts | 4 +- .../tracing/requests/http-no-tracing/test.ts | 4 +- .../http-sampled-no-active-span/test.ts | 4 +- .../tracing/requests/http-sampled/test.ts | 4 +- .../tracing/requests/http-unsampled/test.ts | 4 +- .../tracing/sample-rand-propagation/test.ts | 8 +-- .../tracing/tracePropagationTargets/test.ts | 4 +- .../utils/runner.ts | 3 +- .../node-integration-tests/.eslintrc.js | 4 +- .../node-integration-tests/package.json | 1 + .../node-integration-tests/suites/anr/test.ts | 4 +- .../suites/cron/cron/test.ts | 16 ++--- .../suites/cron/node-cron/test.ts | 16 ++--- .../suites/cron/node-schedule/test.ts | 16 ++--- .../baggage-header-assign/test.ts | 8 +-- .../sentry-trace/baggage-header-out/test.ts | 2 +- .../test.ts | 6 +- .../suites/express/tracing/scenario.mjs | 2 +- .../suites/express/tracing/test.ts | 26 ++++---- .../featureFlags/growthbook/onSpan/test.ts | 4 +- .../tracing/dsc-txn-name-update/test.ts | 16 ++--- .../error-active-span-unsampled/test.ts | 2 +- .../envelope-header/error-active-span/test.ts | 2 +- .../tracing/envelope-header/error/test.ts | 2 +- .../envelope-header/transaction-route/test.ts | 2 +- .../envelope-header/transaction-url/test.ts | 2 +- .../envelope-header/transaction/test.ts | 2 +- .../fetch-strip-query/test.ts | 2 +- .../http-strip-query/test.ts | 2 +- .../suites/tracing/httpIntegration/test.ts | 64 +++++++++--------- .../tracing/meta-tags-twp-errors/test.ts | 12 ++-- .../suites/tracing/meta-tags-twp/test.ts | 2 +- .../suites/tracing/meta-tags/test.ts | 6 +- .../fetch-no-tracing-no-spans/test.ts | 4 +- .../tracing/requests/fetch-no-tracing/test.ts | 4 +- .../fetch-sampled-no-active-span/test.ts | 4 +- .../tracing/requests/fetch-unsampled/test.ts | 4 +- .../requests/http-no-tracing-no-spans/test.ts | 4 +- .../tracing/requests/http-no-tracing/test.ts | 4 +- .../http-sampled-no-active-span/test.ts | 4 +- .../tracing/requests/http-sampled/test.ts | 4 +- .../tracing/requests/http-unsampled/test.ts | 4 +- .../tracing/sample-rand-propagation/test.ts | 12 ++-- .../tracing/tracePropagationTargets/test.ts | 4 +- .../node-integration-tests/utils/runner.ts | 3 +- .../node-overhead-gh-action/.eslintrc.cjs | 4 +- .../node-overhead-gh-action/package.json | 1 + dev-packages/rollup-utils/.eslintrc.cjs | 4 +- dev-packages/rollup-utils/package.json | 3 + .../size-limit-gh-action/.eslintrc.cjs | 4 +- dev-packages/test-utils/.eslintrc.js | 4 +- dev-packages/test-utils/package.json | 3 +- yarn.lock | 65 +++++++++++++++++-- 137 files changed, 542 insertions(+), 439 deletions(-) diff --git a/dev-packages/browser-integration-tests/.eslintrc.js b/dev-packages/browser-integration-tests/.eslintrc.js index a19cfba8812a..8c07222e9a7c 100644 --- a/dev-packages/browser-integration-tests/.eslintrc.js +++ b/dev-packages/browser-integration-tests/.eslintrc.js @@ -3,7 +3,9 @@ module.exports = { browser: true, node: true, }, - extends: ['../../.eslintrc.js'], + // todo: remove regexp plugin from here once we add it to base.js eslint config for the whole project + extends: ['../../.eslintrc.js', 'plugin:regexp/recommended'], + plugins: ['regexp'], ignorePatterns: [ 'suites/**/subject.js', 'suites/**/dist/*', diff --git a/dev-packages/browser-integration-tests/package.json b/dev-packages/browser-integration-tests/package.json index 665e7e9b6e17..8e005588537a 100644 --- a/dev-packages/browser-integration-tests/package.json +++ b/dev-packages/browser-integration-tests/package.json @@ -54,6 +54,7 @@ "devDependencies": { "@types/glob": "8.0.0", "@types/node": "^18.19.1", + "eslint-plugin-regexp": "^1.15.0", "glob": "8.0.3" }, "volta": { diff --git a/dev-packages/browser-integration-tests/suites/manual-client/browser-context/test.ts b/dev-packages/browser-integration-tests/suites/manual-client/browser-context/test.ts index 4637fcc5555d..bb963a975049 100644 --- a/dev-packages/browser-integration-tests/suites/manual-client/browser-context/test.ts +++ b/dev-packages/browser-integration-tests/suites/manual-client/browser-context/test.ts @@ -46,7 +46,7 @@ sentryTest('allows to setup a client manually & capture exceptions', async ({ ge }, }, contexts: { - trace: { trace_id: expect.stringMatching(/[a-f0-9]{32}/), span_id: expect.stringMatching(/[a-f0-9]{16}/) }, + trace: { trace_id: expect.stringMatching(/[a-f\d]{32}/), span_id: expect.stringMatching(/[a-f\d]{16}/) }, }, }); }); diff --git a/dev-packages/browser-integration-tests/suites/profiling/traceLifecycleMode_multiple-chunks/test.ts b/dev-packages/browser-integration-tests/suites/profiling/traceLifecycleMode_multiple-chunks/test.ts index 702140b8823e..421cdfc1e645 100644 --- a/dev-packages/browser-integration-tests/suites/profiling/traceLifecycleMode_multiple-chunks/test.ts +++ b/dev-packages/browser-integration-tests/suites/profiling/traceLifecycleMode_multiple-chunks/test.ts @@ -58,9 +58,9 @@ sentryTest( // Required profile metadata (Sample Format V2) expect(typeof envelopeItemPayload1.profiler_id).toBe('string'); - expect(envelopeItemPayload1.profiler_id).toMatch(/^[a-f0-9]{32}$/); + expect(envelopeItemPayload1.profiler_id).toMatch(/^[a-f\d]{32}$/); expect(typeof envelopeItemPayload1.chunk_id).toBe('string'); - expect(envelopeItemPayload1.chunk_id).toMatch(/^[a-f0-9]{32}$/); + expect(envelopeItemPayload1.chunk_id).toMatch(/^[a-f\d]{32}$/); expect(envelopeItemPayload1.client_sdk).toBeDefined(); expect(typeof envelopeItemPayload1.client_sdk.name).toBe('string'); expect(typeof envelopeItemPayload1.client_sdk.version).toBe('string'); @@ -170,9 +170,9 @@ sentryTest( // Required profile metadata (Sample Format V2) // https://develop.sentry.dev/sdk/telemetry/profiles/sample-format-v2/ expect(typeof envelopeItemPayload2.profiler_id).toBe('string'); - expect(envelopeItemPayload2.profiler_id).toMatch(/^[a-f0-9]{32}$/); + expect(envelopeItemPayload2.profiler_id).toMatch(/^[a-f\d]{32}$/); expect(typeof envelopeItemPayload2.chunk_id).toBe('string'); - expect(envelopeItemPayload2.chunk_id).toMatch(/^[a-f0-9]{32}$/); + expect(envelopeItemPayload2.chunk_id).toMatch(/^[a-f\d]{32}$/); expect(envelopeItemPayload2.client_sdk).toBeDefined(); expect(typeof envelopeItemPayload2.client_sdk.name).toBe('string'); expect(typeof envelopeItemPayload2.client_sdk.version).toBe('string'); diff --git a/dev-packages/browser-integration-tests/suites/profiling/traceLifecycleMode_overlapping-spans/test.ts b/dev-packages/browser-integration-tests/suites/profiling/traceLifecycleMode_overlapping-spans/test.ts index 60744def96cd..161f74d64e83 100644 --- a/dev-packages/browser-integration-tests/suites/profiling/traceLifecycleMode_overlapping-spans/test.ts +++ b/dev-packages/browser-integration-tests/suites/profiling/traceLifecycleMode_overlapping-spans/test.ts @@ -60,9 +60,9 @@ sentryTest( // Required profile metadata (Sample Format V2) // https://develop.sentry.dev/sdk/telemetry/profiles/sample-format-v2/ expect(typeof envelopeItemPayload.profiler_id).toBe('string'); - expect(envelopeItemPayload.profiler_id).toMatch(/^[a-f0-9]{32}$/); + expect(envelopeItemPayload.profiler_id).toMatch(/^[a-f\d]{32}$/); expect(typeof envelopeItemPayload.chunk_id).toBe('string'); - expect(envelopeItemPayload.chunk_id).toMatch(/^[a-f0-9]{32}$/); + expect(envelopeItemPayload.chunk_id).toMatch(/^[a-f\d]{32}$/); expect(envelopeItemPayload.client_sdk).toBeDefined(); expect(typeof envelopeItemPayload.client_sdk.name).toBe('string'); expect(typeof envelopeItemPayload.client_sdk.version).toBe('string'); @@ -175,7 +175,7 @@ sentryTest('attaches thread data to child spans (trace mode)', async ({ page, ge const profilerId = rootSpan?.contexts?.profile?.profiler_id as string | undefined; expect(typeof profilerId).toBe('string'); - expect(profilerId).toMatch(/^[a-f0-9]{32}$/); + expect(profilerId).toMatch(/^[a-f\d]{32}$/); const spans = (rootSpan?.spans ?? []) as Array<{ data?: Record }>; expect(spans.length).toBeGreaterThan(0); diff --git a/dev-packages/browser-integration-tests/suites/public-api/startSpan/standalone-mixed-transaction/test.ts b/dev-packages/browser-integration-tests/suites/public-api/startSpan/standalone-mixed-transaction/test.ts index 8493f4e5fd97..c1e641204b81 100644 --- a/dev-packages/browser-integration-tests/suites/public-api/startSpan/standalone-mixed-transaction/test.ts +++ b/dev-packages/browser-integration-tests/suites/public-api/startSpan/standalone-mixed-transaction/test.ts @@ -34,8 +34,8 @@ sentryTest( const traceId = transactionEnvelopeHeader.trace!.trace_id!; const parentSpanId = transactionEnvelopeItem.contexts?.trace?.span_id; - expect(traceId).toMatch(/[a-f0-9]{32}/); - expect(parentSpanId).toMatch(/[a-f0-9]{16}/); + expect(traceId).toMatch(/[a-f\d]{32}/); + expect(parentSpanId).toMatch(/[a-f\d]{16}/); expect(spanEnvelopeHeader).toEqual({ sent_at: expect.any(String), @@ -76,7 +76,7 @@ sentryTest( segment_id: transactionEnvelopeItem.contexts?.trace?.span_id, parent_span_id: parentSpanId, origin: 'manual', - span_id: expect.stringMatching(/[a-f0-9]{16}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), start_timestamp: expect.any(Number), timestamp: expect.any(Number), trace_id: traceId, @@ -111,7 +111,7 @@ sentryTest( description: 'inner', origin: 'manual', parent_span_id: parentSpanId, - span_id: expect.stringMatching(/[a-f0-9]{16}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), start_timestamp: expect.any(Number), timestamp: expect.any(Number), trace_id: traceId, diff --git a/dev-packages/browser-integration-tests/suites/public-api/startSpan/standalone/test.ts b/dev-packages/browser-integration-tests/suites/public-api/startSpan/standalone/test.ts index aaafd99c91d5..289e907e09b3 100644 --- a/dev-packages/browser-integration-tests/suites/public-api/startSpan/standalone/test.ts +++ b/dev-packages/browser-integration-tests/suites/public-api/startSpan/standalone/test.ts @@ -48,10 +48,10 @@ sentryTest('sends a segment span envelope', async ({ getLocalTestUrl, page }) => }, description: 'standalone_segment_span', origin: 'manual', - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), start_timestamp: expect.any(Number), timestamp: expect.any(Number), - trace_id: expect.stringMatching(/^[0-9a-f]{32}$/), + trace_id: expect.stringMatching(/^[\da-f]{32}$/), is_segment: true, segment_id: spanJson.span_id, }); diff --git a/dev-packages/browser-integration-tests/suites/replay/dsc/test.ts b/dev-packages/browser-integration-tests/suites/replay/dsc/test.ts index ef0882e0206b..e63c45e42293 100644 --- a/dev-packages/browser-integration-tests/suites/replay/dsc/test.ts +++ b/dev-packages/browser-integration-tests/suites/replay/dsc/test.ts @@ -57,7 +57,7 @@ sentryTest( expect(envHeader.trace).toEqual({ environment: 'production', sample_rate: '1', - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), public_key: 'public', replay_id: replay.session?.id, sampled: 'true', @@ -105,7 +105,7 @@ sentryTest( expect(envHeader.trace).toEqual({ environment: 'production', sample_rate: '1', - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), public_key: 'public', sampled: 'true', sample_rand: expect.any(String), @@ -158,7 +158,7 @@ sentryTest( expect(envHeader.trace).toEqual({ environment: 'production', sample_rate: '1', - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), public_key: 'public', replay_id: replay.session?.id, sampled: 'true', @@ -201,7 +201,7 @@ sentryTest( expect(envHeader.trace).toEqual({ environment: 'production', sample_rate: '1', - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), public_key: 'public', sampled: 'true', sample_rand: expect.any(String), @@ -243,7 +243,7 @@ sentryTest('should add replay_id to error DSC while replay is active', async ({ expect(error1Header.trace).toBeDefined(); expect(error1Header.trace).toEqual({ environment: 'production', - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), public_key: 'public', replay_id: replay.session?.id, ...(hasTracing @@ -265,7 +265,7 @@ sentryTest('should add replay_id to error DSC while replay is active', async ({ expect(error2Header.trace).toBeDefined(); expect(error2Header.trace).toEqual({ environment: 'production', - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), public_key: 'public', ...(hasTracing ? { diff --git a/dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/http-timings/test.ts b/dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/http-timings/test.ts index 633be5f570b5..6894d7407349 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/http-timings/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/http-timings/test.ts @@ -34,7 +34,7 @@ sentryTest('creates fetch spans with http timing', async ({ browserName, getLoca expect(span).toMatchObject({ description: `GET http://sentry-test-site.example/${index}`, parent_span_id: tracingEvent.contexts?.trace?.span_id, - span_id: expect.stringMatching(/[a-f0-9]{16}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), start_timestamp: expect.any(Number), timestamp: expect.any(Number), trace_id: tracingEvent.contexts?.trace?.trace_id, diff --git a/dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/linked-traces/consistent-sampling/meta-negative/test.ts b/dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/linked-traces/consistent-sampling/meta-negative/test.ts index 6ec7985b9dad..c8faee2f5feb 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/linked-traces/consistent-sampling/meta-negative/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/linked-traces/consistent-sampling/meta-negative/test.ts @@ -60,7 +60,7 @@ sentryTest.describe('When `consistentTraceSampling` is `true` and page contains expect(extractTraceparentData(sentryTrace)).toEqual({ traceId: expect.not.stringContaining(metaTagTraceId), - parentSpanId: expect.stringMatching(/^[0-9a-f]{16}$/), + parentSpanId: expect.stringMatching(/^[\da-f]{16}$/), parentSampled: false, }); diff --git a/dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/linked-traces/consistent-sampling/meta-precedence/test.ts b/dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/linked-traces/consistent-sampling/meta-precedence/test.ts index ece2b1f85790..3dab9594ba7c 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/linked-traces/consistent-sampling/meta-precedence/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/linked-traces/consistent-sampling/meta-precedence/test.ts @@ -48,7 +48,7 @@ sentryTest.describe('When `consistentTraceSampling` is `true` and page contains expect(extractTraceparentData(sentryTrace)).toEqual({ traceId: expect.not.stringContaining(metaTagTraceIdIndex), - parentSpanId: expect.stringMatching(/^[0-9a-f]{16}$/), + parentSpanId: expect.stringMatching(/^[\da-f]{16}$/), parentSampled: false, }); diff --git a/dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/linked-traces/consistent-sampling/tracesSampler-precedence/test.ts b/dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/linked-traces/consistent-sampling/tracesSampler-precedence/test.ts index 9e896798be90..2bb196c898fd 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/linked-traces/consistent-sampling/tracesSampler-precedence/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/linked-traces/consistent-sampling/tracesSampler-precedence/test.ts @@ -104,8 +104,8 @@ sentryTest.describe('When `consistentTraceSampling` is `true`', () => { { attributes: { 'sentry.link.type': 'previous_trace' }, sampled: false, - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), - trace_id: expect.stringMatching(/^[0-9a-f]{32}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), + trace_id: expect.stringMatching(/^[\da-f]{32}$/), }, ]); diff --git a/dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/linked-traces/negatively-sampled/test.ts b/dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/linked-traces/negatively-sampled/test.ts index 7a8b69fdb364..b84aefb8887d 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/linked-traces/negatively-sampled/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/linked-traces/negatively-sampled/test.ts @@ -24,8 +24,8 @@ sentryTest('includes a span link to a previously negatively sampled span', async expect(navigationTraceContext?.op).toBe('navigation'); expect(navigationTraceContext?.links).toEqual([ { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), sampled: false, attributes: { [SEMANTIC_LINK_ATTRIBUTE_LINK_TYPE]: 'previous_trace', @@ -34,7 +34,7 @@ sentryTest('includes a span link to a previously negatively sampled span', async ]); expect(navigationTraceContext?.data).toMatchObject({ - 'sentry.previous_trace': expect.stringMatching(/[a-f0-9]{32}-[a-f0-9]{16}-0/), + 'sentry.previous_trace': expect.stringMatching(/[a-f\d]{32}-[a-f\d]{16}-0/), }); expect(navigationTraceContext?.trace_id).not.toEqual(navigationTraceContext?.links![0].trace_id); diff --git a/dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/twp-errors-meta/test.ts b/dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/twp-errors-meta/test.ts index 5bed055dbc0a..ca716b2e2648 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/twp-errors-meta/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/twp-errors-meta/test.ts @@ -24,12 +24,12 @@ sentryTest('errors in TwP mode have same trace ID & span IDs', async ({ getLocal // Span ID is a virtual span, not the propagated one expect(spanId1).not.toEqual(spanId); - expect(spanId1).toMatch(/^[a-f0-9]{16}$/); + expect(spanId1).toMatch(/^[a-f\d]{16}$/); const contexts2 = event2.contexts; const { trace_id: traceId2, span_id: spanId2 } = contexts2?.trace || {}; expect(traceId2).toEqual(traceId); - expect(spanId2).toMatch(/^[a-f0-9]{16}$/); + expect(spanId2).toMatch(/^[a-f\d]{16}$/); expect(spanId2).toEqual(spanId1); }); diff --git a/dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/twp-errors/test.ts b/dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/twp-errors/test.ts index 3048de92b2f1..fa579509ba87 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/twp-errors/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/browserTracingIntegration/twp-errors/test.ts @@ -17,13 +17,13 @@ sentryTest('errors in TwP mode have same trace ID & span IDs', async ({ getLocal const contexts1 = event1.contexts; const { trace_id: traceId1, span_id: spanId1 } = contexts1?.trace || {}; - expect(traceId1).toMatch(/^[a-f0-9]{32}$/); - expect(spanId1).toMatch(/^[a-f0-9]{16}$/); + expect(traceId1).toMatch(/^[a-f\d]{32}$/); + expect(spanId1).toMatch(/^[a-f\d]{16}$/); const contexts2 = event2.contexts; const { trace_id: traceId2, span_id: spanId2 } = contexts2?.trace || {}; - expect(traceId2).toMatch(/^[a-f0-9]{32}$/); - expect(spanId2).toMatch(/^[a-f0-9]{16}$/); + expect(traceId2).toMatch(/^[a-f\d]{32}$/); + expect(spanId2).toMatch(/^[a-f\d]{16}$/); expect(traceId2).toEqual(traceId1); expect(spanId2).toEqual(spanId1); diff --git a/dev-packages/browser-integration-tests/suites/tracing/dsc-txn-name-update/test.ts b/dev-packages/browser-integration-tests/suites/tracing/dsc-txn-name-update/test.ts index 0136b1043617..7d33497a988b 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/dsc-txn-name-update/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/dsc-txn-name-update/test.ts @@ -48,7 +48,7 @@ sentryTest('updates the DSC when the txn name is updated and high-quality', asyn return (window as any).__traceId; }); - expect(traceId).toMatch(/^[0-9a-f]{32}$/); + expect(traceId).toMatch(/^[\da-f]{32}$/); // 2 const baggageItems = await makeRequestAndGetBaggageItems(page); @@ -56,7 +56,7 @@ sentryTest('updates the DSC when the txn name is updated and high-quality', asyn 'sentry-environment=production', 'sentry-public_key=public', 'sentry-release=1.1.1', - expect.stringMatching(/sentry-sample_rand=0\.[0-9]+/), + expect.stringMatching(/sentry-sample_rand=0\.\d+/), 'sentry-sample_rate=1', 'sentry-sampled=true', `sentry-trace_id=${traceId}`, @@ -83,7 +83,7 @@ sentryTest('updates the DSC when the txn name is updated and high-quality', asyn 'sentry-environment=production', 'sentry-public_key=public', 'sentry-release=1.1.1', - expect.stringMatching(/sentry-sample_rand=0\.[0-9]+/), + expect.stringMatching(/sentry-sample_rand=0\.\d+/), 'sentry-sample_rate=1', 'sentry-sampled=true', `sentry-trace_id=${traceId}`, @@ -112,7 +112,7 @@ sentryTest('updates the DSC when the txn name is updated and high-quality', asyn 'sentry-environment=production', 'sentry-public_key=public', 'sentry-release=1.1.1', - expect.stringMatching(/sentry-sample_rand=0\.[0-9]+/), + expect.stringMatching(/sentry-sample_rand=0\.\d+/), 'sentry-sample_rate=1', 'sentry-sampled=true', `sentry-trace_id=${traceId}`, diff --git a/dev-packages/browser-integration-tests/suites/tracing/envelope-header-transaction-name/test.ts b/dev-packages/browser-integration-tests/suites/tracing/envelope-header-transaction-name/test.ts index 88a268e69ea2..23043ebc770d 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/envelope-header-transaction-name/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/envelope-header-transaction-name/test.ts @@ -23,7 +23,7 @@ sentryTest( environment: 'production', sample_rate: '1', transaction: expect.stringContaining('/index.html'), - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), public_key: 'public', sampled: 'true', sample_rand: expect.any(String), diff --git a/dev-packages/browser-integration-tests/suites/tracing/envelope-header/test.ts b/dev-packages/browser-integration-tests/suites/tracing/envelope-header/test.ts index 9274cd0bb8ba..7617b498efb2 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/envelope-header/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/envelope-header/test.ts @@ -26,7 +26,7 @@ sentryTest( expect(envHeader.trace).toEqual({ environment: 'production', sample_rate: '1', - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), public_key: 'public', sampled: 'true', sample_rand: expect.any(String), diff --git a/dev-packages/browser-integration-tests/suites/tracing/metrics/pageload-resource-spans/test.ts b/dev-packages/browser-integration-tests/suites/tracing/metrics/pageload-resource-spans/test.ts index f748c339ce14..91c8ec9ff216 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/metrics/pageload-resource-spans/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/metrics/pageload-resource-spans/test.ts @@ -104,7 +104,7 @@ sentryTest('adds resource spans to pageload transaction', async ({ getLocalTestU op: 'resource.img', origin: 'auto.resource.browser.metrics', parent_span_id: spanId, - span_id: expect.stringMatching(/^[a-f0-9]{16}$/), + span_id: expect.stringMatching(/^[a-f\d]{16}$/), start_timestamp: expect.any(Number), timestamp: expect.any(Number), trace_id: traceId, @@ -151,7 +151,7 @@ sentryTest('adds resource spans to pageload transaction', async ({ getLocalTestU op: 'resource.link', origin: 'auto.resource.browser.metrics', parent_span_id: spanId, - span_id: expect.stringMatching(/^[a-f0-9]{16}$/), + span_id: expect.stringMatching(/^[a-f\d]{16}$/), start_timestamp: expect.any(Number), timestamp: expect.any(Number), trace_id: traceId, @@ -192,7 +192,7 @@ sentryTest('adds resource spans to pageload transaction', async ({ getLocalTestU op: 'resource.script', origin: 'auto.resource.browser.metrics', parent_span_id: spanId, - span_id: expect.stringMatching(/^[a-f0-9]{16}$/), + span_id: expect.stringMatching(/^[a-f\d]{16}$/), start_timestamp: expect.any(Number), timestamp: expect.any(Number), trace_id: traceId, diff --git a/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-cls-standalone-spans/test.ts b/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-cls-standalone-spans/test.ts index 24c949c63afa..fd4b3b8fa06b 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-cls-standalone-spans/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-cls-standalone-spans/test.ts @@ -68,7 +68,7 @@ sentryTest('captures a "GOOD" CLS vital with its source as a standalone span', a 'sentry.report_event': 'pagehide', transaction: expect.stringContaining('index.html'), 'user_agent.original': expect.stringContaining('Chrome'), - 'sentry.pageload.span_id': expect.stringMatching(/[a-f0-9]{16}/), + 'sentry.pageload.span_id': expect.stringMatching(/[a-f\d]{16}/), 'cls.source.1': expect.stringContaining('body > div#content > p'), }, description: expect.stringContaining('body > div#content > p'), @@ -81,12 +81,12 @@ sentryTest('captures a "GOOD" CLS vital with its source as a standalone span', a }, op: 'ui.webvital.cls', origin: 'auto.http.browser.cls', - parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), - segment_id: expect.stringMatching(/[a-f0-9]{16}/), + parent_span_id: expect.stringMatching(/[a-f\d]{16}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), + segment_id: expect.stringMatching(/[a-f\d]{16}/), start_timestamp: expect.any(Number), timestamp: spanEnvelopeItem.start_timestamp, - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), }); // Flakey value dependent on timings -> we check for a range @@ -138,7 +138,7 @@ sentryTest('captures a "MEH" CLS vital with its source as a standalone span', as 'sentry.report_event': 'pagehide', transaction: expect.stringContaining('index.html'), 'user_agent.original': expect.stringContaining('Chrome'), - 'sentry.pageload.span_id': expect.stringMatching(/[a-f0-9]{16}/), + 'sentry.pageload.span_id': expect.stringMatching(/[a-f\d]{16}/), 'cls.source.1': expect.stringContaining('body > div#content > p'), }, description: expect.stringContaining('body > div#content > p'), @@ -151,12 +151,12 @@ sentryTest('captures a "MEH" CLS vital with its source as a standalone span', as }, op: 'ui.webvital.cls', origin: 'auto.http.browser.cls', - parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), - segment_id: expect.stringMatching(/[a-f0-9]{16}/), + parent_span_id: expect.stringMatching(/[a-f\d]{16}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), + segment_id: expect.stringMatching(/[a-f\d]{16}/), start_timestamp: expect.any(Number), timestamp: spanEnvelopeItem.start_timestamp, - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), }); // Flakey value dependent on timings -> we check for a range @@ -206,7 +206,7 @@ sentryTest('captures a "POOR" CLS vital with its source as a standalone span.', 'sentry.report_event': 'pagehide', transaction: expect.stringContaining('index.html'), 'user_agent.original': expect.stringContaining('Chrome'), - 'sentry.pageload.span_id': expect.stringMatching(/[a-f0-9]{16}/), + 'sentry.pageload.span_id': expect.stringMatching(/[a-f\d]{16}/), 'cls.source.1': expect.stringContaining('body > div#content > p'), }, description: expect.stringContaining('body > div#content > p'), @@ -219,12 +219,12 @@ sentryTest('captures a "POOR" CLS vital with its source as a standalone span.', }, op: 'ui.webvital.cls', origin: 'auto.http.browser.cls', - parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), - segment_id: expect.stringMatching(/[a-f0-9]{16}/), + parent_span_id: expect.stringMatching(/[a-f\d]{16}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), + segment_id: expect.stringMatching(/[a-f\d]{16}/), start_timestamp: expect.any(Number), timestamp: spanEnvelopeItem.start_timestamp, - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), }); // Flakey value dependent on timings -> we check for a range @@ -275,7 +275,7 @@ sentryTest( 'sentry.report_event': 'pagehide', transaction: expect.stringContaining('index.html'), 'user_agent.original': expect.stringContaining('Chrome'), - 'sentry.pageload.span_id': expect.stringMatching(/[a-f0-9]{16}/), + 'sentry.pageload.span_id': expect.stringMatching(/[a-f\d]{16}/), }, description: 'Layout shift', exclusive_time: 0, @@ -287,12 +287,12 @@ sentryTest( }, op: 'ui.webvital.cls', origin: 'auto.http.browser.cls', - parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), - segment_id: expect.stringMatching(/[a-f0-9]{16}/), + parent_span_id: expect.stringMatching(/[a-f\d]{16}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), + segment_id: expect.stringMatching(/[a-f\d]{16}/), start_timestamp: expect.any(Number), timestamp: spanEnvelopeItem.start_timestamp, - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), }); expect(spanEnvelopeHeaders).toEqual({ @@ -323,8 +323,8 @@ sentryTest( const pageloadSpanId = eventData.contexts?.trace?.span_id; const pageloadTraceId = eventData.contexts?.trace?.trace_id; - expect(pageloadSpanId).toMatch(/[a-f0-9]{16}/); - expect(pageloadTraceId).toMatch(/[a-f0-9]{32}/); + expect(pageloadSpanId).toMatch(/[a-f\d]{16}/); + expect(pageloadTraceId).toMatch(/[a-f\d]{32}/); const spanEnvelopePromise = getMultipleSentryEnvelopeRequests( page, @@ -371,7 +371,7 @@ sentryTest('sends CLS of the initial page when soft-navigating to a new page', a await page.goto(`${url}#soft-navigation`); const pageloadTraceId = pageloadEventData.contexts?.trace?.trace_id; - expect(pageloadTraceId).toMatch(/[a-f0-9]{32}/); + expect(pageloadTraceId).toMatch(/[a-f\d]{32}/); const spanEnvelope = (await spanEnvelopePromise)[0]; const spanEnvelopeItem = spanEnvelope[1][0][1]; diff --git a/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-inp-late/test.ts b/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-inp-late/test.ts index 942230b4594e..a882c06c1e11 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-inp-late/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-inp-late/test.ts @@ -43,7 +43,7 @@ sentryTest('should capture an INP click event span after pageload', async ({ bro const spanEnvelopeItem = spanEnvelope[1][0][1]; const traceId = spanEnvelopeHeaders.trace!.trace_id; - expect(traceId).toMatch(/[a-f0-9]{32}/); + expect(traceId).toMatch(/[a-f\d]{32}/); expect(spanEnvelopeHeaders).toEqual({ sent_at: expect.any(String), @@ -81,7 +81,7 @@ sentryTest('should capture an INP click event span after pageload', async ({ bro origin: 'auto.http.browser.inp', is_segment: true, segment_id: spanEnvelopeItem.span_id, - span_id: expect.stringMatching(/[a-f0-9]{16}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), start_timestamp: expect.any(Number), timestamp: expect.any(Number), trace_id: traceId, diff --git a/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-inp-navigate/test.ts b/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-inp-navigate/test.ts index cf3cdb552cbf..d1cc7cce020d 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-inp-navigate/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-inp-navigate/test.ts @@ -46,7 +46,7 @@ sentryTest( const spanEnvelopeItem = spanEnvelope[1][0][1]; const traceId = spanEnvelopeHeaders.trace!.trace_id; - expect(traceId).toMatch(/[a-f0-9]{32}/); + expect(traceId).toMatch(/[a-f\d]{32}/); expect(spanEnvelopeHeaders).toEqual({ sent_at: expect.any(String), @@ -84,7 +84,7 @@ sentryTest( origin: 'auto.http.browser.inp', is_segment: true, segment_id: spanEnvelopeItem.span_id, - span_id: expect.stringMatching(/[a-f0-9]{16}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), start_timestamp: expect.any(Number), timestamp: expect.any(Number), trace_id: traceId, @@ -127,7 +127,7 @@ sentryTest( const spanEnvelopeItem = spanEnvelope[1][0][1]; const traceId = spanEnvelopeHeaders.trace!.trace_id; - expect(traceId).toMatch(/[a-f0-9]{32}/); + expect(traceId).toMatch(/[a-f\d]{32}/); expect(spanEnvelopeHeaders).toEqual({ sent_at: expect.any(String), @@ -165,7 +165,7 @@ sentryTest( origin: 'auto.http.browser.inp', is_segment: true, segment_id: spanEnvelopeItem.span_id, - span_id: expect.stringMatching(/[a-f0-9]{16}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), start_timestamp: expect.any(Number), timestamp: expect.any(Number), trace_id: traceId, diff --git a/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-inp-parametrized-late/test.ts b/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-inp-parametrized-late/test.ts index 435ed8398668..d1dea39f0231 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-inp-parametrized-late/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-inp-parametrized-late/test.ts @@ -45,7 +45,7 @@ sentryTest( const spanEnvelopeItem = spanEnvelope[1][0][1]; const traceId = spanEnvelopeHeaders.trace!.trace_id; - expect(traceId).toMatch(/[a-f0-9]{32}/); + expect(traceId).toMatch(/[a-f\d]{32}/); expect(spanEnvelopeHeaders).toEqual({ sent_at: expect.any(String), @@ -84,7 +84,7 @@ sentryTest( origin: 'auto.http.browser.inp', is_segment: true, segment_id: spanEnvelopeItem.span_id, - span_id: expect.stringMatching(/[a-f0-9]{16}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), start_timestamp: expect.any(Number), timestamp: expect.any(Number), trace_id: traceId, diff --git a/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-inp-parametrized/test.ts b/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-inp-parametrized/test.ts index 9d83d2608893..a7d614147f83 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-inp-parametrized/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-inp-parametrized/test.ts @@ -43,7 +43,7 @@ sentryTest( const spanEnvelopeItem = spanEnvelope[1][0][1]; const traceId = spanEnvelopeHeaders.trace!.trace_id; - expect(traceId).toMatch(/[a-f0-9]{32}/); + expect(traceId).toMatch(/[a-f\d]{32}/); expect(spanEnvelopeHeaders).toEqual({ sent_at: expect.any(String), @@ -81,8 +81,8 @@ sentryTest( origin: 'auto.http.browser.inp', segment_id: expect.not.stringMatching(spanEnvelopeItem.span_id!), // parent is the pageload span - parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), + parent_span_id: expect.stringMatching(/[a-f\d]{16}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), start_timestamp: expect.any(Number), timestamp: expect.any(Number), trace_id: traceId, diff --git a/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-inp/test.ts b/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-inp/test.ts index bf85d0ad99af..ee92b13802ec 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-inp/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-inp/test.ts @@ -42,7 +42,7 @@ sentryTest('should capture an INP click event span during pageload', async ({ br const spanEnvelopeItem = spanEnvelope[1][0][1]; const traceId = spanEnvelopeHeaders.trace!.trace_id; - expect(traceId).toMatch(/[a-f0-9]{32}/); + expect(traceId).toMatch(/[a-f\d]{32}/); expect(spanEnvelopeHeaders).toEqual({ sent_at: expect.any(String), @@ -80,8 +80,8 @@ sentryTest('should capture an INP click event span during pageload', async ({ br origin: 'auto.http.browser.inp', segment_id: expect.not.stringMatching(spanEnvelopeItem.span_id!), // Parent is the pageload span - parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), + parent_span_id: expect.stringMatching(/[a-f\d]{16}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), start_timestamp: expect.any(Number), timestamp: expect.any(Number), trace_id: traceId, diff --git a/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-lcp-standalone-spans/test.ts b/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-lcp-standalone-spans/test.ts index ad21a6240793..e2b8a3e66e44 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-lcp-standalone-spans/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/metrics/web-vitals-lcp-standalone-spans/test.ts @@ -57,7 +57,7 @@ sentryTest('captures LCP vital as a standalone span', async ({ getLocalTestUrl, const spanEnvelopeItem = spanEnvelope[1][0][1]; const pageloadTraceId = pageloadTransactionEvent.contexts?.trace?.trace_id; - expect(pageloadTraceId).toMatch(/[a-f0-9]{32}/); + expect(pageloadTraceId).toMatch(/[a-f\d]{32}/); expect(spanEnvelopeItem).toEqual({ data: { @@ -67,7 +67,7 @@ sentryTest('captures LCP vital as a standalone span', async ({ getLocalTestUrl, 'sentry.report_event': 'pagehide', transaction: expect.stringContaining('index.html'), 'user_agent.original': expect.stringContaining('Chrome'), - 'sentry.pageload.span_id': expect.stringMatching(/[a-f0-9]{16}/), + 'sentry.pageload.span_id': expect.stringMatching(/[a-f\d]{16}/), 'lcp.element': 'body > img', 'lcp.loadTime': expect.any(Number), 'lcp.renderTime': expect.any(Number), @@ -84,9 +84,9 @@ sentryTest('captures LCP vital as a standalone span', async ({ getLocalTestUrl, }, op: 'ui.webvital.lcp', origin: 'auto.http.browser.lcp', - parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), - segment_id: expect.stringMatching(/[a-f0-9]{16}/), + parent_span_id: expect.stringMatching(/[a-f\d]{16}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), + segment_id: expect.stringMatching(/[a-f\d]{16}/), start_timestamp: expect.any(Number), timestamp: spanEnvelopeItem.start_timestamp, // LCP is a point-in-time metric trace_id: pageloadTraceId, @@ -126,8 +126,8 @@ sentryTest('LCP span is linked to pageload transaction', async ({ getLocalTestUr const pageloadSpanId = eventData.contexts?.trace?.span_id; const pageloadTraceId = eventData.contexts?.trace?.trace_id; - expect(pageloadSpanId).toMatch(/[a-f0-9]{16}/); - expect(pageloadTraceId).toMatch(/[a-f0-9]{32}/); + expect(pageloadSpanId).toMatch(/[a-f\d]{16}/); + expect(pageloadTraceId).toMatch(/[a-f\d]{32}/); const spanEnvelopePromise = getMultipleSentryEnvelopeRequests( page, diff --git a/dev-packages/browser-integration-tests/suites/tracing/request/fetch-immediate/test.ts b/dev-packages/browser-integration-tests/suites/tracing/request/fetch-immediate/test.ts index 7d11168acb1a..f73689554e91 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/request/fetch-immediate/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/request/fetch-immediate/test.ts @@ -25,7 +25,7 @@ sentryTest('should create spans for fetch requests called directly after init', expect(requestSpans![0]).toMatchObject({ description: 'GET http://sentry-test-site.example/0', parent_span_id: tracingEvent.contexts?.trace?.span_id, - span_id: expect.stringMatching(/[a-f0-9]{16}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), start_timestamp: expect.any(Number), timestamp: expect.any(Number), trace_id: tracingEvent.contexts?.trace?.trace_id, diff --git a/dev-packages/browser-integration-tests/suites/tracing/request/fetch-propagateTraceparent/test.ts b/dev-packages/browser-integration-tests/suites/tracing/request/fetch-propagateTraceparent/test.ts index d0aedc65bac8..a580e75415ce 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/request/fetch-propagateTraceparent/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/request/fetch-propagateTraceparent/test.ts @@ -27,8 +27,8 @@ sentryTest( const requestHeaders1 = request1.headers(); const traceparentData1 = extractTraceparentData(requestHeaders1['sentry-trace']); expect(traceparentData1).toMatchObject({ - traceId: expect.stringMatching(/^([a-f0-9]{32})$/), - parentSpanId: expect.stringMatching(/^([a-f0-9]{16})$/), + traceId: expect.stringMatching(/^([a-f\d]{32})$/), + parentSpanId: expect.stringMatching(/^([a-f\d]{16})$/), parentSampled: true, }); diff --git a/dev-packages/browser-integration-tests/suites/tracing/request/fetch-relative-url/test.ts b/dev-packages/browser-integration-tests/suites/tracing/request/fetch-relative-url/test.ts index b1883896100c..0473f01e5015 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/request/fetch-relative-url/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/request/fetch-relative-url/test.ts @@ -23,7 +23,7 @@ sentryTest('should create spans for fetch requests', async ({ getLocalTestUrl, p expect(span).toMatchObject({ description: `GET /test-req/${index}`, parent_span_id: tracingEvent.contexts?.trace?.span_id, - span_id: expect.stringMatching(/[a-f0-9]{16}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), start_timestamp: expect.any(Number), timestamp: expect.any(Number), trace_id: tracingEvent.contexts?.trace?.trace_id, @@ -57,14 +57,14 @@ sentryTest('should attach `sentry-trace` header to fetch requests', async ({ get const request1 = requests[0]; const requestHeaders1 = request1.headers(); expect(requestHeaders1).toMatchObject({ - 'sentry-trace': expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/), + 'sentry-trace': expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-1$/), baggage: expect.any(String), }); const request2 = requests[1]; const requestHeaders2 = request2.headers(); expect(requestHeaders2).toMatchObject({ - 'sentry-trace': expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/), + 'sentry-trace': expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-1$/), baggage: expect.any(String), 'x-test-header': 'existing-header', }); @@ -72,7 +72,7 @@ sentryTest('should attach `sentry-trace` header to fetch requests', async ({ get const request3 = requests[2]; const requestHeaders3 = request3.headers(); expect(requestHeaders3).toMatchObject({ - 'sentry-trace': expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/), + 'sentry-trace': expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-1$/), baggage: expect.any(String), }); }); diff --git a/dev-packages/browser-integration-tests/suites/tracing/request/fetch-strip-query-and-fragment/test.ts b/dev-packages/browser-integration-tests/suites/tracing/request/fetch-strip-query-and-fragment/test.ts index a0fea6e6af29..0ac0731d3537 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/request/fetch-strip-query-and-fragment/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/request/fetch-strip-query-and-fragment/test.ts @@ -24,7 +24,7 @@ sentryTest('strips query params in fetch request spans', async ({ getLocalTestUr expect(requestSpan).toMatchObject({ description: 'GET http://sentry-test-site.example/0', parent_span_id: transactionEvent.contexts?.trace?.span_id, - span_id: expect.stringMatching(/[a-f0-9]{16}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), start_timestamp: expect.any(Number), timestamp: expect.any(Number), trace_id: transactionEvent.contexts?.trace?.trace_id, @@ -67,7 +67,7 @@ sentryTest('strips hash fragment in fetch request spans', async ({ getLocalTestU expect(requestSpan).toMatchObject({ description: 'GET http://sentry-test-site.example/1', parent_span_id: transactionEvent.contexts?.trace?.span_id, - span_id: expect.stringMatching(/[a-f0-9]{16}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), start_timestamp: expect.any(Number), timestamp: expect.any(Number), trace_id: transactionEvent.contexts?.trace?.trace_id, @@ -110,7 +110,7 @@ sentryTest('strips hash fragment and query params in fetch request spans', async expect(requestSpan).toMatchObject({ description: 'GET http://sentry-test-site.example/2', parent_span_id: transactionEvent.contexts?.trace?.span_id, - span_id: expect.stringMatching(/[a-f0-9]{16}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), start_timestamp: expect.any(Number), timestamp: expect.any(Number), trace_id: transactionEvent.contexts?.trace?.trace_id, @@ -154,7 +154,7 @@ sentryTest( expect(requestSpan).toMatchObject({ description: 'GET /api/users', parent_span_id: transactionEvent.contexts?.trace?.span_id, - span_id: expect.stringMatching(/[a-f0-9]{16}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), start_timestamp: expect.any(Number), timestamp: expect.any(Number), trace_id: transactionEvent.contexts?.trace?.trace_id, diff --git a/dev-packages/browser-integration-tests/suites/tracing/request/fetch-tracing-unsampled-propagateTraceparent/test.ts b/dev-packages/browser-integration-tests/suites/tracing/request/fetch-tracing-unsampled-propagateTraceparent/test.ts index 26815021f0e3..b8fd2b92ad01 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/request/fetch-tracing-unsampled-propagateTraceparent/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/request/fetch-tracing-unsampled-propagateTraceparent/test.ts @@ -18,8 +18,8 @@ sentryTest( const traceparentData = extractTraceparentData(requestHeaders['sentry-trace']); expect(traceparentData).toMatchObject({ - traceId: expect.stringMatching(/^([a-f0-9]{32})$/), - parentSpanId: expect.stringMatching(/^([a-f0-9]{16})$/), + traceId: expect.stringMatching(/^([a-f\d]{32})$/), + parentSpanId: expect.stringMatching(/^([a-f\d]{16})$/), parentSampled: false, }); diff --git a/dev-packages/browser-integration-tests/suites/tracing/request/fetch-tracing-unsampled/test.ts b/dev-packages/browser-integration-tests/suites/tracing/request/fetch-tracing-unsampled/test.ts index e1f69cb0fdf1..4d65cfcd78ea 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/request/fetch-tracing-unsampled/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/request/fetch-tracing-unsampled/test.ts @@ -21,14 +21,14 @@ sentryTest('should attach `sentry-trace` header to unsampled fetch requests', as const request1 = requests[0]; const requestHeaders1 = request1.headers(); expect(requestHeaders1).toMatchObject({ - 'sentry-trace': expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-0$/), + 'sentry-trace': expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-0$/), baggage: expect.any(String), }); const request2 = requests[1]; const requestHeaders2 = request2.headers(); expect(requestHeaders2).toMatchObject({ - 'sentry-trace': expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-0$/), + 'sentry-trace': expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-0$/), baggage: expect.any(String), 'x-test-header': 'existing-header', }); @@ -36,7 +36,7 @@ sentryTest('should attach `sentry-trace` header to unsampled fetch requests', as const request3 = requests[2]; const requestHeaders3 = request3.headers(); expect(requestHeaders3).toMatchObject({ - 'sentry-trace': expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-0$/), + 'sentry-trace': expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-0$/), baggage: expect.any(String), }); }); diff --git a/dev-packages/browser-integration-tests/suites/tracing/request/fetch-tracing-without-performance-propagateTraceparent/test.ts b/dev-packages/browser-integration-tests/suites/tracing/request/fetch-tracing-without-performance-propagateTraceparent/test.ts index 718cca0c8701..5ecb32caa07f 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/request/fetch-tracing-without-performance-propagateTraceparent/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/request/fetch-tracing-without-performance-propagateTraceparent/test.ts @@ -22,8 +22,8 @@ sentryTest( const traceparentData = extractTraceparentData(requestHeaders0['sentry-trace']); expect(traceparentData).toMatchObject({ - traceId: expect.stringMatching(/^([a-f0-9]{32})$/), - parentSpanId: expect.stringMatching(/^([a-f0-9]{16})$/), + traceId: expect.stringMatching(/^([a-f\d]{32})$/), + parentSpanId: expect.stringMatching(/^([a-f\d]{16})$/), parentSampled: undefined, }); diff --git a/dev-packages/browser-integration-tests/suites/tracing/request/fetch-tracing-without-performance/test.ts b/dev-packages/browser-integration-tests/suites/tracing/request/fetch-tracing-without-performance/test.ts index c2ebf52d18f6..c16c1d90ddda 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/request/fetch-tracing-without-performance/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/request/fetch-tracing-without-performance/test.ts @@ -23,14 +23,14 @@ sentryTest( const request1 = requests[0]; const requestHeaders1 = request1.headers(); expect(requestHeaders1).toMatchObject({ - 'sentry-trace': expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/), + 'sentry-trace': expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})$/), baggage: expect.any(String), }); const request2 = requests[1]; const requestHeaders2 = request2.headers(); expect(requestHeaders2).toMatchObject({ - 'sentry-trace': expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/), + 'sentry-trace': expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})$/), baggage: expect.any(String), 'x-test-header': 'existing-header', }); @@ -38,7 +38,7 @@ sentryTest( const request3 = requests[2]; const requestHeaders3 = request3.headers(); expect(requestHeaders3).toMatchObject({ - 'sentry-trace': expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/), + 'sentry-trace': expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})$/), baggage: expect.any(String), }); }, diff --git a/dev-packages/browser-integration-tests/suites/tracing/request/fetch/test.ts b/dev-packages/browser-integration-tests/suites/tracing/request/fetch/test.ts index 72a196d5d8e9..7955676bf0c8 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/request/fetch/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/request/fetch/test.ts @@ -26,7 +26,7 @@ sentryTest('should create spans for fetch requests', async ({ getLocalTestUrl, p expect(span).toMatchObject({ description: `GET http://sentry-test-site.example/${index}`, parent_span_id: tracingEvent.contexts?.trace?.span_id, - span_id: expect.stringMatching(/[a-f0-9]{16}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), start_timestamp: expect.any(Number), timestamp: expect.any(Number), trace_id: tracingEvent.contexts?.trace?.trace_id, @@ -62,7 +62,7 @@ sentryTest('attaches `sentry-trace` and `baggage` headers to fetch requests', as const request1 = requests[0]; const requestHeaders1 = request1.headers(); expect(requestHeaders1).toMatchObject({ - 'sentry-trace': expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/), + 'sentry-trace': expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-1$/), baggage: expect.any(String), }); // traceparent must only be attached if propagateTraceparent is `true` @@ -71,7 +71,7 @@ sentryTest('attaches `sentry-trace` and `baggage` headers to fetch requests', as const request2 = requests[1]; const requestHeaders2 = request2.headers(); expect(requestHeaders2).toMatchObject({ - 'sentry-trace': expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/), + 'sentry-trace': expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-1$/), baggage: expect.any(String), 'x-test-header': 'existing-header', }); @@ -80,7 +80,7 @@ sentryTest('attaches `sentry-trace` and `baggage` headers to fetch requests', as const request3 = requests[2]; const requestHeaders3 = request3.headers(); expect(requestHeaders3).toMatchObject({ - 'sentry-trace': expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/), + 'sentry-trace': expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-1$/), baggage: expect.any(String), }); expect(requestHeaders3).not.toHaveProperty('traceparent'); diff --git a/dev-packages/browser-integration-tests/suites/tracing/request/xhr-propagateTraceparent/test.ts b/dev-packages/browser-integration-tests/suites/tracing/request/xhr-propagateTraceparent/test.ts index 1289dfb6cdcc..b97a6a70479b 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/request/xhr-propagateTraceparent/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/request/xhr-propagateTraceparent/test.ts @@ -25,8 +25,8 @@ sentryTest( const requestHeaders1 = request1.headers(); const traceparentData1 = extractTraceparentData(requestHeaders1['sentry-trace']); expect(traceparentData1).toMatchObject({ - traceId: expect.stringMatching(/^([a-f0-9]{32})$/), - parentSpanId: expect.stringMatching(/^([a-f0-9]{16})$/), + traceId: expect.stringMatching(/^([a-f\d]{32})$/), + parentSpanId: expect.stringMatching(/^([a-f\d]{16})$/), parentSampled: true, }); diff --git a/dev-packages/browser-integration-tests/suites/tracing/request/xhr-relative-url/test.ts b/dev-packages/browser-integration-tests/suites/tracing/request/xhr-relative-url/test.ts index ef180c0dcb6d..e207d3db04b2 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/request/xhr-relative-url/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/request/xhr-relative-url/test.ts @@ -23,7 +23,7 @@ sentryTest('should create spans for xhr requests', async ({ getLocalTestUrl, pag expect(span).toMatchObject({ description: `GET /test-req/${index}`, parent_span_id: tracingEvent.contexts?.trace?.span_id, - span_id: expect.stringMatching(/[a-f0-9]{16}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), start_timestamp: expect.any(Number), timestamp: expect.any(Number), trace_id: tracingEvent.contexts?.trace?.trace_id, @@ -57,14 +57,14 @@ sentryTest('should attach `sentry-trace` header to xhr requests', async ({ getLo const request1 = requests[0]; const requestHeaders1 = request1.headers(); expect(requestHeaders1).toMatchObject({ - 'sentry-trace': expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/), + 'sentry-trace': expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-1$/), baggage: expect.any(String), }); const request2 = requests[1]; const requestHeaders2 = request2.headers(); expect(requestHeaders2).toMatchObject({ - 'sentry-trace': expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/), + 'sentry-trace': expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-1$/), baggage: expect.any(String), 'x-test-header': 'existing-header', }); @@ -72,7 +72,7 @@ sentryTest('should attach `sentry-trace` header to xhr requests', async ({ getLo const request3 = requests[2]; const requestHeaders3 = request3.headers(); expect(requestHeaders3).toMatchObject({ - 'sentry-trace': expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/), + 'sentry-trace': expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-1$/), baggage: expect.any(String), }); }); diff --git a/dev-packages/browser-integration-tests/suites/tracing/request/xhr-strip-query-and-fragment/test.ts b/dev-packages/browser-integration-tests/suites/tracing/request/xhr-strip-query-and-fragment/test.ts index d4ed06fcdd4e..fb96465b8b5b 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/request/xhr-strip-query-and-fragment/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/request/xhr-strip-query-and-fragment/test.ts @@ -24,7 +24,7 @@ sentryTest('strips query params in XHR request spans', async ({ getLocalTestUrl, expect(requestSpan).toMatchObject({ description: 'GET http://sentry-test-site.example/0', parent_span_id: transactionEvent.contexts?.trace?.span_id, - span_id: expect.stringMatching(/[a-f0-9]{16}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), start_timestamp: expect.any(Number), timestamp: expect.any(Number), trace_id: transactionEvent.contexts?.trace?.trace_id, @@ -66,7 +66,7 @@ sentryTest('strips hash fragment in XHR request spans', async ({ getLocalTestUrl expect(requestSpan).toMatchObject({ description: 'GET http://sentry-test-site.example/1', parent_span_id: transactionEvent.contexts?.trace?.span_id, - span_id: expect.stringMatching(/[a-f0-9]{16}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), start_timestamp: expect.any(Number), timestamp: expect.any(Number), trace_id: transactionEvent.contexts?.trace?.trace_id, @@ -108,7 +108,7 @@ sentryTest('strips hash fragment and query params in XHR request spans', async ( expect(requestSpan).toMatchObject({ description: 'GET http://sentry-test-site.example/2', parent_span_id: transactionEvent.contexts?.trace?.span_id, - span_id: expect.stringMatching(/[a-f0-9]{16}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), start_timestamp: expect.any(Number), timestamp: expect.any(Number), trace_id: transactionEvent.contexts?.trace?.trace_id, @@ -151,7 +151,7 @@ sentryTest( expect(requestSpan).toMatchObject({ description: 'GET /api/users', parent_span_id: transactionEvent.contexts?.trace?.span_id, - span_id: expect.stringMatching(/[a-f0-9]{16}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), start_timestamp: expect.any(Number), timestamp: expect.any(Number), trace_id: transactionEvent.contexts?.trace?.trace_id, diff --git a/dev-packages/browser-integration-tests/suites/tracing/request/xhr-tracing-unsampled/test.ts b/dev-packages/browser-integration-tests/suites/tracing/request/xhr-tracing-unsampled/test.ts index 786ce872d349..ba4fd377fc1c 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/request/xhr-tracing-unsampled/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/request/xhr-tracing-unsampled/test.ts @@ -21,14 +21,14 @@ sentryTest('should attach `sentry-trace` header to unsampled xhr requests', asyn const request1 = requests[0]; const requestHeaders1 = request1.headers(); expect(requestHeaders1).toMatchObject({ - 'sentry-trace': expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-0$/), + 'sentry-trace': expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-0$/), baggage: expect.any(String), }); const request2 = requests[1]; const requestHeaders2 = request2.headers(); expect(requestHeaders2).toMatchObject({ - 'sentry-trace': expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-0$/), + 'sentry-trace': expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-0$/), baggage: expect.any(String), 'x-test-header': 'existing-header', }); @@ -36,7 +36,7 @@ sentryTest('should attach `sentry-trace` header to unsampled xhr requests', asyn const request3 = requests[2]; const requestHeaders3 = request3.headers(); expect(requestHeaders3).toMatchObject({ - 'sentry-trace': expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-0$/), + 'sentry-trace': expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-0$/), baggage: expect.any(String), }); }); diff --git a/dev-packages/browser-integration-tests/suites/tracing/request/xhr-tracing-without-performance-propagateTraceparent/test.ts b/dev-packages/browser-integration-tests/suites/tracing/request/xhr-tracing-without-performance-propagateTraceparent/test.ts index de1afa51f962..23bf6e6ccac9 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/request/xhr-tracing-without-performance-propagateTraceparent/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/request/xhr-tracing-without-performance-propagateTraceparent/test.ts @@ -18,8 +18,8 @@ sentryTest( const traceparentData = extractTraceparentData(requestHeaders['sentry-trace']); expect(traceparentData).toEqual({ - traceId: expect.stringMatching(/^([a-f0-9]{32})$/), - parentSpanId: expect.stringMatching(/^([a-f0-9]{16})$/), + traceId: expect.stringMatching(/^([a-f\d]{32})$/), + parentSpanId: expect.stringMatching(/^([a-f\d]{16})$/), parentSampled: undefined, }); diff --git a/dev-packages/browser-integration-tests/suites/tracing/request/xhr-tracing-without-performance/test.ts b/dev-packages/browser-integration-tests/suites/tracing/request/xhr-tracing-without-performance/test.ts index 728133a2ac4c..1806fcad21b5 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/request/xhr-tracing-without-performance/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/request/xhr-tracing-without-performance/test.ts @@ -23,14 +23,14 @@ sentryTest( const request1 = requests[0]; const requestHeaders1 = request1.headers(); expect(requestHeaders1).toMatchObject({ - 'sentry-trace': expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/), + 'sentry-trace': expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})$/), baggage: expect.any(String), }); const request2 = requests[1]; const requestHeaders2 = request2.headers(); expect(requestHeaders2).toMatchObject({ - 'sentry-trace': expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/), + 'sentry-trace': expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})$/), baggage: expect.any(String), 'x-test-header': 'existing-header', }); @@ -38,7 +38,7 @@ sentryTest( const request3 = requests[2]; const requestHeaders3 = request3.headers(); expect(requestHeaders3).toMatchObject({ - 'sentry-trace': expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/), + 'sentry-trace': expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})$/), baggage: expect.any(String), }); }, diff --git a/dev-packages/browser-integration-tests/suites/tracing/request/xhr/test.ts b/dev-packages/browser-integration-tests/suites/tracing/request/xhr/test.ts index cf3b11c02260..ccf40203281a 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/request/xhr/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/request/xhr/test.ts @@ -21,7 +21,7 @@ sentryTest('should create spans for XHR requests', async ({ getLocalTestUrl, pag expect(span).toMatchObject({ description: `GET http://sentry-test-site.example/${index}`, parent_span_id: eventData.contexts?.trace?.span_id, - span_id: expect.stringMatching(/[a-f0-9]{16}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), start_timestamp: expect.any(Number), timestamp: expect.any(Number), trace_id: eventData.contexts?.trace?.trace_id, @@ -55,14 +55,14 @@ sentryTest('should attach `sentry-trace` header to XHR requests', async ({ getLo const request1 = requests[0]; const requestHeaders1 = request1.headers(); expect(requestHeaders1).toMatchObject({ - 'sentry-trace': expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/), + 'sentry-trace': expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-1$/), baggage: expect.any(String), }); const request2 = requests[1]; const requestHeaders2 = request2.headers(); expect(requestHeaders2).toMatchObject({ - 'sentry-trace': expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/), + 'sentry-trace': expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-1$/), baggage: expect.any(String), 'x-test-header': 'existing-header', }); @@ -70,7 +70,7 @@ sentryTest('should attach `sentry-trace` header to XHR requests', async ({ getLo const request3 = requests[2]; const requestHeaders3 = request3.headers(); expect(requestHeaders3).toMatchObject({ - 'sentry-trace': expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/), + 'sentry-trace': expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-1$/), baggage: expect.any(String), }); }); diff --git a/dev-packages/browser-integration-tests/suites/tracing/setSpanActive/default/test.ts b/dev-packages/browser-integration-tests/suites/tracing/setSpanActive/default/test.ts index 080ebbfa6e84..2019c78c837f 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/setSpanActive/default/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/setSpanActive/default/test.ts @@ -14,7 +14,7 @@ sentryTest('sets an inactive span active and adds child spans to it', async ({ g const checkoutEvent = envelopeRequestParser(await req); const checkoutSpanId = checkoutEvent.contexts?.trace?.span_id; - expect(checkoutSpanId).toMatch(/[a-f0-9]{16}/); + expect(checkoutSpanId).toMatch(/[a-f\d]{16}/); expect(checkoutEvent.spans).toHaveLength(3); diff --git a/dev-packages/browser-integration-tests/suites/tracing/setSpanActive/nested-parentAlwaysRoot/test.ts b/dev-packages/browser-integration-tests/suites/tracing/setSpanActive/nested-parentAlwaysRoot/test.ts index 2270b470123b..5132178d1981 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/setSpanActive/nested-parentAlwaysRoot/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/setSpanActive/nested-parentAlwaysRoot/test.ts @@ -21,8 +21,8 @@ sentryTest( const checkoutSpanId = checkoutEvent.contexts?.trace?.span_id; const postCheckoutSpanId = postCheckoutEvent.contexts?.trace?.span_id; - expect(checkoutSpanId).toMatch(/[a-f0-9]{16}/); - expect(postCheckoutSpanId).toMatch(/[a-f0-9]{16}/); + expect(checkoutSpanId).toMatch(/[a-f\d]{16}/); + expect(postCheckoutSpanId).toMatch(/[a-f\d]{16}/); expect(checkoutEvent.spans).toHaveLength(4); expect(postCheckoutEvent.spans).toHaveLength(1); diff --git a/dev-packages/browser-integration-tests/suites/tracing/setSpanActive/nested/test.ts b/dev-packages/browser-integration-tests/suites/tracing/setSpanActive/nested/test.ts index 094bb0ed3dd8..cea01f304691 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/setSpanActive/nested/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/setSpanActive/nested/test.ts @@ -21,8 +21,8 @@ sentryTest( const checkoutSpanId = checkoutEvent.contexts?.trace?.span_id; const postCheckoutSpanId = postCheckoutEvent.contexts?.trace?.span_id; - expect(checkoutSpanId).toMatch(/[a-f0-9]{16}/); - expect(postCheckoutSpanId).toMatch(/[a-f0-9]{16}/); + expect(checkoutSpanId).toMatch(/[a-f\d]{16}/); + expect(postCheckoutSpanId).toMatch(/[a-f\d]{16}/); expect(checkoutEvent.spans).toHaveLength(4); expect(postCheckoutEvent.spans).toHaveLength(1); diff --git a/dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/navigation/test.ts b/dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/navigation/test.ts index 42547709e928..0255507287d3 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/navigation/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/navigation/test.ts @@ -38,8 +38,8 @@ sentryTest('creates a new trace and sample_rand on each navigation', async ({ ge expect(navigation1TraceContext).toMatchObject({ op: 'navigation', - trace_id: expect.stringMatching(/^[0-9a-f]{32}$/), - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + trace_id: expect.stringMatching(/^[\da-f]{32}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); expect(navigation1TraceContext).not.toHaveProperty('parent_span_id'); @@ -54,8 +54,8 @@ sentryTest('creates a new trace and sample_rand on each navigation', async ({ ge expect(navigation2TraceContext).toMatchObject({ op: 'navigation', - trace_id: expect.stringMatching(/^[0-9a-f]{32}$/), - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + trace_id: expect.stringMatching(/^[\da-f]{32}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); expect(navigation2TraceContext).not.toHaveProperty('parent_span_id'); @@ -93,8 +93,8 @@ sentryTest('error after navigation has navigation traceId', async ({ getLocalTes expect(navigationTraceContext).toMatchObject({ op: 'navigation', - trace_id: expect.stringMatching(/^[0-9a-f]{32}$/), - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + trace_id: expect.stringMatching(/^[\da-f]{32}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); expect(navigationTraceContext).not.toHaveProperty('parent_span_id'); @@ -120,7 +120,7 @@ sentryTest('error after navigation has navigation traceId', async ({ getLocalTes const errorTraceContext = errorEvent.contexts?.trace; expect(errorTraceContext).toEqual({ trace_id: navigationTraceContext?.trace_id, - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); expect(errorTraceHeader).toEqual({ environment: 'production', @@ -162,8 +162,8 @@ sentryTest('error during navigation has new navigation traceId', async ({ getLoc const navigationTraceContext = navigationEvent?.contexts?.trace; expect(navigationTraceContext).toMatchObject({ op: 'navigation', - trace_id: expect.stringMatching(/^[0-9a-f]{32}$/), - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + trace_id: expect.stringMatching(/^[\da-f]{32}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); expect(navigationTraceContext).not.toHaveProperty('parent_span_id'); @@ -179,7 +179,7 @@ sentryTest('error during navigation has new navigation traceId', async ({ getLoc const errorTraceContext = errorEvent?.contexts?.trace; expect(errorTraceContext).toEqual({ trace_id: navigationTraceContext?.trace_id, - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); expect(errorTraceHeader).toEqual({ @@ -230,8 +230,8 @@ sentryTest( expect(navigationEvent.type).toEqual('transaction'); expect(navigationTraceContext).toMatchObject({ op: 'navigation', - trace_id: expect.stringMatching(/^[0-9a-f]{32}$/), - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + trace_id: expect.stringMatching(/^[\da-f]{32}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); expect(navigationTraceContext).not.toHaveProperty('parent_span_id'); @@ -293,8 +293,8 @@ sentryTest( expect(navigationEvent.type).toEqual('transaction'); expect(navigationTraceContext).toMatchObject({ op: 'navigation', - trace_id: expect.stringMatching(/^[0-9a-f]{32}$/), - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + trace_id: expect.stringMatching(/^[\da-f]{32}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); expect(navigationTraceContext).not.toHaveProperty('parent_span_id'); @@ -335,8 +335,8 @@ sentryTest( const navigationTraceContext = navigationEvent.contexts?.trace; expect(navigationTraceContext).toMatchObject({ op: 'navigation', - trace_id: expect.stringMatching(/^[0-9a-f]{32}$/), - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + trace_id: expect.stringMatching(/^[\da-f]{32}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); expect(navigationTraceContext).not.toHaveProperty('parent_span_id'); @@ -357,7 +357,7 @@ sentryTest( expect(feedbackTraceContext).toMatchObject({ trace_id: navigationTraceContext?.trace_id, - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); }, ); diff --git a/dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/pageload-meta/test.ts b/dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/pageload-meta/test.ts index 98f468818d51..4269f91c2c07 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/pageload-meta/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/pageload-meta/test.ts @@ -43,7 +43,7 @@ sentryTest( op: 'pageload', trace_id: META_TAG_TRACE_ID, parent_span_id: META_TAG_PARENT_SPAN_ID, - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); expect(pageloadTraceHeader).toEqual({ @@ -60,8 +60,8 @@ sentryTest( expect(navigationEvent.type).toEqual('transaction'); expect(navigationTraceContext).toMatchObject({ op: 'navigation', - trace_id: expect.stringMatching(/^[0-9a-f]{32}$/), - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + trace_id: expect.stringMatching(/^[\da-f]{32}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); // navigation span is head of trace, so there's no parent span: expect(navigationTraceContext?.trace_id).not.toHaveProperty('parent_span_id'); @@ -97,7 +97,7 @@ sentryTest('error after tag pageload has pageload traceId', async ({ getL op: 'pageload', trace_id: META_TAG_TRACE_ID, parent_span_id: META_TAG_PARENT_SPAN_ID, - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); expect(pageloadTraceHeader).toEqual({ @@ -123,7 +123,7 @@ sentryTest('error after tag pageload has pageload traceId', async ({ getL expect(errorEvent.contexts?.trace).toEqual({ trace_id: META_TAG_TRACE_ID, parent_span_id: META_TAG_PARENT_SPAN_ID, - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); expect(errorTraceHeader).toEqual({ @@ -165,7 +165,7 @@ sentryTest('error during tag pageload has pageload traceId', async ({ get op: 'pageload', trace_id: META_TAG_TRACE_ID, parent_span_id: META_TAG_PARENT_SPAN_ID, - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); expect(pageloadTraceHeader).toEqual({ @@ -183,7 +183,7 @@ sentryTest('error during tag pageload has pageload traceId', async ({ get expect(errorEvent?.contexts?.trace).toEqual({ trace_id: META_TAG_TRACE_ID, parent_span_id: META_TAG_PARENT_SPAN_ID, - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); expect(errorTraceHeader).toEqual({ @@ -230,7 +230,7 @@ sentryTest( op: 'pageload', trace_id: META_TAG_TRACE_ID, parent_span_id: META_TAG_PARENT_SPAN_ID, - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); expect(pageloadTraceHeader).toEqual({ @@ -247,6 +247,7 @@ sentryTest( const headers = request.headers(); // sampling decision is propagated from meta tag's sentry-trace sampled flag + // eslint-disable-next-line regexp/prefer-d expect(headers['sentry-trace']).toMatch(new RegExp(`^${META_TAG_TRACE_ID}-[0-9a-f]{16}-1$`)); expect(headers['baggage']).toBe(META_TAG_BAGGAGE); }, @@ -284,7 +285,7 @@ sentryTest( op: 'pageload', trace_id: META_TAG_TRACE_ID, parent_span_id: META_TAG_PARENT_SPAN_ID, - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); expect(pageloadTraceHeader).toEqual({ @@ -301,6 +302,7 @@ sentryTest( const headers = request.headers(); // sampling decision is propagated from meta tag's sentry-trace sampled flag + // eslint-disable-next-line regexp/prefer-d expect(headers['sentry-trace']).toMatch(new RegExp(`^${META_TAG_TRACE_ID}-[0-9a-f]{16}-1$`)); expect(headers['baggage']).toBe(META_TAG_BAGGAGE); }, @@ -320,7 +322,7 @@ sentryTest('user feedback event after pageload has pageload traceId in headers', op: 'pageload', trace_id: META_TAG_TRACE_ID, parent_span_id: META_TAG_PARENT_SPAN_ID, - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); const feedbackEventPromise = getFirstSentryEnvelopeRequest(page); @@ -340,6 +342,6 @@ sentryTest('user feedback event after pageload has pageload traceId in headers', expect(feedbackTraceContext).toMatchObject({ trace_id: META_TAG_TRACE_ID, parent_span_id: META_TAG_PARENT_SPAN_ID, - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); }); diff --git a/dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/pageload/test.ts b/dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/pageload/test.ts index e889be038bdd..e6edd02cf360 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/pageload/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/pageload/test.ts @@ -38,8 +38,8 @@ sentryTest( expect(pageloadTraceContext).toMatchObject({ op: 'pageload', - trace_id: expect.stringMatching(/^[0-9a-f]{32}$/), - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + trace_id: expect.stringMatching(/^[\da-f]{32}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); expect(pageloadTraceContext).not.toHaveProperty('parent_span_id'); @@ -54,8 +54,8 @@ sentryTest( expect(navigationTraceContext).toMatchObject({ op: 'navigation', - trace_id: expect.stringMatching(/^[0-9a-f]{32}$/), - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + trace_id: expect.stringMatching(/^[\da-f]{32}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); expect(navigationTraceContext).not.toHaveProperty('parent_span_id'); @@ -89,8 +89,8 @@ sentryTest('error after pageload has pageload traceId', async ({ getLocalTestUrl expect(pageloadEvent.type).toEqual('transaction'); expect(pageloadTraceContext).toMatchObject({ op: 'pageload', - trace_id: expect.stringMatching(/^[0-9a-f]{32}$/), - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + trace_id: expect.stringMatching(/^[\da-f]{32}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); expect(pageloadTraceContext).not.toHaveProperty('parent_span_id'); @@ -116,7 +116,7 @@ sentryTest('error after pageload has pageload traceId', async ({ getLocalTestUrl expect(errorTraceContext).toEqual({ trace_id: pageloadTraceContext?.trace_id, - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); expect(errorTraceHeader).toEqual({ @@ -156,8 +156,8 @@ sentryTest('error during pageload has pageload traceId', async ({ getLocalTestUr expect(pageloadEvent.type).toEqual('transaction'); expect(pageloadTraceContext).toMatchObject({ op: 'pageload', - trace_id: expect.stringMatching(/^[0-9a-f]{32}$/), - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + trace_id: expect.stringMatching(/^[\da-f]{32}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); expect(pageloadTraceContext).not.toHaveProperty('parent_span_id'); @@ -175,7 +175,7 @@ sentryTest('error during pageload has pageload traceId', async ({ getLocalTestUr expect(errorEvent.type).toEqual(undefined); expect(errorTraceContext).toEqual({ trace_id: pageloadTraceContext?.trace_id, - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); expect(errorTraceHeader).toEqual({ @@ -221,8 +221,8 @@ sentryTest( expect(pageloadEvent.type).toEqual('transaction'); expect(pageloadTraceContext).toMatchObject({ op: 'pageload', - trace_id: expect.stringMatching(/^[0-9a-f]{32}$/), - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + trace_id: expect.stringMatching(/^[\da-f]{32}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); expect(pageloadTraceContext).not.toHaveProperty('parent_span_id'); @@ -278,8 +278,8 @@ sentryTest( expect(pageloadEvent.type).toEqual('transaction'); expect(pageloadTraceContext).toMatchObject({ op: 'pageload', - trace_id: expect.stringMatching(/^[0-9a-f]{32}$/), - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + trace_id: expect.stringMatching(/^[\da-f]{32}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); expect(pageloadTraceContext).not.toHaveProperty('parent_span_id'); @@ -457,8 +457,8 @@ sentryTest('user feedback event after pageload has pageload traceId in headers', expect(pageloadTraceContext).toMatchObject({ op: 'pageload', - trace_id: expect.stringMatching(/^[0-9a-f]{32}$/), - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + trace_id: expect.stringMatching(/^[\da-f]{32}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); expect(pageloadTraceContext).not.toHaveProperty('parent_span_id'); @@ -479,6 +479,6 @@ sentryTest('user feedback event after pageload has pageload traceId in headers', expect(feedbackTraceContext).toMatchObject({ trace_id: pageloadTraceContext?.trace_id, - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); }); diff --git a/dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/startNewTrace/test.ts b/dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/startNewTrace/test.ts index 6f5ede5eccf8..40cc8a64d75f 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/startNewTrace/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/startNewTrace/test.ts @@ -37,8 +37,8 @@ sentryTest( expect(pageloadTraceContext).toMatchObject({ op: 'pageload', - trace_id: expect.stringMatching(/^[0-9a-f]{32}$/), - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + trace_id: expect.stringMatching(/^[\da-f]{32}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); expect(pageloadTraceContext).not.toHaveProperty('parent_span_id'); @@ -71,8 +71,8 @@ sentryTest( const newTraceTransactionTraceContext = newTraceTransactionEvent.contexts?.trace; expect(newTraceTransactionTraceContext).toMatchObject({ op: 'ui.interaction.click', - trace_id: expect.stringMatching(/^[0-9a-f]{32}$/), - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + trace_id: expect.stringMatching(/^[\da-f]{32}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); expect(newTraceTransactionTraceHeaders).toEqual({ @@ -88,8 +88,8 @@ sentryTest( const oldTraceTransactionEventTraceContext = oldTraceTransactionEvent.contexts?.trace; expect(oldTraceTransactionEventTraceContext).toMatchObject({ op: 'ui.interaction.click', - trace_id: expect.stringMatching(/^[0-9a-f]{32}$/), - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + trace_id: expect.stringMatching(/^[\da-f]{32}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); expect(oldTraceTransactionTraceHeaders).toEqual({ diff --git a/dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/startNewTraceSampling/test.ts b/dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/startNewTraceSampling/test.ts index 616c89cd66f8..dc3d75f54799 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/startNewTraceSampling/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/startNewTraceSampling/test.ts @@ -37,8 +37,8 @@ sentryTest( expect(pageloadTraceContext).toMatchObject({ op: 'pageload', - trace_id: expect.stringMatching(/^[0-9a-f]{32}$/), - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + trace_id: expect.stringMatching(/^[\da-f]{32}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), data: { 'sentry.sample_rate': 0.5, }, @@ -67,8 +67,8 @@ sentryTest( const newTraceTransactionTraceContext = newTraceTransactionEvent.contexts?.trace; expect(newTraceTransactionTraceContext).toMatchObject({ op: 'ui.interaction.click', - trace_id: expect.stringMatching(/^[0-9a-f]{32}$/), - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + trace_id: expect.stringMatching(/^[\da-f]{32}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), data: { 'sentry.sample_rate': 0.9, }, diff --git a/dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/tracing-without-performance-propagateTraceparent/test.ts b/dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/tracing-without-performance-propagateTraceparent/test.ts index d2106b892b7b..8ce78c869179 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/tracing-without-performance-propagateTraceparent/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/tracing-without-performance-propagateTraceparent/test.ts @@ -36,7 +36,7 @@ sentryTest( // sampling decision is deferred because TwP means we didn't sample any span expect(sentryTraceParentData).toEqual({ traceId: META_TAG_TRACE_ID, - parentSpanId: expect.stringMatching(/^[0-9a-f]{16}$/), + parentSpanId: expect.stringMatching(/^[\da-f]{16}$/), parentSampled: undefined, }); expect(headers['baggage']).toBe(META_TAG_BAGGAGE); @@ -69,7 +69,7 @@ sentryTest( }); expect(headers3['baggage']).toMatch( - /sentry-environment=production,sentry-public_key=public,sentry-trace_id=[0-9a-f]{32}/, + /sentry-environment=production,sentry-public_key=public,sentry-trace_id=[\da-f]{32}/, ); expect(headers3['baggage']).not.toContain(`sentry-trace_id=${META_TAG_TRACE_ID}`); // but traceparent propagates a negative sampling decision because it has no concept of deferred sampling @@ -110,6 +110,7 @@ sentryTest('outgoing XHR requests have new traceId after navigation', async ({ g const headers = request.headers(); // sampling decision is deferred because TwP means we didn't sample any span + // eslint-disable-next-line regexp/prefer-d expect(headers['sentry-trace']).toMatch(new RegExp(`^${META_TAG_TRACE_ID}-[0-9a-f]{16}$`)); expect(headers['baggage']).toBe(META_TAG_BAGGAGE); @@ -121,10 +122,10 @@ sentryTest('outgoing XHR requests have new traceId after navigation', async ({ g const headers2 = request2.headers(); // sampling decision is deferred because TwP means we didn't sample any span - expect(headers2['sentry-trace']).toMatch(/^[0-9a-f]{32}-[0-9a-f]{16}$/); + expect(headers2['sentry-trace']).toMatch(/^[\da-f]{32}-[\da-f]{16}$/); expect(headers2['baggage']).not.toBe(`${META_TAG_TRACE_ID}-${META_TAG_PARENT_SPAN_ID}`); expect(headers2['baggage']).toMatch( - /sentry-environment=production,sentry-public_key=public,sentry-trace_id=[0-9a-f]{32}/, + /sentry-environment=production,sentry-public_key=public,sentry-trace_id=[\da-f]{32}/, ); expect(headers2['baggage']).not.toContain(`sentry-trace_id=${META_TAG_TRACE_ID}`); }); diff --git a/dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/tracing-without-performance/test.ts b/dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/tracing-without-performance/test.ts index 686f65227aa7..51cc61e0de0c 100644 --- a/dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/tracing-without-performance/test.ts +++ b/dev-packages/browser-integration-tests/suites/tracing/trace-lifetime/tracing-without-performance/test.ts @@ -33,7 +33,7 @@ sentryTest('error on initial page has traceId from meta tag', async ({ getLocalT expect(errorEvent.contexts?.trace).toEqual({ trace_id: META_TAG_TRACE_ID, parent_span_id: META_TAG_PARENT_SPAN_ID, - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); expect(errorTraceHeader).toEqual({ @@ -65,7 +65,7 @@ sentryTest('error has new traceId after navigation', async ({ getLocalTestUrl, p expect(errorEvent.contexts?.trace).toEqual({ trace_id: META_TAG_TRACE_ID, parent_span_id: META_TAG_PARENT_SPAN_ID, - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); expect(errorTraceHeader).toEqual({ @@ -85,8 +85,8 @@ sentryTest('error has new traceId after navigation', async ({ getLocalTestUrl, p const [errorEvent2, errorTraceHeader2] = await errorEventPromise2; expect(errorEvent2.contexts?.trace).toEqual({ - trace_id: expect.stringMatching(/^[0-9a-f]{32}$/), - span_id: expect.stringMatching(/^[0-9a-f]{16}$/), + trace_id: expect.stringMatching(/^[\da-f]{32}$/), + span_id: expect.stringMatching(/^[\da-f]{16}$/), }); expect(errorTraceHeader2).toEqual({ @@ -121,6 +121,7 @@ sentryTest('outgoing fetch requests have new traceId after navigation', async ({ const headers = request.headers(); // sampling decision is deferred because TwP means we didn't sample any span + // eslint-disable-next-line regexp/prefer-d expect(headers['sentry-trace']).toMatch(new RegExp(`^${META_TAG_TRACE_ID}-[0-9a-f]{16}$`)); expect(headers['baggage']).toBe(META_TAG_BAGGAGE); @@ -132,10 +133,10 @@ sentryTest('outgoing fetch requests have new traceId after navigation', async ({ const headers2 = request2.headers(); // sampling decision is deferred because TwP means we didn't sample any span - expect(headers2['sentry-trace']).toMatch(/^[0-9a-f]{32}-[0-9a-f]{16}$/); + expect(headers2['sentry-trace']).toMatch(/^[\da-f]{32}-[\da-f]{16}$/); expect(headers2['baggage']).not.toBe(`${META_TAG_TRACE_ID}-${META_TAG_PARENT_SPAN_ID}`); expect(headers2['baggage']).toMatch( - /sentry-environment=production,sentry-public_key=public,sentry-trace_id=[0-9a-f]{32}/, + /sentry-environment=production,sentry-public_key=public,sentry-trace_id=[\da-f]{32}/, ); expect(headers2['baggage']).not.toContain(`sentry-trace_id=${META_TAG_TRACE_ID}`); }); @@ -163,6 +164,7 @@ sentryTest('outgoing XHR requests have new traceId after navigation', async ({ g const headers = request.headers(); // sampling decision is deferred because TwP means we didn't sample any span + // eslint-disable-next-line regexp/prefer-d expect(headers['sentry-trace']).toMatch(new RegExp(`^${META_TAG_TRACE_ID}-[0-9a-f]{16}$`)); expect(headers['baggage']).toBe(META_TAG_BAGGAGE); @@ -174,10 +176,10 @@ sentryTest('outgoing XHR requests have new traceId after navigation', async ({ g const headers2 = request2.headers(); // sampling decision is deferred because TwP means we didn't sample any span - expect(headers2['sentry-trace']).toMatch(/^[0-9a-f]{32}-[0-9a-f]{16}$/); + expect(headers2['sentry-trace']).toMatch(/^[\da-f]{32}-[\da-f]{16}$/); expect(headers2['baggage']).not.toBe(`${META_TAG_TRACE_ID}-${META_TAG_PARENT_SPAN_ID}`); expect(headers2['baggage']).toMatch( - /sentry-environment=production,sentry-public_key=public,sentry-trace_id=[0-9a-f]{32}/, + /sentry-environment=production,sentry-public_key=public,sentry-trace_id=[\da-f]{32}/, ); expect(headers2['baggage']).not.toContain(`sentry-trace_id=${META_TAG_TRACE_ID}`); }); diff --git a/dev-packages/browser-integration-tests/utils/replayHelpers.ts b/dev-packages/browser-integration-tests/utils/replayHelpers.ts index 86a9e5ba3d78..72e98cb3e9d1 100644 --- a/dev-packages/browser-integration-tests/utils/replayHelpers.ts +++ b/dev-packages/browser-integration-tests/utils/replayHelpers.ts @@ -447,9 +447,10 @@ export function normalize( ): string { const rawString = JSON.stringify(obj, null, 2); let normalizedString = rawString - .replace(/"file:\/\/.+(\/.*\.html)"/gm, '"$1"') - .replace(/"timeOffset":\s*-?\d+/gm, '"timeOffset": [timeOffset]') - .replace(/"timestamp":\s*0/gm, '"timestamp": [timestamp]'); + // eslint-disable-next-line regexp/no-super-linear-backtracking + .replace(/"file:\/\/.+(\/.*\.html)"/g, '"$1"') + .replace(/"timeOffset":\s*-?\d+/g, '"timeOffset": [timeOffset]') + .replace(/"timestamp":\s*0/g, '"timestamp": [timestamp]'); if (normalizeNumberAttributes?.length) { // We look for: "attr": "123px", "123", "123%", "123em", "123rem" diff --git a/dev-packages/bundle-analyzer-scenarios/package.json b/dev-packages/bundle-analyzer-scenarios/package.json index e869e1fcf85b..f986cf4208f4 100644 --- a/dev-packages/bundle-analyzer-scenarios/package.json +++ b/dev-packages/bundle-analyzer-scenarios/package.json @@ -12,6 +12,9 @@ "webpack": "^5.95.0", "webpack-bundle-analyzer": "^4.10.2" }, + "devDependencies": { + "eslint-plugin-regexp": "^1.15.0" + }, "scripts": { "analyze": "node webpack.cjs" }, diff --git a/dev-packages/clear-cache-gh-action/.eslintrc.cjs b/dev-packages/clear-cache-gh-action/.eslintrc.cjs index dfc1b926f803..9472d27555a3 100644 --- a/dev-packages/clear-cache-gh-action/.eslintrc.cjs +++ b/dev-packages/clear-cache-gh-action/.eslintrc.cjs @@ -1,5 +1,7 @@ module.exports = { - extends: ['../../.eslintrc.js'], + // todo: remove regexp plugin from here once we add it to base.js eslint config for the whole project + extends: ['../../.eslintrc.js', 'plugin:regexp/recommended'], + plugins: ['regexp'], parserOptions: { sourceType: 'module', ecmaVersion: 'latest', diff --git a/dev-packages/clear-cache-gh-action/package.json b/dev-packages/clear-cache-gh-action/package.json index 5dbba5b9f66c..28666e974eca 100644 --- a/dev-packages/clear-cache-gh-action/package.json +++ b/dev-packages/clear-cache-gh-action/package.json @@ -17,6 +17,9 @@ "@actions/core": "1.10.1", "@actions/github": "^5.0.0" }, + "devDependencies": { + "eslint-plugin-regexp": "^1.15.0" + }, "volta": { "extends": "../../package.json" } diff --git a/dev-packages/cloudflare-integration-tests/.eslintrc.js b/dev-packages/cloudflare-integration-tests/.eslintrc.js index 899a60f9a2bd..5ce331e4074a 100644 --- a/dev-packages/cloudflare-integration-tests/.eslintrc.js +++ b/dev-packages/cloudflare-integration-tests/.eslintrc.js @@ -2,7 +2,9 @@ module.exports = { env: { node: true, }, - extends: ['../../.eslintrc.js'], + // todo: remove regexp plugin from here once we add it to base.js eslint config for the whole project + extends: ['../../.eslintrc.js', 'plugin:regexp/recommended'], + plugins: ['regexp'], overrides: [ { files: ['*.ts'], diff --git a/dev-packages/cloudflare-integration-tests/expect.ts b/dev-packages/cloudflare-integration-tests/expect.ts index 6050ff6816c4..5caec668cd13 100644 --- a/dev-packages/cloudflare-integration-tests/expect.ts +++ b/dev-packages/cloudflare-integration-tests/expect.ts @@ -2,11 +2,11 @@ import type { Contexts, Envelope, Event, SdkInfo } from '@sentry/core'; import { SDK_VERSION } from '@sentry/core'; import { expect } from 'vitest'; -export const UUID_MATCHER = expect.stringMatching(/^[0-9a-f]{32}$/); +export const UUID_MATCHER = expect.stringMatching(/^[\da-f]{32}$/); export const UUID_V4_MATCHER = expect.stringMatching( - /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/, + /^[\da-f]{8}-[\da-f]{4}-4[\da-f]{3}-[89ab][\da-f]{3}-[\da-f]{12}$/, ); -export const SHORT_UUID_MATCHER = expect.stringMatching(/^[0-9a-f]{16}$/); +export const SHORT_UUID_MATCHER = expect.stringMatching(/^[\da-f]{16}$/); export const ISO_DATE_MATCHER = expect.stringMatching(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/); function dropUndefinedKeys>(obj: T): T { diff --git a/dev-packages/cloudflare-integration-tests/package.json b/dev-packages/cloudflare-integration-tests/package.json index b3e8fad26a6a..97bf49dfce5e 100644 --- a/dev-packages/cloudflare-integration-tests/package.json +++ b/dev-packages/cloudflare-integration-tests/package.json @@ -18,6 +18,7 @@ "devDependencies": { "@cloudflare/workers-types": "^4.20250922.0", "@sentry-internal/test-utils": "10.23.0", + "eslint-plugin-regexp": "^1.15.0", "vitest": "^3.2.4", "wrangler": "4.22.0" }, diff --git a/dev-packages/e2e-tests/.eslintrc.js b/dev-packages/e2e-tests/.eslintrc.js index 5ba76262baaf..9c0a56bca5f4 100644 --- a/dev-packages/e2e-tests/.eslintrc.js +++ b/dev-packages/e2e-tests/.eslintrc.js @@ -2,7 +2,9 @@ module.exports = { env: { node: true, }, - extends: ['../../.eslintrc.js'], + // todo: remove regexp plugin from here once we add it to base.js eslint config for the whole project + extends: ['../../.eslintrc.js', 'plugin:regexp/recommended'], + plugins: ['regexp'], ignorePatterns: ['test-applications/**', 'tmp/**'], parserOptions: { sourceType: 'module', diff --git a/dev-packages/e2e-tests/package.json b/dev-packages/e2e-tests/package.json index eab86ffb8ff5..169508d15e55 100644 --- a/dev-packages/e2e-tests/package.json +++ b/dev-packages/e2e-tests/package.json @@ -25,6 +25,7 @@ "@types/node": "^18.19.1", "dotenv": "16.0.3", "esbuild": "0.20.0", + "eslint-plugin-regexp": "^1.15.0", "glob": "8.0.3", "rimraf": "^5.0.10", "ts-node": "10.9.1", diff --git a/dev-packages/e2e-tests/test-applications/aws-serverless/package.json b/dev-packages/e2e-tests/test-applications/aws-serverless/package.json index bf8085c4e892..d24bc1b78805 100644 --- a/dev-packages/e2e-tests/test-applications/aws-serverless/package.json +++ b/dev-packages/e2e-tests/test-applications/aws-serverless/package.json @@ -19,6 +19,7 @@ "aws-cdk-lib": "^2.210.0", "constructs": "^10.4.2", "glob": "^11.0.3", + "rimraf": "^5.0.10", "tmp": "^0.2.5" }, "volta": { diff --git a/dev-packages/external-contributor-gh-action/.eslintrc.cjs b/dev-packages/external-contributor-gh-action/.eslintrc.cjs index dfc1b926f803..9472d27555a3 100644 --- a/dev-packages/external-contributor-gh-action/.eslintrc.cjs +++ b/dev-packages/external-contributor-gh-action/.eslintrc.cjs @@ -1,5 +1,7 @@ module.exports = { - extends: ['../../.eslintrc.js'], + // todo: remove regexp plugin from here once we add it to base.js eslint config for the whole project + extends: ['../../.eslintrc.js', 'plugin:regexp/recommended'], + plugins: ['regexp'], parserOptions: { sourceType: 'module', ecmaVersion: 'latest', diff --git a/dev-packages/external-contributor-gh-action/index.mjs b/dev-packages/external-contributor-gh-action/index.mjs index 2bad8a16f0bd..ef2e14ad32b6 100644 --- a/dev-packages/external-contributor-gh-action/index.mjs +++ b/dev-packages/external-contributor-gh-action/index.mjs @@ -35,7 +35,7 @@ async function run() { // If the contributor message already exists, add the new contributor to the list if (existing) { - const users = existing[1].split(/(?:,? and )|(?:, )/); + const users = existing[1].split(/,? and |, /); if (!users.includes(ghUserName)) { users.push(ghUserName); } diff --git a/dev-packages/external-contributor-gh-action/package.json b/dev-packages/external-contributor-gh-action/package.json index 04b10a3980c6..3640bb7c29d2 100644 --- a/dev-packages/external-contributor-gh-action/package.json +++ b/dev-packages/external-contributor-gh-action/package.json @@ -16,6 +16,9 @@ "dependencies": { "@actions/core": "1.10.1" }, + "devDependencies": { + "eslint-plugin-regexp": "^1.15.0" + }, "volta": { "extends": "../../package.json" } diff --git a/dev-packages/node-core-integration-tests/.eslintrc.js b/dev-packages/node-core-integration-tests/.eslintrc.js index 0598ba3f5ca1..e307575fe52e 100644 --- a/dev-packages/node-core-integration-tests/.eslintrc.js +++ b/dev-packages/node-core-integration-tests/.eslintrc.js @@ -2,7 +2,9 @@ module.exports = { env: { node: true, }, - extends: ['../../.eslintrc.js'], + // todo: remove regexp plugin from here once we add it to base.js eslint config for the whole project + extends: ['../../.eslintrc.js', 'plugin:regexp/recommended'], + plugins: ['regexp'], overrides: [ { files: ['utils/**/*.ts', 'src/**/*.ts'], diff --git a/dev-packages/node-core-integration-tests/package.json b/dev-packages/node-core-integration-tests/package.json index 8c982e61663c..3b27b2ffd3d7 100644 --- a/dev-packages/node-core-integration-tests/package.json +++ b/dev-packages/node-core-integration-tests/package.json @@ -53,6 +53,7 @@ "devDependencies": { "@types/node-cron": "^3.0.11", "@types/node-schedule": "^2.1.7", + "eslint-plugin-regexp": "^1.15.0", "globby": "11" }, "config": { diff --git a/dev-packages/node-core-integration-tests/suites/anr/test.ts b/dev-packages/node-core-integration-tests/suites/anr/test.ts index 08b6a6571e17..c9a81ccb5db0 100644 --- a/dev-packages/node-core-integration-tests/suites/anr/test.ts +++ b/dev-packages/node-core-integration-tests/suites/anr/test.ts @@ -6,8 +6,8 @@ const ANR_EVENT = { // Ensure we have context contexts: { trace: { - span_id: expect.stringMatching(/[a-f0-9]{16}/), - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), }, device: { arch: expect.any(String), diff --git a/dev-packages/node-core-integration-tests/suites/cron/cron/test.ts b/dev-packages/node-core-integration-tests/suites/cron/cron/test.ts index c7d0ca5239fc..60edd2812b4b 100644 --- a/dev-packages/node-core-integration-tests/suites/cron/cron/test.ts +++ b/dev-packages/node-core-integration-tests/suites/cron/cron/test.ts @@ -16,8 +16,8 @@ test('cron instrumentation', async () => { monitor_config: { schedule: { type: 'crontab', value: '* * * * * *' } }, contexts: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), }, }, }, @@ -31,8 +31,8 @@ test('cron instrumentation', async () => { duration: expect.any(Number), contexts: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), }, }, }, @@ -46,8 +46,8 @@ test('cron instrumentation', async () => { monitor_config: { schedule: { type: 'crontab', value: '* * * * * *' } }, contexts: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), }, }, }, @@ -61,8 +61,8 @@ test('cron instrumentation', async () => { duration: expect.any(Number), contexts: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), }, }, }, diff --git a/dev-packages/node-core-integration-tests/suites/cron/node-cron/test.ts b/dev-packages/node-core-integration-tests/suites/cron/node-cron/test.ts index fb3e7bacbf45..dcdb1ba4c4d9 100644 --- a/dev-packages/node-core-integration-tests/suites/cron/node-cron/test.ts +++ b/dev-packages/node-core-integration-tests/suites/cron/node-cron/test.ts @@ -16,8 +16,8 @@ test('node-cron instrumentation', async () => { monitor_config: { schedule: { type: 'crontab', value: '* * * * * *' } }, contexts: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), }, }, }, @@ -31,8 +31,8 @@ test('node-cron instrumentation', async () => { duration: expect.any(Number), contexts: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), }, }, }, @@ -46,8 +46,8 @@ test('node-cron instrumentation', async () => { monitor_config: { schedule: { type: 'crontab', value: '* * * * * *' } }, contexts: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), }, }, }, @@ -61,8 +61,8 @@ test('node-cron instrumentation', async () => { duration: expect.any(Number), contexts: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), }, }, }, diff --git a/dev-packages/node-core-integration-tests/suites/cron/node-schedule/test.ts b/dev-packages/node-core-integration-tests/suites/cron/node-schedule/test.ts index 285e41cee304..220f388d65d0 100644 --- a/dev-packages/node-core-integration-tests/suites/cron/node-schedule/test.ts +++ b/dev-packages/node-core-integration-tests/suites/cron/node-schedule/test.ts @@ -16,8 +16,8 @@ test('node-schedule instrumentation', async () => { monitor_config: { schedule: { type: 'crontab', value: '* * * * * *' } }, contexts: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), }, }, }, @@ -31,8 +31,8 @@ test('node-schedule instrumentation', async () => { duration: expect.any(Number), contexts: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), }, }, }, @@ -46,8 +46,8 @@ test('node-schedule instrumentation', async () => { monitor_config: { schedule: { type: 'crontab', value: '* * * * * *' } }, contexts: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), }, }, }, @@ -61,8 +61,8 @@ test('node-schedule instrumentation', async () => { duration: expect.any(Number), contexts: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), }, }, }, diff --git a/dev-packages/node-core-integration-tests/suites/tracing/dsc-txn-name-update/test.ts b/dev-packages/node-core-integration-tests/suites/tracing/dsc-txn-name-update/test.ts index 9fe401badaa7..b9b2327497f5 100644 --- a/dev-packages/node-core-integration-tests/suites/tracing/dsc-txn-name-update/test.ts +++ b/dev-packages/node-core-integration-tests/suites/tracing/dsc-txn-name-update/test.ts @@ -16,13 +16,13 @@ conditionalTest({ min: 22 })('node >=22', () => { const baggageItems = getBaggageHeaderItems(headers); traceId = baggageItems.find(item => item.startsWith('sentry-trace_id='))?.split('=')[1] as string; - expect(traceId).toMatch(/^[0-9a-f]{32}$/); + expect(traceId).toMatch(/^[\da-f]{32}$/); expect(baggageItems).toEqual([ 'sentry-environment=production', 'sentry-public_key=public', 'sentry-release=1.0', - expect.stringMatching(/sentry-sample_rand=0\.[0-9]+/), + expect.stringMatching(/sentry-sample_rand=0\.\d+/), 'sentry-sample_rate=1', 'sentry-sampled=true', `sentry-trace_id=${traceId}`, @@ -33,7 +33,7 @@ conditionalTest({ min: 22 })('node >=22', () => { 'sentry-environment=production', 'sentry-public_key=public', 'sentry-release=1.0', - expect.stringMatching(/sentry-sample_rand=0\.[0-9]+/), + expect.stringMatching(/sentry-sample_rand=0\.\d+/), 'sentry-sample_rate=1', 'sentry-sampled=true', `sentry-trace_id=${traceId}`, @@ -45,7 +45,7 @@ conditionalTest({ min: 22 })('node >=22', () => { 'sentry-environment=production', 'sentry-public_key=public', 'sentry-release=1.0', - expect.stringMatching(/sentry-sample_rand=0\.[0-9]+/), + expect.stringMatching(/sentry-sample_rand=0\.\d+/), 'sentry-sample_rate=1', 'sentry-sampled=true', `sentry-trace_id=${traceId}`, @@ -77,7 +77,7 @@ test('adds current transaction name to trace envelope header when the txn name i release: '1.0', sample_rate: '1', sampled: 'true', - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), sample_rand: expect.any(String), }, }, @@ -90,7 +90,7 @@ test('adds current transaction name to trace envelope header when the txn name i release: '1.0', sample_rate: '1', sampled: 'true', - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), transaction: 'updated-name-1', sample_rand: expect.any(String), }, @@ -104,7 +104,7 @@ test('adds current transaction name to trace envelope header when the txn name i release: '1.0', sample_rate: '1', sampled: 'true', - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), transaction: 'updated-name-2', sample_rand: expect.any(String), }, @@ -118,7 +118,7 @@ test('adds current transaction name to trace envelope header when the txn name i release: '1.0', sample_rate: '1', sampled: 'true', - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), transaction: 'updated-name-2', sample_rand: expect.any(String), }, diff --git a/dev-packages/node-core-integration-tests/suites/tracing/envelope-header/error-active-span-unsampled/test.ts b/dev-packages/node-core-integration-tests/suites/tracing/envelope-header/error-active-span-unsampled/test.ts index bba04c788282..9fe5f34ef8e5 100644 --- a/dev-packages/node-core-integration-tests/suites/tracing/envelope-header/error-active-span-unsampled/test.ts +++ b/dev-packages/node-core-integration-tests/suites/tracing/envelope-header/error-active-span-unsampled/test.ts @@ -7,7 +7,7 @@ test('envelope header for error event during active unsampled span is correct', .expectHeader({ event: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), public_key: 'public', environment: 'production', release: '1.0', diff --git a/dev-packages/node-core-integration-tests/suites/tracing/envelope-header/error-active-span/test.ts b/dev-packages/node-core-integration-tests/suites/tracing/envelope-header/error-active-span/test.ts index f11defc490c8..4b103c7e7d79 100644 --- a/dev-packages/node-core-integration-tests/suites/tracing/envelope-header/error-active-span/test.ts +++ b/dev-packages/node-core-integration-tests/suites/tracing/envelope-header/error-active-span/test.ts @@ -7,7 +7,7 @@ test('envelope header for error event during active span is correct', async () = .expectHeader({ event: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), public_key: 'public', environment: 'production', release: '1.0', diff --git a/dev-packages/node-core-integration-tests/suites/tracing/envelope-header/error/test.ts b/dev-packages/node-core-integration-tests/suites/tracing/envelope-header/error/test.ts index 9d39209d456f..29a487949adb 100644 --- a/dev-packages/node-core-integration-tests/suites/tracing/envelope-header/error/test.ts +++ b/dev-packages/node-core-integration-tests/suites/tracing/envelope-header/error/test.ts @@ -6,7 +6,7 @@ test('envelope header for error events is correct', async () => { .expectHeader({ event: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), environment: 'production', public_key: 'public', release: '1.0', diff --git a/dev-packages/node-core-integration-tests/suites/tracing/envelope-header/transaction-route/test.ts b/dev-packages/node-core-integration-tests/suites/tracing/envelope-header/transaction-route/test.ts index f4bb6e2b4293..9798194b0c1c 100644 --- a/dev-packages/node-core-integration-tests/suites/tracing/envelope-header/transaction-route/test.ts +++ b/dev-packages/node-core-integration-tests/suites/tracing/envelope-header/transaction-route/test.ts @@ -6,7 +6,7 @@ test('envelope header for transaction event of route correct', async () => { .expectHeader({ transaction: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), public_key: 'public', transaction: 'GET /route', environment: 'production', diff --git a/dev-packages/node-core-integration-tests/suites/tracing/envelope-header/transaction-url/test.ts b/dev-packages/node-core-integration-tests/suites/tracing/envelope-header/transaction-url/test.ts index c4ed5ae4983f..7b6b07191c44 100644 --- a/dev-packages/node-core-integration-tests/suites/tracing/envelope-header/transaction-url/test.ts +++ b/dev-packages/node-core-integration-tests/suites/tracing/envelope-header/transaction-url/test.ts @@ -6,7 +6,7 @@ test('envelope header for transaction event with source=url correct', async () = .expectHeader({ transaction: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), public_key: 'public', environment: 'production', release: '1.0', diff --git a/dev-packages/node-core-integration-tests/suites/tracing/envelope-header/transaction/test.ts b/dev-packages/node-core-integration-tests/suites/tracing/envelope-header/transaction/test.ts index 104761d52c86..24276f57f212 100644 --- a/dev-packages/node-core-integration-tests/suites/tracing/envelope-header/transaction/test.ts +++ b/dev-packages/node-core-integration-tests/suites/tracing/envelope-header/transaction/test.ts @@ -6,7 +6,7 @@ test('envelope header for transaction event is correct', async () => { .expectHeader({ transaction: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), public_key: 'public', environment: 'production', release: '1.0', diff --git a/dev-packages/node-core-integration-tests/suites/tracing/meta-tags-twp-errors/test.ts b/dev-packages/node-core-integration-tests/suites/tracing/meta-tags-twp-errors/test.ts index 7c6612a0f4f7..d58f35b02972 100644 --- a/dev-packages/node-core-integration-tests/suites/tracing/meta-tags-twp-errors/test.ts +++ b/dev-packages/node-core-integration-tests/suites/tracing/meta-tags-twp-errors/test.ts @@ -13,8 +13,8 @@ describe('errors in TwP mode have same trace in trace context and getTraceData() event: event => { const { contexts } = event; const { trace_id, span_id } = contexts?.trace || {}; - expect(trace_id).toMatch(/^[a-f0-9]{32}$/); - expect(span_id).toMatch(/^[a-f0-9]{16}$/); + expect(trace_id).toMatch(/^[a-f\d]{32}$/); + expect(span_id).toMatch(/^[a-f\d]{16}$/); const traceData = contexts?.traceData || {}; @@ -40,12 +40,12 @@ describe('errors in TwP mode have same trace in trace context and getTraceData() event: event => { const { contexts } = event; const { trace_id, span_id } = contexts?.trace || {}; - expect(trace_id).toMatch(/^[a-f0-9]{32}$/); - expect(span_id).toMatch(/^[a-f0-9]{16}$/); + expect(trace_id).toMatch(/^[a-f\d]{32}$/); + expect(span_id).toMatch(/^[a-f\d]{16}$/); const traceData = contexts?.traceData || {}; - expect(traceData['sentry-trace']).toMatch(/^[a-f0-9]{32}-[a-f0-9]{16}$/); + expect(traceData['sentry-trace']).toMatch(/^[a-f\d]{32}-[a-f\d]{16}$/); expect(traceData['sentry-trace']).toContain(`${trace_id}-`); // span_id is a random span ID expect(traceData['sentry-trace']).not.toContain(span_id); @@ -53,7 +53,7 @@ describe('errors in TwP mode have same trace in trace context and getTraceData() expect(traceData.baggage).toContain(`sentry-trace_id=${trace_id}`); expect(traceData.baggage).not.toContain('sentry-sampled='); - expect(traceData.metaTags).toMatch(//); + expect(traceData.metaTags).toMatch(//); expect(traceData.metaTags).toContain(`/); + expect(html).toMatch(//); expect(html).toContain(''); }); @@ -32,7 +32,7 @@ describe('getTraceMetaTags', () => { const html = response?.response; - const traceId = html?.match(//)?.[1]; + const traceId = html?.match(//)?.[1]; expect(traceId).not.toBeUndefined(); expect(html).toContain(' { const [SERVER_URL, closeTestServer] = await createTestServer() .get('/api/v0', headers => { - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); expect(headers['baggage']).toEqual(expect.any(String)); }) .get('/api/v1', headers => { - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); expect(headers['baggage']).toEqual(expect.any(String)); }) diff --git a/dev-packages/node-core-integration-tests/suites/tracing/requests/fetch-no-tracing/test.ts b/dev-packages/node-core-integration-tests/suites/tracing/requests/fetch-no-tracing/test.ts index b4594c4d9c41..046763a0b55a 100644 --- a/dev-packages/node-core-integration-tests/suites/tracing/requests/fetch-no-tracing/test.ts +++ b/dev-packages/node-core-integration-tests/suites/tracing/requests/fetch-no-tracing/test.ts @@ -9,12 +9,12 @@ describe('outgoing fetch', () => { const [SERVER_URL, closeTestServer] = await createTestServer() .get('/api/v0', headers => { - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); expect(headers['baggage']).toEqual(expect.any(String)); }) .get('/api/v1', headers => { - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); expect(headers['baggage']).toEqual(expect.any(String)); }) diff --git a/dev-packages/node-core-integration-tests/suites/tracing/requests/fetch-sampled-no-active-span/test.ts b/dev-packages/node-core-integration-tests/suites/tracing/requests/fetch-sampled-no-active-span/test.ts index 32f24517b3f6..acc1d6c89a25 100644 --- a/dev-packages/node-core-integration-tests/suites/tracing/requests/fetch-sampled-no-active-span/test.ts +++ b/dev-packages/node-core-integration-tests/suites/tracing/requests/fetch-sampled-no-active-span/test.ts @@ -10,12 +10,12 @@ describe('outgoing fetch', () => { const [SERVER_URL, closeTestServer] = await createTestServer() .get('/api/v0', headers => { expect(headers['baggage']).toEqual(expect.any(String)); - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); }) .get('/api/v1', headers => { expect(headers['baggage']).toEqual(expect.any(String)); - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); }) .get('/api/v2', headers => { diff --git a/dev-packages/node-core-integration-tests/suites/tracing/requests/fetch-unsampled/test.ts b/dev-packages/node-core-integration-tests/suites/tracing/requests/fetch-unsampled/test.ts index 097236ba4e7f..4507a360006c 100644 --- a/dev-packages/node-core-integration-tests/suites/tracing/requests/fetch-unsampled/test.ts +++ b/dev-packages/node-core-integration-tests/suites/tracing/requests/fetch-unsampled/test.ts @@ -10,12 +10,12 @@ describe('outgoing fetch', () => { const [SERVER_URL, closeTestServer] = await createTestServer() .get('/api/v0', headers => { expect(headers['baggage']).toEqual(expect.any(String)); - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-0$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-0$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000-0'); }) .get('/api/v1', headers => { expect(headers['baggage']).toEqual(expect.any(String)); - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-0$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-0$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000-0'); }) .get('/api/v2', headers => { diff --git a/dev-packages/node-core-integration-tests/suites/tracing/requests/http-no-tracing-no-spans/test.ts b/dev-packages/node-core-integration-tests/suites/tracing/requests/http-no-tracing-no-spans/test.ts index fe9cba032344..1cad4abf9a99 100644 --- a/dev-packages/node-core-integration-tests/suites/tracing/requests/http-no-tracing-no-spans/test.ts +++ b/dev-packages/node-core-integration-tests/suites/tracing/requests/http-no-tracing-no-spans/test.ts @@ -11,12 +11,12 @@ describe('outgoing http requests with tracing & spans disabled', () => { const [SERVER_URL, closeTestServer] = await createTestServer() .get('/api/v0', headers => { - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); expect(headers['baggage']).toEqual(expect.any(String)); }) .get('/api/v1', headers => { - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); expect(headers['baggage']).toEqual(expect.any(String)); }) diff --git a/dev-packages/node-core-integration-tests/suites/tracing/requests/http-no-tracing/test.ts b/dev-packages/node-core-integration-tests/suites/tracing/requests/http-no-tracing/test.ts index 8727f1cad0de..55882d18830a 100644 --- a/dev-packages/node-core-integration-tests/suites/tracing/requests/http-no-tracing/test.ts +++ b/dev-packages/node-core-integration-tests/suites/tracing/requests/http-no-tracing/test.ts @@ -11,12 +11,12 @@ describe('outgoing http', () => { const [SERVER_URL, closeTestServer] = await createTestServer() .get('/api/v0', headers => { - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); expect(headers['baggage']).toEqual(expect.any(String)); }) .get('/api/v1', headers => { - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); expect(headers['baggage']).toEqual(expect.any(String)); }) diff --git a/dev-packages/node-core-integration-tests/suites/tracing/requests/http-sampled-no-active-span/test.ts b/dev-packages/node-core-integration-tests/suites/tracing/requests/http-sampled-no-active-span/test.ts index d89992dd362e..8cf07571fe24 100644 --- a/dev-packages/node-core-integration-tests/suites/tracing/requests/http-sampled-no-active-span/test.ts +++ b/dev-packages/node-core-integration-tests/suites/tracing/requests/http-sampled-no-active-span/test.ts @@ -12,12 +12,12 @@ describe('outgoing http', () => { const [SERVER_URL, closeTestServer] = await createTestServer() .get('/api/v0', headers => { expect(headers['baggage']).toEqual(expect.any(String)); - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); }) .get('/api/v1', headers => { expect(headers['baggage']).toEqual(expect.any(String)); - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); }) .get('/api/v2', headers => { diff --git a/dev-packages/node-core-integration-tests/suites/tracing/requests/http-sampled/test.ts b/dev-packages/node-core-integration-tests/suites/tracing/requests/http-sampled/test.ts index 1189afc502e5..a1ac7ca292e4 100644 --- a/dev-packages/node-core-integration-tests/suites/tracing/requests/http-sampled/test.ts +++ b/dev-packages/node-core-integration-tests/suites/tracing/requests/http-sampled/test.ts @@ -12,12 +12,12 @@ describe('outgoing http', () => { const [SERVER_URL, closeTestServer] = await createTestServer() .get('/api/v0', headers => { expect(headers['baggage']).toEqual(expect.any(String)); - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-1$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000-1'); }) .get('/api/v1', headers => { expect(headers['baggage']).toEqual(expect.any(String)); - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-1$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000-1'); }) .get('/api/v2', headers => { diff --git a/dev-packages/node-core-integration-tests/suites/tracing/requests/http-unsampled/test.ts b/dev-packages/node-core-integration-tests/suites/tracing/requests/http-unsampled/test.ts index 60d3345dcb51..63ae25f32a0c 100644 --- a/dev-packages/node-core-integration-tests/suites/tracing/requests/http-unsampled/test.ts +++ b/dev-packages/node-core-integration-tests/suites/tracing/requests/http-unsampled/test.ts @@ -12,12 +12,12 @@ describe('outgoing http', () => { const [SERVER_URL, closeTestServer] = await createTestServer() .get('/api/v0', headers => { expect(headers['baggage']).toEqual(expect.any(String)); - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-0$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-0$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000-0'); }) .get('/api/v1', headers => { expect(headers['baggage']).toEqual(expect.any(String)); - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-0$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-0$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000-0'); }) .get('/api/v2', headers => { diff --git a/dev-packages/node-core-integration-tests/suites/tracing/sample-rand-propagation/test.ts b/dev-packages/node-core-integration-tests/suites/tracing/sample-rand-propagation/test.ts index 40001a9f62f5..6bb8f3dfc3f6 100644 --- a/dev-packages/node-core-integration-tests/suites/tracing/sample-rand-propagation/test.ts +++ b/dev-packages/node-core-integration-tests/suites/tracing/sample-rand-propagation/test.ts @@ -30,7 +30,7 @@ describe('sample_rand propagation', () => { }); expect(response).toEqual({ propagatedData: { - baggage: expect.not.stringMatching(/sentry-sample_rand=0\.[0-9]+/), + baggage: expect.not.stringMatching(/sentry-sample_rand=0\.\d+/), }, }); }); @@ -44,7 +44,7 @@ describe('sample_rand propagation', () => { }, }); - const sampleRand = Number((response as any).propagatedData.baggage.match(/sentry-sample_rand=(0\.[0-9]+)/)[1]); + const sampleRand = Number((response as any).propagatedData.baggage.match(/sentry-sample_rand=(0\.\d+)/)[1]); expect(sampleRand).toStrictEqual(expect.any(Number)); expect(sampleRand).not.toBeNaN(); @@ -61,7 +61,7 @@ describe('sample_rand propagation', () => { }, }); - const sampleRand = Number((response as any).propagatedData.baggage.match(/sentry-sample_rand=(0\.[0-9]+)/)[1]); + const sampleRand = Number((response as any).propagatedData.baggage.match(/sentry-sample_rand=(0\.\d+)/)[1]); expect(sampleRand).toStrictEqual(expect.any(Number)); expect(sampleRand).not.toBeNaN(); @@ -77,6 +77,6 @@ describe('sample_rand propagation', () => { }, }); - expect((response as any).propagatedData.baggage).not.toMatch(/sentry-sample_rand=0\.[0-9]+/); + expect((response as any).propagatedData.baggage).not.toMatch(/sentry-sample_rand=0\.\d+/); }); }); diff --git a/dev-packages/node-core-integration-tests/suites/tracing/tracePropagationTargets/test.ts b/dev-packages/node-core-integration-tests/suites/tracing/tracePropagationTargets/test.ts index 8ae06f883b38..a136eb770a8d 100644 --- a/dev-packages/node-core-integration-tests/suites/tracing/tracePropagationTargets/test.ts +++ b/dev-packages/node-core-integration-tests/suites/tracing/tracePropagationTargets/test.ts @@ -12,12 +12,12 @@ conditionalTest({ min: 22 })('node >=22', () => { const [SERVER_URL, closeTestServer] = await createTestServer() .get('/api/v0', headers => { expect(headers['baggage']).toEqual(expect.any(String)); - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-1$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000-1'); }) .get('/api/v1', headers => { expect(headers['baggage']).toEqual(expect.any(String)); - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-1$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000-1'); }) .get('/api/v2', headers => { diff --git a/dev-packages/node-core-integration-tests/utils/runner.ts b/dev-packages/node-core-integration-tests/utils/runner.ts index 22a600efa63b..416d55d803a1 100644 --- a/dev-packages/node-core-integration-tests/utils/runner.ts +++ b/dev-packages/node-core-integration-tests/utils/runner.ts @@ -489,7 +489,7 @@ export function createRunner(...paths: string[]) { function tryParseEnvelopeFromStdoutLine(line: string): void { // Lines can have leading '[something] [{' which we need to remove - const cleanedLine = line.replace(/^.*?] \[{"/, '[{"'); + const cleanedLine = line.replace(/^.*?\] \[\{"/, '[{"'); // See if we have a port message if (cleanedLine.startsWith('{"port":')) { @@ -676,6 +676,7 @@ function convertEsmToCjs(content: string): string { // Handle default imports: import x from 'y' -> const x = require('y') newContent = newContent.replace( + // eslint-disable-next-line regexp/no-super-linear-backtracking, regexp/optimal-quantifier-concatenation /import\s+([\w*{}\s,]+)\s+from\s+['"]([^'"]+)['"]/g, (_, imports: string, module: string) => { if (imports.includes('* as')) { diff --git a/dev-packages/node-integration-tests/.eslintrc.js b/dev-packages/node-integration-tests/.eslintrc.js index 0598ba3f5ca1..e307575fe52e 100644 --- a/dev-packages/node-integration-tests/.eslintrc.js +++ b/dev-packages/node-integration-tests/.eslintrc.js @@ -2,7 +2,9 @@ module.exports = { env: { node: true, }, - extends: ['../../.eslintrc.js'], + // todo: remove regexp plugin from here once we add it to base.js eslint config for the whole project + extends: ['../../.eslintrc.js', 'plugin:regexp/recommended'], + plugins: ['regexp'], overrides: [ { files: ['utils/**/*.ts', 'src/**/*.ts'], diff --git a/dev-packages/node-integration-tests/package.json b/dev-packages/node-integration-tests/package.json index 4ed3a7a25e79..62c3a63793c2 100644 --- a/dev-packages/node-integration-tests/package.json +++ b/dev-packages/node-integration-tests/package.json @@ -86,6 +86,7 @@ "@types/amqplib": "^0.10.5", "@types/node-cron": "^3.0.11", "@types/node-schedule": "^2.1.7", + "eslint-plugin-regexp": "^1.15.0", "file-type": "^20.4.1", "globby": "11", "react": "^18.3.1", diff --git a/dev-packages/node-integration-tests/suites/anr/test.ts b/dev-packages/node-integration-tests/suites/anr/test.ts index 08b6a6571e17..c9a81ccb5db0 100644 --- a/dev-packages/node-integration-tests/suites/anr/test.ts +++ b/dev-packages/node-integration-tests/suites/anr/test.ts @@ -6,8 +6,8 @@ const ANR_EVENT = { // Ensure we have context contexts: { trace: { - span_id: expect.stringMatching(/[a-f0-9]{16}/), - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), }, device: { arch: expect.any(String), diff --git a/dev-packages/node-integration-tests/suites/cron/cron/test.ts b/dev-packages/node-integration-tests/suites/cron/cron/test.ts index 8b9fdfd5c593..a9febf9efbe4 100644 --- a/dev-packages/node-integration-tests/suites/cron/cron/test.ts +++ b/dev-packages/node-integration-tests/suites/cron/cron/test.ts @@ -16,8 +16,8 @@ test('cron instrumentation', async () => { monitor_config: { schedule: { type: 'crontab', value: '* * * * * *' } }, contexts: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), }, }, }, @@ -31,8 +31,8 @@ test('cron instrumentation', async () => { duration: expect.any(Number), contexts: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), }, }, }, @@ -46,8 +46,8 @@ test('cron instrumentation', async () => { monitor_config: { schedule: { type: 'crontab', value: '* * * * * *' } }, contexts: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), }, }, }, @@ -61,8 +61,8 @@ test('cron instrumentation', async () => { duration: expect.any(Number), contexts: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), }, }, }, diff --git a/dev-packages/node-integration-tests/suites/cron/node-cron/test.ts b/dev-packages/node-integration-tests/suites/cron/node-cron/test.ts index 1c5fa515e208..a986e3f83d92 100644 --- a/dev-packages/node-integration-tests/suites/cron/node-cron/test.ts +++ b/dev-packages/node-integration-tests/suites/cron/node-cron/test.ts @@ -16,8 +16,8 @@ test('node-cron instrumentation', async () => { monitor_config: { schedule: { type: 'crontab', value: '* * * * * *' } }, contexts: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), }, }, }, @@ -31,8 +31,8 @@ test('node-cron instrumentation', async () => { duration: expect.any(Number), contexts: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), }, }, }, @@ -46,8 +46,8 @@ test('node-cron instrumentation', async () => { monitor_config: { schedule: { type: 'crontab', value: '* * * * * *' } }, contexts: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), }, }, }, @@ -61,8 +61,8 @@ test('node-cron instrumentation', async () => { duration: expect.any(Number), contexts: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), }, }, }, diff --git a/dev-packages/node-integration-tests/suites/cron/node-schedule/test.ts b/dev-packages/node-integration-tests/suites/cron/node-schedule/test.ts index a2019253203f..2b46e04d50a4 100644 --- a/dev-packages/node-integration-tests/suites/cron/node-schedule/test.ts +++ b/dev-packages/node-integration-tests/suites/cron/node-schedule/test.ts @@ -16,8 +16,8 @@ test('node-schedule instrumentation', async () => { monitor_config: { schedule: { type: 'crontab', value: '* * * * * *' } }, contexts: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), }, }, }, @@ -31,8 +31,8 @@ test('node-schedule instrumentation', async () => { duration: expect.any(Number), contexts: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), }, }, }, @@ -46,8 +46,8 @@ test('node-schedule instrumentation', async () => { monitor_config: { schedule: { type: 'crontab', value: '* * * * * *' } }, contexts: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), }, }, }, @@ -61,8 +61,8 @@ test('node-schedule instrumentation', async () => { duration: expect.any(Number), contexts: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), }, }, }, diff --git a/dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-header-assign/test.ts b/dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-header-assign/test.ts index 8b8d648513e4..20f19dccf3ea 100644 --- a/dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-header-assign/test.ts +++ b/dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-header-assign/test.ts @@ -113,8 +113,8 @@ test('Should populate and propagate sentry baggage if sentry-trace header does n 'sentry-release': '1.0', 'sentry-public_key': 'public', // TraceId changes, hence we only expect that the string contains the traceid key - 'sentry-trace_id': expect.stringMatching(/[\S]*/), - 'sentry-sample_rand': expect.stringMatching(/[\S]*/), + 'sentry-trace_id': expect.stringMatching(/\S*/), + 'sentry-sample_rand': expect.stringMatching(/\S*/), 'sentry-sample_rate': '1', 'sentry-sampled': 'true', 'sentry-transaction': 'GET /test/express', @@ -139,8 +139,8 @@ test('Should populate Sentry and ignore 3rd party content if sentry-trace header 'sentry-release': '1.0', 'sentry-public_key': 'public', // TraceId changes, hence we only expect that the string contains the traceid key - 'sentry-trace_id': expect.stringMatching(/[\S]*/), - 'sentry-sample_rand': expect.stringMatching(/[\S]*/), + 'sentry-trace_id': expect.stringMatching(/\S*/), + 'sentry-sample_rand': expect.stringMatching(/\S*/), 'sentry-sample_rate': '1', 'sentry-sampled': 'true', 'sentry-transaction': 'GET /test/express', diff --git a/dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-header-out/test.ts b/dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-header-out/test.ts index 913fcd5e2038..4551baa06e23 100644 --- a/dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-header-out/test.ts +++ b/dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-header-out/test.ts @@ -23,7 +23,7 @@ test('should attach a baggage header to an outgoing request.', async () => { 'sentry-sampled=true', 'sentry-trace_id=__SENTRY_TRACE_ID__', 'sentry-transaction=GET%20%2Ftest%2Fexpress', - expect.stringMatching(/sentry-sample_rand=0\.[0-9]+/), + expect.stringMatching(/sentry-sample_rand=0\.\d+/), ].forEach(item => { expect(baggage).toContainEqual(item); }); diff --git a/dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-other-vendors-with-sentry-entries/test.ts b/dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-other-vendors-with-sentry-entries/test.ts index 2d2074be773c..dbdd69ffb45b 100644 --- a/dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-other-vendors-with-sentry-entries/test.ts +++ b/dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-other-vendors-with-sentry-entries/test.ts @@ -32,7 +32,7 @@ test('should ignore sentry-values in `baggage` header of a third party vendor an 'other=vendor', 'sentry-environment=myEnv', 'sentry-release=2.1.0', - expect.stringMatching(/sentry-sample_rand=[0-9]+/), + expect.stringMatching(/sentry-sample_rand=\d+/), 'sentry-sample_rate=0.54', 'third=party', ]); @@ -60,10 +60,10 @@ test('should ignore sentry-values in `baggage` header of a third party vendor an 'sentry-environment=prod', 'sentry-public_key=public', 'sentry-release=1.0', - expect.stringMatching(/sentry-sample_rand=[0-9]+/), + expect.stringMatching(/sentry-sample_rand=\d+/), 'sentry-sample_rate=1', 'sentry-sampled=true', - expect.stringMatching(/sentry-trace_id=[0-9a-f]{32}/), + expect.stringMatching(/sentry-trace_id=[\da-f]{32}/), 'sentry-transaction=GET%20%2Ftest%2Fexpress', 'third=party', ]); diff --git a/dev-packages/node-integration-tests/suites/express/tracing/scenario.mjs b/dev-packages/node-integration-tests/suites/express/tracing/scenario.mjs index 4e32a052908d..e307319a1fd0 100644 --- a/dev-packages/node-integration-tests/suites/express/tracing/scenario.mjs +++ b/dev-packages/node-integration-tests/suites/express/tracing/scenario.mjs @@ -39,7 +39,7 @@ app.get(['/test/array1', /\/test\/array[2-9]/], (_req, res) => { res.send({ response: 'response 3' }); }); -app.get(['/test/arr/:id', /\/test\/arr[0-9]*\/required(path)?(\/optionalPath)?\/(lastParam)?/], (_req, res) => { +app.get(['/test/arr/:id', /\/test\/arr\d*\/required(path)?(\/optionalPath)?\/(lastParam)?/], (_req, res) => { res.send({ response: 'response 4' }); }); diff --git a/dev-packages/node-integration-tests/suites/express/tracing/test.ts b/dev-packages/node-integration-tests/suites/express/tracing/test.ts index 4476c76a3933..759df300181a 100644 --- a/dev-packages/node-integration-tests/suites/express/tracing/test.ts +++ b/dev-packages/node-integration-tests/suites/express/tracing/test.ts @@ -14,8 +14,8 @@ describe('express tracing', () => { transaction: { contexts: { trace: { - span_id: expect.stringMatching(/[a-f0-9]{16}/), - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), data: { url: expect.stringMatching(/\/test\/express$/), 'http.response.status_code': 200, @@ -61,8 +61,8 @@ describe('express tracing', () => { }, contexts: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), data: { url: expect.stringMatching(/\/test\/regex$/), 'http.response.status_code': 200, @@ -85,8 +85,8 @@ describe('express tracing', () => { transaction: 'GET /', contexts: { trace: { - span_id: expect.stringMatching(/[a-f0-9]{16}/), - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), data: { 'http.response.status_code': 200, url: expect.stringMatching(/\/$/), @@ -132,8 +132,8 @@ describe('express tracing', () => { }, contexts: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), data: { url: expect.stringMatching(`/test/${segment}$`), 'http.response.status_code': 200, @@ -163,14 +163,14 @@ describe('express tracing', () => { const runner = await createRunner() .expect({ transaction: { - transaction: 'GET /test/arr/:id,/\\/test\\/arr[0-9]*\\/required(path)?(\\/optionalPath)?\\/(lastParam)?/', + transaction: 'GET /test/arr/:id,/\\/test\\/arr\\d*\\/required(path)?(\\/optionalPath)?\\/(lastParam)?/', transaction_info: { source: 'route', }, contexts: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), data: { url: expect.stringMatching(`/test/${segment}$`), 'http.response.status_code': 200, @@ -346,8 +346,8 @@ describe('express tracing', () => { transaction: `GET ${url}`, contexts: { trace: { - span_id: expect.stringMatching(/[a-f0-9]{16}/), - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), data: { 'http.response.status_code': status_code, url: expect.stringMatching(url), diff --git a/dev-packages/node-integration-tests/suites/featureFlags/growthbook/onSpan/test.ts b/dev-packages/node-integration-tests/suites/featureFlags/growthbook/onSpan/test.ts index fbb084b98928..3f0011b4f617 100644 --- a/dev-packages/node-integration-tests/suites/featureFlags/growthbook/onSpan/test.ts +++ b/dev-packages/node-integration-tests/suites/featureFlags/growthbook/onSpan/test.ts @@ -20,8 +20,8 @@ test('GrowthBook flags are added to active span attributes on span end', async ( op: 'function', origin: 'manual', status: 'ok', - span_id: expect.stringMatching(/[a-f0-9]{16}/), - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), }, }, spans: [], diff --git a/dev-packages/node-integration-tests/suites/tracing/dsc-txn-name-update/test.ts b/dev-packages/node-integration-tests/suites/tracing/dsc-txn-name-update/test.ts index f450d2150e31..aa74bea7d79e 100644 --- a/dev-packages/node-integration-tests/suites/tracing/dsc-txn-name-update/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/dsc-txn-name-update/test.ts @@ -12,13 +12,13 @@ test('adds current transaction name to baggage when the txn name is high-quality const baggageItems = getBaggageHeaderItems(headers); traceId = baggageItems.find(item => item.startsWith('sentry-trace_id='))?.split('=')[1] as string; - expect(traceId).toMatch(/^[0-9a-f]{32}$/); + expect(traceId).toMatch(/^[\da-f]{32}$/); expect(baggageItems).toEqual([ 'sentry-environment=production', 'sentry-public_key=public', 'sentry-release=1.0', - expect.stringMatching(/sentry-sample_rand=0\.[0-9]+/), + expect.stringMatching(/sentry-sample_rand=0\.\d+/), 'sentry-sample_rate=1', 'sentry-sampled=true', `sentry-trace_id=${traceId}`, @@ -29,7 +29,7 @@ test('adds current transaction name to baggage when the txn name is high-quality 'sentry-environment=production', 'sentry-public_key=public', 'sentry-release=1.0', - expect.stringMatching(/sentry-sample_rand=0\.[0-9]+/), + expect.stringMatching(/sentry-sample_rand=0\.\d+/), 'sentry-sample_rate=1', 'sentry-sampled=true', `sentry-trace_id=${traceId}`, @@ -41,7 +41,7 @@ test('adds current transaction name to baggage when the txn name is high-quality 'sentry-environment=production', 'sentry-public_key=public', 'sentry-release=1.0', - expect.stringMatching(/sentry-sample_rand=0\.[0-9]+/), + expect.stringMatching(/sentry-sample_rand=0\.\d+/), 'sentry-sample_rate=1', 'sentry-sampled=true', `sentry-trace_id=${traceId}`, @@ -72,7 +72,7 @@ test('adds current transaction name to trace envelope header when the txn name i release: '1.0', sample_rate: '1', sampled: 'true', - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), sample_rand: expect.any(String), }, }, @@ -85,7 +85,7 @@ test('adds current transaction name to trace envelope header when the txn name i release: '1.0', sample_rate: '1', sampled: 'true', - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), transaction: 'updated-name-1', sample_rand: expect.any(String), }, @@ -99,7 +99,7 @@ test('adds current transaction name to trace envelope header when the txn name i release: '1.0', sample_rate: '1', sampled: 'true', - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), transaction: 'updated-name-2', sample_rand: expect.any(String), }, @@ -113,7 +113,7 @@ test('adds current transaction name to trace envelope header when the txn name i release: '1.0', sample_rate: '1', sampled: 'true', - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), transaction: 'updated-name-2', sample_rand: expect.any(String), }, diff --git a/dev-packages/node-integration-tests/suites/tracing/envelope-header/error-active-span-unsampled/test.ts b/dev-packages/node-integration-tests/suites/tracing/envelope-header/error-active-span-unsampled/test.ts index bba04c788282..9fe5f34ef8e5 100644 --- a/dev-packages/node-integration-tests/suites/tracing/envelope-header/error-active-span-unsampled/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/envelope-header/error-active-span-unsampled/test.ts @@ -7,7 +7,7 @@ test('envelope header for error event during active unsampled span is correct', .expectHeader({ event: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), public_key: 'public', environment: 'production', release: '1.0', diff --git a/dev-packages/node-integration-tests/suites/tracing/envelope-header/error-active-span/test.ts b/dev-packages/node-integration-tests/suites/tracing/envelope-header/error-active-span/test.ts index f11defc490c8..4b103c7e7d79 100644 --- a/dev-packages/node-integration-tests/suites/tracing/envelope-header/error-active-span/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/envelope-header/error-active-span/test.ts @@ -7,7 +7,7 @@ test('envelope header for error event during active span is correct', async () = .expectHeader({ event: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), public_key: 'public', environment: 'production', release: '1.0', diff --git a/dev-packages/node-integration-tests/suites/tracing/envelope-header/error/test.ts b/dev-packages/node-integration-tests/suites/tracing/envelope-header/error/test.ts index 9d39209d456f..29a487949adb 100644 --- a/dev-packages/node-integration-tests/suites/tracing/envelope-header/error/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/envelope-header/error/test.ts @@ -6,7 +6,7 @@ test('envelope header for error events is correct', async () => { .expectHeader({ event: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), environment: 'production', public_key: 'public', release: '1.0', diff --git a/dev-packages/node-integration-tests/suites/tracing/envelope-header/transaction-route/test.ts b/dev-packages/node-integration-tests/suites/tracing/envelope-header/transaction-route/test.ts index f4bb6e2b4293..9798194b0c1c 100644 --- a/dev-packages/node-integration-tests/suites/tracing/envelope-header/transaction-route/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/envelope-header/transaction-route/test.ts @@ -6,7 +6,7 @@ test('envelope header for transaction event of route correct', async () => { .expectHeader({ transaction: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), public_key: 'public', transaction: 'GET /route', environment: 'production', diff --git a/dev-packages/node-integration-tests/suites/tracing/envelope-header/transaction-url/test.ts b/dev-packages/node-integration-tests/suites/tracing/envelope-header/transaction-url/test.ts index c4ed5ae4983f..7b6b07191c44 100644 --- a/dev-packages/node-integration-tests/suites/tracing/envelope-header/transaction-url/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/envelope-header/transaction-url/test.ts @@ -6,7 +6,7 @@ test('envelope header for transaction event with source=url correct', async () = .expectHeader({ transaction: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), public_key: 'public', environment: 'production', release: '1.0', diff --git a/dev-packages/node-integration-tests/suites/tracing/envelope-header/transaction/test.ts b/dev-packages/node-integration-tests/suites/tracing/envelope-header/transaction/test.ts index 104761d52c86..24276f57f212 100644 --- a/dev-packages/node-integration-tests/suites/tracing/envelope-header/transaction/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/envelope-header/transaction/test.ts @@ -6,7 +6,7 @@ test('envelope header for transaction event is correct', async () => { .expectHeader({ transaction: { trace: { - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), public_key: 'public', environment: 'production', release: '1.0', diff --git a/dev-packages/node-integration-tests/suites/tracing/http-client-spans/fetch-strip-query/test.ts b/dev-packages/node-integration-tests/suites/tracing/http-client-spans/fetch-strip-query/test.ts index 797047080283..580a63a52e90 100644 --- a/dev-packages/node-integration-tests/suites/tracing/http-client-spans/fetch-strip-query/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/http-client-spans/fetch-strip-query/test.ts @@ -44,7 +44,7 @@ test('strips and handles query params in spans of outgoing fetch requests', asyn origin: 'auto.http.otel.node_fetch', status: 'ok', parent_span_id: txn.contexts?.trace?.span_id, - span_id: expect.stringMatching(/[a-f0-9]{16}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), trace_id: txn.contexts?.trace?.trace_id, }); }, diff --git a/dev-packages/node-integration-tests/suites/tracing/http-client-spans/http-strip-query/test.ts b/dev-packages/node-integration-tests/suites/tracing/http-client-spans/http-strip-query/test.ts index ebe2eff07013..edfac9fe2081 100644 --- a/dev-packages/node-integration-tests/suites/tracing/http-client-spans/http-strip-query/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/http-client-spans/http-strip-query/test.ts @@ -44,7 +44,7 @@ test('strips and handles query params in spans of outgoing http requests', async origin: 'auto.http.otel.http', status: 'ok', parent_span_id: txn.contexts?.trace?.span_id, - span_id: expect.stringMatching(/[a-f0-9]{16}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), trace_id: txn.contexts?.trace?.trace_id, }); }, diff --git a/dev-packages/node-integration-tests/suites/tracing/httpIntegration/test.ts b/dev-packages/node-integration-tests/suites/tracing/httpIntegration/test.ts index 48fab1be2e9d..15c354e45533 100644 --- a/dev-packages/node-integration-tests/suites/tracing/httpIntegration/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/httpIntegration/test.ts @@ -27,8 +27,8 @@ describe('httpIntegration', () => { transaction: { contexts: { trace: { - span_id: expect.stringMatching(/[a-f0-9]{16}/), - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), data: { url: expect.stringMatching(/\/test$/), 'http.response.status_code': 200, @@ -69,8 +69,8 @@ describe('httpIntegration', () => { transaction: { contexts: { trace: { - span_id: expect.stringMatching(/[a-f0-9]{16}/), - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), data: { url: expect.stringMatching(/\/test$/), 'http.response.status_code': 200, @@ -198,8 +198,8 @@ describe('httpIntegration', () => { transaction: 'GET /test1', contexts: { trace: { - span_id: expect.stringMatching(/[a-f0-9]{16}/), - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), data: { 'http.response.status_code': 200, 'sentry.op': 'http.server', @@ -214,8 +214,8 @@ describe('httpIntegration', () => { transaction: 'GET /test2', contexts: { trace: { - span_id: expect.stringMatching(/[a-f0-9]{16}/), - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), data: { 'http.response.status_code': 200, 'sentry.op': 'http.server', @@ -230,8 +230,8 @@ describe('httpIntegration', () => { transaction: 'GET /test3', contexts: { trace: { - span_id: expect.stringMatching(/[a-f0-9]{16}/), - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), data: { 'http.response.status_code': 200, 'sentry.op': 'http.server', @@ -256,8 +256,8 @@ describe('httpIntegration', () => { transaction: 'GET /test1-proxy', contexts: { trace: { - span_id: expect.stringMatching(/[a-f0-9]{16}/), - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), data: { 'http.response.status_code': 200, 'sentry.op': 'http.server', @@ -272,8 +272,8 @@ describe('httpIntegration', () => { transaction: 'GET /test2-proxy', contexts: { trace: { - span_id: expect.stringMatching(/[a-f0-9]{16}/), - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), data: { 'http.response.status_code': 200, 'sentry.op': 'http.server', @@ -288,8 +288,8 @@ describe('httpIntegration', () => { transaction: 'GET /test3-proxy', contexts: { trace: { - span_id: expect.stringMatching(/[a-f0-9]{16}/), - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), data: { 'http.response.status_code': 200, 'sentry.op': 'http.server', @@ -313,8 +313,8 @@ describe('httpIntegration', () => { transaction: 'GET /test1-original', contexts: { trace: { - span_id: expect.stringMatching(/[a-f0-9]{16}/), - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), data: { 'http.response.status_code': 200, 'sentry.op': 'http.server', @@ -329,8 +329,8 @@ describe('httpIntegration', () => { transaction: 'GET /test2-original', contexts: { trace: { - span_id: expect.stringMatching(/[a-f0-9]{16}/), - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), data: { 'http.response.status_code': 200, 'sentry.op': 'http.server', @@ -345,8 +345,8 @@ describe('httpIntegration', () => { transaction: 'GET /test3-original', contexts: { trace: { - span_id: expect.stringMatching(/[a-f0-9]{16}/), - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), data: { 'http.response.status_code': 200, 'sentry.op': 'http.server', @@ -371,8 +371,8 @@ describe('httpIntegration', () => { transaction: 'GET /test1-proxy-original', contexts: { trace: { - span_id: expect.stringMatching(/[a-f0-9]{16}/), - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), data: { 'http.response.status_code': 200, 'sentry.op': 'http.server', @@ -387,8 +387,8 @@ describe('httpIntegration', () => { transaction: 'GET /test2-proxy-original', contexts: { trace: { - span_id: expect.stringMatching(/[a-f0-9]{16}/), - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), data: { 'http.response.status_code': 200, 'sentry.op': 'http.server', @@ -403,8 +403,8 @@ describe('httpIntegration', () => { transaction: 'GET /test3-proxy-original', contexts: { trace: { - span_id: expect.stringMatching(/[a-f0-9]{16}/), - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), data: { 'http.response.status_code': 200, 'sentry.op': 'http.server', @@ -433,8 +433,8 @@ describe('httpIntegration', () => { transaction: { contexts: { trace: { - span_id: expect.stringMatching(/[a-f0-9]{16}/), - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), data: { url: expect.stringMatching(/\/test$/), 'http.response.status_code': 200, @@ -459,8 +459,8 @@ describe('httpIntegration', () => { transaction: { contexts: { trace: { - span_id: expect.stringMatching(/[a-f0-9]{16}/), - trace_id: expect.stringMatching(/[a-f0-9]{32}/), + span_id: expect.stringMatching(/[a-f\d]{16}/), + trace_id: expect.stringMatching(/[a-f\d]{32}/), data: { url: expect.stringMatching(/\/test$/), 'http.response.status_code': 200, diff --git a/dev-packages/node-integration-tests/suites/tracing/meta-tags-twp-errors/test.ts b/dev-packages/node-integration-tests/suites/tracing/meta-tags-twp-errors/test.ts index 7c6612a0f4f7..d58f35b02972 100644 --- a/dev-packages/node-integration-tests/suites/tracing/meta-tags-twp-errors/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/meta-tags-twp-errors/test.ts @@ -13,8 +13,8 @@ describe('errors in TwP mode have same trace in trace context and getTraceData() event: event => { const { contexts } = event; const { trace_id, span_id } = contexts?.trace || {}; - expect(trace_id).toMatch(/^[a-f0-9]{32}$/); - expect(span_id).toMatch(/^[a-f0-9]{16}$/); + expect(trace_id).toMatch(/^[a-f\d]{32}$/); + expect(span_id).toMatch(/^[a-f\d]{16}$/); const traceData = contexts?.traceData || {}; @@ -40,12 +40,12 @@ describe('errors in TwP mode have same trace in trace context and getTraceData() event: event => { const { contexts } = event; const { trace_id, span_id } = contexts?.trace || {}; - expect(trace_id).toMatch(/^[a-f0-9]{32}$/); - expect(span_id).toMatch(/^[a-f0-9]{16}$/); + expect(trace_id).toMatch(/^[a-f\d]{32}$/); + expect(span_id).toMatch(/^[a-f\d]{16}$/); const traceData = contexts?.traceData || {}; - expect(traceData['sentry-trace']).toMatch(/^[a-f0-9]{32}-[a-f0-9]{16}$/); + expect(traceData['sentry-trace']).toMatch(/^[a-f\d]{32}-[a-f\d]{16}$/); expect(traceData['sentry-trace']).toContain(`${trace_id}-`); // span_id is a random span ID expect(traceData['sentry-trace']).not.toContain(span_id); @@ -53,7 +53,7 @@ describe('errors in TwP mode have same trace in trace context and getTraceData() expect(traceData.baggage).toContain(`sentry-trace_id=${trace_id}`); expect(traceData.baggage).not.toContain('sentry-sampled='); - expect(traceData.metaTags).toMatch(//); + expect(traceData.metaTags).toMatch(//); expect(traceData.metaTags).toContain(`/) || [ + const [, traceId, spanId] = html.match(//) || [ undefined, undefined, undefined, diff --git a/dev-packages/node-integration-tests/suites/tracing/meta-tags/test.ts b/dev-packages/node-integration-tests/suites/tracing/meta-tags/test.ts index c1b88699d8a0..a8d88fdd7cb4 100644 --- a/dev-packages/node-integration-tests/suites/tracing/meta-tags/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/meta-tags/test.ts @@ -21,7 +21,7 @@ describe('getTraceMetaTags', () => { const html = response?.response; - expect(html).toMatch(//); + expect(html).toMatch(//); expect(html).toContain(''); }); @@ -32,7 +32,7 @@ describe('getTraceMetaTags', () => { const html = response?.response; - const traceId = html?.match(//)?.[1]; + const traceId = html?.match(//)?.[1]; expect(traceId).not.toBeUndefined(); expect(html).toContain(' { const html = response?.response; - const traceId = html?.match(//)?.[1]; + const traceId = html?.match(//)?.[1]; expect(traceId).not.toBeUndefined(); expect(html).toContain(' { const [SERVER_URL, closeTestServer] = await createTestServer() .get('/api/v0', headers => { - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); expect(headers['baggage']).toEqual(expect.any(String)); }) .get('/api/v1', headers => { - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); expect(headers['baggage']).toEqual(expect.any(String)); }) diff --git a/dev-packages/node-integration-tests/suites/tracing/requests/fetch-no-tracing/test.ts b/dev-packages/node-integration-tests/suites/tracing/requests/fetch-no-tracing/test.ts index b4594c4d9c41..046763a0b55a 100644 --- a/dev-packages/node-integration-tests/suites/tracing/requests/fetch-no-tracing/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/requests/fetch-no-tracing/test.ts @@ -9,12 +9,12 @@ describe('outgoing fetch', () => { const [SERVER_URL, closeTestServer] = await createTestServer() .get('/api/v0', headers => { - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); expect(headers['baggage']).toEqual(expect.any(String)); }) .get('/api/v1', headers => { - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); expect(headers['baggage']).toEqual(expect.any(String)); }) diff --git a/dev-packages/node-integration-tests/suites/tracing/requests/fetch-sampled-no-active-span/test.ts b/dev-packages/node-integration-tests/suites/tracing/requests/fetch-sampled-no-active-span/test.ts index 32f24517b3f6..acc1d6c89a25 100644 --- a/dev-packages/node-integration-tests/suites/tracing/requests/fetch-sampled-no-active-span/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/requests/fetch-sampled-no-active-span/test.ts @@ -10,12 +10,12 @@ describe('outgoing fetch', () => { const [SERVER_URL, closeTestServer] = await createTestServer() .get('/api/v0', headers => { expect(headers['baggage']).toEqual(expect.any(String)); - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); }) .get('/api/v1', headers => { expect(headers['baggage']).toEqual(expect.any(String)); - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); }) .get('/api/v2', headers => { diff --git a/dev-packages/node-integration-tests/suites/tracing/requests/fetch-unsampled/test.ts b/dev-packages/node-integration-tests/suites/tracing/requests/fetch-unsampled/test.ts index 097236ba4e7f..4507a360006c 100644 --- a/dev-packages/node-integration-tests/suites/tracing/requests/fetch-unsampled/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/requests/fetch-unsampled/test.ts @@ -10,12 +10,12 @@ describe('outgoing fetch', () => { const [SERVER_URL, closeTestServer] = await createTestServer() .get('/api/v0', headers => { expect(headers['baggage']).toEqual(expect.any(String)); - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-0$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-0$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000-0'); }) .get('/api/v1', headers => { expect(headers['baggage']).toEqual(expect.any(String)); - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-0$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-0$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000-0'); }) .get('/api/v2', headers => { diff --git a/dev-packages/node-integration-tests/suites/tracing/requests/http-no-tracing-no-spans/test.ts b/dev-packages/node-integration-tests/suites/tracing/requests/http-no-tracing-no-spans/test.ts index fe9cba032344..1cad4abf9a99 100644 --- a/dev-packages/node-integration-tests/suites/tracing/requests/http-no-tracing-no-spans/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/requests/http-no-tracing-no-spans/test.ts @@ -11,12 +11,12 @@ describe('outgoing http requests with tracing & spans disabled', () => { const [SERVER_URL, closeTestServer] = await createTestServer() .get('/api/v0', headers => { - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); expect(headers['baggage']).toEqual(expect.any(String)); }) .get('/api/v1', headers => { - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); expect(headers['baggage']).toEqual(expect.any(String)); }) diff --git a/dev-packages/node-integration-tests/suites/tracing/requests/http-no-tracing/test.ts b/dev-packages/node-integration-tests/suites/tracing/requests/http-no-tracing/test.ts index 7922fe3a443f..d0b13513d1de 100644 --- a/dev-packages/node-integration-tests/suites/tracing/requests/http-no-tracing/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/requests/http-no-tracing/test.ts @@ -9,12 +9,12 @@ describe('outgoing http', () => { const [SERVER_URL, closeTestServer] = await createTestServer() .get('/api/v0', headers => { - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); expect(headers['baggage']).toEqual(expect.any(String)); }) .get('/api/v1', headers => { - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); expect(headers['baggage']).toEqual(expect.any(String)); }) diff --git a/dev-packages/node-integration-tests/suites/tracing/requests/http-sampled-no-active-span/test.ts b/dev-packages/node-integration-tests/suites/tracing/requests/http-sampled-no-active-span/test.ts index 8d1afff8c867..932f379ec23e 100644 --- a/dev-packages/node-integration-tests/suites/tracing/requests/http-sampled-no-active-span/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/requests/http-sampled-no-active-span/test.ts @@ -10,12 +10,12 @@ describe('outgoing http', () => { const [SERVER_URL, closeTestServer] = await createTestServer() .get('/api/v0', headers => { expect(headers['baggage']).toEqual(expect.any(String)); - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); }) .get('/api/v1', headers => { expect(headers['baggage']).toEqual(expect.any(String)); - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000'); }) .get('/api/v2', headers => { diff --git a/dev-packages/node-integration-tests/suites/tracing/requests/http-sampled/test.ts b/dev-packages/node-integration-tests/suites/tracing/requests/http-sampled/test.ts index 5951db7f51b7..9a7b13a34332 100644 --- a/dev-packages/node-integration-tests/suites/tracing/requests/http-sampled/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/requests/http-sampled/test.ts @@ -10,12 +10,12 @@ describe('outgoing http', () => { const [SERVER_URL, closeTestServer] = await createTestServer() .get('/api/v0', headers => { expect(headers['baggage']).toEqual(expect.any(String)); - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-1$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000-1'); }) .get('/api/v1', headers => { expect(headers['baggage']).toEqual(expect.any(String)); - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-1$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000-1'); }) .get('/api/v2', headers => { diff --git a/dev-packages/node-integration-tests/suites/tracing/requests/http-unsampled/test.ts b/dev-packages/node-integration-tests/suites/tracing/requests/http-unsampled/test.ts index 4e83d2e3feb1..28fb877d0425 100644 --- a/dev-packages/node-integration-tests/suites/tracing/requests/http-unsampled/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/requests/http-unsampled/test.ts @@ -10,12 +10,12 @@ describe('outgoing http', () => { const [SERVER_URL, closeTestServer] = await createTestServer() .get('/api/v0', headers => { expect(headers['baggage']).toEqual(expect.any(String)); - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-0$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-0$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000-0'); }) .get('/api/v1', headers => { expect(headers['baggage']).toEqual(expect.any(String)); - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-0$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-0$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000-0'); }) .get('/api/v2', headers => { diff --git a/dev-packages/node-integration-tests/suites/tracing/sample-rand-propagation/test.ts b/dev-packages/node-integration-tests/suites/tracing/sample-rand-propagation/test.ts index df25a261ab2c..a63efe51adbd 100644 --- a/dev-packages/node-integration-tests/suites/tracing/sample-rand-propagation/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/sample-rand-propagation/test.ts @@ -11,7 +11,7 @@ describe('sample_rand propagation', () => { const response = await runner.makeRequest('get', '/check'); expect(response).toEqual({ propagatedData: { - baggage: expect.stringMatching(/sentry-sample_rand=0\.[0-9]+/), + baggage: expect.stringMatching(/sentry-sample_rand=0\.\d+/), }, }); }); @@ -40,7 +40,7 @@ describe('sample_rand propagation', () => { }); expect(response).toEqual({ propagatedData: { - baggage: expect.stringMatching(/sentry-sample_rand=0\.[0-9]+/), + baggage: expect.stringMatching(/sentry-sample_rand=0\.\d+/), }, }); }); @@ -54,7 +54,7 @@ describe('sample_rand propagation', () => { }, }); - const sampleRand = Number((response as any).propagatedData.baggage.match(/sentry-sample_rand=(0\.[0-9]+)/)[1]); + const sampleRand = Number((response as any).propagatedData.baggage.match(/sentry-sample_rand=(0\.\d+)/)[1]); expect(sampleRand).toStrictEqual(expect.any(Number)); expect(sampleRand).not.toBeNaN(); @@ -71,7 +71,7 @@ describe('sample_rand propagation', () => { }, }); - const sampleRand = Number((response as any).propagatedData.baggage.match(/sentry-sample_rand=(0\.[0-9]+)/)[1]); + const sampleRand = Number((response as any).propagatedData.baggage.match(/sentry-sample_rand=(0\.\d+)/)[1]); expect(sampleRand).toStrictEqual(expect.any(Number)); expect(sampleRand).not.toBeNaN(); @@ -87,8 +87,8 @@ describe('sample_rand propagation', () => { }, }); - expect((response as any).propagatedData.baggage).toMatch(/sentry-sample_rand=0\.[0-9]+/); - const sampleRandStr = (response as any).propagatedData.baggage.match(/sentry-sample_rand=(0\.[0-9]+)/)[1]; + expect((response as any).propagatedData.baggage).toMatch(/sentry-sample_rand=0\.\d+/); + const sampleRandStr = (response as any).propagatedData.baggage.match(/sentry-sample_rand=(0\.\d+)/)[1]; expect(sampleRandStr).not.toBe('0.5'); }); }); diff --git a/dev-packages/node-integration-tests/suites/tracing/tracePropagationTargets/test.ts b/dev-packages/node-integration-tests/suites/tracing/tracePropagationTargets/test.ts index 4185dec46afb..9fb39a1ec8f2 100644 --- a/dev-packages/node-integration-tests/suites/tracing/tracePropagationTargets/test.ts +++ b/dev-packages/node-integration-tests/suites/tracing/tracePropagationTargets/test.ts @@ -8,12 +8,12 @@ test('HttpIntegration should instrument correct requests when tracePropagationTa const [SERVER_URL, closeTestServer] = await createTestServer() .get('/api/v0', headers => { expect(headers['baggage']).toEqual(expect.any(String)); - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-1$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000-1'); }) .get('/api/v1', headers => { expect(headers['baggage']).toEqual(expect.any(String)); - expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f0-9]{32})-([a-f0-9]{16})-1$/)); + expect(headers['sentry-trace']).toEqual(expect.stringMatching(/^([a-f\d]{32})-([a-f\d]{16})-1$/)); expect(headers['sentry-trace']).not.toEqual('00000000000000000000000000000000-0000000000000000-1'); }) .get('/api/v2', headers => { diff --git a/dev-packages/node-integration-tests/utils/runner.ts b/dev-packages/node-integration-tests/utils/runner.ts index ac15a944ee0b..97c4021ccc89 100644 --- a/dev-packages/node-integration-tests/utils/runner.ts +++ b/dev-packages/node-integration-tests/utils/runner.ts @@ -611,7 +611,7 @@ export function createRunner(...paths: string[]) { function tryParseEnvelopeFromStdoutLine(line: string): void { // Lines can have leading '[something] [{' which we need to remove - const cleanedLine = line.replace(/^.*?] \[{"/, '[{"'); + const cleanedLine = line.replace(/^.*?\] \[\{"/, '[{"'); // See if we have a port message if (cleanedLine.startsWith('{"port":')) { @@ -801,6 +801,7 @@ function convertEsmToCjs(content: string): string { // Handle default imports: import x from 'y' -> const x = require('y') newContent = newContent.replace( + // eslint-disable-next-line regexp/optimal-quantifier-concatenation, regexp/no-super-linear-backtracking /import\s+([\w*{}\s,]+)\s+from\s+['"]([^'"]+)['"]/g, (_, imports: string, module: string) => { if (imports.includes('* as')) { diff --git a/dev-packages/node-overhead-gh-action/.eslintrc.cjs b/dev-packages/node-overhead-gh-action/.eslintrc.cjs index 381653af6ece..a1c4f5968e46 100644 --- a/dev-packages/node-overhead-gh-action/.eslintrc.cjs +++ b/dev-packages/node-overhead-gh-action/.eslintrc.cjs @@ -2,7 +2,9 @@ module.exports = { env: { node: true, }, - extends: ['../../.eslintrc.js'], + // todo: remove regexp plugin from here once we add it to base.js eslint config for the whole project + extends: ['../../.eslintrc.js', 'plugin:regexp/recommended'], + plugins: ['regexp'], overrides: [ { files: ['**/*.mjs'], diff --git a/dev-packages/node-overhead-gh-action/package.json b/dev-packages/node-overhead-gh-action/package.json index 505fe9a8d683..6b01633f742d 100644 --- a/dev-packages/node-overhead-gh-action/package.json +++ b/dev-packages/node-overhead-gh-action/package.json @@ -35,6 +35,7 @@ "@actions/glob": "0.4.0", "@actions/io": "1.1.3", "autocannon": "^8.0.0", + "eslint-plugin-regexp": "^1.15.0", "markdown-table": "3.0.3", "tree-kill": "1.2.2" }, diff --git a/dev-packages/rollup-utils/.eslintrc.cjs b/dev-packages/rollup-utils/.eslintrc.cjs index 0939c10d3812..f4a3ac1b8cb7 100644 --- a/dev-packages/rollup-utils/.eslintrc.cjs +++ b/dev-packages/rollup-utils/.eslintrc.cjs @@ -1,5 +1,7 @@ module.exports = { - extends: ['../../.eslintrc.js'], + // todo: remove regexp plugin from here once we add it to base.js eslint config for the whole project + extends: ['../../.eslintrc.js', 'plugin:regexp/recommended'], + plugins: ['regexp'], ignorePatterns: ['otelLoaderTemplate.js.tmpl'], sourceType: 'module', }; diff --git a/dev-packages/rollup-utils/package.json b/dev-packages/rollup-utils/package.json index 60600af2d12e..bfe5f6fe498e 100644 --- a/dev-packages/rollup-utils/package.json +++ b/dev-packages/rollup-utils/package.json @@ -12,6 +12,9 @@ "acorn": "^8.7.0", "recast": "^0.20.5" }, + "devDependencies": { + "eslint-plugin-regexp": "^1.15.0" + }, "volta": { "extends": "../../package.json" }, diff --git a/dev-packages/size-limit-gh-action/.eslintrc.cjs b/dev-packages/size-limit-gh-action/.eslintrc.cjs index bc17bc85b4ab..fbc38a65db9c 100644 --- a/dev-packages/size-limit-gh-action/.eslintrc.cjs +++ b/dev-packages/size-limit-gh-action/.eslintrc.cjs @@ -1,5 +1,7 @@ module.exports = { - extends: ['../../.eslintrc.js'], + // todo: remove regexp plugin from here once we add it to base.js eslint config for the whole project + extends: ['../../.eslintrc.js', 'plugin:regexp/recommended'], + plugins: ['regexp'], parserOptions: { sourceType: 'module', ecmaVersion: 'latest', diff --git a/dev-packages/test-utils/.eslintrc.js b/dev-packages/test-utils/.eslintrc.js index fdb9952bae52..3be74e6c3f9d 100644 --- a/dev-packages/test-utils/.eslintrc.js +++ b/dev-packages/test-utils/.eslintrc.js @@ -2,5 +2,7 @@ module.exports = { env: { node: true, }, - extends: ['../../.eslintrc.js'], + // todo: remove regexp plugin from here once we add it to base.js eslint config for the whole project + extends: ['../../.eslintrc.js', 'plugin:regexp/recommended'], + plugins: ['regexp'], }; diff --git a/dev-packages/test-utils/package.json b/dev-packages/test-utils/package.json index 70e3e1fd9263..fa30f4a3c0eb 100644 --- a/dev-packages/test-utils/package.json +++ b/dev-packages/test-utils/package.json @@ -48,7 +48,8 @@ }, "devDependencies": { "@playwright/test": "~1.53.2", - "@sentry/core": "10.23.0" + "@sentry/core": "10.23.0", + "eslint-plugin-regexp": "^1.15.0" }, "volta": { "extends": "../../package.json" diff --git a/yarn.lock b/yarn.lock index a94b2263b7f1..a49764ebb218 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4092,12 +4092,17 @@ resolved "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.25.6.tgz#4276edd5c105bc28b11c6a1f76fb9d29d1bd25c1" integrity sha512-NgJPHHbEpLQgDH2MjQu90pzW/5vvXIZ7KOnPyNBm92A6WgZ/7b6fJyUBjoumLqeOQQGqY2QjQxRo97ah4Sj0cA== -"@eslint-community/eslint-utils@^4.4.0": - version "4.4.0" - resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz#a23514e8fb9af1269d5f7788aa556798d61c6b59" - integrity sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA== +"@eslint-community/eslint-utils@^4.2.0", "@eslint-community/eslint-utils@^4.4.0": + version "4.9.0" + resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.9.0.tgz#7308df158e064f0dd8b8fdb58aa14fa2a7f913b3" + integrity sha512-ayVFHdtZ+hsq1t2Dy24wCmGXGe4q9Gu3smhLYALJrr473ZH27MsnSL+LKUlimp4BWJqMDMLmPpx/Q9R3OAlL4g== dependencies: - eslint-visitor-keys "^3.3.0" + eslint-visitor-keys "^3.4.3" + +"@eslint-community/regexpp@^4.4.0", "@eslint-community/regexpp@^4.5.0": + version "4.12.2" + resolved "https://registry.yarnpkg.com/@eslint-community/regexpp/-/regexpp-4.12.2.tgz#bccdf615bcf7b6e8db830ec0b8d21c9a25de597b" + integrity sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew== "@eslint/eslintrc@^0.4.3": version "0.4.3" @@ -13117,6 +13122,11 @@ comment-parser@^0.7.6: resolved "https://registry.yarnpkg.com/comment-parser/-/comment-parser-0.7.6.tgz#0e743a53c8e646c899a1323db31f6cd337b10f12" integrity sha512-GKNxVA7/iuTnAqGADlTWX4tkhzxZKXp5fLJqKTlQLHkE65XDUKutZ3BHaJC5IGcper2tT3QRD1xr4o3jNpgXXg== +comment-parser@^1.1.2: + version "1.4.1" + resolved "https://registry.yarnpkg.com/comment-parser/-/comment-parser-1.4.1.tgz#bdafead37961ac079be11eb7ec65c4d021eaf9cc" + integrity sha512-buhp5kePrmda3vhc5B9t7pUQXAb2Tnd0qgpkIhPhkHXxJpiPJ11H0ZEU0oBpJ2QztSbzG/ZxMj/CHsYJqRHmyg== + commenting@~1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/commenting/-/commenting-1.1.0.tgz#fae14345c6437b8554f30bc6aa6c1e1633033590" @@ -16208,6 +16218,20 @@ eslint-plugin-react@^7.20.5, eslint-plugin-react@^7.31.11: semver "^6.3.0" string.prototype.matchall "^4.0.8" +eslint-plugin-regexp@^1.15.0: + version "1.15.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-regexp/-/eslint-plugin-regexp-1.15.0.tgz#2717cd4867418287b36d9569c72fca7d242c59b3" + integrity sha512-YEtQPfdudafU7RBIFci81R/Q1yErm0mVh3BkGnXD2Dk8DLwTFdc2ITYH1wCnHKim2gnHfPFgrkh+b2ozyyU7ag== + dependencies: + "@eslint-community/eslint-utils" "^4.2.0" + "@eslint-community/regexpp" "^4.4.0" + comment-parser "^1.1.2" + grapheme-splitter "^1.0.4" + jsdoctypeparser "^9.0.0" + refa "^0.11.0" + regexp-ast-analysis "^0.6.0" + scslre "^0.2.0" + eslint-plugin-simple-import-sort@^6.0.0: version "6.0.1" resolved "https://registry.yarnpkg.com/eslint-plugin-simple-import-sort/-/eslint-plugin-simple-import-sort-6.0.1.tgz#24a3af3b745dcd389c060db28e22d0f5e3edf86e" @@ -16245,7 +16269,7 @@ eslint-visitor-keys@^2.0.0: resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-2.0.0.tgz#21fdc8fbcd9c795cc0321f0563702095751511a8" integrity sha512-QudtT6av5WXels9WjIM7qz1XD1cWGvX4gGXvp/zBn9nXG02D0utdU3Em2m/QjTnrsk6bBjmCygl3rmj118msQQ== -eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4.1: +eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4.1, eslint-visitor-keys@^3.4.3: version "3.4.3" resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz#0cd72fe8550e3c2eae156a96a4dddcd1c8ac5800" integrity sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag== @@ -18086,6 +18110,11 @@ graceful-fs@4.2.11, graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2 resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" integrity sha1-TK+tdrxi8C+gObL5Tpo906ORpyU= +grapheme-splitter@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz#9cf3a665c6247479896834af35cf1dbb4400767e" + integrity sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ== + graphql-tag@^2.11.0: version "2.12.6" resolved "https://registry.yarnpkg.com/graphql-tag/-/graphql-tag-2.12.6.tgz#d441a569c1d2537ef10ca3d1633b48725329b5f1" @@ -26380,6 +26409,13 @@ redux@^4.0.5: loose-envify "^1.4.0" symbol-observable "^1.2.0" +refa@^0.11.0: + version "0.11.0" + resolved "https://registry.yarnpkg.com/refa/-/refa-0.11.0.tgz#07d57a9f5f3ee2dd58e0d145a6a489fda2591ed0" + integrity sha512-486O8/pQXwj9jV0mVvUnTsxq0uknpBnNJ0eCUhkZqJRQ8KutrT1PhzmumdCeM1hSBF2eMlFPmwECRER4IbKXlQ== + dependencies: + "@eslint-community/regexpp" "^4.5.0" + reflect-metadata@0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/reflect-metadata/-/reflect-metadata-0.2.1.tgz#8d5513c0f5ef2b4b9c3865287f3c0940c1f67f74" @@ -26437,6 +26473,14 @@ regex-parser@^2.2.11: resolved "https://registry.yarnpkg.com/regex-parser/-/regex-parser-2.2.11.tgz#3b37ec9049e19479806e878cabe7c1ca83ccfe58" integrity sha512-jbD/FT0+9MBU2XAZluI7w2OBs1RBi6p9M83nkoZayQXXU9e8Robt69FcZc7wU4eJD/YFTjn1JdCk3rbMJajz8Q== +regexp-ast-analysis@^0.6.0: + version "0.6.0" + resolved "https://registry.yarnpkg.com/regexp-ast-analysis/-/regexp-ast-analysis-0.6.0.tgz#c0b648728c85d266a409ce00a6440c01c9834c61" + integrity sha512-OLxjyjPkVH+rQlBLb1I/P/VTmamSjGkvN5PTV5BXP432k3uVz727J7H29GA5IFiY0m7e1xBN7049Wn59FY3DEQ== + dependencies: + "@eslint-community/regexpp" "^4.5.0" + refa "^0.11.0" + regexp-clone@1.0.0, regexp-clone@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/regexp-clone/-/regexp-clone-1.0.0.tgz#222db967623277056260b992626354a04ce9bf63" @@ -27305,6 +27349,15 @@ schema-utils@^4.0.0, schema-utils@^4.3.0, schema-utils@^4.3.2: ajv-formats "^2.1.1" ajv-keywords "^5.1.0" +scslre@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/scslre/-/scslre-0.2.0.tgz#b604eedbab76f87003738d00de44d7601a78609e" + integrity sha512-4hc49fUMmX3jM0XdFUAPBrs1xwEcdHa0KyjEsjFs+Zfc66mpFpq5YmRgDtl+Ffo6AtJIilfei+yKw8fUn3N88w== + dependencies: + "@eslint-community/regexpp" "^4.5.0" + refa "^0.11.0" + regexp-ast-analysis "^0.6.0" + scule@^1.0.0, scule@^1.2.0, scule@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/scule/-/scule-1.3.0.tgz#6efbd22fd0bb801bdcc585c89266a7d2daa8fbd3" From ad870cf18d21b5ef8684ee6ab581169e1de308f7 Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Thu, 6 Nov 2025 17:32:53 +0100 Subject: [PATCH 05/12] feat(metrics)!: Update types (#17907) - Fixing some of the types according to the specs. --- packages/core/src/client.ts | 8 ++------ packages/core/src/metrics/internal.ts | 2 +- packages/core/src/metrics/public-api.ts | 2 +- packages/core/src/types-hoist/metric.ts | 6 +++--- packages/core/test/lib/client.test.ts | 5 ++++- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/packages/core/src/client.ts b/packages/core/src/client.ts index 6a269a969c8d..e0294ef26c59 100644 --- a/packages/core/src/client.ts +++ b/packages/core/src/client.ts @@ -1521,12 +1521,8 @@ function estimateMetricSizeInBytes(metric: Metric): number { weight += metric.name.length * 2; } - // Add weight for the value - if (typeof metric.value === 'string') { - weight += metric.value.length * 2; - } else { - weight += 8; // number - } + // Add weight for number + weight += 8; return weight + estimateAttributesSizeInBytes(metric.attributes); } diff --git a/packages/core/src/metrics/internal.ts b/packages/core/src/metrics/internal.ts index efa204cac5a3..ff097180c6ec 100644 --- a/packages/core/src/metrics/internal.ts +++ b/packages/core/src/metrics/internal.ts @@ -201,7 +201,7 @@ export function _INTERNAL_captureMetric(beforeMetric: Metric, options?: Internal const serializedMetric: SerializedMetric = { timestamp: timestampInSeconds(), - trace_id: traceId, + trace_id: traceId ?? '', span_id: spanId, name: processedMetric.name, type: processedMetric.type, diff --git a/packages/core/src/metrics/public-api.ts b/packages/core/src/metrics/public-api.ts index e508fcb9e6d0..7dcfe74dfdb0 100644 --- a/packages/core/src/metrics/public-api.ts +++ b/packages/core/src/metrics/public-api.ts @@ -30,7 +30,7 @@ export interface MetricOptions { * @param value - The value of the metric. * @param options - Options for capturing the metric. */ -function captureMetric(type: MetricType, name: string, value: number | string, options?: MetricOptions): void { +function captureMetric(type: MetricType, name: string, value: number, options?: MetricOptions): void { _INTERNAL_captureMetric( { type, name, value, unit: options?.unit, attributes: options?.attributes }, { scope: options?.scope }, diff --git a/packages/core/src/types-hoist/metric.ts b/packages/core/src/types-hoist/metric.ts index 9201243c4a38..6ac63da6032b 100644 --- a/packages/core/src/types-hoist/metric.ts +++ b/packages/core/src/types-hoist/metric.ts @@ -9,7 +9,7 @@ export interface Metric { /** * The value of the metric. */ - value: number | string; + value: number; /** * The type of metric. @@ -42,7 +42,7 @@ export interface SerializedMetric { /** * The trace ID for this metric. */ - trace_id?: string; + trace_id: string; /** * The span ID for this metric. @@ -67,7 +67,7 @@ export interface SerializedMetric { /** * The value of the metric. */ - value: number | string; + value: number; /** * Arbitrary structured data that stores information about the metric. diff --git a/packages/core/test/lib/client.test.ts b/packages/core/test/lib/client.test.ts index ae324aa40f9f..d50d6da911b8 100644 --- a/packages/core/test/lib/client.test.ts +++ b/packages/core/test/lib/client.test.ts @@ -2763,7 +2763,10 @@ describe('Client', () => { // Create large metrics that will exceed the 800KB threshold const largeValue = 'x'.repeat(400_000); // 400KB string - _INTERNAL_captureMetric({ name: 'large_metric', value: largeValue, type: 'counter', attributes: {} }, { scope }); + _INTERNAL_captureMetric( + { name: 'large_metric', value: 1, type: 'counter', attributes: { large_value: largeValue } }, + { scope }, + ); expect(sendEnvelopeSpy).toHaveBeenCalledTimes(1); }); From c2530dd879b806675360216ae7b9d73bf0c88780 Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Thu, 6 Nov 2025 19:26:51 +0100 Subject: [PATCH 06/12] feat(metrics): Add top level option `enableMetrics` and `beforeSendMetric` (#18088) - Adds top level options for `enableMetrics` and `beforeSendMetric`. - Kept the experimental flags for now to stay backwards compatible, but added a deprecation note and todo comments for removing them in v11. - Updated all the tests to use the top-level flag. - Had to refactor the `_INTERNAL_captureMetric` function since it broke the complexity threshold of our linter > [!WARNING] > `enableMetrics` now defaults to `true`, so theoretically this PR is behaviourally breaking. --- .size-limit.js | 2 +- .../suites/public-api/metrics/init.js | 3 - .../suites/public-api/metrics/scenario.ts | 3 - .../suites/public-api/metrics/scenario.ts | 3 - packages/browser/src/client.ts | 19 ++- packages/core/src/client.ts | 6 +- packages/core/src/metrics/internal.ts | 113 +++++++++++------- packages/core/src/types-hoist/options.ts | 23 ++++ packages/core/test/lib/client.test.ts | 3 - .../core/test/lib/metrics/internal.test.ts | 56 ++++----- .../core/test/lib/metrics/public-api.test.ts | 28 ++--- 11 files changed, 152 insertions(+), 107 deletions(-) diff --git a/.size-limit.js b/.size-limit.js index c3f0e79d35fa..b4819fc83126 100644 --- a/.size-limit.js +++ b/.size-limit.js @@ -190,7 +190,7 @@ module.exports = [ path: createCDNPath('bundle.tracing.min.js'), gzip: false, brotli: false, - limit: '124.1 KB', + limit: '125 KB', }, { name: 'CDN Bundle (incl. Tracing, Replay) - uncompressed', diff --git a/dev-packages/browser-integration-tests/suites/public-api/metrics/init.js b/dev-packages/browser-integration-tests/suites/public-api/metrics/init.js index df4fda70e4c7..73c6e63ed335 100644 --- a/dev-packages/browser-integration-tests/suites/public-api/metrics/init.js +++ b/dev-packages/browser-integration-tests/suites/public-api/metrics/init.js @@ -4,9 +4,6 @@ window.Sentry = Sentry; Sentry.init({ dsn: 'https://public@dsn.ingest.sentry.io/1337', - _experiments: { - enableMetrics: true, - }, release: '1.0.0', environment: 'test', integrations: integrations => { diff --git a/dev-packages/node-core-integration-tests/suites/public-api/metrics/scenario.ts b/dev-packages/node-core-integration-tests/suites/public-api/metrics/scenario.ts index 9ab9fed7d22b..77adfae79802 100644 --- a/dev-packages/node-core-integration-tests/suites/public-api/metrics/scenario.ts +++ b/dev-packages/node-core-integration-tests/suites/public-api/metrics/scenario.ts @@ -6,9 +6,6 @@ const client = Sentry.init({ dsn: 'https://public@dsn.ingest.sentry.io/1337', release: '1.0.0', environment: 'test', - _experiments: { - enableMetrics: true, - }, transport: loggingTransport, }); diff --git a/dev-packages/node-integration-tests/suites/public-api/metrics/scenario.ts b/dev-packages/node-integration-tests/suites/public-api/metrics/scenario.ts index 9c776eb14d59..8d02a1fcd17c 100644 --- a/dev-packages/node-integration-tests/suites/public-api/metrics/scenario.ts +++ b/dev-packages/node-integration-tests/suites/public-api/metrics/scenario.ts @@ -5,9 +5,6 @@ Sentry.init({ dsn: 'https://public@dsn.ingest.sentry.io/1337', release: '1.0.0', environment: 'test', - _experiments: { - enableMetrics: true, - }, transport: loggingTransport, }); diff --git a/packages/browser/src/client.ts b/packages/browser/src/client.ts index 1b4289d66992..dddaa440b198 100644 --- a/packages/browser/src/client.ts +++ b/packages/browser/src/client.ts @@ -104,10 +104,22 @@ export class BrowserClient extends Client { super(opts); - const { sendDefaultPii, sendClientReports, enableLogs, _experiments } = this._options; + const { + sendDefaultPii, + sendClientReports, + enableLogs, + _experiments, + enableMetrics: enableMetricsOption, + } = this._options; + + // todo(v11): Remove the experimental flag + // eslint-disable-next-line deprecation/deprecation + const enableMetrics = enableMetricsOption ?? _experiments?.enableMetrics ?? true; // Flush logs and metrics when page becomes hidden (e.g., tab switch, navigation) - if (WINDOW.document && (sendClientReports || enableLogs || _experiments?.enableMetrics)) { + // todo(v11): Remove the experimental flag + // eslint-disable-next-line deprecation/deprecation + if (WINDOW.document && (sendClientReports || enableLogs || enableMetrics)) { WINDOW.document.addEventListener('visibilitychange', () => { if (WINDOW.document.visibilityState === 'hidden') { if (sendClientReports) { @@ -116,7 +128,8 @@ export class BrowserClient extends Client { if (enableLogs) { _INTERNAL_flushLogsBuffer(this); } - if (_experiments?.enableMetrics) { + + if (enableMetrics) { _INTERNAL_flushMetricsBuffer(this); } } diff --git a/packages/core/src/client.ts b/packages/core/src/client.ts index e0294ef26c59..c3ff126732f8 100644 --- a/packages/core/src/client.ts +++ b/packages/core/src/client.ts @@ -232,8 +232,12 @@ export abstract class Client { setupWeightBasedFlushing(this, 'afterCaptureLog', 'flushLogs', estimateLogSizeInBytes, _INTERNAL_flushLogsBuffer); } + // todo(v11): Remove the experimental flag + // eslint-disable-next-line deprecation/deprecation + const enableMetrics = this._options.enableMetrics ?? this._options._experiments?.enableMetrics ?? true; + // Setup metric flushing with weight and timeout tracking - if (this._options._experiments?.enableMetrics) { + if (enableMetrics) { setupWeightBasedFlushing( this, 'afterCaptureMetric', diff --git a/packages/core/src/metrics/internal.ts b/packages/core/src/metrics/internal.ts index ff097180c6ec..5371ecba8dfd 100644 --- a/packages/core/src/metrics/internal.ts +++ b/packages/core/src/metrics/internal.ts @@ -116,35 +116,16 @@ export interface InternalCaptureMetricOptions { } /** - * Captures a metric event and sends it to Sentry. - * - * @param metric - The metric event to capture. - * @param options - Options for capturing the metric. - * - * @experimental This method will experience breaking changes. This is not yet part of - * the stable Sentry SDK API and can be changed or removed without warning. + * Enriches metric with all contextual attributes (user, SDK metadata, replay, etc.) */ -export function _INTERNAL_captureMetric(beforeMetric: Metric, options?: InternalCaptureMetricOptions): void { - const currentScope = options?.scope ?? getCurrentScope(); - const captureSerializedMetric = options?.captureSerializedMetric ?? _INTERNAL_captureSerializedMetric; - const client = currentScope?.getClient() ?? getClient(); - if (!client) { - DEBUG_BUILD && debug.warn('No client available to capture metric.'); - return; - } - - const { release, environment, _experiments } = client.getOptions(); - if (!_experiments?.enableMetrics) { - DEBUG_BUILD && debug.warn('metrics option not enabled, metric will not be captured.'); - return; - } - - const [, traceContext] = _getTraceInfoFromScope(client, currentScope); +function _enrichMetricAttributes(beforeMetric: Metric, client: Client, currentScope: Scope): Metric { + const { release, environment } = client.getOptions(); const processedMetricAttributes = { ...beforeMetric.attributes, }; + // Add user attributes const { user: { id, email, username }, } = getMergedScopeData(currentScope); @@ -152,13 +133,16 @@ export function _INTERNAL_captureMetric(beforeMetric: Metric, options?: Internal setMetricAttribute(processedMetricAttributes, 'user.email', email, false); setMetricAttribute(processedMetricAttributes, 'user.name', username, false); + // Add Sentry metadata setMetricAttribute(processedMetricAttributes, 'sentry.release', release); setMetricAttribute(processedMetricAttributes, 'sentry.environment', environment); + // Add SDK metadata const { name, version } = client.getSdkMetadata()?.sdk ?? {}; setMetricAttribute(processedMetricAttributes, 'sentry.sdk.name', name); setMetricAttribute(processedMetricAttributes, 'sentry.sdk.version', version); + // Add replay metadata const replay = client.getIntegrationByName< Integration & { getReplayId: (onlyIfSampled?: boolean) => string; @@ -167,54 +151,97 @@ export function _INTERNAL_captureMetric(beforeMetric: Metric, options?: Internal >('Replay'); const replayId = replay?.getReplayId(true); - setMetricAttribute(processedMetricAttributes, 'sentry.replay_id', replayId); if (replayId && replay?.getRecordingMode() === 'buffer') { - // We send this so we can identify cases where the replayId is attached but the replay itself might not have been sent to Sentry setMetricAttribute(processedMetricAttributes, 'sentry._internal.replay_is_buffering', true); } - const metric: Metric = { + return { ...beforeMetric, attributes: processedMetricAttributes, }; +} - // Run beforeSendMetric callback - const processedMetric = _experiments?.beforeSendMetric ? _experiments.beforeSendMetric(metric) : metric; - - if (!processedMetric) { - DEBUG_BUILD && debug.log('`beforeSendMetric` returned `null`, will not send metric.'); - return; - } - +/** + * Creates a serialized metric ready to be sent to Sentry. + */ +function _buildSerializedMetric(metric: Metric, client: Client, currentScope: Scope): SerializedMetric { + // Serialize attributes const serializedAttributes: Record = {}; - for (const key in processedMetric.attributes) { - if (processedMetric.attributes[key] !== undefined) { - serializedAttributes[key] = metricAttributeToSerializedMetricAttribute(processedMetric.attributes[key]); + for (const key in metric.attributes) { + if (metric.attributes[key] !== undefined) { + serializedAttributes[key] = metricAttributeToSerializedMetricAttribute(metric.attributes[key]); } } + // Get trace context + const [, traceContext] = _getTraceInfoFromScope(client, currentScope); const span = _getSpanForScope(currentScope); const traceId = span ? span.spanContext().traceId : traceContext?.trace_id; const spanId = span ? span.spanContext().spanId : undefined; - const serializedMetric: SerializedMetric = { + return { timestamp: timestampInSeconds(), trace_id: traceId ?? '', span_id: spanId, - name: processedMetric.name, - type: processedMetric.type, - unit: processedMetric.unit, - value: processedMetric.value, + name: metric.name, + type: metric.type, + unit: metric.unit, + value: metric.value, attributes: serializedAttributes, }; +} + +/** + * Captures a metric event and sends it to Sentry. + * + * @param metric - The metric event to capture. + * @param options - Options for capturing the metric. + * + * @experimental This method will experience breaking changes. This is not yet part of + * the stable Sentry SDK API and can be changed or removed without warning. + */ +export function _INTERNAL_captureMetric(beforeMetric: Metric, options?: InternalCaptureMetricOptions): void { + const currentScope = options?.scope ?? getCurrentScope(); + const captureSerializedMetric = options?.captureSerializedMetric ?? _INTERNAL_captureSerializedMetric; + const client = currentScope?.getClient() ?? getClient(); + if (!client) { + DEBUG_BUILD && debug.warn('No client available to capture metric.'); + return; + } + + const { _experiments, enableMetrics, beforeSendMetric } = client.getOptions(); + + // todo(v11): Remove the experimental flag + // eslint-disable-next-line deprecation/deprecation + const metricsEnabled = enableMetrics ?? _experiments?.enableMetrics ?? true; + + if (!metricsEnabled) { + DEBUG_BUILD && debug.warn('metrics option not enabled, metric will not be captured.'); + return; + } + + // Enrich metric with contextual attributes + const enrichedMetric = _enrichMetricAttributes(beforeMetric, client, currentScope); + + // todo(v11): Remove the experimental `beforeSendMetric` + // eslint-disable-next-line deprecation/deprecation + const beforeSendCallback = beforeSendMetric || _experiments?.beforeSendMetric; + const processedMetric = beforeSendCallback ? beforeSendCallback(enrichedMetric) : enrichedMetric; + + if (!processedMetric) { + DEBUG_BUILD && debug.log('`beforeSendMetric` returned `null`, will not send metric.'); + return; + } + + const serializedMetric = _buildSerializedMetric(processedMetric, client, currentScope); DEBUG_BUILD && debug.log('[Metric]', serializedMetric); captureSerializedMetric(client, serializedMetric); - client.emit('afterCaptureMetric', metric); + client.emit('afterCaptureMetric', enrichedMetric); } /** diff --git a/packages/core/src/types-hoist/options.ts b/packages/core/src/types-hoist/options.ts index 2d4c0e6b43a4..ccdc3b180e15 100644 --- a/packages/core/src/types-hoist/options.ts +++ b/packages/core/src/types-hoist/options.ts @@ -287,6 +287,7 @@ export interface ClientOptions Metric | null; }; @@ -401,6 +403,27 @@ export interface ClientOptions Log | null; + /** + * If metrics support should be enabled. + * + * @default true + */ + enableMetrics?: boolean; + + /** + * An event-processing callback for metrics, guaranteed to be invoked after all other metric + * processors. This allows a metric to be modified or dropped before it's sent. + * + * Note that you must return a valid metric from this callback. If you do not wish to modify the metric, simply return + * it at the end. Returning `null` will cause the metric to be dropped. + * + * @default undefined + * + * @param metric The metric generated by the SDK. + * @returns A new metric that will be sent. + */ + beforeSendMetric?: (metric: Metric) => Metric; + /** * Function to compute tracing sample rate dynamically and filter unwanted traces. * diff --git a/packages/core/test/lib/client.test.ts b/packages/core/test/lib/client.test.ts index d50d6da911b8..db25793ccf7b 100644 --- a/packages/core/test/lib/client.test.ts +++ b/packages/core/test/lib/client.test.ts @@ -2753,7 +2753,6 @@ describe('Client', () => { it('flushes metrics when weight exceeds 800KB', () => { const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, - _experiments: { enableMetrics: true }, }); const client = new TestClient(options); const scope = new Scope(); @@ -2774,7 +2773,6 @@ describe('Client', () => { it('accumulates metric weight without flushing when under threshold', () => { const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, - _experiments: { enableMetrics: true }, }); const client = new TestClient(options); const scope = new Scope(); @@ -2791,7 +2789,6 @@ describe('Client', () => { it('flushes metrics on flush event', () => { const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, - _experiments: { enableMetrics: true }, }); const client = new TestClient(options); const scope = new Scope(); diff --git a/packages/core/test/lib/metrics/internal.test.ts b/packages/core/test/lib/metrics/internal.test.ts index c0279c9a270b..d9d123b63e99 100644 --- a/packages/core/test/lib/metrics/internal.test.ts +++ b/packages/core/test/lib/metrics/internal.test.ts @@ -82,7 +82,7 @@ describe('metricAttributeToSerializedMetricAttribute', () => { describe('_INTERNAL_captureMetric', () => { it('captures and sends metrics', () => { - const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, _experiments: { enableMetrics: true } }); + const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); const client = new TestClient(options); const scope = new Scope(); scope.setClient(client); @@ -103,7 +103,7 @@ describe('_INTERNAL_captureMetric', () => { it('does not capture metrics when enableMetrics is not enabled', () => { const logWarnSpy = vi.spyOn(loggerModule.debug, 'warn').mockImplementation(() => undefined); - const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); + const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, enableMetrics: false }); const client = new TestClient(options); const scope = new Scope(); scope.setClient(client); @@ -117,7 +117,7 @@ describe('_INTERNAL_captureMetric', () => { }); it('includes trace context when available', () => { - const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, _experiments: { enableMetrics: true } }); + const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); const client = new TestClient(options); const scope = new Scope(); scope.setClient(client); @@ -138,7 +138,6 @@ describe('_INTERNAL_captureMetric', () => { it('includes release and environment in metric attributes when available', () => { const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, - _experiments: { enableMetrics: true }, release: '1.0.0', environment: 'test', }); @@ -164,7 +163,6 @@ describe('_INTERNAL_captureMetric', () => { it('includes SDK metadata in metric attributes when available', () => { const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, - _experiments: { enableMetrics: true }, }); const client = new TestClient(options); const scope = new Scope(); @@ -195,7 +193,6 @@ describe('_INTERNAL_captureMetric', () => { it('does not include SDK metadata in metric attributes when not available', () => { const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, - _experiments: { enableMetrics: true }, }); const client = new TestClient(options); const scope = new Scope(); @@ -215,7 +212,7 @@ describe('_INTERNAL_captureMetric', () => { }); it('includes custom attributes in metric', () => { - const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, _experiments: { enableMetrics: true } }); + const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); const client = new TestClient(options); const scope = new Scope(); scope.setClient(client); @@ -244,7 +241,7 @@ describe('_INTERNAL_captureMetric', () => { }); it('flushes metrics buffer when it reaches max size', () => { - const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, _experiments: { enableMetrics: true } }); + const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); const client = new TestClient(options); const scope = new Scope(); scope.setClient(client); @@ -263,7 +260,7 @@ describe('_INTERNAL_captureMetric', () => { }); it('does not flush metrics buffer when it is empty', () => { - const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, _experiments: { enableMetrics: true } }); + const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); const client = new TestClient(options); const mockSendEnvelope = vi.spyOn(client as any, 'sendEnvelope').mockImplementation(() => {}); @@ -280,7 +277,7 @@ describe('_INTERNAL_captureMetric', () => { const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, - _experiments: { enableMetrics: true, beforeSendMetric }, + beforeSendMetric, }); const client = new TestClient(options); const scope = new Scope(); @@ -328,7 +325,7 @@ describe('_INTERNAL_captureMetric', () => { const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, - _experiments: { enableMetrics: true, beforeSendMetric }, + beforeSendMetric, }); const client = new TestClient(options); const scope = new Scope(); @@ -352,7 +349,7 @@ describe('_INTERNAL_captureMetric', () => { it('emits afterCaptureMetric event', () => { const afterCaptureMetricSpy = vi.spyOn(TestClient.prototype, 'emit'); - const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, _experiments: { enableMetrics: true } }); + const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); const client = new TestClient(options); const scope = new Scope(); scope.setClient(client); @@ -372,7 +369,7 @@ describe('_INTERNAL_captureMetric', () => { describe('replay integration with onlyIfSampled', () => { it('includes replay ID for sampled sessions', () => { - const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, _experiments: { enableMetrics: true } }); + const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); const client = new TestClient(options); const scope = new Scope(); scope.setClient(client); @@ -401,7 +398,7 @@ describe('_INTERNAL_captureMetric', () => { }); it('excludes replay ID for unsampled sessions when onlyIfSampled=true', () => { - const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, _experiments: { enableMetrics: true } }); + const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); const client = new TestClient(options); const scope = new Scope(); scope.setClient(client); @@ -424,7 +421,7 @@ describe('_INTERNAL_captureMetric', () => { }); it('includes replay ID for buffer mode sessions', () => { - const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, _experiments: { enableMetrics: true } }); + const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); const client = new TestClient(options); const scope = new Scope(); scope.setClient(client); @@ -457,7 +454,7 @@ describe('_INTERNAL_captureMetric', () => { }); it('handles missing replay integration gracefully', () => { - const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, _experiments: { enableMetrics: true } }); + const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); const client = new TestClient(options); const scope = new Scope(); scope.setClient(client); @@ -474,7 +471,7 @@ describe('_INTERNAL_captureMetric', () => { it('combines replay ID with other metric attributes', () => { const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, - _experiments: { enableMetrics: true }, + release: '1.0.0', environment: 'test', }); @@ -526,7 +523,7 @@ describe('_INTERNAL_captureMetric', () => { }); it('does not set replay ID attribute when getReplayId returns null or undefined', () => { - const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, _experiments: { enableMetrics: true } }); + const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); const client = new TestClient(options); const scope = new Scope(); scope.setClient(client); @@ -552,7 +549,7 @@ describe('_INTERNAL_captureMetric', () => { }); it('sets replay_is_buffering attribute when replay is in buffer mode', () => { - const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, _experiments: { enableMetrics: true } }); + const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); const client = new TestClient(options); const scope = new Scope(); scope.setClient(client); @@ -584,7 +581,7 @@ describe('_INTERNAL_captureMetric', () => { }); it('does not set replay_is_buffering attribute when replay is in session mode', () => { - const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, _experiments: { enableMetrics: true } }); + const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); const client = new TestClient(options); const scope = new Scope(); scope.setClient(client); @@ -613,7 +610,7 @@ describe('_INTERNAL_captureMetric', () => { }); it('does not set replay_is_buffering attribute when replay is undefined mode', () => { - const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, _experiments: { enableMetrics: true } }); + const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); const client = new TestClient(options); const scope = new Scope(); scope.setClient(client); @@ -642,7 +639,7 @@ describe('_INTERNAL_captureMetric', () => { }); it('does not set replay_is_buffering attribute when no replay ID is available', () => { - const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, _experiments: { enableMetrics: true } }); + const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); const client = new TestClient(options); const scope = new Scope(); scope.setClient(client); @@ -668,7 +665,7 @@ describe('_INTERNAL_captureMetric', () => { }); it('does not set replay_is_buffering attribute when replay integration is missing', () => { - const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, _experiments: { enableMetrics: true } }); + const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); const client = new TestClient(options); const scope = new Scope(); scope.setClient(client); @@ -687,7 +684,7 @@ describe('_INTERNAL_captureMetric', () => { it('combines replay_is_buffering with other replay attributes', () => { const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, - _experiments: { enableMetrics: true }, + release: '1.0.0', environment: 'test', }); @@ -747,7 +744,6 @@ describe('_INTERNAL_captureMetric', () => { it('includes user data in metric attributes', () => { const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, - _experiments: { enableMetrics: true }, }); const client = new TestClient(options); const scope = new Scope(); @@ -780,7 +776,6 @@ describe('_INTERNAL_captureMetric', () => { it('includes partial user data when only some fields are available', () => { const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, - _experiments: { enableMetrics: true }, }); const client = new TestClient(options); const scope = new Scope(); @@ -804,7 +799,6 @@ describe('_INTERNAL_captureMetric', () => { it('includes user email and username without id', () => { const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, - _experiments: { enableMetrics: true }, }); const client = new TestClient(options); const scope = new Scope(); @@ -833,7 +827,6 @@ describe('_INTERNAL_captureMetric', () => { it('does not include user data when user object is empty', () => { const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, - _experiments: { enableMetrics: true }, }); const client = new TestClient(options); const scope = new Scope(); @@ -849,7 +842,7 @@ describe('_INTERNAL_captureMetric', () => { it('combines user data with other metric attributes', () => { const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, - _experiments: { enableMetrics: true }, + release: '1.0.0', environment: 'test', }); @@ -903,7 +896,6 @@ describe('_INTERNAL_captureMetric', () => { it('handles user data with non-string values', () => { const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, - _experiments: { enableMetrics: true }, }); const client = new TestClient(options); const scope = new Scope(); @@ -932,7 +924,6 @@ describe('_INTERNAL_captureMetric', () => { it('preserves existing user attributes in metric and does not override them', () => { const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, - _experiments: { enableMetrics: true }, }); const client = new TestClient(options); const scope = new Scope(); @@ -975,7 +966,6 @@ describe('_INTERNAL_captureMetric', () => { it('only adds scope user data for attributes that do not already exist', () => { const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, - _experiments: { enableMetrics: true }, }); const client = new TestClient(options); const scope = new Scope(); @@ -1024,7 +1014,7 @@ describe('_INTERNAL_captureMetric', () => { it('overrides user-provided system attributes with SDK values', () => { const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, - _experiments: { enableMetrics: true }, + release: 'sdk-release-1.0.0', environment: 'sdk-environment', }); diff --git a/packages/core/test/lib/metrics/public-api.test.ts b/packages/core/test/lib/metrics/public-api.test.ts index 42fe7c41ae4a..df8ff49c5553 100644 --- a/packages/core/test/lib/metrics/public-api.test.ts +++ b/packages/core/test/lib/metrics/public-api.test.ts @@ -9,7 +9,7 @@ const PUBLIC_DSN = 'https://username@domain/123'; describe('Metrics Public API', () => { describe('count', () => { it('captures a counter metric with default value of 1', () => { - const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, _experiments: { enableMetrics: true } }); + const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); const client = new TestClient(options); const scope = new Scope(); scope.setClient(client); @@ -28,7 +28,7 @@ describe('Metrics Public API', () => { }); it('captures a counter metric with custom value', () => { - const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, _experiments: { enableMetrics: true } }); + const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); const client = new TestClient(options); const scope = new Scope(); scope.setClient(client); @@ -47,7 +47,7 @@ describe('Metrics Public API', () => { }); it('captures a counter metric with attributes', () => { - const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, _experiments: { enableMetrics: true } }); + const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); const client = new TestClient(options); const scope = new Scope(); scope.setClient(client); @@ -87,7 +87,7 @@ describe('Metrics Public API', () => { }); it('captures a counter metric with unit', () => { - const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, _experiments: { enableMetrics: true } }); + const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); const client = new TestClient(options); const scope = new Scope(); scope.setClient(client); @@ -110,7 +110,7 @@ describe('Metrics Public API', () => { }); it('does not capture counter when enableMetrics is not enabled', () => { - const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); + const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, enableMetrics: false }); const client = new TestClient(options); const scope = new Scope(); scope.setClient(client); @@ -123,7 +123,7 @@ describe('Metrics Public API', () => { describe('gauge', () => { it('captures a gauge metric', () => { - const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, _experiments: { enableMetrics: true } }); + const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); const client = new TestClient(options); const scope = new Scope(); scope.setClient(client); @@ -142,7 +142,7 @@ describe('Metrics Public API', () => { }); it('captures a gauge metric with unit', () => { - const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, _experiments: { enableMetrics: true } }); + const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); const client = new TestClient(options); const scope = new Scope(); scope.setClient(client); @@ -165,7 +165,7 @@ describe('Metrics Public API', () => { }); it('captures a gauge metric with attributes', () => { - const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, _experiments: { enableMetrics: true } }); + const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); const client = new TestClient(options); const scope = new Scope(); scope.setClient(client); @@ -200,7 +200,7 @@ describe('Metrics Public API', () => { }); it('does not capture gauge when enableMetrics is not enabled', () => { - const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); + const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, enableMetrics: false }); const client = new TestClient(options); const scope = new Scope(); scope.setClient(client); @@ -213,7 +213,7 @@ describe('Metrics Public API', () => { describe('distribution', () => { it('captures a distribution metric', () => { - const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, _experiments: { enableMetrics: true } }); + const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); const client = new TestClient(options); const scope = new Scope(); scope.setClient(client); @@ -232,7 +232,7 @@ describe('Metrics Public API', () => { }); it('captures a distribution metric with unit', () => { - const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, _experiments: { enableMetrics: true } }); + const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); const client = new TestClient(options); const scope = new Scope(); scope.setClient(client); @@ -255,7 +255,7 @@ describe('Metrics Public API', () => { }); it('captures a distribution metric with attributes', () => { - const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, _experiments: { enableMetrics: true } }); + const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); const client = new TestClient(options); const scope = new Scope(); scope.setClient(client); @@ -290,7 +290,7 @@ describe('Metrics Public API', () => { }); it('does not capture distribution when enableMetrics is not enabled', () => { - const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); + const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, enableMetrics: false }); const client = new TestClient(options); const scope = new Scope(); scope.setClient(client); @@ -303,7 +303,7 @@ describe('Metrics Public API', () => { describe('mixed metric types', () => { it('captures multiple different metric types', () => { - const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN, _experiments: { enableMetrics: true } }); + const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN }); const client = new TestClient(options); const scope = new Scope(); scope.setClient(client); From 296e8609189950529f3e952b616e3b64b9a7eb75 Mon Sep 17 00:00:00 2001 From: Michi Hoffmann Date: Fri, 7 Nov 2025 07:46:00 +0100 Subject: [PATCH 07/12] chore: X handle update (#18117) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5f76eb4f7a11..3fdd9ddfc452 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ convenient interface and improved consistency between various JavaScript environ - [![Forum](https://img.shields.io/badge/forum-sentry-green.svg)](https://forum.sentry.io/c/sdks) - [![Discord](https://img.shields.io/discord/621778831602221064)](https://discord.gg/Ww9hbqr) - [![Stack Overflow](https://img.shields.io/badge/stack%20overflow-sentry-green.svg)](http://stackoverflow.com/questions/tagged/sentry) -- [![Twitter Follow](https://img.shields.io/twitter/follow/getsentry?label=getsentry&style=social)](https://twitter.com/intent/follow?screen_name=getsentry) +- [![X Follow](https://img.shields.io/twitter/follow/sentry?label=sentry&style=social)](https://x.com/intent/follow?screen_name=sentry) ## Contents From 27af12e80644954cc001d7df62aa7633d28538ac Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Fri, 7 Nov 2025 10:14:31 +0100 Subject: [PATCH 08/12] fix(nextjs): Stop accessing sync props in template (#18113) We need to stop accessing params within our wrapper templates as this can break statically rendered pages and cause cache busts in dynamic pages. Opened https://github.com/getsentry/sentry-javascript/issues/18115 to investigate other ways of handling the functionality we're removing here. closes https://github.com/getsentry/sentry-javascript/issues/18097 closes https://github.com/getsentry/sentry-javascript/issues/17431 Note: There's some unused code in the utils that I did not delete as we might be able to reuse this in https://github.com/getsentry/sentry-javascript/issues/18115 --- .../tests/server-components.test.ts | 1 - .../wrapGenerationFunctionWithSentry.ts | 26 ------------------- .../common/wrapServerComponentWithSentry.ts | 20 -------------- 3 files changed, 47 deletions(-) diff --git a/dev-packages/e2e-tests/test-applications/nextjs-app-dir/tests/server-components.test.ts b/dev-packages/e2e-tests/test-applications/nextjs-app-dir/tests/server-components.test.ts index 52f6ae13875a..25d84cdc28e1 100644 --- a/dev-packages/e2e-tests/test-applications/nextjs-app-dir/tests/server-components.test.ts +++ b/dev-packages/e2e-tests/test-applications/nextjs-app-dir/tests/server-components.test.ts @@ -39,7 +39,6 @@ test('Sends a transaction for a request to app router', async ({ page }) => { headers: expect.objectContaining({ 'user-agent': expect.any(String), }), - url: expect.stringContaining('/server-component/parameter/1337/42'), }); // The transaction should not contain any spans with the same name as the transaction diff --git a/packages/nextjs/src/common/wrapGenerationFunctionWithSentry.ts b/packages/nextjs/src/common/wrapGenerationFunctionWithSentry.ts index c22910df43bf..85969ef1064d 100644 --- a/packages/nextjs/src/common/wrapGenerationFunctionWithSentry.ts +++ b/packages/nextjs/src/common/wrapGenerationFunctionWithSentry.ts @@ -3,7 +3,6 @@ import { captureException, getActiveSpan, getCapturedScopesOnSpan, - getClient, getRootSpan, handleCallbackErrors, propagationContextFromHeaders, @@ -13,7 +12,6 @@ import { setCapturedScopesOnSpan, SPAN_STATUS_ERROR, SPAN_STATUS_OK, - spanToJSON, startSpanManual, winterCGHeadersToDict, withIsolationScope, @@ -23,8 +21,6 @@ import type { GenerationFunctionContext } from '../common/types'; import { isNotFoundNavigationError, isRedirectNavigationError } from './nextNavigationErrorUtils'; import { TRANSACTION_ATTR_SENTRY_TRACE_BACKFILL } from './span-attributes-with-logic-attached'; import { commonObjectToIsolationScope, commonObjectToPropagationContext } from './utils/tracingUtils'; -import { getSanitizedRequestUrl } from './utils/urls'; -import { maybeExtractSynchronousParamsAndSearchParams } from './utils/wrapperUtils'; /** * Wraps a generation function (e.g. generateMetadata) with Sentry error and performance instrumentation. */ @@ -46,30 +42,16 @@ export function wrapGenerationFunctionWithSentry a } const isolationScope = commonObjectToIsolationScope(headers); - let pathname = undefined as string | undefined; const activeSpan = getActiveSpan(); if (activeSpan) { const rootSpan = getRootSpan(activeSpan); const { scope } = getCapturedScopesOnSpan(rootSpan); setCapturedScopesOnSpan(rootSpan, scope ?? new Scope(), isolationScope); - - const spanData = spanToJSON(rootSpan); - - if (spanData.data && 'http.target' in spanData.data) { - pathname = spanData.data['http.target'] as string; - } } const headersDict = headers ? winterCGHeadersToDict(headers) : undefined; - let data: Record | undefined = undefined; - if (getClient()?.getOptions().sendDefaultPii) { - const props: unknown = args[0]; - const { params, searchParams } = maybeExtractSynchronousParamsAndSearchParams(props); - data = { params, searchParams }; - } - return withIsolationScope(isolationScope, () => { return withScope(scope => { scope.setTransactionName(`${componentType}.${generationFunctionIdentifier} (${componentRoute})`); @@ -77,12 +59,6 @@ export function wrapGenerationFunctionWithSentry a isolationScope.setSDKProcessingMetadata({ normalizedRequest: { headers: headersDict, - url: getSanitizedRequestUrl( - componentRoute, - data?.params as Record | undefined, - headersDict, - pathname, - ), } satisfies RequestEventData, }); @@ -106,8 +82,6 @@ export function wrapGenerationFunctionWithSentry a scope.setPropagationContext(propagationContext); - scope.setExtra('route_data', data); - return startSpanManual( { op: 'function.nextjs', diff --git a/packages/nextjs/src/common/wrapServerComponentWithSentry.ts b/packages/nextjs/src/common/wrapServerComponentWithSentry.ts index 1f522dbf212f..63871413f006 100644 --- a/packages/nextjs/src/common/wrapServerComponentWithSentry.ts +++ b/packages/nextjs/src/common/wrapServerComponentWithSentry.ts @@ -3,7 +3,6 @@ import { captureException, getActiveSpan, getCapturedScopesOnSpan, - getClient, getRootSpan, handleCallbackErrors, propagationContextFromHeaders, @@ -13,7 +12,6 @@ import { setCapturedScopesOnSpan, SPAN_STATUS_ERROR, SPAN_STATUS_OK, - spanToJSON, startSpanManual, vercelWaitUntil, winterCGHeadersToDict, @@ -25,8 +23,6 @@ import type { ServerComponentContext } from '../common/types'; import { flushSafelyWithTimeout } from '../common/utils/responseEnd'; import { TRANSACTION_ATTR_SENTRY_TRACE_BACKFILL } from './span-attributes-with-logic-attached'; import { commonObjectToIsolationScope, commonObjectToPropagationContext } from './utils/tracingUtils'; -import { getSanitizedRequestUrl } from './utils/urls'; -import { maybeExtractSynchronousParamsAndSearchParams } from './utils/wrapperUtils'; /** * Wraps an `app` directory server component with Sentry error instrumentation. @@ -45,34 +41,18 @@ export function wrapServerComponentWithSentry any> const requestTraceId = getActiveSpan()?.spanContext().traceId; const isolationScope = commonObjectToIsolationScope(context.headers); - let pathname = undefined as string | undefined; const activeSpan = getActiveSpan(); if (activeSpan) { const rootSpan = getRootSpan(activeSpan); const { scope } = getCapturedScopesOnSpan(rootSpan); setCapturedScopesOnSpan(rootSpan, scope ?? new Scope(), isolationScope); - - const spanData = spanToJSON(rootSpan); - - if (spanData.data && 'http.target' in spanData.data) { - pathname = spanData.data['http.target']?.toString(); - } } const headersDict = context.headers ? winterCGHeadersToDict(context.headers) : undefined; - let params: Record | undefined = undefined; - - if (getClient()?.getOptions().sendDefaultPii) { - const props: unknown = args[0]; - const { params: paramsFromProps } = maybeExtractSynchronousParamsAndSearchParams(props); - params = paramsFromProps; - } - isolationScope.setSDKProcessingMetadata({ normalizedRequest: { headers: headersDict, - url: getSanitizedRequestUrl(componentRoute, params, headersDict, pathname), } satisfies RequestEventData, }); From d4a2b2bc93f5d2be3d1b960f89b61e2e08e58ca4 Mon Sep 17 00:00:00 2001 From: Abdelrahman Awad Date: Fri, 7 Nov 2025 12:18:09 +0200 Subject: [PATCH 09/12] test(next): fix flakey tests (#18100) I can't reproduce the flakiness locally, I logged a few things on CI runs and it seems while the fetch spans does get created, it doesn't get created on the middletrasnaction. This is similar to what the note is saying in dev-mode, for it to be less flakey I'm asserting if it either has the span on the right transaction or if it got created in a separate transaction. Ideally we want it to be created within the middleware transaction but it seems like there is a timing issue preventing it from being picked up there. At any case this seems to reduce or eliminate the chances of failed runs, previously it would fail consistently but with this it didn't fail in 5 runs so far. --- .../nextjs-16/tests/middleware.test.ts | 93 ++++++++++++------- 1 file changed, 57 insertions(+), 36 deletions(-) diff --git a/dev-packages/e2e-tests/test-applications/nextjs-16/tests/middleware.test.ts b/dev-packages/e2e-tests/test-applications/nextjs-16/tests/middleware.test.ts index aa4611fb7afc..0bb957bbc466 100644 --- a/dev-packages/e2e-tests/test-applications/nextjs-16/tests/middleware.test.ts +++ b/dev-packages/e2e-tests/test-applications/nextjs-16/tests/middleware.test.ts @@ -62,9 +62,15 @@ test('Faulty middlewares', async ({ request }) => { test('Should trace outgoing fetch requests inside middleware and create breadcrumbs for it', async ({ request }) => { test.skip(isDevMode, 'The fetch requests ends up in a separate tx in dev atm'); const middlewareTransactionPromise = waitForTransaction('nextjs-16', async transactionEvent => { + return transactionEvent?.transaction === 'middleware GET'; + }); + + // In some builds (especially webpack), fetch spans may end up in a separate transaction instead of as child spans + // This test validates that the fetch is traced either way + const fetchTransactionPromise = waitForTransaction('nextjs-16', async transactionEvent => { return ( - transactionEvent?.transaction === 'middleware GET' && - !!transactionEvent.spans?.find(span => span.op === 'http.client') + transactionEvent?.transaction === 'GET http://localhost:3030/' || + transactionEvent?.contexts?.trace?.description === 'GET http://localhost:3030/' ); }); @@ -74,40 +80,7 @@ test('Should trace outgoing fetch requests inside middleware and create breadcru const middlewareTransaction = await middlewareTransactionPromise; - expect(middlewareTransaction.spans).toEqual( - expect.arrayContaining([ - { - data: { - 'http.request.method': 'GET', - 'http.request.method_original': 'GET', - 'http.response.status_code': 200, - 'network.peer.address': '::1', - 'network.peer.port': 3030, - 'otel.kind': 'CLIENT', - 'sentry.op': 'http.client', - 'sentry.origin': 'auto.http.otel.node_fetch', - 'server.address': 'localhost', - 'server.port': 3030, - url: 'http://localhost:3030/', - 'url.full': 'http://localhost:3030/', - 'url.path': '/', - 'url.query': '', - 'url.scheme': 'http', - 'user_agent.original': 'node', - }, - description: 'GET http://localhost:3030/', - op: 'http.client', - origin: 'auto.http.otel.node_fetch', - parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), - span_id: expect.stringMatching(/[a-f0-9]{16}/), - start_timestamp: expect.any(Number), - status: 'ok', - timestamp: expect.any(Number), - trace_id: expect.stringMatching(/[a-f0-9]{32}/), - }, - ]), - ); - + // Breadcrumbs should always be created for the fetch request expect(middlewareTransaction.breadcrumbs).toEqual( expect.arrayContaining([ { @@ -118,4 +91,52 @@ test('Should trace outgoing fetch requests inside middleware and create breadcru }, ]), ); + + // Check if http.client span exists as a child of the middleware transaction + const hasHttpClientSpan = !!middlewareTransaction.spans?.find(span => span.op === 'http.client'); + + if (hasHttpClientSpan) { + // Check if fetch is traced as a child span of the middleware transaction + expect(middlewareTransaction.spans).toEqual( + expect.arrayContaining([ + { + data: { + 'http.request.method': 'GET', + 'http.request.method_original': 'GET', + 'http.response.status_code': 200, + 'network.peer.address': '::1', + 'network.peer.port': 3030, + 'otel.kind': 'CLIENT', + 'sentry.op': 'http.client', + 'sentry.origin': 'auto.http.otel.node_fetch', + 'server.address': 'localhost', + 'server.port': 3030, + url: 'http://localhost:3030/', + 'url.full': 'http://localhost:3030/', + 'url.path': '/', + 'url.query': '', + 'url.scheme': 'http', + 'user_agent.original': 'node', + }, + description: 'GET http://localhost:3030/', + op: 'http.client', + origin: 'auto.http.otel.node_fetch', + parent_span_id: expect.stringMatching(/[a-f0-9]{16}/), + span_id: expect.stringMatching(/[a-f0-9]{16}/), + start_timestamp: expect.any(Number), + status: 'ok', + timestamp: expect.any(Number), + trace_id: expect.stringMatching(/[a-f0-9]{32}/), + }, + ]), + ); + } else { + // Alternatively, fetch is traced as a separate transaction, similar to Dev builds + const fetchTransaction = await fetchTransactionPromise; + + expect(fetchTransaction.contexts?.trace?.op).toBe('http.client'); + expect(fetchTransaction.contexts?.trace?.status).toBe('ok'); + expect(fetchTransaction.contexts?.trace?.data?.['http.request.method']).toBe('GET'); + expect(fetchTransaction.contexts?.trace?.data?.['url.full']).toBe('http://localhost:3030/'); + } }); From d26e1a93a1d72bf15dec5dbc9c5b73aea0cd452a Mon Sep 17 00:00:00 2001 From: Andrei <168741329+andreiborza@users.noreply.github.com> Date: Mon, 10 Nov 2025 10:05:16 +0100 Subject: [PATCH 10/12] feat(aws): Add `SENTRY_LAYER_EXTENSION` to configure using the lambda layer extension via env variables (#18101) Our recommended approach for the aws sdk is to use our Lambda layer. When the Lambda layer is used, it would previously automatically set up the layer extension. This can be disabled by setting `useLayerExtension: false` during init, but when using the layer with our auto-wrapping as per recommendation, it wasn't possible to opt out of using the extension. This PR adds `SENTRY_LAYER_EXTENSION` that can be used to opt out of the extension. --------- Co-authored-by: Lukas Stracke --- packages/aws-serverless/package.json | 1 + packages/aws-serverless/src/init.ts | 40 +++++++--- packages/aws-serverless/test/init.test.ts | 96 +++++++++++++++++++++++ 3 files changed, 124 insertions(+), 13 deletions(-) diff --git a/packages/aws-serverless/package.json b/packages/aws-serverless/package.json index b4763f675a35..ae86d94f73e1 100644 --- a/packages/aws-serverless/package.json +++ b/packages/aws-serverless/package.json @@ -71,6 +71,7 @@ "@opentelemetry/semantic-conventions": "^1.37.0", "@sentry/core": "10.23.0", "@sentry/node": "10.23.0", + "@sentry/node-core": "10.23.0", "@types/aws-lambda": "^8.10.62" }, "devDependencies": { diff --git a/packages/aws-serverless/src/init.ts b/packages/aws-serverless/src/init.ts index e19cc41baf46..25180a41f6e6 100644 --- a/packages/aws-serverless/src/init.ts +++ b/packages/aws-serverless/src/init.ts @@ -2,6 +2,7 @@ import type { Integration, Options } from '@sentry/core'; import { applySdkMetadata, debug, getSDKSource } from '@sentry/core'; import type { NodeClient, NodeOptions } from '@sentry/node'; import { getDefaultIntegrationsWithoutPerformance, initWithoutDefaultIntegrations } from '@sentry/node'; +import { envToBool } from '@sentry/node-core'; import { DEBUG_BUILD } from './debug-build'; import { awsIntegration } from './integration/aws'; import { awsLambdaIntegration } from './integration/awslambda'; @@ -54,7 +55,10 @@ export function getDefaultIntegrations(_options: Options): Integration[] { export interface AwsServerlessOptions extends NodeOptions { /** - * If Sentry events should be proxied through the Lambda extension when using the Lambda layer. Defaults to `true` when using the Lambda layer. + * If Sentry events should be proxied through the Lambda extension when using the Lambda layer. + * Defaults to `true` when using the Lambda layer. + * + * Can also be configured via the `SENTRY_LAYER_EXTENSION` environment variable. */ useLayerExtension?: boolean; } @@ -68,31 +72,41 @@ export function init(options: AwsServerlessOptions = {}): NodeClient | undefined const sdkSource = getSDKSource(); const proxyWouldInterfere = shouldDisableLayerExtensionForProxy(); + // Determine useLayerExtension value with the following priority: + // 1. Explicit option value (if provided) + // 2. Environment variable SENTRY_LAYER_EXTENSION (if set) + // 3. Default logic based on sdkSource, tunnel, and proxy settings + const useLayerExtensionFromEnv = envToBool(process.env.SENTRY_LAYER_EXTENSION, { strict: true }); + const defaultUseLayerExtension = sdkSource === 'aws-lambda-layer' && !options.tunnel && !proxyWouldInterfere; + const useLayerExtension = options.useLayerExtension ?? useLayerExtensionFromEnv ?? defaultUseLayerExtension; + const opts = { defaultIntegrations: getDefaultIntegrations(options), - useLayerExtension: sdkSource === 'aws-lambda-layer' && !options.tunnel && !proxyWouldInterfere, + useLayerExtension, ...options, }; if (opts.useLayerExtension) { - if (sdkSource === 'aws-lambda-layer') { - if (!opts.tunnel) { - DEBUG_BUILD && debug.log('Proxying Sentry events through the Sentry Lambda extension'); - opts.tunnel = 'http://localhost:9000/envelope'; - } else { + if (sdkSource !== 'aws-lambda-layer') { + DEBUG_BUILD && debug.warn('The Sentry Lambda extension is only supported when using the AWS Lambda layer.'); + } else if (opts.tunnel || proxyWouldInterfere) { + if (opts.tunnel) { DEBUG_BUILD && debug.warn( `Using a custom tunnel with the Sentry Lambda extension is not supported. Events will be tunnelled to ${opts.tunnel} and not through the extension.`, ); } + + if (proxyWouldInterfere) { + DEBUG_BUILD && + debug.warn( + 'Sentry Lambda extension is disabled due to proxy environment variables (http_proxy/https_proxy). Consider adding localhost to no_proxy to re-enable.', + ); + } } else { - DEBUG_BUILD && debug.warn('The Sentry Lambda extension is only supported when using the AWS Lambda layer.'); + DEBUG_BUILD && debug.log('Proxying Sentry events through the Sentry Lambda extension'); + opts.tunnel = 'http://localhost:9000/envelope'; } - } else if (sdkSource === 'aws-lambda-layer' && proxyWouldInterfere) { - DEBUG_BUILD && - debug.warn( - 'Sentry Lambda extension disabled due to proxy environment variables (http_proxy/https_proxy). Consider adding localhost to no_proxy to re-enable.', - ); } applySdkMetadata(opts, 'aws-serverless', ['aws-serverless'], sdkSource); diff --git a/packages/aws-serverless/test/init.test.ts b/packages/aws-serverless/test/init.test.ts index e6a675ecc43f..500338dc7144 100644 --- a/packages/aws-serverless/test/init.test.ts +++ b/packages/aws-serverless/test/init.test.ts @@ -19,9 +19,13 @@ const mockInitWithoutDefaultIntegrations = vi.mocked(initWithoutDefaultIntegrati describe('init', () => { beforeEach(() => { + // Clear all mocks between tests + vi.clearAllMocks(); + // Clean up environment variables between tests delete process.env.http_proxy; delete process.env.no_proxy; + delete process.env.SENTRY_LAYER_EXTENSION; }); describe('Lambda extension setup', () => { @@ -386,4 +390,96 @@ describe('init', () => { ); }); }); + + describe('SENTRY_LAYER_EXTENSION environment variable', () => { + test('should enable useLayerExtension when SENTRY_LAYER_EXTENSION=true', () => { + process.env.SENTRY_LAYER_EXTENSION = 'true'; + mockGetSDKSource.mockReturnValue('aws-lambda-layer'); + const options: AwsServerlessOptions = {}; + + init(options); + + expect(mockInitWithoutDefaultIntegrations).toHaveBeenCalledWith( + expect.objectContaining({ + useLayerExtension: true, + tunnel: 'http://localhost:9000/envelope', + }), + ); + }); + + test('should disable useLayerExtension when SENTRY_LAYER_EXTENSION=false', () => { + process.env.SENTRY_LAYER_EXTENSION = 'false'; + mockGetSDKSource.mockReturnValue('aws-lambda-layer'); + const options: AwsServerlessOptions = {}; + + init(options); + + expect(mockInitWithoutDefaultIntegrations).toHaveBeenCalledWith( + expect.objectContaining({ + useLayerExtension: false, + }), + ); + expect(mockInitWithoutDefaultIntegrations).toHaveBeenCalledWith( + expect.not.objectContaining({ + tunnel: expect.any(String), + }), + ); + }); + + test('should fall back to default behavior when SENTRY_LAYER_EXTENSION is not set', () => { + mockGetSDKSource.mockReturnValue('aws-lambda-layer'); + const options: AwsServerlessOptions = {}; + + init(options); + + expect(mockInitWithoutDefaultIntegrations).toHaveBeenCalledWith( + expect.objectContaining({ + useLayerExtension: true, + tunnel: 'http://localhost:9000/envelope', + }), + ); + }); + + test('should prioritize explicit option over environment variable', () => { + process.env.SENTRY_LAYER_EXTENSION = 'true'; + mockGetSDKSource.mockReturnValue('aws-lambda-layer'); + const options: AwsServerlessOptions = { + useLayerExtension: false, + }; + + init(options); + + expect(mockInitWithoutDefaultIntegrations).toHaveBeenCalledWith( + expect.objectContaining({ + useLayerExtension: false, + }), + ); + expect(mockInitWithoutDefaultIntegrations).toHaveBeenCalledWith( + expect.not.objectContaining({ + tunnel: expect.any(String), + }), + ); + }); + + test('should not set tunnel even tho useLayerExtension is set via env var when proxy is explicitly set', () => { + process.env.http_proxy = 'http://proxy.example.com:8080'; + process.env.SENTRY_LAYER_EXTENSION = 'true'; + mockGetSDKSource.mockReturnValue('aws-lambda-layer'); + const options: AwsServerlessOptions = {}; + + init(options); + + // useLayerExtension is respected but tunnel is not set due to proxy interference + expect(mockInitWithoutDefaultIntegrations).toHaveBeenCalledWith( + expect.objectContaining({ + useLayerExtension: true, + }), + ); + expect(mockInitWithoutDefaultIntegrations).toHaveBeenCalledWith( + expect.not.objectContaining({ + tunnel: expect.any(String), + }), + ); + }); + }); }); From 10211f432addf326d36fc168be59924e4ccaca43 Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Mon, 10 Nov 2025 10:40:19 +0100 Subject: [PATCH 11/12] fix(nextjs): Delete css map files (#18131) closes https://github.com/getsentry/sentry-javascript/issues/18125 We want to delete `*.map.css` files when `deleteSourcemapsAfterUpload` is enabled. --- packages/nextjs/src/config/getBuildPluginOptions.ts | 2 +- packages/nextjs/test/config/getBuildPluginOptions.test.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/nextjs/src/config/getBuildPluginOptions.ts b/packages/nextjs/src/config/getBuildPluginOptions.ts index 6de802917015..e36e88802fa5 100644 --- a/packages/nextjs/src/config/getBuildPluginOptions.ts +++ b/packages/nextjs/src/config/getBuildPluginOptions.ts @@ -40,7 +40,7 @@ const FILE_PATTERNS = { } as const; // Source map file extensions to delete -const SOURCEMAP_EXTENSIONS = ['*.js.map', '*.mjs.map', '*.cjs.map'] as const; +const SOURCEMAP_EXTENSIONS = ['*.js.map', '*.mjs.map', '*.cjs.map', '*.css.map'] as const; type BuildTool = keyof typeof LOGGER_PREFIXES; diff --git a/packages/nextjs/test/config/getBuildPluginOptions.test.ts b/packages/nextjs/test/config/getBuildPluginOptions.test.ts index 0281624584d0..609183d198bb 100644 --- a/packages/nextjs/test/config/getBuildPluginOptions.test.ts +++ b/packages/nextjs/test/config/getBuildPluginOptions.test.ts @@ -308,6 +308,7 @@ describe('getBuildPluginOptions', () => { '/path/to/.next/static/**/*.js.map', '/path/to/.next/static/**/*.mjs.map', '/path/to/.next/static/**/*.cjs.map', + '/path/to/.next/static/**/*.css.map', ]); }); @@ -331,6 +332,7 @@ describe('getBuildPluginOptions', () => { '/path/to/.next/static/**/*.js.map', '/path/to/.next/static/**/*.mjs.map', '/path/to/.next/static/**/*.cjs.map', + '/path/to/.next/static/**/*.css.map', ]); }); @@ -355,6 +357,7 @@ describe('getBuildPluginOptions', () => { '/path/to/.next/static/**/*.js.map', '/path/to/.next/static/**/*.mjs.map', '/path/to/.next/static/**/*.cjs.map', + '/path/to/.next/static/**/*.css.map', ]); }); @@ -788,6 +791,7 @@ describe('getBuildPluginOptions', () => { `${complexPath}/static/**/*.js.map`, `${complexPath}/static/**/*.mjs.map`, `${complexPath}/static/**/*.cjs.map`, + `${complexPath}/static/**/*.css.map`, ]); }); }); From 0054094bbc1f1634a06f45618009f9f6302f8fc4 Mon Sep 17 00:00:00 2001 From: Charly Gomez Date: Mon, 10 Nov 2025 11:11:55 +0100 Subject: [PATCH 12/12] meta(changelog): Update changelog for 10.24.0 --- CHANGELOG.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c98188d73b5c..0f98b440d47d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,34 @@ - "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott +## 10.24.0 + +### Important Changes + +- **feat(metrics): Add top level option `enableMetrics` and `beforeSendMetric` ([#18088](https://github.com/getsentry/sentry-javascript/pull/18088))** + + This PR moves `enableMetrics` and `beforeSendMetric` out of the `_experiments` options. + The metrics feature will now be **enabled by default** (none of our integrations will auto-emit metrics as of now), but you can disable sending metrics via `enableMetrics: false`. + Metric options within `_experiments` got deprecated but will still work as of now, they will be removed with the next major version of our SDKs. + +### Other Changes + +- feat(aws): Add `SENTRY_LAYER_EXTENSION` to configure using the lambda layer extension via env variables ([#18101](https://github.com/getsentry/sentry-javascript/pull/18101)) +- feat(core): Include all exception object keys instead of truncating ([#18044](https://github.com/getsentry/sentry-javascript/pull/18044)) +- feat(metrics)!: Update types ([#17907](https://github.com/getsentry/sentry-javascript/pull/17907)) +- feat(replay): ignore `background-image` when `blockAllMedia` is enabled ([#18019](https://github.com/getsentry/sentry-javascript/pull/18019)) +- fix(nextjs): Delete css map files ([#18131](https://github.com/getsentry/sentry-javascript/pull/18131)) +- fix(nextjs): Stop accessing sync props in template ([#18113](https://github.com/getsentry/sentry-javascript/pull/18113)) + +
+ Internal Changes + +- chore: X handle update ([#18117](https://github.com/getsentry/sentry-javascript/pull/18117)) +- chore(eslint): Add eslint-plugin-regexp rule (dev-packages) ([#18063](https://github.com/getsentry/sentry-javascript/pull/18063)) +- test(next): fix flakey tests ([#18100](https://github.com/getsentry/sentry-javascript/pull/18100)) +- test(node-core): Proof that withMonitor doesn't create a new trace ([#18057](https://github.com/getsentry/sentry-javascript/pull/18057)) +
+ ## 10.23.0 - feat(core): Send `user-agent` header with envelope requests in server SDKs ([#17929](https://github.com/getsentry/sentry-javascript/pull/17929))