mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 18:00:18 +01:00
remove rpc urls from metrics (#16710)
This commit is contained in:
parent
dd0844e200
commit
b3895b6840
@ -91,8 +91,6 @@ export default class MetaMetricsController {
|
|||||||
* networkDidChange event emitted by the networkController
|
* networkDidChange event emitted by the networkController
|
||||||
* @param {Function} options.getCurrentChainId - Gets the current chain id from the
|
* @param {Function} options.getCurrentChainId - Gets the current chain id from the
|
||||||
* network controller
|
* network controller
|
||||||
* @param {Function} options.getNetworkIdentifier - Gets the current network
|
|
||||||
* identifier from the network controller
|
|
||||||
* @param {string} options.version - The version of the extension
|
* @param {string} options.version - The version of the extension
|
||||||
* @param {string} options.environment - The environment the extension is running in
|
* @param {string} options.environment - The environment the extension is running in
|
||||||
* @param {string} options.extension - webextension-polyfill
|
* @param {string} options.extension - webextension-polyfill
|
||||||
@ -104,7 +102,6 @@ export default class MetaMetricsController {
|
|||||||
preferencesStore,
|
preferencesStore,
|
||||||
onNetworkDidChange,
|
onNetworkDidChange,
|
||||||
getCurrentChainId,
|
getCurrentChainId,
|
||||||
getNetworkIdentifier,
|
|
||||||
version,
|
version,
|
||||||
environment,
|
environment,
|
||||||
initState,
|
initState,
|
||||||
@ -120,7 +117,6 @@ export default class MetaMetricsController {
|
|||||||
};
|
};
|
||||||
const prefState = preferencesStore.getState();
|
const prefState = preferencesStore.getState();
|
||||||
this.chainId = getCurrentChainId();
|
this.chainId = getCurrentChainId();
|
||||||
this.network = getNetworkIdentifier();
|
|
||||||
this.locale = prefState.currentLocale.replace('_', '-');
|
this.locale = prefState.currentLocale.replace('_', '-');
|
||||||
this.version =
|
this.version =
|
||||||
environment === 'production' ? version : `${version}-${environment}`;
|
environment === 'production' ? version : `${version}-${environment}`;
|
||||||
@ -150,7 +146,6 @@ export default class MetaMetricsController {
|
|||||||
|
|
||||||
onNetworkDidChange(() => {
|
onNetworkDidChange(() => {
|
||||||
this.chainId = getCurrentChainId();
|
this.chainId = getCurrentChainId();
|
||||||
this.network = getNetworkIdentifier();
|
|
||||||
});
|
});
|
||||||
this.segment = segment;
|
this.segment = segment;
|
||||||
|
|
||||||
@ -470,7 +465,6 @@ export default class MetaMetricsController {
|
|||||||
properties: {
|
properties: {
|
||||||
params,
|
params,
|
||||||
locale: this.locale,
|
locale: this.locale,
|
||||||
network: this.network,
|
|
||||||
chain_id: this.chainId,
|
chain_id: this.chainId,
|
||||||
environment_type: environmentType,
|
environment_type: environmentType,
|
||||||
},
|
},
|
||||||
@ -668,7 +662,6 @@ export default class MetaMetricsController {
|
|||||||
value,
|
value,
|
||||||
currency,
|
currency,
|
||||||
category,
|
category,
|
||||||
network: properties?.network ?? this.network,
|
|
||||||
locale: this.locale,
|
locale: this.locale,
|
||||||
chain_id: properties?.chain_id ?? this.chainId,
|
chain_id: properties?.chain_id ?? this.chainId,
|
||||||
environment_type: environmentType,
|
environment_type: environmentType,
|
||||||
|
@ -8,7 +8,11 @@ import {
|
|||||||
TRAITS,
|
TRAITS,
|
||||||
} from '../../../shared/constants/metametrics';
|
} from '../../../shared/constants/metametrics';
|
||||||
import waitUntilCalled from '../../../test/lib/wait-until-called';
|
import waitUntilCalled from '../../../test/lib/wait-until-called';
|
||||||
import { CHAIN_IDS, CURRENCY_SYMBOLS } from '../../../shared/constants/network';
|
import {
|
||||||
|
CHAIN_IDS,
|
||||||
|
CURRENCY_SYMBOLS,
|
||||||
|
NETWORK_TYPES,
|
||||||
|
} from '../../../shared/constants/network';
|
||||||
import * as Utils from '../lib/util';
|
import * as Utils from '../lib/util';
|
||||||
import MetaMetricsController from './metametrics';
|
import MetaMetricsController from './metametrics';
|
||||||
import { NETWORK_EVENTS } from './network';
|
import { NETWORK_EVENTS } from './network';
|
||||||
@ -16,7 +20,6 @@ import { NETWORK_EVENTS } from './network';
|
|||||||
const segment = createSegmentMock(2, 10000);
|
const segment = createSegmentMock(2, 10000);
|
||||||
|
|
||||||
const VERSION = '0.0.1-test';
|
const VERSION = '0.0.1-test';
|
||||||
const NETWORK = 'Mainnet';
|
|
||||||
const FAKE_CHAIN_ID = '0x1338';
|
const FAKE_CHAIN_ID = '0x1338';
|
||||||
const LOCALE = 'en_US';
|
const LOCALE = 'en_US';
|
||||||
const TEST_META_METRICS_ID = '0xabc';
|
const TEST_META_METRICS_ID = '0xabc';
|
||||||
@ -46,7 +49,6 @@ const DEFAULT_TEST_CONTEXT = {
|
|||||||
const DEFAULT_SHARED_PROPERTIES = {
|
const DEFAULT_SHARED_PROPERTIES = {
|
||||||
chain_id: FAKE_CHAIN_ID,
|
chain_id: FAKE_CHAIN_ID,
|
||||||
locale: LOCALE.replace('_', '-'),
|
locale: LOCALE.replace('_', '-'),
|
||||||
network: NETWORK,
|
|
||||||
environment_type: 'background',
|
environment_type: 'background',
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -64,7 +66,7 @@ const DEFAULT_PAGE_PROPERTIES = {
|
|||||||
|
|
||||||
function getMockNetworkController(
|
function getMockNetworkController(
|
||||||
chainId = FAKE_CHAIN_ID,
|
chainId = FAKE_CHAIN_ID,
|
||||||
provider = { type: NETWORK },
|
provider = { type: NETWORK_TYPES.MAINNET },
|
||||||
) {
|
) {
|
||||||
let networkStore = { chainId, provider };
|
let networkStore = { chainId, provider };
|
||||||
const on = sinon.stub().withArgs(NETWORK_EVENTS.NETWORK_DID_CHANGE);
|
const on = sinon.stub().withArgs(NETWORK_EVENTS.NETWORK_DID_CHANGE);
|
||||||
@ -130,8 +132,6 @@ function getMetaMetricsController({
|
|||||||
} = {}) {
|
} = {}) {
|
||||||
return new MetaMetricsController({
|
return new MetaMetricsController({
|
||||||
segment: segmentInstance || segment,
|
segment: segmentInstance || segment,
|
||||||
getNetworkIdentifier:
|
|
||||||
networkController.getNetworkIdentifier.bind(networkController),
|
|
||||||
getCurrentChainId:
|
getCurrentChainId:
|
||||||
networkController.getCurrentChainId.bind(networkController),
|
networkController.getCurrentChainId.bind(networkController),
|
||||||
onNetworkDidChange: networkController.on.bind(
|
onNetworkDidChange: networkController.on.bind(
|
||||||
@ -178,7 +178,6 @@ describe('MetaMetricsController', function () {
|
|||||||
});
|
});
|
||||||
const metaMetricsController = getMetaMetricsController();
|
const metaMetricsController = getMetaMetricsController();
|
||||||
assert.strictEqual(metaMetricsController.version, VERSION);
|
assert.strictEqual(metaMetricsController.version, VERSION);
|
||||||
assert.strictEqual(metaMetricsController.network, NETWORK);
|
|
||||||
assert.strictEqual(metaMetricsController.chainId, FAKE_CHAIN_ID);
|
assert.strictEqual(metaMetricsController.chainId, FAKE_CHAIN_ID);
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
metaMetricsController.state.participateInMetaMetrics,
|
metaMetricsController.state.participateInMetaMetrics,
|
||||||
@ -203,14 +202,12 @@ describe('MetaMetricsController', function () {
|
|||||||
const metaMetricsController = getMetaMetricsController({
|
const metaMetricsController = getMetaMetricsController({
|
||||||
networkController,
|
networkController,
|
||||||
});
|
});
|
||||||
assert.strictEqual(metaMetricsController.network, NETWORK);
|
|
||||||
networkController.store.updateState({
|
networkController.store.updateState({
|
||||||
provider: {
|
provider: {
|
||||||
type: 'NEW_NETWORK',
|
type: 'NEW_NETWORK',
|
||||||
},
|
},
|
||||||
chainId: '0xaab',
|
chainId: '0xaab',
|
||||||
});
|
});
|
||||||
assert.strictEqual(metaMetricsController.network, 'NEW_NETWORK');
|
|
||||||
assert.strictEqual(metaMetricsController.chainId, '0xaab');
|
assert.strictEqual(metaMetricsController.chainId, '0xaab');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -219,7 +216,6 @@ describe('MetaMetricsController', function () {
|
|||||||
const metaMetricsController = getMetaMetricsController({
|
const metaMetricsController = getMetaMetricsController({
|
||||||
preferencesStore,
|
preferencesStore,
|
||||||
});
|
});
|
||||||
assert.strictEqual(metaMetricsController.network, NETWORK);
|
|
||||||
preferencesStore.updateState({
|
preferencesStore.updateState({
|
||||||
currentLocale: 'en_UK',
|
currentLocale: 'en_UK',
|
||||||
});
|
});
|
||||||
|
@ -289,13 +289,6 @@ 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,
|
||||||
@ -305,18 +298,9 @@ async function addEthereumChainHandler(
|
|||||||
properties: {
|
properties: {
|
||||||
chain_id: _chainId,
|
chain_id: _chainId,
|
||||||
network_name: _chainName,
|
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: rpcUrlOrigin,
|
|
||||||
symbol: ticker,
|
symbol: ticker,
|
||||||
block_explorer_url: firstValidBlockExplorerUrl,
|
|
||||||
source: EVENT.SOURCE.TRANSACTION.DAPP,
|
source: EVENT.SOURCE.TRANSACTION.DAPP,
|
||||||
},
|
},
|
||||||
sensitiveProperties: {
|
|
||||||
rpc_url: rpcUrlOrigin,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Once the network has been added, the requested is considered successful
|
// Once the network has been added, the requested is considered successful
|
||||||
|
@ -2121,29 +2121,18 @@ 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: rpcUrlOrigin,
|
url: ORIGIN_METAMASK,
|
||||||
},
|
},
|
||||||
properties: {
|
properties: {
|
||||||
chain_id: chainId,
|
chain_id: chainId,
|
||||||
network_name: chainName,
|
network_name: chainName,
|
||||||
network: rpcUrlOrigin,
|
|
||||||
symbol: ticker,
|
symbol: ticker,
|
||||||
block_explorer_url: blockExplorerUrl,
|
|
||||||
source: EVENT.SOURCE.NETWORK.POPULAR_NETWORK_LIST,
|
source: EVENT.SOURCE.NETWORK.POPULAR_NETWORK_LIST,
|
||||||
},
|
},
|
||||||
sensitiveProperties: {
|
|
||||||
rpc_url: rpcUrlOrigin,
|
|
||||||
},
|
|
||||||
actionId,
|
actionId,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ import {
|
|||||||
FEATURED_RPCS,
|
FEATURED_RPCS,
|
||||||
} from '../../../../../shared/constants/network';
|
} from '../../../../../shared/constants/network';
|
||||||
import { decimalToHex } from '../../../../../shared/lib/transactions-controller-utils';
|
import { decimalToHex } from '../../../../../shared/lib/transactions-controller-utils';
|
||||||
|
import { ORIGIN_METAMASK } from '../../../../../shared/constants/app';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempts to convert the given chainId to a decimal string, for display
|
* Attempts to convert the given chainId to a decimal string, for display
|
||||||
@ -530,29 +531,18 @@ 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: rpcUrlOrigin,
|
url: ORIGIN_METAMASK,
|
||||||
},
|
},
|
||||||
properties: {
|
properties: {
|
||||||
chain_id: addHexPrefix(Number(chainId).toString(16)),
|
chain_id: addHexPrefix(Number(chainId).toString(16)),
|
||||||
network_name: networkName,
|
network_name: networkName,
|
||||||
network: rpcUrlOrigin,
|
|
||||||
symbol: ticker,
|
symbol: ticker,
|
||||||
block_explorer_url: blockExplorerUrl,
|
|
||||||
source: EVENT.SOURCE.NETWORK.CUSTOM_NETWORK_FORM,
|
source: EVENT.SOURCE.NETWORK.CUSTOM_NETWORK_FORM,
|
||||||
},
|
},
|
||||||
sensitiveProperties: {
|
|
||||||
rpc_url: rpcUrlOrigin,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
dispatch(setNewNetworkAdded(networkName));
|
dispatch(setNewNetworkAdded(networkName));
|
||||||
history.push(DEFAULT_ROUTE);
|
history.push(DEFAULT_ROUTE);
|
||||||
|
Loading…
Reference in New Issue
Block a user