From 0fe9b522098a36b06c6ff6c25ac475373471393d Mon Sep 17 00:00:00 2001 From: Quinn Slack Date: Fri, 6 Oct 2023 09:20:05 -0700 Subject: [PATCH] add sentry esbuild plugin (#57409) Webpack builds already use the Webpack Sentry plugin to automatically inject code to send errors to Sentry. This adds the same to the esbuild build config. --- client/web/dev/esbuild/build.ts | 11 +++ package.json | 1 + pnpm-lock.yaml | 142 ++++++++++++++++++++++++++++++-- 3 files changed, 145 insertions(+), 9 deletions(-) diff --git a/client/web/dev/esbuild/build.ts b/client/web/dev/esbuild/build.ts index 98fdaf3d44c..42d56dd680b 100644 --- a/client/web/dev/esbuild/build.ts +++ b/client/web/dev/esbuild/build.ts @@ -1,6 +1,7 @@ import { writeFileSync } from 'fs' import path from 'path' +import { sentryEsbuildPlugin } from '@sentry/esbuild-plugin' import * as esbuild from 'esbuild' import { @@ -66,6 +67,16 @@ export const BUILD_OPTIONS: esbuild.BuildOptions = { }), omitSlowDeps ? null : monacoPlugin(MONACO_LANGUAGES_AND_FEATURES), buildTimerPlugin, + ENVIRONMENT_CONFIG.SENTRY_UPLOAD_SOURCE_MAPS + ? sentryEsbuildPlugin({ + org: ENVIRONMENT_CONFIG.SENTRY_ORGANIZATION, + project: ENVIRONMENT_CONFIG.SENTRY_PROJECT, + authToken: ENVIRONMENT_CONFIG.SENTRY_DOT_COM_AUTH_TOKEN, + silent: true, + release: { name: `frontend@${ENVIRONMENT_CONFIG.VERSION}` }, + sourcemaps: { assets: path.join(ENVIRONMENT_CONFIG.STATIC_ASSETS_PATH, 'scripts', '*.map') }, + }) + : null, ].filter(isDefined), define: { ...Object.fromEntries( diff --git a/package.json b/package.json index 30504742b7a..513cd4645cf 100644 --- a/package.json +++ b/package.json @@ -117,6 +117,7 @@ "@pollyjs/persister-fs": "^5.0.0", "@remix-run/server-runtime": "^1.17.0", "@sentry/cli": "^1.74.4", + "@sentry/esbuild-plugin": "^2.7.1", "@sentry/webpack-plugin": "^1.20.0", "@slack/web-api": "^5.15.0", "@sourcegraph/eslint-config": "0.32.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9fbf9b4f38c..164b8e00402 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -558,6 +558,9 @@ importers: '@sentry/cli': specifier: ^1.74.4 version: 1.74.6 + '@sentry/esbuild-plugin': + specifier: ^2.7.1 + version: 2.7.1 '@sentry/webpack-plugin': specifier: ^1.20.0 version: 1.20.0 @@ -6229,7 +6232,7 @@ packages: '@types/jsonwebtoken': 8.5.9 chalk: 4.1.2 debug: 4.3.4 - dotenv: 16.0.3 + dotenv: 16.3.1 graphql: 15.4.0 graphql-request: 5.0.0(graphql@15.4.0) http-proxy-agent: 5.0.0 @@ -9033,6 +9036,16 @@ packages: picomatch: 2.3.1 dev: true + /@sentry-internal/tracing@7.70.0: + resolution: {integrity: sha512-SpbE6wZhs6QwG2ORWCt8r28o1T949qkWx/KeRTCdK4Ub95PQ3Y3DgnqD8Wz//3q50Wt6EZDEibmz4t067g6PPg==} + engines: {node: '>=8'} + dependencies: + '@sentry/core': 7.70.0 + '@sentry/types': 7.70.0 + '@sentry/utils': 7.70.0 + tslib: 2.1.0 + dev: true + /@sentry/browser@7.8.1: resolution: {integrity: sha512-9JuagYqHyaZu/4RqyxrAgEHo71oV592XBuUKC33gajCVKWbyG3mNqudSMoHtdM1DrV9REZ4Elha7zFaE2cJX6g==} engines: {node: '>=8'} @@ -9043,6 +9056,23 @@ packages: tslib: 2.1.0 dev: false + /@sentry/bundler-plugin-core@2.7.1: + resolution: {integrity: sha512-ZC/B/7FzzgGpux2t54B2ioXudlq60MHMVPaUeuFzWwxmxiArrV4uBXcp18RMW5ns4biik5WBAD72vbsoloBfIQ==} + engines: {node: '>= 14'} + dependencies: + '@sentry/cli': 2.21.1 + '@sentry/node': 7.70.0 + '@sentry/utils': 7.70.0 + dotenv: 16.3.1 + find-up: 5.0.0 + glob: 9.3.2 + magic-string: 0.27.0 + unplugin: 1.0.1 + transitivePeerDependencies: + - encoding + - supports-color + dev: true + /@sentry/cli@1.74.6: resolution: {integrity: sha512-pJ7JJgozyjKZSTjOGi86chIngZMLUlYt2HOog+OJn+WGvqEkVymu8m462j1DiXAnex9NspB4zLLNuZ/R6rTQHg==} engines: {node: '>= 8'} @@ -9061,6 +9091,31 @@ packages: - supports-color dev: true + /@sentry/cli@2.21.1: + resolution: {integrity: sha512-iJGL818zHzVb129CNWLoZriymq2nrnhk1XqN4Fh0AMxYJcOICmXYKR8RSkLhhE1U1J1D77UzA+FyBhWHOFA82A==} + engines: {node: '>= 10'} + hasBin: true + requiresBuild: true + dependencies: + https-proxy-agent: 5.0.1 + node-fetch: 2.6.11 + progress: 2.0.3 + proxy-from-env: 1.1.0 + which: 2.0.2 + transitivePeerDependencies: + - encoding + - supports-color + dev: true + + /@sentry/core@7.70.0: + resolution: {integrity: sha512-voUsGVM+jwRp99AQYFnRvr7sVd2tUhIMj1L6F42LtD3vp7t5ZnKp3NpXagtFW2vWzXESfyJUBhM0qI/bFvn7ZA==} + engines: {node: '>=8'} + dependencies: + '@sentry/types': 7.70.0 + '@sentry/utils': 7.70.0 + tslib: 2.1.0 + dev: true + /@sentry/core@7.8.1: resolution: {integrity: sha512-PRivbdIzApi/gSixAxozhOBTylSVdw/9VxaStYHd7JJGhs36KXkV8ylpbCmYO4ap7/Ue9/slzwpvPOJJzmzAgA==} engines: {node: '>=8'} @@ -9071,6 +9126,18 @@ packages: tslib: 2.1.0 dev: false + /@sentry/esbuild-plugin@2.7.1: + resolution: {integrity: sha512-D1aOSq2mGoXLWq/g2tFRY+Aqc2e+IJWuBJgyhM3i+fimCv+tf/EKBuW/Hknf3IRJ8pGxNlgonOu9fDXknOpSLg==} + engines: {node: '>= 14'} + dependencies: + '@sentry/bundler-plugin-core': 2.7.1 + unplugin: 1.0.1 + uuid: 9.0.0 + transitivePeerDependencies: + - encoding + - supports-color + dev: true + /@sentry/hub@7.8.1: resolution: {integrity: sha512-AxwyGyS9Lp4XsURu4t8opa5vZ+NAB6I/n+B/Uix3YZea9z8jdWYAu9vsXSizOrtxekc/i7ZN4bnlNgXVHix0iA==} engines: {node: '>=8'} @@ -9080,11 +9147,40 @@ packages: tslib: 2.1.0 dev: false + /@sentry/node@7.70.0: + resolution: {integrity: sha512-GeGlnu3QnJX0GN2FvZ3E31e48ZhRzEpREyC0Wa4BRvYHnyiGvsQjo/0RKeq6vvlggRhVnuoMg/jESyUmdntrAA==} + engines: {node: '>=8'} + dependencies: + '@sentry-internal/tracing': 7.70.0 + '@sentry/core': 7.70.0 + '@sentry/types': 7.70.0 + '@sentry/utils': 7.70.0 + cookie: 0.5.0 + https-proxy-agent: 5.0.1 + lru_map: 0.3.3 + tslib: 2.1.0 + transitivePeerDependencies: + - supports-color + dev: true + + /@sentry/types@7.70.0: + resolution: {integrity: sha512-rY4DqpiDBtXSk4MDNBH3dwWqfPbNBI/9GA7Y5WJSIcObBtfBKp0fzYliHJZD0pgM7d4DPFrDn42K9Iiumgymkw==} + engines: {node: '>=8'} + dev: true + /@sentry/types@7.8.1: resolution: {integrity: sha512-LOoaeBXVI23Kh5SpIbxSRiJ6+eYZXVOFyPFH1T1mGBj95LPwRMqOdg0lUTmFJGBKbDGDB/YNjNnu1kQ7GrXBXw==} engines: {node: '>=8'} dev: false + /@sentry/utils@7.70.0: + resolution: {integrity: sha512-0cChMH0lsGp+5I3D4wOHWwjFN19HVrGUs7iWTLTO5St3EaVbdeLbI1vFXHxMxvopbwgpeZafbreHw/loIdZKpw==} + engines: {node: '>=8'} + dependencies: + '@sentry/types': 7.70.0 + tslib: 2.1.0 + dev: true + /@sentry/utils@7.8.1: resolution: {integrity: sha512-isUZjft4HWTOk1Z58KFJ/zzXeFtIJgP82CkYQlW464ZR2WCqPHYlXXXRWZpOHOfMnrf+gWeX9WAGS9rTAdhiSg==} engines: {node: '>=8'} @@ -18547,8 +18643,8 @@ packages: /dotenv-expand@5.1.0: resolution: {integrity: sha512-YXQl1DSa4/PQyRfgrv6aoNjhasp/p4qs9FjJ4q4cQk+8m4r6k4ZSiEyytKG8f8W9gi8WsQtIObNmKd+tMzNTmA==} - /dotenv@16.0.3: - resolution: {integrity: sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==} + /dotenv@16.3.1: + resolution: {integrity: sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==} engines: {node: '>=12'} dev: true @@ -20838,6 +20934,16 @@ packages: once: 1.4.0 path-is-absolute: 1.0.1 + /glob@9.3.2: + resolution: {integrity: sha512-BTv/JhKXFEHsErMte/AnfiSv8yYOLLiyH2lTg8vn02O21zWFgHPTfxtgn1QRe7NRgggUhC8hacR2Re94svHqeA==} + engines: {node: '>=16 || 14 >=14.17'} + dependencies: + fs.realpath: 1.0.0 + minimatch: 7.4.6 + minipass: 4.2.8 + path-scurry: 1.10.1 + dev: true + /global-modules@1.0.0: resolution: {integrity: sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg==} engines: {node: '>=0.10.0'} @@ -24220,7 +24326,7 @@ packages: engines: {node: '>=14.0.0'} dependencies: app-root-dir: 1.0.2 - dotenv: 16.0.3 + dotenv: 16.3.1 dotenv-expand: 10.0.0 dev: true @@ -24731,6 +24837,10 @@ packages: es5-ext: 0.10.53 dev: true + /lru_map@0.3.3: + resolution: {integrity: sha512-Pn9cox5CsMYngeDbmChANltQl+5pi6XmTrraMSzhPmMBbmgcxmqWry0U3PGapCU1yB4/LqCcom7qhHZiF/jGfQ==} + dev: true + /lunr@2.3.9: resolution: {integrity: sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==} dev: true @@ -25661,6 +25771,13 @@ packages: brace-expansion: 2.0.1 dev: true + /minimatch@7.4.6: + resolution: {integrity: sha512-sBz8G/YjVniEz6lKPNpKxXwazJe4c19fEfV2GDMX6AjFz+MX9uDWIZW8XreVhkFW3fkIdTv/gxWr/Kks5FFAVw==} + engines: {node: '>=10'} + dependencies: + brace-expansion: 2.0.1 + dev: true + /minimatch@9.0.3: resolution: {integrity: sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==} engines: {node: '>=16 || 14 >=14.17'} @@ -25708,11 +25825,9 @@ packages: yallist: 4.0.0 dev: true - /minipass@4.0.0: - resolution: {integrity: sha512-g2Uuh2jEKoht+zvO6vJqXmYpflPqzRBT+Th2h01DKh5z7wbY/AZ2gCQ78cP70YoHPyFdY30YBV5WxgLOEwOykw==} + /minipass@4.2.8: + resolution: {integrity: sha512-fNzuVyifolSLFL4NzpF+wEF4qrgqaaKX0haXPQEdQ7NKAN+WecoKMHV09YcuL/DHxrUsYQOK3MiuDf7Ip2OXfQ==} engines: {node: '>=8'} - dependencies: - yallist: 4.0.0 dev: true /minipass@7.0.2: @@ -31613,7 +31728,7 @@ packages: dependencies: chownr: 2.0.0 fs-minipass: 2.1.0 - minipass: 4.0.0 + minipass: 4.2.8 minizlib: 2.1.2 mkdirp: 1.0.4 yallist: 4.0.0 @@ -32616,6 +32731,15 @@ packages: resolution: {integrity: sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==} engines: {node: '>= 0.8'} + /unplugin@1.0.1: + resolution: {integrity: sha512-aqrHaVBWW1JVKBHmGo33T5TxeL0qWzfvjWokObHA9bYmN7eNDkwOxmLjhioHl9878qDFMAaT51XNroRyuz7WxA==} + dependencies: + acorn: 8.10.0 + chokidar: 3.5.3 + webpack-sources: 3.2.3 + webpack-virtual-modules: 0.5.0 + dev: true + /unplugin@1.4.0: resolution: {integrity: sha512-5x4eIEL6WgbzqGtF9UV8VEC/ehKptPXDS6L2b0mv4FRMkJxRtjaJfOWDd6a8+kYbqsjklix7yWP0N3SUepjXcg==} dependencies: