diff --git a/.eslintrc.js b/.eslintrc.js index 763a684cf9..4412fd7675 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -305,7 +305,7 @@ module.exports = { }, }, { - files: [ '*.config.ts', 'playwright/**', 'deploy/tools/**', 'middleware.ts', 'nextjs/**' ], + files: [ '*.config.ts', '*.config.js', 'playwright/**', 'deploy/tools/**', 'middleware.ts', 'nextjs/**' ], rules: { // for configs allow to consume env variables from process.env directly 'no-restricted-properties': [ 0 ], diff --git a/.github/workflows/pre-release.yml b/.github/workflows/pre-release.yml index fc7c85d427..94aaac7b1c 100644 --- a/.github/workflows/pre-release.yml +++ b/.github/workflows/pre-release.yml @@ -32,3 +32,8 @@ jobs: label_name: 'pre-release' label_description: Tasks in pre-release right now secrets: inherit + + upload_source_maps: + name: Upload source maps to Sentry + uses: './.github/workflows/upload-source-maps.yml' + secrets: inherit diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index eea62fafd2..bbb3f07448 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -78,3 +78,9 @@ jobs: name: Publish Docker image uses: './.github/workflows/publish-image.yml' secrets: inherit + + upload_source_maps: + name: Upload source maps to Sentry + needs: publish_image + uses: './.github/workflows/upload-source-maps.yml' + secrets: inherit diff --git a/.github/workflows/upload-source-maps.yml b/.github/workflows/upload-source-maps.yml new file mode 100644 index 0000000000..95acd14f9e --- /dev/null +++ b/.github/workflows/upload-source-maps.yml @@ -0,0 +1,49 @@ +name: Upload source maps to Sentry +on: + workflow_call: + workflow_dispatch: + +env: + SENTRY_ORG: ${{ vars.SENTRY_ORG }} + SENTRY_PROJECT: ${{ vars.SENTRY_PROJECT }} + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + SENTRY_DSN: ${{ secrets.SENTRY_DSN }} + +jobs: + build_and_upload: + name: Build app with source maps and upload to Sentry + runs-on: ubuntu-latest + if: ${{ github.ref_type == 'tag' }} + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: 18 + cache: 'yarn' + + - name: Cache node_modules + uses: actions/cache@v3 + id: cache-node-modules + with: + path: | + node_modules + key: node_modules-${{ runner.os }}-${{ hashFiles('yarn.lock') }} + + - name: Install dependencies + if: steps.cache-node-modules.outputs.cache-hit != 'true' + run: yarn --frozen-lockfile --ignore-optional + + - name: Make production build with source maps + run: yarn build + env: + NODE_ENV: production + GENERATE_SOURCEMAPS: true + + - name: Inject Sentry debug ID + run: yarn sentry-cli sourcemaps inject ./.next + + - name: Upload source maps to Sentry + run: yarn sentry-cli sourcemaps upload --release=${{ github.ref_name }} --validate ./.next \ No newline at end of file diff --git a/next.config.js b/next.config.js index a87794d387..521d101a06 100644 --- a/next.config.js +++ b/next.config.js @@ -38,6 +38,7 @@ const moduleExports = { redirects, headers, output: 'standalone', + productionBrowserSourceMaps: process.env.GENERATE_SOURCEMAPS === 'true', }; module.exports = withRoutes(moduleExports); diff --git a/package.json b/package.json index 732eec6b0d..56e6575785 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "@metamask/post-message-stream": "^7.0.0", "@metamask/providers": "^10.2.1", "@monaco-editor/react": "^4.4.6", + "@sentry/cli": "^2.21.2", "@sentry/react": "^7.72.0", "@slise/embed-react": "^2.2.0", "@tanstack/react-query": "^4.0.10", diff --git a/yarn.lock b/yarn.lock index ed7ac4b6b3..ddfb4d4731 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3396,6 +3396,17 @@ "@sentry/utils" "7.72.0" tslib "^2.4.1 || ^1.9.3" +"@sentry/cli@^2.21.2": + version "2.21.2" + resolved "https://registry.yarnpkg.com/@sentry/cli/-/cli-2.21.2.tgz#89e5633ff48a83d078c76c6997fffd4b68b2da1c" + integrity sha512-X1nye89zl+QV3FSuQDGItfM51tW9PQ7ce0TtV/12DgGgTVEgnVp5uvO3wX5XauHvulQzRPzwUL3ZK+yS5bAwCw== + dependencies: + https-proxy-agent "^5.0.0" + node-fetch "^2.6.7" + progress "^2.0.3" + proxy-from-env "^1.1.0" + which "^2.0.2" + "@sentry/core@7.72.0": version "7.72.0" resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.72.0.tgz#df19f9dc1c2cfc5993a73c0c36283c35f9c52f94" @@ -8361,7 +8372,7 @@ http-proxy-agent@^5.0.0: agent-base "6" debug "4" -https-proxy-agent@^5.0.1: +https-proxy-agent@^5.0.0, https-proxy-agent@^5.0.1: version "5.0.1" resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz#c59ef224a04fe8b754f3db0063a25ea30d0005d6" integrity sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA== @@ -9958,6 +9969,13 @@ node-fetch@^2.6.11: dependencies: whatwg-url "^5.0.0" +node-fetch@^2.6.7: + version "2.7.0" + resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.7.0.tgz#d0f0fa6e3e2dc1d27efcd8ad99d550bda94d187d" + integrity sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A== + dependencies: + whatwg-url "^5.0.0" + node-fetch@^3.2.9: version "3.2.10" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-3.2.10.tgz#e8347f94b54ae18b57c9c049ef641cef398a85c8" @@ -10652,6 +10670,11 @@ process@^0.11.10: resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" integrity sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A== +progress@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.3.tgz#7e8cf8d8f5b8f239c1bc68beb4eb78567d572ef8" + integrity sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA== + promise-polyfill@^8.1.3: version "8.3.0" resolved "https://registry.yarnpkg.com/promise-polyfill/-/promise-polyfill-8.3.0.tgz#9284810268138d103807b11f4e23d5e945a4db63" @@ -12741,7 +12764,7 @@ which-typed-array@^1.1.2, which-typed-array@^1.1.8, which-typed-array@^1.1.9: has-tostringtag "^1.0.0" is-typed-array "^1.1.10" -which@^2.0.1: +which@^2.0.1, which@^2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1" integrity sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==