diff --git a/.yarn/versions/c0285415.yml b/.yarn/versions/c0285415.yml new file mode 100644 index 000000000..b6809d1a9 --- /dev/null +++ b/.yarn/versions/c0285415.yml @@ -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 diff --git a/packages/background/package.json b/packages/background/package.json index 2300e8565..20d7e6915 100644 --- a/packages/background/package.json +++ b/packages/background/package.json @@ -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:*", diff --git a/packages/background/src/index.js b/packages/background/src/index.js index 0c24a03fa..f7f70aa45 100644 --- a/packages/background/src/index.js +++ b/packages/background/src/index.js @@ -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 @@ -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') @@ -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({ @@ -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) { diff --git a/packages/extension-runtime/background.js b/packages/extension-runtime/background.js index 816634538..3a9df6fae 100644 --- a/packages/extension-runtime/background.js +++ b/packages/extension-runtime/background.js @@ -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, @@ -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) } } } diff --git a/packages/extension-runtime/package.json b/packages/extension-runtime/package.json index 2b95f8523..0b32b908c 100644 --- a/packages/extension-runtime/package.json +++ b/packages/extension-runtime/package.json @@ -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" } diff --git a/packages/popup/package.json b/packages/popup/package.json index 6a8640f33..7a1d58163 100644 --- a/packages/popup/package.json +++ b/packages/popup/package.json @@ -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", diff --git a/packages/popup/src/index.js b/packages/popup/src/index.js index 80127993b..6fd893c9f 100644 --- a/packages/popup/src/index.js +++ b/packages/popup/src/index.js @@ -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' @@ -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=${ diff --git a/packages/rpc-engine/index.js b/packages/rpc-engine/index.js index 509f80d3d..a3caa348a 100644 --- a/packages/rpc-engine/index.js +++ b/packages/rpc-engine/index.js @@ -1,6 +1,6 @@ // # rpc engine import {stream} from '@thi.ng/rstream' -import {partial, identity} from '@fluent-wallet/compose' +import {partial} from '@fluent-wallet/compose' import {chan} from '@fluent-wallet/csp' import {rpcErrorHandlerFactory} from './src/error.js' import * as perms from './src/permissions.js' @@ -69,7 +69,6 @@ const defRpcEngineFactory = (db, options = {methods: []}) => { error: rpcErrorHandlerFactory({ isProd, debugLog: _debugLog, - sentryCapture: options?.sentryCapture || identity, }), }) diff --git a/packages/rpc-engine/middlewares/call-rpc.js b/packages/rpc-engine/middlewares/call-rpc.js index 8264b5ad0..d607d3c50 100644 --- a/packages/rpc-engine/middlewares/call-rpc.js +++ b/packages/rpc-engine/middlewares/call-rpc.js @@ -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) { @@ -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 @@ -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 => { @@ -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), @@ -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))), }, ], ) diff --git a/packages/rpc-engine/middlewares/fetch.js b/packages/rpc-engine/middlewares/fetch.js index 32541f783..06964c5e4 100644 --- a/packages/rpc-engine/middlewares/fetch.js +++ b/packages/rpc-engine/middlewares/fetch.js @@ -5,7 +5,6 @@ import {chan} from '@fluent-wallet/csp' import {init as initCache} from '@fluent-wallet/cache-rpc' import rndId from '@fluent-wallet/random-id' import {REGENERATE} from '@fluent-wallet/consts' -import {addBreadcrumb} from '@fluent-wallet/sentry' const fetcher = initFetcher() @@ -26,111 +25,108 @@ function fetch({id, method, params, jsonrpc, timeout, network: {endpoint}}) { }) } -export default defMiddleware( - ({tx: {map, filter, comp, sideEffect}, stream: {resolve}}) => [ - { - id: 'injectFetchFn', - ins: { - req: {stream: '/injectWalletDB/node'}, - }, - fn: comp( - sideEffect(() => addBreadcrumb({category: 'middleware-injectFetchFn'})), - map(({req}) => ({ - ...req, - f: (...args) => { - let params - let overrides = {} - if (args.length === 1) { - params = args[0] - } else if (args.length === 2) { - params = args[1] - overrides = args[0] - if (overrides.id === REGENERATE) overrides.id = rndId() - } +export default defMiddleware(({tx: {map, filter, comp}, stream: {resolve}}) => [ + { + id: 'injectFetchFn', + ins: { + req: {stream: '/injectWalletDB/node'}, + }, + fn: comp( + map(({req}) => ({ + ...req, + f: (...args) => { + let params + let overrides = {} + if (args.length === 1) { + params = args[0] + } else if (args.length === 2) { + params = args[1] + overrides = args[0] + if (overrides.id === REGENERATE) overrides.id = rndId() + } - return new Promise((resolve, reject) => { - const c = chan(1) - c.onerror = reject - c.read().then(resolve) + return new Promise((resolve, reject) => { + const c = chan(1) + c.onerror = reject + c.read().then(resolve) - s.next({ - ...req, - params, - ...overrides, - jsonrpc: '2.0', - resC: c, - }) + s.next({ + ...req, + params, + ...overrides, + jsonrpc: '2.0', + resC: c, }) - }, - })), - ), - }, + }) + }, + })), + ), + }, - { - id: 'beforeFetch', - ins: { - req: {stream: () => s}, - }, - fn: map(({req, rpcStore}) => { - const {resC, jsonrpc, method} = req - const cache = rpcStore[method].cache + { + id: 'beforeFetch', + ins: { + req: {stream: () => s}, + }, + fn: map(({req, rpcStore}) => { + const {resC, jsonrpc, method} = req + const cache = rpcStore[method].cache - // no cache strategy - if (!cache) return req + // no cache strategy + if (!cache) return req - const c = getCache({req, conf: cache}) + const c = getCache({req, conf: cache}) - // cache found - if (c !== undefined) { - resC.write({result: c, id: req.id, jsonrpc}) - return - } + // cache found + if (c !== undefined) { + resC.write({result: c, id: req.id, jsonrpc}) + return + } - const network = req.network - return {...req, network} - }), + const network = req.network + return {...req, network} + }), + }, + { + id: 'fetchRpc', + ins: { + req: {stream: '/beforeFetch/node'}, }, - { - id: 'fetchRpc', - ins: { - req: {stream: '/beforeFetch/node'}, - }, - fn: comp( - filter(({req}) => Boolean(req)), // filter early resolved request - map(({req}) => - fetch(req) - .then(res => res.json()) - .then(res => ({req, res})) - .catch(err => { - if (req.errorFallThrough) { - req.resC.onerror(err) - return {req} - } - throw err - }), - ), + fn: comp( + filter(({req}) => Boolean(req)), // filter early resolved request + map(({req}) => + fetch(req) + .then(res => res.json()) + .then(res => ({req, res})) + .catch(err => { + if (req.errorFallThrough) { + req.resC.onerror(err) + return {req} + } + throw err + }), ), - }, - { - id: 'afterFetch', - ins: { - ctx: { - stream: r => - r('/fetchRpc/node').subscribe( - resolve({ - fail: function (err) { - if (this?.parent?.error) this.parent.error(err) - else throw err - }, - }), - ), - }, + ), + }, + { + id: 'afterFetch', + ins: { + ctx: { + stream: r => + r('/fetchRpc/node').subscribe( + resolve({ + fail: function (err) { + if (this?.parent?.error) this.parent.error(err) + else throw err + }, + }), + ), }, - fn: map(({ctx: {res, req}, rpcStore}) => { - if (!res) return - setCache({req, res, conf: rpcStore[req.method].cache}) - req.resC.write(res) - }), }, - ], -) + fn: map(({ctx: {res, req}, rpcStore}) => { + if (!res) return + setCache({req, res, conf: rpcStore[req.method].cache}) + req.resC.write(res) + }), + }, +]) diff --git a/packages/rpc-engine/middlewares/inject-rpc-store.js b/packages/rpc-engine/middlewares/inject-rpc-store.js index 408bd7134..dd6cb714c 100644 --- a/packages/rpc-engine/middlewares/inject-rpc-store.js +++ b/packages/rpc-engine/middlewares/inject-rpc-store.js @@ -1,6 +1,5 @@ import {defMiddleware} from '../middleware.js' import {parseError} from '@fluent-wallet/json-rpc-error' -import {addBreadcrumb} from '@fluent-wallet/sentry' function updateReqRpcStack(req) { const {method} = req @@ -85,14 +84,6 @@ export default defMiddleware( ins: {req: {stream: '/validateRpcDataEnd/node'}}, fn: comp( sideEffect(({req}) => updateReqRpcStack(req)), - sideEffect(({req}) => - addBreadcrumb({ - category: 'middleware-injectRpcStore', - data: { - rpcStack: req._rpcStack, - }, - }), - ), map(({sendNewRpcRequest, req, rpcStore}) => ({ ...req, ...rpcStore[req.method], diff --git a/packages/rpc-engine/middlewares/inject-wallet-db.js b/packages/rpc-engine/middlewares/inject-wallet-db.js index 7ca367144..08733a235 100644 --- a/packages/rpc-engine/middlewares/inject-wallet-db.js +++ b/packages/rpc-engine/middlewares/inject-wallet-db.js @@ -1,23 +1,19 @@ import {defMiddleware} from '../middleware.js' -import {addBreadcrumb} from '@fluent-wallet/sentry' -export default defMiddleware( - ({tx: {map, comp, sideEffect}, perms: {getWalletDB}}) => ({ - id: 'injectWalletDB', - ins: { - req: {stream: '/injectRpcStore/node'}, - }, - fn: comp( - sideEffect(() => addBreadcrumb({category: 'middleware-injectWalletDB'})), - map(({req, rpcStore, db}) => { - return { - ...req, - db: - req.method === 'wallet_dbQuery' - ? db - : getWalletDB(rpcStore, db, req.method), - } - }), - ), - }), -) +export default defMiddleware(({tx: {map, comp}, perms: {getWalletDB}}) => ({ + id: 'injectWalletDB', + ins: { + req: {stream: '/injectRpcStore/node'}, + }, + fn: comp( + map(({req, rpcStore, db}) => { + return { + ...req, + db: + req.method === 'wallet_dbQuery' + ? db + : getWalletDB(rpcStore, db, req.method), + } + }), + ), +})) diff --git a/packages/rpc-engine/middlewares/validate-json-rpc-format.js b/packages/rpc-engine/middlewares/validate-json-rpc-format.js index 5e520e128..4fb422bb1 100644 --- a/packages/rpc-engine/middlewares/validate-json-rpc-format.js +++ b/packages/rpc-engine/middlewares/validate-json-rpc-format.js @@ -2,25 +2,12 @@ import {defMiddleware} from '../middleware.js' import {utils as rpcUtils} from '@fluent-wallet/json-rpc' import rndId from '@fluent-wallet/random-id' import * as jsonRpcErr from '@fluent-wallet/json-rpc-error' -import {addBreadcrumb} from '@fluent-wallet/sentry' -export default defMiddleware(({tx: {map, sideEffect, comp}}) => { +export default defMiddleware(({tx: {map, comp}}) => { return { id: 'validateAndFormatJsonRpc', ins: {req: {stream: '/START/node'}}, fn: comp( - sideEffect(({req}) => - addBreadcrumb({ - category: 'middleware-validateAndFormatJsonRpc', - data: { - method: req.method, - rpcStack: req._rpcStack, - internal: req._internal, - popup: req._popup, - inpage: req._inpage, - }, - }), - ), map(({req, MODE}) => { req.jsonrpc = req.jsonrpc || '2.0' req.id = req.id ?? rndId() diff --git a/packages/rpc-engine/middlewares/validate-rpc-data.js b/packages/rpc-engine/middlewares/validate-rpc-data.js index 1fb40a57b..846b6dba2 100644 --- a/packages/rpc-engine/middlewares/validate-rpc-data.js +++ b/packages/rpc-engine/middlewares/validate-rpc-data.js @@ -1,7 +1,6 @@ import {defMiddleware} from '../middleware.js' import EpochRefConf from '@fluent-wallet/rpc-epoch-ref' import * as jsonRpcErr from '@fluent-wallet/json-rpc-error' -import {addBreadcrumb} from '@fluent-wallet/sentry' function transformFakeDbRpcMethods(arg) { const {req} = arg @@ -207,125 +206,75 @@ function formatEpochRef(arg) { return {...arg, req} } -export default defMiddleware( - ({tx: {check, comp, pluck, map, filter, sideEffect}}) => [ - { - id: 'transformFakeDbRpcMethods', - ins: { - req: {stream: '/validateAndFormatJsonRpc/node'}, - }, - fn: comp( - sideEffect(() => - addBreadcrumb({category: 'middleware-transformFakeDbRpcMethods'}), - ), - map(transformFakeDbRpcMethods), - pluck('req'), - ), +export default defMiddleware(({tx: {check, comp, pluck, map, filter}}) => [ + { + id: 'transformFakeDbRpcMethods', + ins: { + req: {stream: '/validateAndFormatJsonRpc/node'}, }, - { - id: 'validateRpcMethod', - ins: { - req: {stream: '/transformFakeDbRpcMethods/node'}, - }, - fn: comp( - sideEffect(() => - addBreadcrumb({category: 'middleware-validateRpcMethod'}), - ), - check(validateRpcMehtod), - pluck('req'), - ), + fn: comp(map(transformFakeDbRpcMethods), pluck('req')), + }, + { + id: 'validateRpcMethod', + ins: { + req: {stream: '/transformFakeDbRpcMethods/node'}, }, - { - id: 'validateExternalMethod', - ins: { - req: {stream: '/validateRpcMethod/node'}, - }, - fn: comp( - sideEffect(() => - addBreadcrumb({category: 'middleware-validateExternalMethod'}), - ), - check(validateExternalMethod), - pluck('req'), - ), + fn: comp(check(validateRpcMehtod), pluck('req')), + }, + { + id: 'validateExternalMethod', + ins: { + req: {stream: '/validateRpcMethod/node'}, }, - { - id: 'validateLockState', - ins: { - req: {stream: '/validateExternalMethod/node'}, - }, - fn: comp( - sideEffect(() => - addBreadcrumb({category: 'middleware-validateLockState'}), - ), - check(validateLockState), - pluck('req'), - ), + fn: comp(check(validateExternalMethod), pluck('req')), + }, + { + id: 'validateLockState', + ins: { + req: {stream: '/validateExternalMethod/node'}, }, - { - id: 'formatRpcSiteAndApp', - ins: { - req: {stream: '/validateLockState/node'}, - }, - fn: comp( - sideEffect(() => - addBreadcrumb({category: 'middleware-formatRpcSiteAndApp'}), - ), - map(formatRpcSiteAndApp), - pluck('req'), - ), + fn: comp(check(validateLockState), pluck('req')), + }, + { + id: 'formatRpcSiteAndApp', + ins: { + req: {stream: '/validateLockState/node'}, }, - { - id: 'formatRpcNetwork', - ins: { - req: {stream: '/formatRpcSiteAndApp/node'}, - }, - fn: comp( - sideEffect(() => - addBreadcrumb({category: 'middleware-formatRpcNetwork'}), - ), - map(formatRpcNetwork), - filter(({req}) => Boolean(req)), - pluck('req'), - ), + fn: comp(map(formatRpcSiteAndApp), pluck('req')), + }, + { + id: 'formatRpcNetwork', + ins: { + req: {stream: '/formatRpcSiteAndApp/node'}, }, - { - id: 'formatEpochRef', - ins: { - req: {stream: '/formatRpcNetwork/node'}, - }, - fn: comp( - sideEffect(() => - addBreadcrumb({category: 'middleware-formatEpochRef'}), - ), - map(formatEpochRef), - pluck('req'), - ), + fn: comp( + map(formatRpcNetwork), + filter(({req}) => Boolean(req)), + pluck('req'), + ), + }, + { + id: 'formatEpochRef', + ins: { + req: {stream: '/formatRpcNetwork/node'}, }, - { - id: 'validateNetworkSupport', - ins: { - req: {stream: '/formatEpochRef/node'}, - }, - fn: comp( - sideEffect(() => - addBreadcrumb({category: 'middleware-validateNetworkSupport'}), - ), - check(validateNetworkSupport), - pluck('req'), - ), + fn: comp(map(formatEpochRef), pluck('req')), + }, + { + id: 'validateNetworkSupport', + ins: { + req: {stream: '/formatEpochRef/node'}, }, - { - id: 'validateRpcDataEnd', - ins: { - req: {stream: '/validateNetworkSupport/node'}, - }, - fn: comp( - sideEffect(() => - addBreadcrumb({category: 'middleware-validateRpcDataEnd'}), - ), - pluck('req'), - filter(req => Boolean(req)), - ), + fn: comp(check(validateNetworkSupport), pluck('req')), + }, + { + id: 'validateRpcDataEnd', + ins: { + req: {stream: '/validateNetworkSupport/node'}, }, - ], -) + fn: comp( + pluck('req'), + filter(req => Boolean(req)), + ), + }, +]) diff --git a/packages/rpc-engine/middlewares/validate-rpc-params.js b/packages/rpc-engine/middlewares/validate-rpc-params.js index f990d6bc6..d07b6257d 100644 --- a/packages/rpc-engine/middlewares/validate-rpc-params.js +++ b/packages/rpc-engine/middlewares/validate-rpc-params.js @@ -1,6 +1,5 @@ import {defMiddleware} from '../middleware.js' import {validate, explain} from '@fluent-wallet/spec' -import {addBreadcrumb} from '@fluent-wallet/sentry' import {isString, isArray} from '@fluent-wallet/checks' const toLowerCaseFields = [ @@ -25,13 +24,12 @@ function preprocessTx(tx) { return tx } -export default defMiddleware(({tx: {map, comp, sideEffect}}) => ({ +export default defMiddleware(({tx: {map, comp}}) => ({ id: 'validateRpcParams', ins: { req: {stream: '/injectFetchFn/node'}, }, fn: comp( - sideEffect(() => addBreadcrumb({category: 'middleware-validateRpcParams'})), map(({rpcStore, req}) => { const {params, method} = req const {schemas, Err} = rpcStore[method] diff --git a/packages/rpc-engine/src/error.js b/packages/rpc-engine/src/error.js index fde9cfea3..e262833b3 100644 --- a/packages/rpc-engine/src/error.js +++ b/packages/rpc-engine/src/error.js @@ -12,14 +12,9 @@ export const appendRpcStackToErrorMessage = (err, stack) => { return err } -export const rpcErrorHandlerFactory = ({ - isProd = true, - debugLog, - sentryCapture = x => x, -} = {}) => { +export const rpcErrorHandlerFactory = ({isProd = true, debugLog} = {}) => { return function (err) { if (!err || !err.message || !err.rpcData || !err.rpcData._c) { - sentryCapture(err) if (!isProd) { console.error( 'DEV_ONLY_ERROR in method: ', diff --git a/packages/rpcs/wallet_addVault/index.js b/packages/rpcs/wallet_addVault/index.js index 66cbf5039..66f6d7ec8 100644 --- a/packages/rpcs/wallet_addVault/index.js +++ b/packages/rpcs/wallet_addVault/index.js @@ -1,4 +1,3 @@ -import {updateUserId, captureMessage} from '@fluent-wallet/sentry' import { stringp, or, @@ -300,7 +299,6 @@ const processAddress = address => { export const main = async arg => { const { db: { - getAddress, createVault, getVault, findGroup, @@ -421,8 +419,6 @@ export const main = async arg => { if (arg.params.waitTillFinish) promises.push(allAccountCreatedChan.read()) return await Promise.all(promises).then(() => { - updateUserId(getAddress()?.[0]?.hex) - if (isFirstGroup) captureMessage('user_created_first_account_group') return groupId }) } diff --git a/packages/rpcs/wallet_addVault/package.json b/packages/rpcs/wallet_addVault/package.json index 40dedaafb..8246f5e76 100644 --- a/packages/rpcs/wallet_addVault/package.json +++ b/packages/rpcs/wallet_addVault/package.json @@ -8,7 +8,6 @@ "@fluent-wallet/base32-address": "workspace:packages/base32-address", "@fluent-wallet/consts": "workspace:packages/consts", "@fluent-wallet/csp": "workspace:*", - "@fluent-wallet/sentry": "workspace:*", "@fluent-wallet/spec": "workspace:packages/spec", "@fluent-wallet/utils": "workspace:packages/utils", "browser-passworder": "^2.0.3" diff --git a/packages/rpcs/wallet_handleUnfinishedCFXTx/index.js b/packages/rpcs/wallet_handleUnfinishedCFXTx/index.js index a9546fad0..361bb3d0d 100644 --- a/packages/rpcs/wallet_handleUnfinishedCFXTx/index.js +++ b/packages/rpcs/wallet_handleUnfinishedCFXTx/index.js @@ -1,6 +1,5 @@ import {mapp} from '@fluent-wallet/spec' import {stream, resolve, CloseMode} from '@thi.ng/rstream' -import {capture as sentryCaptureError} from '@fluent-wallet/sentry' import { sideEffect, map, @@ -217,52 +216,47 @@ export const main = ({ const failed = !sameAsSuccess && shouldDiscard if (errorType === 'unknownError') - sentryCaptureError(err, { - tags: { - custom_type: 'unknown sendTx error', - rpc_network: network.name, - }, + defs({ + failed: failed && {errorType, err}, + sameAsSuccess, + resend: !shouldDiscard && !sameAsSuccess, }) - - defs({ - failed: failed && {errorType, err}, - sameAsSuccess, - resend: !shouldDiscard && !sameAsSuccess, - }) - .transform( - branchObj({ - failed: [ - sideEffect( - ({err}) => - typeof failedCb === 'function' && failedCb(err), - ), - sideEffect(({errorType}) => { - if (setTxFailed({hash, error: errorType})) { - getExt().then(ext => - ext.notifications.create(hash, { - title: 'Failed transaction', - message: `Transaction ${parseInt( - tx.txPayload.nonce, - 16, - )} failed! ${err?.data || err?.message || ''}`, - }), - ) - } - }), - sideEffect(() => { - updateBadge(getUnfinishedTxCount()) - }), - ], - resend: sideEffect(keepTrack), - // retry in next run - sameAsSuccess: [ - sideEffect(() => setTxPending({hash})), - sideEffect(() => typeof okCb === 'function' && okCb(hash)), - sideEffect(keepTrack), - ], - }), - ) - .done() + .transform( + branchObj({ + failed: [ + sideEffect( + ({err}) => + typeof failedCb === 'function' && failedCb(err), + ), + sideEffect(({errorType}) => { + if (setTxFailed({hash, error: errorType})) { + getExt().then(ext => + ext.notifications.create(hash, { + title: 'Failed transaction', + message: `Transaction ${parseInt( + tx.txPayload.nonce, + 16, + )} failed! ${err?.data || err?.message || ''}`, + }), + ) + } + }), + sideEffect(() => { + updateBadge(getUnfinishedTxCount()) + }), + ], + resend: sideEffect(keepTrack), + // retry in next run + sameAsSuccess: [ + sideEffect(() => setTxPending({hash})), + sideEffect( + () => typeof okCb === 'function' && okCb(hash), + ), + sideEffect(keepTrack), + ], + }), + ) + .done() }, }), ) diff --git a/packages/rpcs/wallet_handleUnfinishedCFXTx/package.json b/packages/rpcs/wallet_handleUnfinishedCFXTx/package.json index bd9cf3da2..48266a5c9 100644 --- a/packages/rpcs/wallet_handleUnfinishedCFXTx/package.json +++ b/packages/rpcs/wallet_handleUnfinishedCFXTx/package.json @@ -8,7 +8,6 @@ "@ethersproject/bignumber": "5.6.2", "@fluent-wallet/compose": "workspace:*", "@fluent-wallet/conflux-tx-error": "workspace:*", - "@fluent-wallet/sentry": "workspace:*", "@fluent-wallet/spec": "workspace:*", "@fluent-wallet/transducers": "workspace:*", "@fluent-wallet/webextension": "workspace:*", diff --git a/packages/rpcs/wallet_handleUnfinishedETHTx/index.js b/packages/rpcs/wallet_handleUnfinishedETHTx/index.js index 856272df7..6e75adb2e 100644 --- a/packages/rpcs/wallet_handleUnfinishedETHTx/index.js +++ b/packages/rpcs/wallet_handleUnfinishedETHTx/index.js @@ -1,6 +1,5 @@ import {mapp} from '@fluent-wallet/spec' import {stream, resolve, CloseMode} from '@thi.ng/rstream' -import {capture as sentryCaptureError} from '@fluent-wallet/sentry' import { sideEffect, map, @@ -223,52 +222,47 @@ export const main = ({ !sameAsSuccess && (shouldDiscard || resendPriceTooLow) if (errorType === 'unknownError') - sentryCaptureError(err, { - tags: { - custom_type: 'unknown sendTx error', - rpc_network: network.name, - }, + defs({ + failed: failed && {errorType, err}, + sameAsSuccess, + resend: !shouldDiscard && !sameAsSuccess, }) - - defs({ - failed: failed && {errorType, err}, - sameAsSuccess, - resend: !shouldDiscard && !sameAsSuccess, - }) - .transform( - branchObj({ - failed: [ - sideEffect( - ({err}) => - typeof failedCb === 'function' && failedCb(err), - ), - sideEffect(({errorType}) => { - if (setTxFailed({hash, error: errorType})) { - getExt().then(ext => - ext.notifications.create(hash, { - title: 'Failed transaction', - message: `Transaction ${parseInt( - tx.txPayload.nonce, - 16, - )} failed! ${err?.data || err?.message || ''}`, - }), - ) - } - }), - sideEffect(() => { - updateBadge(getUnfinishedTxCount()) - }), - ], - resend: sideEffect(keepTrack), - // retry in next run - sameAsSuccess: [ - sideEffect(() => setTxPending({hash})), - sideEffect(() => typeof okCb === 'function' && okCb(hash)), - sideEffect(keepTrack), - ], - }), - ) - .done() + .transform( + branchObj({ + failed: [ + sideEffect( + ({err}) => + typeof failedCb === 'function' && failedCb(err), + ), + sideEffect(({errorType}) => { + if (setTxFailed({hash, error: errorType})) { + getExt().then(ext => + ext.notifications.create(hash, { + title: 'Failed transaction', + message: `Transaction ${parseInt( + tx.txPayload.nonce, + 16, + )} failed! ${err?.data || err?.message || ''}`, + }), + ) + } + }), + sideEffect(() => { + updateBadge(getUnfinishedTxCount()) + }), + ], + resend: sideEffect(keepTrack), + // retry in next run + sameAsSuccess: [ + sideEffect(() => setTxPending({hash})), + sideEffect( + () => typeof okCb === 'function' && okCb(hash), + ), + sideEffect(keepTrack), + ], + }), + ) + .done() }, }), ) diff --git a/packages/rpcs/wallet_handleUnfinishedETHTx/package.json b/packages/rpcs/wallet_handleUnfinishedETHTx/package.json index 32e63cdb4..1e1f20817 100644 --- a/packages/rpcs/wallet_handleUnfinishedETHTx/package.json +++ b/packages/rpcs/wallet_handleUnfinishedETHTx/package.json @@ -8,7 +8,6 @@ "@ethersproject/bignumber": "5.6.2", "@fluent-wallet/compose": "workspace:*", "@fluent-wallet/ethereum-tx-error": "workspace:*", - "@fluent-wallet/sentry": "workspace:*", "@fluent-wallet/spec": "workspace:*", "@thi.ng/rstream": "7.2.7" } diff --git a/packages/rpcs/wallet_refetchBalance/index.js b/packages/rpcs/wallet_refetchBalance/index.js index 698b719a7..13675de61 100644 --- a/packages/rpcs/wallet_refetchBalance/index.js +++ b/packages/rpcs/wallet_refetchBalance/index.js @@ -1,5 +1,4 @@ import {or, optParam, enums, map, truep} from '@fluent-wallet/spec' -import {capture as sentryCaptureError} from '@fluent-wallet/sentry' export const NAME = 'wallet_refetchBalance' @@ -55,14 +54,7 @@ export const main = async ({ .then(rst => { return rst && upsertBalances({data: rst, networkId: network.id}) }) - .catch(err => - sentryCaptureError(err, { - tags: { - custom_type: 'error refetch balance', - rpc_network: network?.endpoint, - }, - }), - ), + .catch(err => console.warn('refetchBalance error', err)), ) await Promise.all(promises) diff --git a/packages/rpcs/wallet_refetchBalance/package.json b/packages/rpcs/wallet_refetchBalance/package.json index 9c36bff9f..e25c7e61e 100644 --- a/packages/rpcs/wallet_refetchBalance/package.json +++ b/packages/rpcs/wallet_refetchBalance/package.json @@ -5,7 +5,6 @@ "packageManager": "yarn@3.0.1", "version": "0.0.10", "dependencies": { - "@fluent-wallet/sentry": "workspace:*", "@fluent-wallet/spec": "workspace:packages/spec" } } diff --git a/packages/rpcs/wallet_setCurrentNetwork/index.js b/packages/rpcs/wallet_setCurrentNetwork/index.js index 8c3fe8f55..08bac1125 100644 --- a/packages/rpcs/wallet_setCurrentNetwork/index.js +++ b/packages/rpcs/wallet_setCurrentNetwork/index.js @@ -1,5 +1,4 @@ import {dbid, oneOrMore} from '@fluent-wallet/spec' -import {Sentry} from '@fluent-wallet/sentry' export const NAME = 'wallet_setCurrentNetwork' @@ -79,6 +78,4 @@ export const main = async ({ getConnectedSitesWithoutApps().forEach(site => { site.post({event: 'chainChanged', params: nextNetwork.chainId}) }) - - Sentry.setTag('current_network', nextNetwork.name) } diff --git a/packages/rpcs/wallet_setCurrentNetwork/package.json b/packages/rpcs/wallet_setCurrentNetwork/package.json index 963b83765..53a0fca47 100644 --- a/packages/rpcs/wallet_setCurrentNetwork/package.json +++ b/packages/rpcs/wallet_setCurrentNetwork/package.json @@ -4,7 +4,6 @@ "main": "index.js", "version": "0.0.14", "dependencies": { - "@fluent-wallet/sentry": "workspace:*", "@fluent-wallet/spec": "workspace:packages/spec" } } diff --git a/packages/service-worker/index.ts b/packages/service-worker/index.ts index 6e9ac8fd7..53e08b892 100644 --- a/packages/service-worker/index.ts +++ b/packages/service-worker/index.ts @@ -4,19 +4,13 @@ import {EXT_STORAGE} from '@fluent-wallet/consts' import {isManifestV3} from './env' import {defRpcEngine} from '@fluent-wallet/rpc-engine' import {persist as persistToExtStorageHandler} from '../background/src/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 '../background/src//db-schema' import {listen} from '@fluent-wallet/extension-runtime/background.js' import fillInitialDBData from '../background/src/init-db.js' import * as bb from '@fluent-wallet/webextension' -import {updateUserId} from '@fluent-wallet/sentry' + import {rpcEngineOpts} from '../background/src/rpc-engine-opts' // # setup @@ -31,10 +25,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') @@ -66,7 +56,6 @@ async function initDB(initDBFn, skipRestore) { // ## init rpc engine async function initRPCEngine(dbConnection) { - rpcEngineOpts.sentryCapture = sentryCapture const {request} = defRpcEngine(dbConnection, rpcEngineOpts) const protectedRequest = (req = {} as any) => @@ -138,8 +127,6 @@ function saveTimestamp() { async function initApp() { const {request, db} = await initBG() - // ## sentry - updateUserId(db.getAddress()?.[0]?.hex) // ## start long running jobs if (!IS_TEST_MODE) { diff --git a/yarn.lock b/yarn.lock index 7160a4af4..b15c7020e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4740,7 +4740,6 @@ __metadata: version: 0.0.0-use.local resolution: "@fluent-wallet/extension-runtime@workspace:packages/extension-runtime" dependencies: - "@fluent-wallet/sentry": "workspace:*" "@thi.ng/rstream": 6.0.21 webextension-polyfill: 0.8.0 languageName: unknown @@ -4924,7 +4923,7 @@ __metadata: languageName: unknown linkType: soft -"@fluent-wallet/sentry@workspace:*, @fluent-wallet/sentry@workspace:packages/sentry": +"@fluent-wallet/sentry@workspace:packages/sentry": version: 0.0.0-use.local resolution: "@fluent-wallet/sentry@workspace:packages/sentry" dependencies: @@ -5133,7 +5132,6 @@ __metadata: "@fluent-wallet/base32-address": "workspace:packages/base32-address" "@fluent-wallet/consts": "workspace:packages/consts" "@fluent-wallet/csp": "workspace:*" - "@fluent-wallet/sentry": "workspace:*" "@fluent-wallet/spec": "workspace:packages/spec" "@fluent-wallet/utils": "workspace:packages/utils" browser-passworder: ^2.0.3 @@ -5527,7 +5525,6 @@ __metadata: "@ethersproject/bignumber": 5.6.2 "@fluent-wallet/compose": "workspace:*" "@fluent-wallet/conflux-tx-error": "workspace:*" - "@fluent-wallet/sentry": "workspace:*" "@fluent-wallet/spec": "workspace:*" "@fluent-wallet/transducers": "workspace:*" "@fluent-wallet/webextension": "workspace:*" @@ -5542,7 +5539,6 @@ __metadata: "@ethersproject/bignumber": 5.6.2 "@fluent-wallet/compose": "workspace:*" "@fluent-wallet/ethereum-tx-error": "workspace:*" - "@fluent-wallet/sentry": "workspace:*" "@fluent-wallet/spec": "workspace:*" "@thi.ng/rstream": 7.2.7 languageName: unknown @@ -5633,7 +5629,6 @@ __metadata: version: 0.0.0-use.local resolution: "@fluent-wallet/wallet_refetch-balance@workspace:packages/rpcs/wallet_refetchBalance" dependencies: - "@fluent-wallet/sentry": "workspace:*" "@fluent-wallet/spec": "workspace:packages/spec" languageName: unknown linkType: soft @@ -5744,7 +5739,6 @@ __metadata: version: 0.0.0-use.local resolution: "@fluent-wallet/wallet_set-current-network@workspace:packages/rpcs/wallet_setCurrentNetwork" dependencies: - "@fluent-wallet/sentry": "workspace:*" "@fluent-wallet/spec": "workspace:packages/spec" languageName: unknown linkType: soft @@ -19026,7 +19020,6 @@ __metadata: "@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/test-helpers": "workspace:packages/test-helpers" "@fluent-wallet/transducers": "workspace:packages/transducers" "@fluent-wallet/txpool_next-nonce": "workspace:*" @@ -19165,7 +19158,6 @@ __metadata: "@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"