Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jordan+Fabo/1626 update sentry #1731

Merged
merged 11 commits into from
Dec 13, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
26 changes: 16 additions & 10 deletions app/src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`)

Expand Down Expand Up @@ -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)
}
})

Expand Down Expand Up @@ -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)
})
}
Expand All @@ -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: `[email protected]`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's WIP but I was curious :)
If you want to forget aligning this with package.json we can do something like

import {version} from './package.json';

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea. will fix.

})
.install()
Sentry.captureException(new Error("Good bye"))
}
},

mocked: value => {
Expand Down Expand Up @@ -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: `[email protected]`
})
Sentry.captureException(new Error("TESTING SENTRY"))

let appVersionPath = join(root, `app_version`)
let genesisPath = join(root, `genesis.json`)
Expand Down
17 changes: 11 additions & 6 deletions app/src/renderer/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -21,23 +21,28 @@ 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) => {
console.error(`An error has occurred: ${error}

Guru Meditation #${info}`)

Raven.captureException(error)
Sentry.captureException(error)

if (store.state.devMode) {
throw error
Expand Down
4 changes: 2 additions & 2 deletions app/src/renderer/vuex/modules/blockchain.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Raven from "raven-js"
import * as Sentry from "@sentry/browser"

export default ({ node }) => {
const state = {
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions app/src/renderer/vuex/modules/connection.js
Original file line number Diff line number Diff line change
@@ -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`)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/renderer/vuex/modules/delegates.js
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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 []
Expand Down
4 changes: 2 additions & 2 deletions app/src/renderer/vuex/modules/delegation.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Raven from "raven-js"
import * as Sentry from "@sentry/browser"
import { calculateShares } from "scripts/common"

export default ({ node }) => {
Expand Down Expand Up @@ -149,7 +149,7 @@ export default ({ node }) => {
title: `Error fetching delegations`,
body: error.message
})
Raven.captureException(error)
Sentry.captureException(error)
state.error = error
}

Expand Down
4 changes: 2 additions & 2 deletions app/src/renderer/vuex/modules/governance/deposits.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Raven from "raven-js"
import * as Sentry from "@sentry/browser"

export default ({ node }) => {
const state = {
Expand Down Expand Up @@ -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
}
},
Expand Down
4 changes: 2 additions & 2 deletions app/src/renderer/vuex/modules/governance/parameters.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Raven from "raven-js"
import * as Sentry from "@sentry/browser"

export default ({ node }) => {
const emptyState = {
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions app/src/renderer/vuex/modules/governance/proposals.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Raven from "raven-js"
import * as Sentry from "@sentry/browser"
import Vue from "vue"

export default ({ node }) => {
Expand Down Expand Up @@ -55,7 +55,7 @@ export default ({ node }) => {
title: `Error fetching proposals`,
body: error.message
})
Raven.captureException(error)
Sentry.captureException(error)
state.error = error
}
},
Expand All @@ -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
}
},
Expand Down
4 changes: 2 additions & 2 deletions app/src/renderer/vuex/modules/governance/votes.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Raven from "raven-js"
import * as Sentry from "@sentry/browser"

export default ({ node }) => {
const state = {
Expand Down Expand Up @@ -30,7 +30,7 @@ export default ({ node }) => {
title: `Error fetching votes`,
body: error.message
})
Raven.captureException(error)
Sentry.captureException(error)
state.error = error
}
},
Expand Down
4 changes: 2 additions & 2 deletions app/src/renderer/vuex/modules/keybase.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from "axios"
import Raven from "raven-js"
import * as Sentry from "@sentry/browser"

export default ({}) => {
const emptyState = {
Expand Down Expand Up @@ -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
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/renderer/vuex/modules/parameters.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Raven from "raven-js"
import * as Sentry from "@sentry/browser"

export default ({ node }) => {
const emptyState = {
Expand Down Expand Up @@ -33,7 +33,7 @@ export default ({ node }) => {
title: `Error fetching staking parameters`,
body: error.message
})
Raven.captureException(error)
Sentry.captureException(error)
state.error = error
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/renderer/vuex/modules/pool.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Raven from "raven-js"
import * as Sentry from "@sentry/browser"

export default ({ node }) => {
const emptyState = {
Expand Down Expand Up @@ -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
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/renderer/vuex/modules/transactions.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -76,7 +76,7 @@ export default ({ node }) => {
title: `Error getting transactions`,
body: error.message
})
Raven.captureException(error)
Sentry.captureException(error)
state.error = error
}
},
Expand Down
10 changes: 4 additions & 6 deletions app/src/renderer/vuex/modules/user.js
Original file line number Diff line number Diff line change
@@ -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`)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/src/renderer/vuex/modules/validators.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Raven from "raven-js"
import * as Sentry from "@sentry/browser"

export default ({ node }) => {
const emptyState = {
Expand Down Expand Up @@ -45,7 +45,7 @@ export default ({ node }) => {
title: `Error fetching validator set`,
body: error.message
})
Raven.captureException(error)
Sentry.captureException(error)
state.error = error
}
},
Expand Down
8 changes: 4 additions & 4 deletions app/src/renderer/vuex/modules/wallet.js
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -83,7 +83,7 @@ export default ({ node }) => {
title: `Error fetching balances`,
body: error.message
})
Raven.captureException(error)
Sentry.captureException(error)
state.error = error
}
},
Expand All @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
Loading