From d8af0639ec2ec54b67e61facf573bde96164887a Mon Sep 17 00:00:00 2001 From: Felipe Novaes Rocha Date: Tue, 28 Dec 2021 18:33:36 -0300 Subject: [PATCH 1/9] fix: disable prettier and fix eslint on 2 files --- .eslintrc.js | 2 +- .../Garden/Preferences/EVMExecutor.js | 38 ++++++++++--------- src/components/SingleDatePicker/DatePicker.js | 37 ++++++++++-------- 3 files changed, 42 insertions(+), 35 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 215acec13..6260581c2 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -3,7 +3,7 @@ module.exports = { parser: '@typescript-eslint/parser', extends: [ 'eslint:recommended', - 'plugin:prettier/recommended', + // 'plugin:prettier/recommended', 'plugin:react/recommended', ], plugins: ['react-hooks'], diff --git a/src/components/Garden/Preferences/EVMExecutor.js b/src/components/Garden/Preferences/EVMExecutor.js index 2ffd0d0f1..e9e66870c 100644 --- a/src/components/Garden/Preferences/EVMExecutor.js +++ b/src/components/Garden/Preferences/EVMExecutor.js @@ -1,4 +1,6 @@ +/* eslint-disable no-unexpected-multiline */ import React, { useCallback, useMemo, useState } from 'react' + import { utils } from 'ethers' import { @@ -11,20 +13,21 @@ import { TextInput, } from '@1hive/1hive-ui' -import CreateDecisionScreens from '../ModalFlows/CreateDecisionScreens/CreateDecisionScreens' import MultiModal from '@components/MultiModal/MultiModal' import { useConnectedGarden } from '@providers/ConnectedGarden' -import { useGardenState } from '@/providers/GardenState' -import { useWallet } from '@/providers/Wallet' import { SHORTENED_APPS_NAMES } from '@utils/app-utils' - -import env from '@/environment' import { getAppByName } from '@utils/data-utils' + import actions from '@/actions/garden-action-types' -import radspec from '@/radspec' import { TERMINAL_EXECUTOR_MESSAGE } from '@/constants' +import env from '@/environment' +import { useGardenState } from '@/providers/GardenState' +import { useWallet } from '@/providers/Wallet' +import radspec from '@/radspec' + +import CreateDecisionScreens from '../ModalFlows/CreateDecisionScreens/CreateDecisionScreens' const INTERACTION_TYPES = ['Internal', 'External', 'Terminal'] @@ -37,9 +40,8 @@ function EVMExecutor({ evmcrispr }) { const gardenState = useGardenState() const connectedGarden = useConnectedGarden() - const [createDecisionModalVisible, setCreateDecisionModalVisible] = useState( - false - ) + const [createDecisionModalVisible, setCreateDecisionModalVisible] = + useState(false) const [abi, setAbi] = useState() const [externalContractAddress, setExternalContractAddress] = useState(null) const [formattedAbi, setFormattedAbi] = useState(null) @@ -71,7 +73,7 @@ function EVMExecutor({ evmcrispr }) { return evmcrispr.apps() }, [evmcrispr]) - const shortenedAppsNames = installedApps.map(appName => { + const shortenedAppsNames = installedApps.map((appName) => { const dotIndex = appName.indexOf('.') return ( SHORTENED_APPS_NAMES.get( @@ -92,7 +94,7 @@ function EVMExecutor({ evmcrispr }) { appFunctions = evmcrispr.appMethods(appName) } if (interactionType === EXTERNAL_INDEX && formattedAbi) { - appFunctions = formattedAbi.map(item => { + appFunctions = formattedAbi.map((item) => { if (item.type === 'function' && item.stateMutability !== 'view') { return item.name } @@ -126,7 +128,7 @@ function EVMExecutor({ evmcrispr }) { }) } if (interactionType === EXTERNAL_INDEX && formattedAbi) { - return formattedAbi[selectedFunction].inputs.map(parameter => { + return formattedAbi[selectedFunction].inputs.map((parameter) => { return [parameter.name, parameter.type] }) } @@ -160,7 +162,7 @@ function EVMExecutor({ evmcrispr }) { const handleOnChangeParameters = useCallback((index, event) => { const newValue = event.target.value - setParameters(prevState => { + setParameters((prevState) => { const newArray = [...prevState] newArray[index] = newValue return newArray @@ -229,12 +231,12 @@ function EVMExecutor({ evmcrispr }) { code, ]) - const handleOnContractAddressChange = useCallback(event => { + const handleOnContractAddressChange = useCallback((event) => { const value = event.target.value setExternalContractAddress(value) }, []) - const handleOnAbiChange = useCallback(event => { + const handleOnAbiChange = useCallback((event) => { const value = event.target.value setAbi(value) let iface @@ -243,7 +245,7 @@ function EVMExecutor({ evmcrispr }) { iface = new utils.Interface(value) formattedAbi = iface.format(utils.FormatTypes.json) setFormattedAbi( - JSON.parse(formattedAbi).filter(item => { + JSON.parse(formattedAbi).filter((item) => { if (item.type === 'function' && item.stateMutability !== 'view') { return item.name } @@ -262,7 +264,7 @@ function EVMExecutor({ evmcrispr }) { setCreateDecisionModalVisible(false) }, []) - const handleOnSetCode = useCallback(event => { + const handleOnSetCode = useCallback((event) => { const value = event.target.value setCode(value) }, []) @@ -342,7 +344,7 @@ function EVMExecutor({ evmcrispr }) { return ( handleOnChangeParameters(index, event)} + onChange={(event) => handleOnChangeParameters(index, event)} placeholder={`${parameter[0].toString()} : ${parameter[1].toString()}`} wide css={` diff --git a/src/components/SingleDatePicker/DatePicker.js b/src/components/SingleDatePicker/DatePicker.js index 097948a4b..7c27b832f 100644 --- a/src/components/SingleDatePicker/DatePicker.js +++ b/src/components/SingleDatePicker/DatePicker.js @@ -1,9 +1,14 @@ +/* eslint-disable no-unexpected-multiline */ import React, { useState } from 'react' + import PropTypes from 'prop-types' -import { eachDayOfInterval, GU } from '@1hive/1hive-ui' + +import { GU, eachDayOfInterval } from '@1hive/1hive-ui' + +import { dayjs } from '@utils/date-utils' + import MonthDay from './MonthDay' import { Selector } from './components' -import { dayjs } from '@utils/date-utils' function DatePicker({ initialDate, @@ -20,22 +25,22 @@ function DatePicker({ }) { const [selectedDate, setSelectedDate] = useState(initialDate) - const setDate = ({ year, add }) => event => { - setSelectedDate( - dayjs(selectedDate) - .startOf('month') - [add ? 'add' : 'subtract'](1, year ? 'year' : 'month') - .toDate() - ) - } + const setDate = + ({ year, add }) => + (event) => { + setSelectedDate( + dayjs(selectedDate) + .startOf('month') + [add ? 'add' : 'subtract'](1, year ? 'year' : 'month') + .toDate() + ) + } - const today = dayjs() - .startOf('day') - .toDate() + const today = dayjs().startOf('day').toDate() const selectedDayjs = dayjs(selectedDate || today) - const isSelected = day => { + const isSelected = (day) => { if (initialDate) { return day.isSame(initialDate, 'day') } @@ -81,7 +86,7 @@ function DatePicker({ eachDayOfInterval({ start: selectedDayjs.startOf('week'), end: selectedDayjs.endOf('week'), - }).map(day => { + }).map((day) => { const dayJs = dayjs(day) return ( @@ -93,7 +98,7 @@ function DatePicker({ {eachDayOfInterval({ start: selectedDayjs.startOf('month').startOf('week'), end: selectedDayjs.endOf('month').endOf('week'), - }).map(day => { + }).map((day) => { const dayJs = dayjs(day) return ( Date: Tue, 28 Dec 2021 20:16:00 -0300 Subject: [PATCH 2/9] feat: (wip) implement Sentry --- .env.example | 3 +- package.json | 2 ++ src/App.tsx | 7 ++-- src/environment.js | 7 +++- src/sentry.ts | 41 ++++++++++++++++++++++++ tsconfig.json | 5 ++- yarn.lock | 79 ++++++++++++++++++++++++++++++++++++++++++++-- 7 files changed, 137 insertions(+), 7 deletions(-) create mode 100644 src/sentry.ts diff --git a/.env.example b/.env.example index aff82280b..74edcb9bf 100644 --- a/.env.example +++ b/.env.example @@ -1 +1,2 @@ -REACT_APP_PINATA_API_TOKEN= \ No newline at end of file +REACT_APP_PINATA_API_TOKEN= +REACT_APP_SENTRY_DSN= \ No newline at end of file diff --git a/package.json b/package.json index ae79e7d5f..5ce5325f9 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,8 @@ "@juggle/resize-observer": "^3.2.0", "@nivo/core": "^0.73.0", "@nivo/line": "^0.73.0", + "@sentry/react": "^6.16.1", + "@sentry/tracing": "^6.16.1", "bignumber.js": "^9.0.0", "canvas-confetti": "^1.4.0", "clipboard-polyfill": "^3.0.0-pre5", diff --git a/src/App.tsx b/src/App.tsx index 66da37b04..f4ca65024 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,17 +1,20 @@ import React from 'react' import { HashRouter } from 'react-router-dom' + import { Main } from '@1hive/1hive-ui' -import GlobalErrorHandler from './GlobalErrorHandler' import MainView from '@components/MainView' -import Routes from './routes/Routes' import WelcomeLoader from '@components/Welcome/WelcomeLoader' +import GlobalErrorHandler from './GlobalErrorHandler' import { GardensProvider } from './providers/Gardens' import { ProfileProvider } from './providers/Profile' import { UserProvider } from './providers/User' import { WalletProvider } from './providers/Wallet' +import Routes from './routes/Routes' +import initializeSentry from './sentry' +initializeSentry() function App() { return ( diff --git a/src/environment.js b/src/environment.js index a07fec64c..a00f3f48a 100644 --- a/src/environment.js +++ b/src/environment.js @@ -7,6 +7,8 @@ const DEFAULT_VOTING_APP_NAME = 'disputable-voting' const DEFAULT_XDAI_ETH_NODE_ENDPOINT = 'https://rpc.xdaichain.com' const DEFAULT_POLYGON_ETH_NODE_ENDPOINT = 'https://polygon-rpc.com' +const DEFAULT_VERCEL_ENV = 'localhost' + const ENV_VARS = { AGREEMENT_APP_NAME() { return ( @@ -60,8 +62,11 @@ const ENV_VARS = { POCKET_API_KEY() { return process.env.REACT_APP_POCKET_API_KEY || null }, + SENTRY_DSN() { + return process.env.REACT_APP_SENTRY_DSN || null + }, VERCEL_ENV() { - return process.env.REACT_APP_VERCEL_ENV || null + return process.env.REACT_APP_VERCEL_ENV || DEFAULT_VERCEL_ENV }, VOTING_APP_NAME() { return process.env.REACT_APP_VOTING_APP_NAME || DEFAULT_VOTING_APP_NAME diff --git a/src/sentry.ts b/src/sentry.ts new file mode 100644 index 000000000..9af91cb41 --- /dev/null +++ b/src/sentry.ts @@ -0,0 +1,41 @@ +import { Severity, captureMessage } from '@sentry/browser' +import * as Sentry from '@sentry/react' +import { Integrations } from '@sentry/tracing' + +import env from './environment' +import { getNetworkType } from './utils/web3-utils' + +export const sentryEnabled = Boolean(env('SENTRY_DSN')) + +export default function initializeSentry() { + if (sentryEnabled) { + Sentry.init({ + dsn: env('SENTRY_DSN'), + integrations: [new Integrations.BrowserTracing()], + environment: `${env('VERCEL_ENV')}@${getNetworkType()}`, + // release: 'gardens-ui@' + env('VERCEL_ENV'), + + // Set tracesSampleRate to 1.0 to capture 100% + // of transactions for performance monitoring. + // We recommend adjusting this value in production + tracesSampleRate: 1.0, + }) + // Add more info context, but it not can be searchable. + // Sentry.setContext('Git User', { + // name: 'Felipe', + // email: 'windholyghost@gmail.com', + // }) + } +} + +export function logWithSentry(message: string, level = Severity.Warning) { + if (sentryEnabled) { + captureMessage(message, { + // We too could sent tags to be searchable. + // tags: { + // gitDeveloper: '', + // }, + level, + }) + } +} diff --git a/tsconfig.json b/tsconfig.json index 50b1791e4..014afb5e9 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,7 +21,10 @@ "typeRoots": [ "./src/types", "./node_modules/@types" - ] + ], + "sourceMap": true, + "inlineSources": true, + "sourceRoot": "/" }, "include": [ "src" diff --git a/yarn.lock b/yarn.lock index 0e83e604b..ecda7f0d2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2938,6 +2938,81 @@ "@react-spring/shared" "~9.2.0" "@react-spring/types" "~9.2.0" +"@sentry/browser@6.16.1": + version "6.16.1" + resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-6.16.1.tgz#4270ab0fbd1de425e339b3e7a364feb09f470a87" + integrity sha512-F2I5RL7RTLQF9CccMrqt73GRdK3FdqaChED3RulGQX5lH6U3exHGFxwyZxSrY4x6FedfBFYlfXWWCJXpLnFkow== + dependencies: + "@sentry/core" "6.16.1" + "@sentry/types" "6.16.1" + "@sentry/utils" "6.16.1" + tslib "^1.9.3" + +"@sentry/core@6.16.1": + version "6.16.1" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.16.1.tgz#d9f7a75f641acaddf21b6aafa7a32e142f68f17c" + integrity sha512-UFI0264CPUc5cR1zJH+S2UPOANpm6dLJOnsvnIGTjsrwzR0h8Hdl6rC2R/GPq+WNbnipo9hkiIwDlqbqvIU5vw== + dependencies: + "@sentry/hub" "6.16.1" + "@sentry/minimal" "6.16.1" + "@sentry/types" "6.16.1" + "@sentry/utils" "6.16.1" + tslib "^1.9.3" + +"@sentry/hub@6.16.1": + version "6.16.1" + resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-6.16.1.tgz#526e19db51f4412da8634734044c605b936a7b80" + integrity sha512-4PGtg6AfpqMkreTpL7ymDeQ/U1uXv03bKUuFdtsSTn/FRf9TLS4JB0KuTZCxfp1IRgAA+iFg6B784dDkT8R9eg== + dependencies: + "@sentry/types" "6.16.1" + "@sentry/utils" "6.16.1" + tslib "^1.9.3" + +"@sentry/minimal@6.16.1": + version "6.16.1" + resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-6.16.1.tgz#6a9506a92623d2ff1fc17d60989688323326772e" + integrity sha512-dq+mI1EQIvUM+zJtGCVgH3/B3Sbx4hKlGf2Usovm9KoqWYA+QpfVBholYDe/H2RXgO7LFEefDLvOdHDkqeJoyA== + dependencies: + "@sentry/hub" "6.16.1" + "@sentry/types" "6.16.1" + tslib "^1.9.3" + +"@sentry/react@^6.16.1": + version "6.16.1" + resolved "https://registry.yarnpkg.com/@sentry/react/-/react-6.16.1.tgz#d4930c4b23bcd307306a0549d20964d98caed38c" + integrity sha512-n8fOEKbym4kBi946q3AWXBNy1UKTmABj/hE2nAJbTWhi5IwdM7WBG6QCT2yq7oTHLuTxQrAwgKQc+A6zFTyVHg== + dependencies: + "@sentry/browser" "6.16.1" + "@sentry/minimal" "6.16.1" + "@sentry/types" "6.16.1" + "@sentry/utils" "6.16.1" + hoist-non-react-statics "^3.3.2" + tslib "^1.9.3" + +"@sentry/tracing@^6.16.1": + version "6.16.1" + resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-6.16.1.tgz#32fba3e07748e9a955055afd559a65996acb7d71" + integrity sha512-MPSbqXX59P+OEeST+U2V/8Hu/8QjpTUxTNeNyTHWIbbchdcMMjDbXTS3etCgajZR6Ro+DHElOz5cdSxH6IBGlA== + dependencies: + "@sentry/hub" "6.16.1" + "@sentry/minimal" "6.16.1" + "@sentry/types" "6.16.1" + "@sentry/utils" "6.16.1" + tslib "^1.9.3" + +"@sentry/types@6.16.1": + version "6.16.1" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.16.1.tgz#4917607115b30315757c2cf84f80bac5100b8ac0" + integrity sha512-Wh354g30UsJ5kYJbercektGX4ZMc9MHU++1NjeN2bTMnbofEcpUDWIiKeulZEY65IC1iU+1zRQQgtYO+/hgCUQ== + +"@sentry/utils@6.16.1": + version "6.16.1" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-6.16.1.tgz#1b9e14c2831b6e8b816f7021b9876133bf2be008" + integrity sha512-7ngq/i4R8JZitJo9Sl8PDnjSbDehOxgr1vsoMmerIsyRZ651C/8B+jVkMhaAPgSdyJ0AlE3O7DKKTP1FXFw9qw== + dependencies: + "@sentry/types" "6.16.1" + tslib "^1.9.3" + "@sindresorhus/is@^0.14.0": version "0.14.0" resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea" @@ -10520,7 +10595,7 @@ hmac-drbg@^1.0.1: minimalistic-assert "^1.0.0" minimalistic-crypto-utils "^1.0.1" -hoist-non-react-statics@^3.0.0, hoist-non-react-statics@^3.1.0, hoist-non-react-statics@^3.3.0: +hoist-non-react-statics@^3.0.0, hoist-non-react-statics@^3.1.0, hoist-non-react-statics@^3.3.0, hoist-non-react-statics@^3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45" integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw== @@ -20585,7 +20660,7 @@ tsconfig-paths@^3.11.0: minimist "^1.2.0" strip-bom "^3.0.0" -tslib@^1.10.0, tslib@^1.8.1, tslib@^1.9.0: +tslib@^1.10.0, 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== From e7618d2c47c721207c741e750dfaa6f54bf4e685 Mon Sep 17 00:00:00 2001 From: Felipe Novaes Rocha Date: Tue, 28 Dec 2021 18:33:36 -0300 Subject: [PATCH 3/9] fix: disable prettier and fix eslint on 2 files --- .../Garden/Preferences/EVMExecutor.js | 25 ++++++++++++------- src/components/SingleDatePicker/DatePicker.js | 14 +++++++---- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/components/Garden/Preferences/EVMExecutor.js b/src/components/Garden/Preferences/EVMExecutor.js index e579b7d4f..e9e66870c 100644 --- a/src/components/Garden/Preferences/EVMExecutor.js +++ b/src/components/Garden/Preferences/EVMExecutor.js @@ -1,6 +1,8 @@ /* eslint-disable no-unexpected-multiline */ import React, { useCallback, useMemo, useState } from 'react' + import { utils } from 'ethers' + import { Box, Button, @@ -10,16 +12,21 @@ import { Info, TextInput, } from '@1hive/1hive-ui' + import MultiModal from '@components/MultiModal/MultiModal' + import { useConnectedGarden } from '@providers/ConnectedGarden' + import { SHORTENED_APPS_NAMES } from '@utils/app-utils' import { getAppByName } from '@utils/data-utils' + import actions from '@/actions/garden-action-types' import { TERMINAL_EXECUTOR_MESSAGE } from '@/constants' import env from '@/environment' import { useGardenState } from '@/providers/GardenState' import { useWallet } from '@/providers/Wallet' import radspec from '@/radspec' + import CreateDecisionScreens from '../ModalFlows/CreateDecisionScreens/CreateDecisionScreens' const INTERACTION_TYPES = ['Internal', 'External', 'Terminal'] @@ -66,7 +73,7 @@ function EVMExecutor({ evmcrispr }) { return evmcrispr.apps() }, [evmcrispr]) - const shortenedAppsNames = installedApps.map(appName => { + const shortenedAppsNames = installedApps.map((appName) => { const dotIndex = appName.indexOf('.') return ( SHORTENED_APPS_NAMES.get( @@ -87,7 +94,7 @@ function EVMExecutor({ evmcrispr }) { appFunctions = evmcrispr.appMethods(appName) } if (interactionType === EXTERNAL_INDEX && formattedAbi) { - appFunctions = formattedAbi.map(item => { + appFunctions = formattedAbi.map((item) => { if (item.type === 'function' && item.stateMutability !== 'view') { return item.name } @@ -121,7 +128,7 @@ function EVMExecutor({ evmcrispr }) { }) } if (interactionType === EXTERNAL_INDEX && formattedAbi) { - return formattedAbi[selectedFunction].inputs.map(parameter => { + return formattedAbi[selectedFunction].inputs.map((parameter) => { return [parameter.name, parameter.type] }) } @@ -155,7 +162,7 @@ function EVMExecutor({ evmcrispr }) { const handleOnChangeParameters = useCallback((index, event) => { const newValue = event.target.value - setParameters(prevState => { + setParameters((prevState) => { const newArray = [...prevState] newArray[index] = newValue return newArray @@ -224,12 +231,12 @@ function EVMExecutor({ evmcrispr }) { code, ]) - const handleOnContractAddressChange = useCallback(event => { + const handleOnContractAddressChange = useCallback((event) => { const value = event.target.value setExternalContractAddress(value) }, []) - const handleOnAbiChange = useCallback(event => { + const handleOnAbiChange = useCallback((event) => { const value = event.target.value setAbi(value) let iface @@ -238,7 +245,7 @@ function EVMExecutor({ evmcrispr }) { iface = new utils.Interface(value) formattedAbi = iface.format(utils.FormatTypes.json) setFormattedAbi( - JSON.parse(formattedAbi).filter(item => { + JSON.parse(formattedAbi).filter((item) => { if (item.type === 'function' && item.stateMutability !== 'view') { return item.name } @@ -257,7 +264,7 @@ function EVMExecutor({ evmcrispr }) { setCreateDecisionModalVisible(false) }, []) - const handleOnSetCode = useCallback(event => { + const handleOnSetCode = useCallback((event) => { const value = event.target.value setCode(value) }, []) @@ -337,7 +344,7 @@ function EVMExecutor({ evmcrispr }) { return ( handleOnChangeParameters(index, event)} + onChange={(event) => handleOnChangeParameters(index, event)} placeholder={`${parameter[0].toString()} : ${parameter[1].toString()}`} wide css={` diff --git a/src/components/SingleDatePicker/DatePicker.js b/src/components/SingleDatePicker/DatePicker.js index d1429fa5d..7c27b832f 100644 --- a/src/components/SingleDatePicker/DatePicker.js +++ b/src/components/SingleDatePicker/DatePicker.js @@ -1,8 +1,12 @@ /* eslint-disable no-unexpected-multiline */ import React, { useState } from 'react' + import PropTypes from 'prop-types' -import { eachDayOfInterval, GU } from '@1hive/1hive-ui' + +import { GU, eachDayOfInterval } from '@1hive/1hive-ui' + import { dayjs } from '@utils/date-utils' + import MonthDay from './MonthDay' import { Selector } from './components' @@ -23,7 +27,7 @@ function DatePicker({ const setDate = ({ year, add }) => - event => { + (event) => { setSelectedDate( dayjs(selectedDate) .startOf('month') @@ -36,7 +40,7 @@ function DatePicker({ const selectedDayjs = dayjs(selectedDate || today) - const isSelected = day => { + const isSelected = (day) => { if (initialDate) { return day.isSame(initialDate, 'day') } @@ -82,7 +86,7 @@ function DatePicker({ eachDayOfInterval({ start: selectedDayjs.startOf('week'), end: selectedDayjs.endOf('week'), - }).map(day => { + }).map((day) => { const dayJs = dayjs(day) return ( @@ -94,7 +98,7 @@ function DatePicker({ {eachDayOfInterval({ start: selectedDayjs.startOf('month').startOf('week'), end: selectedDayjs.endOf('month').endOf('week'), - }).map(day => { + }).map((day) => { const dayJs = dayjs(day) return ( Date: Tue, 28 Dec 2021 20:16:00 -0300 Subject: [PATCH 4/9] feat: (wip) implement Sentry --- .env.example | 3 +- package.json | 2 ++ src/App.tsx | 7 ++-- src/environment.js | 7 +++- src/sentry.ts | 41 ++++++++++++++++++++++++ tsconfig.json | 5 ++- yarn.lock | 79 ++++++++++++++++++++++++++++++++++++++++++++-- 7 files changed, 137 insertions(+), 7 deletions(-) create mode 100644 src/sentry.ts diff --git a/.env.example b/.env.example index aff82280b..74edcb9bf 100644 --- a/.env.example +++ b/.env.example @@ -1 +1,2 @@ -REACT_APP_PINATA_API_TOKEN= \ No newline at end of file +REACT_APP_PINATA_API_TOKEN= +REACT_APP_SENTRY_DSN= \ No newline at end of file diff --git a/package.json b/package.json index a2698bbf0..e176e15ba 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,8 @@ "@nivo/core": "^0.73.0", "@nivo/line": "^0.73.0", "assert": "^2.0.0", + "@sentry/react": "^6.16.1", + "@sentry/tracing": "^6.16.1", "bignumber.js": "^9.0.0", "buffer": "^6.0.3", "canvas-confetti": "^1.4.0", diff --git a/src/App.tsx b/src/App.tsx index 66da37b04..f4ca65024 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,17 +1,20 @@ import React from 'react' import { HashRouter } from 'react-router-dom' + import { Main } from '@1hive/1hive-ui' -import GlobalErrorHandler from './GlobalErrorHandler' import MainView from '@components/MainView' -import Routes from './routes/Routes' import WelcomeLoader from '@components/Welcome/WelcomeLoader' +import GlobalErrorHandler from './GlobalErrorHandler' import { GardensProvider } from './providers/Gardens' import { ProfileProvider } from './providers/Profile' import { UserProvider } from './providers/User' import { WalletProvider } from './providers/Wallet' +import Routes from './routes/Routes' +import initializeSentry from './sentry' +initializeSentry() function App() { return ( diff --git a/src/environment.js b/src/environment.js index a07fec64c..a00f3f48a 100644 --- a/src/environment.js +++ b/src/environment.js @@ -7,6 +7,8 @@ const DEFAULT_VOTING_APP_NAME = 'disputable-voting' const DEFAULT_XDAI_ETH_NODE_ENDPOINT = 'https://rpc.xdaichain.com' const DEFAULT_POLYGON_ETH_NODE_ENDPOINT = 'https://polygon-rpc.com' +const DEFAULT_VERCEL_ENV = 'localhost' + const ENV_VARS = { AGREEMENT_APP_NAME() { return ( @@ -60,8 +62,11 @@ const ENV_VARS = { POCKET_API_KEY() { return process.env.REACT_APP_POCKET_API_KEY || null }, + SENTRY_DSN() { + return process.env.REACT_APP_SENTRY_DSN || null + }, VERCEL_ENV() { - return process.env.REACT_APP_VERCEL_ENV || null + return process.env.REACT_APP_VERCEL_ENV || DEFAULT_VERCEL_ENV }, VOTING_APP_NAME() { return process.env.REACT_APP_VOTING_APP_NAME || DEFAULT_VOTING_APP_NAME diff --git a/src/sentry.ts b/src/sentry.ts new file mode 100644 index 000000000..9af91cb41 --- /dev/null +++ b/src/sentry.ts @@ -0,0 +1,41 @@ +import { Severity, captureMessage } from '@sentry/browser' +import * as Sentry from '@sentry/react' +import { Integrations } from '@sentry/tracing' + +import env from './environment' +import { getNetworkType } from './utils/web3-utils' + +export const sentryEnabled = Boolean(env('SENTRY_DSN')) + +export default function initializeSentry() { + if (sentryEnabled) { + Sentry.init({ + dsn: env('SENTRY_DSN'), + integrations: [new Integrations.BrowserTracing()], + environment: `${env('VERCEL_ENV')}@${getNetworkType()}`, + // release: 'gardens-ui@' + env('VERCEL_ENV'), + + // Set tracesSampleRate to 1.0 to capture 100% + // of transactions for performance monitoring. + // We recommend adjusting this value in production + tracesSampleRate: 1.0, + }) + // Add more info context, but it not can be searchable. + // Sentry.setContext('Git User', { + // name: 'Felipe', + // email: 'windholyghost@gmail.com', + // }) + } +} + +export function logWithSentry(message: string, level = Severity.Warning) { + if (sentryEnabled) { + captureMessage(message, { + // We too could sent tags to be searchable. + // tags: { + // gitDeveloper: '', + // }, + level, + }) + } +} diff --git a/tsconfig.json b/tsconfig.json index 6e14060ef..1fab9ef3e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -22,7 +22,10 @@ "./src/types", "./node_modules/@types" ], - "noFallthroughCasesInSwitch": true + "noFallthroughCasesInSwitch": true, + "sourceMap": true, + "inlineSources": true, + "sourceRoot": "/" }, "include": [ "src" diff --git a/yarn.lock b/yarn.lock index 1b0e70da6..1005c6ec3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2939,6 +2939,81 @@ resolved "https://registry.yarnpkg.com/@rushstack/eslint-patch/-/eslint-patch-1.1.0.tgz#7f698254aadf921e48dda8c0a6b304026b8a9323" integrity sha512-JLo+Y592QzIE+q7Dl2pMUtt4q8SKYI5jDrZxrozEQxnGVOyYE+GWK9eLkwTaeN9DDctlaRAQ3TBmzZ1qdLE30A== +"@sentry/browser@6.16.1": + version "6.16.1" + resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-6.16.1.tgz#4270ab0fbd1de425e339b3e7a364feb09f470a87" + integrity sha512-F2I5RL7RTLQF9CccMrqt73GRdK3FdqaChED3RulGQX5lH6U3exHGFxwyZxSrY4x6FedfBFYlfXWWCJXpLnFkow== + dependencies: + "@sentry/core" "6.16.1" + "@sentry/types" "6.16.1" + "@sentry/utils" "6.16.1" + tslib "^1.9.3" + +"@sentry/core@6.16.1": + version "6.16.1" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.16.1.tgz#d9f7a75f641acaddf21b6aafa7a32e142f68f17c" + integrity sha512-UFI0264CPUc5cR1zJH+S2UPOANpm6dLJOnsvnIGTjsrwzR0h8Hdl6rC2R/GPq+WNbnipo9hkiIwDlqbqvIU5vw== + dependencies: + "@sentry/hub" "6.16.1" + "@sentry/minimal" "6.16.1" + "@sentry/types" "6.16.1" + "@sentry/utils" "6.16.1" + tslib "^1.9.3" + +"@sentry/hub@6.16.1": + version "6.16.1" + resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-6.16.1.tgz#526e19db51f4412da8634734044c605b936a7b80" + integrity sha512-4PGtg6AfpqMkreTpL7ymDeQ/U1uXv03bKUuFdtsSTn/FRf9TLS4JB0KuTZCxfp1IRgAA+iFg6B784dDkT8R9eg== + dependencies: + "@sentry/types" "6.16.1" + "@sentry/utils" "6.16.1" + tslib "^1.9.3" + +"@sentry/minimal@6.16.1": + version "6.16.1" + resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-6.16.1.tgz#6a9506a92623d2ff1fc17d60989688323326772e" + integrity sha512-dq+mI1EQIvUM+zJtGCVgH3/B3Sbx4hKlGf2Usovm9KoqWYA+QpfVBholYDe/H2RXgO7LFEefDLvOdHDkqeJoyA== + dependencies: + "@sentry/hub" "6.16.1" + "@sentry/types" "6.16.1" + tslib "^1.9.3" + +"@sentry/react@^6.16.1": + version "6.16.1" + resolved "https://registry.yarnpkg.com/@sentry/react/-/react-6.16.1.tgz#d4930c4b23bcd307306a0549d20964d98caed38c" + integrity sha512-n8fOEKbym4kBi946q3AWXBNy1UKTmABj/hE2nAJbTWhi5IwdM7WBG6QCT2yq7oTHLuTxQrAwgKQc+A6zFTyVHg== + dependencies: + "@sentry/browser" "6.16.1" + "@sentry/minimal" "6.16.1" + "@sentry/types" "6.16.1" + "@sentry/utils" "6.16.1" + hoist-non-react-statics "^3.3.2" + tslib "^1.9.3" + +"@sentry/tracing@^6.16.1": + version "6.16.1" + resolved "https://registry.yarnpkg.com/@sentry/tracing/-/tracing-6.16.1.tgz#32fba3e07748e9a955055afd559a65996acb7d71" + integrity sha512-MPSbqXX59P+OEeST+U2V/8Hu/8QjpTUxTNeNyTHWIbbchdcMMjDbXTS3etCgajZR6Ro+DHElOz5cdSxH6IBGlA== + dependencies: + "@sentry/hub" "6.16.1" + "@sentry/minimal" "6.16.1" + "@sentry/types" "6.16.1" + "@sentry/utils" "6.16.1" + tslib "^1.9.3" + +"@sentry/types@6.16.1": + version "6.16.1" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.16.1.tgz#4917607115b30315757c2cf84f80bac5100b8ac0" + integrity sha512-Wh354g30UsJ5kYJbercektGX4ZMc9MHU++1NjeN2bTMnbofEcpUDWIiKeulZEY65IC1iU+1zRQQgtYO+/hgCUQ== + +"@sentry/utils@6.16.1": + version "6.16.1" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-6.16.1.tgz#1b9e14c2831b6e8b816f7021b9876133bf2be008" + integrity sha512-7ngq/i4R8JZitJo9Sl8PDnjSbDehOxgr1vsoMmerIsyRZ651C/8B+jVkMhaAPgSdyJ0AlE3O7DKKTP1FXFw9qw== + dependencies: + "@sentry/types" "6.16.1" + tslib "^1.9.3" + "@sindresorhus/is@^0.14.0": version "0.14.0" resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea" @@ -10667,7 +10742,7 @@ hmac-drbg@^1.0.1: minimalistic-assert "^1.0.0" minimalistic-crypto-utils "^1.0.1" -hoist-non-react-statics@^3.0.0, hoist-non-react-statics@^3.1.0, hoist-non-react-statics@^3.3.0: +hoist-non-react-statics@^3.0.0, hoist-non-react-statics@^3.1.0, hoist-non-react-statics@^3.3.0, hoist-non-react-statics@^3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45" integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw== @@ -20413,7 +20488,7 @@ tsconfig-paths@^3.11.0: minimist "^1.2.0" strip-bom "^3.0.0" -tslib@^1.10.0, tslib@^1.8.1: +tslib@^1.10.0, tslib@^1.8.1, 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== From e85758657f31631ad34e4112df23465b82d6574c Mon Sep 17 00:00:00 2001 From: Felipe Novaes Rocha Date: Tue, 28 Dec 2021 23:34:29 -0300 Subject: [PATCH 5/9] test: add logs to sentry --- src/App.tsx | 3 ++- src/components/Home.tsx | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index f4ca65024..cd6f71cf1 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -12,9 +12,10 @@ import { ProfileProvider } from './providers/Profile' import { UserProvider } from './providers/User' import { WalletProvider } from './providers/Wallet' import Routes from './routes/Routes' -import initializeSentry from './sentry' +import initializeSentry, { logWithSentry } from './sentry' initializeSentry() +logWithSentry('Init App.tsx') function App() { return ( diff --git a/src/components/Home.tsx b/src/components/Home.tsx index 59c44b48f..371eb6d0d 100644 --- a/src/components/Home.tsx +++ b/src/components/Home.tsx @@ -1,21 +1,28 @@ import React, { useCallback, useState } from 'react' + import styled from 'styled-components' + import { GU, useToast } from '@1hive/1hive-ui' + import { useGardens } from '@providers/Gardens' +import { useWallet } from '@providers/Wallet' + import { useNodeHeight } from '@hooks/useNodeHeight' + +import { logWithSentry } from '@/sentry' + import GardensFilters from './GardensFilters' import GardensList from './GardensList' import LandingBanner from './LandingBanner' -import { useWallet } from '@providers/Wallet' -import MultiModal from './MultiModal/MultiModal' -import ConnectWalletScreens from './MultiModal/ConnectWallet/ConnectWalletScreens' import Loader from './Loader' +import ConnectWalletScreens from './MultiModal/ConnectWallet/ConnectWalletScreens' +import MultiModal from './MultiModal/MultiModal' import Onboarding from './Onboarding' const DynamicSection = styled.div<{ marginTop: any }>` - margin-top: ${props => props.marginTop}px; + margin-top: ${(props) => props.marginTop}px; padding: 0 ${2 * GU}px; ` @@ -38,10 +45,12 @@ function Home() { return } setOnboardingVisible(true) + logWithSentry('Opened Onboarding') }, [account]) const handleOnboardingClose = useCallback(() => { setOnboardingVisible(false) + logWithSentry('Closed Onboarding') toast('Saved!') }, [toast]) From 651dbcb3cbfa7104b4eb1f4d998312496f06c3bc Mon Sep 17 00:00:00 2001 From: Felipe Novaes Rocha Date: Tue, 28 Dec 2021 23:46:26 -0300 Subject: [PATCH 6/9] fix: env to activate sentry --- src/environment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/environment.js b/src/environment.js index a00f3f48a..58d6a0972 100644 --- a/src/environment.js +++ b/src/environment.js @@ -63,7 +63,7 @@ const ENV_VARS = { return process.env.REACT_APP_POCKET_API_KEY || null }, SENTRY_DSN() { - return process.env.REACT_APP_SENTRY_DSN || null + return process.env.REACT_APP_SENTRY_DSN || process.env.SENTRY_DSN || null }, VERCEL_ENV() { return process.env.REACT_APP_VERCEL_ENV || DEFAULT_VERCEL_ENV From 9eb848ba2ced0ed820e21fd2fb68521c27862325 Mon Sep 17 00:00:00 2001 From: Felipe Novaes Rocha Date: Wed, 29 Dec 2021 01:02:01 -0300 Subject: [PATCH 7/9] test: addind sentry-webpack-plugin to send source maps --- config-overrides.js | 13 +++++++++++++ package.json | 3 ++- yarn.lock | 28 ++++++++++++++++++++++++++-- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/config-overrides.js b/config-overrides.js index 950cdedfb..9f192d0ab 100644 --- a/config-overrides.js +++ b/config-overrides.js @@ -10,6 +10,8 @@ const { } = require('customize-cra') const webpack = require('webpack') +const SentryWebpackPlugin = require('@sentry/webpack-plugin') + module.exports = override( useBabelRc(), addWebpackAlias({ @@ -27,6 +29,17 @@ module.exports = override( Buffer: ['buffer', 'Buffer'], }) ), + addWebpackPlugin( + new SentryWebpackPlugin({ + authToken: process.env.SENTRY_AUTH_TOKEN, + org: process.env.SENTRY_ORG, + project: process.env.SENTRY_PROJECT, + include: './build', + debug: true, + validate: true, + release: process.env.VERCEL_GIT_COMMIT_SHA, + }) + ), addWebpackPlugin( new webpack.ProvidePlugin({ process: 'process/browser', diff --git a/package.json b/package.json index e176e15ba..3511e27e2 100644 --- a/package.json +++ b/package.json @@ -20,9 +20,9 @@ "@juggle/resize-observer": "^3.2.0", "@nivo/core": "^0.73.0", "@nivo/line": "^0.73.0", - "assert": "^2.0.0", "@sentry/react": "^6.16.1", "@sentry/tracing": "^6.16.1", + "assert": "^2.0.0", "bignumber.js": "^9.0.0", "buffer": "^6.0.3", "canvas-confetti": "^1.4.0", @@ -70,6 +70,7 @@ "@babel/plugin-proposal-class-properties": "^7.16.5", "@babel/preset-env": "^7.16.5", "@babel/preset-react": "^7.16.5", + "@sentry/webpack-plugin": "^1.18.3", "@trivago/prettier-plugin-sort-imports": "^3.1.1", "@types/node": "^16.11.12", "@types/react": "^17.0.37", diff --git a/yarn.lock b/yarn.lock index 1005c6ec3..e4c6b144a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2949,6 +2949,18 @@ "@sentry/utils" "6.16.1" tslib "^1.9.3" +"@sentry/cli@^1.70.1": + version "1.71.0" + resolved "https://registry.yarnpkg.com/@sentry/cli/-/cli-1.71.0.tgz#1e33e05d7651b68f501764ab24dce3d5932b195d" + integrity sha512-Z8TzH7PkiRfjWSzjXOfPWWp6wxjr+n39Jdrt26OcInVQZM1sx/gZULrDiQZ1L2dy9Fe9AR4SF4nt2/7h2GmLQQ== + dependencies: + https-proxy-agent "^5.0.0" + mkdirp "^0.5.5" + node-fetch "^2.6.0" + npmlog "^4.1.2" + progress "^2.0.3" + proxy-from-env "^1.1.0" + "@sentry/core@6.16.1": version "6.16.1" resolved "https://registry.yarnpkg.com/@sentry/core/-/core-6.16.1.tgz#d9f7a75f641acaddf21b6aafa7a32e142f68f17c" @@ -3014,6 +3026,13 @@ "@sentry/types" "6.16.1" tslib "^1.9.3" +"@sentry/webpack-plugin@^1.18.3": + version "1.18.3" + resolved "https://registry.yarnpkg.com/@sentry/webpack-plugin/-/webpack-plugin-1.18.3.tgz#1cd3401f84f561b4a451dac5f42465ee5102f5d6" + integrity sha512-Qk3Jevislc5DZK0X/WwRVcOtO7iatnWARsEgTV/TuXvDN+fUDDpD/2MytAWAbpLaLy3xEB/cXGeLsbv6d1XNkQ== + dependencies: + "@sentry/cli" "^1.70.1" + "@sindresorhus/is@^0.14.0": version "0.14.0" resolved "https://registry.yarnpkg.com/@sindresorhus/is/-/is-0.14.0.tgz#9fb3a3cf3132328151f353de4632e01e52102bea" @@ -15693,7 +15712,7 @@ npm-run-path@^4.0.1: dependencies: path-key "^3.0.0" -npmlog@^4.0.2: +npmlog@^4.0.2, npmlog@^4.1.2: version "4.1.2" resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.1.2.tgz#08a7f2a8bf734604779a9efa4ad5cc717abb954b" integrity sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg== @@ -17449,7 +17468,7 @@ process@^0.11.10: resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" integrity sha1-czIwDoQBYb2j5podHZGn1LwW8YI= -progress@^2.0.0, progress@^2.0.1: +progress@^2.0.0, progress@^2.0.1, 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== @@ -17579,6 +17598,11 @@ proxy-addr@~2.0.5: forwarded "0.2.0" 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" From ae096314e207aada92aaec62797fb8fb1e369d94 Mon Sep 17 00:00:00 2001 From: Felipe Novaes Rocha Date: Wed, 29 Dec 2021 02:48:52 -0300 Subject: [PATCH 8/9] test: add release config --- config-overrides.js | 4 +++- src/environment.js | 4 ++++ src/sentry.ts | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/config-overrides.js b/config-overrides.js index 9f192d0ab..bb4b71155 100644 --- a/config-overrides.js +++ b/config-overrides.js @@ -35,7 +35,9 @@ module.exports = override( org: process.env.SENTRY_ORG, project: process.env.SENTRY_PROJECT, include: './build', - debug: true, + debug: false, + // ignore: ['node_modules', 'webpack.config.js'], + configFile: path.resolve(__dirname, '.sentryclirc'), validate: true, release: process.env.VERCEL_GIT_COMMIT_SHA, }) diff --git a/src/environment.js b/src/environment.js index 58d6a0972..02261dd84 100644 --- a/src/environment.js +++ b/src/environment.js @@ -8,6 +8,7 @@ const DEFAULT_XDAI_ETH_NODE_ENDPOINT = 'https://rpc.xdaichain.com' const DEFAULT_POLYGON_ETH_NODE_ENDPOINT = 'https://polygon-rpc.com' const DEFAULT_VERCEL_ENV = 'localhost' +const DEFAULT_VERCEL_GIT_COMMIT_SHA = 'bababa' const ENV_VARS = { AGREEMENT_APP_NAME() { @@ -68,6 +69,9 @@ const ENV_VARS = { VERCEL_ENV() { return process.env.REACT_APP_VERCEL_ENV || DEFAULT_VERCEL_ENV }, + VERCEL_GIT_COMMIT_SHA() { + return process.env.VERCEL_GIT_COMMIT_SHA || DEFAULT_VERCEL_GIT_COMMIT_SHA + }, VOTING_APP_NAME() { return process.env.REACT_APP_VOTING_APP_NAME || DEFAULT_VOTING_APP_NAME }, diff --git a/src/sentry.ts b/src/sentry.ts index 9af91cb41..5b98601ed 100644 --- a/src/sentry.ts +++ b/src/sentry.ts @@ -8,12 +8,13 @@ import { getNetworkType } from './utils/web3-utils' export const sentryEnabled = Boolean(env('SENTRY_DSN')) export default function initializeSentry() { + console.log(`sentryEnabled: ${sentryEnabled}`) if (sentryEnabled) { Sentry.init({ dsn: env('SENTRY_DSN'), integrations: [new Integrations.BrowserTracing()], environment: `${env('VERCEL_ENV')}@${getNetworkType()}`, - // release: 'gardens-ui@' + env('VERCEL_ENV'), + release: env('VERCEL_GIT_COMMIT_SHA'), // Set tracesSampleRate to 1.0 to capture 100% // of transactions for performance monitoring. From 1a4407d86421f5a3b3698afda58941f8a567f6d1 Mon Sep 17 00:00:00 2001 From: Felipe Novaes Rocha Date: Wed, 29 Dec 2021 03:43:48 -0300 Subject: [PATCH 9/9] fix: invert env --- src/environment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/environment.js b/src/environment.js index 02261dd84..af654f6cc 100644 --- a/src/environment.js +++ b/src/environment.js @@ -64,7 +64,7 @@ const ENV_VARS = { return process.env.REACT_APP_POCKET_API_KEY || null }, SENTRY_DSN() { - return process.env.REACT_APP_SENTRY_DSN || process.env.SENTRY_DSN || null + return process.env.SENTRY_DSN || process.env.REACT_APP_SENTRY_DSN || null }, VERCEL_ENV() { return process.env.REACT_APP_VERCEL_ENV || DEFAULT_VERCEL_ENV