Skip to content

Commit

Permalink
fix: tags pending approvals receiving undefined (#12331)
Browse files Browse the repository at this point in the history
## **Description**

Fix this:
https://metamask.sentry.io/issues/6063420089/events/d1047fbf9e814a6d9fc0c86bf2115f2a/?project=2299799&referrer=previous-event

`selectPendingApprovals` may return undefined, and when we do
`Object.values(undefined)` a error is thrown

## **Related issues**

Fixes:

## **Manual testing steps**

1. Go to this page...
2.
3.

## **Screenshots/Recordings**

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

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

### **After**

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

## **Pre-merge author checklist**

- [ ] 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).
- [ ] 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
- [ ] 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.
  • Loading branch information
tommasini authored Nov 19, 2024
1 parent 1bfc731 commit 35212ec
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/util/sentry/tags/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export function getTraceTags(state: RootState) {
if (!state?.engine?.backgroundState?.TokensController) return;
if (!state?.engine?.backgroundState?.TransactionController) return;
if (!state?.engine?.backgroundState?.NotificationServicesController) return;
if (!state?.engine?.backgroundState?.ApprovalController) return;
if (!Object.keys(state?.engine?.backgroundState).length) return;

const unlocked = state.user.userLoggedIn;
Expand All @@ -21,9 +22,10 @@ export function getTraceTags(state: RootState) {
const notificationCount = getNotificationsList(state).length;
const tokenCount = selectAllTokensFlat(state).length;
const transactionCount = selectTransactions(state).length;
const pendingApprovals = Object.values(selectPendingApprovals(state));
const pendingApprovals = selectPendingApprovals(state);
const pendingApprovalsValues = Object.values(pendingApprovals ?? {});

const firstApprovalType = pendingApprovals?.[0]?.type;
const firstApprovalType = pendingApprovalsValues?.[0]?.type;

return {
'wallet.account_count': accountCount,
Expand Down

0 comments on commit 35212ec

Please sign in to comment.