From 7cdc88dbd2c3d56acec540a68892b8f12fabe168 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Tue, 20 May 2025 13:45:47 +0200
Subject: [PATCH 1/6] feat(deps): bump @sentry/rollup-plugin from 3.1.2 to
3.2.1 (#15511)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Bumps
[@sentry/rollup-plugin](https://github.com/getsentry/sentry-javascript-bundler-plugins)
from 3.1.2 to 3.2.1.
Release notes
Sourced from @sentry/rollup-plugin
's
releases.
3.2.1
- deps: Bump
@sentry/cli
to 2.42.2 (#685)
3.2.0
- feat(core): Accept and await a promise in
sourcemaps.filesToDeleteAfterUpload
(#677)
Changelog
Sourced from @sentry/rollup-plugin
's
changelog.
3.2.1
- deps: Bump
@sentry/cli
to 2.42.2 (#685)
3.2.0
- feat(core): Accept and await a promise in
sourcemaps.filesToDeleteAfterUpload
(#677)
Commits
4c79586
release: 3.2.1
0968db9
deps: Bump @sentry/cli
to 2.42.2
(#685)
c72d4df
docs: Add react component name to readme feature list (#684)
ac96af1
Merge branch 'release/3.2.0'
9ce301a
release: 3.2.0
a650878
meta: Update changelog for 3.2.0 (#678)
4255012
feat(core): Accept and await a promise in
`sourcemaps.filesToDeleteAfterUploa...
7e71b59
Merge branch 'release/3.1.2'
- See full diff in compare
view
[](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
You can trigger a rebase of this PR by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
Dependabot commands and options
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
> **Note**
> Automatic rebases have been disabled on this pull request as it has
been open for over 30 days.
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
packages/nuxt/package.json | 2 +-
yarn.lock | 30 +++++++++++++++++++++++++-----
2 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/packages/nuxt/package.json b/packages/nuxt/package.json
index 6e35dc95bab2..1c6f3c853fa2 100644
--- a/packages/nuxt/package.json
+++ b/packages/nuxt/package.json
@@ -47,7 +47,7 @@
"@sentry/core": "9.20.0",
"@sentry/node": "9.20.0",
"@sentry/opentelemetry": "9.20.0",
- "@sentry/rollup-plugin": "3.2.4",
+ "@sentry/rollup-plugin": "3.4.0",
"@sentry/vite-plugin": "3.2.4",
"@sentry/vue": "9.20.0"
},
diff --git a/yarn.lock b/yarn.lock
index b9faa5f80dab..259abebcb21b 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -6479,6 +6479,11 @@
resolved "https://registry.yarnpkg.com/@sentry/babel-plugin-component-annotate/-/babel-plugin-component-annotate-3.3.1.tgz#baecd89396cbb4659565a4e8efe7f0a71b19262a"
integrity sha512-5GOxGT7lZN+I8A7Vp0rWY+726FDKEw8HnFiebe51rQrMbfGfCu2Aw9uSM0nT9OG6xhV6WvGccIcCszTPs4fUZQ==
+"@sentry/babel-plugin-component-annotate@3.4.0":
+ version "3.4.0"
+ resolved "https://registry.yarnpkg.com/@sentry/babel-plugin-component-annotate/-/babel-plugin-component-annotate-3.4.0.tgz#f47a7652e16f84556df82cbc38f0004bca1335d1"
+ integrity sha512-tSzfc3aE7m0PM0Aj7HBDet5llH9AB9oc+tBQ8AvOqUSnWodLrNCuWeQszJ7mIBovD3figgCU3h0cvI6U5cDtsg==
+
"@sentry/bundler-plugin-core@2.22.6":
version "2.22.6"
resolved "https://registry.yarnpkg.com/@sentry/bundler-plugin-core/-/bundler-plugin-core-2.22.6.tgz#a1ea1fd43700a3ece9e7db016997e79a2782b87d"
@@ -6521,6 +6526,20 @@
magic-string "0.30.8"
unplugin "1.0.1"
+"@sentry/bundler-plugin-core@3.4.0":
+ version "3.4.0"
+ resolved "https://registry.yarnpkg.com/@sentry/bundler-plugin-core/-/bundler-plugin-core-3.4.0.tgz#3a3459aba94cbeb093347f5730f15df25153fd0a"
+ integrity sha512-X1Q41AsQ6xcT6hB4wYmBDBukndKM/inT4IsR7pdKLi7ICpX2Qq6lisamBAEPCgEvnLpazSFguaiC0uiwMKAdqw==
+ dependencies:
+ "@babel/core" "^7.18.5"
+ "@sentry/babel-plugin-component-annotate" "3.4.0"
+ "@sentry/cli" "2.42.2"
+ dotenv "^16.3.1"
+ find-up "^5.0.0"
+ glob "^9.3.2"
+ magic-string "0.30.8"
+ unplugin "1.0.1"
+
"@sentry/cli-darwin@2.42.2":
version "2.42.2"
resolved "https://registry.yarnpkg.com/@sentry/cli-darwin/-/cli-darwin-2.42.2.tgz#a32a4f226e717122b37d9969e8d4d0e14779f720"
@@ -6635,12 +6654,12 @@
"@sentry/cli-win32-i686" "2.43.0"
"@sentry/cli-win32-x64" "2.43.0"
-"@sentry/rollup-plugin@3.2.4":
- version "3.2.4"
- resolved "https://registry.yarnpkg.com/@sentry/rollup-plugin/-/rollup-plugin-3.2.4.tgz#aa07424b3ffc582e471f9af5d933e663b7ba3ff5"
- integrity sha512-ZWTT1mc1OiROdRbXX9zTGXvdWpHwMyPJjKsI4+sT/ohwTU3/nh8yGw6+VTxOkrsZj72+p2OcAfpO7Yv/gUP9Yg==
+"@sentry/rollup-plugin@3.4.0":
+ version "3.4.0"
+ resolved "https://registry.yarnpkg.com/@sentry/rollup-plugin/-/rollup-plugin-3.4.0.tgz#326618d6fe91a030ee4ab335e1bab35f201090b0"
+ integrity sha512-oqDcjV+aaTZZ7oOadk90KlShOYfKEEQsvbZtzHl7HPHNt5kmtTaQyWphPIDt2Z9OCK8QF5T8GLsr1MCOXJ6vqA==
dependencies:
- "@sentry/bundler-plugin-core" "3.2.4"
+ "@sentry/bundler-plugin-core" "3.4.0"
unplugin "1.0.1"
"@sentry/vite-plugin@2.22.6", "@sentry/vite-plugin@^2.22.6":
@@ -27096,6 +27115,7 @@ stylus@0.59.0, stylus@^0.59.0:
sucrase@^3.27.0, sucrase@^3.35.0, sucrase@getsentry/sucrase#es2020-polyfills:
version "3.36.0"
+ uid fd682f6129e507c00bb4e6319cc5d6b767e36061
resolved "https://codeload.github.com/getsentry/sucrase/tar.gz/fd682f6129e507c00bb4e6319cc5d6b767e36061"
dependencies:
"@jridgewell/gen-mapping" "^0.3.2"
From 90cb4d1d9f679962d2aa852031c580b36bfd562f Mon Sep 17 00:00:00 2001
From: Onur Temizkan
Date: Tue, 20 May 2025 13:02:20 +0100
Subject: [PATCH 2/6] test(node): Add `pg-native` tests (#15465)
Moved the `pg` and `pg-native` dependencies inside the test suite. This
keeps `libpq` out of the root `yarn.lock`.
---
.../node-integration-tests/package.json | 2 +-
.../tracing/postgres/docker-compose.yml | 2 +-
.../suites/tracing/postgres/package.json | 16 +++
.../tracing/postgres/scenario-native.js | 48 +++++++
.../suites/tracing/postgres/scenario.js | 2 +-
.../suites/tracing/postgres/test.ts | 63 ++++++++-
.../suites/tracing/postgres/yarn.lock | 124 ++++++++++++++++++
yarn.lock | 80 ++++++-----
8 files changed, 289 insertions(+), 48 deletions(-)
create mode 100644 dev-packages/node-integration-tests/suites/tracing/postgres/package.json
create mode 100644 dev-packages/node-integration-tests/suites/tracing/postgres/scenario-native.js
create mode 100644 dev-packages/node-integration-tests/suites/tracing/postgres/yarn.lock
diff --git a/dev-packages/node-integration-tests/package.json b/dev-packages/node-integration-tests/package.json
index 6af9b2485cf5..54c19a4fe3fa 100644
--- a/dev-packages/node-integration-tests/package.json
+++ b/dev-packages/node-integration-tests/package.json
@@ -60,7 +60,7 @@
"nock": "^13.5.5",
"node-cron": "^3.0.3",
"node-schedule": "^2.1.1",
- "pg": "^8.7.3",
+ "pg": "8.16.0",
"proxy": "^2.1.1",
"redis-4": "npm:redis@^4.6.14",
"reflect-metadata": "0.2.1",
diff --git a/dev-packages/node-integration-tests/suites/tracing/postgres/docker-compose.yml b/dev-packages/node-integration-tests/suites/tracing/postgres/docker-compose.yml
index dac954ad81d7..51d9b86d028f 100644
--- a/dev-packages/node-integration-tests/suites/tracing/postgres/docker-compose.yml
+++ b/dev-packages/node-integration-tests/suites/tracing/postgres/docker-compose.yml
@@ -6,7 +6,7 @@ services:
restart: always
container_name: integration-tests-postgres
ports:
- - '5444:5432'
+ - '5494:5432'
environment:
POSTGRES_USER: test
POSTGRES_PASSWORD: test
diff --git a/dev-packages/node-integration-tests/suites/tracing/postgres/package.json b/dev-packages/node-integration-tests/suites/tracing/postgres/package.json
new file mode 100644
index 000000000000..602eab3a6f3d
--- /dev/null
+++ b/dev-packages/node-integration-tests/suites/tracing/postgres/package.json
@@ -0,0 +1,16 @@
+{
+ "name": "sentry-postgres-test",
+ "version": "1.0.0",
+ "description": "",
+ "main": "index.js",
+ "engines": {
+ "node": ">=18"
+ },
+ "keywords": [],
+ "author": "",
+ "license": "ISC",
+ "dependencies": {
+ "pg": "8.16.0",
+ "pg-native": "3.5.0"
+ }
+}
diff --git a/dev-packages/node-integration-tests/suites/tracing/postgres/scenario-native.js b/dev-packages/node-integration-tests/suites/tracing/postgres/scenario-native.js
new file mode 100644
index 000000000000..6c68f4b64562
--- /dev/null
+++ b/dev-packages/node-integration-tests/suites/tracing/postgres/scenario-native.js
@@ -0,0 +1,48 @@
+const { loggingTransport } = require('@sentry-internal/node-integration-tests');
+const Sentry = require('@sentry/node');
+
+Sentry.init({
+ dsn: 'https://public@dsn.ingest.sentry.io/1337',
+ release: '1.0',
+ tracesSampleRate: 1.0,
+ transport: loggingTransport,
+});
+
+// Stop the process from exiting before the transaction is sent
+setInterval(() => {}, 1000);
+
+const { native } = require('pg');
+
+const { Client } = native;
+
+const client = new Client({ port: 5494, user: 'test', password: 'test', database: 'tests' });
+
+async function run() {
+ await Sentry.startSpan(
+ {
+ name: 'Test Transaction',
+ op: 'transaction',
+ },
+ async () => {
+ try {
+ await client.connect();
+
+ await client
+ .query(
+ 'CREATE TABLE "NativeUser" ("id" SERIAL NOT NULL,"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,"email" TEXT NOT NULL,"name" TEXT,CONSTRAINT "User_pkey" PRIMARY KEY ("id"));',
+ )
+ .catch(() => {
+ // if this is not a fresh database, the table might already exist
+ });
+
+ await client.query('INSERT INTO "NativeUser" ("email", "name") VALUES ($1, $2)', ['tim', 'tim@domain.com']);
+ await client.query('SELECT * FROM "NativeUser"');
+ } finally {
+ await client.end();
+ }
+ },
+ );
+}
+
+// eslint-disable-next-line @typescript-eslint/no-floating-promises
+run();
diff --git a/dev-packages/node-integration-tests/suites/tracing/postgres/scenario.js b/dev-packages/node-integration-tests/suites/tracing/postgres/scenario.js
index 20dc9fe738ad..4f4e2d56b39b 100644
--- a/dev-packages/node-integration-tests/suites/tracing/postgres/scenario.js
+++ b/dev-packages/node-integration-tests/suites/tracing/postgres/scenario.js
@@ -13,7 +13,7 @@ setInterval(() => {}, 1000);
const { Client } = require('pg');
-const client = new Client({ port: 5444, user: 'test', password: 'test', database: 'tests' });
+const client = new Client({ port: 5494, user: 'test', password: 'test', database: 'tests' });
async function run() {
await Sentry.startSpan(
diff --git a/dev-packages/node-integration-tests/suites/tracing/postgres/test.ts b/dev-packages/node-integration-tests/suites/tracing/postgres/test.ts
index c34619e161ad..b0d0649a1ac9 100644
--- a/dev-packages/node-integration-tests/suites/tracing/postgres/test.ts
+++ b/dev-packages/node-integration-tests/suites/tracing/postgres/test.ts
@@ -2,7 +2,7 @@ import { describe, expect, test } from 'vitest';
import { createRunner } from '../../../utils/runner';
describe('postgres auto instrumentation', () => {
- test('should auto-instrument `pg` package', { timeout: 60_000 }, async () => {
+ test('should auto-instrument `pg` package', { timeout: 90_000 }, async () => {
const EXPECTED_TRANSACTION = {
transaction: 'Test Transaction',
spans: expect.arrayContaining([
@@ -47,7 +47,66 @@ describe('postgres auto instrumentation', () => {
};
await createRunner(__dirname, 'scenario.js')
- .withDockerCompose({ workingDirectory: [__dirname], readyMatches: ['port 5432'] })
+ .withDockerCompose({
+ workingDirectory: [__dirname],
+ readyMatches: ['port 5432'],
+ setupCommand: 'yarn',
+ })
+ .expect({ transaction: EXPECTED_TRANSACTION })
+ .start()
+ .completed();
+ });
+
+ test('should auto-instrument `pg-native` package', { timeout: 90_000 }, async () => {
+ const EXPECTED_TRANSACTION = {
+ transaction: 'Test Transaction',
+ spans: expect.arrayContaining([
+ expect.objectContaining({
+ data: expect.objectContaining({
+ 'db.system': 'postgresql',
+ 'db.name': 'tests',
+ 'sentry.origin': 'manual',
+ 'sentry.op': 'db',
+ }),
+ description: 'pg.connect',
+ op: 'db',
+ status: 'ok',
+ }),
+ expect.objectContaining({
+ data: expect.objectContaining({
+ 'db.system': 'postgresql',
+ 'db.name': 'tests',
+ 'db.statement': 'INSERT INTO "NativeUser" ("email", "name") VALUES ($1, $2)',
+ 'sentry.origin': 'auto.db.otel.postgres',
+ 'sentry.op': 'db',
+ }),
+ description: 'INSERT INTO "NativeUser" ("email", "name") VALUES ($1, $2)',
+ op: 'db',
+ status: 'ok',
+ origin: 'auto.db.otel.postgres',
+ }),
+ expect.objectContaining({
+ data: expect.objectContaining({
+ 'db.system': 'postgresql',
+ 'db.name': 'tests',
+ 'db.statement': 'SELECT * FROM "NativeUser"',
+ 'sentry.origin': 'auto.db.otel.postgres',
+ 'sentry.op': 'db',
+ }),
+ description: 'SELECT * FROM "NativeUser"',
+ op: 'db',
+ status: 'ok',
+ origin: 'auto.db.otel.postgres',
+ }),
+ ]),
+ };
+
+ await createRunner(__dirname, 'scenario-native.js')
+ .withDockerCompose({
+ workingDirectory: [__dirname],
+ readyMatches: ['port 5432'],
+ setupCommand: 'yarn',
+ })
.expect({ transaction: EXPECTED_TRANSACTION })
.start()
.completed();
diff --git a/dev-packages/node-integration-tests/suites/tracing/postgres/yarn.lock b/dev-packages/node-integration-tests/suites/tracing/postgres/yarn.lock
new file mode 100644
index 000000000000..9eb59e69f6c2
--- /dev/null
+++ b/dev-packages/node-integration-tests/suites/tracing/postgres/yarn.lock
@@ -0,0 +1,124 @@
+# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
+# yarn lockfile v1
+
+
+bindings@1.5.0:
+ version "1.5.0"
+ resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.5.0.tgz#10353c9e945334bc0511a6d90b38fbc7c9c504df"
+ integrity sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==
+ dependencies:
+ file-uri-to-path "1.0.0"
+
+file-uri-to-path@1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd"
+ integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==
+
+libpq@^1.8.15:
+ version "1.8.15"
+ resolved "https://registry.yarnpkg.com/libpq/-/libpq-1.8.15.tgz#bf9cea8e59e1a4a911d06df01d408213a09925ad"
+ integrity sha512-4lSWmly2Nsj3LaTxxtFmJWuP3Kx+0hYHEd+aNrcXEWT0nKWaPd9/QZPiMkkC680zeALFGHQdQWjBvnilL+vgWA==
+ dependencies:
+ bindings "1.5.0"
+ nan "~2.22.2"
+
+nan@~2.22.2:
+ version "2.22.2"
+ resolved "https://registry.yarnpkg.com/nan/-/nan-2.22.2.tgz#6b504fd029fb8f38c0990e52ad5c26772fdacfbb"
+ integrity sha512-DANghxFkS1plDdRsX0X9pm0Z6SJNN6gBdtXfanwoZ8hooC5gosGFSBGRYHUVPz1asKA/kMRqDRdHrluZ61SpBQ==
+
+pg-cloudflare@^1.2.5:
+ version "1.2.5"
+ resolved "https://registry.yarnpkg.com/pg-cloudflare/-/pg-cloudflare-1.2.5.tgz#2e3649c38a7a9c74a7e5327c8098a2fd9af595bd"
+ integrity sha512-OOX22Vt0vOSRrdoUPKJ8Wi2OpE/o/h9T8X1s4qSkCedbNah9ei2W2765be8iMVxQUsvgT7zIAT2eIa9fs5+vtg==
+
+pg-connection-string@^2.9.0:
+ version "2.9.0"
+ resolved "https://registry.yarnpkg.com/pg-connection-string/-/pg-connection-string-2.9.0.tgz#f75e06591fdd42ec7636fe2c6a03febeedbec9bf"
+ integrity sha512-P2DEBKuvh5RClafLngkAuGe9OUlFV7ebu8w1kmaaOgPcpJd1RIFh7otETfI6hAR8YupOLFTY7nuvvIn7PLciUQ==
+
+pg-int8@1.0.1:
+ version "1.0.1"
+ resolved "https://registry.yarnpkg.com/pg-int8/-/pg-int8-1.0.1.tgz#943bd463bf5b71b4170115f80f8efc9a0c0eb78c"
+ integrity sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==
+
+pg-native@3.5.0:
+ version "3.5.0"
+ resolved "https://registry.yarnpkg.com/pg-native/-/pg-native-3.5.0.tgz#1a43c0d5f5744e40df3bf737c43178ce98984255"
+ integrity sha512-rj4LYouevTdKxvRLnvtOLEPOerkiPAqUdZE1K48IfQluEH/x7GrldEDdSaEOmJ6z7s6LQwDTpAPhm2s00iG8xw==
+ dependencies:
+ libpq "^1.8.15"
+ pg-types "2.2.0"
+
+pg-pool@^3.10.0:
+ version "3.10.0"
+ resolved "https://registry.yarnpkg.com/pg-pool/-/pg-pool-3.10.0.tgz#134b0213755c5e7135152976488aa7cd7ee1268d"
+ integrity sha512-DzZ26On4sQ0KmqnO34muPcmKbhrjmyiO4lCCR0VwEd7MjmiKf5NTg/6+apUEu0NF7ESa37CGzFxH513CoUmWnA==
+
+pg-protocol@^1.10.0:
+ version "1.10.0"
+ resolved "https://registry.yarnpkg.com/pg-protocol/-/pg-protocol-1.10.0.tgz#a473afcbb1c6e5dc3ac24869ba3dd563f8a1ae1b"
+ integrity sha512-IpdytjudNuLv8nhlHs/UrVBhU0e78J0oIS/0AVdTbWxSOkFUVdsHC/NrorO6nXsQNDTT1kzDSOMJubBQviX18Q==
+
+pg-types@2.2.0:
+ version "2.2.0"
+ resolved "https://registry.yarnpkg.com/pg-types/-/pg-types-2.2.0.tgz#2d0250d636454f7cfa3b6ae0382fdfa8063254a3"
+ integrity sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==
+ dependencies:
+ pg-int8 "1.0.1"
+ postgres-array "~2.0.0"
+ postgres-bytea "~1.0.0"
+ postgres-date "~1.0.4"
+ postgres-interval "^1.1.0"
+
+pg@8.16.0:
+ version "8.16.0"
+ resolved "https://registry.yarnpkg.com/pg/-/pg-8.16.0.tgz#40b08eedb5eb1834252cf3e3629503e32e6c6c04"
+ integrity sha512-7SKfdvP8CTNXjMUzfcVTaI+TDzBEeaUnVwiVGZQD1Hh33Kpev7liQba9uLd4CfN8r9mCVsD0JIpq03+Unpz+kg==
+ dependencies:
+ pg-connection-string "^2.9.0"
+ pg-pool "^3.10.0"
+ pg-protocol "^1.10.0"
+ pg-types "2.2.0"
+ pgpass "1.0.5"
+ optionalDependencies:
+ pg-cloudflare "^1.2.5"
+
+pgpass@1.0.5:
+ version "1.0.5"
+ resolved "https://registry.yarnpkg.com/pgpass/-/pgpass-1.0.5.tgz#9b873e4a564bb10fa7a7dbd55312728d422a223d"
+ integrity sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==
+ dependencies:
+ split2 "^4.1.0"
+
+postgres-array@~2.0.0:
+ version "2.0.0"
+ resolved "https://registry.yarnpkg.com/postgres-array/-/postgres-array-2.0.0.tgz#48f8fce054fbc69671999329b8834b772652d82e"
+ integrity sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==
+
+postgres-bytea@~1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/postgres-bytea/-/postgres-bytea-1.0.0.tgz#027b533c0aa890e26d172d47cf9ccecc521acd35"
+ integrity sha512-xy3pmLuQqRBZBXDULy7KbaitYqLcmxigw14Q5sj8QBVLqEwXfeybIKVWiqAXTlcvdvb0+xkOtDbfQMOf4lST1w==
+
+postgres-date@~1.0.4:
+ version "1.0.7"
+ resolved "https://registry.yarnpkg.com/postgres-date/-/postgres-date-1.0.7.tgz#51bc086006005e5061c591cee727f2531bf641a8"
+ integrity sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==
+
+postgres-interval@^1.1.0:
+ version "1.2.0"
+ resolved "https://registry.yarnpkg.com/postgres-interval/-/postgres-interval-1.2.0.tgz#b460c82cb1587507788819a06aa0fffdb3544695"
+ integrity sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==
+ dependencies:
+ xtend "^4.0.0"
+
+split2@^4.1.0:
+ version "4.2.0"
+ resolved "https://registry.yarnpkg.com/split2/-/split2-4.2.0.tgz#c9c5920904d148bab0b9f67145f245a86aadbfa4"
+ integrity sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==
+
+xtend@^4.0.0:
+ version "4.0.2"
+ resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54"
+ integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==
diff --git a/yarn.lock b/yarn.lock
index 259abebcb21b..67dbf24aac88 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -11281,11 +11281,6 @@ buffer-more-ints@~1.0.0:
resolved "https://registry.yarnpkg.com/buffer-more-ints/-/buffer-more-ints-1.0.0.tgz#ef4f8e2dddbad429ed3828a9c55d44f05c611422"
integrity sha512-EMetuGFz5SLsT0QTnXzINh4Ksr+oo4i+UGTXEshiGCQWnsgSs7ZhJ8fzlwQ+OzEMs0MpDAMr1hxnblp5a4vcHg==
-buffer-writer@2.0.0:
- version "2.0.0"
- resolved "https://registry.yarnpkg.com/buffer-writer/-/buffer-writer-2.0.0.tgz#ce7eb81a38f7829db09c873f2fbb792c0c98ec04"
- integrity sha512-a7ZpuTZU1TRtnwyCNW3I5dc0wWNC3VR9S++Ewyk2HHZdrO3CQJqSpd+95Us590V6AL7JqUAH2IwZ/398PmNFgw==
-
buffer@^5.5.0:
version "5.7.1"
resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0"
@@ -15453,11 +15448,6 @@ expect-type@^1.1.0:
resolved "https://registry.yarnpkg.com/expect-type/-/expect-type-1.1.0.tgz#a146e414250d13dfc49eafcfd1344a4060fa4c75"
integrity sha512-bFi65yM+xZgk+u/KRIpekdSYkTB5W1pEf0Lt8Q8Msh7b+eQ7LXVtIB1Bkm4fvclDEL1b2CZkMhv2mOeF8tMdkA==
-exponential-backoff@^3.1.1:
- version "3.1.1"
- resolved "https://registry.yarnpkg.com/exponential-backoff/-/exponential-backoff-3.1.1.tgz#64ac7526fe341ab18a39016cd22c787d01e00bf6"
- integrity sha512-dX7e/LHVJ6W3DE1MHWi9S1EYzDESENfLrYohG2G++ovZrYOkm4Knwa0mc1cn84xJOR4KEU0WSchhLbd0UklbHw==
-
express@4.21.1, express@^4.10.7, express@^4.17.1, express@^4.17.3, express@^4.18.1, express@^4.21.1:
version "4.21.1"
resolved "https://registry.yarnpkg.com/express/-/express-4.21.1.tgz#9dae5dda832f16b4eec941a4e44aa89ec481b281"
@@ -21691,12 +21681,11 @@ node-gyp-build@^4.2.2, node-gyp-build@^4.3.0:
integrity sha512-NTZVKn9IylLwUzaKjkas1e4u2DLNcV4rdYagA4PWdPwW87Bi7z+BznyKSRwS/761tV/lzCGXplWsiaMjLqP2zQ==
node-gyp@^9.0.0:
- version "9.4.1"
- resolved "https://registry.yarnpkg.com/node-gyp/-/node-gyp-9.4.1.tgz#8a1023e0d6766ecb52764cc3a734b36ff275e185"
- integrity sha512-OQkWKbjQKbGkMf/xqI1jjy3oCTgMKJac58G2+bjZb3fza6gW2YrCSdMQYaoTb70crvE//Gngr4f0AgVHmqHvBQ==
+ version "9.3.0"
+ resolved "https://registry.yarnpkg.com/node-gyp/-/node-gyp-9.3.0.tgz#f8eefe77f0ad8edb3b3b898409b53e697642b319"
+ integrity sha512-A6rJWfXFz7TQNjpldJ915WFb1LnhO4lIve3ANPbWreuEoLoKlFT3sxIepPBkLhM27crW8YmN+pjlgbasH6cH/Q==
dependencies:
env-paths "^2.2.0"
- exponential-backoff "^3.1.1"
glob "^7.1.4"
graceful-fs "^4.2.6"
make-fetch-happen "^10.0.3"
@@ -22799,11 +22788,6 @@ package-name-regex@~2.0.6:
resolved "https://registry.yarnpkg.com/package-name-regex/-/package-name-regex-2.0.6.tgz#b54bcb04d950e38082b7bb38fa558e01c1679334"
integrity sha512-gFL35q7kbE/zBaPA3UKhp2vSzcPYx2ecbYuwv1ucE9Il6IIgBDweBlH8D68UFGZic2MkllKa2KHCfC1IQBQUYA==
-packet-reader@1.0.0:
- version "1.0.0"
- resolved "https://registry.yarnpkg.com/packet-reader/-/packet-reader-1.0.0.tgz#9238e5480dedabacfe1fe3f2771063f164157d74"
- integrity sha512-HAKu/fG3HpHFO0AA8WE8q2g+gBJaZ9MG7fcKk+IJPLTGAD6Psw4443l+9DGRbOIh3/aXr7Phy0TjilYivJo5XQ==
-
pacote@13.6.2:
version "13.6.2"
resolved "https://registry.yarnpkg.com/pacote/-/pacote-13.6.2.tgz#0d444ba3618ab3e5cd330b451c22967bbd0ca48a"
@@ -23175,11 +23159,21 @@ periscopic@^3.1.0:
estree-walker "^3.0.0"
is-reference "^3.0.0"
-pg-connection-string@2.6.1, pg-connection-string@^2.5.0:
+pg-cloudflare@^1.2.5:
+ version "1.2.5"
+ resolved "https://registry.yarnpkg.com/pg-cloudflare/-/pg-cloudflare-1.2.5.tgz#2e3649c38a7a9c74a7e5327c8098a2fd9af595bd"
+ integrity sha512-OOX22Vt0vOSRrdoUPKJ8Wi2OpE/o/h9T8X1s4qSkCedbNah9ei2W2765be8iMVxQUsvgT7zIAT2eIa9fs5+vtg==
+
+pg-connection-string@2.6.1:
version "2.6.1"
resolved "https://registry.yarnpkg.com/pg-connection-string/-/pg-connection-string-2.6.1.tgz#78c23c21a35dd116f48e12e23c0965e8d9e2cbfb"
integrity sha512-w6ZzNu6oMmIzEAYVw+RLK0+nqHPt8K3ZnknKi+g48Ak2pr3dtljJW3o+D/n2zzCG07Zoe9VOX3aiKpj+BN0pjg==
+pg-connection-string@^2.9.0:
+ version "2.9.0"
+ resolved "https://registry.yarnpkg.com/pg-connection-string/-/pg-connection-string-2.9.0.tgz#f75e06591fdd42ec7636fe2c6a03febeedbec9bf"
+ integrity sha512-P2DEBKuvh5RClafLngkAuGe9OUlFV7ebu8w1kmaaOgPcpJd1RIFh7otETfI6hAR8YupOLFTY7nuvvIn7PLciUQ==
+
pg-int8@1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/pg-int8/-/pg-int8-1.0.1.tgz#943bd463bf5b71b4170115f80f8efc9a0c0eb78c"
@@ -23190,17 +23184,17 @@ pg-numeric@1.0.2:
resolved "https://registry.yarnpkg.com/pg-numeric/-/pg-numeric-1.0.2.tgz#816d9a44026086ae8ae74839acd6a09b0636aa3a"
integrity sha512-BM/Thnrw5jm2kKLE5uJkXqqExRUY/toLHda65XgFTBTFYZyopbKjBe29Ii3RbkvlsMoFwD+tHeGaCjjv0gHlyw==
-pg-pool@^3.5.1:
- version "3.5.1"
- resolved "https://registry.yarnpkg.com/pg-pool/-/pg-pool-3.5.1.tgz#f499ce76f9bf5097488b3b83b19861f28e4ed905"
- integrity sha512-6iCR0wVrro6OOHFsyavV+i6KYL4lVNyYAB9RD18w66xSzN+d8b66HiwuP30Gp1SH5O9T82fckkzsRjlrhD0ioQ==
+pg-pool@^3.10.0:
+ version "3.10.0"
+ resolved "https://registry.yarnpkg.com/pg-pool/-/pg-pool-3.10.0.tgz#134b0213755c5e7135152976488aa7cd7ee1268d"
+ integrity sha512-DzZ26On4sQ0KmqnO34muPcmKbhrjmyiO4lCCR0VwEd7MjmiKf5NTg/6+apUEu0NF7ESa37CGzFxH513CoUmWnA==
-pg-protocol@*, pg-protocol@^1.5.0:
- version "1.5.0"
- resolved "https://registry.yarnpkg.com/pg-protocol/-/pg-protocol-1.5.0.tgz#b5dd452257314565e2d54ab3c132adc46565a6a0"
- integrity sha512-muRttij7H8TqRNu/DxrAJQITO4Ac7RmX3Klyr/9mJEOBeIpgnF8f9jAfRz5d3XwQZl5qBjF9gLsUtMPJE0vezQ==
+pg-protocol@*, pg-protocol@^1.10.0:
+ version "1.10.0"
+ resolved "https://registry.yarnpkg.com/pg-protocol/-/pg-protocol-1.10.0.tgz#a473afcbb1c6e5dc3ac24869ba3dd563f8a1ae1b"
+ integrity sha512-IpdytjudNuLv8nhlHs/UrVBhU0e78J0oIS/0AVdTbWxSOkFUVdsHC/NrorO6nXsQNDTT1kzDSOMJubBQviX18Q==
-pg-types@^2.1.0, pg-types@^2.2.0:
+pg-types@2.2.0, pg-types@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/pg-types/-/pg-types-2.2.0.tgz#2d0250d636454f7cfa3b6ae0382fdfa8063254a3"
integrity sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==
@@ -23224,20 +23218,20 @@ pg-types@^4.0.1:
postgres-interval "^3.0.0"
postgres-range "^1.1.1"
-pg@^8.7.3:
- version "8.7.3"
- resolved "https://registry.yarnpkg.com/pg/-/pg-8.7.3.tgz#8a5bdd664ca4fda4db7997ec634c6e5455b27c44"
- integrity sha512-HPmH4GH4H3AOprDJOazoIcpI49XFsHCe8xlrjHkWiapdbHK+HLtbm/GQzXYAZwmPju/kzKhjaSfMACG+8cgJcw==
- dependencies:
- buffer-writer "2.0.0"
- packet-reader "1.0.0"
- pg-connection-string "^2.5.0"
- pg-pool "^3.5.1"
- pg-protocol "^1.5.0"
- pg-types "^2.1.0"
- pgpass "1.x"
-
-pgpass@1.x:
+pg@8.16.0:
+ version "8.16.0"
+ resolved "https://registry.yarnpkg.com/pg/-/pg-8.16.0.tgz#40b08eedb5eb1834252cf3e3629503e32e6c6c04"
+ integrity sha512-7SKfdvP8CTNXjMUzfcVTaI+TDzBEeaUnVwiVGZQD1Hh33Kpev7liQba9uLd4CfN8r9mCVsD0JIpq03+Unpz+kg==
+ dependencies:
+ pg-connection-string "^2.9.0"
+ pg-pool "^3.10.0"
+ pg-protocol "^1.10.0"
+ pg-types "2.2.0"
+ pgpass "1.0.5"
+ optionalDependencies:
+ pg-cloudflare "^1.2.5"
+
+pgpass@1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/pgpass/-/pgpass-1.0.5.tgz#9b873e4a564bb10fa7a7dbd55312728d422a223d"
integrity sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==
From 4de987849d526416720b31746aab2bd3192bb791 Mon Sep 17 00:00:00 2001
From: Francesco Gringl-Novy
Date: Tue, 20 May 2025 14:40:28 +0200
Subject: [PATCH 3/6] ref(browser): Streamline browser `init()` checks (#16340)
Extracted this out of
https://github.com/getsentry/sentry-javascript/pull/15307
This PR:
1. Moves things around in the `sdk.ts` file a bit, moving types & consts
to the top of the file
2. Removes an "unecessary" log around fetch not being supported: This
log has two problems. First, it is not actually logged, because we do
`logger.log()` before running `init()`, which would actually set the
logger up. So the log would never show up. Second, the log is
superfluous, if the (default) fetch transport fails to send because
fetch is not available, you get a warning anyhow for this.
3. Streamlines the browser extension check code slightly.
Closes https://github.com/getsentry/sentry-javascript/issues/16284
---
.../skip-init-browser-extension/test.ts | 2 +-
.../skip-init-chrome-extension/test.ts | 2 +-
packages/browser/src/sdk.ts | 124 +++++++++---------
packages/browser/test/sdk.test.ts | 4 +-
packages/core/src/index.ts | 2 +
packages/core/src/utils-hoist/supports.ts | 10 +-
6 files changed, 76 insertions(+), 68 deletions(-)
diff --git a/dev-packages/browser-integration-tests/suites/manual-client/skip-init-browser-extension/test.ts b/dev-packages/browser-integration-tests/suites/manual-client/skip-init-browser-extension/test.ts
index e997e08f8257..5098b4aa6552 100644
--- a/dev-packages/browser-integration-tests/suites/manual-client/skip-init-browser-extension/test.ts
+++ b/dev-packages/browser-integration-tests/suites/manual-client/skip-init-browser-extension/test.ts
@@ -23,7 +23,7 @@ sentryTest(
if (hasDebugLogs()) {
expect(errorLogs.length).toEqual(1);
expect(errorLogs[0]).toEqual(
- '[Sentry] You cannot run Sentry this way in a browser extension, check: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/',
+ '[Sentry] You cannot use Sentry.init() in a browser extension, see: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/',
);
} else {
expect(errorLogs.length).toEqual(0);
diff --git a/dev-packages/browser-integration-tests/suites/manual-client/skip-init-chrome-extension/test.ts b/dev-packages/browser-integration-tests/suites/manual-client/skip-init-chrome-extension/test.ts
index 8d3ea4f27faf..411fbd2f9db8 100644
--- a/dev-packages/browser-integration-tests/suites/manual-client/skip-init-chrome-extension/test.ts
+++ b/dev-packages/browser-integration-tests/suites/manual-client/skip-init-chrome-extension/test.ts
@@ -21,7 +21,7 @@ sentryTest('should not initialize when inside a Chrome browser extension', async
if (hasDebugLogs()) {
expect(errorLogs.length).toEqual(1);
expect(errorLogs[0]).toEqual(
- '[Sentry] You cannot run Sentry this way in a browser extension, check: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/',
+ '[Sentry] You cannot use Sentry.init() in a browser extension, see: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/',
);
} else {
expect(errorLogs.length).toEqual(0);
diff --git a/packages/browser/src/sdk.ts b/packages/browser/src/sdk.ts
index f3c8be4b3f40..56f3ace8f193 100644
--- a/packages/browser/src/sdk.ts
+++ b/packages/browser/src/sdk.ts
@@ -7,9 +7,7 @@ import {
getLocationHref,
inboundFiltersIntegration,
initAndBind,
- logger,
stackParserFromStackParserOptions,
- supportsFetch,
} from '@sentry/core';
import type { BrowserClientOptions, BrowserOptions } from './client';
import { BrowserClient } from './client';
@@ -24,6 +22,22 @@ import { linkedErrorsIntegration } from './integrations/linkederrors';
import { defaultStackParser } from './stack-parsers';
import { makeFetchTransport } from './transports/fetch';
+type ExtensionProperties = {
+ chrome?: Runtime;
+ browser?: Runtime;
+ nw?: unknown;
+};
+type Runtime = {
+ runtime?: {
+ id?: string;
+ };
+};
+
+/**
+ * A magic string that build tooling can leverage in order to inject a release value into the SDK.
+ */
+declare const __SENTRY_RELEASE__: string | undefined;
+
/** Get the default integrations for the browser SDK. */
export function getDefaultIntegrations(_options: Options): Integration[] {
/**
@@ -79,49 +93,6 @@ function dropTopLevelUndefinedKeys(obj: T): Partial {
return mutatetedObj;
}
-type ExtensionProperties = {
- chrome?: Runtime;
- browser?: Runtime;
- nw?: unknown;
-};
-type Runtime = {
- runtime?: {
- id?: string;
- };
-};
-
-function shouldShowBrowserExtensionError(): boolean {
- const windowWithMaybeExtension =
- typeof WINDOW.window !== 'undefined' && (WINDOW as typeof WINDOW & ExtensionProperties);
- if (!windowWithMaybeExtension) {
- // No need to show the error if we're not in a browser window environment (e.g. service workers)
- return false;
- }
-
- const extensionKey = windowWithMaybeExtension.chrome ? 'chrome' : 'browser';
- const extensionObject = windowWithMaybeExtension[extensionKey];
-
- const runtimeId = extensionObject?.runtime?.id;
- const href = getLocationHref() || '';
-
- const extensionProtocols = ['chrome-extension:', 'moz-extension:', 'ms-browser-extension:', 'safari-web-extension:'];
-
- // Running the SDK in a dedicated extension page and calling Sentry.init is fine; no risk of data leakage
- const isDedicatedExtensionPage =
- !!runtimeId && WINDOW === WINDOW.top && extensionProtocols.some(protocol => href.startsWith(`${protocol}//`));
-
- // Running the SDK in NW.js, which appears like a browser extension but isn't, is also fine
- // see: https://github.com/getsentry/sentry-javascript/issues/12668
- const isNWjs = typeof windowWithMaybeExtension.nw !== 'undefined';
-
- return !!runtimeId && !isDedicatedExtensionPage && !isNWjs;
-}
-
-/**
- * A magic string that build tooling can leverage in order to inject a release value into the SDK.
- */
-declare const __SENTRY_RELEASE__: string | undefined;
-
/**
* The Sentry Browser SDK Client.
*
@@ -169,25 +140,11 @@ declare const __SENTRY_RELEASE__: string | undefined;
* @see {@link BrowserOptions} for documentation on configuration options.
*/
export function init(browserOptions: BrowserOptions = {}): Client | undefined {
- const options = applyDefaultOptions(browserOptions);
-
- if (!options.skipBrowserExtensionCheck && shouldShowBrowserExtensionError()) {
- if (DEBUG_BUILD) {
- consoleSandbox(() => {
- // eslint-disable-next-line no-console
- console.error(
- '[Sentry] You cannot run Sentry this way in a browser extension, check: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/',
- );
- });
- }
+ if (!browserOptions.skipBrowserExtensionCheck && _checkForBrowserExtension()) {
return;
}
- if (DEBUG_BUILD && !supportsFetch()) {
- logger.warn(
- 'No Fetch API detected. The Sentry SDK requires a Fetch API compatible environment to send events. Please add a Fetch API polyfill.',
- );
- }
+ const options = applyDefaultOptions(browserOptions);
const clientOptions: BrowserClientOptions = {
...options,
stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),
@@ -213,3 +170,48 @@ export function forceLoad(): void {
export function onLoad(callback: () => void): void {
callback();
}
+
+function _isEmbeddedBrowserExtension(): boolean {
+ if (typeof WINDOW.window === 'undefined') {
+ // No need to show the error if we're not in a browser window environment (e.g. service workers)
+ return false;
+ }
+
+ const _window = WINDOW as typeof WINDOW & ExtensionProperties;
+
+ // Running the SDK in NW.js, which appears like a browser extension but isn't, is also fine
+ // see: https://github.com/getsentry/sentry-javascript/issues/12668
+ if (_window.nw) {
+ return false;
+ }
+
+ const extensionObject = _window['chrome'] || _window['browser'];
+
+ if (!extensionObject?.runtime?.id) {
+ return false;
+ }
+
+ const href = getLocationHref();
+ const extensionProtocols = ['chrome-extension', 'moz-extension', 'ms-browser-extension', 'safari-web-extension'];
+
+ // Running the SDK in a dedicated extension page and calling Sentry.init is fine; no risk of data leakage
+ const isDedicatedExtensionPage =
+ WINDOW === WINDOW.top && extensionProtocols.some(protocol => href.startsWith(`${protocol}://`));
+
+ return !isDedicatedExtensionPage;
+}
+
+function _checkForBrowserExtension(): true | void {
+ if (_isEmbeddedBrowserExtension()) {
+ if (DEBUG_BUILD) {
+ consoleSandbox(() => {
+ // eslint-disable-next-line no-console
+ console.error(
+ '[Sentry] You cannot use Sentry.init() in a browser extension, see: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/',
+ );
+ });
+ }
+
+ return true;
+ }
+}
diff --git a/packages/browser/test/sdk.test.ts b/packages/browser/test/sdk.test.ts
index 4761a41228fe..342b008bfc18 100644
--- a/packages/browser/test/sdk.test.ts
+++ b/packages/browser/test/sdk.test.ts
@@ -149,7 +149,7 @@ describe('init', () => {
expect(consoleErrorSpy).toBeCalledTimes(1);
expect(consoleErrorSpy).toHaveBeenCalledWith(
- '[Sentry] You cannot run Sentry this way in a browser extension, check: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/',
+ '[Sentry] You cannot use Sentry.init() in a browser extension, see: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/',
);
consoleErrorSpy.mockRestore();
@@ -164,7 +164,7 @@ describe('init', () => {
expect(consoleErrorSpy).toBeCalledTimes(1);
expect(consoleErrorSpy).toHaveBeenCalledWith(
- '[Sentry] You cannot run Sentry this way in a browser extension, check: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/',
+ '[Sentry] You cannot use Sentry.init() in a browser extension, see: https://docs.sentry.io/platforms/javascript/best-practices/browser-extensions/',
);
consoleErrorSpy.mockRestore();
diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts
index 6d281fde0ac9..a67f003aac56 100644
--- a/packages/core/src/index.ts
+++ b/packages/core/src/index.ts
@@ -203,9 +203,11 @@ export {
supportsDOMError,
supportsDOMException,
supportsErrorEvent,
+ // eslint-disable-next-line deprecation/deprecation
supportsFetch,
supportsHistory,
supportsNativeFetch,
+ // eslint-disable-next-line deprecation/deprecation
supportsReferrerPolicy,
supportsReportingObserver,
} from './utils-hoist/supports';
diff --git a/packages/core/src/utils-hoist/supports.ts b/packages/core/src/utils-hoist/supports.ts
index 2336c41b0672..9cb6a71d8058 100644
--- a/packages/core/src/utils-hoist/supports.ts
+++ b/packages/core/src/utils-hoist/supports.ts
@@ -69,8 +69,11 @@ export function supportsHistory(): boolean {
* {@link supportsFetch}.
*
* @returns Answer to the given question.
+ * @deprecated This is no longer used and will be removed in a future major version.
*/
-export function supportsFetch(): boolean {
+export const supportsFetch = _isFetchSupported;
+
+function _isFetchSupported(): boolean {
if (!('fetch' in WINDOW)) {
return false;
}
@@ -104,7 +107,7 @@ export function supportsNativeFetch(): boolean {
return true;
}
- if (!supportsFetch()) {
+ if (!_isFetchSupported()) {
return false;
}
@@ -153,6 +156,7 @@ export function supportsReportingObserver(): boolean {
* {@link supportsReferrerPolicy}.
*
* @returns Answer to the given question.
+ * @deprecated This is no longer used and will be removed in a future major version.
*/
export function supportsReferrerPolicy(): boolean {
// Despite all stars in the sky saying that Edge supports old draft syntax, aka 'never', 'always', 'origin' and 'default'
@@ -160,7 +164,7 @@ export function supportsReferrerPolicy(): boolean {
// it doesn't. And it throws an exception instead of ignoring this parameter...
// REF: https://github.com/getsentry/raven-js/issues/1233
- if (!supportsFetch()) {
+ if (!_isFetchSupported()) {
return false;
}
From 4a88835599dce5866706672fe426c8283eb0be38 Mon Sep 17 00:00:00 2001
From: Onur Temizkan
Date: Tue, 20 May 2025 15:08:36 +0100
Subject: [PATCH 4/6] fix(remix): Use generic types for `ServerBuild` argument
and return (#16336)
Closes: #15615
Ref:
https://github.com/getsentry/sentry-javascript/issues/15615#issuecomment-2887533896
Looks like `createRequestHandler` exported from `@shopify/remix-oxygen`
does not accept a function that returns/resolves a `ServerBuild`. [It
only accepts a plain
`ServerBuild`](https://github.com/Shopify/hydrogen/blob/a7e33c1dd45e3c7c27ab2e1125851468051cee0b/packages/remix-oxygen/src/server.ts#L20).
---
packages/remix/src/server/instrumentServer.ts | 25 +++++++------------
1 file changed, 9 insertions(+), 16 deletions(-)
diff --git a/packages/remix/src/server/instrumentServer.ts b/packages/remix/src/server/instrumentServer.ts
index 3417188cc7d5..4f67f2ae8b3d 100644
--- a/packages/remix/src/server/instrumentServer.ts
+++ b/packages/remix/src/server/instrumentServer.ts
@@ -246,12 +246,9 @@ function makeWrappedRootLoader() {
};
}
-function wrapRequestHandler(
+function wrapRequestHandler ServerBuild | Promise)>(
origRequestHandler: RequestHandler,
- build:
- | ServerBuild
- | { build: ServerBuild }
- | (() => ServerBuild | { build: ServerBuild } | Promise),
+ build: T,
options?: {
instrumentTracing?: boolean;
},
@@ -278,7 +275,7 @@ function wrapRequestHandler(
// check if the build is nested under `build` key
if ('build' in resolvedBuild) {
- resolvedRoutes = createRoutes(resolvedBuild.build.routes);
+ resolvedRoutes = createRoutes((resolvedBuild.build as ServerBuild).routes);
} else {
resolvedRoutes = createRoutes(resolvedBuild.routes);
}
@@ -407,12 +404,12 @@ function instrumentBuildCallback(
/**
* Instruments `remix` ServerBuild for performance tracing and error tracking.
*/
-export function instrumentBuild(
- build: ServerBuild | (() => ServerBuild | Promise),
+export function instrumentBuild ServerBuild | Promise)>(
+ build: T,
options?: {
instrumentTracing?: boolean;
},
-): ServerBuild | (() => ServerBuild | Promise) {
+): T {
if (typeof build === 'function') {
return function () {
const resolvedBuild = build();
@@ -424,19 +421,15 @@ export function instrumentBuild(
} else {
return instrumentBuildCallback(resolvedBuild, options);
}
- };
+ } as T;
} else {
- return instrumentBuildCallback(build, options);
+ return instrumentBuildCallback(build, options) as T;
}
}
export const makeWrappedCreateRequestHandler = (options?: { instrumentTracing?: boolean }) =>
function (origCreateRequestHandler: CreateRequestHandlerFunction): CreateRequestHandlerFunction {
- return function (
- this: unknown,
- build: ServerBuild | (() => ServerBuild | Promise),
- ...args: unknown[]
- ): RequestHandler {
+ return function (this: unknown, build, ...args: unknown[]): RequestHandler {
const newBuild = instrumentBuild(build, options);
const requestHandler = origCreateRequestHandler.call(this, newBuild, ...args);
From acc6fe100bea39f6f58fc56c807d2a430001ce10 Mon Sep 17 00:00:00 2001
From: Abhijeet Prasad
Date: Tue, 20 May 2025 14:59:47 -0400
Subject: [PATCH 5/6] Revert "feat(browser): Track measure detail as span
attributes" (#16348)
It seems like this change introduced a problem where accessing
`event.detail` causes a `DOMException` to be thrown (only on firefox?).
This is causing the SDK to crash if someone has tracing enabled. Until
we figure out a reproduction and a more formal fix (with some e2e
tests) let's revert the problematic PR and move forward.
Reverts getsentry/sentry-javascript#16240
ref https://github.com/getsentry/sentry-javascript/issues/16347
---
.size-limit.js | 4 +-
.../src/metrics/browserMetrics.ts | 35 +---
.../test/browser/browserMetrics.test.ts | 166 +-----------------
3 files changed, 8 insertions(+), 197 deletions(-)
diff --git a/.size-limit.js b/.size-limit.js
index 012fea839bda..10efb849a582 100644
--- a/.size-limit.js
+++ b/.size-limit.js
@@ -52,7 +52,7 @@ module.exports = [
path: 'packages/browser/build/npm/esm/index.js',
import: createImport('init', 'browserTracingIntegration', 'replayIntegration'),
gzip: true,
- limit: '71 KB',
+ limit: '70.1 KB',
modifyWebpackConfig: function (config) {
const webpack = require('webpack');
@@ -206,7 +206,7 @@ module.exports = [
import: createImport('init'),
ignore: ['next/router', 'next/constants'],
gzip: true,
- limit: '42.5 KB',
+ limit: '42 KB',
},
// SvelteKit SDK (ESM)
{
diff --git a/packages/browser-utils/src/metrics/browserMetrics.ts b/packages/browser-utils/src/metrics/browserMetrics.ts
index 646d73ef29c3..71470a0d8706 100644
--- a/packages/browser-utils/src/metrics/browserMetrics.ts
+++ b/packages/browser-utils/src/metrics/browserMetrics.ts
@@ -1,11 +1,10 @@
/* eslint-disable max-lines */
-import type { Measurements, Span, SpanAttributes, SpanAttributeValue, StartSpanOptions } from '@sentry/core';
+import type { Measurements, Span, SpanAttributes, StartSpanOptions } from '@sentry/core';
import {
browserPerformanceTimeOrigin,
getActiveSpan,
getComponentName,
htmlTreeAsString,
- isPrimitive,
parseUrl,
SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,
setMeasurement,
@@ -340,7 +339,7 @@ export function addPerformanceEntries(span: Span, options: AddPerformanceEntries
case 'mark':
case 'paint':
case 'measure': {
- _addMeasureSpans(span, entry as PerformanceMeasure, startTime, duration, timeOrigin);
+ _addMeasureSpans(span, entry, startTime, duration, timeOrigin);
// capture web vitals
const firstHidden = getVisibilityWatcher();
@@ -422,7 +421,7 @@ export function addPerformanceEntries(span: Span, options: AddPerformanceEntries
*/
export function _addMeasureSpans(
span: Span,
- entry: PerformanceMeasure,
+ entry: PerformanceEntry,
startTime: number,
duration: number,
timeOrigin: number,
@@ -451,34 +450,6 @@ export function _addMeasureSpans(
attributes['sentry.browser.measure_start_time'] = measureStartTimestamp;
}
- // https://developer.mozilla.org/en-US/docs/Web/API/Performance/measure#detail
- if (entry.detail) {
- // Handle detail as an object
- if (typeof entry.detail === 'object') {
- for (const [key, value] of Object.entries(entry.detail)) {
- if (value && isPrimitive(value)) {
- attributes[`sentry.browser.measure.detail.${key}`] = value as SpanAttributeValue;
- } else {
- try {
- // This is user defined so we can't guarantee it's serializable
- attributes[`sentry.browser.measure.detail.${key}`] = JSON.stringify(value);
- } catch {
- // skip
- }
- }
- }
- } else if (isPrimitive(entry.detail)) {
- attributes['sentry.browser.measure.detail'] = entry.detail as SpanAttributeValue;
- } else {
- // This is user defined so we can't guarantee it's serializable
- try {
- attributes['sentry.browser.measure.detail'] = JSON.stringify(entry.detail);
- } catch {
- // skip
- }
- }
- }
-
// Measurements from third parties can be off, which would create invalid spans, dropping transactions in the process.
if (measureStartTimestamp <= measureEndTimestamp) {
startAndEndSpan(span, measureStartTimestamp, measureEndTimestamp, {
diff --git a/packages/browser-utils/test/browser/browserMetrics.test.ts b/packages/browser-utils/test/browser/browserMetrics.test.ts
index a6004b73622a..99cf451f824e 100644
--- a/packages/browser-utils/test/browser/browserMetrics.test.ts
+++ b/packages/browser-utils/test/browser/browserMetrics.test.ts
@@ -70,8 +70,7 @@ describe('_addMeasureSpans', () => {
name: 'measure-1',
duration: 10,
startTime: 12,
- detail: null,
- } as PerformanceMeasure;
+ } as PerformanceEntry;
const timeOrigin = 100;
const startTime = 23;
@@ -107,8 +106,7 @@ describe('_addMeasureSpans', () => {
name: 'measure-1',
duration: 10,
startTime: 12,
- detail: null,
- } as PerformanceMeasure;
+ } as PerformanceEntry;
const timeOrigin = 100;
const startTime = 23;
@@ -118,165 +116,6 @@ describe('_addMeasureSpans', () => {
expect(spans).toHaveLength(0);
});
-
- it('adds measure spans with primitive detail', () => {
- const spans: Span[] = [];
-
- getClient()?.on('spanEnd', span => {
- spans.push(span);
- });
-
- const entry = {
- entryType: 'measure',
- name: 'measure-1',
- duration: 10,
- startTime: 12,
- detail: 'test-detail',
- } as PerformanceMeasure;
-
- const timeOrigin = 100;
- const startTime = 23;
- const duration = 356;
-
- _addMeasureSpans(span, entry, startTime, duration, timeOrigin);
-
- expect(spans).toHaveLength(1);
- expect(spanToJSON(spans[0]!)).toEqual(
- expect.objectContaining({
- description: 'measure-1',
- start_timestamp: timeOrigin + startTime,
- timestamp: timeOrigin + startTime + duration,
- op: 'measure',
- origin: 'auto.resource.browser.metrics',
- data: {
- [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'measure',
- [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.resource.browser.metrics',
- 'sentry.browser.measure.detail': 'test-detail',
- },
- }),
- );
- });
-
- it('adds measure spans with object detail', () => {
- const spans: Span[] = [];
-
- getClient()?.on('spanEnd', span => {
- spans.push(span);
- });
-
- const detail = {
- component: 'Button',
- action: 'click',
- metadata: { id: 123 },
- };
-
- const entry = {
- entryType: 'measure',
- name: 'measure-1',
- duration: 10,
- startTime: 12,
- detail,
- } as PerformanceMeasure;
-
- const timeOrigin = 100;
- const startTime = 23;
- const duration = 356;
-
- _addMeasureSpans(span, entry, startTime, duration, timeOrigin);
-
- expect(spans).toHaveLength(1);
- expect(spanToJSON(spans[0]!)).toEqual(
- expect.objectContaining({
- description: 'measure-1',
- start_timestamp: timeOrigin + startTime,
- timestamp: timeOrigin + startTime + duration,
- op: 'measure',
- origin: 'auto.resource.browser.metrics',
- data: {
- [SEMANTIC_ATTRIBUTE_SENTRY_OP]: 'measure',
- [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.resource.browser.metrics',
- 'sentry.browser.measure.detail.component': 'Button',
- 'sentry.browser.measure.detail.action': 'click',
- 'sentry.browser.measure.detail.metadata': JSON.stringify({ id: 123 }),
- },
- }),
- );
- });
-
- it('handles non-primitive detail values by stringifying them', () => {
- const spans: Span[] = [];
-
- getClient()?.on('spanEnd', span => {
- spans.push(span);
- });
-
- const detail = {
- component: 'Button',
- action: 'click',
- metadata: { id: 123 },
- callback: () => {},
- };
-
- const entry = {
- entryType: 'measure',
- name: 'measure-1',
- duration: 10,
- startTime: 12,
- detail,
- } as PerformanceMeasure;
-
- const timeOrigin = 100;
- const startTime = 23;
- const duration = 356;
-
- _addMeasureSpans(span, entry, startTime, duration, timeOrigin);
-
- expect(spans).toHaveLength(1);
- const spanData = spanToJSON(spans[0]!).data;
- expect(spanData['sentry.browser.measure.detail.component']).toBe('Button');
- expect(spanData['sentry.browser.measure.detail.action']).toBe('click');
- expect(spanData['sentry.browser.measure.detail.metadata']).toBe(JSON.stringify({ id: 123 }));
- expect(spanData['sentry.browser.measure.detail.callback']).toBe(JSON.stringify(detail.callback));
- });
-
- it('handles errors in object detail value stringification', () => {
- const spans: Span[] = [];
-
- getClient()?.on('spanEnd', span => {
- spans.push(span);
- });
-
- const circular: any = {};
- circular.self = circular;
-
- const detail = {
- component: 'Button',
- action: 'click',
- circular,
- };
-
- const entry = {
- entryType: 'measure',
- name: 'measure-1',
- duration: 10,
- startTime: 12,
- detail,
- } as PerformanceMeasure;
-
- const timeOrigin = 100;
- const startTime = 23;
- const duration = 356;
-
- // Should not throw
- _addMeasureSpans(span, entry, startTime, duration, timeOrigin);
-
- expect(spans).toHaveLength(1);
- const spanData = spanToJSON(spans[0]!).data;
- expect(spanData['sentry.browser.measure.detail.component']).toBe('Button');
- expect(spanData['sentry.browser.measure.detail.action']).toBe('click');
- // The circular reference should be skipped
- expect(spanData['sentry.browser.measure.detail.circular']).toBeUndefined();
- });
});
describe('_addResourceSpans', () => {
@@ -625,6 +464,7 @@ describe('_addNavigationSpans', () => {
transferSize: 14726,
encodedBodySize: 14426,
decodedBodySize: 67232,
+ responseStatus: 200,
serverTiming: [],
unloadEventStart: 0,
unloadEventEnd: 0,
From 8fd6fd9dc9cf7c32c7d1ca879b1927d28a406dc3 Mon Sep 17 00:00:00 2001
From: Abhijeet Prasad
Date: Tue, 20 May 2025 15:02:24 -0400
Subject: [PATCH 6/6] meta(changelog): Update changelog for 9.22.0
---
CHANGELOG.md | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c65c71599258..ceb36dfdaffc 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,6 +10,19 @@
- "You miss 100 percent of the chances you don't take. — Wayne Gretzky" — Michael Scott
+## 9.22.0
+
+### Important changes
+
+- **Revert "feat(browser): Track measure detail as span attributes" ([#16348](https://github.com/getsentry/sentry-javascript/pull/16348))**
+
+This is a revert of a feature introduced in `9.20.0` with [#16240](https://github.com/getsentry/sentry-javascript/pull/16240). This feature was causing crashes in firefox, so we are reverting it. We will re-enable this functionality in the future after fixing the crash.
+
+### Other changes
+
+- feat(deps): bump @sentry/rollup-plugin from 3.1.2 to 3.2.1 ([#15511](https://github.com/getsentry/sentry-javascript/pull/15511))
+- fix(remix): Use generic types for `ServerBuild` argument and return ([#16336](https://github.com/getsentry/sentry-javascript/pull/16336))
+
## 9.21.0
- docs: Fix v7 migration link ([#14629](https://github.com/getsentry/sentry-javascript/pull/14629))