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

fix: trackevent enabled is undefined #12180

Merged
merged 67 commits into from
Nov 25, 2024

Conversation

NicolasMassart
Copy link
Contributor

@NicolasMassart NicolasMassart commented Nov 5, 2024

Description

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.

Current changes in this PR

  • 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

Related issues

Fixes #12117

Manual testing steps

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

Screenshots/Recordings

events-1.mov
events-2.mov

Before

N/A

After

N/A

Pre-merge author checklist

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.

@NicolasMassart NicolasMassart requested review from a team as code owners November 5, 2024 16:03
@NicolasMassart NicolasMassart self-assigned this Nov 5, 2024
Copy link
Contributor

github-actions bot commented Nov 5, 2024

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@NicolasMassart NicolasMassart added needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) Run Smoke E2E Triggers smoke e2e on Bitrise release-7.35.0 Issue or pull request that will be included in release 7.35.0 and removed team-mobile-platform labels Nov 5, 2024
Copy link
Contributor

github-actions bot commented Nov 5, 2024

https://bitrise.io/ Bitrise

❌❌❌ pr_smoke_e2e_pipeline failed on Bitrise! ❌❌❌

Commit hash: c34c507
Build link: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/379821b0-8f2a-4d77-89aa-e087be7ea3fa

Note

  • You can kick off another pr_smoke_e2e_pipeline on Bitrise by removing and re-applying the Run Smoke E2E label on the pull request

Tip

  • Check the documentation if you have any doubts on how to understand the failure on bitrise

@NicolasMassart NicolasMassart requested review from a team as code owners November 5, 2024 22:18
@NicolasMassart NicolasMassart marked this pull request as draft November 5, 2024 22:19
@NicolasMassart
Copy link
Contributor Author

Converted to draft as I have issues fixing app/components/Views/Settings/SecuritySettings/Sections/MetaMetricsAndDataCollectionSection/MetaMetricsAndDataCollectionSection.test.tsx

@NicolasMassart
Copy link
Contributor Author

We decided to go with not fixing but removing the initial cause (that is the backward compatible multi signature trackEvent), and go with a cleanup and update all calls to use new method with event builder.
All changes in this PR will be reverted after this comment.

Get rid of multiple signatures and backward compat
Update unit tests
@NicolasMassart NicolasMassart force-pushed the fix/12117_trackevent_enabled_undefined branch from dc62720 to e1d4ff5 Compare November 7, 2024 15:50
@NicolasMassart NicolasMassart removed the needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) label Nov 7, 2024
remove useless files
@sethkfman sethkfman marked this pull request as ready for review November 12, 2024 16:37
@sethkfman sethkfman requested review from a team as code owners November 12, 2024 16:37
remove useless files
@NicolasMassart NicolasMassart requested a review from a team as a code owner November 12, 2024 17:46
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 78.57143% with 6 lines in your changes missing coverage. Please review.

Project coverage is 56.35%. Comparing base (b2c9110) to head (962111b).
Report is 22 commits behind head on main.

Files with missing lines Patch % Lines
app/components/UI/AccountOverview/index.js 0.00% 2 Missing ⚠️
app/components/UI/AccountRightButton/index.tsx 50.00% 1 Missing ⚠️
app/components/UI/AddCustomCollectible/index.tsx 50.00% 1 Missing ⚠️
app/components/UI/AssetOverview/AssetOverview.tsx 66.66% 1 Missing ⚠️
...onents/UI/LedgerModals/LedgerConfirmationModal.tsx 83.33% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12180      +/-   ##
==========================================
+ Coverage   56.31%   56.35%   +0.03%     
==========================================
  Files        1786     1789       +3     
  Lines       40375    40495     +120     
  Branches     5060     5071      +11     
==========================================
+ Hits        22738    22819      +81     
- Misses      16088    16129      +41     
+ Partials     1549     1547       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sethkfman sethkfman added the skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. label Nov 22, 2024
@sethkfman sethkfman requested a review from jclancy93 November 22, 2024 22:27
brianacnguyen
brianacnguyen previously approved these changes Nov 23, 2024
@Matt561
Copy link
Contributor

Matt561 commented Nov 24, 2024

@NicolasMassart would it be possible to update the recently added withMetaMetrics high order function to make sure these changes don't break our staking events before release? I suspect the lift is small since it's a single function.

I don't mind adding a fix as part of this PR too if you'd rather I do it! Just let me know.

@NicolasMassart
Copy link
Contributor Author

@NicolasMassart would it be possible to update the recently added withMetaMetrics high order function to make sure these changes don't break our staking events before release? I suspect the lift is small since it's a single function.

I don't mind adding a fix as part of this PR too if you'd rather I do it! Just let me know.

I do not see any reason why this would not work. Your wrapper was already using the new way to call trackEvent.
However, your confidence could be highly improved by simply having a unit test for this withMetaMetrics. So please, write one if you want to make sure your code is not impacted by this or future work.

Copy link
Contributor

@sethkfman sethkfman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
41.3% Coverage on New Code (required ≥ 60%)

See analysis details on SonarQube Cloud

@NicolasMassart NicolasMassart added this pull request to the merge queue Nov 25, 2024
Merged via the queue into main with commit 2506358 Nov 25, 2024
35 of 37 checks passed
@NicolasMassart NicolasMassart deleted the fix/12117_trackevent_enabled_undefined branch November 25, 2024 17:12
@github-actions github-actions bot locked and limited conversation to collaborators Nov 25, 2024
@metamaskbot metamaskbot added the release-7.37.0 Issue or pull request that will be included in release 7.37.0 label Nov 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-7.35.0 Issue or pull request that will be included in release 7.35.0 release-7.37.0 Issue or pull request that will be included in release 7.37.0 Run Smoke E2E Triggers smoke e2e on Bitrise skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. team-mobile-platform
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

[Bug]: metametrics enable value is undefined