From 48ab5d75c3f20ca89635271f03ae73b323b8864e Mon Sep 17 00:00:00 2001 From: EvgeniyJB Date: Tue, 17 Dec 2024 14:49:37 +0100 Subject: [PATCH] bugfix: add all bridge event --- .../templates/AddWalletToList/index.tsx | 3 ++ .../bridge/context/Bridge.Context.tsx | 28 ++++++++++--------- .../templates/BridgeForm/BridgeForm.tsx | 3 ++ src/features/bridge/utils/getBridgeFee.ts | 1 - 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/src/components/templates/AddWalletToList/index.tsx b/src/components/templates/AddWalletToList/index.tsx index da2d70918..d4cf2c976 100644 --- a/src/components/templates/AddWalletToList/index.tsx +++ b/src/components/templates/AddWalletToList/index.tsx @@ -11,6 +11,8 @@ import { COLORS } from '@constants/colors'; import { SearchIcon } from '@components/svg/icons'; import { NumberUtils } from '@utils/number'; import { useListActions } from '@features/lists'; +import { sendFirebaseEvent } from '@lib/firebaseEventAnalytics/sendFirebaseEvent'; +import { CustomAppEvents } from '@lib/firebaseEventAnalytics/constants/CustomAppEvents'; export interface AddWalletToListProps { wallet: ExplorerAccount; @@ -47,6 +49,7 @@ export const AddWalletToList = ({ const { item: list } = args; const onPress = () => { toggleWalletInList(list); + sendFirebaseEvent(CustomAppEvents.watchlist_address_group_added); }; return ( diff --git a/src/features/bridge/context/Bridge.Context.tsx b/src/features/bridge/context/Bridge.Context.tsx index 022ce034b..ec19c425a 100644 --- a/src/features/bridge/context/Bridge.Context.tsx +++ b/src/features/bridge/context/Bridge.Context.tsx @@ -1,8 +1,8 @@ import { createContextSelector } from '@utils/createContextSelector'; import { useCallback, useEffect, useMemo, useState } from 'react'; import { - Config as BridgeConfigModel, BridgeDataState, + Config as BridgeConfigModel, FeeData, Token } from '@lib/bridgeSDK/models/types'; @@ -31,6 +31,8 @@ import { BridgeTransactionHistoryDTO } from '@models/dtos/Bridge'; import { useTranslation } from 'react-i18next'; import { Toast, ToastType } from '@components/modular'; import { useWalletStore } from '@entities/wallet'; +import { sendFirebaseEvent } from '@lib/firebaseEventAnalytics/sendFirebaseEvent'; +import { CustomAppEvents } from '@lib/firebaseEventAnalytics/constants/CustomAppEvents'; export const BridgeContext = () => { const { t } = useTranslation(); @@ -65,15 +67,22 @@ export const BridgeContext = () => { const bridgeErrorHandler = useCallback( (_error: unknown) => { // @ts-ignore - const errorCode = _error.code; + const errorCode = _error?.code; + // @ts-ignore + const errorMethods = _error?.method; // @ts-ignore - const errorMethods = _error.method; + const errorMessage = _error?.message || JSON.stringify(_error); + const type = ToastType.Failed; const insufficientFundsToPayFees = errorCode === BRIDGE_ERROR_CODES.INSUFFICIENT_FUNDS && errorMethods === METHODS_FROM_ERRORS.ESTIMATE_GAS; + sendFirebaseEvent(CustomAppEvents.bridge_error, { + bridgeError: errorMessage + }); + switch (true) { case insufficientFundsToPayFees: return Toast.show({ @@ -125,9 +134,6 @@ export const BridgeContext = () => { setSelectedTokenPairs(pairsToTokenByDefault); } } - } catch (e) { - // TODO remove IT after testing - alert(`networkDataSetterError ${JSON.stringify(e)}`); } finally { setTemplateDataLoader(false); } @@ -155,9 +161,7 @@ export const BridgeContext = () => { setBridges(bridges); } } catch (e) { - // TODO remove IT after testing bridgeErrorHandler(e); - alert(`DATA BRIDLE LOADING ERROR ${JSON.stringify(e)}`); } finally { setBridgeDataLoader(false); } @@ -246,6 +250,9 @@ export const BridgeContext = () => { gasFee: getOnlyGasFee }; if (bridgeConfig) { + if (!getOnlyGasFee) { + sendFirebaseEvent(CustomAppEvents.bridge_start); + } return await bridgeWithdraw({ bridgeConfig, fromNetwork: fromData.value.id, @@ -256,11 +263,6 @@ export const BridgeContext = () => { } catch (e) { // ignore bridgeErrorHandler(e); - alert( - `${ - getOnlyGasFee ? 'getOnlyGasFee' : '' - } processBridge ERROR ${JSON.stringify(e)}` - ); } }, [ diff --git a/src/features/bridge/templates/BridgeForm/BridgeForm.tsx b/src/features/bridge/templates/BridgeForm/BridgeForm.tsx index 633dc7164..8a5b787e9 100644 --- a/src/features/bridge/templates/BridgeForm/BridgeForm.tsx +++ b/src/features/bridge/templates/BridgeForm/BridgeForm.tsx @@ -42,6 +42,8 @@ import { } from '@features/bridge/constants'; import { getAllBridgeTokenBalance } from '@lib'; import { useWalletStore } from '@entities/wallet'; +import { sendFirebaseEvent } from '@lib/firebaseEventAnalytics/sendFirebaseEvent'; +import { CustomAppEvents } from '@lib/firebaseEventAnalytics/constants/CustomAppEvents'; export const BridgeForm = () => { const { wallet: selectedWallet } = useWalletStore(); @@ -283,6 +285,7 @@ export const BridgeForm = () => { setPreviewLoader(true); processBridge(false, bridgePreviewDataRef.current.value.feeData) .then((transaction) => { + sendFirebaseEvent(CustomAppEvents.bridge_finish); const transactionWaitingInfo = { ...DEFAULT_TRANSACTION, networkFrom: fromData.value.name, diff --git a/src/features/bridge/utils/getBridgeFee.ts b/src/features/bridge/utils/getBridgeFee.ts index a368e5ecd..bfd9b0f78 100644 --- a/src/features/bridge/utils/getBridgeFee.ts +++ b/src/features/bridge/utils/getBridgeFee.ts @@ -49,7 +49,6 @@ export const getFeeData = async ({ } } } catch (e) { - alert(`getFeeData ERROR ${JSON.stringify(e)}`); return e; // ignore }