From f1a9ec93fde2def7128decb0d4e457a207b08d7d Mon Sep 17 00:00:00 2001 From: Jordan Bibla Date: Mon, 10 Dec 2018 14:33:47 -0500 Subject: [PATCH 1/9] upgrade from raven to sentry/browser --- app/src/main/index.js | 26 ++-- app/src/renderer/main.js | 17 ++- app/src/renderer/vuex/modules/blockchain.js | 4 +- app/src/renderer/vuex/modules/connection.js | 6 +- app/src/renderer/vuex/modules/delegates.js | 4 +- app/src/renderer/vuex/modules/delegation.js | 4 +- .../vuex/modules/governance/deposits.js | 4 +- .../vuex/modules/governance/parameters.js | 4 +- .../vuex/modules/governance/proposals.js | 6 +- .../renderer/vuex/modules/governance/votes.js | 4 +- app/src/renderer/vuex/modules/keybase.js | 4 +- app/src/renderer/vuex/modules/parameters.js | 4 +- app/src/renderer/vuex/modules/pool.js | 4 +- app/src/renderer/vuex/modules/transactions.js | 4 +- app/src/renderer/vuex/modules/user.js | 10 +- app/src/renderer/vuex/modules/validators.js | 4 +- app/src/renderer/vuex/modules/wallet.js | 8 +- package.json | 4 +- test/unit/specs/App.spec.js | 6 +- test/unit/specs/main.spec.js | 10 +- yarn.lock | 123 ++++++++++++------ 21 files changed, 155 insertions(+), 105 deletions(-) diff --git a/app/src/main/index.js b/app/src/main/index.js index 7371175025..4fe6014e82 100644 --- a/app/src/main/index.js +++ b/app/src/main/index.js @@ -7,7 +7,7 @@ const https = require(`https`) let { join, relative } = require(`path`) let childProcess = require(`child_process`) let semver = require(`semver`) -let Raven = require(`raven`) +const Sentry = require("@sentry/node") const readline = require(`readline`) let axios = require(`axios`) @@ -222,7 +222,7 @@ function startProcess(name, args, env) { console.error(...errorMessage) // also output to console for easier debugging handleCrash(error) - Raven.captureException(error) + Sentry.captureException(error) } }) @@ -382,12 +382,12 @@ if (!TEST) { // on uncaught exceptions we wait so the sentry event can be sent process.on(`uncaughtException`, async function(error) { logError(`[Uncaught Exception]`, error) - Raven.captureException(error) + Sentry.captureException(error) handleCrash(error) }) process.on(`unhandledRejection`, async function(error) { logError(`[Unhandled Promise Rejection]`, error) - Raven.captureException(error) + Sentry.captureException(error) handleCrash(error) }) } @@ -399,11 +399,13 @@ const eventHandlers = { }, "error-collection": (event, optin) => { - Raven.uninstall() - .config(optin ? config.sentry_dsn : ``, { - captureUnhandledRejections: false + if (optin) { + Sentry.init({ + dsn: config.sentry_dsn, + release: `voyager@0.8001.1` }) - .install() + Sentry.captureException(new Error("Good bye")) + } }, mocked: value => { @@ -595,8 +597,12 @@ const checkGaiaCompatibility = async gaiacliVersionPath => { } async function main() { - // we only enable error collection after users opted in - Raven.config(``, { captureUnhandledRejections: false }).install() + // Sentry is used for automatic error reporting. It is turned off by default. + Sentry.init({ + dsn: config.sentry_dsn, + release: `voyager@0.8001.1` + }) + Sentry.captureException(new Error("TESTING SENTRY")) let appVersionPath = join(root, `app_version`) let genesisPath = join(root, `genesis.json`) diff --git a/app/src/renderer/main.js b/app/src/renderer/main.js index e0639c8a41..5a1d848ff3 100644 --- a/app/src/renderer/main.js +++ b/app/src/renderer/main.js @@ -5,7 +5,7 @@ import Electron from "vue-electron" import Router from "vue-router" import Tooltip from "vue-directive-tooltip" import Vuelidate from "vuelidate" -import Raven from "raven-js" +import * as Sentry from "@sentry/browser" import { ipcRenderer, remote } from "electron" import App from "./App" @@ -21,15 +21,20 @@ let store let node let router -// Raven serves automatic error reporting. It is turned off by default -Raven.config(``).install() +// Sentry is used for automatic error reporting. It is turned off by default. +Sentry.init({}) + +// this will pass the state to Sentry when errors are sent. +Sentry.configureScope(scope => { + scope.setExtra(Store.state) +}) // handle uncaught errors window.addEventListener(`unhandledrejection`, function(event) { - Raven.captureException(event.reason) + Sentry.captureException(event.reason) }) window.addEventListener(`error`, function(event) { - Raven.captureException(event.reason) + Sentry.captureException(event.reason) }) Vue.config.errorHandler = (error, vm, info) => { @@ -37,7 +42,7 @@ Vue.config.errorHandler = (error, vm, info) => { Guru Meditation #${info}`) - Raven.captureException(error) + Sentry.captureException(error) if (store.state.devMode) { throw error diff --git a/app/src/renderer/vuex/modules/blockchain.js b/app/src/renderer/vuex/modules/blockchain.js index f903e3833f..6d5c43c226 100644 --- a/app/src/renderer/vuex/modules/blockchain.js +++ b/app/src/renderer/vuex/modules/blockchain.js @@ -1,4 +1,4 @@ -import Raven from "raven-js" +import * as Sentry from "@sentry/browser" export default ({ node }) => { const state = { @@ -67,7 +67,7 @@ export default ({ node }) => { title: `Error fetching block information`, body: error.message }) - Raven.captureException(error) + Sentry.captureException(error) state.loading = false state.error = error return null diff --git a/app/src/renderer/vuex/modules/connection.js b/app/src/renderer/vuex/modules/connection.js index 4377d782db..d269dc4af9 100644 --- a/app/src/renderer/vuex/modules/connection.js +++ b/app/src/renderer/vuex/modules/connection.js @@ -1,5 +1,5 @@ import { ipcRenderer, remote } from "electron" -import Raven from "raven-js" +import * as Sentry from "@sentry/browser" import { sleep } from "scripts/common.js" const config = remote.getGlobal(`config`) @@ -86,7 +86,7 @@ export default function({ node }) { { query: `tm.event = 'NewBlockHeader'` }, (error, event) => { if (error) { - Raven.captureException(error) + Sentry.captureException(error) return console.error(`error subscribing to headers`, error) } dispatch(`setLastHeader`, event.data.value.header) @@ -126,7 +126,7 @@ export default function({ node }) { }, timeout) node.rpc.status(error => { if (error) { - Raven.captureException(error) + Sentry.captureException(error) console.error(`Couldn't get status via RPC:`, error) return } diff --git a/app/src/renderer/vuex/modules/delegates.js b/app/src/renderer/vuex/modules/delegates.js index f715109086..bc48ccaf48 100644 --- a/app/src/renderer/vuex/modules/delegates.js +++ b/app/src/renderer/vuex/modules/delegates.js @@ -1,4 +1,4 @@ -import Raven from "raven-js" +import * as Sentry from "@sentry/browser" import BN from "bignumber.js" import { ratToBigNumber } from "scripts/common" import num from "scripts/num" @@ -106,7 +106,7 @@ export default ({ node }) => { title: `Error fetching validators`, body: error.message }) - Raven.captureException(error) + Sentry.captureException(error) commit(`setDelegateLoading`, false) state.error = error return [] diff --git a/app/src/renderer/vuex/modules/delegation.js b/app/src/renderer/vuex/modules/delegation.js index 44beb52700..4c43b32e47 100644 --- a/app/src/renderer/vuex/modules/delegation.js +++ b/app/src/renderer/vuex/modules/delegation.js @@ -1,4 +1,4 @@ -import Raven from "raven-js" +import * as Sentry from "@sentry/browser" import { calculateShares } from "scripts/common" export default ({ node }) => { @@ -149,7 +149,7 @@ export default ({ node }) => { title: `Error fetching delegations`, body: error.message }) - Raven.captureException(error) + Sentry.captureException(error) state.error = error } diff --git a/app/src/renderer/vuex/modules/governance/deposits.js b/app/src/renderer/vuex/modules/governance/deposits.js index c0f279c3b0..866dac4bc5 100644 --- a/app/src/renderer/vuex/modules/governance/deposits.js +++ b/app/src/renderer/vuex/modules/governance/deposits.js @@ -1,4 +1,4 @@ -import Raven from "raven-js" +import * as Sentry from "@sentry/browser" export default ({ node }) => { const state = { @@ -30,7 +30,7 @@ export default ({ node }) => { title: `Error fetching deposits on proposals`, body: error.message }) - Raven.captureException(error) + Sentry.captureException(error) state.error = error } }, diff --git a/app/src/renderer/vuex/modules/governance/parameters.js b/app/src/renderer/vuex/modules/governance/parameters.js index 612901c041..2d08a48c56 100644 --- a/app/src/renderer/vuex/modules/governance/parameters.js +++ b/app/src/renderer/vuex/modules/governance/parameters.js @@ -1,4 +1,4 @@ -import Raven from "raven-js" +import * as Sentry from "@sentry/browser" export default ({ node }) => { const emptyState = { @@ -38,7 +38,7 @@ export default ({ node }) => { title: `Error fetching governance parameters`, body: error.message }) - Raven.captureException(error) + Sentry.captureException(error) state.error = error } state.loading = false diff --git a/app/src/renderer/vuex/modules/governance/proposals.js b/app/src/renderer/vuex/modules/governance/proposals.js index 3b4e43f0a4..89cb95218e 100644 --- a/app/src/renderer/vuex/modules/governance/proposals.js +++ b/app/src/renderer/vuex/modules/governance/proposals.js @@ -1,4 +1,4 @@ -import Raven from "raven-js" +import * as Sentry from "@sentry/browser" import Vue from "vue" export default ({ node }) => { @@ -55,7 +55,7 @@ export default ({ node }) => { title: `Error fetching proposals`, body: error.message }) - Raven.captureException(error) + Sentry.captureException(error) state.error = error } }, @@ -72,7 +72,7 @@ export default ({ node }) => { title: `Error querying proposal with id #${proposal_id}`, body: error.message }) - Raven.captureException(error) + Sentry.captureException(error) state.error = error } }, diff --git a/app/src/renderer/vuex/modules/governance/votes.js b/app/src/renderer/vuex/modules/governance/votes.js index dafbe6bc95..f042bf349d 100644 --- a/app/src/renderer/vuex/modules/governance/votes.js +++ b/app/src/renderer/vuex/modules/governance/votes.js @@ -1,4 +1,4 @@ -import Raven from "raven-js" +import * as Sentry from "@sentry/browser" export default ({ node }) => { const state = { @@ -30,7 +30,7 @@ export default ({ node }) => { title: `Error fetching votes`, body: error.message }) - Raven.captureException(error) + Sentry.captureException(error) state.error = error } }, diff --git a/app/src/renderer/vuex/modules/keybase.js b/app/src/renderer/vuex/modules/keybase.js index 81b7cce736..3e3df26b84 100644 --- a/app/src/renderer/vuex/modules/keybase.js +++ b/app/src/renderer/vuex/modules/keybase.js @@ -1,5 +1,5 @@ import axios from "axios" -import Raven from "raven-js" +import * as Sentry from "@sentry/browser" export default ({}) => { const emptyState = { @@ -60,7 +60,7 @@ export default ({}) => { title: `Error fetching keybase information for validators`, body: error.message }) - Raven.captureException(error) + Sentry.captureException(error) state.error = error } } diff --git a/app/src/renderer/vuex/modules/parameters.js b/app/src/renderer/vuex/modules/parameters.js index f721ad49fa..5f4f51d4da 100644 --- a/app/src/renderer/vuex/modules/parameters.js +++ b/app/src/renderer/vuex/modules/parameters.js @@ -1,4 +1,4 @@ -import Raven from "raven-js" +import * as Sentry from "@sentry/browser" export default ({ node }) => { const emptyState = { @@ -33,7 +33,7 @@ export default ({ node }) => { title: `Error fetching staking parameters`, body: error.message }) - Raven.captureException(error) + Sentry.captureException(error) state.error = error } } diff --git a/app/src/renderer/vuex/modules/pool.js b/app/src/renderer/vuex/modules/pool.js index 2b760e12d4..e3a8880997 100644 --- a/app/src/renderer/vuex/modules/pool.js +++ b/app/src/renderer/vuex/modules/pool.js @@ -1,4 +1,4 @@ -import Raven from "raven-js" +import * as Sentry from "@sentry/browser" export default ({ node }) => { const emptyState = { @@ -37,7 +37,7 @@ export default ({ node }) => { title: `Error fetching staking pool information`, body: error.message }) - Raven.captureException(error) + Sentry.captureException(error) state.error = error } } diff --git a/app/src/renderer/vuex/modules/transactions.js b/app/src/renderer/vuex/modules/transactions.js index eaef890d58..4ba2bf74ee 100644 --- a/app/src/renderer/vuex/modules/transactions.js +++ b/app/src/renderer/vuex/modules/transactions.js @@ -1,6 +1,6 @@ import fp from "lodash/fp" import { uniqBy } from "lodash" -import Raven from "raven-js" +import * as Sentry from "@sentry/browser" export default ({ node }) => { let emptyState = { loading: false, @@ -76,7 +76,7 @@ export default ({ node }) => { title: `Error getting transactions`, body: error.message }) - Raven.captureException(error) + Sentry.captureException(error) state.error = error } }, diff --git a/app/src/renderer/vuex/modules/user.js b/app/src/renderer/vuex/modules/user.js index 506fea0897..4462f7521e 100644 --- a/app/src/renderer/vuex/modules/user.js +++ b/app/src/renderer/vuex/modules/user.js @@ -1,4 +1,4 @@ -import Raven from "raven-js" +import * as Sentry from "@sentry/browser" import { ipcRenderer, remote } from "electron" import enableGoogleAnalytics from "../../google-analytics.js" const config = remote.getGlobal(`config`) @@ -65,7 +65,7 @@ export default ({ node }) => { let keys = await node.keys.values() commit(`setAccounts`, keys) } catch (error) { - Raven.captureException(error) + Sentry.captureException(error) commit(`notifyError`, { title: `Couldn't read keys`, body: error.message @@ -147,12 +147,10 @@ export default ({ node }) => { state.errorCollection ) - Raven.uninstall() - .config(state.errorCollection ? config.sentry_dsn_public : ``) - .install() if (state.errorCollection) { - console.log(`Analytics enabled in browser`) + Sentry.init({ dsn: config.sentry_dsn }) enableGoogleAnalytics(config.google_analytics_uid) + console.log(`Analytics and error reporting have been enabled`) window.analytics && window.analytics.send(`pageview`, { dl: window.location.pathname diff --git a/app/src/renderer/vuex/modules/validators.js b/app/src/renderer/vuex/modules/validators.js index ec6c5204f9..883627e5f4 100644 --- a/app/src/renderer/vuex/modules/validators.js +++ b/app/src/renderer/vuex/modules/validators.js @@ -1,4 +1,4 @@ -import Raven from "raven-js" +import * as Sentry from "@sentry/browser" export default ({ node }) => { const emptyState = { @@ -45,7 +45,7 @@ export default ({ node }) => { title: `Error fetching validator set`, body: error.message }) - Raven.captureException(error) + Sentry.captureException(error) state.error = error } }, diff --git a/app/src/renderer/vuex/modules/wallet.js b/app/src/renderer/vuex/modules/wallet.js index b3a2e07f88..41623fa723 100644 --- a/app/src/renderer/vuex/modules/wallet.js +++ b/app/src/renderer/vuex/modules/wallet.js @@ -1,4 +1,4 @@ -import Raven from "raven-js" +import * as Sentry from "@sentry/browser" import fs from "fs-extra" import { join } from "path" import { remote } from "electron" @@ -83,7 +83,7 @@ export default ({ node }) => { title: `Error fetching balances`, body: error.message }) - Raven.captureException(error) + Sentry.captureException(error) state.error = error } }, @@ -107,7 +107,7 @@ export default ({ node }) => { } if (maxIterations === 0) { const error = new Error(`Couldn't load genesis at path ${genesisPath}`) - Raven.captureException(error) + Sentry.captureException(error) state.error = error return } @@ -145,7 +145,7 @@ export default ({ node }) => { function onTx(error, event) { if (error) { - Raven.captureException(error) + Sentry.captureException(error) console.error(`error subscribing to transactions`, error) return } diff --git a/package.json b/package.json index 049b8cf9ad..8952b9ffb0 100644 --- a/package.json +++ b/package.json @@ -102,6 +102,8 @@ "webpack-dev-server": "2.11.2" }, "dependencies": { + "@sentry/browser": "4.4.1", + "@sentry/node": "4.4.1", "@tendermint/ui": "0.4.3", "@vue/test-utils": "1.0.0-beta.11", "autosize": "4.0.2", @@ -123,8 +125,6 @@ "no-scroll": "2.1.0", "numeral": "2.0.6", "perfect-scrollbar": "1.3.0", - "raven": "2.6.0", - "raven-js": "3.24.2", "semver": "5.5.0", "shortid": "2.2.8", "tendermint": "2.0.5", diff --git a/test/unit/specs/App.spec.js b/test/unit/specs/App.spec.js index 4f91f1f86e..89cc0225f4 100644 --- a/test/unit/specs/App.spec.js +++ b/test/unit/specs/App.spec.js @@ -12,7 +12,7 @@ describe(`App Start`, () => { google_analytics_uid: `123`, sentry_dsn_public: `456` })) - jest.mock(`raven-js`, () => ({ + jest.mock(`@sentry/browser`, () => ({ config: () => { return { install: () => {} } }, @@ -81,8 +81,8 @@ describe(`App Start`, () => { mockDone() }) - it(`does not set Raven dsn if analytics is disabled`, mockDone => { - jest.mock(`raven-js`, () => ({ + it(`does not set Sentry dsn if analytics is disabled`, mockDone => { + jest.mock(`@sentry/browser`, () => ({ config: dsn => { expect(dsn).toBe(``) return { diff --git a/test/unit/specs/main.spec.js b/test/unit/specs/main.spec.js index 672dfec7ee..665f7a066c 100644 --- a/test/unit/specs/main.spec.js +++ b/test/unit/specs/main.spec.js @@ -6,11 +6,11 @@ jest.mock(`readline`, () => ({ }) })) -jest.mock(`raven`, () => ({ - config: () => ({ install: () => {} }), - uninstall: () => ({ config: () => ({ install: () => {} }) }), - captureException: () => {} -})) +// jest.mock(`raven`, () => ({ +// config: () => ({ install: () => {} }), +// uninstall: () => ({ config: () => ({ install: () => {} }) }), +// captureException: () => {} +// })) // prevents warnings from repeated event handling process.setMaxListeners(1000) diff --git a/yarn.lock b/yarn.lock index 8e0d8707cc..5df9e8885c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -39,6 +39,74 @@ node-fetch "^2.1.1" url-template "^2.0.8" +"@sentry/browser@4.4.1": + version "4.4.1" + resolved "https://registry.yarnpkg.com/@sentry/browser/-/browser-4.4.1.tgz#3473ca9e61926c2e896abe84bddfb2651004fb5a" + integrity sha512-P3VoG5tPavva1wqOIeOyOlqyw9+f0Z/OTxLsYgRxHxG7TrDGeZeWPfusI1KaoiK6sDD4FX3PVzfRAXaqa+mE1A== + dependencies: + "@sentry/core" "4.4.1" + "@sentry/types" "4.4.1" + "@sentry/utils" "4.4.1" + tslib "^1.9.3" + +"@sentry/core@4.4.1": + version "4.4.1" + resolved "https://registry.yarnpkg.com/@sentry/core/-/core-4.4.1.tgz#8836813d9d309059913b464cee6d23da09cc4056" + integrity sha512-4sn4Ro7PUpYTkkG4Bn5Q6WytBCOYxpi4vrvOy27EdAGmyjjZ7iRIrkN4q+yhVtu99y+vV6q/0MBfeALc2E6Ckg== + dependencies: + "@sentry/hub" "4.4.1" + "@sentry/minimal" "4.4.1" + "@sentry/types" "4.4.1" + "@sentry/utils" "4.4.1" + tslib "^1.9.3" + +"@sentry/hub@4.4.1": + version "4.4.1" + resolved "https://registry.yarnpkg.com/@sentry/hub/-/hub-4.4.1.tgz#3f82405131bf10ef9e751e2760d63bfff809fa4a" + integrity sha512-fhHIW8KtirG7LAb9V02/IwMfDx7f4CaRDP9kZ7DFjZF2z9RWPCgfn39YoZrAy6r95DaBvNYXABE07ooxn0Tgkw== + dependencies: + "@sentry/types" "4.4.1" + "@sentry/utils" "4.4.1" + tslib "^1.9.3" + +"@sentry/minimal@4.4.1": + version "4.4.1" + resolved "https://registry.yarnpkg.com/@sentry/minimal/-/minimal-4.4.1.tgz#332e97395a20a01e398ae6614a8fb857f2566c31" + integrity sha512-fDQfeHzAvqHHSl/ELWU495khqWaqqF6/pAXsBW2BlGTqO8E4ErOWvayJgkXSWy54NlHg0073aJlwIU+4i2jmtA== + dependencies: + "@sentry/hub" "4.4.1" + "@sentry/types" "4.4.1" + tslib "^1.9.3" + +"@sentry/node@4.4.1": + version "4.4.1" + resolved "https://registry.yarnpkg.com/@sentry/node/-/node-4.4.1.tgz#20cb65307015c8916ad3b3556694adde94104c74" + integrity sha512-qPqF9A5GaAKEMFJRfBPGQ9kyZLXGv2iRhJUbc7DyO7F9LWsIqjokclr2F5qyOFVQAhkv/qLjAE1biVFG8/LwUQ== + dependencies: + "@sentry/core" "4.4.1" + "@sentry/hub" "4.4.1" + "@sentry/types" "4.4.1" + "@sentry/utils" "4.4.1" + "@types/stack-trace" "0.0.29" + cookie "0.3.1" + https-proxy-agent "^2.2.1" + lsmod "1.0.0" + stack-trace "0.0.10" + tslib "^1.9.3" + +"@sentry/types@4.4.1": + version "4.4.1" + resolved "https://registry.yarnpkg.com/@sentry/types/-/types-4.4.1.tgz#d19f9b0450a543aa11b136681ea19612e3cc1611" + integrity sha512-2F/L03X2BpWfTrq+ZrL54Tb+y22Pvq9GYvRKO87Y/02huqHVdDhuIcsBXooOXExkk6T32LFYh/m2CASkLDtkFQ== + +"@sentry/utils@4.4.1": + version "4.4.1" + resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-4.4.1.tgz#cf80fe596d43dc04f51cb780e0cf70017a8c1eb1" + integrity sha512-164oCsQQFbedDd/dgXYiaefmuKZvtzb1vpkjqPUe3LjCmnyziCIhEfC5NiCP1Uk/ViA8PHOK66Kj0TuUjh814A== + dependencies: + "@sentry/types" "4.4.1" + tslib "^1.9.3" + "@tendermint/ui@0.4.3": version "0.4.3" resolved "https://registry.yarnpkg.com/@tendermint/ui/-/ui-0.4.3.tgz#4507a9a3293c97f52d1ccf5cde53f977cdf31dd6" @@ -82,6 +150,11 @@ version "5.5.0" resolved "https://registry.yarnpkg.com/@types/semver/-/semver-5.5.0.tgz#146c2a29ee7d3bae4bf2fcb274636e264c813c45" +"@types/stack-trace@0.0.29": + version "0.0.29" + resolved "https://registry.yarnpkg.com/@types/stack-trace/-/stack-trace-0.0.29.tgz#eb7a7c60098edb35630ed900742a5ecb20cfcb4d" + integrity sha512-TgfOX+mGY/NyNxJLIbDWrO9DjGoVSW9+aB8H2yy1fy32jsvxijhmyJI9fDFgvz3YP4lvJaq9DzdR/M1bOgVc9g== + "@types/strip-bom@^3.0.0": version "3.0.0" resolved "https://registry.yarnpkg.com/@types/strip-bom/-/strip-bom-3.0.0.tgz#14a8ec3956c2e81edb7520790aecf21c290aebd2" @@ -1595,10 +1668,6 @@ chardet@^0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e" -charenc@~0.0.1: - version "0.0.2" - resolved "https://registry.yarnpkg.com/charenc/-/charenc-0.0.2.tgz#c0a1d2f3a7092e03774bfa83f14c0fc5790a8667" - chart.js@2.7.2: version "2.7.2" resolved "https://registry.yarnpkg.com/chart.js/-/chart.js-2.7.2.tgz#3c9fde4dc5b95608211bdefeda7e5d33dffa5714" @@ -2033,10 +2102,6 @@ cross-unzip@0.0.2: version "0.0.2" resolved "https://registry.yarnpkg.com/cross-unzip/-/cross-unzip-0.0.2.tgz#5183bc47a09559befcf98cc4657964999359372f" -crypt@~0.0.1: - version "0.0.2" - resolved "https://registry.yarnpkg.com/crypt/-/crypt-0.0.2.tgz#88d7ff7ec0dfb86f713dc87bbb42d044d3e6c41b" - crypto-browserify@^3.11.0: version "3.12.0" resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.12.0.tgz#396cf9f3137f03e4b8e532c58f698254e00f80ec" @@ -3964,7 +4029,7 @@ https-browserify@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73" -https-proxy-agent@^2.2.0: +https-proxy-agent@^2.2.0, https-proxy-agent@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-2.2.1.tgz#51552970fa04d723e04c56d04178c3f92592bbc0" dependencies: @@ -4182,7 +4247,7 @@ is-binary-path@^1.0.0: dependencies: binary-extensions "^1.0.0" -is-buffer@^1.1.5, is-buffer@~1.1.1: +is-buffer@^1.1.5: version "1.1.6" resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" @@ -5101,6 +5166,11 @@ lru-cache@^4.0.1, lru-cache@^4.1.1, lru-cache@^4.1.2: pseudomap "^1.0.2" yallist "^2.1.2" +lsmod@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/lsmod/-/lsmod-1.0.0.tgz#9a00f76dca36eb23fa05350afe1b585d4299e64b" + integrity sha1-mgD3bco26yP6BTUK/htYXUKZ5ks= + make-dir@^1.0.0: version "1.3.0" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.3.0.tgz#79c1033b80515bd6d24ec9933e860ca75ee27f0c" @@ -5156,14 +5226,6 @@ md5.js@^1.3.4: hash-base "^3.0.0" inherits "^2.0.1" -md5@^2.2.1: - version "2.2.1" - resolved "https://registry.yarnpkg.com/md5/-/md5-2.2.1.tgz#53ab38d5fe3c8891ba465329ea23fac0540126f9" - dependencies: - charenc "~0.0.1" - crypt "~0.0.1" - is-buffer "~1.1.1" - mdurl@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/mdurl/-/mdurl-1.0.1.tgz#fe85b2ec75a59037f2adfec100fd6c601761152e" @@ -6697,20 +6759,6 @@ range-parser@^1.0.3, range-parser@~1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.0.tgz#f49be6b487894ddc40dcc94a322f611092e00d5e" -raven-js@3.24.2: - version "3.24.2" - resolved "https://registry.yarnpkg.com/raven-js/-/raven-js-3.24.2.tgz#c5cacb363b198812e80cd4c6714e5e478549ebcf" - -raven@2.6.0: - version "2.6.0" - resolved "https://registry.yarnpkg.com/raven/-/raven-2.6.0.tgz#3806a82c9ee8cd3e75c3b7ea7bb1935aad092d0c" - dependencies: - cookie "0.3.1" - md5 "^2.2.1" - stack-trace "0.0.10" - timed-out "4.0.1" - uuid "3.0.0" - raw-body@2.3.2: version "2.3.2" resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.3.2.tgz#bcd60c77d3eb93cde0050295c3f379389bc88f89" @@ -7511,6 +7559,7 @@ sshpk@^1.7.0: stack-trace@0.0.10: version "0.0.10" resolved "https://registry.yarnpkg.com/stack-trace/-/stack-trace-0.0.10.tgz#547c70b347e8d32b4e108ea1a2a159e5fdde19c0" + integrity sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA= static-extend@^0.1.1: version "0.1.2" @@ -7932,10 +7981,6 @@ time-stamp@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/time-stamp/-/time-stamp-2.0.0.tgz#95c6a44530e15ba8d6f4a3ecb8c3a3fac46da357" -timed-out@4.0.1: - version "4.0.1" - resolved "https://registry.yarnpkg.com/timed-out/-/timed-out-4.0.1.tgz#f32eacac5a175bea25d7fab565ab3ed8741ef56f" - timers-browserify@^2.0.4: version "2.0.10" resolved "https://registry.yarnpkg.com/timers-browserify/-/timers-browserify-2.0.10.tgz#1d28e3d2aadf1d5a5996c4e9f95601cd053480ae" @@ -8060,7 +8105,7 @@ tsconfig@^7.0.0: strip-bom "^3.0.0" strip-json-comments "^2.0.0" -tslib@^1.9.0: +tslib@^1.9.0, tslib@^1.9.3: version "1.9.3" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286" @@ -8274,10 +8319,6 @@ utils-merge@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" -uuid@3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.0.0.tgz#6728fc0459c450d796a99c31837569bdf672d728" - uuid@^3.0.1, uuid@^3.1.0, uuid@^3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131" From 8c359f2785b4b09139aa0d6dc81a011131a882ee Mon Sep 17 00:00:00 2001 From: Jordan Bibla Date: Mon, 10 Dec 2018 14:36:26 -0500 Subject: [PATCH 2/9] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fed97be0f1..8656b31f85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,6 +78,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - [\#1638](https://github.com/cosmos/voyager/issues/1638) removed account password from the state and now user has to input it on every transaction @fedekunze - [\#1655](https://github.com/cosmos/voyager/issues/1655) Text and Textarea fields trimmed @sabau - [\#1686](https://github.com/cosmos/voyager/issues/1686) Changed proposals from array to object @sabau +- [\#1626](https://github.com/cosmos/voyager/issues/1626) upgraded from raven to sentry/browser @jbibla ### Fixed From bb340feb1bce792efd14031529004fda44786e34 Mon Sep 17 00:00:00 2001 From: Voyager Bot Date: Tue, 11 Dec 2018 16:45:58 +0100 Subject: [PATCH 3/9] linted --- app/src/main/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/index.js b/app/src/main/index.js index 4fe6014e82..a01615389c 100644 --- a/app/src/main/index.js +++ b/app/src/main/index.js @@ -7,7 +7,7 @@ const https = require(`https`) let { join, relative } = require(`path`) let childProcess = require(`child_process`) let semver = require(`semver`) -const Sentry = require("@sentry/node") +const Sentry = require(`@sentry/node`) const readline = require(`readline`) let axios = require(`axios`) @@ -404,7 +404,7 @@ const eventHandlers = { dsn: config.sentry_dsn, release: `voyager@0.8001.1` }) - Sentry.captureException(new Error("Good bye")) + Sentry.captureException(new Error(`Good bye`)) } }, @@ -602,7 +602,7 @@ async function main() { dsn: config.sentry_dsn, release: `voyager@0.8001.1` }) - Sentry.captureException(new Error("TESTING SENTRY")) + Sentry.captureException(new Error(`TESTING SENTRY`)) let appVersionPath = join(root, `app_version`) let genesisPath = join(root, `genesis.json`) From e3690ade27dce7935592cd3c9125c4ae651bda2d Mon Sep 17 00:00:00 2001 From: Voyager Bot Date: Wed, 12 Dec 2018 15:54:29 +0100 Subject: [PATCH 4/9] fixed integration tests --- .../components/common/PagePreferences.vue | 39 +++++----- .../components/common/TmSessionSignUp.vue | 42 +++++------ app/src/renderer/vuex/modules/user.js | 3 +- tasks/test-build.js | 2 +- test/unit/specs/App.spec.js | 16 ++-- .../components/common/PagePreferences.spec.js | 10 ++- .../components/common/TmSessionSignUp.spec.js | 74 ++++++++++++------- .../TmSessionSignUp.spec.js.snap | 9 --- .../store/__snapshots__/user.spec.js.snap | 9 --- test/unit/specs/store/user.spec.js | 31 +++++--- 10 files changed, 124 insertions(+), 111 deletions(-) delete mode 100644 test/unit/specs/store/__snapshots__/user.spec.js.snap diff --git a/app/src/renderer/components/common/PagePreferences.vue b/app/src/renderer/components/common/PagePreferences.vue index 9ddc20ea9d..55ef16c557 100644 --- a/app/src/renderer/components/common/PagePreferences.vue +++ b/app/src/renderer/components/common/PagePreferences.vue @@ -12,7 +12,7 @@ :options="networkSelectOptions" type="select" placeholder="Select network..." - @change.native="setMockedConnector" + @change.native="setMockedConnector()" /> @@ -23,7 +23,7 @@ id="toggle-onboarding" value="Launch Tutorial" icon="open_in_new" - @click.native="setOnboarding" + @click.native="setOnboarding()" /> @@ -50,7 +50,7 @@ icon="exit_to_app" type="button" value="Sign Out" - @click.native="signOut" + @click.native="signOut()" /> @@ -115,33 +115,30 @@ export default { this.themeSelectActive = this.themes.active }, methods: { - signOut() { - this.$store.dispatch(`signOut`) - this.$store.commit(`notifySignOut`) + signOut({ $store } = this) { + $store.dispatch(`signOut`) + $store.commit(`notifySignOut`) }, - setAppTheme() { - if (this.themes.active === `dark`) { - this.$store.commit(`setTheme`, `light`) + setAppTheme({ $store, themes } = this) { + if (themes.active === `dark`) { + $store.commit(`setTheme`, `light`) } else { - this.$store.commit(`setTheme`, `dark`) + $store.commit(`setTheme`, `dark`) } }, - setErrorCollection() { - this.$store.dispatch(`setErrorCollection`, { + setErrorCollection({ $store } = this) { + $store.dispatch(`setErrorCollection`, { account: this.user.account, optin: !this.user.errorCollection }) }, - setOnboarding() { - this.$store.commit(`setOnboardingState`, 0) - this.$store.commit(`setOnboardingActive`, true) + setOnboarding({ $store } = this) { + $store.commit(`setOnboardingState`, 0) + $store.commit(`setOnboardingActive`, true) }, - setMockedConnector() { - this.$store.dispatch( - `setMockedConnector`, - this.networkSelectActive === `mock` - ) + setMockedConnector({ $store, networkSelectActive } = this) { + $store.dispatch(`setMockedConnector`, networkSelectActive === `mock`) } } } diff --git a/app/src/renderer/components/common/TmSessionSignUp.vue b/app/src/renderer/components/common/TmSessionSignUp.vue index 0539f29dd0..44b63b7d03 100644 --- a/app/src/renderer/components/common/TmSessionSignUp.vue +++ b/app/src/renderer/components/common/TmSessionSignUp.vue @@ -6,7 +6,7 @@ >arrow_back
Create Account
- help_outline + help_outline
{ }) } else { console.log(`Analytics disabled in browser`) + Sentry.init({}) window.analytics = null } diff --git a/tasks/test-build.js b/tasks/test-build.js index 015dae2292..9d5153e844 100644 --- a/tasks/test-build.js +++ b/tasks/test-build.js @@ -16,7 +16,7 @@ function test(executablePath) { child.stdout.pipe(process.stdout) child.stdout.on(`data`, async data => { - let msg = new Buffer(data, `utf-8`).toString() + let msg = Buffer.from(data, `utf-8`).toString() if (msg.indexOf(`[START SUCCESS]`) !== -1) { clearTimeout(wait) await cleanExitChild(child) diff --git a/test/unit/specs/App.spec.js b/test/unit/specs/App.spec.js index 89cc0225f4..7b0ef32d88 100644 --- a/test/unit/specs/App.spec.js +++ b/test/unit/specs/App.spec.js @@ -13,9 +13,8 @@ describe(`App Start`, () => { sentry_dsn_public: `456` })) jest.mock(`@sentry/browser`, () => ({ - config: () => { - return { install: () => {} } - }, + init: () => {}, + configureScope: () => {}, captureException: error => mockConsole.error(error) })) jest.mock(`renderer/google-analytics.js`, () => () => {}) @@ -83,14 +82,11 @@ describe(`App Start`, () => { it(`does not set Sentry dsn if analytics is disabled`, mockDone => { jest.mock(`@sentry/browser`, () => ({ - config: dsn => { - expect(dsn).toBe(``) - return { - install: () => { - mockDone() - } - } + init: config => { + expect(config).toEqual({}) + mockDone() }, + configureScope: () => {}, captureException: error => mockConsole.error(error) })) require(`renderer/main.js`) diff --git a/test/unit/specs/components/common/PagePreferences.spec.js b/test/unit/specs/components/common/PagePreferences.spec.js index 88e490ff89..0a3502439d 100644 --- a/test/unit/specs/components/common/PagePreferences.spec.js +++ b/test/unit/specs/components/common/PagePreferences.spec.js @@ -41,12 +41,16 @@ describe(`PagePreferences`, () => { it(`should set the error collection opt in`, async () => { let errorCollection = wrapper.vm.user.errorCollection - wrapper.vm.setErrorCollection() - expect(store.dispatch).toHaveBeenCalledWith(`setErrorCollection`, { + const dispatch = jest.fn() + wrapper.vm.setErrorCollection({ + $store: { + dispatch + } + }) + expect(dispatch).toHaveBeenCalledWith(`setErrorCollection`, { account: `default`, optin: !errorCollection }) - expect(wrapper.vm.user.errorCollection).not.toBe(errorCollection) }) it(`can switch the theme`, () => { diff --git a/test/unit/specs/components/common/TmSessionSignUp.spec.js b/test/unit/specs/components/common/TmSessionSignUp.spec.js index 6d52a5f0c6..3223cfcf4a 100644 --- a/test/unit/specs/components/common/TmSessionSignUp.spec.js +++ b/test/unit/specs/components/common/TmSessionSignUp.spec.js @@ -43,7 +43,16 @@ describe(`NISessionSignUp`, () => { }) it(`should close the modal on successful login`, async () => { - wrapper.setData({ + const commit = jest.fn() + await wrapper.vm.onSubmit({ + $store: { + commit, + dispatch: jest.fn(() => `key`) + }, + $v: { + $touch: () => {}, + $error: false + }, fields: { signUpPassword: `1234567890`, signUpPasswordConfirm: `1234567890`, @@ -52,12 +61,21 @@ describe(`NISessionSignUp`, () => { signUpWarning: true } }) - await wrapper.vm.onSubmit() - expect(store.commit).toHaveBeenCalledWith(`setModalSession`, false) + expect(commit).toHaveBeenCalledWith(`setModalSession`, false) }) it(`should signal signedin state on successful login`, async () => { - wrapper.setData({ + const commit = jest.fn() + const dispatch = jest.fn(() => `key`) + await wrapper.vm.onSubmit({ + $store: { + commit, + dispatch + }, + $v: { + $touch: () => {}, + $error: false + }, fields: { signUpPassword: `1234567890`, signUpPasswordConfirm: `1234567890`, @@ -66,18 +84,25 @@ describe(`NISessionSignUp`, () => { signUpWarning: true } }) - await wrapper.vm.onSubmit() - expect( - store.commit.mock.calls.find(([action]) => action === `notify`)[1] - ).toMatchSnapshot() - expect(store.dispatch).toHaveBeenCalledWith(`signIn`, { + expect(commit).toHaveBeenCalledWith(`notify`, expect.any(Object)) + expect(dispatch).toHaveBeenCalledWith(`signIn`, { password: `1234567890`, account: `testaccount` }) }) it(`should set error collection opt in state`, async () => { - wrapper.setData({ + const commit = jest.fn() + const dispatch = jest.fn(() => `key`) + await wrapper.vm.onSubmit({ + $store: { + commit, + dispatch + }, + $v: { + $touch: () => {}, + $error: false + }, fields: { signUpPassword: `1234567890`, signUpPasswordConfirm: `1234567890`, @@ -87,33 +112,32 @@ describe(`NISessionSignUp`, () => { errorCollection: true } }) - await wrapper.vm.onSubmit() - expect( - store.dispatch.mock.calls.find( - ([action]) => action === `setErrorCollection` - )[1] - ).toMatchObject({ + expect(dispatch).toHaveBeenCalledWith(`setErrorCollection`, { account: `testaccount`, optin: true }) - wrapper.setData({ + dispatch.mockClear() + + await wrapper.vm.onSubmit({ + $store: { + commit, + dispatch + }, + $v: { + $touch: () => {}, + $error: false + }, fields: { signUpPassword: `1234567890`, signUpPasswordConfirm: `1234567890`, signUpSeed: `bar`, // <-- doesn#t check for correctness of seed signUpName: `testaccount`, - signUpWarning: true, + signUpWarning: false, errorCollection: false } }) - store.dispatch.mockClear() - await wrapper.vm.onSubmit() - expect( - store.dispatch.mock.calls.find( - ([action]) => action === `setErrorCollection` - )[1] - ).toMatchObject({ + expect(dispatch).toHaveBeenCalledWith(`setErrorCollection`, { account: `testaccount`, optin: false }) diff --git a/test/unit/specs/components/common/__snapshots__/TmSessionSignUp.spec.js.snap b/test/unit/specs/components/common/__snapshots__/TmSessionSignUp.spec.js.snap index 1fe2973310..1d34b21be2 100644 --- a/test/unit/specs/components/common/__snapshots__/TmSessionSignUp.spec.js.snap +++ b/test/unit/specs/components/common/__snapshots__/TmSessionSignUp.spec.js.snap @@ -99,12 +99,3 @@ exports[`NISessionSignUp has the expected html structure 1`] = `
" `; - -exports[`NISessionSignUp should signal signedin state on successful login 1`] = ` -Object { - "body": "Your account has been created.", - "icon": "check_circle", - "time": 42000, - "title": "Signed Up", -} -`; diff --git a/test/unit/specs/store/__snapshots__/user.spec.js.snap b/test/unit/specs/store/__snapshots__/user.spec.js.snap deleted file mode 100644 index 82aea3170f..0000000000 --- a/test/unit/specs/store/__snapshots__/user.spec.js.snap +++ /dev/null @@ -1,9 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Module: User should set the error collection opt in 1`] = ` -Array [ - Array [ - "https://4dee9f70a7d94cc0959a265c45902d84@sentry.io/288169", - ], -] -`; diff --git a/test/unit/specs/store/user.spec.js b/test/unit/specs/store/user.spec.js index f6dd154e20..d8dc33b01a 100644 --- a/test/unit/specs/store/user.spec.js +++ b/test/unit/specs/store/user.spec.js @@ -5,6 +5,12 @@ function mockGA() { window.analytics = { send: jest.fn() } } jest.mock(`renderer/google-analytics.js`, () => mockGA) +let mockConsole = console // needed to use the console in a mock +jest.mock(`@sentry/browser`, () => ({ + init: () => {}, + configureScope: () => {}, + captureException: error => mockConsole.error(error) +})) let instance = setup() @@ -50,6 +56,7 @@ describe(`Module: User`, () => { }) it(`should show an error if loading accounts fails`, async () => { + jest.spyOn(console, `error`).mockImplementationOnce(() => {}) node.keys.values = () => Promise.reject(`Expected Error`) await store.dispatch(`loadAccounts`) expect(store.state.notifications[0].title).toBe(`Couldn't read keys`) @@ -158,19 +165,21 @@ describe(`Module: User`, () => { }) it(`should set the error collection opt in`, async () => { - const Raven = require(`raven-js`) - const ravenSpy = jest.spyOn(Raven, `config`) - store.dispatch(`setErrorCollection`, { account: `abc`, optin: true }) + const Sentry = require(`@sentry/browser`) + const sentrySpy = jest.spyOn(Sentry, `init`) + await store.dispatch(`setErrorCollection`, { account: `abc`, optin: true }) expect(store.state.user.errorCollection).toBe(true) expect(window.analytics).toBeTruthy() - expect(ravenSpy).toHaveBeenCalled() - expect(ravenSpy).not.toHaveBeenCalledWith(``) - expect(ravenSpy.mock.calls).toMatchSnapshot() + expect(sentrySpy).toHaveBeenCalled() + expect(sentrySpy).toHaveBeenCalledWith({ + dsn: expect.stringMatching(`https://.*@sentry.io/.*`) + }) + sentrySpy.mockClear() store.dispatch(`setErrorCollection`, { account: `abc`, optin: false }) expect(store.state.user.errorCollection).toBe(false) expect(window.analytics).toBeFalsy() - expect(ravenSpy).toHaveBeenCalledWith(``) + expect(sentrySpy).toHaveBeenCalledWith({}) }) it(`should persist the error collection opt in`, () => { @@ -203,8 +212,8 @@ describe(`Module: User`, () => { }) it(`should not set error collection if in development mode`, async () => { - const Raven = require(`raven-js`) - const ravenSpy = jest.spyOn(Raven, `config`) + const Sentry = require(`@sentry/browser`) + const sentrySpy = jest.spyOn(Sentry, `init`) jest.doMock(`electron`, () => ({ ipcRenderer: { send: jest.fn() }, remote: { @@ -225,10 +234,10 @@ describe(`Module: User`, () => { store = test.store node = test.node - ravenSpy.mockClear() + sentrySpy.mockClear() store.dispatch(`setErrorCollection`, { account: `abc`, optin: true }) expect(store.state.user.errorCollection).toBe(false) expect(window.analytics).toBeFalsy() - expect(ravenSpy).not.toHaveBeenCalled() + expect(sentrySpy).not.toHaveBeenCalled() }) }) From fbf00705955c836a43edbc812031faf079d8ee75 Mon Sep 17 00:00:00 2001 From: Voyager Bot Date: Wed, 12 Dec 2018 16:47:49 +0100 Subject: [PATCH 5/9] fixed tests --- app/config.toml | 1 - app/src/main/index.js | 14 ++++++++------ app/src/renderer/main.js | 2 +- app/src/renderer/vuex/modules/user.js | 5 ++++- jest.config.js | 1 + test/unit/helpers/electron_mock.js | 4 ++-- test/unit/helpers/sentry_mock.js | 5 +++++ test/unit/specs/App.spec.js | 12 ++---------- test/unit/specs/main.spec.js | 10 +--------- .../specs/store/__snapshots__/wallet.spec.js.snap | 13 ------------- test/unit/specs/store/user.spec.js | 9 ++------- test/unit/specs/store/wallet.spec.js | 9 +++++---- 12 files changed, 31 insertions(+), 54 deletions(-) create mode 100644 test/unit/helpers/sentry_mock.js diff --git a/app/config.toml b/app/config.toml index afc4cd4c2e..a85c002454 100644 --- a/app/config.toml +++ b/app/config.toml @@ -16,7 +16,6 @@ node_rpc = "http://fabo.interblock.io:26657" google_analytics_uid = "UA-51029217-3" sentry_dsn = "https://4dee9f70a7d94cc0959a265c45902d84:cbf160384aab4cdeafbe9a08dee3b961@sentry.io/288169" -sentry_dsn_public = "https://4dee9f70a7d94cc0959a265c45902d84@sentry.io/288169" # time to wait for a block until node is declared halted node_halted_timeout = 120000 diff --git a/app/src/main/index.js b/app/src/main/index.js index a01615389c..483938c5a0 100644 --- a/app/src/main/index.js +++ b/app/src/main/index.js @@ -11,13 +11,14 @@ const Sentry = require(`@sentry/node`) const readline = require(`readline`) let axios = require(`axios`) -let pkg = require(`../../../package.json`) +let { version: pkgVersion } = require(`../../../package.json`) let addMenu = require(`./menu.js`) let config = require(`../config.js`) config.node_lcd = process.env.LCD_URL || config.node_lcd config.node_rpc = process.env.RPC_URL || config.node_rpc let LcdClient = require(`../renderer/connectors/lcdClient.js`) global.config = config // to make the config accessable from renderer +global.config.version = pkgVersion require(`electron-debug`)() @@ -402,9 +403,10 @@ const eventHandlers = { if (optin) { Sentry.init({ dsn: config.sentry_dsn, - release: `voyager@0.8001.1` + release: `voyager@${pkgVersion}` }) - Sentry.captureException(new Error(`Good bye`)) + } else { + Sentry.init({}) } }, @@ -555,7 +557,7 @@ function checkConsistentConfigDir( ) } else { let existingVersion = fs.readFileSync(appVersionPath, `utf8`).trim() - let semverDiff = semver.diff(existingVersion, pkg.version) + let semverDiff = semver.diff(existingVersion, pkgVersion) let compatible = semverDiff !== `major` && semverDiff !== `minor` if (compatible) { log(`configs are compatible with current app version`) @@ -563,7 +565,7 @@ function checkConsistentConfigDir( // TODO: versions of the app with different data formats will need to learn how to // migrate old data throw Error(`Data was created with an incompatible app version - data=${existingVersion} app=${pkg.version}`) + data=${existingVersion} app=${pkgVersion}`) } } } @@ -657,7 +659,7 @@ async function main() { fs.accessSync(networkPath) // crash if invalid path fs.copySync(networkPath, root) - fs.writeFileSync(appVersionPath, pkg.version) + fs.writeFileSync(appVersionPath, pkgVersion) } await checkGaiaCompatibility(gaiacliVersionPath) diff --git a/app/src/renderer/main.js b/app/src/renderer/main.js index 5a1d848ff3..b7442b03a9 100644 --- a/app/src/renderer/main.js +++ b/app/src/renderer/main.js @@ -5,7 +5,7 @@ import Electron from "vue-electron" import Router from "vue-router" import Tooltip from "vue-directive-tooltip" import Vuelidate from "vuelidate" -import * as Sentry from "@sentry/browser" +import Sentry from "@sentry/browser" import { ipcRenderer, remote } from "electron" import App from "./App" diff --git a/app/src/renderer/vuex/modules/user.js b/app/src/renderer/vuex/modules/user.js index 2b5c638799..48f27d3777 100644 --- a/app/src/renderer/vuex/modules/user.js +++ b/app/src/renderer/vuex/modules/user.js @@ -148,7 +148,10 @@ export default ({ node }) => { ) if (state.errorCollection) { - Sentry.init({ dsn: config.sentry_dsn }) + Sentry.init({ + dsn: config.sentry_dsn, + release: `voyager@${config.version}` + }) enableGoogleAnalytics(config.google_analytics_uid) console.log(`Analytics and error reporting have been enabled`) window.analytics && diff --git a/jest.config.js b/jest.config.js index d10dc82bee..1b9a839c94 100644 --- a/jest.config.js +++ b/jest.config.js @@ -41,6 +41,7 @@ module.exports = { `./test/unit/helpers/console_error_throw.js`, `./test/unit/helpers/genesis_mock.js`, `./test/unit/helpers/electron_mock.js`, + `./test/unit/helpers/sentry_mock.js`, `jest-localstorage-mock` ] } diff --git a/test/unit/helpers/electron_mock.js b/test/unit/helpers/electron_mock.js index 860309290c..12cbe8f844 100644 --- a/test/unit/helpers/electron_mock.js +++ b/test/unit/helpers/electron_mock.js @@ -16,8 +16,8 @@ jest.mock(`electron`, () => ({ return { default_network: `mock-net`, google_analytics_uid: `UA-TEST`, - sentry_dsn: `https://4dee9f70a7d94cc0959a265c45902d84:cbf160384aab4cdeafbe9a08dee3b961@sentry.io/288169`, - sentry_dsn_public: `https://4dee9f70a7d94cc0959a265c45902d84@sentry.io/288169` + sentry_dsn: `https://xx:xx@sentry.io/xx`, + version: `0.0.1` } if (name === `root`) return `./test/unit/tmp/test_root/` }, diff --git a/test/unit/helpers/sentry_mock.js b/test/unit/helpers/sentry_mock.js new file mode 100644 index 0000000000..61a38a0ed8 --- /dev/null +++ b/test/unit/helpers/sentry_mock.js @@ -0,0 +1,5 @@ +jest.mock(`@sentry/browser`, () => ({ + init: () => {}, + configureScope: () => {}, + captureException: () => {} +})) diff --git a/test/unit/specs/App.spec.js b/test/unit/specs/App.spec.js index 7b0ef32d88..7bb0d42a5e 100644 --- a/test/unit/specs/App.spec.js +++ b/test/unit/specs/App.spec.js @@ -5,17 +5,9 @@ jest.mock( () => jest.fn(() => require(`../helpers/node_mock`)) // using jest.fn to be able to spy on the constructor call ) -let mockConsole = console // needed to use the console in a mock - describe(`App Start`, () => { jest.mock(`../../../app/src/config`, () => ({ - google_analytics_uid: `123`, - sentry_dsn_public: `456` - })) - jest.mock(`@sentry/browser`, () => ({ - init: () => {}, - configureScope: () => {}, - captureException: error => mockConsole.error(error) + google_analytics_uid: `123` })) jest.mock(`renderer/google-analytics.js`, () => () => {}) // popper.js is used by tooltips and causes some errors if @@ -87,7 +79,7 @@ describe(`App Start`, () => { mockDone() }, configureScope: () => {}, - captureException: error => mockConsole.error(error) + captureException: () => {} })) require(`renderer/main.js`) }) diff --git a/test/unit/specs/main.spec.js b/test/unit/specs/main.spec.js index 665f7a066c..d08db742f6 100644 --- a/test/unit/specs/main.spec.js +++ b/test/unit/specs/main.spec.js @@ -6,12 +6,6 @@ jest.mock(`readline`, () => ({ }) })) -// jest.mock(`raven`, () => ({ -// config: () => ({ install: () => {} }), -// uninstall: () => ({ config: () => ({ install: () => {} }) }), -// captureException: () => {} -// })) - // prevents warnings from repeated event handling process.setMaxListeners(1000) @@ -667,8 +661,6 @@ function mockConfig() { default_network: `gaia-5001`, mocked: false, - google_analytics_uid: `UA-51029217-3`, - sentry_dsn: `https://abc:def@sentry.io/288169`, - sentry_dsn_public: `https://abc@sentry.io/288169` + google_analytics_uid: `UA-51029217-3` })) } diff --git a/test/unit/specs/store/__snapshots__/wallet.spec.js.snap b/test/unit/specs/store/__snapshots__/wallet.spec.js.snap index d04e501e9d..94235d3358 100644 --- a/test/unit/specs/store/__snapshots__/wallet.spec.js.snap +++ b/test/unit/specs/store/__snapshots__/wallet.spec.js.snap @@ -1,18 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Module: Wallet should handle subscription errors 1`] = ` -Array [ - Array [ - "error subscribing to transactions", - [Error: foo], - ], - Array [ - "error subscribing to transactions", - [Error: foo], - ], -] -`; - exports[`Module: Wallet should have an empty state by default 1`] = ` Object { "address": null, diff --git a/test/unit/specs/store/user.spec.js b/test/unit/specs/store/user.spec.js index d8dc33b01a..f5a76e5f18 100644 --- a/test/unit/specs/store/user.spec.js +++ b/test/unit/specs/store/user.spec.js @@ -5,12 +5,6 @@ function mockGA() { window.analytics = { send: jest.fn() } } jest.mock(`renderer/google-analytics.js`, () => mockGA) -let mockConsole = console // needed to use the console in a mock -jest.mock(`@sentry/browser`, () => ({ - init: () => {}, - configureScope: () => {}, - captureException: error => mockConsole.error(error) -})) let instance = setup() @@ -172,7 +166,8 @@ describe(`Module: User`, () => { expect(window.analytics).toBeTruthy() expect(sentrySpy).toHaveBeenCalled() expect(sentrySpy).toHaveBeenCalledWith({ - dsn: expect.stringMatching(`https://.*@sentry.io/.*`) + dsn: expect.stringMatching(`https://.*@sentry.io/.*`), + release: `voyager@0.0.1` }) sentrySpy.mockClear() diff --git a/test/unit/specs/store/wallet.spec.js b/test/unit/specs/store/wallet.spec.js index 055c4db96c..3dad9ec6d8 100644 --- a/test/unit/specs/store/wallet.spec.js +++ b/test/unit/specs/store/wallet.spec.js @@ -111,7 +111,7 @@ describe(`Module: Wallet`, () => { it(`should throw an error if can't load genesis`, async () => { jest.resetModules() - jest.spyOn(console, `log`) + jest.spyOn(console, `error`).mockImplementationOnce(() => {}) jest.doMock(`fs-extra`, () => ({ pathExists: () => Promise.reject(`didn't found`) })) @@ -120,7 +120,6 @@ describe(`Module: Wallet`, () => { let commit = jest.fn() await actions.loadDenoms({ commit, state, rootState: mockRootState }, 2) expect(state.error).toMatchSnapshot() - console.log.mockReset() }) it(`should query the balances on reconnection`, () => { @@ -175,14 +174,16 @@ describe(`Module: Wallet`, () => { store.state.wallet.address = `x` store.state.wallet.decodedAddress = `x` - console.error = jest.fn() + jest + .spyOn(console, `error`) + .mockImplementationOnce(() => {}) + .mockImplementationOnce(() => {}) node.rpc.subscribe = jest.fn(({}, cb) => { //query is param cb(Error(`foo`)) }) store.dispatch(`walletSubscribe`) - expect(console.error.mock.calls).toMatchSnapshot() }) it(`should query wallet on subscription txs`, async () => { From 37cc16eeaf800f7e8d1eb068ef5e1b2e50820236 Mon Sep 17 00:00:00 2001 From: Voyager Bot Date: Wed, 12 Dec 2018 18:25:39 +0100 Subject: [PATCH 6/9] fixed wallet tests --- .../store/__snapshots__/wallet.spec.js.snap | 29 ------------------- test/unit/specs/store/wallet.spec.js | 3 ++ 2 files changed, 3 insertions(+), 29 deletions(-) diff --git a/test/unit/specs/store/__snapshots__/wallet.spec.js.snap b/test/unit/specs/store/__snapshots__/wallet.spec.js.snap index b862b5814a..94235d3358 100644 --- a/test/unit/specs/store/__snapshots__/wallet.spec.js.snap +++ b/test/unit/specs/store/__snapshots__/wallet.spec.js.snap @@ -1,34 +1,5 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Module: Wallet should handle subscription errors 1`] = ` -Array [ - Array [ - "error subscribing to transactions", - [Error: foo], - ], - Array [ - "error subscribing to transactions", - [Error: foo], - ], - Array [ - "error subscribing to transactions", - [Error: foo], - ], - Array [ - "error subscribing to transactions", - [Error: foo], - ], - Array [ - "error subscribing to transactions", - [Error: foo], - ], - Array [ - "error subscribing to transactions", - [Error: foo], - ], -] -`; - exports[`Module: Wallet should have an empty state by default 1`] = ` Object { "address": null, diff --git a/test/unit/specs/store/wallet.spec.js b/test/unit/specs/store/wallet.spec.js index 3dad9ec6d8..bbfd50743e 100644 --- a/test/unit/specs/store/wallet.spec.js +++ b/test/unit/specs/store/wallet.spec.js @@ -178,6 +178,9 @@ describe(`Module: Wallet`, () => { .spyOn(console, `error`) .mockImplementationOnce(() => {}) .mockImplementationOnce(() => {}) + .mockImplementationOnce(() => {}) + .mockImplementationOnce(() => {}) + .mockImplementationOnce(() => {}) node.rpc.subscribe = jest.fn(({}, cb) => { //query is param cb(Error(`foo`)) From e10d72df317411f7d9a4845199963dcfb853a7eb Mon Sep 17 00:00:00 2001 From: Voyager Bot Date: Thu, 13 Dec 2018 11:11:16 +0100 Subject: [PATCH 7/9] fixed e2e tests --- app/src/renderer/main.js | 2 +- app/src/renderer/vuex/modules/user.js | 2 +- test/unit/helpers/sentry_mock.js | 6 +++--- test/unit/specs/store/user.spec.js | 14 ++++++-------- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/app/src/renderer/main.js b/app/src/renderer/main.js index b7442b03a9..5a1d848ff3 100644 --- a/app/src/renderer/main.js +++ b/app/src/renderer/main.js @@ -5,7 +5,7 @@ import Electron from "vue-electron" import Router from "vue-router" import Tooltip from "vue-directive-tooltip" import Vuelidate from "vuelidate" -import Sentry from "@sentry/browser" +import * as Sentry from "@sentry/browser" import { ipcRenderer, remote } from "electron" import App from "./App" diff --git a/app/src/renderer/vuex/modules/user.js b/app/src/renderer/vuex/modules/user.js index 48f27d3777..162ea728b2 100644 --- a/app/src/renderer/vuex/modules/user.js +++ b/app/src/renderer/vuex/modules/user.js @@ -1,4 +1,4 @@ -import Sentry from "@sentry/browser" +import * as Sentry from "@sentry/browser" import { ipcRenderer, remote } from "electron" import enableGoogleAnalytics from "../../google-analytics.js" const config = remote.getGlobal(`config`) diff --git a/test/unit/helpers/sentry_mock.js b/test/unit/helpers/sentry_mock.js index 61a38a0ed8..d08747ce5e 100644 --- a/test/unit/helpers/sentry_mock.js +++ b/test/unit/helpers/sentry_mock.js @@ -1,5 +1,5 @@ jest.mock(`@sentry/browser`, () => ({ - init: () => {}, - configureScope: () => {}, - captureException: () => {} + init: jest.fn(), + configureScope: jest.fn(), + captureException: jest.fn() })) diff --git a/test/unit/specs/store/user.spec.js b/test/unit/specs/store/user.spec.js index f5a76e5f18..e7aacfd1c0 100644 --- a/test/unit/specs/store/user.spec.js +++ b/test/unit/specs/store/user.spec.js @@ -160,21 +160,20 @@ describe(`Module: User`, () => { it(`should set the error collection opt in`, async () => { const Sentry = require(`@sentry/browser`) - const sentrySpy = jest.spyOn(Sentry, `init`) await store.dispatch(`setErrorCollection`, { account: `abc`, optin: true }) expect(store.state.user.errorCollection).toBe(true) expect(window.analytics).toBeTruthy() - expect(sentrySpy).toHaveBeenCalled() - expect(sentrySpy).toHaveBeenCalledWith({ + expect(Sentry.init).toHaveBeenCalled() + expect(Sentry.init).toHaveBeenCalledWith({ dsn: expect.stringMatching(`https://.*@sentry.io/.*`), release: `voyager@0.0.1` }) - sentrySpy.mockClear() + Sentry.init.mockClear() store.dispatch(`setErrorCollection`, { account: `abc`, optin: false }) expect(store.state.user.errorCollection).toBe(false) expect(window.analytics).toBeFalsy() - expect(sentrySpy).toHaveBeenCalledWith({}) + expect(Sentry.init).toHaveBeenCalledWith({}) }) it(`should persist the error collection opt in`, () => { @@ -208,7 +207,6 @@ describe(`Module: User`, () => { it(`should not set error collection if in development mode`, async () => { const Sentry = require(`@sentry/browser`) - const sentrySpy = jest.spyOn(Sentry, `init`) jest.doMock(`electron`, () => ({ ipcRenderer: { send: jest.fn() }, remote: { @@ -229,10 +227,10 @@ describe(`Module: User`, () => { store = test.store node = test.node - sentrySpy.mockClear() + Sentry.init.mockClear() store.dispatch(`setErrorCollection`, { account: `abc`, optin: true }) expect(store.state.user.errorCollection).toBe(false) expect(window.analytics).toBeFalsy() - expect(sentrySpy).not.toHaveBeenCalled() + expect(Sentry.init).not.toHaveBeenCalled() }) }) From 1a36d17414ee131ea7d372680113b28ed42c01be Mon Sep 17 00:00:00 2001 From: Voyager Bot Date: Thu, 13 Dec 2018 11:19:50 +0100 Subject: [PATCH 8/9] removed forced error --- app/src/main/index.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/src/main/index.js b/app/src/main/index.js index 483938c5a0..68d8500542 100644 --- a/app/src/main/index.js +++ b/app/src/main/index.js @@ -600,11 +600,7 @@ const checkGaiaCompatibility = async gaiacliVersionPath => { async function main() { // Sentry is used for automatic error reporting. It is turned off by default. - Sentry.init({ - dsn: config.sentry_dsn, - release: `voyager@0.8001.1` - }) - Sentry.captureException(new Error(`TESTING SENTRY`)) + Sentry.init({}) let appVersionPath = join(root, `app_version`) let genesisPath = join(root, `genesis.json`) From ebf2c4f1570176290331d058788fff7312569626 Mon Sep 17 00:00:00 2001 From: Voyager Bot Date: Thu, 13 Dec 2018 11:25:47 +0100 Subject: [PATCH 9/9] fixed bug with not being able to signup --- app/src/renderer/components/common/TmSessionSignUp.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/renderer/components/common/TmSessionSignUp.vue b/app/src/renderer/components/common/TmSessionSignUp.vue index 44b63b7d03..90688acba0 100644 --- a/app/src/renderer/components/common/TmSessionSignUp.vue +++ b/app/src/renderer/components/common/TmSessionSignUp.vue @@ -1,6 +1,6 @@