diff --git a/app/scripts/controllers/metametrics.js b/app/scripts/controllers/metametrics.js index 4bb1c4f46..00e07009f 100644 --- a/app/scripts/controllers/metametrics.js +++ b/app/scripts/controllers/metametrics.js @@ -200,9 +200,9 @@ export default class MetaMetricsController { value, currency, category, - network: this.network, + network: properties?.network ?? this.network, locale: this.locale, - chain_id: this.chainId, + chain_id: properties?.chain_id ?? this.chainId, environment_type: environmentType, }, context: this._buildContext(referrer, page), diff --git a/app/scripts/lib/rpc-method-middleware/handlers/add-ethereum-chain.js b/app/scripts/lib/rpc-method-middleware/handlers/add-ethereum-chain.js index a797ccf3f..cb7b69f7c 100644 --- a/app/scripts/lib/rpc-method-middleware/handlers/add-ethereum-chain.js +++ b/app/scripts/lib/rpc-method-middleware/handlers/add-ethereum-chain.js @@ -26,6 +26,7 @@ async function addEthereumChainHandler( findCustomRpcBy, updateRpcTarget, requestUserApproval, + sendMetrics, }, ) { 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 requestUserApproval({ origin,