Skip to content

Commit

Permalink
chore: remove sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
iosh committed Aug 21, 2024
1 parent 41acdc3 commit a15f190
Show file tree
Hide file tree
Showing 30 changed files with 245 additions and 420 deletions.
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
"name": "vscode-jest-tests",
"request": "launch",
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
"args": ["--runInBand"],
"args": ["${fileBasenameNoExtension}"],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true
"env": {"NODE_OPTIONS": "--experimental-vm-modules", "NODE_ENV": "test"}
},
{
"type": "pwa-node",
Expand Down
14 changes: 14 additions & 0 deletions .yarn/versions/c0285415.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
releases:
"@fluent-wallet/extension-runtime": patch
"@fluent-wallet/rpc-engine": patch
"@fluent-wallet/use-rpc": patch
"@fluent-wallet/wallet_add-vault": patch
"@fluent-wallet/wallet_handle-unfinished-cfx-tx": patch
"@fluent-wallet/wallet_handle-unfinished-eth-tx": patch
"@fluent-wallet/wallet_refetch-balance": patch
"@fluent-wallet/wallet_set-current-network": patch
browser-extension: patch
helios: patch
helios-background: patch
helios-inpage: patch
helios-popup: patch
1 change: 0 additions & 1 deletion packages/background/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
"@fluent-wallet/net_version": "workspace:packages/rpcs/net_version",
"@fluent-wallet/personal_sign": "workspace:packages/rpcs/personal_sign",
"@fluent-wallet/rpc-engine": "workspace:packages/rpc-engine",
"@fluent-wallet/sentry": "workspace:*",
"@fluent-wallet/transducers": "workspace:packages/transducers",
"@fluent-wallet/txpool_next-nonce": "workspace:*",
"@fluent-wallet/wallet_accounts": "workspace:*",
Expand Down
19 changes: 1 addition & 18 deletions packages/background/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,11 @@ import {EXT_STORAGE} from '@fluent-wallet/consts'

import {defRpcEngine} from '@fluent-wallet/rpc-engine'
import {persist as persistToExtStorageHandler} from './persist-db-to-ext-storage'
import {
Sentry,
init as initSentry,
capture as sentryCapture,
} from '@fluent-wallet/sentry'
import {getDefaultOptions as getSentryDefaultOptions} from '@fluent-wallet/sentry/computeDefaultOptions'

import browser from 'webextension-polyfill'
import SCHEMA from './db-schema'
import {listen} from '@fluent-wallet/extension-runtime/background.js'
import fillInitialDBData from './init-db.js'
import * as bb from '@fluent-wallet/webextension'
import {updateUserId} from '@fluent-wallet/sentry'
import {rpcEngineOpts} from './rpc-engine-opts'

// # setup
Expand All @@ -32,10 +24,6 @@ bb.commands.onCommand.addListener(commandName => {
else window.open(`${location.origin}/popup.html`)
})

// ## sentry
initSentry(getSentryDefaultOptions())
Sentry.setTag('custom_location', 'background')

// ## init db
async function initDB(initDBFn, skipRestore) {
const {createdb} = await import('@fluent-wallet/db')
Expand Down Expand Up @@ -67,8 +55,6 @@ async function initDB(initDBFn, skipRestore) {

// ## init rpc engine
async function initRPCEngine(dbConnection) {
rpcEngineOpts.sentryCapture = sentryCapture

const {request} = defRpcEngine(dbConnection, rpcEngineOpts)
const protectedRequest = (req = {}) =>
request({
Expand Down Expand Up @@ -132,10 +118,7 @@ export const initBG = async ({
// # initialize
;(async () => {
// ## db
const {request, db} = await initBG()

// ## sentry
updateUserId(db.getAddress()?.[0]?.hex)
const {request} = await initBG()

// ## start long running jobs
if (!IS_TEST_MODE) {
Expand Down
13 changes: 2 additions & 11 deletions packages/extension-runtime/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@ import browser from 'webextension-polyfill'
// eslint-disable-next-line no-unused-vars
import {stream, trace} from '@thi.ng/rstream'

import {capture as sentryCaptureError} from '@fluent-wallet/sentry'

function sentryCapturePostMessageeError(err) {
// skip disconnected port error
// these errors indicating bg try to post message to closed popup
if (!err?.message?.includes('disconnected port'))
sentryCaptureError(err, {tags: {custom_type: 'error postMessage'}})
}

const popupStream = stream({
id: 'popup',
closeIn: false,
Expand Down Expand Up @@ -39,10 +30,10 @@ function onConnect(port) {
msg = JSON.parse(JSON.stringify(msg))
port.postMessage(msg)
} catch (err) {
sentryCapturePostMessageeError(err)
console.warn('failed to post message', err)
}
} else {
sentryCapturePostMessageeError(err)
console.warn('failed to post message', err)
}
}
}
Expand Down
1 change: 0 additions & 1 deletion packages/extension-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
"main": "index.js",
"version": "0.0.11",
"dependencies": {
"@fluent-wallet/sentry": "workspace:*",
"@thi.ng/rstream": "6.0.21",
"webextension-polyfill": "0.8.0"
}
Expand Down
1 change: 0 additions & 1 deletion packages/popup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"@fluent-wallet/jazz-icon": "workspace:packages/jazz-icon",
"@fluent-wallet/ledger": "workspace:packages/ledger",
"@fluent-wallet/radio": "workspace:packages/ui/components/Radio",
"@fluent-wallet/sentry": "workspace:*",
"@fluent-wallet/shorten-address": "workspace:packages/ui/shorten-address",
"@fluent-wallet/tx-history-checker": "workspace:*",
"@fluent-wallet/use-rpc": "workspace:packages/ui/useRPC",
Expand Down
8 changes: 0 additions & 8 deletions packages/popup/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ import './i18n.js'
import {SWRConfig} from 'swr'
import {ROUTES} from './constants'
import {IS_PROD_MODE, PACKAGE_VERSION} from '@fluent-wallet/inner-utils'
import {
init as initSentry,
capture as sentryCapture,
} from '@fluent-wallet/sentry'
import {getDefaultOptions} from '@fluent-wallet/sentry/computeDefaultOptions'

initSentry(getDefaultOptions())

const {ERROR} = ROUTES
// import reportWebVitals from './reportWebVitals'
Expand Down Expand Up @@ -76,7 +69,6 @@ ReactDOM.render(
if (error && location) {
if (!IS_PROD_MODE) console.error(error)
const prevPath = window?.location?.hash === '#/' ? 'home' : ''
sentryCapture(error)
location.href = `${location.origin}${
location.pathname
}#${ERROR}?errorMsg=${
Expand Down
2 changes: 1 addition & 1 deletion packages/rpc-engine/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const defRpcEngineFactory = (db, options = {methods: []}) => {
error: rpcErrorHandlerFactory({
isProd,
debugLog: _debugLog,
sentryCapture: options?.sentryCapture || identity,
sentryCapture: identity,
}),
})

Expand Down
10 changes: 1 addition & 9 deletions packages/rpc-engine/middlewares/call-rpc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {defMiddleware} from '../middleware.js'
import {addBreadcrumb} from '@fluent-wallet/sentry'

function formatRes(res, id) {
const template = {id, jsonrpc: '2.0'}
if (res !== undefined) {
Expand All @@ -23,7 +21,6 @@ export default defMiddleware(
req: {stream: '/validateRpcParams/node'},
},
fn: comp(
sideEffect(() => addBreadcrumb({category: 'middleware-beforeCallRpc'})),
map(async ({rpcStore, req, db}) => {
const method = rpcStore[req.method]
// validate dapp permissions to call this rpc
Expand Down Expand Up @@ -90,7 +87,6 @@ export default defMiddleware(
},
},
fn: comp(
sideEffect(() => addBreadcrumb({category: 'middleware-callRpc'})),
map(async ({rpcStore, req}) => ({
req,
res: await rpcStore[req.method].main(req).catch(err => {
Expand All @@ -106,7 +102,6 @@ export default defMiddleware(
ctx: {stream: r => r('/callRpc/node').subscribe(resolve())},
},
fn: comp(
sideEffect(() => addBreadcrumb({category: 'middleware-afterCallRpc'})),
map(({ctx: {req, res}}) => ({
req,
res: formatRes(res, req.id),
Expand All @@ -123,10 +118,7 @@ export default defMiddleware(
res: {stream: '/afterCallRpc/outs/res'},
req: {stream: '/afterCallRpc/outs/req'},
},
fn: comp(
sideEffect(() => addBreadcrumb({category: 'middleware-END'})),
sideEffect(({res, req: {_c}}) => _c.write(res)),
),
fn: comp(sideEffect(({res, req: {_c}}) => _c.write(res))),
},
],
)
Loading

0 comments on commit a15f190

Please sign in to comment.