Skip to content

Commit

Permalink
Merge pull request #896 from ambrosus/AMB-5145
Browse files Browse the repository at this point in the history
bugfix: add all bridge event
  • Loading branch information
EvgeniyJB authored Dec 17, 2024
2 parents 6763bbb + 767c2e0 commit 8d6ef36
Show file tree
Hide file tree
Showing 29 changed files with 145 additions and 64 deletions.
6 changes: 4 additions & 2 deletions src/api/staking/staking-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import {
StakeArgs
} from '@api/staking/types';
import { Cache, CacheKey } from '@lib/cache';
import { sendFirebaseEvent } from '@lib/firebaseEventAnalytics/sendFirebaseEvent';
import { CustomAppEvents } from '@lib/firebaseEventAnalytics/constants/CustomAppEvents';
import {
CustomAppEvents,
sendFirebaseEvent
} from '@lib/firebaseEventAnalytics';

const STAKE_ESTIMATED_GAS_LIMIT = 67079;
const UNSTAKE_ESTIMATED_GAS_LIMIT = 77516;
Expand Down
6 changes: 4 additions & 2 deletions src/components/templates/AccountActions/components/Bridge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { useTranslation } from 'react-i18next';
import { useNavigation } from '@react-navigation/native';
import { HomeNavigationProp } from '@appTypes';
import { AccountActionButton } from '@components/templates/AccountActions/components/ActionButton';
import { sendFirebaseEvent } from '@lib/firebaseEventAnalytics/sendFirebaseEvent';
import { CustomAppEvents } from '@lib/firebaseEventAnalytics/constants/CustomAppEvents';
import {
CustomAppEvents,
sendFirebaseEvent
} from '@lib/firebaseEventAnalytics';
import { BridgeAccountActionIcon } from '@components/svg/icons/v2/actions';

