diff --git a/.github/workflows/build-and-deploy-arbitrum-staging.yaml b/.github/workflows/build-and-deploy-arbitrum-staging.yaml index fe0f12ff..219765d3 100644 --- a/.github/workflows/build-and-deploy-arbitrum-staging.yaml +++ b/.github/workflows/build-and-deploy-arbitrum-staging.yaml @@ -41,4 +41,7 @@ jobs: --build-arg VITE_SENTRY_ENV=${{ secrets.SENTRY_ENV }} --build-arg VITE_ARBITRUM_ALLOW_LIST=${{secrets.VITE_ARBITRUM_ALLOW_LIST}} --build-arg VITE_HIDE_DOCUMENT_MODEL_SELECTION_SETTINGS=true + --build-arg SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }} + --build-arg SENTRY_ORG=${{ secrets.SENTRY_ORG }} + --build-arg SENTRY_PROJECT=${{ secrets.SENTRY_PROJECT }} process_type: web \ No newline at end of file diff --git a/.github/workflows/build-and-deploy-powerhouse-develop.yaml b/.github/workflows/build-and-deploy-powerhouse-develop.yaml index e45b54d1..1642a3c6 100644 --- a/.github/workflows/build-and-deploy-powerhouse-develop.yaml +++ b/.github/workflows/build-and-deploy-powerhouse-develop.yaml @@ -28,4 +28,9 @@ jobs: --build-arg VITE_ROUTER_BASENAME=/develop/powerhouse/connect --build-arg VITE_DEFAULT_DRIVES_URL=https://apps.powerhouse.io/develop/powerhouse/switchboard/d/core-dev --build-arg VITE_SEARCH_BAR_ENABLED=false + --build-arg VITE_SENTRY_DSN=${{ secrets.SENTRY_DSN }} + --build-arg VITE_SENTRY_ENV=${{ secrets.SENTRY_ENV }} + --build-arg SENTRY_AUTH_TOKEN=${{ secrets.SENTRY_AUTH_TOKEN }} + --build-arg SENTRY_ORG=${{ secrets.SENTRY_ORG }} + --build-arg SENTRY_PROJECT=${{ secrets.SENTRY_PROJECT }} process_type: web \ No newline at end of file diff --git a/.gitignore b/.gitignore index 8c5d459c..8363a407 100644 --- a/.gitignore +++ b/.gitignore @@ -64,4 +64,6 @@ out/ # Generated assets public/icons.svg -.env.local \ No newline at end of file +.env.local +# Sentry Config File +.env.sentry-build-plugin diff --git a/Dockerfile b/Dockerfile index f59bb207..51375f56 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,15 @@ FROM node:lts-alpine AS builder ARG BASE_PATH="" ENV BASE_PATH=${BASE_PATH} +ARG SENTRY_ORG="" +ENV SENTRY_ORG=${SENTRY_ORG} + +ARG SENTRY_PROJECT="" +ENV SENTRY_PROJECT=${SENTRY_PROJECT} + +ARG SENTRY_AUTH_TOKEN="" +ENV SENTRY_AUTH_TOKEN=${SENTRY_AUTH_TOKEN} + ARG VITE_BASE_HREF="" ENV VITE_BASE_HREF=${VITE_BASE_HREF} diff --git a/package-lock.json b/package-lock.json index 7416bdc2..6c8f17ff 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "dependencies": { "@powerhousedao/design-system": "1.0.0-alpha.160", "@sentry/react": "^7.109.0", + "@sentry/vite-plugin": "^2.22.2", "@tanstack/react-virtual": "^3.8.1", "did-key-creator": "^1.2.0", "document-drive": "^1.0.0-alpha.88", @@ -10026,6 +10027,15 @@ "node": ">=8" } }, + "node_modules/@sentry/babel-plugin-component-annotate": { + "version": "2.22.2", + "resolved": "https://registry.npmjs.org/@sentry/babel-plugin-component-annotate/-/babel-plugin-component-annotate-2.22.2.tgz", + "integrity": "sha512-6kFAHGcs0npIC4HTt4ULs8uOfEucvMI7VW4hoyk17jhRaW8CbxzxfWCfIeRbDkE8pYwnARaq83tu025Hrk2zgA==", + "license": "MIT", + "engines": { + "node": ">= 14" + } + }, "node_modules/@sentry/browser": { "version": "7.118.0", "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-7.118.0.tgz", @@ -10044,6 +10054,254 @@ "node": ">=8" } }, + "node_modules/@sentry/bundler-plugin-core": { + "version": "2.22.2", + "resolved": "https://registry.npmjs.org/@sentry/bundler-plugin-core/-/bundler-plugin-core-2.22.2.tgz", + "integrity": "sha512-TwEEW4FeEJ5Mamp4fGnktfVjzN77KAW0xFQsEPuxZtOAPG17zX/PGvdyRX/TE1jkZWhTzqUDIdgzqlNLjyEnUw==", + "license": "MIT", + "dependencies": { + "@babel/core": "^7.18.5", + "@sentry/babel-plugin-component-annotate": "2.22.2", + "@sentry/cli": "^2.33.1", + "dotenv": "^16.3.1", + "find-up": "^5.0.0", + "glob": "^9.3.2", + "magic-string": "0.30.8", + "unplugin": "1.0.1" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/@sentry/bundler-plugin-core/node_modules/glob": { + "version": "9.3.5", + "resolved": "https://registry.npmjs.org/glob/-/glob-9.3.5.tgz", + "integrity": "sha512-e1LleDykUz2Iu+MTYdkSsuWX8lvAjAcs0Xef0lNIu0S2wOAzuTxCJtcd9S3cijlwYF18EsU3rzb8jPVobxDh9Q==", + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "minimatch": "^8.0.2", + "minipass": "^4.2.4", + "path-scurry": "^1.6.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@sentry/bundler-plugin-core/node_modules/magic-string": { + "version": "0.30.8", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.8.tgz", + "integrity": "sha512-ISQTe55T2ao7XtlAStud6qwYPZjE4GK1S/BeVPus4jrq6JuOnQ00YKQC581RWhR122W7msZV263KzVeLoqidyQ==", + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.4.15" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@sentry/bundler-plugin-core/node_modules/minimatch": { + "version": "8.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-8.0.4.tgz", + "integrity": "sha512-W0Wvr9HyFXZRGIDgCicunpQ299OKXs9RgZfaukz4qAW/pJhcpUfupc9c+OObPOFueNy8VSrZgEmDtk6Kh4WzDA==", + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@sentry/bundler-plugin-core/node_modules/minipass": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-4.2.8.tgz", + "integrity": "sha512-fNzuVyifolSLFL4NzpF+wEF4qrgqaaKX0haXPQEdQ7NKAN+WecoKMHV09YcuL/DHxrUsYQOK3MiuDf7Ip2OXfQ==", + "license": "ISC", + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/cli": { + "version": "2.33.1", + "resolved": "https://registry.npmjs.org/@sentry/cli/-/cli-2.33.1.tgz", + "integrity": "sha512-dUlZ4EFh98VFRPJ+f6OW3JEYQ7VvqGNMa0AMcmvk07ePNeK/GicAWmSQE4ZfJTTl80ul6HZw1kY01fGQOQlVRA==", + "hasInstallScript": true, + "license": "BSD-3-Clause", + "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" + }, + "bin": { + "sentry-cli": "bin/sentry-cli" + }, + "engines": { + "node": ">= 10" + }, + "optionalDependencies": { + "@sentry/cli-darwin": "2.33.1", + "@sentry/cli-linux-arm": "2.33.1", + "@sentry/cli-linux-arm64": "2.33.1", + "@sentry/cli-linux-i686": "2.33.1", + "@sentry/cli-linux-x64": "2.33.1", + "@sentry/cli-win32-i686": "2.33.1", + "@sentry/cli-win32-x64": "2.33.1" + } + }, + "node_modules/@sentry/cli-darwin": { + "version": "2.33.1", + "resolved": "https://registry.npmjs.org/@sentry/cli-darwin/-/cli-darwin-2.33.1.tgz", + "integrity": "sha512-+4/VIx/E1L2hChj5nGf5MHyEPHUNHJ/HoG5RY+B+vyEutGily1c1+DM2bum7RbD0xs6wKLIyup5F02guzSzG8A==", + "license": "BSD-3-Clause", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@sentry/cli-linux-arm": { + "version": "2.33.1", + "resolved": "https://registry.npmjs.org/@sentry/cli-linux-arm/-/cli-linux-arm-2.33.1.tgz", + "integrity": "sha512-zbxEvQju+tgNvzTOt635le4kS/Fbm2XC2RtYbCTs034Vb8xjrAxLnK0z1bQnStUV8BkeBHtsNVrG+NSQDym2wg==", + "cpu": [ + "arm" + ], + "license": "BSD-3-Clause", + "optional": true, + "os": [ + "linux", + "freebsd" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@sentry/cli-linux-arm64": { + "version": "2.33.1", + "resolved": "https://registry.npmjs.org/@sentry/cli-linux-arm64/-/cli-linux-arm64-2.33.1.tgz", + "integrity": "sha512-DbGV56PRKOLsAZJX27Jt2uZ11QfQEMmWB4cIvxkKcFVE+LJP4MVA+MGGRUL6p+Bs1R9ZUuGbpKGtj0JiG6CoXw==", + "cpu": [ + "arm64" + ], + "license": "BSD-3-Clause", + "optional": true, + "os": [ + "linux", + "freebsd" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@sentry/cli-linux-i686": { + "version": "2.33.1", + "resolved": "https://registry.npmjs.org/@sentry/cli-linux-i686/-/cli-linux-i686-2.33.1.tgz", + "integrity": "sha512-g2LS4oPXkPWOfKWukKzYp4FnXVRRSwBxhuQ9eSw2peeb58ZIObr4YKGOA/8HJRGkooBJIKGaAR2mH2Pk1TKaiA==", + "cpu": [ + "x86", + "ia32" + ], + "license": "BSD-3-Clause", + "optional": true, + "os": [ + "linux", + "freebsd" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@sentry/cli-linux-x64": { + "version": "2.33.1", + "resolved": "https://registry.npmjs.org/@sentry/cli-linux-x64/-/cli-linux-x64-2.33.1.tgz", + "integrity": "sha512-IV3dcYV/ZcvO+VGu9U6kuxSdbsV2kzxaBwWUQxtzxJ+cOa7J8Hn1t0koKGtU53JVZNBa06qJWIcqgl4/pCuKIg==", + "cpu": [ + "x64" + ], + "license": "BSD-3-Clause", + "optional": true, + "os": [ + "linux", + "freebsd" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@sentry/cli-win32-i686": { + "version": "2.33.1", + "resolved": "https://registry.npmjs.org/@sentry/cli-win32-i686/-/cli-win32-i686-2.33.1.tgz", + "integrity": "sha512-F7cJySvkpzIu7fnLKNHYwBzZYYwlhoDbAUnaFX0UZCN+5DNp/5LwTp37a5TWOsmCaHMZT4i9IO4SIsnNw16/zQ==", + "cpu": [ + "x86", + "ia32" + ], + "license": "BSD-3-Clause", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@sentry/cli-win32-x64": { + "version": "2.33.1", + "resolved": "https://registry.npmjs.org/@sentry/cli-win32-x64/-/cli-win32-x64-2.33.1.tgz", + "integrity": "sha512-8VyRoJqtb2uQ8/bFRKNuACYZt7r+Xx0k2wXRGTyH05lCjAiVIXn7DiS2BxHFty7M1QEWUCMNsb/UC/x/Cu2wuA==", + "cpu": [ + "x64" + ], + "license": "BSD-3-Clause", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@sentry/cli/node_modules/agent-base": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "license": "MIT", + "dependencies": { + "debug": "4" + }, + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/@sentry/cli/node_modules/https-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "license": "MIT", + "dependencies": { + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/@sentry/cli/node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "license": "MIT" + }, "node_modules/@sentry/core": { "version": "7.118.0", "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.118.0.tgz", @@ -10121,6 +10379,19 @@ "node": ">=8" } }, + "node_modules/@sentry/vite-plugin": { + "version": "2.22.2", + "resolved": "https://registry.npmjs.org/@sentry/vite-plugin/-/vite-plugin-2.22.2.tgz", + "integrity": "sha512-LJSNTw75UJq77v2jCan8cRh0w1u6W30jxQsbqF7YyyhhfjPTyFUXYday9RDDe84qDEnspbZmgeTSWTvaTGsBRg==", + "license": "MIT", + "dependencies": { + "@sentry/bundler-plugin-core": "2.22.2", + "unplugin": "1.0.1" + }, + "engines": { + "node": ">= 14" + } + }, "node_modules/@sideway/address": { "version": "4.1.5", "resolved": "https://registry.npmjs.org/@sideway/address/-/address-4.1.5.tgz", @@ -13220,7 +13491,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, "dependencies": { "balanced-match": "^1.0.0" } @@ -15767,7 +16037,6 @@ "version": "16.4.5", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", - "dev": true, "engines": { "node": ">=12" }, @@ -27194,7 +27463,6 @@ "version": "1.11.1", "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", - "dev": true, "dependencies": { "lru-cache": "^10.2.0", "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" @@ -27209,14 +27477,12 @@ "node_modules/path-scurry/node_modules/lru-cache": { "version": "10.4.3", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", - "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", - "dev": true + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==" }, "node_modules/path-scurry/node_modules/minipass": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", - "dev": true, "engines": { "node": ">=16 || 14 >=14.17" } @@ -27959,7 +28225,6 @@ "version": "2.0.3", "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", "integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==", - "dev": true, "engines": { "node": ">=0.4.0" } @@ -32417,6 +32682,18 @@ "node": ">= 0.8" } }, + "node_modules/unplugin": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/unplugin/-/unplugin-1.0.1.tgz", + "integrity": "sha512-aqrHaVBWW1JVKBHmGo33T5TxeL0qWzfvjWokObHA9bYmN7eNDkwOxmLjhioHl9878qDFMAaT51XNroRyuz7WxA==", + "license": "MIT", + "dependencies": { + "acorn": "^8.8.1", + "chokidar": "^3.5.3", + "webpack-sources": "^3.2.3", + "webpack-virtual-modules": "^0.5.0" + } + }, "node_modules/unstorage": { "version": "1.10.2", "resolved": "https://registry.npmjs.org/unstorage/-/unstorage-1.10.2.tgz", @@ -33219,6 +33496,21 @@ "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" }, + "node_modules/webpack-sources": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.2.3.tgz", + "integrity": "sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==", + "license": "MIT", + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/webpack-virtual-modules": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/webpack-virtual-modules/-/webpack-virtual-modules-0.5.0.tgz", + "integrity": "sha512-kyDivFZ7ZM0BVOUteVbDFhlRt7Ah/CSPwJdi8hBpkK7QLumUqdLtVfm/PX/hkcnrvr0i77fO5+TjZ94Pe+C9iw==", + "license": "MIT" + }, "node_modules/whatwg-fetch": { "version": "3.6.20", "resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.6.20.tgz", diff --git a/package.json b/package.json index df092b4e..37d71794 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@powerhousedao/connect", "productName": "Powerhouse-Connect", - "version": "1.0.0-next.7", + "version": "1.0.0-next.8", "description": "Powerhouse Connect", "main": ".vite/build/main.js", "license": "AGPL-3.0-only", @@ -91,6 +91,7 @@ "dependencies": { "@powerhousedao/design-system": "1.0.0-alpha.160", "@sentry/react": "^7.109.0", + "@sentry/vite-plugin": "^2.22.2", "@tanstack/react-virtual": "^3.8.1", "did-key-creator": "^1.2.0", "document-drive": "^1.0.0-alpha.88", diff --git a/src/hooks/useUiNodes.ts b/src/hooks/useUiNodes.ts index 377665e7..a0863d2c 100644 --- a/src/hooks/useUiNodes.ts +++ b/src/hooks/useUiNodes.ts @@ -222,10 +222,13 @@ export function useUiNodes() { if (parentNode.kind === FILE) { throw new Error('Cannot add file to a file'); } + + const fileName = file.name.replace(/\.zip$/gim, ''); + return await addFile( file, parentNode.driveId, - file.name, + fileName, parentNode.id, ); }, diff --git a/src/services/renown/index.ts b/src/services/renown/index.ts index 8f3cc984..e9db5320 100644 --- a/src/services/renown/index.ts +++ b/src/services/renown/index.ts @@ -101,13 +101,13 @@ export class Renown { if (!this.#baseUrl) { throw new Error('RENOWN_URL is not set'); } - - const response = await fetch( - `${this.#baseUrl}/api/auth/credential?address=${encodeURIComponent(address)}&chainId=${encodeURIComponent(chainId)}&connectId=${encodeURIComponent(connectId)}`, - { - method: 'GET', - }, + const url = new URL( + `/api/auth/credential?address=${encodeURIComponent(address)}&chainId=${encodeURIComponent(chainId)}&connectId=${encodeURIComponent(connectId)}`, + this.#baseUrl, ); + const response = await fetch(url, { + method: 'GET', + }); if (response.ok) { const result = (await response.json()) as { credential: PowerhouseVerifiableCredential; diff --git a/src/utils/registerServiceWorker.ts b/src/utils/registerServiceWorker.ts index 45dbd781..dbafb700 100644 --- a/src/utils/registerServiceWorker.ts +++ b/src/utils/registerServiceWorker.ts @@ -1,4 +1,13 @@ /* eslint-disable @typescript-eslint/no-unsafe-member-access */ +import connectConfig from 'connect-config'; + +const serviceWorkerScriptPath = [ + connectConfig.routerBasename, + 'service-worker.js', +] + .join('/') + .replace(/\/{2,}/gm, '/'); + type SET_APP_VERSION_MESSAGE = { type: 'SET_APP_VERSION'; version: string; @@ -32,7 +41,7 @@ class ServiceWorkerManager { if ('serviceWorker' in navigator) { window.addEventListener('load', () => { navigator.serviceWorker - .register('/service-worker.js') + .register(serviceWorkerScriptPath) .then(registration => { // Listen for messages from the service worker if (this.debug) { diff --git a/vite.renderer.config.mts b/vite.renderer.config.mts index e0923b67..4b061fde 100644 --- a/vite.renderer.config.mts +++ b/vite.renderer.config.mts @@ -1,9 +1,10 @@ +import { sentryVitePlugin } from '@sentry/vite-plugin'; import react from '@vitejs/plugin-react'; import fs from 'fs'; import jotaiDebugLabel from 'jotai/babel/plugin-debug-label'; import jotaiReactRefresh from 'jotai/babel/plugin-react-refresh'; import path from 'path'; -import { HtmlTagDescriptor, defineConfig, loadEnv } from 'vite'; +import { HtmlTagDescriptor, PluginOption, defineConfig, loadEnv } from 'vite'; import { createHtmlPlugin } from 'vite-plugin-html'; import svgr from 'vite-plugin-svgr'; import pkg from './package.json'; @@ -35,6 +36,42 @@ export default defineConfig(({ mode }) => { const requiresHardRefresh = env.VITE_APP_REQUIRES_HARD_REFRESH === 'true'; + const plugins: PluginOption[] = [ + react({ + include: 'src/**/*.tsx', + babel: { + plugins: isProd ? [] : [jotaiDebugLabel, jotaiReactRefresh], + }, + }), + svgr(), + createHtmlPlugin({ + minify: true, + inject: { + tags: [ + ...(clientConfig.meta.map(meta => ({ + ...meta, + injectTo: 'head', + })) as HtmlTagDescriptor[]), + ], + }, + }), + generateVersionPlugin(isProd ? requiresHardRefresh : false), + ]; + + const authToken = process.env.SENTRY_AUTH_TOKEN; + const org = process.env.SENTRY_ORG; + const project = process.env.SENTRY_PROJECT; + const uploadSentrySourcemaps = authToken && org && project; + if (uploadSentrySourcemaps) { + plugins.push( + sentryVitePlugin({ + authToken, + org, + project, + }) as PluginOption, + ); + } + return { define: { 'process.env': { @@ -42,27 +79,7 @@ export default defineConfig(({ mode }) => { REQUIRES_HARD_REFRESH: isProd ? requiresHardRefresh : false, }, }, - plugins: [ - react({ - include: 'src/**/*.tsx', - babel: { - plugins: isProd ? [] : [jotaiDebugLabel, jotaiReactRefresh], - }, - }), - svgr(), - createHtmlPlugin({ - minify: true, - inject: { - tags: [ - ...(clientConfig.meta.map(meta => ({ - ...meta, - injectTo: 'head', - })) as HtmlTagDescriptor[]), - ], - }, - }), - generateVersionPlugin(isProd ? requiresHardRefresh : false), - ], + plugins, build: { minify: isProd, sourcemap: isProd,