Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: v7.36.0 #12314

Merged
merged 20 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
4787841
Update changelog for 7.36.0 release
sethkfman Nov 16, 2024
c6362ff
Bump version number to 1501
metamaskbot Nov 16, 2024
642e534
bump semver 7.36.0 android
sethkfman Nov 16, 2024
b7ac57e
chore: Cherry pick f35d583 (#12343)
sethkfman Nov 19, 2024
44843ad
chore(runway): cherry-pick fix: tags pending approvals receiving unde…
runway-github[bot] Nov 20, 2024
4114259
chore: cherrypick do not show staked eth balance when balance is zero…
nickewansmith Nov 20, 2024
8d02f7d
fix: fix missing variable patch (#12402)
sahar-fehri Nov 22, 2024
e618c25
chore(runway): cherry-pick fix: breaking selector due to missing cont…
runway-github[bot] Nov 25, 2024
5bd749c
chore: Cherry pick 2506358 (merge in trackEvent work) (#12415)
Nov 25, 2024
eed3576
Bump version number to 1503
metamaskbot Nov 25, 2024
1b670f5
[chore] Merge in feat: updated staking events to use withMetaMetrics …
Nov 26, 2024
c7ddd29
chore(runway): cherry-pick fix: update wallet_addEthereumChain.js wit…
runway-github[bot] Nov 26, 2024
9437aa2
Bump version number to 1504
metamaskbot Nov 26, 2024
b6868d6
Bump version number to 1505
metamaskbot Nov 27, 2024
92f1d99
chore(runway): cherry-pick fix: gas fee edit from swaps (#12471)
runway-github[bot] Nov 27, 2024
3e52404
sync with main
sethkfman Dec 4, 2024
66ce567
revert additional changes
sethkfman Dec 4, 2024
f490835
fixed xcode proj changes
sethkfman Dec 4, 2024
16a77da
Update Attributions
metamaskbot Dec 4, 2024
c7a17fc
remove notification formating
sethkfman Dec 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: Cherry pick 2506358 (merge in trackEvent work) (#12415)
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

> [!IMPORTANT]
> The issue is due to the fact that `MetaMetrics.trackEvent` method has
multiple signatures to handle the backward compatibility with old ways
to call it.
> After discussion (see the change history of this description), we
decided to remove backward compatibility and the multiple signature
system. We are going to simplify and then fix all the `trackEvent`
calls.
Asside from the changes in `MetaMetrics` and `useMetrics` hook (and
tests) all the changes should be on the calls of `trackEvent`.

- removes multiple signature `MetaMetrics.trackEvent`
- updates `MetaMetrics` unit tests
- updates `useMetrics` hook
- updates `useMetrics` hook unit tests
- deletes now useless legacy compatibility utils
- updates all `trackEvent` calls
- updates all unit tests that test `trackEvent` calls

Fixes #12117

1. navigate the app
2. check trackEvent is called (check app logs)


https://github.com/user-attachments/assets/058f6607-eda1-4eb5-bcae-a774deb13648


https://github.com/user-attachments/assets/fa0816cf-5459-4825-a162-a9a2e87c86ac

N/A

N/A

- [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
- [x] I’ve included tests if applicable
- [x] 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.

- [ ] 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.

---------

<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

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

---------

Co-authored-by: Nico MASSART <NicolasMassart@users.noreply.github.com>
Co-authored-by: Frank von Hoven <141057783+frankvonhoven@users.noreply.github.com>
Co-authored-by: Frank von Hoven <frank.vonhoven@consensys.net>
  • Loading branch information
4 people authored Nov 25, 2024
commit 5bd749cb89987be24e224bef61868fb326663c63
6 changes: 3 additions & 3 deletions app/actions/onboarding/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { IMetaMetricsEvent } from '../../core/Analytics';
import { ITrackingEvent } from '../../core/Analytics/MetaMetrics.types';

export const SAVE_EVENT = 'SAVE_EVENT';
export const CLEAR_EVENTS = 'CLEAR_EVENTS';

interface SaveEventAction {
type: typeof SAVE_EVENT;
event: [IMetaMetricsEvent];
event: [ITrackingEvent];
}

interface ClearEventsAction {
Expand All @@ -15,7 +15,7 @@ interface ClearEventsAction {
export type OnboardingActionTypes = SaveEventAction | ClearEventsAction;

export function saveOnboardingEvent(
eventArgs: [IMetaMetricsEvent],
eventArgs: [ITrackingEvent],
): SaveEventAction {
return {
type: SAVE_EVENT,
Expand Down
24 changes: 18 additions & 6 deletions app/component-library/components/Navigation/TabBar/TabBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import OnboardingWizard from '../../../../components/UI/OnboardingWizard';

const TabBar = ({ state, descriptors, navigation }: TabBarProps) => {
const { colors } = useTheme();
const { trackEvent } = useMetrics();
const { trackEvent, createEventBuilder } = useMetrics();
const { bottom: bottomInset } = useSafeAreaInsets();
const { styles } = useStyles(styleSheet, { bottomInset });
const chainId = useSelector(selectChainId);
Expand Down Expand Up @@ -73,10 +73,14 @@ const TabBar = ({ state, descriptors, navigation }: TabBarProps) => {
navigation.navigate(Routes.MODAL.ROOT_MODAL_FLOW, {
screen: Routes.MODAL.WALLET_ACTIONS,
});
trackEvent(MetaMetricsEvents.ACTIONS_BUTTON_CLICKED, {
text: '',
chain_id: getDecimalChainId(chainId),
});
trackEvent(
createEventBuilder(MetaMetricsEvents.ACTIONS_BUTTON_CLICKED)
.addProperties({
text: '',
chain_id: getDecimalChainId(chainId),
})
.build(),
);
break;
case Routes.BROWSER_VIEW:
navigation.navigate(Routes.BROWSER.HOME, {
Expand Down Expand Up @@ -124,7 +128,15 @@ const TabBar = ({ state, descriptors, navigation }: TabBarProps) => {
/>
);
},
[state, descriptors, navigation, colors, chainId, trackEvent],
[
state,
descriptors,
navigation,
colors,
chainId,
trackEvent,
createEventBuilder,
],
);

const renderTabBarItems = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { MetaMetricsEvents } from '../../../core/Analytics';
import { backgroundState } from '../../../util/test/initial-root-state';
import { render } from '@testing-library/react-native';
import { useMetrics } from '../../../components/hooks/useMetrics';
import { MetricsEventBuilder } from '../../../core/Analytics/MetricsEventBuilder';

jest.mock('../../Views/confirmations/hooks/useApprovalRequest');
jest.mock('../../../components/hooks/useMetrics');
Expand Down Expand Up @@ -68,22 +69,23 @@ const mockSelectorState = (state: any) => {

const mockTrackEvent = jest.fn();

(useMetrics as jest.MockedFn<typeof useMetrics>).mockReturnValue({
trackEvent: mockTrackEvent,
createEventBuilder: MetricsEventBuilder.createEventBuilder,
enable: jest.fn(),
addTraitsToUser: jest.fn(),
createDataDeletionTask: jest.fn(),
checkDataDeleteStatus: jest.fn(),
getDeleteRegulationCreationDate: jest.fn(),
getDeleteRegulationId: jest.fn(),
isDataRecorded: jest.fn(),
isEnabled: jest.fn(),
getMetaMetricsId: jest.fn(),
});

describe('PermissionApproval', () => {
beforeEach(() => {
jest.resetAllMocks();
(useMetrics as jest.MockedFn<typeof useMetrics>).mockReturnValue({
trackEvent: mockTrackEvent,
createEventBuilder: jest.fn(),
enable: jest.fn(),
addTraitsToUser: jest.fn(),
createDataDeletionTask: jest.fn(),
checkDataDeleteStatus: jest.fn(),
getDeleteRegulationCreationDate: jest.fn(),
getDeleteRegulationId: jest.fn(),
isDataRecorded: jest.fn(),
isEnabled: jest.fn(),
getMetaMetricsId: jest.fn(),
});
jest.clearAllMocks();
});

it('navigates', async () => {
Expand Down Expand Up @@ -143,14 +145,17 @@ describe('PermissionApproval', () => {

render(<PermissionApproval navigation={navigationMock} />);

expect(mockTrackEvent).toHaveBeenCalledTimes(1);
expect(mockTrackEvent).toHaveBeenCalledWith(
const expectedEvent = MetricsEventBuilder.createEventBuilder(
MetaMetricsEvents.CONNECT_REQUEST_STARTED,
{
)
.addProperties({
number_of_accounts: 3,
source: 'PERMISSION SYSTEM',
},
);
})
.build();

expect(mockTrackEvent).toHaveBeenCalledTimes(1);
expect(mockTrackEvent).toHaveBeenCalledWith(expectedEvent);
});

it('does not navigate if no approval request', async () => {
Expand Down
22 changes: 16 additions & 6 deletions app/components/Approvals/PermissionApproval/PermissionApproval.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface PermissionApprovalProps {
}

const PermissionApproval = (props: PermissionApprovalProps) => {
const { trackEvent } = useMetrics();
const { trackEvent, createEventBuilder } = useMetrics();
const { approvalRequest } = useApprovalRequest();
const totalAccounts = useSelector(selectAccountsLength);
const isProcessing = useRef<boolean>(false);
Expand All @@ -38,18 +38,28 @@ const PermissionApproval = (props: PermissionApprovalProps) => {

isProcessing.current = true;

trackEvent(MetaMetricsEvents.CONNECT_REQUEST_STARTED, {
number_of_accounts: totalAccounts,
source: 'PERMISSION SYSTEM',
});
trackEvent(
createEventBuilder(MetaMetricsEvents.CONNECT_REQUEST_STARTED)
.addProperties({
number_of_accounts: totalAccounts,
source: 'PERMISSION SYSTEM',
})
.build(),
);

props.navigation.navigate(
...createAccountConnectNavDetails({
hostInfo: requestData,
permissionRequestId: id,
}),
);
}, [approvalRequest, totalAccounts, props.navigation, trackEvent]);
}, [
approvalRequest,
totalAccounts,
props.navigation,
trackEvent,
createEventBuilder,
]);

return null;
};
Expand Down
44 changes: 30 additions & 14 deletions app/components/Nav/Main/MainNavigator.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ const SettingsFlow = () => (
);

const HomeTabs = () => {
const { trackEvent } = useMetrics();
const { trackEvent, createEventBuilder } = useMetrics();
const drawerRef = useRef(null);
const [isKeyboardHidden, setIsKeyboardHidden] = useState(true);

Expand Down Expand Up @@ -439,10 +439,14 @@ const HomeTabs = () => {
home: {
tabBarIconKey: TabBarIconKey.Wallet,
callback: () => {
trackEvent(MetaMetricsEvents.WALLET_OPENED, {
number_of_accounts: accountsLength,
chain_id: getDecimalChainId(chainId),
});
trackEvent(
createEventBuilder(MetaMetricsEvents.WALLET_OPENED)
.addProperties({
number_of_accounts: accountsLength,
chain_id: getDecimalChainId(chainId),
})
.build(),
);
},
rootScreenName: Routes.WALLET_VIEW,
},
Expand All @@ -453,27 +457,39 @@ const HomeTabs = () => {
browser: {
tabBarIconKey: TabBarIconKey.Browser,
callback: () => {
trackEvent(MetaMetricsEvents.BROWSER_OPENED, {
number_of_accounts: accountsLength,
chain_id: getDecimalChainId(chainId),
source: 'Navigation Tab',
active_connected_dapp: activeConnectedDapp,
number_of_open_tabs: amountOfBrowserOpenTabs,
});
trackEvent(
createEventBuilder(MetaMetricsEvents.BROWSER_OPENED)
.addProperties({
number_of_accounts: accountsLength,
chain_id: getDecimalChainId(chainId),
source: 'Navigation Tab',
active_connected_dapp: activeConnectedDapp,
number_of_open_tabs: amountOfBrowserOpenTabs,
})
.build(),
);
},
rootScreenName: Routes.BROWSER_VIEW,
},
activity: {
tabBarIconKey: TabBarIconKey.Activity,
callback: () => {
trackEvent(MetaMetricsEvents.NAVIGATION_TAPS_TRANSACTION_HISTORY);
trackEvent(
createEventBuilder(
MetaMetricsEvents.NAVIGATION_TAPS_TRANSACTION_HISTORY,
).build(),
);
},
rootScreenName: Routes.TRANSACTIONS_VIEW,
},
settings: {
tabBarIconKey: TabBarIconKey.Setting,
callback: () => {
trackEvent(MetaMetricsEvents.NAVIGATION_TAPS_SETTINGS);
trackEvent(
createEventBuilder(
MetaMetricsEvents.NAVIGATION_TAPS_SETTINGS,
).build(),
);
},
rootScreenName: Routes.SETTINGS_VIEW,
unmountOnBlur: true,
Expand Down
32 changes: 25 additions & 7 deletions app/components/Nav/Main/RootRPCMethodsUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export const useSwapConfirmedEvent = ({ trackSwaps }) => {
};

const RootRPCMethodsUI = (props) => {
const { trackEvent } = useMetrics();
const { trackEvent, createEventBuilder } = useMetrics();
const [transactionModalType, setTransactionModalType] = useState(undefined);
const tokenList = useSelector(selectTokenList);
const setTransactionObject = props.setTransactionObject;
Expand Down Expand Up @@ -241,15 +241,28 @@ const RootRPCMethodsUI = (props) => {

Logger.log('Swaps', 'Sending metrics event', event);

trackEvent(event, { sensitiveProperties: { ...parameters } });
trackEvent(
createEventBuilder(event)
.addSensitiveProperties({ ...parameters })
.build(),
);
} catch (e) {
Logger.error(e, MetaMetricsEvents.SWAP_TRACKING_FAILED);
trackEvent(MetaMetricsEvents.SWAP_TRACKING_FAILED, {
error: e,
});
trackEvent(
createEventBuilder(MetaMetricsEvents.SWAP_TRACKING_FAILED)
.addProperties({
error: e,
})
.build(),
);
}
},
[props.selectedAddress, props.shouldUseSmartTransaction, trackEvent],
[
props.selectedAddress,
props.shouldUseSmartTransaction,
trackEvent,
createEventBuilder,
],
);

const { addTransactionMetaIdForListening } = useSwapConfirmedEvent({
Expand Down Expand Up @@ -323,7 +336,11 @@ const RootRPCMethodsUI = (props) => {
);
Logger.error(error, 'error while trying to send transaction (Main)');
} else {
trackEvent(MetaMetricsEvents.QR_HARDWARE_TRANSACTION_CANCELED);
trackEvent(
createEventBuilder(
MetaMetricsEvents.QR_HARDWARE_TRANSACTION_CANCELED,
).build(),
);
}
}
},
Expand All @@ -333,6 +350,7 @@ const RootRPCMethodsUI = (props) => {
trackEvent,
swapsTransactions,
addTransactionMetaIdForListening,
createEventBuilder,
],
);

Expand Down
Loading
Loading