From 1638f96912c60c6354a479c6e174e268511b53ec Mon Sep 17 00:00:00 2001 From: Mpendulo Ndlovu Date: Mon, 7 Oct 2024 13:05:56 +0200 Subject: [PATCH] fix: fix signature requested analytics (#11595) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** This PR fixes an issue where the `Signature Requested` mobile analytics event was not being sent when a dapp sends a sign request. Only the `Signature Approved` analytics where being sent. Examples: From [MetaMask SDK Wagmi test dapp](https://mmsdk-wagmi-test-dapp.vercel.app) (mobile browser): ``` {"event": "Signature Requested", "properties": {"account_type": "MetaMask", "chain_id": "11155111", "dapp_host_name": "wagmi.io", "request_platform": "web-mobile", "request_source": "MetaMask-SDK-Remote-Conn", "signature_type": "personal_sign", "version": "N/A"}, "type": "track"} ``` From [WalletConnect test dapp](https://appkit-lab.reown.com) (mobile browser): ``` {"event": "Signature Requested", "properties": {"account_type": "MetaMask", "chain_id": "11155111", "dapp_host_name": "appkit-lab.reown.com", "request_platform": undefined, "request_source": "WalletConnect", "signature_type": "eth_signTypedData_v4", "version": "N/A"}, "type": "track"} ``` From iOS SDK test dapp: ``` {"event": "Signature Requested", "properties": {"account_type": "MetaMask", "chain_id": "11155111", "dapp_host_name": "dubdapp.com", "request_platform": "ios", "request_source": "MetaMask-SDK-Remote-Conn", "signature_type": "eth_signTypedData_v4", "version": "N/A"}, "type": "track"} ``` ## **Related issues** Fixes: [SDK-65](https://consensyssoftware.atlassian.net/browse/SDK-65) ## **Manual testing steps** 1. Go to this [mmsdk-wagmi-test-dapp](https://mmsdk-wagmi-test-dapp.vercel.app/) on mobile device 2. Connect to MetaMask 3. Sign message 4. Check the logs that `Signature Requested` is being logged to analytics and also check Segment that the event is being received. ## **Pre-merge author checklist** - [x] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. [SDK-65]: https://consensyssoftware.atlassian.net/browse/SDK-65?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ --- .../components/SignatureRequest/index.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/app/components/Views/confirmations/components/SignatureRequest/index.js b/app/components/Views/confirmations/components/SignatureRequest/index.js index 869e2752ed0..aa1fb6c3db3 100644 --- a/app/components/Views/confirmations/components/SignatureRequest/index.js +++ b/app/components/Views/confirmations/components/SignatureRequest/index.js @@ -214,6 +214,21 @@ class SignatureRequest extends PureComponent { return createStyles(colors); }; + componentDidMount = () => { + const { currentPageInformation, type, fromAddress } = this.props; + + this.props.metrics.trackEvent( + MetaMetricsEvents.SIGNATURE_REQUESTED, + getAnalyticsParams( + { + currentPageInformation, + from: fromAddress, + }, + type, + ), + ); + }; + renderActionViewChildren = () => { const { children,