add Custom Network Added event (#10484)

feature/default_network_editable
Brad Decker 4 years ago committed by GitHub
parent aabe653240
commit 1d23b59af3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      app/scripts/controllers/metametrics.js
  2. 22
      app/scripts/lib/rpc-method-middleware/handlers/add-ethereum-chain.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),

@ -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,

Loading…
Cancel
Save