Skip to content

Commit

Permalink
bugfix: add all bridge event
Browse files Browse the repository at this point in the history
  • Loading branch information
EvgeniyJB committed Dec 17, 2024
1 parent 90906b2 commit 48ab5d7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
3 changes: 3 additions & 0 deletions src/components/templates/AddWalletToList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -47,6 +49,7 @@ export const AddWalletToList = ({
const { item: list } = args;
const onPress = () => {
toggleWalletInList(list);
sendFirebaseEvent(CustomAppEvents.watchlist_address_group_added);
};

return (
Expand Down
28 changes: 15 additions & 13 deletions src/features/bridge/context/Bridge.Context.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -125,9 +134,6 @@ export const BridgeContext = () => {
setSelectedTokenPairs(pairsToTokenByDefault);
}
}
} catch (e) {
// TODO remove IT after testing
alert(`networkDataSetterError ${JSON.stringify(e)}`);
} finally {
setTemplateDataLoader(false);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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,
Expand All @@ -256,11 +263,6 @@ export const BridgeContext = () => {
} catch (e) {
// ignore
bridgeErrorHandler(e);
alert(
`${
getOnlyGasFee ? 'getOnlyGasFee' : ''
} processBridge ERROR ${JSON.stringify(e)}`
);
}
},
[
Expand Down
3 changes: 3 additions & 0 deletions src/features/bridge/templates/BridgeForm/BridgeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion src/features/bridge/utils/getBridgeFee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export const getFeeData = async ({
}
}
} catch (e) {
alert(`getFeeData ERROR ${JSON.stringify(e)}`);
return e;
// ignore
}
Expand Down

0 comments on commit 48ab5d7

Please sign in to comment.