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({
event: 'Custom Network Added',
category: EVENT.CATEGORIES.NETWORK,
@ -274,13 +281,13 @@ async function addEthereumChainHandler(
// property included in all events. For RPC type networks
// the MetaMetrics controller uses the rpcUrl for the network
// property.
network: firstValidRPCUrl,
network: rpcUrlOrigin,
symbol: ticker,
block_explorer_url: firstValidBlockExplorerUrl,
source: EVENT.SOURCE.TRANSACTION.DAPP,
},
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({
event: 'Custom Network Added',
category: EVENT.CATEGORIES.NETWORK,
referrer: {
url: rpcUrl,
url: rpcUrlOrigin,
},
properties: {
chain_id: chainId,
network_name: chainName,
network: rpcUrl,
network: rpcUrlOrigin,
symbol: ticker,
block_explorer_url: blockExplorerUrl,
source: EVENT.SOURCE.NETWORK.POPULAR_NETWORK_LIST,
},
sensitiveProperties: {
rpc_url: rpcUrl,
rpc_url: rpcUrlOrigin,
},
});
}

View File

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