From 822222425b2520ae5af08e313e1f80979b0bf720 Mon Sep 17 00:00:00 2001 From: tommasini <46944231+tommasini@users.noreply.github.com> Date: Mon, 4 Mar 2024 17:04:34 +0000 Subject: [PATCH] feat: state logs in the exported file with app version and build number (#8768) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** Adding the app versions and build number to the state logs txt file ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** IOS sim: https://recordit.co/mvaITSTtQC ### **Before** ### **After** ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've clearly explained what problem this PR is solving and how it is solved. - [ ] I've linked related issues - [ ] I've included manual testing steps - [ ] I've included screenshots/recordings if applicable - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] 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. - [ ] I’ve properly set the pull request status: - [ ] In case it's not yet "ready for review", I've set it to "draft". - [ ] In case it's "ready for review", I've changed it from "draft" to "non-draft". ## **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. --------- Co-authored-by: Nico MASSART --- .../Views/Settings/AdvancedSettings/index.js | 12 ++++++--- app/util/logs/index.test.ts | 27 +++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/app/components/Views/Settings/AdvancedSettings/index.js b/app/components/Views/Settings/AdvancedSettings/index.js index ab5691a2bd5..558e5a31885 100644 --- a/app/components/Views/Settings/AdvancedSettings/index.js +++ b/app/components/Views/Settings/AdvancedSettings/index.js @@ -266,12 +266,18 @@ class AdvancedSettings extends PureComponent { // A not so great way to copy objects by value try { - const data = generateStateLogs(fullState); + const stateLogsWithReleaseDetails = generateStateLogs({ + ...fullState, + appVersion, + buildNumber, + }); - let url = `data:text/plain;base64,${new Buffer(data).toString('base64')}`; + let url = `data:text/plain;base64,${new Buffer( + stateLogsWithReleaseDetails, + ).toString('base64')}`; // // Android accepts attachements as BASE64 if (Device.isIos()) { - await RNFS.writeFile(path, data, 'utf8'); + await RNFS.writeFile(path, stateLogsWithReleaseDetails, 'utf8'); url = path; } diff --git a/app/util/logs/index.test.ts b/app/util/logs/index.test.ts index b29a3eacb70..67ace4168ef 100644 --- a/app/util/logs/index.test.ts +++ b/app/util/logs/index.test.ts @@ -24,6 +24,31 @@ describe('logs :: generateStateLogs', () => { }, }; const logs = generateStateLogs(mockStateInput); + + expect(logs.includes('NftController')).toBe(false); + expect(logs.includes('TokensController')).toBe(false); + expect(logs.includes('AssetsContractController')).toBe(false); + expect(logs.includes('TokenDetectionController')).toBe(false); + expect(logs.includes('NftDetectionController')).toBe(false); + expect(logs.includes('PhishingController')).toBe(false); + expect(logs.includes("vault: 'vault mock'")).toBe(false); + }); + + it('generates extra logs if values added to the state object parameter', () => { + const mockStateInput = { + appVersion: '1', + buildNumber: '123', + engine: { + backgroundState: { + ...initialBackgroundState, + KeyringController: { + vault: 'vault mock', + }, + }, + }, + }; + const logs = generateStateLogs(mockStateInput); + expect(logs.includes('NftController')).toBe(false); expect(logs.includes('TokensController')).toBe(false); expect(logs.includes('AssetsContractController')).toBe(false); @@ -31,5 +56,7 @@ describe('logs :: generateStateLogs', () => { expect(logs.includes('NftDetectionController')).toBe(false); expect(logs.includes('PhishingController')).toBe(false); expect(logs.includes("vault: 'vault mock'")).toBe(false); + expect(logs.includes('appVersion')).toBe(true); + expect(logs.includes('buildNumber')).toBe(true); }); });