interface BridgeProps {
Expand Down
6 changes: 4 additions & 2 deletions src/components/templates/AccountActions/components/Kosmos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import React from 'react';
import { useNavigation } from '@react-navigation/native';
import { AccountActionButton } from './ActionButton';
import { HomeNavigationProp } from '@appTypes';
import { sendFirebaseEvent } from '@lib/firebaseEventAnalytics/sendFirebaseEvent';
import { CustomAppEvents } from '@lib/firebaseEventAnalytics/constants/CustomAppEvents';
import {
CustomAppEvents,
sendFirebaseEvent
} from '@lib/firebaseEventAnalytics';
import { KosmosAccountActionIcon } from '@components/svg/icons/v2/actions';

interface KosmosProps {
Expand Down
6 changes: 4 additions & 2 deletions src/components/templates/AccountActions/components/Send.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import { AccountActionButton } from './ActionButton';
import { useNavigation } from '@react-navigation/native';
import { HomeNavigationProp } from '@appTypes';
import { ExplorerAccount, Token } from '@models';
import { sendFirebaseEvent } from '@lib/firebaseEventAnalytics/sendFirebaseEvent';
import { CustomAppEvents } from '@lib/firebaseEventAnalytics/constants/CustomAppEvents';
import {
CustomAppEvents,
sendFirebaseEvent
} from '@lib/firebaseEventAnalytics';
import { SendAccountActionIcon } from '@components/svg/icons/v2/actions';
import { useSendFundsStore } from '@features/send-funds';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { useTranslation } from 'react-i18next';
import { AccountActionButton } from './ActionButton';
import { useNavigation } from '@react-navigation/native';
import { HomeNavigationProp } from '@appTypes';
import { sendFirebaseEvent } from '@lib/firebaseEventAnalytics/sendFirebaseEvent';
import { CustomAppEvents } from '@lib/firebaseEventAnalytics/constants/CustomAppEvents';
import {
CustomAppEvents,
sendFirebaseEvent
} from '@lib/firebaseEventAnalytics';
import { StakeAccountActionIcon } from '@components/svg/icons/v2/actions';

interface StakingProps {
Expand Down
6 changes: 4 additions & 2 deletions src/components/templates/AccountActions/components/Swap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { useTranslation } from 'react-i18next';
import { useNavigation } from '@react-navigation/native';
import { HomeNavigationProp } from '@appTypes';
import { AccountActionButton } from './ActionButton';
import { sendFirebaseEvent } from '@lib/firebaseEventAnalytics/sendFirebaseEvent';
import { CustomAppEvents } from '@lib/firebaseEventAnalytics/constants/CustomAppEvents';
import {
CustomAppEvents,
sendFirebaseEvent
} from '@lib/firebaseEventAnalytics';
import { SwapAccountActionIcon } from '@components/svg/icons/v2/actions';

interface SwapActionProps {
Expand Down
6 changes: 6 additions & 0 deletions src/components/templates/AddWalletToList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ import { SearchIcon } from '@components/svg/icons';
import { NumberUtils } from '@utils/number';
import { useListActions } from '@features/lists';

import {
CustomAppEvents,
sendFirebaseEvent
} from '@lib/firebaseEventAnalytics';

export interface AddWalletToListProps {
wallet: ExplorerAccount;
lists: AccountList[];
Expand Down Expand Up @@ -47,6 +52,7 @@ export const AddWalletToList = ({
const { item: list } = args;
const onPress = () => {
toggleWalletInList(list);
sendFirebaseEvent(CustomAppEvents.watchlist_address_group_added);
};

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ import { verticalScale } from '@utils/scaling';
import { StringUtils } from '@utils/string';
import { useTranslation } from 'react-i18next';
import { BottomSheet } from '@components/composite';
import { sendFirebaseEvent } from '@lib/firebaseEventAnalytics/sendFirebaseEvent';
import { CustomAppEvents } from '@lib/firebaseEventAnalytics/constants/CustomAppEvents';

import {
CustomAppEvents,
sendFirebaseEvent
} from '@lib/firebaseEventAnalytics';

type Props = {
ref: RefObject<BottomSheetRef>;
Expand Down
7 changes: 5 additions & 2 deletions src/components/templates/SearchAddress/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ import { Toast, ToastPosition, ToastType } from '@components/modular';
import { CRYPTO_ADDRESS_MAX_LENGTH } from '@constants/variables';
import { COLORS } from '@constants/colors';
import { SearchTabNavigationProp } from '@appTypes';
import { sendFirebaseEvent } from '@lib/firebaseEventAnalytics/sendFirebaseEvent';
import { CustomAppEvents } from '@lib/firebaseEventAnalytics/constants/CustomAppEvents';

import {
CustomAppEvents,
sendFirebaseEvent
} from '@lib/firebaseEventAnalytics';
import { useAddressesStore } from '@entities/addresses';

interface SearchAdressProps {
Expand Down
32 changes: 17 additions & 15 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 @@ -32,6 +32,11 @@ import { useTranslation } from 'react-i18next';
import { Toast, ToastType } from '@components/modular';
import { useWalletStore } from '@entities/wallet';

import {
CustomAppEvents,
sendFirebaseEvent
} from '@lib/firebaseEventAnalytics';

export const BridgeContext = () => {
const { t } = useTranslation();

Expand Down Expand Up @@ -64,16 +69,20 @@ export const BridgeContext = () => {

const bridgeErrorHandler = useCallback(
(_error: unknown) => {
// @ts-ignore
const errorCode = _error.code;
// @ts-ignore
const errorMethods = _error.method;
const errorCode = (_error as { code: string }).code;
const errorMethods = (_error as { method?: string }).method;
const errorMessage =
(_error as { message?: string }).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
6 changes: 6 additions & 0 deletions src/features/bridge/templates/BridgeForm/BridgeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ import {
import { getAllBridgeTokenBalance } from '@lib';
import { useWalletStore } from '@entities/wallet';

import {
CustomAppEvents,
sendFirebaseEvent
} from '@lib/firebaseEventAnalytics';

export const BridgeForm = () => {
const { wallet: selectedWallet } = useWalletStore();
const keyboardHeight = useKeyboardHeight() + DEVICE_HEIGHT * 0.01;
Expand Down Expand Up @@ -283,6 +288,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
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ import { useClaimBonds } from '@features/kosmos/lib/hooks/use-claim-bonds';
import { SecondaryButton, Toast, ToastType } from '@components/modular';
import { getTimeRemaining, TxType, useToken } from '@entities/kosmos';
import { COLORS } from '@constants/colors';
import { sendFirebaseEvent } from '@lib/firebaseEventAnalytics/sendFirebaseEvent';
import { CustomAppEvents } from '@lib/firebaseEventAnalytics/constants/CustomAppEvents';

import {
CustomAppEvents,
sendFirebaseEvent
} from '@lib/firebaseEventAnalytics';
import { TextOrSpinner } from '@components/composite';
import { buttonWithShadowStyle } from '@constants/shadow';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ import {
import { filter } from '@/features/kosmos/utils';
import { DEVICE_HEIGHT, DEVICE_WIDTH } from '@constants/variables';
import { HomeNavigationProp } from '@appTypes';
import { sendFirebaseEvent } from '@lib/firebaseEventAnalytics/sendFirebaseEvent';
import { CustomAppEvents } from '@lib/firebaseEventAnalytics/constants/CustomAppEvents';

import {
CustomAppEvents,
sendFirebaseEvent
} from '@lib/firebaseEventAnalytics';

const ESTIMATED_ITEM_SIZE = 56;
const ESTIMATED_LIST_SIZE = { width: DEVICE_WIDTH, height: DEVICE_HEIGHT };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ import {
} from '@features/kosmos/lib/hooks';
import { purchaseBonds } from '@features/kosmos/lib/contracts';
import Config from '@constants/config';
import { sendFirebaseEvent } from '@lib/firebaseEventAnalytics/sendFirebaseEvent';
import { CustomAppEvents } from '@lib/firebaseEventAnalytics/constants/CustomAppEvents';

import {
CustomAppEvents,
sendFirebaseEvent
} from '@lib/firebaseEventAnalytics';
import { buttonWithShadowStyle } from '@constants/shadow';
import { TextOrSpinner } from '@components/composite';
import { usePurchaseStore } from '@features/kosmos';
Expand Down
7 changes: 5 additions & 2 deletions src/features/lists/lib/hooks/use-list-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import { useCallback } from 'react';
import { PublicAddressListDB } from '@database';
import { CacheableAccountList } from '@appTypes';
import { useListsStore } from '@entities/lists/model/lists.store';
import { sendFirebaseEvent } from '@lib/firebaseEventAnalytics/sendFirebaseEvent';
import { CustomAppEvents } from '@lib/firebaseEventAnalytics/constants/CustomAppEvents';

import {
CustomAppEvents,
sendFirebaseEvent
} from '@lib/firebaseEventAnalytics';
import { AccountList, ExplorerAccount } from '@models';
import { useAddressesStore } from '@entities/addresses';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ import {
SwapErrorImpactButton
} from '@features/swap/components/base/swap-buttons-list';
import { AllowanceStatus, BottomSheetStatus } from '@features/swap/types';
import { sendFirebaseEvent } from '@lib/firebaseEventAnalytics/sendFirebaseEvent';
import { CustomAppEvents } from '@lib/firebaseEventAnalytics/constants/CustomAppEvents';

import {
CustomAppEvents,
sendFirebaseEvent
} from '@lib/firebaseEventAnalytics';

const SWAP_ERROR_TITLE = 'The transaction cannot succeed due to error:';
const SWAP_ERROR_DESCRIPTION =
Expand Down
7 changes: 5 additions & 2 deletions src/features/swap/lib/hooks/use-swap-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ import { createSigner } from '@features/swap/utils/contracts/instances';
import { useSwapSettings } from './use-swap-settings';
import { useSwapTokens } from './use-swap-tokens';
import { useSwapHelpers } from './use-swap-helpers';
import { sendFirebaseEvent } from '@lib/firebaseEventAnalytics/sendFirebaseEvent';
import { CustomAppEvents } from '@lib/firebaseEventAnalytics/constants/CustomAppEvents';

import {
CustomAppEvents,
sendFirebaseEvent
} from '@lib/firebaseEventAnalytics';
import { useWalletPrivateKey } from '@entities/wallet';

export function useSwapActions() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import { Row } from '@components/base';
import { AccountActionItem } from '../../base';
import { QRCodeIcon } from '@components/svg/icons/v2';
import { SendAccountActionIcon } from '@components/svg/icons/v2/actions';
import { CustomAppEvents } from '@lib/firebaseEventAnalytics/constants/CustomAppEvents';
import { sendFirebaseEvent } from '@lib/firebaseEventAnalytics/sendFirebaseEvent';

import {
CustomAppEvents,
sendFirebaseEvent
} from '@lib/firebaseEventAnalytics';
import { COLORS } from '@constants/colors';
import { Token } from '@models';
import { HomeNavigationProp } from '@appTypes';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ import { COLORS } from '@constants/colors';
import { WalletSessionsLabel } from '@features/wallet-connect/components/composite';
import { useWalletConnectContextSelector } from '@features/wallet-connect/lib/hooks';
import { Cache, CacheKey } from '@lib/cache';
import { CustomAppEvents } from '@lib/firebaseEventAnalytics/constants/CustomAppEvents';
import { sendFirebaseEvent } from '@lib/firebaseEventAnalytics/sendFirebaseEvent';

import {
CustomAppEvents,
sendFirebaseEvent
} from '@lib/firebaseEventAnalytics';
import { scale } from '@utils/scaling';
import { HomeNavigationProp } from '@appTypes/navigation';
import { StringUtils } from '@utils/string';
Expand Down
7 changes: 5 additions & 2 deletions src/hooks/cache/useWatchlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ import { useAddressesStore } from '@entities/addresses';
import { API } from '@api/api';
import { ExplorerAccount } from '@models/Explorer';
import { AddressUtils } from '@utils/address';
import { sendFirebaseEvent } from '@lib/firebaseEventAnalytics/sendFirebaseEvent';
import { CustomAppEvents } from '@lib/firebaseEventAnalytics/constants/CustomAppEvents';

import {
CustomAppEvents,
sendFirebaseEvent
} from '@lib/firebaseEventAnalytics';

export const useWatchlist = () => {
const { allAddresses } = useAddressesStore();
Expand Down
2 changes: 2 additions & 0 deletions src/lib/firebaseEventAnalytics/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './constants/CustomAppEvents';
export * from './sendFirebaseEvent';
7 changes: 5 additions & 2 deletions src/navigation/components/TabBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ import Animated, {
} from 'react-native-reanimated';
import { useFocusEffect } from '@react-navigation/native';
import { styles } from './styles';
import { sendFirebaseEvent } from '@lib/firebaseEventAnalytics/sendFirebaseEvent';
import { CustomAppEvents } from '@lib/firebaseEventAnalytics/constants/CustomAppEvents';

import {
CustomAppEvents,
sendFirebaseEvent
} from '@lib/firebaseEventAnalytics';
import { scale, verticalScale } from '@utils/scaling';
import { MAIN_TABS } from '@navigation/constants';
import { useCurrentRoute } from '@contexts/Navigation/Navigation.context';
Expand Down
7 changes: 5 additions & 2 deletions src/screens/SendFunds/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ import { Token } from '@models';
import { TransactionUtils } from '@utils/transaction';
import { NumberUtils } from '@utils/number';
import { styles } from './styles';
import { sendFirebaseEvent } from '@lib/firebaseEventAnalytics/sendFirebaseEvent';
import { CustomAppEvents } from '@lib/firebaseEventAnalytics/constants/CustomAppEvents';

import {
CustomAppEvents,
sendFirebaseEvent
} from '@lib/firebaseEventAnalytics';
import {
useAMBEntity,
useAmountChangeHandler
Expand Down
Loading

0 comments on commit 8d6ef36

Please sign in to comment.