From 01e055b70318674bc710e81daecb76340a009373 Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Fri, 10 Nov 2023 15:43:04 +0100 Subject: [PATCH 01/21] feat(telemetry): add Sentry to client --- .github/workflows/prod-build.yml | 3 +++ .github/workflows/stage-build.yml | 3 +++ .github/workflows/test-build.yml | 6 +++++ client/src/env.ts | 5 ++++ client/src/index.tsx | 5 ++++ client/src/telemetry/sentry.ts | 10 ++++++++ package.json | 1 + yarn.lock | 40 ++++++++++++++++++++++++++++++- 8 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 client/src/telemetry/sentry.ts diff --git a/.github/workflows/prod-build.yml b/.github/workflows/prod-build.yml index da267b3640f3..faa497d6aa7c 100644 --- a/.github/workflows/prod-build.yml +++ b/.github/workflows/prod-build.yml @@ -247,6 +247,9 @@ jobs: REACT_APP_OBSERVATORY_API_URL: https://observatory-api.mdn.mozilla.net # Sentry. + REACT_APP_SENTRY_DSN: ${{ secrets.SENTRY_DSN_CLIENT }} + REACT_APP_SENTRY_ENVIRONMENT: prod + REACT_APP_SENTRY_RELEASE: ${{ github.sha }} SENTRY_DSN_BUILD: ${{ secrets.SENTRY_DSN_BUILD }} SENTRY_ENVIRONMENT: prod SENTRY_RELEASE: ${{ github.sha }} diff --git a/.github/workflows/stage-build.yml b/.github/workflows/stage-build.yml index 5c1a301b94ab..d4564306e05f 100644 --- a/.github/workflows/stage-build.yml +++ b/.github/workflows/stage-build.yml @@ -264,6 +264,9 @@ jobs: REACT_APP_OBSERVATORY_API_URL: https://observatory-api.mdn.allizom.net # Sentry. + REACT_APP_SENTRY_DSN: ${{ secrets.SENTRY_DSN_CLIENT }} + REACT_APP_SENTRY_ENVIRONMENT: stage + REACT_APP_SENTRY_RELEASE: ${{ github.sha }} SENTRY_DSN_BUILD: ${{ secrets.SENTRY_DSN_BUILD }} SENTRY_ENVIRONMENT: stage SENTRY_RELEASE: ${{ github.sha }} diff --git a/.github/workflows/test-build.yml b/.github/workflows/test-build.yml index bfa70d1d960d..a59e8624e6d1 100644 --- a/.github/workflows/test-build.yml +++ b/.github/workflows/test-build.yml @@ -159,6 +159,12 @@ jobs: # Observatory REACT_APP_OBSERVATORY_API_URL: https://observatory-api.mdn.allizom.net + + # Sentry. + REACT_APP_SENTRY_DSN: ${{ secrets.SENTRY_DSN_CLIENT }} + REACT_APP_SENTRY_ENVIRONMENT: test + REACT_APP_SENTRY_RELEASE: ${{ github.sha }} + run: | set -eo pipefail diff --git a/client/src/env.ts b/client/src/env.ts index 5f9eea8c8fb0..39e69a3802e5 100644 --- a/client/src/env.ts +++ b/client/src/env.ts @@ -103,6 +103,11 @@ export const GLEAN_LOG_CLICK = Boolean( JSON.parse(process.env.REACT_APP_GLEAN_LOG_CLICK || "false") ); +export const SENTRY_DSN = process.env.REACT_APP_SENTRY_DSN || ""; +export const SENTRY_ENVIRONMENT = + process.env.REACT_APP_SENTRY_ENVIRONMENT || ""; +export const SENTRY_RELEASE = process.env.REACT_APP_SENTRY_RELEASE || ""; + export const AI_FEEDBACK_GITHUB_REPO = process.env.REACT_APP_AI_FEEDBACK_GITHUB_REPO || "mdn/private-ai-feedback"; diff --git a/client/src/index.tsx b/client/src/index.tsx index b9cd51c2df86..682d5ca8d6fe 100644 --- a/client/src/index.tsx +++ b/client/src/index.tsx @@ -8,8 +8,13 @@ import { UserDataProvider } from "./user-context"; import { UIProvider } from "./ui-context"; import { GleanProvider } from "./telemetry/glean-context"; import { PlacementProvider } from "./placement-context"; +import { initSentry } from "./telemetry/sentry"; +import { SENTRY_DSN } from "./env"; // import * as serviceWorker from './serviceWorker'; +if (SENTRY_DSN) { + initSentry(SENTRY_DSN); +} const container = document.getElementById("root"); if (!container) { diff --git a/client/src/telemetry/sentry.ts b/client/src/telemetry/sentry.ts new file mode 100644 index 000000000000..327d852a89f6 --- /dev/null +++ b/client/src/telemetry/sentry.ts @@ -0,0 +1,10 @@ +import * as Sentry from "@sentry/react"; +import { SENTRY_ENVIRONMENT, SENTRY_RELEASE } from "../env"; + +export function initSentry(dsn: string) { + Sentry.init({ + dsn, + release: SENTRY_RELEASE, + environment: SENTRY_ENVIRONMENT || "dev", + }); +} diff --git a/package.json b/package.json index ed877e6a7787..aa790f08ae56 100644 --- a/package.json +++ b/package.json @@ -75,6 +75,7 @@ "@mdn/browser-compat-data": "^5.5.51", "@mozilla/glean": "5.0.3", "@sentry/node": "^8.29.0", + "@sentry/react": "^7.80.0", "@stripe/stripe-js": "^4.4.0", "@use-it/interval": "^1.0.0", "@vscode/ripgrep": "^1.15.9", diff --git a/yarn.lock b/yarn.lock index 4c1888a97c1d..d55b53f72bf1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2949,6 +2949,17 @@ "@sentry/types" "8.29.0" "@sentry/utils" "8.29.0" +"@sentry/browser@7.80.0": + version "7.80.0" + resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.80.0.tgz#385fb59ac1d52b67919087f3d7044575ae0abbdd" + integrity sha512-Ngwjc+yyf/aH5q7iQM1LeDNlhM1Ilt4ZLUogTghZR/guwNWmCtk3OHcjOLz7fxBBj9wGFUc2pHPyeYM6bQhrEw== + dependencies: + "@sentry-internal/tracing" "7.80.0" + "@sentry/core" "7.80.0" + "@sentry/replay" "7.80.0" + "@sentry/types" "7.80.0" + "@sentry/utils" "7.80.0" + "@sentry/node@^8.29.0": version "8.29.0" resolved "https://registry.yarnpkg.com/@sentry/node/-/node-8.29.0.tgz#6e462b8802356a630c56733dc795a4035464c4ab" @@ -2996,6 +3007,26 @@ "@sentry/types" "8.29.0" "@sentry/utils" "8.29.0" +"@sentry/react@^7.80.0": + version "7.80.0" + resolved "https://registry.yarnpkg.com/@sentry/react/-/react-7.80.0.tgz#ee589ff202174ced45e77dc2714237031ca9c726" + integrity sha512-xoX7fqgY0NZR9Fud/IJ4a3b8Z/HsdwU5SLILi46lV+CWaXS6eFM1E81jG2Vd2EeYIpkH+bMA//XHMEod8LAJcQ== + dependencies: + "@sentry/browser" "7.80.0" + "@sentry/types" "7.80.0" + "@sentry/utils" "7.80.0" + hoist-non-react-statics "^3.3.2" + +"@sentry/replay@7.80.0": + version "7.80.0" + resolved "https://registry.yarnpkg.com/@sentry/replay/-/replay-7.80.0.tgz#0626d85af1d8573038d52ae9e244e3e95fa47385" + integrity sha512-wWnpuJq3OaDLp1LutE4oxWXnau04fvwuzBjuaFvOXOV+pB/kn+pDPuVOC5+FH/RMRZ5ftwX5+dF6fojfcLVGCg== + dependencies: + "@sentry-internal/tracing" "7.80.0" + "@sentry/core" "7.80.0" + "@sentry/types" "7.80.0" + "@sentry/utils" "7.80.0" + "@sentry/types@8.29.0": version "8.29.0" resolved "https://registry.yarnpkg.com/@sentry/types/-/types-8.29.0.tgz#c19e43524b8e7766028f4da8f02eddcc33518541" @@ -8711,6 +8742,13 @@ history@^5.2.0: dependencies: "@babel/runtime" "^7.7.6" +hoist-non-react-statics@^3.3.2: + version "3.3.2" + resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45" + integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw== + dependencies: + react-is "^16.7.0" + hoopy@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/hoopy/-/hoopy-0.1.4.tgz#609207d661100033a9a9402ad3dea677381c1b1d" @@ -13265,7 +13303,7 @@ react-dom@^18.3.1: loose-envify "^1.1.0" scheduler "^0.23.2" -react-is@^16.13.1: +react-is@^16.13.1, react-is@^16.7.0: version "16.13.1" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== From f96464a4ed97357c277229346b083602ac783593 Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Fri, 10 Nov 2023 17:41:08 +0100 Subject: [PATCH 02/21] fix(csp): add *.sentry.io as connect-src --- libs/constants/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/libs/constants/index.js b/libs/constants/index.js index cf445f4149f2..d445cc016eda 100644 --- a/libs/constants/index.js +++ b/libs/constants/index.js @@ -116,6 +116,7 @@ export const CSP_DIRECTIVES = { "https://observatory-api.mdn.mozilla.net", "stats.g.doubleclick.net", + "*.sentry.io", "https://api.stripe.com", ], "font-src": ["'self'"], From 2d36d027aab7205d371bb30f562d07553cff30dd Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Fri, 10 Nov 2023 19:18:53 +0100 Subject: [PATCH 03/21] chore(telemetry): reduce Sentry bundle size --- client/config/webpack.config.js | 8 ++++++++ client/src/index.tsx | 2 +- client/src/telemetry/sentry.ts | 15 +++++++++++++-- package.json | 2 +- yarn.lock | 21 ++------------------- 5 files changed, 25 insertions(+), 23 deletions(-) diff --git a/client/config/webpack.config.js b/client/config/webpack.config.js index db2139910913..8ef571c7d2cd 100644 --- a/client/config/webpack.config.js +++ b/client/config/webpack.config.js @@ -414,6 +414,14 @@ function config(webpackEnv) { // during a production build. // Otherwise React will be compiled in the very slow development mode. new webpack.DefinePlugin(env.stringified), + // Treeshake Sentry. + new webpack.DefinePlugin({ + __SENTRY_DEBUG__: false, + __SENTRY_TRACING__: false, + __RRWEB_EXCLUDE_IFRAME__: true, + __RRWEB_EXCLUDE_SHADOW_DOM__: true, + __SENTRY_EXCLUDE_REPLAY_WORKER__: true, + }), // Experimental hot reloading for React . // https://github.com/facebook/react/tree/main/packages/react-refresh isEnvDevelopment && diff --git a/client/src/index.tsx b/client/src/index.tsx index 682d5ca8d6fe..9a059ae90b90 100644 --- a/client/src/index.tsx +++ b/client/src/index.tsx @@ -8,8 +8,8 @@ import { UserDataProvider } from "./user-context"; import { UIProvider } from "./ui-context"; import { GleanProvider } from "./telemetry/glean-context"; import { PlacementProvider } from "./placement-context"; -import { initSentry } from "./telemetry/sentry"; import { SENTRY_DSN } from "./env"; +import { initSentry } from "./telemetry/sentry"; // import * as serviceWorker from './serviceWorker'; if (SENTRY_DSN) { diff --git a/client/src/telemetry/sentry.ts b/client/src/telemetry/sentry.ts index 327d852a89f6..ceff9eaf5783 100644 --- a/client/src/telemetry/sentry.ts +++ b/client/src/telemetry/sentry.ts @@ -1,10 +1,21 @@ -import * as Sentry from "@sentry/react"; +import { + BrowserClient, + defaultStackParser, + getCurrentHub, + makeFetchTransport, +} from "@sentry/browser"; + import { SENTRY_ENVIRONMENT, SENTRY_RELEASE } from "../env"; export function initSentry(dsn: string) { - Sentry.init({ + const client = new BrowserClient({ dsn, release: SENTRY_RELEASE, environment: SENTRY_ENVIRONMENT || "dev", + transport: makeFetchTransport, + stackParser: defaultStackParser, + integrations: [], }); + + getCurrentHub().bindClient(client); } diff --git a/package.json b/package.json index aa790f08ae56..8b71a59e287f 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,6 @@ "@mdn/browser-compat-data": "^5.5.51", "@mozilla/glean": "5.0.3", "@sentry/node": "^8.29.0", - "@sentry/react": "^7.80.0", "@stripe/stripe-js": "^4.4.0", "@use-it/interval": "^1.0.0", "@vscode/ripgrep": "^1.15.9", @@ -159,6 +158,7 @@ "@mdn/minimalist": "^2.0.4", "@playwright/test": "^1.47.0", "@pmmmwh/react-refresh-webpack-plugin": "^0.5.15", + "@sentry/browser": "^7.80.0", "@svgr/webpack": "^8.1.0", "@swc/core": "^1.7.24", "@testing-library/react": "^15.0.7", diff --git a/yarn.lock b/yarn.lock index d55b53f72bf1..67ea5dea5c82 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2949,7 +2949,7 @@ "@sentry/types" "8.29.0" "@sentry/utils" "8.29.0" -"@sentry/browser@7.80.0": +"@sentry/browser@^7.80.0": version "7.80.0" resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.80.0.tgz#385fb59ac1d52b67919087f3d7044575ae0abbdd" integrity sha512-Ngwjc+yyf/aH5q7iQM1LeDNlhM1Ilt4ZLUogTghZR/guwNWmCtk3OHcjOLz7fxBBj9wGFUc2pHPyeYM6bQhrEw== @@ -3007,16 +3007,6 @@ "@sentry/types" "8.29.0" "@sentry/utils" "8.29.0" -"@sentry/react@^7.80.0": - version "7.80.0" - resolved "https://registry.yarnpkg.com/@sentry/react/-/react-7.80.0.tgz#ee589ff202174ced45e77dc2714237031ca9c726" - integrity sha512-xoX7fqgY0NZR9Fud/IJ4a3b8Z/HsdwU5SLILi46lV+CWaXS6eFM1E81jG2Vd2EeYIpkH+bMA//XHMEod8LAJcQ== - dependencies: - "@sentry/browser" "7.80.0" - "@sentry/types" "7.80.0" - "@sentry/utils" "7.80.0" - hoist-non-react-statics "^3.3.2" - "@sentry/replay@7.80.0": version "7.80.0" resolved "https://registry.yarnpkg.com/@sentry/replay/-/replay-7.80.0.tgz#0626d85af1d8573038d52ae9e244e3e95fa47385" @@ -8742,13 +8732,6 @@ history@^5.2.0: dependencies: "@babel/runtime" "^7.7.6" -hoist-non-react-statics@^3.3.2: - version "3.3.2" - resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45" - integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw== - dependencies: - react-is "^16.7.0" - hoopy@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/hoopy/-/hoopy-0.1.4.tgz#609207d661100033a9a9402ad3dea677381c1b1d" @@ -13303,7 +13286,7 @@ react-dom@^18.3.1: loose-envify "^1.1.0" scheduler "^0.23.2" -react-is@^16.13.1, react-is@^16.7.0: +react-is@^16.13.1: version "16.13.1" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== From 21fe8ba944a9b1f6be577612690cfd153bd0037e Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Fri, 10 Nov 2023 19:27:34 +0100 Subject: [PATCH 04/21] chore(telemetry): add minimal integrations --- client/src/telemetry/sentry.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/src/telemetry/sentry.ts b/client/src/telemetry/sentry.ts index ceff9eaf5783..6f97fd86db27 100644 --- a/client/src/telemetry/sentry.ts +++ b/client/src/telemetry/sentry.ts @@ -1,5 +1,7 @@ import { BrowserClient, + Dedupe, + GlobalHandlers, defaultStackParser, getCurrentHub, makeFetchTransport, @@ -14,7 +16,7 @@ export function initSentry(dsn: string) { environment: SENTRY_ENVIRONMENT || "dev", transport: makeFetchTransport, stackParser: defaultStackParser, - integrations: [], + integrations: [new GlobalHandlers(), new Dedupe()], }); getCurrentHub().bindClient(client); From cf3f5c7964ad867f47872d2f4d589c5640bbd19f Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Fri, 10 Nov 2023 19:49:14 +0100 Subject: [PATCH 05/21] chore(telemetry): load sentry async --- client/src/telemetry/sentry.ts | 33 +++---- package.json | 1 + yarn.lock | 163 +++++++++++++++++++++++++++++++-- 3 files changed, 171 insertions(+), 26 deletions(-) diff --git a/client/src/telemetry/sentry.ts b/client/src/telemetry/sentry.ts index 6f97fd86db27..9e781bf8252e 100644 --- a/client/src/telemetry/sentry.ts +++ b/client/src/telemetry/sentry.ts @@ -1,23 +1,20 @@ -import { - BrowserClient, - Dedupe, - GlobalHandlers, - defaultStackParser, - getCurrentHub, - makeFetchTransport, -} from "@sentry/browser"; - import { SENTRY_ENVIRONMENT, SENTRY_RELEASE } from "../env"; export function initSentry(dsn: string) { - const client = new BrowserClient({ - dsn, - release: SENTRY_RELEASE, - environment: SENTRY_ENVIRONMENT || "dev", - transport: makeFetchTransport, - stackParser: defaultStackParser, - integrations: [new GlobalHandlers(), new Dedupe()], + let events: ErrorEvent[] = []; + const errorHandler = (event: ErrorEvent) => { + events.push(event); + }; + window.addEventListener("error", errorHandler); + import(/* webpackChunkName: "sentry" */ "@sentry/react").then((Sentry) => { + Sentry.init({ + dsn, + release: SENTRY_RELEASE, + environment: SENTRY_ENVIRONMENT || "dev", + }); + window.removeEventListener("error", errorHandler); + for (const event of events) { + Sentry.captureException(event); + } }); - - getCurrentHub().bindClient(client); } diff --git a/package.json b/package.json index 8b71a59e287f..072c6032dbca 100644 --- a/package.json +++ b/package.json @@ -75,6 +75,7 @@ "@mdn/browser-compat-data": "^5.5.51", "@mozilla/glean": "5.0.3", "@sentry/node": "^8.29.0", + "@sentry/react": "^7.80.0", "@stripe/stripe-js": "^4.4.0", "@use-it/interval": "^1.0.0", "@vscode/ripgrep": "^1.15.9", diff --git a/yarn.lock b/yarn.lock index 67ea5dea5c82..b4b1613d6f00 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2941,15 +2941,44 @@ resolved "https://registry.yarnpkg.com/@sec-ant/readable-stream/-/readable-stream-0.4.1.tgz#60de891bb126abfdc5410fdc6166aca065f10a0c" integrity sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg== -"@sentry/core@8.29.0": - version "8.29.0" - resolved "https://registry.yarnpkg.com/@sentry/core/-/core-8.29.0.tgz#52032ece2d7b60f3775f10189c27e26b1cebdbca" - integrity sha512-scMbZaJ0Ov8NPgWn86EdjhyTLrhvRVbTxjg0imJAvhIvRbblH3xyqye/17Qnk2fOp8TNDOl7TBZHi0NCFQ5HUw== +"@sentry-internal/feedback@7.119.0": + version "7.119.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/feedback/-/feedback-7.119.0.tgz#429b3ea0fd34e928d2e7de5dcbe9377272a3f221" + integrity sha512-om8TkAU5CQGO8nkmr7qsSBVkP+/vfeS4JgtW3sjoTK0fhj26+DljR6RlfCGWtYQdPSP6XV7atcPTjbSnsmG9FQ== + dependencies: + "@sentry/core" "7.119.0" + "@sentry/types" "7.119.0" + "@sentry/utils" "7.119.0" + +"@sentry-internal/replay-canvas@7.119.0": + version "7.119.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/replay-canvas/-/replay-canvas-7.119.0.tgz#85669d184ba79150e64d05de02f5e2b616e68371" + integrity sha512-NL02VQx6ekPxtVRcsdp1bp5Tb5w6vnfBKSIfMKuDRBy5A10Uc3GSoy/c3mPyHjOxB84452A+xZSx6bliEzAnuA== + dependencies: + "@sentry/core" "7.119.0" + "@sentry/replay" "7.119.0" + "@sentry/types" "7.119.0" + "@sentry/utils" "7.119.0" + +"@sentry-internal/tracing@7.119.0": + version "7.119.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/tracing/-/tracing-7.119.0.tgz#201561af2a4ad1837333287c26050a5e688537ca" + integrity sha512-oKdFJnn+56f0DHUADlL8o9l8jTib3VDLbWQBVkjD9EprxfaCwt2m8L5ACRBdQ8hmpxCEo4I8/6traZ7qAdBUqA== + dependencies: + "@sentry/core" "7.119.0" + "@sentry/types" "7.119.0" + "@sentry/utils" "7.119.0" + +"@sentry-internal/tracing@7.80.0": + version "7.80.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/tracing/-/tracing-7.80.0.tgz#f9a6c0456b3cbf4a53c986a0b9208572d80e0756" + integrity sha512-P1Ab9gamHLsbH9D82i1HY8xfq9dP8runvc4g50AAd6OXRKaJ45f2KGRZUmnMEVqBQ7YoPYp2LFMkrhNYbcZEoQ== dependencies: - "@sentry/types" "8.29.0" - "@sentry/utils" "8.29.0" + "@sentry/core" "7.80.0" + "@sentry/types" "7.80.0" + "@sentry/utils" "7.80.0" -"@sentry/browser@^7.80.0": +"@sentry/browser@7.80.0": version "7.80.0" resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.80.0.tgz#385fb59ac1d52b67919087f3d7044575ae0abbdd" integrity sha512-Ngwjc+yyf/aH5q7iQM1LeDNlhM1Ilt4ZLUogTghZR/guwNWmCtk3OHcjOLz7fxBBj9wGFUc2pHPyeYM6bQhrEw== @@ -2960,6 +2989,54 @@ "@sentry/types" "7.80.0" "@sentry/utils" "7.80.0" +"@sentry/browser@^7.80.0": + version "7.119.0" + resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.119.0.tgz#65004015c107be5d2f49a852ebcffc5d19d90e0d" + integrity sha512-WwmW1Y4D764kVGeKmdsNvQESZiAn9t8LmCWO0ucBksrjL2zw9gBPtOpRcO6l064sCLeSxxzCN+kIxhRm1gDFEA== + dependencies: + "@sentry-internal/feedback" "7.119.0" + "@sentry-internal/replay-canvas" "7.119.0" + "@sentry-internal/tracing" "7.119.0" + "@sentry/core" "7.119.0" + "@sentry/integrations" "7.119.0" + "@sentry/replay" "7.119.0" + "@sentry/types" "7.119.0" + "@sentry/utils" "7.119.0" + +"@sentry/core@7.119.0": + version "7.119.0" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.119.0.tgz#a6e41119bb03ec27689f9ad04e79d1fba5b7fc37" + integrity sha512-CS2kUv9rAJJEjiRat6wle3JATHypB0SyD7pt4cpX5y0dN5dZ1JrF57oLHRMnga9fxRivydHz7tMTuBhSSwhzjw== + dependencies: + "@sentry/types" "7.119.0" + "@sentry/utils" "7.119.0" + +"@sentry/core@7.80.0": + version "7.80.0" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.80.0.tgz#7b8a460c19160b81ade20080333189f1a80c1410" + integrity sha512-nJiiymdTSEyI035/rdD3VOq6FlOZ2wWLR5bit9LK8a3rzHU3UXkwScvEo6zYgs0Xp1sC0yu1S9+0BEiYkmi29A== + dependencies: + "@sentry/types" "7.80.0" + "@sentry/utils" "7.80.0" + +"@sentry/core@8.29.0": + version "8.29.0" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-8.29.0.tgz#52032ece2d7b60f3775f10189c27e26b1cebdbca" + integrity sha512-scMbZaJ0Ov8NPgWn86EdjhyTLrhvRVbTxjg0imJAvhIvRbblH3xyqye/17Qnk2fOp8TNDOl7TBZHi0NCFQ5HUw== + dependencies: + "@sentry/types" "8.29.0" + "@sentry/utils" "8.29.0" + +"@sentry/integrations@7.119.0": + version "7.119.0" + resolved "https://registry.yarnpkg.com/@sentry/integrations/-/integrations-7.119.0.tgz#5b25c603026dbacfe1ae7bb8d768506a129149fb" + integrity sha512-OHShvtsRW0A+ZL/ZbMnMqDEtJddPasndjq+1aQXw40mN+zeP7At/V1yPZyFaURy86iX7Ucxw5BtmzuNy7hLyTA== + dependencies: + "@sentry/core" "7.119.0" + "@sentry/types" "7.119.0" + "@sentry/utils" "7.119.0" + localforage "^1.8.1" + "@sentry/node@^8.29.0": version "8.29.0" resolved "https://registry.yarnpkg.com/@sentry/node/-/node-8.29.0.tgz#6e462b8802356a630c56733dc795a4035464c4ab" @@ -3007,6 +3084,26 @@ "@sentry/types" "8.29.0" "@sentry/utils" "8.29.0" +"@sentry/react@^7.80.0": + version "7.80.0" + resolved "https://registry.yarnpkg.com/@sentry/react/-/react-7.80.0.tgz#ee589ff202174ced45e77dc2714237031ca9c726" + integrity sha512-xoX7fqgY0NZR9Fud/IJ4a3b8Z/HsdwU5SLILi46lV+CWaXS6eFM1E81jG2Vd2EeYIpkH+bMA//XHMEod8LAJcQ== + dependencies: + "@sentry/browser" "7.80.0" + "@sentry/types" "7.80.0" + "@sentry/utils" "7.80.0" + hoist-non-react-statics "^3.3.2" + +"@sentry/replay@7.119.0": + version "7.119.0" + resolved "https://registry.yarnpkg.com/@sentry/replay/-/replay-7.119.0.tgz#50881079d013c77f87a994331d8bcad1d49e0960" + integrity sha512-BnNsYL+X5I4WCH6wOpY6HQtp4MgVt0NVlhLUsEyrvMUiTs0bPkDBrulsgZQBUKJsbOr3l9nHrFoNVB/0i6WNLA== + dependencies: + "@sentry-internal/tracing" "7.119.0" + "@sentry/core" "7.119.0" + "@sentry/types" "7.119.0" + "@sentry/utils" "7.119.0" + "@sentry/replay@7.80.0": version "7.80.0" resolved "https://registry.yarnpkg.com/@sentry/replay/-/replay-7.80.0.tgz#0626d85af1d8573038d52ae9e244e3e95fa47385" @@ -3017,11 +3114,35 @@ "@sentry/types" "7.80.0" "@sentry/utils" "7.80.0" +"@sentry/types@7.119.0": + version "7.119.0" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.119.0.tgz#8b3d7a1405c362e75cd900d46089df4e70919d2a" + integrity sha512-27qQbutDBPKGbuJHROxhIWc1i0HJaGLA90tjMu11wt0E4UNxXRX+UQl4Twu68v4EV3CPvQcEpQfgsViYcXmq+w== + +"@sentry/types@7.80.0": + version "7.80.0" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.80.0.tgz#f6896de2d231a7f8d814cf1c981c474240e96d8a" + integrity sha512-4bpMO+2jWiWLDa8zbTASWWNLWe6yhjfPsa7/6VH5y9x1NGtL8oRbqUsTgsvjF3nmeHEMkHQsC8NHPaQ/ibFmZQ== + "@sentry/types@8.29.0": version "8.29.0" resolved "https://registry.yarnpkg.com/@sentry/types/-/types-8.29.0.tgz#c19e43524b8e7766028f4da8f02eddcc33518541" integrity sha512-j4gX3ctzgD4xVWllXAhm6M+kHFEvrFoUPFq60X/pgkjsWCocGuhtNfB0rW43ICG8hCnlz8IYl7O7b8V8qY7SPg== +"@sentry/utils@7.119.0": + version "7.119.0" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.119.0.tgz#debe29020f6ef3786a5bd855cf1b97116b7be826" + integrity sha512-ZwyXexWn2ZIe2bBoYnXJVPc2esCSbKpdc6+0WJa8eutXfHq3FRKg4ohkfCBpfxljQGEfP1+kfin945lA21Ka+A== + dependencies: + "@sentry/types" "7.119.0" + +"@sentry/utils@7.80.0": + version "7.80.0" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.80.0.tgz#5bd682fa9a382eea952d4fa3628f0f33e4240ff3" + integrity sha512-XbBCEl6uLvE50ftKwrEo6XWdDaZXHXu+kkHXTPWQEcnbvfZKLuG9V0Hxtxxq3xQgyWmuF05OH1GcqYqiO+v5Yg== + dependencies: + "@sentry/types" "7.80.0" + "@sentry/utils@8.29.0": version "8.29.0" resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-8.29.0.tgz#d4a36643369e30ba62ef8f40f149420a100f64bb" @@ -8732,6 +8853,13 @@ history@^5.2.0: dependencies: "@babel/runtime" "^7.7.6" +hoist-non-react-statics@^3.3.2: + version "3.3.2" + resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45" + integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw== + dependencies: + react-is "^16.7.0" + hoopy@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/hoopy/-/hoopy-0.1.4.tgz#609207d661100033a9a9402ad3dea677381c1b1d" @@ -9112,6 +9240,11 @@ imagemin@^9.0.0: slash "^5.1.0" uint8array-extras "^1.1.0" +immediate@~3.0.5: + version "3.0.6" + resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.0.6.tgz#9db1dbd0faf8de6fbe0f5dd5e56bb606280de69b" + integrity sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ== + immutable@^4.0.0: version "4.1.0" resolved "https://registry.yarnpkg.com/immutable/-/immutable-4.1.0.tgz#f795787f0db780183307b9eb2091fcac1f6fafef" @@ -10525,6 +10658,13 @@ levn@~0.3.0: prelude-ls "~1.1.2" type-check "~0.3.2" +lie@3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/lie/-/lie-3.1.1.tgz#9a436b2cc7746ca59de7a41fa469b3efb76bd87e" + integrity sha512-RiNhHysUjhrDQntfYSfY4MU24coXXdEOgw9WGcKHNeEwffDYbF//u87M1EWaMGzuFoSbqW0C9C6lEEhDOAswfw== + dependencies: + immediate "~3.0.5" + lilconfig@2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-2.1.0.tgz#78e23ac89ebb7e1bfbf25b18043de756548e7f52" @@ -10594,6 +10734,13 @@ loader-utils@^2.0.0, loader-utils@^2.0.4: emojis-list "^3.0.0" json5 "^2.1.2" +localforage@^1.8.1: + version "1.10.0" + resolved "https://registry.yarnpkg.com/localforage/-/localforage-1.10.0.tgz#5c465dc5f62b2807c3a84c0c6a1b1b3212781dd4" + integrity sha512-14/H1aX7hzBBmmh7sGPd+AOMkkIrHM3Z1PAyGgZigA1H1p5O5ANnMyWzvpAETtG68/dC4pC0ncy3+PPGzXZHPg== + dependencies: + lie "3.1.1" + locate-path@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0" @@ -13286,7 +13433,7 @@ react-dom@^18.3.1: loose-envify "^1.1.0" scheduler "^0.23.2" -react-is@^16.13.1: +react-is@^16.13.1, react-is@^16.7.0: version "16.13.1" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== From 7d326857481034a725703fdbbf4cf1bd7a24f36a Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Fri, 10 Nov 2023 20:00:26 +0100 Subject: [PATCH 06/21] chore(telemetry): load Sentry on demand --- client/src/telemetry/sentry.ts | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/client/src/telemetry/sentry.ts b/client/src/telemetry/sentry.ts index 9e781bf8252e..4dd4a1b2469f 100644 --- a/client/src/telemetry/sentry.ts +++ b/client/src/telemetry/sentry.ts @@ -1,20 +1,21 @@ import { SENTRY_ENVIRONMENT, SENTRY_RELEASE } from "../env"; export function initSentry(dsn: string) { - let events: ErrorEvent[] = []; + let initSentry: Promise | null = null; const errorHandler = (event: ErrorEvent) => { - events.push(event); + if (!initSentry) { + initSentry = import( + /* webpackChunkName: "sentry" */ "@sentry/react" + ).then((Sentry) => { + Sentry.init({ + dsn, + release: SENTRY_RELEASE, + environment: SENTRY_ENVIRONMENT || "dev", + }); + return Sentry; + }); + } + initSentry.then((Sentry) => Sentry.captureException(event)); }; window.addEventListener("error", errorHandler); - import(/* webpackChunkName: "sentry" */ "@sentry/react").then((Sentry) => { - Sentry.init({ - dsn, - release: SENTRY_RELEASE, - environment: SENTRY_ENVIRONMENT || "dev", - }); - window.removeEventListener("error", errorHandler); - for (const event of events) { - Sentry.captureException(event); - } - }); } From b1baa078fb979a9a045fbf3f4e05f738d2cefb77 Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Fri, 10 Nov 2023 21:09:38 +0100 Subject: [PATCH 07/21] fixup! chore(telemetry): load Sentry on demand --- client/src/telemetry/sentry.ts | 43 ++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/client/src/telemetry/sentry.ts b/client/src/telemetry/sentry.ts index 4dd4a1b2469f..cdbfd1120154 100644 --- a/client/src/telemetry/sentry.ts +++ b/client/src/telemetry/sentry.ts @@ -1,21 +1,34 @@ -import { SENTRY_ENVIRONMENT, SENTRY_RELEASE } from "../env"; +import { SENTRY_DSN, SENTRY_ENVIRONMENT, SENTRY_RELEASE } from "../env"; + +let sentryPromise: Promise | null = null; + +function loadSentry(): Promise { + if (!sentryPromise) { + sentryPromise = import( + /* webpackChunkName: "sentry" */ "@sentry/react" + ).then((Sentry) => { + Sentry.init({ + dsn: SENTRY_DSN, + release: SENTRY_RELEASE, + environment: SENTRY_ENVIRONMENT || "dev", + }); + return Sentry; + }); + } + return sentryPromise; +} export function initSentry(dsn: string) { - let initSentry: Promise | null = null; + let removeEventListener: (() => void) | null = null; const errorHandler = (event: ErrorEvent) => { - if (!initSentry) { - initSentry = import( - /* webpackChunkName: "sentry" */ "@sentry/react" - ).then((Sentry) => { - Sentry.init({ - dsn, - release: SENTRY_RELEASE, - environment: SENTRY_ENVIRONMENT || "dev", - }); - return Sentry; - }); - } - initSentry.then((Sentry) => Sentry.captureException(event)); + loadSentry().then((Sentry) => { + if (removeEventListener) { + removeEventListener(); + removeEventListener = null; + } + Sentry.captureException(event); + }); }; window.addEventListener("error", errorHandler); + removeEventListener = () => window.removeEventListener("error", errorHandler); } From 6af261e599263ff11ae00a5004c0c835486f223c Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Fri, 10 Nov 2023 21:15:29 +0100 Subject: [PATCH 08/21] fix(telemetry): deduplicate errors before sentry was loaded --- client/src/telemetry/sentry.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/src/telemetry/sentry.ts b/client/src/telemetry/sentry.ts index cdbfd1120154..4e496868dc35 100644 --- a/client/src/telemetry/sentry.ts +++ b/client/src/telemetry/sentry.ts @@ -20,13 +20,17 @@ function loadSentry(): Promise { export function initSentry(dsn: string) { let removeEventListener: (() => void) | null = null; + const capturedMessages = new Set(); const errorHandler = (event: ErrorEvent) => { loadSentry().then((Sentry) => { if (removeEventListener) { removeEventListener(); removeEventListener = null; } - Sentry.captureException(event); + if (!capturedMessages.has(event.message)) { + Sentry.captureException(event); + capturedMessages.add(event.message); + } }); }; window.addEventListener("error", errorHandler); From ce6cd4af91c5cb0e54e09981d150207d40523df8 Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Fri, 10 Nov 2023 21:17:07 +0100 Subject: [PATCH 09/21] fix(telemetry): remove unused initSentry() param --- client/src/index.tsx | 5 +---- client/src/telemetry/sentry.ts | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/client/src/index.tsx b/client/src/index.tsx index 9a059ae90b90..3c875cb5f407 100644 --- a/client/src/index.tsx +++ b/client/src/index.tsx @@ -8,13 +8,10 @@ import { UserDataProvider } from "./user-context"; import { UIProvider } from "./ui-context"; import { GleanProvider } from "./telemetry/glean-context"; import { PlacementProvider } from "./placement-context"; -import { SENTRY_DSN } from "./env"; import { initSentry } from "./telemetry/sentry"; // import * as serviceWorker from './serviceWorker'; -if (SENTRY_DSN) { - initSentry(SENTRY_DSN); -} +initSentry(); const container = document.getElementById("root"); if (!container) { diff --git a/client/src/telemetry/sentry.ts b/client/src/telemetry/sentry.ts index 4e496868dc35..5cfb2ae89928 100644 --- a/client/src/telemetry/sentry.ts +++ b/client/src/telemetry/sentry.ts @@ -18,7 +18,7 @@ function loadSentry(): Promise { return sentryPromise; } -export function initSentry(dsn: string) { +export function initSentry() { let removeEventListener: (() => void) | null = null; const capturedMessages = new Set(); const errorHandler = (event: ErrorEvent) => { From 21e827e02e562c9dde212ffc7ec405215e4b8508 Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Fri, 10 Nov 2023 21:17:39 +0100 Subject: [PATCH 10/21] fixup! fix(telemetry): remove unused initSentry() param --- client/src/telemetry/sentry.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client/src/telemetry/sentry.ts b/client/src/telemetry/sentry.ts index 5cfb2ae89928..f71d7c470711 100644 --- a/client/src/telemetry/sentry.ts +++ b/client/src/telemetry/sentry.ts @@ -19,6 +19,9 @@ function loadSentry(): Promise { } export function initSentry() { + if (!SENTRY_DSN) { + return; + } let removeEventListener: (() => void) | null = null; const capturedMessages = new Set(); const errorHandler = (event: ErrorEvent) => { From b400d23f2ddf7326511ae7792548ed3311bcbd0d Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Fri, 10 Nov 2023 21:18:04 +0100 Subject: [PATCH 11/21] fix(telemetry): avoid invalid release value --- client/src/telemetry/sentry.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/telemetry/sentry.ts b/client/src/telemetry/sentry.ts index f71d7c470711..149b1b08f12c 100644 --- a/client/src/telemetry/sentry.ts +++ b/client/src/telemetry/sentry.ts @@ -9,7 +9,7 @@ function loadSentry(): Promise { ).then((Sentry) => { Sentry.init({ dsn: SENTRY_DSN, - release: SENTRY_RELEASE, + release: SENTRY_RELEASE || "dev", environment: SENTRY_ENVIRONMENT || "dev", }); return Sentry; From 54df66cb7711e6a8a305fb154c0cc940f11f24cd Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Fri, 10 Nov 2023 21:21:46 +0100 Subject: [PATCH 12/21] chore(webpack): quantify gain of sentry treeshaking --- client/config/webpack.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/config/webpack.config.js b/client/config/webpack.config.js index 8ef571c7d2cd..8a360f7ed068 100644 --- a/client/config/webpack.config.js +++ b/client/config/webpack.config.js @@ -414,7 +414,7 @@ function config(webpackEnv) { // during a production build. // Otherwise React will be compiled in the very slow development mode. new webpack.DefinePlugin(env.stringified), - // Treeshake Sentry. + // Treeshake Sentry (saves about 12 kB on the chunk). new webpack.DefinePlugin({ __SENTRY_DEBUG__: false, __SENTRY_TRACING__: false, From bcaf327b4e385ca800573f5c282f7527aaa231c1 Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Mon, 9 Sep 2024 16:26:52 +0200 Subject: [PATCH 13/21] chore(deps): bump @sentry/* from 7.80.0 to 8.29.0 --- package.json | 4 +- yarn.lock | 215 ++++++++++++++------------------------------------- 2 files changed, 60 insertions(+), 159 deletions(-) diff --git a/package.json b/package.json index 072c6032dbca..ba8710194b33 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,7 @@ "@mdn/browser-compat-data": "^5.5.51", "@mozilla/glean": "5.0.3", "@sentry/node": "^8.29.0", - "@sentry/react": "^7.80.0", + "@sentry/react": "^8.29.0", "@stripe/stripe-js": "^4.4.0", "@use-it/interval": "^1.0.0", "@vscode/ripgrep": "^1.15.9", @@ -159,7 +159,7 @@ "@mdn/minimalist": "^2.0.4", "@playwright/test": "^1.47.0", "@pmmmwh/react-refresh-webpack-plugin": "^0.5.15", - "@sentry/browser": "^7.80.0", + "@sentry/browser": "^8.29.0", "@svgr/webpack": "^8.1.0", "@swc/core": "^1.7.24", "@testing-library/react": "^15.0.7", diff --git a/yarn.lock b/yarn.lock index b4b1613d6f00..91043ac9fbfc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2941,83 +2941,56 @@ resolved "https://registry.yarnpkg.com/@sec-ant/readable-stream/-/readable-stream-0.4.1.tgz#60de891bb126abfdc5410fdc6166aca065f10a0c" integrity sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg== -"@sentry-internal/feedback@7.119.0": - version "7.119.0" - resolved "https://registry.yarnpkg.com/@sentry-internal/feedback/-/feedback-7.119.0.tgz#429b3ea0fd34e928d2e7de5dcbe9377272a3f221" - integrity sha512-om8TkAU5CQGO8nkmr7qsSBVkP+/vfeS4JgtW3sjoTK0fhj26+DljR6RlfCGWtYQdPSP6XV7atcPTjbSnsmG9FQ== - dependencies: - "@sentry/core" "7.119.0" - "@sentry/types" "7.119.0" - "@sentry/utils" "7.119.0" - -"@sentry-internal/replay-canvas@7.119.0": - version "7.119.0" - resolved "https://registry.yarnpkg.com/@sentry-internal/replay-canvas/-/replay-canvas-7.119.0.tgz#85669d184ba79150e64d05de02f5e2b616e68371" - integrity sha512-NL02VQx6ekPxtVRcsdp1bp5Tb5w6vnfBKSIfMKuDRBy5A10Uc3GSoy/c3mPyHjOxB84452A+xZSx6bliEzAnuA== - dependencies: - "@sentry/core" "7.119.0" - "@sentry/replay" "7.119.0" - "@sentry/types" "7.119.0" - "@sentry/utils" "7.119.0" - -"@sentry-internal/tracing@7.119.0": - version "7.119.0" - resolved "https://registry.yarnpkg.com/@sentry-internal/tracing/-/tracing-7.119.0.tgz#201561af2a4ad1837333287c26050a5e688537ca" - integrity sha512-oKdFJnn+56f0DHUADlL8o9l8jTib3VDLbWQBVkjD9EprxfaCwt2m8L5ACRBdQ8hmpxCEo4I8/6traZ7qAdBUqA== - dependencies: - "@sentry/core" "7.119.0" - "@sentry/types" "7.119.0" - "@sentry/utils" "7.119.0" - -"@sentry-internal/tracing@7.80.0": - version "7.80.0" - resolved "https://registry.yarnpkg.com/@sentry-internal/tracing/-/tracing-7.80.0.tgz#f9a6c0456b3cbf4a53c986a0b9208572d80e0756" - integrity sha512-P1Ab9gamHLsbH9D82i1HY8xfq9dP8runvc4g50AAd6OXRKaJ45f2KGRZUmnMEVqBQ7YoPYp2LFMkrhNYbcZEoQ== - dependencies: - "@sentry/core" "7.80.0" - "@sentry/types" "7.80.0" - "@sentry/utils" "7.80.0" - -"@sentry/browser@7.80.0": - version "7.80.0" - resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.80.0.tgz#385fb59ac1d52b67919087f3d7044575ae0abbdd" - integrity sha512-Ngwjc+yyf/aH5q7iQM1LeDNlhM1Ilt4ZLUogTghZR/guwNWmCtk3OHcjOLz7fxBBj9wGFUc2pHPyeYM6bQhrEw== - dependencies: - "@sentry-internal/tracing" "7.80.0" - "@sentry/core" "7.80.0" - "@sentry/replay" "7.80.0" - "@sentry/types" "7.80.0" - "@sentry/utils" "7.80.0" - -"@sentry/browser@^7.80.0": - version "7.119.0" - resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-7.119.0.tgz#65004015c107be5d2f49a852ebcffc5d19d90e0d" - integrity sha512-WwmW1Y4D764kVGeKmdsNvQESZiAn9t8LmCWO0ucBksrjL2zw9gBPtOpRcO6l064sCLeSxxzCN+kIxhRm1gDFEA== - dependencies: - "@sentry-internal/feedback" "7.119.0" - "@sentry-internal/replay-canvas" "7.119.0" - "@sentry-internal/tracing" "7.119.0" - "@sentry/core" "7.119.0" - "@sentry/integrations" "7.119.0" - "@sentry/replay" "7.119.0" - "@sentry/types" "7.119.0" - "@sentry/utils" "7.119.0" - -"@sentry/core@7.119.0": - version "7.119.0" - resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.119.0.tgz#a6e41119bb03ec27689f9ad04e79d1fba5b7fc37" - integrity sha512-CS2kUv9rAJJEjiRat6wle3JATHypB0SyD7pt4cpX5y0dN5dZ1JrF57oLHRMnga9fxRivydHz7tMTuBhSSwhzjw== - dependencies: - "@sentry/types" "7.119.0" - "@sentry/utils" "7.119.0" - -"@sentry/core@7.80.0": - version "7.80.0" - resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.80.0.tgz#7b8a460c19160b81ade20080333189f1a80c1410" - integrity sha512-nJiiymdTSEyI035/rdD3VOq6FlOZ2wWLR5bit9LK8a3rzHU3UXkwScvEo6zYgs0Xp1sC0yu1S9+0BEiYkmi29A== - dependencies: - "@sentry/types" "7.80.0" - "@sentry/utils" "7.80.0" +"@sentry-internal/browser-utils@8.29.0": + version "8.29.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/browser-utils/-/browser-utils-8.29.0.tgz#c84e8d8a08170dbf52968e6b563775949c2ac532" + integrity sha512-6HpyQkaqPvK6Lnigjlarq/LDYgXT2OBNf24RK7z0ipJSxSIpmtelfzHbnwWYnypNDXfTDdPm97fZEenQHryYJA== + dependencies: + "@sentry/core" "8.29.0" + "@sentry/types" "8.29.0" + "@sentry/utils" "8.29.0" + +"@sentry-internal/feedback@8.29.0": + version "8.29.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/feedback/-/feedback-8.29.0.tgz#9c562f7d13794131b6ac87860cda5492ed538e37" + integrity sha512-yAL5YMEFk4XaeVRUGEguydahRzaQrNPAaWRv6k+XRzCv9CGBhxb14KXQc9X/penlauMFcDfgelCPKcTqcf6wDw== + dependencies: + "@sentry/core" "8.29.0" + "@sentry/types" "8.29.0" + "@sentry/utils" "8.29.0" + +"@sentry-internal/replay-canvas@8.29.0": + version "8.29.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/replay-canvas/-/replay-canvas-8.29.0.tgz#57a08adec35641607b53ea079f7a6ef539e98c00" + integrity sha512-W2YbZRvp2lYC50V51fNLcnoIiK1Km4vSc+v6SL7c//lv2qpyumoUAAIDKY+14s8Lgt1RsR6rfZhfheD4O/6WSQ== + dependencies: + "@sentry-internal/replay" "8.29.0" + "@sentry/core" "8.29.0" + "@sentry/types" "8.29.0" + "@sentry/utils" "8.29.0" + +"@sentry-internal/replay@8.29.0": + version "8.29.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/replay/-/replay-8.29.0.tgz#d704ad5a137c3dd6fe398e0c9856c4fc043be707" + integrity sha512-Xgv/eYucsm7GaGKms2ClQ02NpD07MxjoTjp1/vYZm0H4Q08dVphVZrQp7hL1oX/VD9mb5SFyyKuuIRqIu7S8RA== + dependencies: + "@sentry-internal/browser-utils" "8.29.0" + "@sentry/core" "8.29.0" + "@sentry/types" "8.29.0" + "@sentry/utils" "8.29.0" + +"@sentry/browser@8.29.0", "@sentry/browser@^8.29.0": + version "8.29.0" + resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-8.29.0.tgz#d60a754a26c5235fab05fe2e675ced07209aaa88" + integrity sha512-aKTy4H/3RI0q9LIeepesjWGlGNeh4HGFfwQjzHME8gcWCQ5LSlzYX4U+hu2yp7r1Jfd9MUTFfOuuLih2HGLGsQ== + dependencies: + "@sentry-internal/browser-utils" "8.29.0" + "@sentry-internal/feedback" "8.29.0" + "@sentry-internal/replay" "8.29.0" + "@sentry-internal/replay-canvas" "8.29.0" + "@sentry/core" "8.29.0" + "@sentry/types" "8.29.0" + "@sentry/utils" "8.29.0" "@sentry/core@8.29.0": version "8.29.0" @@ -3027,16 +3000,6 @@ "@sentry/types" "8.29.0" "@sentry/utils" "8.29.0" -"@sentry/integrations@7.119.0": - version "7.119.0" - resolved "https://registry.yarnpkg.com/@sentry/integrations/-/integrations-7.119.0.tgz#5b25c603026dbacfe1ae7bb8d768506a129149fb" - integrity sha512-OHShvtsRW0A+ZL/ZbMnMqDEtJddPasndjq+1aQXw40mN+zeP7At/V1yPZyFaURy86iX7Ucxw5BtmzuNy7hLyTA== - dependencies: - "@sentry/core" "7.119.0" - "@sentry/types" "7.119.0" - "@sentry/utils" "7.119.0" - localforage "^1.8.1" - "@sentry/node@^8.29.0": version "8.29.0" resolved "https://registry.yarnpkg.com/@sentry/node/-/node-8.29.0.tgz#6e462b8802356a630c56733dc795a4035464c4ab" @@ -3084,65 +3047,22 @@ "@sentry/types" "8.29.0" "@sentry/utils" "8.29.0" -"@sentry/react@^7.80.0": - version "7.80.0" - resolved "https://registry.yarnpkg.com/@sentry/react/-/react-7.80.0.tgz#ee589ff202174ced45e77dc2714237031ca9c726" - integrity sha512-xoX7fqgY0NZR9Fud/IJ4a3b8Z/HsdwU5SLILi46lV+CWaXS6eFM1E81jG2Vd2EeYIpkH+bMA//XHMEod8LAJcQ== +"@sentry/react@^8.29.0": + version "8.29.0" + resolved "https://registry.yarnpkg.com/@sentry/react/-/react-8.29.0.tgz#f69b87a7947213dcaabdd18bafb6ac818d30f0a2" + integrity sha512-ux+9rNHx2ZyWC94OBb5K1HFQU/v64gL/n3co9e/3cD9nUnqXMJuw/IofiwD1fv6nfdWECLU50A1OtXhA9/c+XQ== dependencies: - "@sentry/browser" "7.80.0" - "@sentry/types" "7.80.0" - "@sentry/utils" "7.80.0" + "@sentry/browser" "8.29.0" + "@sentry/core" "8.29.0" + "@sentry/types" "8.29.0" + "@sentry/utils" "8.29.0" hoist-non-react-statics "^3.3.2" -"@sentry/replay@7.119.0": - version "7.119.0" - resolved "https://registry.yarnpkg.com/@sentry/replay/-/replay-7.119.0.tgz#50881079d013c77f87a994331d8bcad1d49e0960" - integrity sha512-BnNsYL+X5I4WCH6wOpY6HQtp4MgVt0NVlhLUsEyrvMUiTs0bPkDBrulsgZQBUKJsbOr3l9nHrFoNVB/0i6WNLA== - dependencies: - "@sentry-internal/tracing" "7.119.0" - "@sentry/core" "7.119.0" - "@sentry/types" "7.119.0" - "@sentry/utils" "7.119.0" - -"@sentry/replay@7.80.0": - version "7.80.0" - resolved "https://registry.yarnpkg.com/@sentry/replay/-/replay-7.80.0.tgz#0626d85af1d8573038d52ae9e244e3e95fa47385" - integrity sha512-wWnpuJq3OaDLp1LutE4oxWXnau04fvwuzBjuaFvOXOV+pB/kn+pDPuVOC5+FH/RMRZ5ftwX5+dF6fojfcLVGCg== - dependencies: - "@sentry-internal/tracing" "7.80.0" - "@sentry/core" "7.80.0" - "@sentry/types" "7.80.0" - "@sentry/utils" "7.80.0" - -"@sentry/types@7.119.0": - version "7.119.0" - resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.119.0.tgz#8b3d7a1405c362e75cd900d46089df4e70919d2a" - integrity sha512-27qQbutDBPKGbuJHROxhIWc1i0HJaGLA90tjMu11wt0E4UNxXRX+UQl4Twu68v4EV3CPvQcEpQfgsViYcXmq+w== - -"@sentry/types@7.80.0": - version "7.80.0" - resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.80.0.tgz#f6896de2d231a7f8d814cf1c981c474240e96d8a" - integrity sha512-4bpMO+2jWiWLDa8zbTASWWNLWe6yhjfPsa7/6VH5y9x1NGtL8oRbqUsTgsvjF3nmeHEMkHQsC8NHPaQ/ibFmZQ== - "@sentry/types@8.29.0": version "8.29.0" resolved "https://registry.yarnpkg.com/@sentry/types/-/types-8.29.0.tgz#c19e43524b8e7766028f4da8f02eddcc33518541" integrity sha512-j4gX3ctzgD4xVWllXAhm6M+kHFEvrFoUPFq60X/pgkjsWCocGuhtNfB0rW43ICG8hCnlz8IYl7O7b8V8qY7SPg== -"@sentry/utils@7.119.0": - version "7.119.0" - resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.119.0.tgz#debe29020f6ef3786a5bd855cf1b97116b7be826" - integrity sha512-ZwyXexWn2ZIe2bBoYnXJVPc2esCSbKpdc6+0WJa8eutXfHq3FRKg4ohkfCBpfxljQGEfP1+kfin945lA21Ka+A== - dependencies: - "@sentry/types" "7.119.0" - -"@sentry/utils@7.80.0": - version "7.80.0" - resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.80.0.tgz#5bd682fa9a382eea952d4fa3628f0f33e4240ff3" - integrity sha512-XbBCEl6uLvE50ftKwrEo6XWdDaZXHXu+kkHXTPWQEcnbvfZKLuG9V0Hxtxxq3xQgyWmuF05OH1GcqYqiO+v5Yg== - dependencies: - "@sentry/types" "7.80.0" - "@sentry/utils@8.29.0": version "8.29.0" resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-8.29.0.tgz#d4a36643369e30ba62ef8f40f149420a100f64bb" @@ -9240,11 +9160,6 @@ imagemin@^9.0.0: slash "^5.1.0" uint8array-extras "^1.1.0" -immediate@~3.0.5: - version "3.0.6" - resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.0.6.tgz#9db1dbd0faf8de6fbe0f5dd5e56bb606280de69b" - integrity sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ== - immutable@^4.0.0: version "4.1.0" resolved "https://registry.yarnpkg.com/immutable/-/immutable-4.1.0.tgz#f795787f0db780183307b9eb2091fcac1f6fafef" @@ -10658,13 +10573,6 @@ levn@~0.3.0: prelude-ls "~1.1.2" type-check "~0.3.2" -lie@3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/lie/-/lie-3.1.1.tgz#9a436b2cc7746ca59de7a41fa469b3efb76bd87e" - integrity sha512-RiNhHysUjhrDQntfYSfY4MU24coXXdEOgw9WGcKHNeEwffDYbF//u87M1EWaMGzuFoSbqW0C9C6lEEhDOAswfw== - dependencies: - immediate "~3.0.5" - lilconfig@2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/lilconfig/-/lilconfig-2.1.0.tgz#78e23ac89ebb7e1bfbf25b18043de756548e7f52" @@ -10734,13 +10642,6 @@ loader-utils@^2.0.0, loader-utils@^2.0.4: emojis-list "^3.0.0" json5 "^2.1.2" -localforage@^1.8.1: - version "1.10.0" - resolved "https://registry.yarnpkg.com/localforage/-/localforage-1.10.0.tgz#5c465dc5f62b2807c3a84c0c6a1b1b3212781dd4" - integrity sha512-14/H1aX7hzBBmmh7sGPd+AOMkkIrHM3Z1PAyGgZigA1H1p5O5ANnMyWzvpAETtG68/dC4pC0ncy3+PPGzXZHPg== - dependencies: - lie "3.1.1" - locate-path@^5.0.0: version "5.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0" From 2abfc924c397c4000579970202f52e92053e1dc7 Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Mon, 9 Sep 2024 17:41:58 +0200 Subject: [PATCH 14/21] chore(deps-dev): remove unnecessary @sentry/browser --- package.json | 1 - yarn.lock | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index ba8710194b33..0b5ae7cbbc38 100644 --- a/package.json +++ b/package.json @@ -159,7 +159,6 @@ "@mdn/minimalist": "^2.0.4", "@playwright/test": "^1.47.0", "@pmmmwh/react-refresh-webpack-plugin": "^0.5.15", - "@sentry/browser": "^8.29.0", "@svgr/webpack": "^8.1.0", "@swc/core": "^1.7.24", "@testing-library/react": "^15.0.7", diff --git a/yarn.lock b/yarn.lock index 91043ac9fbfc..7629f1e6c6a9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2979,7 +2979,7 @@ "@sentry/types" "8.29.0" "@sentry/utils" "8.29.0" -"@sentry/browser@8.29.0", "@sentry/browser@^8.29.0": +"@sentry/browser@8.29.0": version "8.29.0" resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-8.29.0.tgz#d60a754a26c5235fab05fe2e675ced07209aaa88" integrity sha512-aKTy4H/3RI0q9LIeepesjWGlGNeh4HGFfwQjzHME8gcWCQ5LSlzYX4U+hu2yp7r1Jfd9MUTFfOuuLih2HGLGsQ== From 8e27d77a7c37fdc2802722369a6bd075a0737ceb Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Mon, 9 Sep 2024 18:00:03 +0200 Subject: [PATCH 15/21] chore(build): avoid importing everything from @sentry/node --- build/index.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/build/index.ts b/build/index.ts index c9cb88533910..2a2b14267705 100644 --- a/build/index.ts +++ b/build/index.ts @@ -3,7 +3,10 @@ import path from "node:path"; import chalk from "chalk"; import * as cheerio from "cheerio"; -import * as Sentry from "@sentry/node"; +import { + setContext as setSentryContext, + setTags as setSentryTags, +} from "@sentry/node"; import { MacroInvocationError, @@ -182,12 +185,12 @@ export async function buildDocument( document, documentOptions: DocumentOptions = {} ): Promise { - Sentry.setContext("doc", { + setSentryContext("doc", { path: document?.fileInfo?.path, title: document?.metadata?.title, url: document?.url, }); - Sentry.setTags({ + setSentryTags({ doc_slug: document?.metadata?.slug, doc_locale: document?.metadata?.locale, }); From 2488abdd3fbd04c32189c7ad639968ea2b104819 Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Mon, 9 Sep 2024 18:15:49 +0200 Subject: [PATCH 16/21] chore(sentry): disable treeshake --- client/config/webpack.config.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/client/config/webpack.config.js b/client/config/webpack.config.js index 8a360f7ed068..b516068dfcad 100644 --- a/client/config/webpack.config.js +++ b/client/config/webpack.config.js @@ -415,13 +415,13 @@ function config(webpackEnv) { // Otherwise React will be compiled in the very slow development mode. new webpack.DefinePlugin(env.stringified), // Treeshake Sentry (saves about 12 kB on the chunk). - new webpack.DefinePlugin({ - __SENTRY_DEBUG__: false, - __SENTRY_TRACING__: false, - __RRWEB_EXCLUDE_IFRAME__: true, - __RRWEB_EXCLUDE_SHADOW_DOM__: true, - __SENTRY_EXCLUDE_REPLAY_WORKER__: true, - }), + //new webpack.DefinePlugin({ + // __SENTRY_DEBUG__: false, + // __SENTRY_TRACING__: false, + // __RRWEB_EXCLUDE_IFRAME__: true, + // __RRWEB_EXCLUDE_SHADOW_DOM__: true, + // __SENTRY_EXCLUDE_REPLAY_WORKER__: true, + //}), // Experimental hot reloading for React . // https://github.com/facebook/react/tree/main/packages/react-refresh isEnvDevelopment && From 8ab5269afa52cda9c4001e2de291200fa40f2727 Mon Sep 17 00:00:00 2001 From: Leo McArdle Date: Fri, 6 Sep 2024 17:04:25 +0000 Subject: [PATCH 17/21] enhance(build): show bundle size diff on PRs also updates the `yarn analyze` command --- .github/workflows/pr-bundlesize-compare.yml | 99 ++++++++++++ client/config/webpack.config.js | 7 + package.json | 6 +- yarn.lock | 157 ++++++++++---------- 4 files changed, 190 insertions(+), 79 deletions(-) create mode 100644 .github/workflows/pr-bundlesize-compare.yml diff --git a/.github/workflows/pr-bundlesize-compare.yml b/.github/workflows/pr-bundlesize-compare.yml new file mode 100644 index 000000000000..576bfefc8996 --- /dev/null +++ b/.github/workflows/pr-bundlesize-compare.yml @@ -0,0 +1,99 @@ +on: + # this action will error unless run in a pr context + pull_request: + +jobs: + # Build current and upload stats.json + build-head: + name: "Build head" + permissions: + contents: read + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{github.event.pull_request.head.ref}} + + - name: Setup Node.js environment + uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + cache: yarn + + - name: Cache @vscode/ripgrep bin + uses: actions/cache@v4 + with: + key: vscode-ripgrep-bin-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('yarn.lock') }} + path: node_modules/@vscode/ripgrep/bin/ + + - name: Install all yarn packages + run: yarn --frozen-lockfile + env: + # https://github.com/microsoft/vscode-ripgrep#github-api-limit-note + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Build + run: yarn build:client + env: + ANALYZE_BUNDLE: true + + - name: Upload stats.json + uses: actions/upload-artifact@v4 + with: + name: head-stats + path: ./client/build/stats.json + + # Build base for comparison and upload stats.json + build-base: + name: "Build base" + permissions: + contents: read + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.base_ref }} + + - name: Setup Node.js environment + uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + cache: yarn + + - name: Cache @vscode/ripgrep bin + uses: actions/cache@v4 + with: + key: vscode-ripgrep-bin-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('yarn.lock') }} + path: node_modules/@vscode/ripgrep/bin/ + + - name: Install all yarn packages + run: yarn --frozen-lockfile + env: + # https://github.com/microsoft/vscode-ripgrep#github-api-limit-note + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Build + run: yarn build:client + env: + ANALYZE_BUNDLE: true + + - name: Upload stats.json + uses: actions/upload-artifact@v4 + with: + name: base-stats + path: ./client/build/stats.json + + # run the action against the stats.json files + compare: + name: "Compare base & head bundle sizes" + runs-on: ubuntu-latest + needs: [build-base, build-head] + permissions: + pull-requests: write + steps: + - uses: actions/download-artifact@v4 + - uses: github/webpack-bundlesize-compare-action@v1.8.2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + current-stats-json-path: ./head-stats/stats.json + base-stats-json-path: ./base-stats/stats.json diff --git a/client/config/webpack.config.js b/client/config/webpack.config.js index db2139910913..f839f3762044 100644 --- a/client/config/webpack.config.js +++ b/client/config/webpack.config.js @@ -11,6 +11,7 @@ import CssMinimizerPlugin from "css-minimizer-webpack-plugin"; import { WebpackManifestPlugin } from "webpack-manifest-plugin"; import ESLintPlugin from "eslint-webpack-plugin"; import ReactRefreshWebpackPlugin from "@pmmmwh/react-refresh-webpack-plugin"; +import { BundleAnalyzerPlugin } from "webpack-bundle-analyzer"; import paths from "./paths.js"; import getClientEnvironment from "./env.js"; @@ -497,6 +498,12 @@ function config(webpackEnv) { new ESLintPlugin({ extensions: ["js", "mjs", "jsx", "ts", "tsx"], }), + isEnvProduction && + process.env.ANALYZE_BUNDLE && + new BundleAnalyzerPlugin({ + analyzerMode: "disabled", + generateStatsFile: true, + }), ].filter(Boolean), // Turn off performance processing because we utilize // our own hints via the FileSizeReporter diff --git a/package.json b/package.json index ba9ba603db4b..d56fe0c66266 100644 --- a/package.json +++ b/package.json @@ -15,8 +15,7 @@ }, "scripts": { "ai-help-macros": "cross-env NODE_OPTIONS='--no-warnings=ExperimentalWarning --loader ts-node/esm' node scripts/ai-help-macros.ts", - "analyze": "source-map-explorer 'client/build/static/js/*.js'", - "analyze:css": "source-map-explorer 'client/build/static/css/*.css'", + "analyze": "(test -f client/build/stats.json || cross-env ANALYZE_BUNDLE=true yarn build:client) && webpack-bundle-analyzer client/build/stats.json", "build": "cross-env NODE_ENV=production NODE_OPTIONS='--no-warnings=ExperimentalWarning --loader ts-node/esm' node build/cli.ts", "build:blog": "cross-env NODE_ENV=production NODE_OPTIONS='--no-warnings=ExperimentalWarning --loader ts-node/esm' node build/build-blog.ts", "build:client": "cd client && cross-env NODE_ENV=production BABEL_ENV=production node scripts/build.js", @@ -171,6 +170,7 @@ "@types/react": "^18.3.4", "@types/react-dom": "^18.3.0", "@types/react-modal": "^3.16.3", + "@types/webpack-bundle-analyzer": "^4.7.0", "babel-jest": "^29.7.0", "babel-loader": "^9.1.3", "babel-plugin-named-asset-import": "^0.3.8", @@ -239,7 +239,6 @@ "rough-notation": "^0.5.1", "sass": "^1.78.0", "sass-loader": "^16.0.1", - "source-map-explorer": "^2.5.3", "source-map-loader": "^5.0.0", "style-loader": "^3.3.4", "stylelint": "^15.11.0", @@ -258,6 +257,7 @@ "typescript": "^5.5.4", "typescript-eslint": "^8.4.0", "webpack": "^5.94.0", + "webpack-bundle-analyzer": "^4.10.2", "webpack-cli": "^5.1.4", "webpack-dev-server": "^5.1.0", "webpack-manifest-plugin": "^5.0.0", diff --git a/yarn.lock b/yarn.lock index 79f9aaa3cf39..d323bf7db091 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1943,7 +1943,7 @@ enabled "2.0.x" kuler "^2.0.0" -"@discoveryjs/json-ext@^0.5.0": +"@discoveryjs/json-ext@0.5.7", "@discoveryjs/json-ext@^0.5.0": version "0.5.7" resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz#1d572bfbbe14b7704e0ba0f39b74815b84870d70" integrity sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw== @@ -2912,6 +2912,11 @@ schema-utils "^4.2.0" source-map "^0.7.3" +"@polka/url@^1.0.0-next.24": + version "1.0.0-next.25" + resolved "https://registry.yarnpkg.com/@polka/url/-/url-1.0.0-next.25.tgz#f077fdc0b5d0078d30893396ff4827a13f99e817" + integrity sha512-j7P6Rgr3mmtdkeDGTe0E/aYyWEWVtc5yFXtHCRHs28/jptDEWfaVOc5T7cblqy1XKPPfCxJc/8DwQ5YgLOZOVQ== + "@prisma/instrumentation@5.19.1": version "5.19.1" resolved "https://registry.yarnpkg.com/@prisma/instrumentation/-/instrumentation-5.19.1.tgz#146319cf85f22b7a43296f0f40cfeac55516e66e" @@ -3811,6 +3816,15 @@ resolved "https://registry.yarnpkg.com/@types/unist/-/unist-2.0.6.tgz#250a7b16c3b91f672a24552ec64678eeb1d3a08d" integrity sha512-PBjIUxZHOuj0R15/xuwJYjFi+KZdNFrehocChv4g5hu6aFroHue8m0lBP0POdK2nKzbw0cgV1mws8+V/JAcEkQ== +"@types/webpack-bundle-analyzer@^4.7.0": + version "4.7.0" + resolved "https://registry.yarnpkg.com/@types/webpack-bundle-analyzer/-/webpack-bundle-analyzer-4.7.0.tgz#fe199e724ce3d38705f6f1ba4d62429b7c360541" + integrity sha512-c5i2ThslSNSG8W891BRvOd/RoCjI2zwph8maD22b1adtSns20j+0azDDMCK06DiVrzTgnwiDl5Ntmu1YRJw8Sg== + dependencies: + "@types/node" "*" + tapable "^2.2.0" + webpack "^5" + "@types/wrap-ansi@^3.0.0": version "3.0.0" resolved "https://registry.yarnpkg.com/@types/wrap-ansi/-/wrap-ansi-3.0.0.tgz#18b97a972f94f60a679fd5c796d96421b9abb9fd" @@ -4273,11 +4287,23 @@ acorn-jsx@^5.3.2: resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937" integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ== +acorn-walk@^8.0.0: + version "8.3.3" + resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.3.3.tgz#9caeac29eefaa0c41e3d4c65137de4d6f34df43e" + integrity sha512-MxXdReSRhGO7VlFe1bRG/oI7/mdLV9B9JJT0N8vZOhF7gFRR5l3M8W9G8JxmKV+JC5mGqJ0QvqfSOLsCPa4nUw== + dependencies: + acorn "^8.11.0" + acorn-walk@^8.0.2, acorn-walk@^8.1.1: version "8.2.0" resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1" integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA== +acorn@^8.0.4, acorn@^8.11.0: + version "8.12.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.12.1.tgz#71616bdccbe25e27a54439e0046e89ca76df2248" + integrity sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg== + acorn@^8.1.0, acorn@^8.4.1, acorn@^8.7.1, acorn@^8.8.1, acorn@^8.8.2, acorn@^8.9.0: version "8.11.3" resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.11.3.tgz#71e0b14e13a4ec160724b38fb7b0f233b1b81d7a" @@ -5021,11 +5047,6 @@ bser@2.1.1: dependencies: node-int64 "^0.4.0" -btoa@^1.2.1: - version "1.2.1" - resolved "https://registry.yarnpkg.com/btoa/-/btoa-1.2.1.tgz#01a9909f8b2c93f6bf680ba26131eb30f7fa3d73" - integrity sha512-SB4/MIGlsiVkMcHmT+pSmIPoNDoHg+7cMzmt3Uxt628MTz2487DKSqK/fuhFBrkuqrYv5UCEnACpF4dTFNKc/g== - buffer-alloc-unsafe@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz#bd7dc26ae2972d0eda253be061dba992349c19f0" @@ -5437,15 +5458,6 @@ client-only@^0.0.1: resolved "https://registry.yarnpkg.com/client-only/-/client-only-0.0.1.tgz#38bba5d403c41ab150bff64a95c85013cf73bca1" integrity sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA== -cliui@^7.0.2: - version "7.0.4" - resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f" - integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ== - dependencies: - string-width "^4.2.0" - strip-ansi "^6.0.0" - wrap-ansi "^7.0.0" - cliui@^8.0.1: version "8.0.1" resolved "https://registry.yarnpkg.com/cliui/-/cliui-8.0.1.tgz#0c04b075db02cbfe60dc8e6cf2f5486b1a3608aa" @@ -6078,7 +6090,7 @@ dayjs@^1.11.13: resolved "https://registry.yarnpkg.com/dayjs/-/dayjs-1.11.13.tgz#92430b0139055c3ebb60150aa13e860a4b5a366c" integrity sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg== -debounce@^1.0.0: +debounce@^1.0.0, debounce@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/debounce/-/debounce-1.2.1.tgz#38881d8f4166a5c5848020c11827b834bcb3e0a5" integrity sha512-XRRe6Glud4rd/ZGQfiV1ruXSfbvfJedlV9Y6zOlP+2K04vBYiJEte6stfFkCP03aMnY5tsipamumUjL14fofug== @@ -6578,7 +6590,7 @@ ee-first@1.1.1: resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" integrity sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow== -ejs@^3.1.10, ejs@^3.1.5: +ejs@^3.1.10: version "3.1.10" resolved "https://registry.yarnpkg.com/ejs/-/ejs-3.1.10.tgz#69ab8358b14e896f80cc39e62087b88500c3ac3b" integrity sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA== @@ -6968,7 +6980,7 @@ escalade@^3.1.1, escalade@^3.1.2: resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.2.tgz#54076e9ab29ea5bf3d8f1ed62acffbb88272df27" integrity sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA== -escape-html@^1.0.3, escape-html@~1.0.3: +escape-html@~1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/escape-html/-/escape-html-1.0.3.tgz#0258eae4d3d0c0974de1c169188ef0051d1d1988" integrity sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow== @@ -8757,7 +8769,7 @@ html-entities@^2.1.0, html-entities@^2.4.0: resolved "https://registry.yarnpkg.com/html-entities/-/html-entities-2.4.0.tgz#edd0cee70402584c8c76cc2c0556db09d1f45061" integrity sha512-igBTJcNNNhvZFRtm8uA6xMY6xYleeDwn3PeBCkDz7tHttv4F2hsDI2aPgNERWzvRcNYHNT3ymRaQzllmXj4YsQ== -html-escaper@^2.0.0: +html-escaper@^2.0.0, html-escaper@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/html-escaper/-/html-escaper-2.0.2.tgz#dfd60027da36a36dfcbe236262c00a5822681453" integrity sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg== @@ -9678,7 +9690,7 @@ is-weakset@^2.0.1: call-bind "^1.0.2" get-intrinsic "^1.1.1" -is-wsl@^2.1.1, is-wsl@^2.2.0: +is-wsl@^2.2.0: version "2.2.0" resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-2.2.0.tgz#74a4c76e77ca9fd3f932f290c17ea326cd157271" integrity sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww== @@ -11474,6 +11486,11 @@ mozjpeg@^8.0.0: bin-build "^3.0.0" bin-wrapper "^4.0.0" +mrmime@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/mrmime/-/mrmime-2.0.0.tgz#151082a6e06e59a9a39b46b3e14d5cfe92b3abb4" + integrity sha512-eu38+hdgojoyq63s+yTpN4XMBdt5l8HhMhc4VKLO9KM5caLIBvUm4thi7fFaxyTmCKeNnXZ5pAlBwCUnhA09uw== + ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" @@ -11857,14 +11874,6 @@ open@^10.0.3, open@^10.1.0: is-inside-container "^1.0.0" is-wsl "^3.1.0" -open@^7.3.1: - version "7.4.2" - resolved "https://registry.yarnpkg.com/open/-/open-7.4.2.tgz#b8147e26dcf3e426316c730089fd71edd29c2321" - integrity sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q== - dependencies: - is-docker "^2.0.0" - is-wsl "^2.1.1" - openai@^4.58.1: version "4.58.1" resolved "https://registry.yarnpkg.com/openai/-/openai-4.58.1.tgz#be3720720e730cd6e14726b346d0bbe8d7983017" @@ -11880,6 +11889,11 @@ openai@^4.58.1: node-fetch "^2.6.7" qs "^6.10.3" +opener@^1.5.2: + version "1.5.2" + resolved "https://registry.yarnpkg.com/opener/-/opener-1.5.2.tgz#5d37e1f35077b9dcac4301372271afdeb2a13598" + integrity sha512-ur5UIdyw5Y7yEj9wLzhqXiy6GZ3Mwx0yGI+5sMn2r0N0v3cKJvUmFH5yPP+WXh9e0xfyzyJX95D8l088DNFj7A== + opentelemetry-instrumentation-fetch-node@1.2.3: version "1.2.3" resolved "https://registry.yarnpkg.com/opentelemetry-instrumentation-fetch-node/-/opentelemetry-instrumentation-fetch-node-1.2.3.tgz#beb24048bdccb1943ba2a5bbadca68020e448ea7" @@ -13830,13 +13844,6 @@ rimraf@^3.0.2: dependencies: glob "^7.1.3" -rimraf@~2.6.2: - version "2.6.3" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab" - integrity sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA== - dependencies: - glob "^7.1.3" - rough-notation@^0.5.1: version "0.5.1" resolved "https://registry.yarnpkg.com/rough-notation/-/rough-notation-0.5.1.tgz#32abbb16b973fb00fba83ab96b18704e98620e95" @@ -14259,6 +14266,15 @@ simple-swizzle@^0.2.2: dependencies: is-arrayish "^0.3.1" +sirv@^2.0.3: + version "2.0.4" + resolved "https://registry.yarnpkg.com/sirv/-/sirv-2.0.4.tgz#5dd9a725c578e34e449f332703eb2a74e46a29b0" + integrity sha512-94Bdh3cC2PKrbgSOUqTiGPWVZeSiXfKOVZNJniWoqrWrRkB1CJzBU3NEbiTsPcYy1lDsANA/THzS+9WBiy5nfQ== + dependencies: + "@polka/url" "^1.0.0-next.24" + mrmime "^2.0.0" + totalist "^3.0.0" + sisteransi@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed" @@ -14376,24 +14392,6 @@ source-list-map@^2.0.1: resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-2.0.1.tgz#3993bd873bfc48479cca9ea3a547835c7c154b34" integrity sha512-qnQ7gVMxGNxsiL4lEuJwe/To8UnK7fAnmbGEEH8RpLouuKbeEm0lhbQVFIrNSuB+G7tVrAlVsZgETT5nljf+Iw== -source-map-explorer@^2.5.3: - version "2.5.3" - resolved "https://registry.yarnpkg.com/source-map-explorer/-/source-map-explorer-2.5.3.tgz#33551b51e33b70f56d15e79083cdd4c43e583b69" - integrity sha512-qfUGs7UHsOBE5p/lGfQdaAj/5U/GWYBw2imEpD6UQNkqElYonkow8t+HBL1qqIl3CuGZx7n8/CQo4x1HwSHhsg== - dependencies: - btoa "^1.2.1" - chalk "^4.1.0" - convert-source-map "^1.7.0" - ejs "^3.1.5" - escape-html "^1.0.3" - glob "^7.1.6" - gzip-size "^6.0.0" - lodash "^4.17.20" - open "^7.3.1" - source-map "^0.7.4" - temp "^0.9.4" - yargs "^16.2.0" - source-map-generator@0.8.0: version "0.8.0" resolved "https://registry.npmmirror.com/source-map-generator/-/source-map-generator-0.8.0.tgz#10d5ca0651e2c9302ea338739cbd4408849c5d00" @@ -15159,14 +15157,6 @@ temp-dir@^3.0.0: resolved "https://registry.yarnpkg.com/temp-dir/-/temp-dir-3.0.0.tgz#7f147b42ee41234cc6ba3138cd8e8aa2302acffa" integrity sha512-nHc6S/bwIilKHNRgK/3jlhDoIHcp45YgyiwcAk46Tr0LfEqGBVpmiAyuiuxeVE44m3mXnEeVhaipLOEWmH+Njw== -temp@^0.9.4: - version "0.9.4" - resolved "https://registry.yarnpkg.com/temp/-/temp-0.9.4.tgz#cd20a8580cb63635d0e4e9d4bd989d44286e7620" - integrity sha512-yYrrsWnrXMcdsnu/7YMYAofM1ktpL5By7vZhf15CrXijWWrEYZks5AXBudalfSWJLlnen/QUJUB5aoB0kqZUGA== - dependencies: - mkdirp "^0.5.1" - rimraf "~2.6.2" - tempfile@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/tempfile/-/tempfile-2.0.0.tgz#6b0446856a9b1114d1856ffcbe509cccb0977265" @@ -15289,6 +15279,11 @@ token-types@^6.0.0: "@tokenizer/token" "^0.3.0" ieee754 "^1.2.1" +totalist@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/totalist/-/totalist-3.0.1.tgz#ba3a3d600c915b1a97872348f79c127475f6acf8" + integrity sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ== + tough-cookie@^4.1.2, tough-cookie@^4.1.4: version "4.1.4" resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-4.1.4.tgz#945f1461b45b5a8c76821c33ea49c3ac192c1b36" @@ -16036,6 +16031,24 @@ webidl-conversions@^7.0.0: resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-7.0.0.tgz#256b4e1882be7debbf01d05f0aa2039778ea080a" integrity sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g== +webpack-bundle-analyzer@^4.10.2: + version "4.10.2" + resolved "https://registry.yarnpkg.com/webpack-bundle-analyzer/-/webpack-bundle-analyzer-4.10.2.tgz#633af2862c213730be3dbdf40456db171b60d5bd" + integrity sha512-vJptkMm9pk5si4Bv922ZbKLV8UTT4zib4FPgXMhgzUny0bfDDkLXAVQs3ly3fS4/TN9ROFtb0NFrm04UXFE/Vw== + dependencies: + "@discoveryjs/json-ext" "0.5.7" + acorn "^8.0.4" + acorn-walk "^8.0.0" + commander "^7.2.0" + debounce "^1.2.1" + escape-string-regexp "^4.0.0" + gzip-size "^6.0.0" + html-escaper "^2.0.2" + opener "^1.5.2" + picocolors "^1.0.0" + sirv "^2.0.3" + ws "^7.3.1" + webpack-cli@^5.1.4: version "5.1.4" resolved "https://registry.yarnpkg.com/webpack-cli/-/webpack-cli-5.1.4.tgz#c8e046ba7eaae4911d7e71e2b25b776fcc35759b" @@ -16135,7 +16148,7 @@ webpack-sources@^3.2.3: resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde" integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w== -webpack@^5.94.0: +webpack@^5, webpack@^5.94.0: version "5.94.0" resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.94.0.tgz#77a6089c716e7ab90c1c67574a28da518a20970f" integrity sha512-KcsGn50VT+06JH/iunZJedYGUJS5FGjow8wb9c0v5n1Om8O1g4L6LjtfxwlXIATopoQu+vOXXa7gYisWxCoPyg== @@ -16433,6 +16446,11 @@ write-file-atomic@^5.0.1: imurmurhash "^0.1.4" signal-exit "^4.0.1" +ws@^7.3.1: + version "7.5.10" + resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.10.tgz#58b5c20dc281633f6c19113f39b349bd8bd558d9" + integrity sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ== + ws@^8.11.0, ws@^8.18.0: version "8.18.0" resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.0.tgz#0d7505a6eafe2b0e712d232b42279f53bc289bbc" @@ -16500,7 +16518,7 @@ yaml@^2.2.2: resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.2.2.tgz#ec551ef37326e6d42872dad1970300f8eb83a073" integrity sha512-CBKFWExMn46Foo4cldiChEzn7S7SRV+wqiluAb6xmueD/fGyRHIhX8m14vVGgeFWjN540nKCNVj6P21eQjgTuA== -yargs-parser@^20.2.2, yargs-parser@^20.2.9: +yargs-parser@^20.2.9: version "20.2.9" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee" integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w== @@ -16510,19 +16528,6 @@ yargs-parser@^21.0.0, yargs-parser@^21.1.1: resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-21.1.1.tgz#9096bceebf990d21bb31fa9516e0ede294a77d35" integrity sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw== -yargs@^16.2.0: - version "16.2.0" - resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66" - integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw== - dependencies: - cliui "^7.0.2" - escalade "^3.1.1" - get-caller-file "^2.0.5" - require-directory "^2.1.1" - string-width "^4.2.0" - y18n "^5.0.5" - yargs-parser "^20.2.2" - yargs@^17.3.1: version "17.6.0" resolved "https://registry.yarnpkg.com/yargs/-/yargs-17.6.0.tgz#e134900fc1f218bc230192bdec06a0a5f973e46c" From 6312cbc932235bc52f8ece167616459a7277cc41 Mon Sep 17 00:00:00 2001 From: Leo McArdle Date: Fri, 6 Sep 2024 17:49:11 +0000 Subject: [PATCH 18/21] fix(bundle-size): conditionally remove hashes to keep filenames static --- .github/workflows/pr-bundlesize-compare.yml | 4 +-- client/config/webpack.config.js | 39 ++++++++++++++------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/.github/workflows/pr-bundlesize-compare.yml b/.github/workflows/pr-bundlesize-compare.yml index 576bfefc8996..c9fef0021a98 100644 --- a/.github/workflows/pr-bundlesize-compare.yml +++ b/.github/workflows/pr-bundlesize-compare.yml @@ -35,7 +35,7 @@ jobs: - name: Build run: yarn build:client env: - ANALYZE_BUNDLE: true + ANALYZE_BUNDLE_PR: true - name: Upload stats.json uses: actions/upload-artifact@v4 @@ -75,7 +75,7 @@ jobs: - name: Build run: yarn build:client env: - ANALYZE_BUNDLE: true + ANALYZE_BUNDLE_PR: true - name: Upload stats.json uses: actions/upload-artifact@v4 diff --git a/client/config/webpack.config.js b/client/config/webpack.config.js index f839f3762044..92906a67a3b3 100644 --- a/client/config/webpack.config.js +++ b/client/config/webpack.config.js @@ -22,6 +22,10 @@ import ForkTsCheckerWebpackPlugin from "fork-ts-checker-webpack-plugin"; // Source maps are resource heavy and can cause out of memory issue for large source files. const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== "false"; +// to compare file sizes in PRs we need them to not include hashes +const analyzeBundlePR = process.env.ANALYZE_BUNDLE_PR; +const analyzeBundle = analyzeBundlePR || process.env.ANALYZE_BUNDLE; + // This is the production and development configuration. // It is focused on developer experience, fast rebuilds, and a minimal bundle. function config(webpackEnv) { @@ -119,15 +123,20 @@ function config(webpackEnv) { // Add /* filename */ comments to generated require()s in the output. pathinfo: isEnvDevelopment, // There will be one main bundle, and one file per asynchronous chunk. - // In development, it does not produce real files. - filename: isEnvProduction - ? "static/js/[name].[contenthash:8].js" - : isEnvDevelopment && "static/js/bundle.js", + filename: analyzeBundlePR + ? "static/js/[name].js" + : isEnvProduction + ? "static/js/[name].[contenthash:8].js" + : isEnvDevelopment && "static/js/bundle.js", // There are also additional JS chunk files if you use code splitting. - chunkFilename: isEnvProduction - ? "static/js/[name].[contenthash:8].chunk.js" - : isEnvDevelopment && "static/js/[name].chunk.js", - assetModuleFilename: "static/media/[name].[hash][ext]", + chunkFilename: analyzeBundlePR + ? "static/js/[name].chunk.js" + : isEnvProduction + ? "static/js/[name].[contenthash:8].chunk.js" + : isEnvDevelopment && "static/js/[name].chunk.js", + assetModuleFilename: analyzeBundlePR + ? "static/media/[file]" + : "static/media/[name].[hash][ext]", publicPath: "/", // Point sourcemap entries to original disk location (format as URL on Windows) devtoolModuleFilenameTemplate: isEnvProduction @@ -252,7 +261,9 @@ function config(webpackEnv) { { loader: resolve.sync("file-loader"), options: { - name: "static/media/[name].[hash].[ext]", + name: analyzeBundlePR + ? "static/media/[path][name].[ext]" + : "static/media/[name].[hash].[ext]", }, }, ], @@ -429,8 +440,12 @@ function config(webpackEnv) { new MiniCssExtractPlugin({ // Options similar to the same options in webpackOptions.output // both options are optional - filename: "static/css/[name].[contenthash:8].css", - chunkFilename: "static/css/[name].[contenthash:8].chunk.css", + filename: analyzeBundlePR + ? "static/css/[name].css" + : "static/css/[name].[contenthash:8].css", + chunkFilename: analyzeBundlePR + ? "static/css/[name].chunk.css" + : "static/css/[name].[contenthash:8].chunk.css", }), // Generate an asset manifest file with the following content: // - "files" key: Mapping of all asset filenames to their corresponding @@ -499,7 +514,7 @@ function config(webpackEnv) { extensions: ["js", "mjs", "jsx", "ts", "tsx"], }), isEnvProduction && - process.env.ANALYZE_BUNDLE && + analyzeBundle && new BundleAnalyzerPlugin({ analyzerMode: "disabled", generateStatsFile: true, From 0f7e753fc88d92f1b401af675ab78879c154d130 Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Wed, 11 Sep 2024 11:21:48 +0200 Subject: [PATCH 19/21] Revert "chore(sentry): disable treeshake" This reverts commit 2488abdd3fbd04c32189c7ad639968ea2b104819. --- client/config/webpack.config.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/client/config/webpack.config.js b/client/config/webpack.config.js index b516068dfcad..8a360f7ed068 100644 --- a/client/config/webpack.config.js +++ b/client/config/webpack.config.js @@ -415,13 +415,13 @@ function config(webpackEnv) { // Otherwise React will be compiled in the very slow development mode. new webpack.DefinePlugin(env.stringified), // Treeshake Sentry (saves about 12 kB on the chunk). - //new webpack.DefinePlugin({ - // __SENTRY_DEBUG__: false, - // __SENTRY_TRACING__: false, - // __RRWEB_EXCLUDE_IFRAME__: true, - // __RRWEB_EXCLUDE_SHADOW_DOM__: true, - // __SENTRY_EXCLUDE_REPLAY_WORKER__: true, - //}), + new webpack.DefinePlugin({ + __SENTRY_DEBUG__: false, + __SENTRY_TRACING__: false, + __RRWEB_EXCLUDE_IFRAME__: true, + __RRWEB_EXCLUDE_SHADOW_DOM__: true, + __SENTRY_EXCLUDE_REPLAY_WORKER__: true, + }), // Experimental hot reloading for React . // https://github.com/facebook/react/tree/main/packages/react-refresh isEnvDevelopment && From bfff09584a330259e8761320c8bfa8ea752eeeed Mon Sep 17 00:00:00 2001 From: Claas Augner Date: Wed, 11 Sep 2024 11:22:38 +0200 Subject: [PATCH 20/21] chore(deps): bump @sentry/browser from 8.29.0 to 8.30.0 --- package.json | 1 + yarn.lock | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/package.json b/package.json index 316a114341f6..f0fe94bd1ab7 100644 --- a/package.json +++ b/package.json @@ -74,6 +74,7 @@ "@mdn/bcd-utils-api": "^0.0.7", "@mdn/browser-compat-data": "^5.5.51", "@mozilla/glean": "5.0.3", + "@sentry/browser": "^8.30.0", "@sentry/node": "^8.29.0", "@sentry/react": "^8.29.0", "@stripe/stripe-js": "^4.4.0", diff --git a/yarn.lock b/yarn.lock index 9ffdd35fec40..6d01fa0834d2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2581,6 +2581,15 @@ "@sentry/types" "8.29.0" "@sentry/utils" "8.29.0" +"@sentry-internal/browser-utils@8.30.0": + version "8.30.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/browser-utils/-/browser-utils-8.30.0.tgz#eb68c79556ffb864eb5924a53affde52f2b77362" + integrity sha512-pwX+awNWaxSOAsBLVLqc1+Hw+Fm1Nci9mbKFA6Ed5YzCG049PnBVQwugpmx2dcyyCqJpORhcIqb9jHdCkYmCiA== + dependencies: + "@sentry/core" "8.30.0" + "@sentry/types" "8.30.0" + "@sentry/utils" "8.30.0" + "@sentry-internal/feedback@8.29.0": version "8.29.0" resolved "https://registry.yarnpkg.com/@sentry-internal/feedback/-/feedback-8.29.0.tgz#9c562f7d13794131b6ac87860cda5492ed538e37" @@ -2590,6 +2599,15 @@ "@sentry/types" "8.29.0" "@sentry/utils" "8.29.0" +"@sentry-internal/feedback@8.30.0": + version "8.30.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/feedback/-/feedback-8.30.0.tgz#6f78a245298502e4cc5ce77313dde6965abfecfe" + integrity sha512-ParFRxQY6helxkwUDmro77Wc5uSIC6rZos88jYMrYwFmoTJaNWf4lDzPyECfdSiSYyzSMZk4dorSUN85Ul7DCg== + dependencies: + "@sentry/core" "8.30.0" + "@sentry/types" "8.30.0" + "@sentry/utils" "8.30.0" + "@sentry-internal/replay-canvas@8.29.0": version "8.29.0" resolved "https://registry.yarnpkg.com/@sentry-internal/replay-canvas/-/replay-canvas-8.29.0.tgz#57a08adec35641607b53ea079f7a6ef539e98c00" @@ -2600,6 +2618,16 @@ "@sentry/types" "8.29.0" "@sentry/utils" "8.29.0" +"@sentry-internal/replay-canvas@8.30.0": + version "8.30.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/replay-canvas/-/replay-canvas-8.30.0.tgz#3630eec14d23b1fd368d8c331ee695aa5bb41425" + integrity sha512-y/QqcvchhtMlVA6eOZicIfTxtZarazQZJuFW0018ynPxBTiuuWSxMCLqduulXUYsFejfD8/eKHb3BpCIFdDYjg== + dependencies: + "@sentry-internal/replay" "8.30.0" + "@sentry/core" "8.30.0" + "@sentry/types" "8.30.0" + "@sentry/utils" "8.30.0" + "@sentry-internal/replay@8.29.0": version "8.29.0" resolved "https://registry.yarnpkg.com/@sentry-internal/replay/-/replay-8.29.0.tgz#d704ad5a137c3dd6fe398e0c9856c4fc043be707" @@ -2610,6 +2638,16 @@ "@sentry/types" "8.29.0" "@sentry/utils" "8.29.0" +"@sentry-internal/replay@8.30.0": + version "8.30.0" + resolved "https://registry.yarnpkg.com/@sentry-internal/replay/-/replay-8.30.0.tgz#6a4a8bd551a16ea5f77f913acbccd88061868c84" + integrity sha512-/KFre+BrovPCiovgAu5N1ErJtkDVzkJA5hV3Jw011AlxRWxrmPwu6+9sV9/rn3tqYAGyq6IggYqeIOHhLh1Ihg== + dependencies: + "@sentry-internal/browser-utils" "8.30.0" + "@sentry/core" "8.30.0" + "@sentry/types" "8.30.0" + "@sentry/utils" "8.30.0" + "@sentry/browser@8.29.0": version "8.29.0" resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-8.29.0.tgz#d60a754a26c5235fab05fe2e675ced07209aaa88" @@ -2623,6 +2661,19 @@ "@sentry/types" "8.29.0" "@sentry/utils" "8.29.0" +"@sentry/browser@^8.30.0": + version "8.30.0" + resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-8.30.0.tgz#3c6d5ef62d7daca2873b47f59b136c33941b56de" + integrity sha512-M+tKqawH9S3CqlAIcqdZcHbcsNQkEa9MrPqPCYvXco3C4LRpNizJP2XwBiGQY2yK+fOSvbaWpPtlI938/wuRZQ== + dependencies: + "@sentry-internal/browser-utils" "8.30.0" + "@sentry-internal/feedback" "8.30.0" + "@sentry-internal/replay" "8.30.0" + "@sentry-internal/replay-canvas" "8.30.0" + "@sentry/core" "8.30.0" + "@sentry/types" "8.30.0" + "@sentry/utils" "8.30.0" + "@sentry/core@8.29.0": version "8.29.0" resolved "https://registry.yarnpkg.com/@sentry/core/-/core-8.29.0.tgz#52032ece2d7b60f3775f10189c27e26b1cebdbca" From 23ec4a1368bc45641159e86daf67af590f754e2d Mon Sep 17 00:00:00 2001 From: Leo McArdle Date: Mon, 9 Sep 2024 11:40:39 +0000 Subject: [PATCH 21/21] fix(bundle-size): partially revert 4a5cf81b8958bb3b5f80b8d20ae0bc1ae1d426bb although "deterministic" isn't when changing loaders, it *is* when changing import order - which is more important. we'll probably avoid the prior problem with changing loader config changing chunk names (but not their contents) if/when we move to named chunks --- client/config/webpack.config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/config/webpack.config.js b/client/config/webpack.config.js index 52a17f0098ba..0c6e8a9460a4 100644 --- a/client/config/webpack.config.js +++ b/client/config/webpack.config.js @@ -162,8 +162,8 @@ function config(webpackEnv) { level: "none", }, optimization: { - chunkIds: isEnvProduction ? "natural" : "named", - moduleIds: isEnvProduction ? "natural" : "named", + chunkIds: isEnvProduction ? "deterministic" : "named", + moduleIds: isEnvProduction ? "deterministic" : "named", minimize: isEnvProduction, minimizer: [ // This is only used in production mode