Skip to content

Commit 834e17f

Browse files
committed
Merge branch 'develop' into feature/node-14
* develop: Bump vm-browserify from 0.0.4 to 1.1.2 (#2447) Bump jest-serializer from 24.4.0 to 26.6.2 (#2501) Bump react-native-share from 3.3.2 to 5.2.2 (#2499) Bump json-rpc-middleware-stream from 2.1.1 to 3.0.0 (#2411) Bump eslint-plugin-prettier from 3.3.0 to 3.3.1 (#2406) Bump babel-eslint from 10.0.3 to 10.1.0 (#2403) Display correct number of decimals for 'usd' fiat (#2381) bugfix/4849 (#2491) bugfix/2488 (#2490) Fix/analytics v1 priority1 (#2487) Add scripts for generating and verifying SHA 512 checksums (#2168)
2 parents d4fcd81 + 582b86d commit 834e17f

File tree

31 files changed

+635
-285
lines changed

31 files changed

+635
-285
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Current Develop Branch
44

55
## v2.1.0 - Apr 12 2021
6+
- [#2487](https://github.com/MetaMask/metamask-mobile/pull/2487): Fix/analytics v1 priority1
67
- [#2456](https://github.com/MetaMask/metamask-mobile/pull/2456): Analytics v2 (priority 1)
78
- [#2408](https://github.com/MetaMask/metamask-mobile/pull/2408): Fix/gas estimations
89
- [#2479](https://github.com/MetaMask/metamask-mobile/pull/2479): remove controllers tgz

app/components/Nav/Main/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,11 @@ const Main = props => {
128128
const onUnapprovedMessage = (messageParams, type) => {
129129
const { title: currentPageTitle, url: currentPageUrl } = messageParams.meta;
130130
delete messageParams.meta;
131-
setSignMessage(true);
132131
setSignMessageParams(messageParams);
133132
setSignType(type);
134133
setCurrentPageTitle(currentPageTitle);
135134
setCurrentPageUrl(currentPageUrl);
135+
setSignMessage(true);
136136
};
137137

138138
const connectionChangeHandler = useCallback(

app/components/UI/AccountApproval/index.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,18 @@ class AccountApproval extends PureComponent {
101101
};
102102

103103
getAnalyticsParams = () => {
104-
const { currentPageInformation, chainId, networkType } = this.props;
105-
const url = new URL(currentPageInformation.url);
106-
return {
107-
dapp_host_name: url?.host,
108-
dapp_url: currentPageInformation?.url,
109-
network_name: networkType,
110-
chain_id: chainId
111-
};
104+
try {
105+
const { currentPageInformation, chainId, networkType } = this.props;
106+
const url = new URL(currentPageInformation?.url);
107+
return {
108+
dapp_host_name: url?.host,
109+
dapp_url: currentPageInformation?.url,
110+
network_name: networkType,
111+
chain_id: chainId
112+
};
113+
} catch (error) {
114+
return {};
115+
}
112116
};
113117

114118
componentDidMount = () => {

app/components/UI/AddCustomCollectible/index.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,16 @@ class AddCustomCollectible extends PureComponent {
7474
};
7575

7676
getAnalyticsParams = () => {
77-
const { NetworkController } = Engine.context;
78-
const { chainId, type } = NetworkController?.state?.provider || {};
79-
const { address } = this.state;
80-
return {
81-
collectible_address: { value: address, anonymous: true },
82-
network_name: type,
83-
chain_id: chainId
84-
};
77+
try {
78+
const { NetworkController } = Engine.context;
79+
const { chainId, type } = NetworkController?.state?.provider || {};
80+
return {
81+
network_name: type,
82+
chain_id: chainId
83+
};
84+
} catch (error) {
85+
return {};
86+
}
8587
};
8688

8789
addCollectible = async () => {

app/components/UI/AddCustomToken/index.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,20 @@ export default class AddCustomToken extends PureComponent {
5252
};
5353

5454
getAnalyticsParams = () => {
55-
const { NetworkController } = Engine.context;
56-
const { chainId, type } = NetworkController?.state?.provider || {};
57-
const { address, symbol } = this.state;
58-
return {
59-
token_address: { value: address, anonymous: true },
60-
token_symbol: { value: symbol, anonymous: true },
61-
network_name: type,
62-
chain_id: chainId,
63-
source: 'Custom token'
64-
};
55+
try {
56+
const { NetworkController } = Engine.context;
57+
const { chainId, type } = NetworkController?.state?.provider || {};
58+
const { address, symbol } = this.state;
59+
return {
60+
token_address: address,
61+
token_symbol: symbol,
62+
network_name: type,
63+
chain_id: chainId,
64+
source: 'Custom token'
65+
};
66+
} catch (error) {
67+
return {};
68+
}
6569
};
6670

6771
addToken = async () => {

app/components/UI/ApproveTransactionReview/index.js

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -318,26 +318,30 @@ class ApproveTransactionReview extends PureComponent {
318318
}
319319

320320
getAnalyticsParams = () => {
321-
const { activeTabUrl, transaction, onSetAnalyticsParams } = this.props;
322-
const { tokenSymbol, originalApproveAmount, encodedAmount } = this.state;
323-
const { NetworkController } = Engine.context;
324-
const { chainId, type } = NetworkController?.state?.provider || {};
325-
const isDapp = !Object.values(AppConstants.DEEPLINKS).includes(transaction.origin);
326-
const unlimited = encodedAmount === 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff';
327-
const params = {
328-
dapp_host_name: transaction?.origin,
329-
dapp_url: isDapp ? activeTabUrl : undefined,
330-
network_name: type,
331-
chain_id: chainId,
332-
active_currency: { value: tokenSymbol, anonymous: true },
333-
number_tokens_requested: { value: originalApproveAmount, anonymous: true },
334-
unlimited_permission_requested: unlimited,
335-
referral_type: isDapp ? 'dapp' : transaction?.origin
336-
};
337-
// Send analytics params to parent component so it's available when cancelling and confirming
338-
onSetAnalyticsParams && onSetAnalyticsParams(params);
339-
340-
return params;
321+
try {
322+
const { activeTabUrl, transaction, onSetAnalyticsParams } = this.props;
323+
const { tokenSymbol, originalApproveAmount, encodedAmount } = this.state;
324+
const { NetworkController } = Engine.context;
325+
const { chainId, type } = NetworkController?.state?.provider || {};
326+
const isDapp = !Object.values(AppConstants.DEEPLINKS).includes(transaction?.origin);
327+
const unlimited = encodedAmount === 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff';
328+
const params = {
329+
dapp_host_name: transaction?.origin,
330+
dapp_url: isDapp ? activeTabUrl : undefined,
331+
network_name: type,
332+
chain_id: chainId,
333+
active_currency: { value: tokenSymbol, anonymous: true },
334+
number_tokens_requested: { value: originalApproveAmount, anonymous: true },
335+
unlimited_permission_requested: unlimited,
336+
referral_type: isDapp ? 'dapp' : transaction?.origin
337+
};
338+
// Send analytics params to parent component so it's available when cancelling and confirming
339+
onSetAnalyticsParams && onSetAnalyticsParams(params);
340+
341+
return params;
342+
} catch (error) {
343+
return {};
344+
}
341345
};
342346

343347
trackApproveEvent = event => {

app/components/UI/CustomGas/index.js

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -330,11 +330,15 @@ class CustomGas extends PureComponent {
330330
/**
331331
* Extra analytics params to be send with the gas analytics
332332
*/
333-
analyticsParams: PropTypes.object
333+
analyticsParams: PropTypes.object,
334+
/**
335+
* The currently selected gas speed
336+
*/
337+
gasSpeedSelected: PropTypes.string
334338
};
335339

336340
state = {
337-
gasSpeedSelected: this?.props?.gasSpeedSelected || 'average',
341+
gasSpeedSelected: this.props.gasSpeedSelected || 'average',
338342
customGasPrice: '10',
339343
customGasLimit: fromWei(this.props.gas, 'wei'),
340344
customGasPriceBNWei: this.props.gasPrice,
@@ -512,16 +516,20 @@ class CustomGas extends PureComponent {
512516
};
513517

514518
getAnalyticsParams = () => {
515-
const { advancedCustomGas, chainId, networkType, view, analyticsParams } = this.props;
516-
const { gasSpeedSelected } = this.state;
517-
return {
518-
...(analyticsParams || {}),
519-
network_name: networkType,
520-
chain_id: chainId,
521-
function_type: { value: view, anonymous: true },
522-
gas_mode: { value: advancedCustomGas ? 'Advanced' : 'Basic', anonymous: true },
523-
speed_set: { value: advancedCustomGas ? undefined : gasSpeedSelected, anonymous: true }
524-
};
519+
try {
520+
const { advancedCustomGas, chainId, networkType, view, analyticsParams } = this.props;
521+
const { gasSpeedSelected } = this.state;
522+
return {
523+
...(analyticsParams || {}),
524+
network_name: networkType,
525+
chain_id: chainId,
526+
function_type: view,
527+
gas_mode: advancedCustomGas ? 'Advanced' : 'Basic',
528+
speed_set: advancedCustomGas ? undefined : gasSpeedSelected
529+
};
530+
} catch (error) {
531+
return {};
532+
}
525533
};
526534

527535
//Handle gas fee selection when save button is pressed instead of everytime a change is made, otherwise cannot switch back to review mode if there is an error

app/components/UI/MessageSign/index.js

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,21 @@ export default class MessageSign extends PureComponent {
6262
};
6363

6464
getAnalyticsParams = () => {
65-
const { currentPageInformation } = this.props;
66-
const { NetworkController } = Engine.context;
67-
const { chainId, type } = NetworkController?.state?.provider || {};
68-
const url = new URL(currentPageInformation.url);
69-
return {
70-
dapp_host_name: url?.host,
71-
dapp_url: currentPageInformation?.url,
72-
network_name: type,
73-
chain_id: chainId,
74-
sign_type: 'eth'
75-
};
65+
try {
66+
const { currentPageInformation } = this.props;
67+
const { NetworkController } = Engine.context;
68+
const { chainId, type } = NetworkController?.state?.provider || {};
69+
const url = new URL(currentPageInformation?.url);
70+
return {
71+
dapp_host_name: url?.host,
72+
dapp_url: currentPageInformation?.url,
73+
network_name: type,
74+
chain_id: chainId,
75+
sign_type: 'eth'
76+
};
77+
} catch (error) {
78+
return {};
79+
}
7680
};
7781

7882
componentDidMount = () => {
@@ -113,14 +117,14 @@ export default class MessageSign extends PureComponent {
113117
};
114118

115119
cancelSignature = () => {
116-
AnalyticsV2.trackEvent(AnalyticsV2.ANALYTICS_EVENTS.SIGN_REQUEST_CANCELLED, this.getAnalyticsParams());
117120
this.rejectMessage();
121+
AnalyticsV2.trackEvent(AnalyticsV2.ANALYTICS_EVENTS.SIGN_REQUEST_CANCELLED, this.getAnalyticsParams());
118122
this.props.onCancel();
119123
};
120124

121125
confirmSignature = () => {
122-
AnalyticsV2.trackEvent(AnalyticsV2.ANALYTICS_EVENTS.SIGN_REQUEST_COMPLETED, this.getAnalyticsParams());
123126
this.signMessage();
127+
AnalyticsV2.trackEvent(AnalyticsV2.ANALYTICS_EVENTS.SIGN_REQUEST_COMPLETED, this.getAnalyticsParams());
124128
this.props.onConfirm();
125129
};
126130

app/components/UI/PersonalSign/index.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,22 @@ export default class PersonalSign extends PureComponent {
6767
};
6868

6969
getAnalyticsParams = () => {
70-
const { currentPageInformation } = this.props;
71-
const { NetworkController } = Engine.context;
72-
const { chainId, type } = NetworkController?.state?.provider || {};
73-
const url = new URL(currentPageInformation.url);
74-
return {
75-
dapp_host_name: url?.host,
76-
dapp_url: currentPageInformation?.url,
77-
network_name: type,
78-
chain_id: chainId,
79-
sign_type: 'personal'
80-
};
70+
try {
71+
const { currentPageInformation } = this.props;
72+
const { NetworkController } = Engine.context;
73+
const { chainId, type } = NetworkController?.state?.provider || {};
74+
const url = new URL(currentPageInformation?.url);
75+
76+
return {
77+
dapp_host_name: url?.host,
78+
dapp_url: currentPageInformation?.url,
79+
network_name: type,
80+
chain_id: chainId,
81+
sign_type: 'personal'
82+
};
83+
} catch (error) {
84+
return {};
85+
}
8186
};
8287

8388
componentDidMount = () => {
@@ -118,14 +123,14 @@ export default class PersonalSign extends PureComponent {
118123
};
119124

120125
cancelSignature = () => {
121-
AnalyticsV2.trackEvent(AnalyticsV2.ANALYTICS_EVENTS.SIGN_REQUEST_CANCELLED, this.getAnalyticsParams());
122126
this.rejectMessage();
127+
AnalyticsV2.trackEvent(AnalyticsV2.ANALYTICS_EVENTS.SIGN_REQUEST_CANCELLED, this.getAnalyticsParams());
123128
this.props.onCancel();
124129
};
125130

126131
confirmSignature = () => {
127-
AnalyticsV2.trackEvent(AnalyticsV2.ANALYTICS_EVENTS.SIGN_REQUEST_COMPLETED, this.getAnalyticsParams());
128132
this.signMessage();
133+
AnalyticsV2.trackEvent(AnalyticsV2.ANALYTICS_EVENTS.SIGN_REQUEST_COMPLETED, this.getAnalyticsParams());
129134
this.props.onConfirm();
130135
};
131136

app/components/UI/SearchTokenAutocomplete/index.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,20 @@ export default class SearchTokenAutocomplete extends PureComponent {
5050
};
5151

5252
getAnalyticsParams = () => {
53-
const { NetworkController } = Engine.context;
54-
const { chainId, type } = NetworkController?.state?.provider || {};
55-
const { address, symbol } = this.state.selectedAsset;
56-
return {
57-
token_address: { value: address, anonymous: true },
58-
token_symbol: { value: symbol, anonymous: true },
59-
network_name: type,
60-
chain_id: chainId,
61-
source: 'Add token dropdown'
62-
};
53+
try {
54+
const { NetworkController } = Engine.context;
55+
const { chainId, type } = NetworkController?.state?.provider || {};
56+
const { address, symbol } = this.state.selectedAsset || {};
57+
return {
58+
token_address: address,
59+
token_symbol: symbol,
60+
network_name: type,
61+
chain_id: chainId,
62+
source: 'Add token dropdown'
63+
};
64+
} catch (error) {
65+
return {};
66+
}
6367
};
6468

6569
addToken = async () => {

0 commit comments

Comments
 (0)