Skip to content

Commit

Permalink
feat: state logs in the exported file with app version and build numb…
Browse files Browse the repository at this point in the history
…er (#8768)

## **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**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **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 <NicolasMassart@users.noreply.github.com>
  • Loading branch information
tommasini and NicolasMassart authored Mar 4, 2024
1 parent 41068c9 commit 8222224
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
12 changes: 9 additions & 3 deletions app/components/Views/Settings/AdvancedSettings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
27 changes: 27 additions & 0 deletions app/util/logs/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,39 @@ 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);
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);
expect(logs.includes('appVersion')).toBe(true);
expect(logs.includes('buildNumber')).toBe(true);
});
});

0 comments on commit 8222224

Please sign in to comment.