diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index 73f05bb..3019d31 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -28,6 +28,13 @@ - name: Build run: yarn run full-build + env: + SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_TOKEN }} + SENTRY_DSN: ${{ secrets.SENTRY_DSN }} + SENTRY_URL: ${{ secrets.SENTRY_URL }} + SENTRY_ORG: ${{ secrets.SENTRY_ORG }} + SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} + SENTRY_NO_PROGRESS_BAR: 1 - name: Deploy to dev server uses: appleboy/scp-action@master diff --git a/.gitignore b/.gitignore index 23cf531..88608a7 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,5 @@ yarn-error.log* /src/__data__/host*.json + +.sentryclirc diff --git a/.vscode/settings.json b/.vscode/settings.json index 8f62ac6..7ee233f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -27,6 +27,7 @@ "arraybuffer", "authorised", "behaviour", + "broadcastchannel", "btns", "categorised", "chartjs", diff --git a/craco.config.js b/craco.config.js index 5a008c9..e30b4af 100644 --- a/craco.config.js +++ b/craco.config.js @@ -10,6 +10,7 @@ const GitRevisionPlugin = require("git-revision-webpack-plugin"); const { DefinePlugin } = require("webpack"); const { commits } = require("./tools/commitLog"); +const SentryCliPlugin = require("@sentry/webpack-plugin"); const gitRevisionPlugin = new GitRevisionPlugin({ // Include the "-dirty" suffix if the local tree has been modified, and @@ -86,7 +87,14 @@ "__BUILD_TIME__": DefinePlugin.runtimeValue(Date.now), "__GIT_COMMITS__": JSON.stringify(commits), "__PKGBUILD__": DefinePlugin.runtimeValue(() => JSON.stringify(require("crypto").createHash("sha256").update(require("fs").readFileSync("package.json")).digest("hex").substr(0, 7)), ["package.json"]) - }) + }), + ...(process.env.NODE_ENV === "production" && process.env.SENTRY_ENABLED === "true" + ? [new SentryCliPlugin({ + include: "./build/", + ignore: ["node_modules", "craco.config.js", "tools", "public"], + release: "kristweb2-react@" + gitRevisionPlugin.version() + })] + : []) ], optimization: { diff --git a/package.json b/package.json index d27932e..d44fdee 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,8 @@ "private": true, "dependencies": { "@ant-design/icons": "^4.5.0", + "@sentry/react": "^6.2.3", + "@sentry/tracing": "^6.2.3", "@testing-library/jest-dom": "^5.11.9", "@testing-library/react": "^11.2.5", "@testing-library/user-event": "^13.0.7", @@ -23,6 +25,7 @@ "async-mutex": "^0.3.1", "await-to-js": "^3.0.0", "base64-arraybuffer": "^0.2.0", + "broadcastchannel-polyfill": "^1.0.1", "chart.js": "^2.9.4", "classnames": "^2.2.6", "csv-stringify": "^5.6.2", @@ -88,6 +91,7 @@ "devDependencies": { "@craco/craco": "^6.1.1", "@lemmmy/craco-less": "1.18.0", + "@sentry/webpack-plugin": "^1.14.2", "@simbathesailor/babel-plugin-use-what-changed": "^2.0.3", "@simbathesailor/use-what-changed": "^1.0.0", "@types/classnames": "^2.2.11", diff --git a/src/global/StorageBroadcast.tsx b/src/global/StorageBroadcast.tsx index e0e3da2..bb4e526 100644 --- a/src/global/StorageBroadcast.tsx +++ b/src/global/StorageBroadcast.tsx @@ -8,6 +8,9 @@ import { getWalletKey, parseWallet, syncWallet } from "@wallets"; import { getContactKey, parseContact } from "@contacts"; +// Required for Safari +import "broadcastchannel-polyfill"; + import Debug from "debug"; const debug = Debug("kristweb:storage-broadcast"); diff --git a/src/index.tsx b/src/index.tsx index 6e099b7..0e8e360 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,6 +1,7 @@ // Copyright (c) 2020-2021 Drew Lemmy // This file is part of KristWeb 2 under AGPL-3.0. // Full details: https://github.com/tmpim/KristWeb2/blob/master/LICENSE.txt +import "@utils/errors"; import "@utils/setup"; import { i18nLoader } from "@utils/i18n"; import { isLocalhost } from "@utils"; diff --git a/src/pages/settings/ResetMasterPassword.tsx b/src/pages/settings/ResetMasterPassword.tsx new file mode 100644 index 0000000..50a4cf8 --- /dev/null +++ b/src/pages/settings/ResetMasterPassword.tsx @@ -0,0 +1,28 @@ +// Copyright (c) 2020-2021 Drew Lemmy +// This file is part of KristWeb 2 under AGPL-3.0. +// Full details: https://github.com/tmpim/KristWeb2/blob/master/LICENSE.txt +import { useCallback } from "react"; +import { Modal } from "antd"; +import { ExclamationCircleOutlined } from "@ant-design/icons"; + +import { useTFns } from "@utils/i18n"; + +interface HookRes { + resetMasterPasswordCtx: JSX.Element; + openResetMasterPassword: () => void; +} + +export function useResetMasterPasswordModal(): HookRes { + const { tStr } = useTFns("masterPassword.reset."); + const [modal, contextHolder] = Modal.useModal(); + + const openResetMasterPassword = useCallback(() => modal.confirm({ + icon: , + title: tStr("modalTitle"), + }), [tStr, modal]); + + return { + resetMasterPasswordCtx: contextHolder, + openResetMasterPassword + }; +} diff --git a/src/utils/errors.ts b/src/utils/errors.ts new file mode 100644 index 0000000..f48fa5d --- /dev/null +++ b/src/utils/errors.ts @@ -0,0 +1,19 @@ +// Copyright (c) 2020-2021 Drew Lemmy +// This file is part of KristWeb 2 under AGPL-3.0. +// Full details: https://github.com/tmpim/KristWeb2/blob/master/LICENSE.txt +import * as Sentry from "@sentry/react"; +import { Integrations } from "@sentry/tracing"; + +declare const __GIT_VERSION__: string; +const gitVersion: string = __GIT_VERSION__; + +Sentry.init({ + dsn: "https://51a018424102449b88f94c795cf62bb7@sentry.lemmmy.pw/2", + release: "kristweb2-react@" + gitVersion, + integrations: [new Integrations.BrowserTracing()], + + // Set tracesSampleRate to 1.0 to capture 100% + // of transactions for performance monitoring. + // We recommend adjusting this value in production + tracesSampleRate: 1.0 +}); diff --git a/yarn.lock b/yarn.lock index eaacf45..bdc3d11 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1563,6 +1563,99 @@ estree-walker "^1.0.1" picomatch "^2.2.2" +"@sentry/browser@6.2.3": + version "6.2.3" + resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-6.2.3.tgz#b622b3fb62340574e395b6ae12ffbb9d25d98bd4" + integrity sha512-QUqrZdAosY2MPAUfJYpyCT+dA6v7A2h8imO8R3Lbi0hRSPr+L7zjqHgFs3CTHJLmLV74cxHt6rVVUPSksYNQDQ== + dependencies: + "@sentry/core" "6.2.3" + "@sentry/types" "6.2.3" + "@sentry/utils" "6.2.3" + tslib "^1.9.3" + +"@sentry/cli@^1.63.1": + version "1.63.1" + resolved "https://registry.yarnpkg.com/@sentry/cli/-/cli-1.63.1.tgz#306a0591190432574082d4ce4a72363201972461" + integrity sha512-qksIcrnObkGvtubs1FmW4EMXLo7R43Dobgzuxnyoebo1Y5KfRLziiw6H+ux8D4c1Nui4SuvDGDq0ObAfO5oE6Q== + dependencies: + https-proxy-agent "^5.0.0" + mkdirp "^0.5.5" + node-fetch "^2.6.0" + progress "^2.0.3" + proxy-from-env "^1.1.0" + +"@sentry/core@6.2.3": + version "6.2.3" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.2.3.tgz#ed5d21fd8b18ddc289d04c669393a437fb09639f" + integrity sha512-GpfHoSJiXchVXgyaMWVtIPVw2t97KkD1OJ4JdL3/TeH3auX5XvsN5iHTk+x/Er8t13IpOnvidH1xWdV1dnax2w== + dependencies: + "@sentry/hub" "6.2.3" + "@sentry/minimal" "6.2.3" + "@sentry/types" "6.2.3" + "@sentry/utils" "6.2.3" + tslib "^1.9.3" + +"@sentry/hub@6.2.3": + version "6.2.3" + resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-6.2.3.tgz#07fba07627b7523f69f8b862f00cd197e5e4e5bd" + integrity sha512-D5Horfo2l0p52S7KPvy7qwWNMrE4IsCN8ODbfcCsfJu7hEXJmItbkbohIVSqO5neukhn5nu+x8kyCe9Q5u1Q6g== + dependencies: + "@sentry/types" "6.2.3" + "@sentry/utils" "6.2.3" + tslib "^1.9.3" + +"@sentry/minimal@6.2.3": + version "6.2.3" + resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-6.2.3.tgz#462ce7739fa85fd7d6dd13d56d20f17ff91e46d0" + integrity sha512-Gpn9x4NQAG7E94EK1+hAz9GUcYrffTuqJ/XgqvHYk0jsHZ6RfsXYrmBac0ZwUxOivMf2t0n5opK0v5rhMDfF2w== + dependencies: + "@sentry/hub" "6.2.3" + "@sentry/types" "6.2.3" + tslib "^1.9.3" + +"@sentry/react@^6.2.3": + version "6.2.3" + resolved "https://registry.yarnpkg.com/@sentry/react/-/react-6.2.3.tgz#66e8a2073acd74677e4daf850e165273eb8eea7a" + integrity sha512-T2mBD9ZFxzLQ3Kc5cey7A5fBA+qN67NdmRw9W1Grk6cEoJIrQYg3LnFbM5YnBBK86ciXQlgz7ZsF7rbjRcmWMQ== + dependencies: + "@sentry/browser" "6.2.3" + "@sentry/minimal" "6.2.3" + "@sentry/types" "6.2.3" + "@sentry/utils" "6.2.3" + hoist-non-react-statics "^3.3.2" + tslib "^1.9.3" + +"@sentry/tracing@^6.2.3": + version "6.2.3" + resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-6.2.3.tgz#fefa55b1f2265973a747b30da14a54b779b5090e" + integrity sha512-OnQZKp7qVera+Z4ly6hgybGgyf10p2VDXqwueXkMVeLD+PwlPG8a8NMpKkZ+QxwRbQbSFhRLQaib3NX34tusBQ== + dependencies: + "@sentry/hub" "6.2.3" + "@sentry/minimal" "6.2.3" + "@sentry/types" "6.2.3" + "@sentry/utils" "6.2.3" + tslib "^1.9.3" + +"@sentry/types@6.2.3": + version "6.2.3" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.2.3.tgz#0c06a475a51d28c73a69b05f0d43db05310ec241" + integrity sha512-BpA+9FherWgYlkMD/82bGFh/gAqZNlZX5UE8vWLKyyzNyOEEz3v9ScxE8dOSWE4v5iXJR1O3jjxaTcRQxPVgCA== + +"@sentry/utils@6.2.3": + version "6.2.3" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-6.2.3.tgz#c96539571a67fb2eed56897133649f35309e3f74" + integrity sha512-YnkJm97wSvck39eRpqWjIuuwbvzPilvAcMqhbUy9yK/UBQMDGUzAKCOKH40udw1DwMUCWjJ71mOCDgUorE4Fog== + dependencies: + "@sentry/types" "6.2.3" + tslib "^1.9.3" + +"@sentry/webpack-plugin@^1.14.2": + version "1.14.2" + resolved "https://registry.yarnpkg.com/@sentry/webpack-plugin/-/webpack-plugin-1.14.2.tgz#4faf3b048f24c7e615e2970199206466202adce8" + integrity sha512-kYiDoGyDvfkMftcfI44HMLVe/Oqj8gQEf80gpB7Dv5HE4PJO5ttEwv24zD9QFRuoebEdsuh12jHli/DqLUYZiA== + dependencies: + "@sentry/cli" "^1.63.1" + "@simbathesailor/babel-plugin-use-what-changed@^2.0.3": version "2.0.3" resolved "https://registry.yarnpkg.com/@simbathesailor/babel-plugin-use-what-changed/-/babel-plugin-use-what-changed-2.0.3.tgz#68a5d70d84892cf8310e62921e65b13b679d400a" @@ -2437,6 +2530,13 @@ loader-utils "^2.0.0" regex-parser "^2.2.11" +agent-base@6: + version "6.0.2" + resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-6.0.2.tgz#49fff58577cfee3f37176feab4c22e00f86d7f77" + integrity sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ== + dependencies: + debug "4" + aggregate-error@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/aggregate-error/-/aggregate-error-3.1.0.tgz#92670ff50f5359bdb7a3e0d40d0ec30c5737687a" @@ -3251,6 +3351,11 @@ dependencies: fill-range "^7.0.1" +broadcastchannel-polyfill@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/broadcastchannel-polyfill/-/broadcastchannel-polyfill-1.0.1.tgz#7596b3d78526b3919e76562aff00cd1278a205ea" + integrity sha512-iooPAN913j4xfrIu5o+mDaks9UUDOBfgjn8SsuzysfXr/X+f8m9y5t8c5rAbW6P0LdUXBJx33zwN4Cs6b9BGRw== + brorand@^1.0.1, brorand@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f" @@ -4398,6 +4503,13 @@ dependencies: ms "2.0.0" +debug@4, debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1: + version "4.3.1" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.1.tgz#f0d229c505e0c6d8c49ac553d1b13dc183f6b2ee" + integrity sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ== + dependencies: + ms "2.1.2" + debug@^3.1.1, debug@^3.2.6: version "3.2.7" resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a" @@ -4405,13 +4517,6 @@ dependencies: ms "^2.1.1" -debug@^4.0.1, debug@^4.1.0, debug@^4.1.1, debug@^4.3.1: - version "4.3.1" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.1.tgz#f0d229c505e0c6d8c49ac553d1b13dc183f6b2ee" - integrity sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ== - dependencies: - ms "2.1.2" - decamelize@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -6199,6 +6304,14 @@ resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73" integrity sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM= +https-proxy-agent@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-5.0.0.tgz#e2a90542abb68a762e0a0850f6c9edadfd8506b2" + integrity sha512-EkYm5BcKUGiduxzSt3Eppko+PiNWNEpa4ySk9vTC6wDsQJW9rHSa+UhGNJoRYp7bz6Ht1eaRIa6QaJqO5rCFbA== + dependencies: + agent-base "6" + debug "4" + human-signals@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3" @@ -8120,7 +8233,7 @@ lower-case "^2.0.2" tslib "^2.0.3" -node-fetch@2.6.1: +node-fetch@2.6.1, node-fetch@^2.6.0: version "2.6.1" resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052" integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw== @@ -9520,7 +9633,7 @@ resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" integrity sha1-czIwDoQBYb2j5podHZGn1LwW8YI= -progress@^2.0.0: +progress@^2.0.0, 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== @@ -9581,6 +9694,11 @@ forwarded "~0.1.2" ipaddr.js "1.9.1" +proxy-from-env@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz#e102f16ca355424865755d2c9e8ea4f24d58c3e2" + integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== + prr@~1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/prr/-/prr-1.0.1.tgz#d3fc114ba06995a45ec6893f484ceb1d78f5f476" @@ -11908,7 +12026,7 @@ minimist "^1.2.0" strip-bom "^3.0.0" -tslib@^1.10.0, tslib@^1.14.1, tslib@^1.8.1, tslib@^1.9.0: +tslib@^1.10.0, tslib@^1.14.1, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3: version "1.14.1" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==