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

add Custom Network Added event (#10484)

This commit is contained in:
Brad Decker 2021-02-23 09:58:35 -06:00 committed by GitHub
parent aabe653240
commit 1d23b59af3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 2 deletions

View File

@ -200,9 +200,9 @@ export default class MetaMetricsController {
value, value,
currency, currency,
category, category,
network: this.network, network: properties?.network ?? this.network,
locale: this.locale, locale: this.locale,
chain_id: this.chainId, chain_id: properties?.chain_id ?? this.chainId,
environment_type: environmentType, environment_type: environmentType,
}, },
context: this._buildContext(referrer, page), context: this._buildContext(referrer, page),

View File

@ -26,6 +26,7 @@ async function addEthereumChainHandler(
findCustomRpcBy, findCustomRpcBy,
updateRpcTarget, updateRpcTarget,
requestUserApproval, requestUserApproval,
sendMetrics,
}, },
) { ) {
if (!req.params?.[0] || typeof req.params[0] !== 'object') { if (!req.params?.[0] || typeof req.params[0] !== 'object') {
@ -227,6 +228,27 @@ async function addEthereumChainHandler(
}), }),
); );
sendMetrics({
event: 'Custom Network Added',
category: 'Network',
referrer: {
url: origin,
},
sensitiveProperties: {
chain_id: _chainId,
rpc_url: firstValidRPCUrl,
network_name: _chainName,
// Including network to override the default network
// property included in all events. For RPC type networks
// the MetaMetrics controller uses the rpcUrl for the network
// property.
network: firstValidRPCUrl,
symbol: ticker,
block_explorer_url: firstValidBlockExplorerUrl,
source: 'dapp',
},
});
await updateRpcTarget( await updateRpcTarget(
await requestUserApproval({ await requestUserApproval({
origin, origin,