1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Only send the rpc origin to segment when calling trackevent for newly added custom networks (#15227)

This commit is contained in:
Alex Donesky 2022-07-15 12:08:44 -05:00 committed by GitHub
parent cbda923c61
commit 4993d28a8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 8 deletions

View File

@ -261,6 +261,13 @@ async function addEthereumChainHandler(
}), }),
); );
let rpcUrlOrigin;
try {
rpcUrlOrigin = new URL(firstValidRPCUrl).origin;
} catch {
// ignore
}
sendMetrics({ sendMetrics({
event: 'Custom Network Added', event: 'Custom Network Added',
category: EVENT.CATEGORIES.NETWORK, category: EVENT.CATEGORIES.NETWORK,
@ -274,13 +281,13 @@ async function addEthereumChainHandler(
// property included in all events. For RPC type networks // property included in all events. For RPC type networks
// the MetaMetrics controller uses the rpcUrl for the network // the MetaMetrics controller uses the rpcUrl for the network
// property. // property.
network: firstValidRPCUrl, network: rpcUrlOrigin,
symbol: ticker, symbol: ticker,
block_explorer_url: firstValidBlockExplorerUrl, block_explorer_url: firstValidBlockExplorerUrl,
source: EVENT.SOURCE.TRANSACTION.DAPP, source: EVENT.SOURCE.TRANSACTION.DAPP,
}, },
sensitiveProperties: { sensitiveProperties: {
rpc_url: firstValidRPCUrl, rpc_url: rpcUrlOrigin,
}, },
}); });

View File

@ -2065,22 +2065,28 @@ export default class MetamaskController extends EventEmitter {
}, },
); );
let rpcUrlOrigin;
try {
rpcUrlOrigin = new URL(rpcUrl).origin;
} catch {
// ignore
}
this.metaMetricsController.trackEvent({ this.metaMetricsController.trackEvent({
event: 'Custom Network Added', event: 'Custom Network Added',
category: EVENT.CATEGORIES.NETWORK, category: EVENT.CATEGORIES.NETWORK,
referrer: { referrer: {
url: rpcUrl, url: rpcUrlOrigin,
}, },
properties: { properties: {
chain_id: chainId, chain_id: chainId,
network_name: chainName, network_name: chainName,
network: rpcUrl, network: rpcUrlOrigin,
symbol: ticker, symbol: ticker,
block_explorer_url: blockExplorerUrl, block_explorer_url: blockExplorerUrl,
source: EVENT.SOURCE.NETWORK.POPULAR_NETWORK_LIST, source: EVENT.SOURCE.NETWORK.POPULAR_NETWORK_LIST,
}, },
sensitiveProperties: { sensitiveProperties: {
rpc_url: rpcUrl, rpc_url: rpcUrlOrigin,
}, },
}); });
} }

View File

@ -512,22 +512,28 @@ const NetworksForm = ({
} }
if (addNewNetwork) { if (addNewNetwork) {
let rpcUrlOrigin;
try {
rpcUrlOrigin = new URL(rpcUrl).origin;
} catch {
// error
}
trackEvent({ trackEvent({
event: 'Custom Network Added', event: 'Custom Network Added',
category: EVENT.CATEGORIES.NETWORK, category: EVENT.CATEGORIES.NETWORK,
referrer: { referrer: {
url: rpcUrl, url: rpcUrlOrigin,
}, },
properties: { properties: {
chain_id: chainId, chain_id: chainId,
network_name: networkName, network_name: networkName,
network: rpcUrl, network: rpcUrlOrigin,
symbol: ticker, symbol: ticker,
block_explorer_url: blockExplorerUrl, block_explorer_url: blockExplorerUrl,
source: EVENT.SOURCE.NETWORK.CUSTOM_NETWORK_FORM, source: EVENT.SOURCE.NETWORK.CUSTOM_NETWORK_FORM,
}, },
sensitiveProperties: { sensitiveProperties: {
rpc_url: rpcUrl, rpc_url: rpcUrlOrigin,
}, },
}); });
dispatch(setNewNetworkAdded(networkName)); dispatch(setNewNetworkAdded(networkName));