From 1521bab4c47ff64a3eabf101c491c69c0a3cb7c7 Mon Sep 17 00:00:00 2001 From: Ciaran McGhie Date: Tue, 6 Jun 2023 14:10:03 +0100 Subject: [PATCH] chore(react-helpers,utils,logger): create logger lib and move sentry/logger utils there (#3990) --- .../lib/hooks/use-telemetry-approval.spec.ts | 4 +-- .../lib/hooks/use-telemetry-approval.ts | 2 +- apps/trading/sentry.client.config.js | 2 +- libs/apollo-client/src/lib/apollo-client.ts | 2 +- libs/deposits/src/lib/use-deposit-balances.ts | 3 +- libs/deposits/src/lib/use-get-allowance.ts | 3 +- .../src/lib/use-get-deposit-maximum.ts | 3 +- .../src/lib/use-get-deposited-amount.ts | 3 +- libs/environment/src/hooks/use-releases.ts | 2 +- libs/logger/.babelrc | 12 +++++++ libs/logger/.eslintrc.json | 18 ++++++++++ libs/logger/README.md | 7 ++++ libs/logger/jest.config.ts | 10 ++++++ libs/logger/package.json | 5 +++ libs/logger/project.json | 34 +++++++++++++++++++ libs/logger/src/hooks/index.ts | 1 + .../src/hooks/use-logger.ts | 5 +-- libs/logger/src/index.ts | 2 ++ libs/logger/src/lib/index.ts | 2 ++ .../src/lib/local-logger.spec.ts | 0 .../{utils => logger}/src/lib/local-logger.ts | 0 .../src/lib/sentry-utils.spec.ts | 0 .../{utils => logger}/src/lib/sentry-utils.ts | 0 libs/logger/tsconfig.json | 23 +++++++++++++ libs/logger/tsconfig.lib.json | 10 ++++++ libs/logger/tsconfig.spec.json | 20 +++++++++++ libs/react-helpers/.eslintrc.json | 24 ++++++++----- libs/react-helpers/src/hooks/index.ts | 1 - .../src/hooks/use-mutation-observer.ts | 7 +--- .../src/hooks/use-resize-observer.ts | 7 +--- libs/ui-toolkit/.eslintrc.json | 10 +++++- libs/utils/.eslintrc.json | 24 ++++++++----- libs/utils/src/index.ts | 2 -- libs/web3/src/lib/use-eager-connect.ts | 7 ++-- ...se-ethereum-withdraw-approvals-manager.tsx | 2 +- libs/web3/src/lib/use-get-withdraw-delay.ts | 2 +- .../src/lib/use-complete-withdraw.ts | 2 +- .../src/lib/use-verify-withdrawal.ts | 3 +- libs/withdraws/src/lib/use-withdraw-asset.tsx | 3 +- tsconfig.base.json | 1 + workspace.json | 1 + 41 files changed, 215 insertions(+), 54 deletions(-) create mode 100644 libs/logger/.babelrc create mode 100644 libs/logger/.eslintrc.json create mode 100644 libs/logger/README.md create mode 100644 libs/logger/jest.config.ts create mode 100644 libs/logger/package.json create mode 100644 libs/logger/project.json create mode 100644 libs/logger/src/hooks/index.ts rename libs/{react-helpers => logger}/src/hooks/use-logger.ts (68%) create mode 100644 libs/logger/src/index.ts create mode 100644 libs/logger/src/lib/index.ts rename libs/{utils => logger}/src/lib/local-logger.spec.ts (100%) rename libs/{utils => logger}/src/lib/local-logger.ts (100%) rename libs/{utils => logger}/src/lib/sentry-utils.spec.ts (100%) rename libs/{utils => logger}/src/lib/sentry-utils.ts (100%) create mode 100644 libs/logger/tsconfig.json create mode 100644 libs/logger/tsconfig.lib.json create mode 100644 libs/logger/tsconfig.spec.json diff --git a/apps/trading/lib/hooks/use-telemetry-approval.spec.ts b/apps/trading/lib/hooks/use-telemetry-approval.spec.ts index 6a4c9f00d..97ec110d6 100644 --- a/apps/trading/lib/hooks/use-telemetry-approval.spec.ts +++ b/apps/trading/lib/hooks/use-telemetry-approval.spec.ts @@ -1,11 +1,11 @@ import { renderHook, act, waitFor } from '@testing-library/react'; import { useLocalStorage } from '@vegaprotocol/react-helpers'; -import { SentryInit, SentryClose } from '@vegaprotocol/utils'; +import { SentryInit, SentryClose } from '@vegaprotocol/logger'; import { STORAGE_KEY, useTelemetryApproval } from './use-telemetry-approval'; const mockSetValue = jest.fn(); const mockRemoveValue = jest.fn(); -jest.mock('@vegaprotocol/utils'); +jest.mock('@vegaprotocol/logger'); jest.mock('@vegaprotocol/react-helpers', () => ({ ...jest.requireActual('@vegaprotocol/react-helpers'), useLocalStorage: jest diff --git a/apps/trading/lib/hooks/use-telemetry-approval.ts b/apps/trading/lib/hooks/use-telemetry-approval.ts index 21e6a2469..d469e58ac 100644 --- a/apps/trading/lib/hooks/use-telemetry-approval.ts +++ b/apps/trading/lib/hooks/use-telemetry-approval.ts @@ -1,6 +1,6 @@ import { useLocalStorage } from '@vegaprotocol/react-helpers'; import { useCallback } from 'react'; -import { SentryInit, SentryClose } from '@vegaprotocol/utils'; +import { SentryInit, SentryClose } from '@vegaprotocol/logger'; import { ENV } from '../config'; export const STORAGE_KEY = 'vega_telemetry_approval'; diff --git a/apps/trading/sentry.client.config.js b/apps/trading/sentry.client.config.js index 7b5a79bb5..9ecc813be 100644 --- a/apps/trading/sentry.client.config.js +++ b/apps/trading/sentry.client.config.js @@ -1,5 +1,5 @@ import { ENV } from './lib/config/env'; -import { LocalStorage, SentryInit } from '@vegaprotocol/utils'; +import { LocalStorage, SentryInit } from '@vegaprotocol/logger'; import { STORAGE_KEY } from './lib/hooks/use-telemetry-approval'; const { dsn, envName } = ENV; diff --git a/libs/apollo-client/src/lib/apollo-client.ts b/libs/apollo-client/src/lib/apollo-client.ts index 0aac83e8e..c812ab472 100644 --- a/libs/apollo-client/src/lib/apollo-client.ts +++ b/libs/apollo-client/src/lib/apollo-client.ts @@ -13,7 +13,7 @@ import { createClient as createWSClient } from 'graphql-ws'; import { onError } from '@apollo/client/link/error'; import { RetryLink } from '@apollo/client/link/retry'; import ApolloLinkTimeout from 'apollo-link-timeout'; -import { localLoggerFactory } from '@vegaprotocol/utils'; +import { localLoggerFactory } from '@vegaprotocol/logger'; import { useHeaderStore } from './header-store'; const isBrowser = typeof window !== 'undefined'; diff --git a/libs/deposits/src/lib/use-deposit-balances.ts b/libs/deposits/src/lib/use-deposit-balances.ts index e8bb31c8c..8ceb02b17 100644 --- a/libs/deposits/src/lib/use-deposit-balances.ts +++ b/libs/deposits/src/lib/use-deposit-balances.ts @@ -8,7 +8,8 @@ import { useIsExemptDepositor, } from './use-get-deposit-maximum'; import { useGetDepositedAmount } from './use-get-deposited-amount'; -import { isAssetTypeERC20, localLoggerFactory } from '@vegaprotocol/utils'; +import { isAssetTypeERC20 } from '@vegaprotocol/utils'; +import { localLoggerFactory } from '@vegaprotocol/logger'; import { useAccountBalance } from '@vegaprotocol/accounts'; import type { Asset } from '@vegaprotocol/assets'; import { useWeb3React } from '@web3-react/core'; diff --git a/libs/deposits/src/lib/use-get-allowance.ts b/libs/deposits/src/lib/use-get-allowance.ts index 53548a55b..dd6ffa07e 100644 --- a/libs/deposits/src/lib/use-get-allowance.ts +++ b/libs/deposits/src/lib/use-get-allowance.ts @@ -4,7 +4,8 @@ import { useCallback } from 'react'; import { useEthereumConfig } from '@vegaprotocol/web3'; import BigNumber from 'bignumber.js'; import type { Asset } from '@vegaprotocol/assets'; -import { addDecimal, localLoggerFactory } from '@vegaprotocol/utils'; +import { addDecimal } from '@vegaprotocol/utils'; +import { localLoggerFactory } from '@vegaprotocol/logger'; export const useGetAllowance = ( contract: Token | null, diff --git a/libs/deposits/src/lib/use-get-deposit-maximum.ts b/libs/deposits/src/lib/use-get-deposit-maximum.ts index 7aa027e09..d680a3ad8 100644 --- a/libs/deposits/src/lib/use-get-deposit-maximum.ts +++ b/libs/deposits/src/lib/use-get-deposit-maximum.ts @@ -1,7 +1,8 @@ import { useCallback } from 'react'; import BigNumber from 'bignumber.js'; import type { Asset } from '@vegaprotocol/assets'; -import { addDecimal, localLoggerFactory } from '@vegaprotocol/utils'; +import { addDecimal } from '@vegaprotocol/utils'; +import { localLoggerFactory } from '@vegaprotocol/logger'; import type { CollateralBridge } from '@vegaprotocol/smart-contracts'; export const useGetDepositMaximum = ( diff --git a/libs/deposits/src/lib/use-get-deposited-amount.ts b/libs/deposits/src/lib/use-get-deposited-amount.ts index d8814b91a..5edea56a9 100644 --- a/libs/deposits/src/lib/use-get-deposited-amount.ts +++ b/libs/deposits/src/lib/use-get-deposited-amount.ts @@ -3,7 +3,8 @@ import { ethers } from 'ethers'; import { useEthereumConfig } from '@vegaprotocol/web3'; import BigNumber from 'bignumber.js'; import type { Asset } from '@vegaprotocol/assets'; -import { addDecimal, localLoggerFactory } from '@vegaprotocol/utils'; +import { addDecimal } from '@vegaprotocol/utils'; +import { localLoggerFactory } from '@vegaprotocol/logger'; import { useWeb3React } from '@web3-react/core'; export const useGetDepositedAmount = (asset: Asset | undefined) => { diff --git a/libs/environment/src/hooks/use-releases.ts b/libs/environment/src/hooks/use-releases.ts index bb10de383..6d5ffc701 100644 --- a/libs/environment/src/hooks/use-releases.ts +++ b/libs/environment/src/hooks/use-releases.ts @@ -1,4 +1,4 @@ -import { localLoggerFactory } from '@vegaprotocol/utils'; +import { localLoggerFactory } from '@vegaprotocol/logger'; import { useCallback, useEffect, useState } from 'react'; import z from 'zod'; diff --git a/libs/logger/.babelrc b/libs/logger/.babelrc new file mode 100644 index 000000000..ccae900be --- /dev/null +++ b/libs/logger/.babelrc @@ -0,0 +1,12 @@ +{ + "presets": [ + [ + "@nrwl/react/babel", + { + "runtime": "automatic", + "useBuiltIns": "usage" + } + ] + ], + "plugins": [] +} diff --git a/libs/logger/.eslintrc.json b/libs/logger/.eslintrc.json new file mode 100644 index 000000000..734ddacee --- /dev/null +++ b/libs/logger/.eslintrc.json @@ -0,0 +1,18 @@ +{ + "extends": ["plugin:@nrwl/nx/react", "../../.eslintrc.json"], + "ignorePatterns": ["!**/*"], + "overrides": [ + { + "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], + "rules": {} + }, + { + "files": ["*.ts", "*.tsx"], + "rules": {} + }, + { + "files": ["*.js", "*.jsx"], + "rules": {} + } + ] +} diff --git a/libs/logger/README.md b/libs/logger/README.md new file mode 100644 index 000000000..116bb4a11 --- /dev/null +++ b/libs/logger/README.md @@ -0,0 +1,7 @@ +# logger + +This library was generated with [Nx](https://nx.dev). + +## Running unit tests + +Run `nx test logger` to execute the unit tests via [Jest](https://jestjs.io). diff --git a/libs/logger/jest.config.ts b/libs/logger/jest.config.ts new file mode 100644 index 000000000..08ccc7749 --- /dev/null +++ b/libs/logger/jest.config.ts @@ -0,0 +1,10 @@ +/* eslint-disable */ +export default { + displayName: 'logger', + preset: '../../jest.preset.js', + transform: { + '^.+\\.[tj]sx?$': 'babel-jest', + }, + moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'], + coverageDirectory: '../../coverage/libs/logger', +}; diff --git a/libs/logger/package.json b/libs/logger/package.json new file mode 100644 index 000000000..52aafb7dd --- /dev/null +++ b/libs/logger/package.json @@ -0,0 +1,5 @@ +{ + "name": "@vegaprotocol/logger", + "version": "0.0.1", + "type": "commonjs" +} diff --git a/libs/logger/project.json b/libs/logger/project.json new file mode 100644 index 000000000..8a501a8ea --- /dev/null +++ b/libs/logger/project.json @@ -0,0 +1,34 @@ +{ + "$schema": "../../node_modules/nx/schemas/project-schema.json", + "sourceRoot": "libs/logger/src", + "projectType": "library", + "tags": [], + "targets": { + "build": { + "executor": "@nrwl/js:tsc", + "outputs": ["{options.outputPath}"], + "format": ["esm", "cjs"], + "options": { + "outputPath": "dist/libs/logger", + "main": "libs/logger/src/index.ts", + "tsConfig": "libs/logger/tsconfig.lib.json", + "assets": ["libs/logger/*.md"] + } + }, + "lint": { + "executor": "@nrwl/linter:eslint", + "outputs": ["{options.outputFile}"], + "options": { + "lintFilePatterns": ["libs/logger/**/*.{ts,tsx,js,jsx}"] + } + }, + "test": { + "executor": "@nrwl/jest:jest", + "outputs": ["coverage/libs/logger"], + "options": { + "jestConfig": "libs/logger/jest.config.ts", + "passWithNoTests": true + } + } + } +} diff --git a/libs/logger/src/hooks/index.ts b/libs/logger/src/hooks/index.ts new file mode 100644 index 000000000..bb4bdc019 --- /dev/null +++ b/libs/logger/src/hooks/index.ts @@ -0,0 +1 @@ +export * from './use-logger'; diff --git a/libs/react-helpers/src/hooks/use-logger.ts b/libs/logger/src/hooks/use-logger.ts similarity index 68% rename from libs/react-helpers/src/hooks/use-logger.ts rename to libs/logger/src/hooks/use-logger.ts index 759d3f3b8..e4837d579 100644 --- a/libs/react-helpers/src/hooks/use-logger.ts +++ b/libs/logger/src/hooks/use-logger.ts @@ -1,6 +1,7 @@ import { useRef } from 'react'; -import type { LocalLogger, LoggerConf } from '@vegaprotocol/utils'; -import { localLoggerFactory, SentryInit } from '@vegaprotocol/utils'; +import type { LocalLogger, LoggerConf } from '../lib/local-logger'; +import { localLoggerFactory } from '../lib/local-logger'; +import { SentryInit } from '../lib/sentry-utils'; export interface LoggerProps extends LoggerConf { dsn?: string; diff --git a/libs/logger/src/index.ts b/libs/logger/src/index.ts new file mode 100644 index 000000000..6a96501a1 --- /dev/null +++ b/libs/logger/src/index.ts @@ -0,0 +1,2 @@ +export * from './lib'; +export * from './hooks'; diff --git a/libs/logger/src/lib/index.ts b/libs/logger/src/lib/index.ts new file mode 100644 index 000000000..8c93e3456 --- /dev/null +++ b/libs/logger/src/lib/index.ts @@ -0,0 +1,2 @@ +export * from './local-logger'; +export * from './sentry-utils'; diff --git a/libs/utils/src/lib/local-logger.spec.ts b/libs/logger/src/lib/local-logger.spec.ts similarity index 100% rename from libs/utils/src/lib/local-logger.spec.ts rename to libs/logger/src/lib/local-logger.spec.ts diff --git a/libs/utils/src/lib/local-logger.ts b/libs/logger/src/lib/local-logger.ts similarity index 100% rename from libs/utils/src/lib/local-logger.ts rename to libs/logger/src/lib/local-logger.ts diff --git a/libs/utils/src/lib/sentry-utils.spec.ts b/libs/logger/src/lib/sentry-utils.spec.ts similarity index 100% rename from libs/utils/src/lib/sentry-utils.spec.ts rename to libs/logger/src/lib/sentry-utils.spec.ts diff --git a/libs/utils/src/lib/sentry-utils.ts b/libs/logger/src/lib/sentry-utils.ts similarity index 100% rename from libs/utils/src/lib/sentry-utils.ts rename to libs/logger/src/lib/sentry-utils.ts diff --git a/libs/logger/tsconfig.json b/libs/logger/tsconfig.json new file mode 100644 index 000000000..e302a4d20 --- /dev/null +++ b/libs/logger/tsconfig.json @@ -0,0 +1,23 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "module": "commonjs", + "forceConsistentCasingInFileNames": true, + "strict": true, + "noImplicitOverride": true, + "noPropertyAccessFromIndexSignature": false, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + "esModuleInterop": true + }, + "files": [], + "include": [], + "references": [ + { + "path": "./tsconfig.lib.json" + }, + { + "path": "./tsconfig.spec.json" + } + ] +} diff --git a/libs/logger/tsconfig.lib.json b/libs/logger/tsconfig.lib.json new file mode 100644 index 000000000..e85ef50f6 --- /dev/null +++ b/libs/logger/tsconfig.lib.json @@ -0,0 +1,10 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "declaration": true, + "types": [] + }, + "include": ["**/*.ts"], + "exclude": ["jest.config.ts", "**/*.spec.ts", "**/*.test.ts"] +} diff --git a/libs/logger/tsconfig.spec.json b/libs/logger/tsconfig.spec.json new file mode 100644 index 000000000..ff08addd6 --- /dev/null +++ b/libs/logger/tsconfig.spec.json @@ -0,0 +1,20 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "outDir": "../../dist/out-tsc", + "module": "commonjs", + "types": ["jest", "node"] + }, + "include": [ + "jest.config.ts", + "**/*.test.ts", + "**/*.spec.ts", + "**/*.test.tsx", + "**/*.spec.tsx", + "**/*.test.js", + "**/*.spec.js", + "**/*.test.jsx", + "**/*.spec.jsx", + "**/*.d.ts" + ] +} diff --git a/libs/react-helpers/.eslintrc.json b/libs/react-helpers/.eslintrc.json index 04cd72d3c..25ff9d375 100644 --- a/libs/react-helpers/.eslintrc.json +++ b/libs/react-helpers/.eslintrc.json @@ -7,15 +7,21 @@ "rules": { "no-restricted-imports": [ "error", - "@apollo/client", - "@vegaprotocol/data-provider", - "ag-grid-react", - "ag-grid-community", - "graphql", - "graphql-tag", - "graphql-ws", - "ethers", - "@ethersproject" + { + "paths": [ + "error", + "@apollo/client", + "@vegaprotocol/data-provider", + "ag-grid-react", + "ag-grid-community", + "graphql", + "graphql-tag", + "graphql-ws", + "ethers", + "@ethersproject" + ], + "patterns": ["@sentry/*"] + } ] } }, diff --git a/libs/react-helpers/src/hooks/index.ts b/libs/react-helpers/src/hooks/index.ts index f9b9e40c3..d63e0d6b8 100644 --- a/libs/react-helpers/src/hooks/index.ts +++ b/libs/react-helpers/src/hooks/index.ts @@ -11,6 +11,5 @@ export * from './use-theme-switcher'; export * from './use-storybook-theme-observer'; export * from './use-yesterday'; export * from './use-previous'; -export * from './use-logger'; export * from './use-pane-layout'; export * from './use-copy-timeout'; diff --git a/libs/react-helpers/src/hooks/use-mutation-observer.ts b/libs/react-helpers/src/hooks/use-mutation-observer.ts index d2c93ccde..b423aa634 100644 --- a/libs/react-helpers/src/hooks/use-mutation-observer.ts +++ b/libs/react-helpers/src/hooks/use-mutation-observer.ts @@ -1,4 +1,3 @@ -import { captureException } from '@sentry/react'; import debounce from 'lodash/debounce'; import { useEffect, useMemo } from 'react'; @@ -31,11 +30,7 @@ export function useMutationObserver( useEffect(() => { if (!observer || !target) return; - try { - observer.observe(target, options.config); - } catch (err) { - captureException(err); - } + observer.observe(target, options.config); return () => observer?.disconnect(); }, [observer, options.config, target]); } diff --git a/libs/react-helpers/src/hooks/use-resize-observer.ts b/libs/react-helpers/src/hooks/use-resize-observer.ts index 6e2c510f2..a7b7fe672 100644 --- a/libs/react-helpers/src/hooks/use-resize-observer.ts +++ b/libs/react-helpers/src/hooks/use-resize-observer.ts @@ -1,6 +1,5 @@ import debounce from 'lodash/debounce'; import { useCallback, useEffect, useMemo } from 'react'; -import { localLoggerFactory } from '@vegaprotocol/utils'; type ResizeObserverConfiguration = { debounceTime: number; @@ -35,11 +34,7 @@ export function useResizeObserver( useEffect(() => { if (!observer || !target) return; - try { - observer.observe(target, options.config); - } catch (err) { - localLoggerFactory({ application: 'react-helpers' }).debug(err as Error); - } + observer.observe(target, options.config); return () => observer?.disconnect(); }, [observer, options.config, target]); } diff --git a/libs/ui-toolkit/.eslintrc.json b/libs/ui-toolkit/.eslintrc.json index 734ddacee..f889a206a 100644 --- a/libs/ui-toolkit/.eslintrc.json +++ b/libs/ui-toolkit/.eslintrc.json @@ -4,7 +4,15 @@ "overrides": [ { "files": ["*.ts", "*.tsx", "*.js", "*.jsx"], - "rules": {} + "rules": { + "no-restricted-imports": [ + "error", + { + "paths": [], + "patterns": ["@sentry/*"] + } + ] + } }, { "files": ["*.ts", "*.tsx"], diff --git a/libs/utils/.eslintrc.json b/libs/utils/.eslintrc.json index ee1206a44..e8c3634b5 100644 --- a/libs/utils/.eslintrc.json +++ b/libs/utils/.eslintrc.json @@ -7,15 +7,21 @@ "rules": { "no-restricted-imports": [ "error", - "@apollo/client", - "@vegaprotocol/data-provider", - "ag-grid-react", - "ag-grid-community", - "graphql", - "graphql-tag", - "graphql-ws", - "ethers", - "@ethersproject" + { + "paths": [ + "error", + "@apollo/client", + "@vegaprotocol/data-provider", + "ag-grid-react", + "ag-grid-community", + "graphql", + "graphql-tag", + "graphql-ws", + "ethers", + "@ethersproject" + ], + "patterns": ["@sentry/*"] + } ] } }, diff --git a/libs/utils/src/index.ts b/libs/utils/src/index.ts index 3d7927235..d260e0cff 100644 --- a/libs/utils/src/index.ts +++ b/libs/utils/src/index.ts @@ -6,7 +6,6 @@ export * from './lib/get-user-locale'; export * from './lib/helpers'; export * from './lib/is-asset-erc20'; export * from './lib/is-valid-url'; -export * from './lib/local-logger'; export * from './lib/local-storage'; export * from './lib/markets'; export * from './lib/price-change'; @@ -14,4 +13,3 @@ export * from './lib/remove-0x'; export * from './lib/remove-pagination-wrapper'; export * from './lib/time'; export * from './lib/validate'; -export * from './lib/sentry-utils'; diff --git a/libs/web3/src/lib/use-eager-connect.ts b/libs/web3/src/lib/use-eager-connect.ts index 647d19e2e..e6551e9e4 100644 --- a/libs/web3/src/lib/use-eager-connect.ts +++ b/libs/web3/src/lib/use-eager-connect.ts @@ -1,5 +1,6 @@ -import type { LoggerProps } from '@vegaprotocol/react-helpers'; -import { useLocalStorage, useLogger } from '@vegaprotocol/react-helpers'; +import { useLocalStorage } from '@vegaprotocol/react-helpers'; +import type { LoggerProps } from '@vegaprotocol/logger'; +import { localLoggerFactory } from '@vegaprotocol/logger'; import type { Web3ReactHooks } from '@web3-react/core'; import { MetaMask } from '@web3-react/metamask'; import type { Connector } from '@web3-react/types'; @@ -14,7 +15,7 @@ export const useEagerConnect = (loggerConf: LoggerProps) => { const [eagerConnector] = useLocalStorage(ETHEREUM_EAGER_CONNECT); const attemptedRef = useRef(false); - const logger = useLogger(loggerConf); + const logger = localLoggerFactory(loggerConf); useEffect(() => { if (attemptedRef.current || 'Cypress' in window) return; diff --git a/libs/web3/src/lib/use-ethereum-withdraw-approvals-manager.tsx b/libs/web3/src/lib/use-ethereum-withdraw-approvals-manager.tsx index c79bdd6c5..89d9947cd 100644 --- a/libs/web3/src/lib/use-ethereum-withdraw-approvals-manager.tsx +++ b/libs/web3/src/lib/use-ethereum-withdraw-approvals-manager.tsx @@ -5,7 +5,7 @@ import { addDecimal } from '@vegaprotocol/utils'; import { useGetWithdrawThreshold } from './use-get-withdraw-threshold'; import { useGetWithdrawDelay } from './use-get-withdraw-delay'; import { t } from '@vegaprotocol/i18n'; -import { localLoggerFactory } from '@vegaprotocol/utils'; +import { localLoggerFactory } from '@vegaprotocol/logger'; import { CollateralBridge } from '@vegaprotocol/smart-contracts'; diff --git a/libs/web3/src/lib/use-get-withdraw-delay.ts b/libs/web3/src/lib/use-get-withdraw-delay.ts index e11f84201..1099226a2 100644 --- a/libs/web3/src/lib/use-get-withdraw-delay.ts +++ b/libs/web3/src/lib/use-get-withdraw-delay.ts @@ -1,6 +1,6 @@ import { useBridgeContract } from './use-bridge-contract'; import { useCallback } from 'react'; -import { localLoggerFactory } from '@vegaprotocol/utils'; +import { localLoggerFactory } from '@vegaprotocol/logger'; /** * Gets the delay in seconds thats required if the withdrawal amount is diff --git a/libs/withdraws/src/lib/use-complete-withdraw.ts b/libs/withdraws/src/lib/use-complete-withdraw.ts index e826f1e6b..d5932b002 100644 --- a/libs/withdraws/src/lib/use-complete-withdraw.ts +++ b/libs/withdraws/src/lib/use-complete-withdraw.ts @@ -6,7 +6,7 @@ import { useEthereumTransaction, } from '@vegaprotocol/web3'; import { useCallback, useEffect, useState } from 'react'; -import { localLoggerFactory } from '@vegaprotocol/utils'; +import { localLoggerFactory } from '@vegaprotocol/logger'; import { Erc20ApprovalDocument } from './__generated__/Erc20Approval'; import type { Erc20ApprovalQuery, diff --git a/libs/withdraws/src/lib/use-verify-withdrawal.ts b/libs/withdraws/src/lib/use-verify-withdrawal.ts index 28596f613..252eea6b4 100644 --- a/libs/withdraws/src/lib/use-verify-withdrawal.ts +++ b/libs/withdraws/src/lib/use-verify-withdrawal.ts @@ -1,6 +1,7 @@ import { useCallback, useState } from 'react'; import BigNumber from 'bignumber.js'; -import { addDecimal, localLoggerFactory } from '@vegaprotocol/utils'; +import { addDecimal } from '@vegaprotocol/utils'; +import { localLoggerFactory } from '@vegaprotocol/logger'; import { t } from '@vegaprotocol/i18n'; import { ApprovalStatus, diff --git a/libs/withdraws/src/lib/use-withdraw-asset.tsx b/libs/withdraws/src/lib/use-withdraw-asset.tsx index 6f05dcf69..d65584d32 100644 --- a/libs/withdraws/src/lib/use-withdraw-asset.tsx +++ b/libs/withdraws/src/lib/use-withdraw-asset.tsx @@ -1,5 +1,6 @@ import type { Asset } from '@vegaprotocol/assets'; -import { addDecimal, localLoggerFactory } from '@vegaprotocol/utils'; +import { addDecimal } from '@vegaprotocol/utils'; +import { localLoggerFactory } from '@vegaprotocol/logger'; import * as Schema from '@vegaprotocol/types'; import BigNumber from 'bignumber.js'; import { useCallback, useEffect } from 'react'; diff --git a/tsconfig.base.json b/tsconfig.base.json index e13e6b4de..c39912da7 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -31,6 +31,7 @@ "@vegaprotocol/i18n": ["libs/i18n/src/index.ts"], "@vegaprotocol/ledger": ["libs/ledger/src/index.ts"], "@vegaprotocol/liquidity": ["libs/liquidity/src/index.ts"], + "@vegaprotocol/logger": ["libs/logger/src/index.ts"], "@vegaprotocol/market-depth": ["libs/market-depth/src/index.ts"], "@vegaprotocol/markets": ["libs/markets/src/index.ts"], "@vegaprotocol/mock": ["libs/cypress/mock.ts"], diff --git a/workspace.json b/workspace.json index 41a68bac1..f4da2a020 100644 --- a/workspace.json +++ b/workspace.json @@ -21,6 +21,7 @@ "ledger": "libs/ledger", "liquidity": "libs/liquidity", "liquidity-provision-dashboard": "apps/liquidity-provision-dashboard", + "logger": "libs/logger", "market-depth": "libs/market-depth", "markets": "libs/markets", "multisig-signer": "apps/multisig-signer",