diff --git a/.depcheckrc.json b/.depcheckrc.json index 5c482e7..9e2c1cd 100644 --- a/.depcheckrc.json +++ b/.depcheckrc.json @@ -11,6 +11,8 @@ "assert", "buffer", "crypto*", - "stream*" + "stream*", + "env-paths", + "open" ] } diff --git a/.github/workflows/publish_npmjs.yaml b/.github/workflows/publish_npmjs.yaml index 7cd6343..781cac7 100644 --- a/.github/workflows/publish_npmjs.yaml +++ b/.github/workflows/publish_npmjs.yaml @@ -20,3 +20,11 @@ jobs: - run: npm publish --access public env: NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + - name: Create Sentry release + uses: getsentry/action-release@v1 + env: + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }} + SENTRY_ORG: ${{ secrets.SENTRY_ORG }} + SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} + with: + sourcemaps: ./build/static/js diff --git a/README.md b/README.md index 0288616..4aaecec 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,16 @@ The Bee Dashboard runs in development mode on [http://localhost:3031/](http://lo > Setting the `REACT_APP_DEV_MODE=1` environment variable, or opening Bee Dashboard with the query string `?devMode=1` loosens some checks. This makes it possible to develop Bee Dashboard without having connected peers and chequebook properly set up, effectively supporting the dev mode of Bee itself. +#### Bee Desktop development + +If you want to develop Bee Dashboard in the Bee Desktop mode, then spin up `bee-desktop` to the point where you see Bee Dashboard (eq. install Bee etc.) and: + +```sh +echo "REACT_APP_BEE_DESKTOP_URL=http://localhost:3000" > .env.development.local +npm start +npm run desktop # This will inject the API key to the Dashboard +``` + ## Contribute There are some ways you can make this module better: diff --git a/desktop.mjs b/desktop.mjs new file mode 100644 index 0000000..00fe7d2 --- /dev/null +++ b/desktop.mjs @@ -0,0 +1,14 @@ +#!/usr/bin/env node + +import envPaths from 'env-paths' +import open from 'open' + +import { readFile } from 'node:fs/promises' +import { join } from 'node:path' + +const paths = envPaths('bee-desktop') +const apiKey = await readFile(join(paths.data, 'api-key.txt'), {encoding: 'utf-8'}) +const url = `http://localhost:3001/?v=${apiKey}#/` + +console.log('Opening: ' + url) +await open(url) diff --git a/package-lock.json b/package-lock.json index 1ef6005..5ac9ca7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,8 @@ "@material-ui/core": "4.12.3", "@material-ui/icons": "4.11.2", "@material-ui/lab": "4.0.0-alpha.57", + "@sentry/react": "^7.1.1", + "@sentry/tracing": "^7.1.1", "assert": "^2.0.0", "axios": "0.24.0", "bignumber.js": "9.0.1", @@ -78,6 +80,7 @@ "babel-plugin-tsconfig-paths": "1.0.2", "cors": "^2.8.5", "depcheck": "^1.4.3", + "env-paths": "^3.0.0", "eslint": "8.17.0 ", "eslint-config-prettier": "8.5.0", "eslint-config-react-app": "7.0.1", @@ -91,6 +94,7 @@ "eslint-plugin-testing-library": "5.5.1", "express": "^4.17.3", "file-loader": "6.2.0", + "open": "^8.4.0", "prettier": "2.4.1", "react-scripts": "^5.0.1", "ts-node": "^10.8.1", @@ -102,7 +106,7 @@ "engines": { "bee": ">=0.6.0", "node": ">=12.0.0", - "npm": ">=6.0.0" + "npm": ">=6.9.0" }, "peerDependencies": { "react": ">= 17.0.2", @@ -4168,6 +4172,99 @@ "integrity": "sha512-WiBSI6JBIhC6LRIsB2Kwh8DsGTlbBU+mLRxJmAe3LjHTdkDpwIbEOZgoXBbZilk/vlfjK8i6nKRAvIRn1XaIMw==", "dev": true }, + "node_modules/@sentry/browser": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-7.1.1.tgz", + "integrity": "sha512-5AQvStZ+nOP/yxsBmeMZpeGLVtuOgnCNvswKd/c1CJwNw7bDmCE4TQeNKp1C3Gb7lSdBk8ViwUKn0ZpoVQ5MTw==", + "dependencies": { + "@sentry/core": "7.1.1", + "@sentry/types": "7.1.1", + "@sentry/utils": "7.1.1", + "tslib": "^1.9.3" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/core": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.1.1.tgz", + "integrity": "sha512-SADdAoG5u1LTJhPN5KPtn5HHmH6r0mr6h2LokuZnhj6/okrAuCIIKOb6Fh8jV7j2VuABvew8+FjJHORxi7D/3Q==", + "dependencies": { + "@sentry/hub": "7.1.1", + "@sentry/types": "7.1.1", + "@sentry/utils": "7.1.1", + "tslib": "^1.9.3" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/hub": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-7.1.1.tgz", + "integrity": "sha512-ASsRVjYDIii6ZTf36JnIYKHWBQBk0P42Tgq324MpyPgaeVDg3saBcyXO5iAtWvY6Vmdi2H4JCVDoir2Zz3Me1w==", + "dependencies": { + "@sentry/types": "7.1.1", + "@sentry/utils": "7.1.1", + "tslib": "^1.9.3" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/react": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@sentry/react/-/react-7.1.1.tgz", + "integrity": "sha512-Z7cZvXHIWxg7OhOSy4InhrRgQPRNtHsyOkIAHkgwW32JYOGTg1HdqQ5mFUxQLejhU/YqsxVjTK4CI58FATykLw==", + "dependencies": { + "@sentry/browser": "7.1.1", + "@sentry/types": "7.1.1", + "@sentry/utils": "7.1.1", + "hoist-non-react-statics": "^3.3.2", + "tslib": "^1.9.3" + }, + "engines": { + "node": ">=8" + }, + "peerDependencies": { + "react": "15.x || 16.x || 17.x || 18.x" + } + }, + "node_modules/@sentry/tracing": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@sentry/tracing/-/tracing-7.1.1.tgz", + "integrity": "sha512-MJ+EPGfvPlgbJOcZRoIl6+Oi0oRE2nIi/HP2BPJSKGxXFi2Y09bcZUwfxOH8fkUa465jOGBFdCm+sXcbyExvuw==", + "dependencies": { + "@sentry/hub": "7.1.1", + "@sentry/types": "7.1.1", + "@sentry/utils": "7.1.1", + "tslib": "^1.9.3" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/types": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.1.1.tgz", + "integrity": "sha512-5N1UMd2SqvUXprcIUMyDEju3H9lJY2oWfWQBGo0lG6Amn/lGAPAYlchg+4vQCLutDQMyd8K9zPwcbKn4u6gHdw==", + "engines": { + "node": ">=8" + } + }, + "node_modules/@sentry/utils": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.1.1.tgz", + "integrity": "sha512-DPRHDf3InfyVgmxToE4Z+AATAR4OVm+wsXDLFGGyncR91CE1x4wLQKOcAJJwX3F0Hz1VHENfmx1DvyYTHOrC/A==", + "dependencies": { + "@sentry/types": "7.1.1", + "tslib": "^1.9.3" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/@sinclair/typebox": { "version": "0.23.5", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.23.5.tgz", @@ -8696,6 +8793,18 @@ "url": "https://github.com/fb55/entities?sponsor=1" } }, + "node_modules/env-paths": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-3.0.0.tgz", + "integrity": "sha512-dtJUTepzMW3Lm/NPxRf3wP4642UWhjL2sQxc+ym2YMj1m/H2zDNQOlezafzkHwn6sMstjHTwG6iQQsctDW/b1A==", + "dev": true, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/envinfo": { "version": "7.8.1", "resolved": "https://registry.npmjs.org/envinfo/-/envinfo-7.8.1.tgz", @@ -23212,6 +23321,75 @@ "integrity": "sha512-WiBSI6JBIhC6LRIsB2Kwh8DsGTlbBU+mLRxJmAe3LjHTdkDpwIbEOZgoXBbZilk/vlfjK8i6nKRAvIRn1XaIMw==", "dev": true }, + "@sentry/browser": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@sentry/browser/-/browser-7.1.1.tgz", + "integrity": "sha512-5AQvStZ+nOP/yxsBmeMZpeGLVtuOgnCNvswKd/c1CJwNw7bDmCE4TQeNKp1C3Gb7lSdBk8ViwUKn0ZpoVQ5MTw==", + "requires": { + "@sentry/core": "7.1.1", + "@sentry/types": "7.1.1", + "@sentry/utils": "7.1.1", + "tslib": "^1.9.3" + } + }, + "@sentry/core": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-7.1.1.tgz", + "integrity": "sha512-SADdAoG5u1LTJhPN5KPtn5HHmH6r0mr6h2LokuZnhj6/okrAuCIIKOb6Fh8jV7j2VuABvew8+FjJHORxi7D/3Q==", + "requires": { + "@sentry/hub": "7.1.1", + "@sentry/types": "7.1.1", + "@sentry/utils": "7.1.1", + "tslib": "^1.9.3" + } + }, + "@sentry/hub": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@sentry/hub/-/hub-7.1.1.tgz", + "integrity": "sha512-ASsRVjYDIii6ZTf36JnIYKHWBQBk0P42Tgq324MpyPgaeVDg3saBcyXO5iAtWvY6Vmdi2H4JCVDoir2Zz3Me1w==", + "requires": { + "@sentry/types": "7.1.1", + "@sentry/utils": "7.1.1", + "tslib": "^1.9.3" + } + }, + "@sentry/react": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@sentry/react/-/react-7.1.1.tgz", + "integrity": "sha512-Z7cZvXHIWxg7OhOSy4InhrRgQPRNtHsyOkIAHkgwW32JYOGTg1HdqQ5mFUxQLejhU/YqsxVjTK4CI58FATykLw==", + "requires": { + "@sentry/browser": "7.1.1", + "@sentry/types": "7.1.1", + "@sentry/utils": "7.1.1", + "hoist-non-react-statics": "^3.3.2", + "tslib": "^1.9.3" + } + }, + "@sentry/tracing": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@sentry/tracing/-/tracing-7.1.1.tgz", + "integrity": "sha512-MJ+EPGfvPlgbJOcZRoIl6+Oi0oRE2nIi/HP2BPJSKGxXFi2Y09bcZUwfxOH8fkUa465jOGBFdCm+sXcbyExvuw==", + "requires": { + "@sentry/hub": "7.1.1", + "@sentry/types": "7.1.1", + "@sentry/utils": "7.1.1", + "tslib": "^1.9.3" + } + }, + "@sentry/types": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@sentry/types/-/types-7.1.1.tgz", + "integrity": "sha512-5N1UMd2SqvUXprcIUMyDEju3H9lJY2oWfWQBGo0lG6Amn/lGAPAYlchg+4vQCLutDQMyd8K9zPwcbKn4u6gHdw==" + }, + "@sentry/utils": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@sentry/utils/-/utils-7.1.1.tgz", + "integrity": "sha512-DPRHDf3InfyVgmxToE4Z+AATAR4OVm+wsXDLFGGyncR91CE1x4wLQKOcAJJwX3F0Hz1VHENfmx1DvyYTHOrC/A==", + "requires": { + "@sentry/types": "7.1.1", + "tslib": "^1.9.3" + } + }, "@sinclair/typebox": { "version": "0.23.5", "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.23.5.tgz", @@ -26766,6 +26944,12 @@ "integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==", "dev": true }, + "env-paths": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-3.0.0.tgz", + "integrity": "sha512-dtJUTepzMW3Lm/NPxRf3wP4642UWhjL2sQxc+ym2YMj1m/H2zDNQOlezafzkHwn6sMstjHTwG6iQQsctDW/b1A==", + "dev": true + }, "envinfo": { "version": "7.8.1", "resolved": "https://registry.npmjs.org/envinfo/-/envinfo-7.8.1.tgz", diff --git a/package.json b/package.json index c87f38d..34373e1 100644 --- a/package.json +++ b/package.json @@ -32,12 +32,14 @@ "@material-ui/core": "4.12.3", "@material-ui/icons": "4.11.2", "@material-ui/lab": "4.0.0-alpha.57", + "@sentry/react": "^7.1.1", + "@sentry/tracing": "^7.1.1", "assert": "^2.0.0", "axios": "0.24.0", "bignumber.js": "9.0.1", "buffer": "^6.0.3", - "crypto-browserify": "^3.12.0", "crypto": "npm:crypto-browserify", + "crypto-browserify": "^3.12.0", "ethereumjs-wallet": "^1.0.2", "ethers": "^5.6.4", "file-saver": "^2.0.5", @@ -92,6 +94,7 @@ "babel-plugin-tsconfig-paths": "1.0.2", "cors": "^2.8.5", "depcheck": "^1.4.3", + "env-paths": "^3.0.0", "eslint": "8.17.0 ", "eslint-config-prettier": "8.5.0", "eslint-config-react-app": "7.0.1", @@ -105,6 +108,7 @@ "eslint-plugin-testing-library": "5.5.1", "express": "^4.17.3", "file-loader": "6.2.0", + "open": "^8.4.0", "prettier": "2.4.1", "react-scripts": "^5.0.1", "ts-node": "^10.8.1", @@ -120,6 +124,7 @@ "scripts": { "prepare": "npm run build", "start": "react-scripts start", + "desktop": "node ./desktop.mjs", "build": "react-scripts build", "build:component": "TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\"}' webpack --mode=production", "compile:types": "tsc --project tsconfig.lib.json --emitDeclarationOnly --declaration", diff --git a/src/App.tsx b/src/App.tsx index 430dc45..1cd57b1 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -3,6 +3,8 @@ import { ThemeProvider } from '@material-ui/core/styles' import { SnackbarProvider } from 'notistack' import React, { ReactElement } from 'react' import { HashRouter as Router } from 'react-router-dom' +import * as Sentry from '@sentry/react' +import { BrowserTracing } from '@sentry/tracing' import './App.css' import Dashboard from './layout/Dashboard' import { Provider as BeeProvider } from './providers/Bee' @@ -14,6 +16,10 @@ import { Provider as StampsProvider } from './providers/Stamps' import { Provider as TopUpProvider } from './providers/TopUp' import BaseRouter from './routes' import { theme } from './theme' +import { config } from './config' +import { getBeeDesktopLogs, getBeeLogs } from './utils/desktop' +import packageJson from '../package.json' +import ItsBroken from './layout/ItsBroken' interface Props { beeApiUrl?: string @@ -21,35 +27,77 @@ interface Props { lockedApiSettings?: boolean } -const App = ({ beeApiUrl, beeDebugApiUrl, lockedApiSettings }: Props): ReactElement => ( -