1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 01:47:00 +01:00

Swaps: Add more anonymized tracking for HW wallet and HW wallet type (#11087)

This commit is contained in:
Daniel 2021-05-13 21:26:08 +02:00 committed by GitHub
parent 23db732f87
commit a174e3b99a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 81 additions and 1 deletions

View File

@ -24,6 +24,24 @@ export const createSwapsMockStore = () => {
'0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48': 2,
'0x1111111111111111111111111111111111111111': 0.1,
},
identities: {
'0xfdea65c8e26263f6d9a1b5de9555d2931a33b825': {
address: '0xfdea65c8e26263f6d9a1b5de9555d2931a33b825',
name: 'Send Account 1',
},
'0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb': {
address: '0xc5b8dbac4c1d3f152cdeb400e2313f309c410acb',
name: 'Send Account 2',
},
'0x2f8d4a878cfa04a6e60d46362f5644deab66572d': {
address: '0x2f8d4a878cfa04a6e60d46362f5644deab66572d',
name: 'Send Account 3',
},
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc': {
address: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
name: 'Send Account 4',
},
},
accounts: {
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc': {
address: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
@ -35,6 +53,21 @@ export const createSwapsMockStore = () => {
},
},
selectedAddress: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
keyringTypes: ['Simple Key Pair', 'HD Key Tree'],
keyrings: [
{
type: 'HD Key Tree',
accounts: [
'0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc',
'c5b8dbac4c1d3f152cdeb400e2313f309c410acb',
'2f8d4a878cfa04a6e60d46362f5644deab66572d',
],
},
{
type: 'Simple Key Pair',
accounts: ['0xd85a4b6a394794842887b8284293d69163007bbb'],
},
],
frequentRpcListDetail: [],
tokens: [
{

View File

@ -545,6 +545,8 @@ export const fetchQuotesAndSetQuoteState = (
request_type: balanceError ? 'Quote' : 'Order',
slippage: maxSlippage,
custom_slippage: maxSlippage !== 2,
is_hardware_wallet: hardwareWalletUsed,
hardware_wallet_type: hardwareWalletType,
},
});
dispatch(setSwapsErrorKey(QUOTES_NOT_AVAILABLE_ERROR));
@ -685,6 +687,8 @@ export const signAndSendTransactions = (history, metaMetricsEvent) => {
performance_savings: usedQuote.savings?.performance,
fee_savings: usedQuote.savings?.fee,
median_metamask_fee: usedQuote.savings?.medianMetaMaskFee,
is_hardware_wallet: hardwareWalletUsed,
hardware_wallet_type: getHardwareWalletType(state),
};
metaMetricsEvent({

View File

@ -9,6 +9,10 @@ import {
getApproveTxParams,
prepareToLeaveSwaps,
} from '../../../ducks/swaps/swaps';
import {
isHardwareWallet,
getHardwareWalletType,
} from '../../../selectors/selectors';
import {
DEFAULT_ROUTE,
BUILD_QUOTE_ROUTE,
@ -34,6 +38,8 @@ export default function AwaitingSignatures() {
const fetchParams = useSelector(getFetchParams);
const { destinationTokenInfo, sourceTokenInfo } = fetchParams?.metaData || {};
const approveTxParams = useSelector(getApproveTxParams);
const hardwareWalletUsed = useSelector(isHardwareWallet);
const hardwareWalletType = useSelector(getHardwareWalletType);
const needsTwoConfirmations = Boolean(approveTxParams);
const awaitingSignaturesEvent = useNewMetricEvent({
@ -46,6 +52,8 @@ export default function AwaitingSignatures() {
request_type: fetchParams?.balanceError ? 'Quote' : 'Order',
slippage: fetchParams?.slippage,
custom_slippage: fetchParams?.slippage === 2,
is_hardware_wallet: hardwareWalletUsed,
hardware_wallet_type: hardwareWalletType,
},
category: 'swaps',
});

View File

@ -13,6 +13,8 @@ import {
getCurrentCurrency,
getRpcPrefsForCurrentProvider,
getUSDConversionRate,
isHardwareWallet,
getHardwareWalletType,
} from '../../../selectors';
import {
@ -95,6 +97,8 @@ export default function AwaitingSwap({
feeinUnformattedFiat = renderableNetworkFees.rawNetworkFees;
}
const hardwareWalletUsed = useSelector(isHardwareWallet);
const hardwareWalletType = useSelector(getHardwareWalletType);
const quotesExpiredEvent = useNewMetricEvent({
event: 'Quotes Timed Out',
sensitiveProperties: {
@ -105,6 +109,8 @@ export default function AwaitingSwap({
slippage: fetchParams?.slippage,
custom_slippage: fetchParams?.slippage === 2,
gas_fees: feeinUnformattedFiat,
is_hardware_wallet: hardwareWalletUsed,
hardware_wallet_type: hardwareWalletType,
},
category: 'swaps',
});

View File

@ -13,6 +13,8 @@ import {
getSelectedAccount,
getCurrentChainId,
getIsSwapsChain,
isHardwareWallet,
getHardwareWalletType,
} from '../../selectors/selectors';
import {
getQuotes,
@ -184,6 +186,8 @@ export default function Swap() {
};
}, [dispatch, chainId]);
const hardwareWalletUsed = useSelector(isHardwareWallet);
const hardwareWalletType = useSelector(getHardwareWalletType);
const exitedSwapsEvent = useNewMetricEvent({
event: 'Exited Swaps',
category: 'swaps',
@ -195,6 +199,8 @@ export default function Swap() {
slippage: fetchParams?.slippage,
custom_slippage: fetchParams?.slippage !== 2,
current_screen: pathname.match(/\/swaps\/(.+)/u)[1],
is_hardware_wallet: hardwareWalletUsed,
hardware_wallet_type: hardwareWalletType,
},
});
const exitEventRef = useRef();

View File

@ -10,6 +10,10 @@ import {
getFetchParams,
getQuotesFetchStartTime,
} from '../../../ducks/swaps/swaps';
import {
isHardwareWallet,
getHardwareWalletType,
} from '../../../selectors/selectors';
import { I18nContext } from '../../../contexts/i18n';
import { MetaMetricsContext } from '../../../contexts/metametrics.new';
import Mascot from '../../../components/ui/mascot';
@ -67,6 +71,8 @@ export default function LoadingSwapsQuotes({
const fetchParams = useSelector(getFetchParams);
const quotesFetchStartTime = useSelector(getQuotesFetchStartTime);
const hardwareWalletUsed = useSelector(isHardwareWallet);
const hardwareWalletType = useSelector(getHardwareWalletType);
const quotesRequestCancelledEventConfig = {
event: 'Quotes Request Cancelled',
category: 'swaps',
@ -78,6 +84,8 @@ export default function LoadingSwapsQuotes({
slippage: fetchParams?.slippage,
custom_slippage: fetchParams?.slippage !== 2,
response_time: Date.now() - quotesFetchStartTime,
is_hardware_wallet: hardwareWalletUsed,
hardware_wallet_type: hardwareWalletType,
},
};

View File

@ -39,6 +39,8 @@ import {
getSwapsDefaultToken,
getCurrentChainId,
getNativeCurrency,
isHardwareWallet,
getHardwareWalletType,
} from '../../../selectors';
import { toPrecisionWithoutTrailingZeros } from '../../../helpers/utils/util';
import { getTokens } from '../../../ducks/metamask/metamask';
@ -330,6 +332,8 @@ export default function ViewQuote() {
available_quotes: numberOfQuotes,
};
const hardwareWalletUsed = useSelector(isHardwareWallet);
const hardwareWalletType = useSelector(getHardwareWalletType);
const allAvailableQuotesOpened = useNewMetricEvent({
event: 'All Available Quotes Opened',
category: 'swaps',
@ -340,6 +344,8 @@ export default function ViewQuote() {
usedQuote?.aggregator === topQuote?.aggregator
? null
: usedQuote?.aggregator,
is_hardware_wallet: hardwareWalletUsed,
hardware_wallet_type: hardwareWalletType,
},
});
const quoteDetailsOpened = useNewMetricEvent({
@ -352,6 +358,8 @@ export default function ViewQuote() {
usedQuote?.aggregator === topQuote?.aggregator
? null
: usedQuote?.aggregator,
is_hardware_wallet: hardwareWalletUsed,
hardware_wallet_type: hardwareWalletType,
},
});
const editSpendLimitOpened = useNewMetricEvent({
@ -362,13 +370,20 @@ export default function ViewQuote() {
custom_spend_limit_set: originalApproveAmount === approveAmount,
custom_spend_limit_amount:
originalApproveAmount === approveAmount ? null : approveAmount,
is_hardware_wallet: hardwareWalletUsed,
hardware_wallet_type: hardwareWalletType,
},
});
const bestQuoteReviewedEvent = useNewMetricEvent({
event: 'Best Quote Reviewed',
category: 'swaps',
sensitiveProperties: { ...eventObjectBase, network_fees: feeInFiat },
sensitiveProperties: {
...eventObjectBase,
network_fees: feeInFiat,
is_hardware_wallet: hardwareWalletUsed,
hardware_wallet_type: hardwareWalletType,
},
});
useEffect(() => {
if (