Skip to content

Commit

Permalink
Merge branch 'develop' into feature/node-14
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
rickycodes committed Apr 13, 2021
2 parents d4fcd81 + 582b86d commit 834e17f
Show file tree
Hide file tree
Showing 31 changed files with 635 additions and 285 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Current Develop Branch

## v2.1.0 - Apr 12 2021
- [#2487](https://github.com/MetaMask/metamask-mobile/pull/2487): Fix/analytics v1 priority1
- [#2456](https://github.com/MetaMask/metamask-mobile/pull/2456): Analytics v2 (priority 1)
- [#2408](https://github.com/MetaMask/metamask-mobile/pull/2408): Fix/gas estimations
- [#2479](https://github.com/MetaMask/metamask-mobile/pull/2479): remove controllers tgz
Expand Down
2 changes: 1 addition & 1 deletion app/components/Nav/Main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,11 @@ const Main = props => {
const onUnapprovedMessage = (messageParams, type) => {
const { title: currentPageTitle, url: currentPageUrl } = messageParams.meta;
delete messageParams.meta;
setSignMessage(true);
setSignMessageParams(messageParams);
setSignType(type);
setCurrentPageTitle(currentPageTitle);
setCurrentPageUrl(currentPageUrl);
setSignMessage(true);
};

const connectionChangeHandler = useCallback(
Expand Down
20 changes: 12 additions & 8 deletions app/components/UI/AccountApproval/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,18 @@ class AccountApproval extends PureComponent {
};

getAnalyticsParams = () => {
const { currentPageInformation, chainId, networkType } = this.props;
const url = new URL(currentPageInformation.url);
return {
dapp_host_name: url?.host,
dapp_url: currentPageInformation?.url,
network_name: networkType,
chain_id: chainId
};
try {
const { currentPageInformation, chainId, networkType } = this.props;
const url = new URL(currentPageInformation?.url);
return {
dapp_host_name: url?.host,
dapp_url: currentPageInformation?.url,
network_name: networkType,
chain_id: chainId
};
} catch (error) {
return {};
}
};

componentDidMount = () => {
Expand Down
18 changes: 10 additions & 8 deletions app/components/UI/AddCustomCollectible/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,16 @@ class AddCustomCollectible extends PureComponent {
};

getAnalyticsParams = () => {
const { NetworkController } = Engine.context;
const { chainId, type } = NetworkController?.state?.provider || {};
const { address } = this.state;
return {
collectible_address: { value: address, anonymous: true },
network_name: type,
chain_id: chainId
};
try {
const { NetworkController } = Engine.context;
const { chainId, type } = NetworkController?.state?.provider || {};
return {
network_name: type,
chain_id: chainId
};
} catch (error) {
return {};
}
};

addCollectible = async () => {
Expand Down
24 changes: 14 additions & 10 deletions app/components/UI/AddCustomToken/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,20 @@ export default class AddCustomToken extends PureComponent {
};

getAnalyticsParams = () => {
const { NetworkController } = Engine.context;
const { chainId, type } = NetworkController?.state?.provider || {};
const { address, symbol } = this.state;
return {
token_address: { value: address, anonymous: true },
token_symbol: { value: symbol, anonymous: true },
network_name: type,
chain_id: chainId,
source: 'Custom token'
};
try {
const { NetworkController } = Engine.context;
const { chainId, type } = NetworkController?.state?.provider || {};
const { address, symbol } = this.state;
return {
token_address: address,
token_symbol: symbol,
network_name: type,
chain_id: chainId,
source: 'Custom token'
};
} catch (error) {
return {};
}
};

addToken = async () => {
Expand Down
44 changes: 24 additions & 20 deletions app/components/UI/ApproveTransactionReview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,26 +318,30 @@ class ApproveTransactionReview extends PureComponent {
}

getAnalyticsParams = () => {
const { activeTabUrl, transaction, onSetAnalyticsParams } = this.props;
const { tokenSymbol, originalApproveAmount, encodedAmount } = this.state;
const { NetworkController } = Engine.context;
const { chainId, type } = NetworkController?.state?.provider || {};
const isDapp = !Object.values(AppConstants.DEEPLINKS).includes(transaction.origin);
const unlimited = encodedAmount === 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff';
const params = {
dapp_host_name: transaction?.origin,
dapp_url: isDapp ? activeTabUrl : undefined,
network_name: type,
chain_id: chainId,
active_currency: { value: tokenSymbol, anonymous: true },
number_tokens_requested: { value: originalApproveAmount, anonymous: true },
unlimited_permission_requested: unlimited,
referral_type: isDapp ? 'dapp' : transaction?.origin
};
// Send analytics params to parent component so it's available when cancelling and confirming
onSetAnalyticsParams && onSetAnalyticsParams(params);

return params;
try {
const { activeTabUrl, transaction, onSetAnalyticsParams } = this.props;
const { tokenSymbol, originalApproveAmount, encodedAmount } = this.state;
const { NetworkController } = Engine.context;
const { chainId, type } = NetworkController?.state?.provider || {};
const isDapp = !Object.values(AppConstants.DEEPLINKS).includes(transaction?.origin);
const unlimited = encodedAmount === 'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff';
const params = {
dapp_host_name: transaction?.origin,
dapp_url: isDapp ? activeTabUrl : undefined,
network_name: type,
chain_id: chainId,
active_currency: { value: tokenSymbol, anonymous: true },
number_tokens_requested: { value: originalApproveAmount, anonymous: true },
unlimited_permission_requested: unlimited,
referral_type: isDapp ? 'dapp' : transaction?.origin
};
// Send analytics params to parent component so it's available when cancelling and confirming
onSetAnalyticsParams && onSetAnalyticsParams(params);

return params;
} catch (error) {
return {};
}
};

trackApproveEvent = event => {
Expand Down
32 changes: 20 additions & 12 deletions app/components/UI/CustomGas/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,11 +330,15 @@ class CustomGas extends PureComponent {
/**
* Extra analytics params to be send with the gas analytics
*/
analyticsParams: PropTypes.object
analyticsParams: PropTypes.object,
/**
* The currently selected gas speed
*/
gasSpeedSelected: PropTypes.string
};

state = {
gasSpeedSelected: this?.props?.gasSpeedSelected || 'average',
gasSpeedSelected: this.props.gasSpeedSelected || 'average',
customGasPrice: '10',
customGasLimit: fromWei(this.props.gas, 'wei'),
customGasPriceBNWei: this.props.gasPrice,
Expand Down Expand Up @@ -512,16 +516,20 @@ class CustomGas extends PureComponent {
};

getAnalyticsParams = () => {
const { advancedCustomGas, chainId, networkType, view, analyticsParams } = this.props;
const { gasSpeedSelected } = this.state;
return {
...(analyticsParams || {}),
network_name: networkType,
chain_id: chainId,
function_type: { value: view, anonymous: true },
gas_mode: { value: advancedCustomGas ? 'Advanced' : 'Basic', anonymous: true },
speed_set: { value: advancedCustomGas ? undefined : gasSpeedSelected, anonymous: true }
};
try {
const { advancedCustomGas, chainId, networkType, view, analyticsParams } = this.props;
const { gasSpeedSelected } = this.state;
return {
...(analyticsParams || {}),
network_name: networkType,
chain_id: chainId,
function_type: view,
gas_mode: advancedCustomGas ? 'Advanced' : 'Basic',
speed_set: advancedCustomGas ? undefined : gasSpeedSelected
};
} catch (error) {
return {};
}
};

//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
Expand Down
30 changes: 17 additions & 13 deletions app/components/UI/MessageSign/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,21 @@ export default class MessageSign extends PureComponent {
};

getAnalyticsParams = () => {
const { currentPageInformation } = this.props;
const { NetworkController } = Engine.context;
const { chainId, type } = NetworkController?.state?.provider || {};
const url = new URL(currentPageInformation.url);
return {
dapp_host_name: url?.host,
dapp_url: currentPageInformation?.url,
network_name: type,
chain_id: chainId,
sign_type: 'eth'
};
try {
const { currentPageInformation } = this.props;
const { NetworkController } = Engine.context;
const { chainId, type } = NetworkController?.state?.provider || {};
const url = new URL(currentPageInformation?.url);
return {
dapp_host_name: url?.host,
dapp_url: currentPageInformation?.url,
network_name: type,
chain_id: chainId,
sign_type: 'eth'
};
} catch (error) {
return {};
}
};

componentDidMount = () => {
Expand Down Expand Up @@ -113,14 +117,14 @@ export default class MessageSign extends PureComponent {
};

cancelSignature = () => {
AnalyticsV2.trackEvent(AnalyticsV2.ANALYTICS_EVENTS.SIGN_REQUEST_CANCELLED, this.getAnalyticsParams());
this.rejectMessage();
AnalyticsV2.trackEvent(AnalyticsV2.ANALYTICS_EVENTS.SIGN_REQUEST_CANCELLED, this.getAnalyticsParams());
this.props.onCancel();
};

confirmSignature = () => {
AnalyticsV2.trackEvent(AnalyticsV2.ANALYTICS_EVENTS.SIGN_REQUEST_COMPLETED, this.getAnalyticsParams());
this.signMessage();
AnalyticsV2.trackEvent(AnalyticsV2.ANALYTICS_EVENTS.SIGN_REQUEST_COMPLETED, this.getAnalyticsParams());
this.props.onConfirm();
};

Expand Down
31 changes: 18 additions & 13 deletions app/components/UI/PersonalSign/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,22 @@ export default class PersonalSign extends PureComponent {
};

getAnalyticsParams = () => {
const { currentPageInformation } = this.props;
const { NetworkController } = Engine.context;
const { chainId, type } = NetworkController?.state?.provider || {};
const url = new URL(currentPageInformation.url);
return {
dapp_host_name: url?.host,
dapp_url: currentPageInformation?.url,
network_name: type,
chain_id: chainId,
sign_type: 'personal'
};
try {
const { currentPageInformation } = this.props;
const { NetworkController } = Engine.context;
const { chainId, type } = NetworkController?.state?.provider || {};
const url = new URL(currentPageInformation?.url);

return {
dapp_host_name: url?.host,
dapp_url: currentPageInformation?.url,
network_name: type,
chain_id: chainId,
sign_type: 'personal'
};
} catch (error) {
return {};
}
};

componentDidMount = () => {
Expand Down Expand Up @@ -118,14 +123,14 @@ export default class PersonalSign extends PureComponent {
};

cancelSignature = () => {
AnalyticsV2.trackEvent(AnalyticsV2.ANALYTICS_EVENTS.SIGN_REQUEST_CANCELLED, this.getAnalyticsParams());
this.rejectMessage();
AnalyticsV2.trackEvent(AnalyticsV2.ANALYTICS_EVENTS.SIGN_REQUEST_CANCELLED, this.getAnalyticsParams());
this.props.onCancel();
};

confirmSignature = () => {
AnalyticsV2.trackEvent(AnalyticsV2.ANALYTICS_EVENTS.SIGN_REQUEST_COMPLETED, this.getAnalyticsParams());
this.signMessage();
AnalyticsV2.trackEvent(AnalyticsV2.ANALYTICS_EVENTS.SIGN_REQUEST_COMPLETED, this.getAnalyticsParams());
this.props.onConfirm();
};

Expand Down
24 changes: 14 additions & 10 deletions app/components/UI/SearchTokenAutocomplete/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,20 @@ export default class SearchTokenAutocomplete extends PureComponent {
};

getAnalyticsParams = () => {
const { NetworkController } = Engine.context;
const { chainId, type } = NetworkController?.state?.provider || {};
const { address, symbol } = this.state.selectedAsset;
return {
token_address: { value: address, anonymous: true },
token_symbol: { value: symbol, anonymous: true },
network_name: type,
chain_id: chainId,
source: 'Add token dropdown'
};
try {
const { NetworkController } = Engine.context;
const { chainId, type } = NetworkController?.state?.provider || {};
const { address, symbol } = this.state.selectedAsset || {};
return {
token_address: address,
token_symbol: symbol,
network_name: type,
chain_id: chainId,
source: 'Add token dropdown'
};
} catch (error) {
return {};
}
};

addToken = async () => {
Expand Down
18 changes: 11 additions & 7 deletions app/components/UI/TransactionEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,13 +611,17 @@ class TransactionEditor extends PureComponent {
};

getGasAnalyticsParams = () => {
const { transaction, activeTabUrl } = this.props;
const { selectedAsset } = transaction;
return {
dapp_host_name: transaction?.origin,
dapp_url: activeTabUrl,
active_currency: { value: selectedAsset?.symbol, anonymous: true }
};
try {
const { transaction, activeTabUrl } = this.props;
const { selectedAsset } = transaction;
return {
dapp_host_name: transaction?.origin,
dapp_url: activeTabUrl,
active_currency: { value: selectedAsset?.symbol, anonymous: true }
};
} catch (error) {
return {};
}
};

render = () => {
Expand Down

0 comments on commit 834e17f

Please sign in to comment.