Skip to content

Commit

Permalink
chore: Add extra event props (#26123)
Browse files Browse the repository at this point in the history
  • Loading branch information
dan437 authored Jul 26, 2024
1 parent c7880bf commit 0e503c3
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 28 deletions.
15 changes: 15 additions & 0 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ import {
getFeatureFlagsByChainId,
getSmartTransactionsOptInStatus,
getCurrentChainSupportsSmartTransactions,
getHardwareWalletType,
} from '../../shared/modules/selectors';
import { createCaipStream } from '../../shared/modules/caip-stream';
import { BaseUrl } from '../../shared/constants/urls';
Expand Down Expand Up @@ -1947,6 +1948,20 @@ export default class MetamaskController extends EventEmitter {
trackMetaMetricsEvent: this.metaMetricsController.trackEvent.bind(
this.metaMetricsController,
),
getMetaMetricsProps: async () => {
const selectedAddress =
this.accountsController.getSelectedAccount().address;
const accountHardwareType = await getHardwareWalletType(
this._getMetaMaskState(),
);
const accountType = await this.getAccountType(selectedAddress);
const deviceModel = await this.getDeviceModel(selectedAddress);
return {
accountHardwareType,
accountType,
deviceModel,
};
},
},
{
supportedChainIds: getAllowedSmartTransactionsChainIds(),
Expand Down
21 changes: 19 additions & 2 deletions lavamoat/browserify/beta/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1977,8 +1977,10 @@
},
"@metamask/network-controller>@metamask/eth-json-rpc-provider": {
"packages": {
"@metamask/rpc-errors": true,
"@metamask/safe-event-emitter": true,
"@metamask/snaps-controllers>@metamask/json-rpc-engine": true
"@metamask/snaps-controllers>@metamask/json-rpc-engine": true,
"uuid": true
}
},
"@metamask/notification-controller": {
Expand Down Expand Up @@ -2619,7 +2621,22 @@
"packages": {
"@metamask/rpc-errors": true,
"@metamask/safe-event-emitter": true,
"@metamask/utils": true
"@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/utils": true
}
},
"@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/utils": {
"globals": {
"TextDecoder": true,
"TextEncoder": true
},
"packages": {
"@metamask/rpc-errors>@metamask/utils>@metamask/superstruct": true,
"@metamask/utils>@scure/base": true,
"@metamask/utils>pony-cause": true,
"@noble/hashes": true,
"browserify>buffer": true,
"nock>debug": true,
"semver": true
}
},
"@metamask/snaps-controllers>@metamask/json-rpc-middleware-stream": {
Expand Down
21 changes: 19 additions & 2 deletions lavamoat/browserify/flask/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1977,8 +1977,10 @@
},
"@metamask/network-controller>@metamask/eth-json-rpc-provider": {
"packages": {
"@metamask/rpc-errors": true,
"@metamask/safe-event-emitter": true,
"@metamask/snaps-controllers>@metamask/json-rpc-engine": true
"@metamask/snaps-controllers>@metamask/json-rpc-engine": true,
"uuid": true
}
},
"@metamask/notification-controller": {
Expand Down Expand Up @@ -2619,7 +2621,22 @@
"packages": {
"@metamask/rpc-errors": true,
"@metamask/safe-event-emitter": true,
"@metamask/utils": true
"@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/utils": true
}
},
"@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/utils": {
"globals": {
"TextDecoder": true,
"TextEncoder": true
},
"packages": {
"@metamask/rpc-errors>@metamask/utils>@metamask/superstruct": true,
"@metamask/utils>@scure/base": true,
"@metamask/utils>pony-cause": true,
"@noble/hashes": true,
"browserify>buffer": true,
"nock>debug": true,
"semver": true
}
},
"@metamask/snaps-controllers>@metamask/json-rpc-middleware-stream": {
Expand Down
21 changes: 19 additions & 2 deletions lavamoat/browserify/main/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -1977,8 +1977,10 @@
},
"@metamask/network-controller>@metamask/eth-json-rpc-provider": {
"packages": {
"@metamask/rpc-errors": true,
"@metamask/safe-event-emitter": true,
"@metamask/snaps-controllers>@metamask/json-rpc-engine": true
"@metamask/snaps-controllers>@metamask/json-rpc-engine": true,
"uuid": true
}
},
"@metamask/notification-controller": {
Expand Down Expand Up @@ -2619,7 +2621,22 @@
"packages": {
"@metamask/rpc-errors": true,
"@metamask/safe-event-emitter": true,
"@metamask/utils": true
"@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/utils": true
}
},
"@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/utils": {
"globals": {
"TextDecoder": true,
"TextEncoder": true
},
"packages": {
"@metamask/rpc-errors>@metamask/utils>@metamask/superstruct": true,
"@metamask/utils>@scure/base": true,
"@metamask/utils>pony-cause": true,
"@noble/hashes": true,
"browserify>buffer": true,
"nock>debug": true,
"semver": true
}
},
"@metamask/snaps-controllers>@metamask/json-rpc-middleware-stream": {
Expand Down
21 changes: 19 additions & 2 deletions lavamoat/browserify/mmi/policy.json
Original file line number Diff line number Diff line change
Expand Up @@ -2069,8 +2069,10 @@
},
"@metamask/network-controller>@metamask/eth-json-rpc-provider": {
"packages": {
"@metamask/rpc-errors": true,
"@metamask/safe-event-emitter": true,
"@metamask/snaps-controllers>@metamask/json-rpc-engine": true
"@metamask/snaps-controllers>@metamask/json-rpc-engine": true,
"uuid": true
}
},
"@metamask/notification-controller": {
Expand Down Expand Up @@ -2711,7 +2713,22 @@
"packages": {
"@metamask/rpc-errors": true,
"@metamask/safe-event-emitter": true,
"@metamask/utils": true
"@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/utils": true
}
},
"@metamask/snaps-controllers>@metamask/json-rpc-engine>@metamask/utils": {
"globals": {
"TextDecoder": true,
"TextEncoder": true
},
"packages": {
"@metamask/rpc-errors>@metamask/utils>@metamask/superstruct": true,
"@metamask/utils>@scure/base": true,
"@metamask/utils>pony-cause": true,
"@noble/hashes": true,
"browserify>buffer": true,
"nock>debug": true,
"semver": true
}
},
"@metamask/snaps-controllers>@metamask/json-rpc-middleware-stream": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@
"@metamask/scure-bip39": "^2.0.3",
"@metamask/selected-network-controller": "^15.0.2",
"@metamask/signature-controller": "^16.0.0",
"@metamask/smart-transactions-controller": "^10.1.6",
"@metamask/smart-transactions-controller": "^11.0.0",
"@metamask/snaps-controllers": "^9.2.0",
"@metamask/snaps-execution-environments": "^6.5.0",
"@metamask/snaps-rpc-methods": "^9.1.4",
Expand Down
4 changes: 4 additions & 0 deletions shared/modules/selectors/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { getHardwareWalletType } from '../../../ui/selectors/selectors';

export * from './smart-transactions';
export * from './feature-flags';
export * from './token-auto-detect';
export * from './nft-auto-detect';
export * from './account';

export { getHardwareWalletType };
4 changes: 4 additions & 0 deletions ui/ducks/swaps/swaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,8 @@ export const signAndSendSwapsSmartTransaction = ({
dispatch(setSwapsSTXSubmitLoading(true));
const state = getState();
const fetchParams = getFetchParams(state);
const hardwareWalletUsed = isHardwareWallet(state);
const hardwareWalletType = getHardwareWalletType(state);
const { metaData, value: swapTokenValue, slippage } = fetchParams;
const { sourceTokenInfo = {}, destinationTokenInfo = {} } = metaData;
const usedQuote = getUsedQuote(state);
Expand Down Expand Up @@ -926,6 +928,8 @@ export const signAndSendSwapsSmartTransaction = ({
performance_savings: usedQuote.savings?.performance,
fee_savings: usedQuote.savings?.fee,
median_metamask_fee: usedQuote.savings?.medianMetaMaskFee,
is_hardware_wallet: hardwareWalletUsed,
hardware_wallet_type: hardwareWalletType,
stx_enabled: smartTransactionsEnabled,
current_stx_enabled: currentSmartTransactionsEnabled,
stx_user_opt_in: smartTransactionsOptInStatus,
Expand Down
41 changes: 22 additions & 19 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5207,14 +5207,16 @@ __metadata:
languageName: node
linkType: hard

"@metamask/eth-json-rpc-provider@npm:^4.0.0":
version: 4.0.0
resolution: "@metamask/eth-json-rpc-provider@npm:4.0.0"
"@metamask/eth-json-rpc-provider@npm:^4.0.0, @metamask/eth-json-rpc-provider@npm:^4.1.0":
version: 4.1.1
resolution: "@metamask/eth-json-rpc-provider@npm:4.1.1"
dependencies:
"@metamask/json-rpc-engine": "npm:^9.0.0"
"@metamask/json-rpc-engine": "npm:^9.0.1"
"@metamask/rpc-errors": "npm:^6.3.1"
"@metamask/safe-event-emitter": "npm:^3.0.0"
"@metamask/utils": "npm:^8.3.0"
checksum: 10/00e87f5d70e044d3dfe7a62ae8c3b530e92dea91de2ad921dee00cd3307fbb1444c5441a05f6178aaf81e3b11f6feeccaa4a8683edf058bf7769c00efeb8915a
"@metamask/utils": "npm:^9.0.0"
uuid: "npm:^8.3.2"
checksum: 10/db2bbf9f2dde2c2551713fd500d3ce1cf7abe90a38b9cd82fdecefd5767143251c6a6b2efe0dced6c87bb014a8f14303b35d8fb96f211fe684e003ef2d16ee73
languageName: node
linkType: hard

Expand Down Expand Up @@ -5526,14 +5528,14 @@ __metadata:
languageName: node
linkType: hard

"@metamask/json-rpc-engine@npm:^9.0.0":
version: 9.0.0
resolution: "@metamask/json-rpc-engine@npm:9.0.0"
"@metamask/json-rpc-engine@npm:^9.0.0, @metamask/json-rpc-engine@npm:^9.0.1":
version: 9.0.2
resolution: "@metamask/json-rpc-engine@npm:9.0.2"
dependencies:
"@metamask/rpc-errors": "npm:^6.2.1"
"@metamask/rpc-errors": "npm:^6.3.1"
"@metamask/safe-event-emitter": "npm:^3.0.0"
"@metamask/utils": "npm:^8.3.0"
checksum: 10/9ddde2ca81e3b3a70e0cc752b5e22e436723cafa1948cbb45d63a42796a1260ff0f9356ebda0d375d9aae81232e77e487a8d0e1273aed3aa83ca0fe3e2f2763f
"@metamask/utils": "npm:^9.1.0"
checksum: 10/1649c0aac59fddf50f995b4b40ec2d90e6c1fa1982a3adfcf984a37daa5bd8db8a3764609f97e88275151815fe49d457f9d30e7f89c43d62d6a0c7db7f867cc0
languageName: node
linkType: hard

Expand Down Expand Up @@ -6204,25 +6206,26 @@ __metadata:
languageName: node
linkType: hard

"@metamask/smart-transactions-controller@npm:^10.1.6":
version: 10.1.6
resolution: "@metamask/smart-transactions-controller@npm:10.1.6"
"@metamask/smart-transactions-controller@npm:^11.0.0":
version: 11.0.0
resolution: "@metamask/smart-transactions-controller@npm:11.0.0"
dependencies:
"@babel/runtime": "npm:^7.24.1"
"@ethereumjs/tx": "npm:^5.2.1"
"@ethereumjs/util": "npm:^9.0.2"
"@ethersproject/bytes": "npm:^5.7.0"
"@metamask/base-controller": "npm:^6.0.0"
"@metamask/controller-utils": "npm:^11.0.0"
"@metamask/eth-json-rpc-provider": "npm:^4.1.0"
"@metamask/eth-query": "npm:^4.0.0"
"@metamask/network-controller": "npm:^19.0.0"
"@metamask/polling-controller": "npm:^8.0.0"
"@metamask/transaction-controller": "npm:^32.0.0"
"@metamask/transaction-controller": "npm:^34.0.0"
bignumber.js: "npm:^9.0.1"
events: "npm:^3.3.0"
fast-json-patch: "npm:^3.1.0"
lodash: "npm:^4.17.21"
checksum: 10/e914a35ba822ad9bad877c9a5f5496b85fbe9b8dc6b682cc46134c18fdfef29fc5cad1af4c8bac4c2feddfe97fbf9b78faa021da0ea08559bdcc05bef3b49d85
checksum: 10/741536fe1524c8c1acfad421e4d17c61500de9f64d7ef97ddccac6e16e830f3e9bbfb5c2b9281082fb2121cec077f3470ce8c40711f3c9524e88275c02e8b821
languageName: node
linkType: hard

Expand Down Expand Up @@ -6563,7 +6566,7 @@ __metadata:
languageName: node
linkType: hard

"@metamask/utils@npm:^9.0.0":
"@metamask/utils@npm:^9.0.0, @metamask/utils@npm:^9.1.0":
version: 9.1.0
resolution: "@metamask/utils@npm:9.1.0"
dependencies:
Expand Down Expand Up @@ -25298,7 +25301,7 @@ __metadata:
"@metamask/scure-bip39": "npm:^2.0.3"
"@metamask/selected-network-controller": "npm:^15.0.2"
"@metamask/signature-controller": "npm:^16.0.0"
"@metamask/smart-transactions-controller": "npm:^10.1.6"
"@metamask/smart-transactions-controller": "npm:^11.0.0"
"@metamask/snaps-controllers": "npm:^9.2.0"
"@metamask/snaps-execution-environments": "npm:^6.5.0"
"@metamask/snaps-rpc-methods": "npm:^9.1.4"
Expand Down

0 comments on commit 0e503c3

Please sign in to comment.