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: use Segment (batch 1) #8067

Merged
merged 43 commits into from
Feb 20, 2024
Merged

feat: use Segment (batch 1) #8067

merged 43 commits into from
Feb 20, 2024

Conversation

NicolasMassart
Copy link
Contributor

@NicolasMassart NicolasMassart commented Dec 11, 2023

Description

Batch PR to group changes from:

Related issues

Fixes https://github.com/MetaMask/mobile-planning/issues/1129

Manual testing steps

See each PR for details

Screenshots/Recordings

See each PR for details

Before

See each PR for details

After

See each PR for details

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • 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 format if applicable
  • I’ve applied the right labels on the PR (see labeling guidelines). 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.

NicolasMassart and others added 8 commits December 6, 2023 11:14
…proxy (Batch 2 of 4) (#7520)

# What is the reason for the change?
- Implement a new metrics system for the Segment SDK.
- Make it work alongside the old one so that we can remove the old one
progressively.

# What is the improvement/solution?
- Create a new class to handle metrics with segment
- abstract all segment SDK calls
- provide our own user and anonymous Ids for improved privacy
- Reuse the Mixpanel user id it available, otherwise generates a new one
with the same format
- patch Segment SDK to allow the privacy aware user and anonymous Ids
- No event sent at all if user haven't accepted to send metrics info
- Total reset of the infos in case user asks to reset (in settings)
- Ability to disable all metrics
- Ability to ask for deletion of all data

Fixes MetaMask/mobile-planning#1222
…4) (#7990)

- Initialise MetaMetrics on app start without removing Analytics yet as
we still uses it outside of onboarding
- create a `trackAfterInteractions` utility function to reduce code when
tracking events.
- Replace calls to Analytics with calls to `trackAfterInteractions` in
all components involved in onboarding screens (see
[`OnboardingNav`](https://github.com/MetaMask/metamask-mobile/blob/feat%2F1275_segment_onboarding_impl/app/components/Nav/App/index.js#L122-L175)
in `app/components/Nav/App/index.js`)
- Fix onboarding events queue usage in
`app/components/UI/OptinMetrics/index.js`
  - Update Opt-on/Opt-out in onboarding
- Extract Analytics User profil properties in UserProfileMetaData util
and inject it in MetaMetrics identify request alongside device metadata

Fixes MetaMask/mobile-planning#1275
- rename Segment env vars:
  - `SEGMENT_WRITE_KEY`
  - `SEGMENT_PROXY_URL`
- add env var placeholders in example file

Fixes missing variables naming change in
MetaMask/mobile-planning#1222
Copy link
Contributor

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.

Copy link

socket-security bot commented Dec 11, 2023

🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎

To accept the risk, merge this PR and you will not be notified again.

Alert Package NoteSource
New author npm/@stdlib/assert-has-tostringtag-support@0.0.9
New author npm/@stdlib/assert-is-object-like@0.0.8
New author npm/@stdlib/assert-is-regexp-string@0.0.9
New author npm/@stdlib/assert-is-string@0.0.8
New author npm/@stdlib/buffer-from-string@0.0.8
New author npm/@stdlib/constants-float64-exponent-bias@0.0.8
New author npm/@stdlib/constants-float64-high-word-exponent-mask@0.0.8
New author npm/@stdlib/constants-float64-max-base2-exponent@0.0.8
New author npm/@stdlib/constants-float64-max-base2-exponent-subnormal@0.0.8
New author npm/@stdlib/constants-float64-min-base2-exponent-subnormal@0.0.8
New author npm/@stdlib/constants-float64-ninf@0.0.8
New author npm/@stdlib/constants-float64-pinf@0.0.8
New author npm/@stdlib/constants-float64-smallest-normal@0.0.8
New author npm/@stdlib/math-base-napi-unary@0.0.9
New author npm/@stdlib/math-base-special-copysign@0.0.7
New author npm/@stdlib/number-float64-base-to-float32@0.0.7
New author npm/@stdlib/number-float64-base-to-words@0.0.7
New author npm/@stdlib/regexp-regexp@0.0.8
New author npm/@stdlib/string-lowercase@0.0.9
New author npm/@stdlib/string-replace@0.0.11
New author npm/@stdlib/utils-escape-regexp-string@0.0.9
New author npm/@stdlib/utils-regexp-from-string@0.0.9
New author npm/@segment/tsub@2.0.0
Deprecated npm/@segment/analytics-react-native@2.17.0
  • Reason: Version causing issues with RN 0.71+

View full report↗︎

Next steps

What is new author?

A new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.

Scrutinize new collaborator additions to packages because they now have the ability to publish code into your dependency tree. Packages should avoid frequent or unnecessary additions or changes to publishing rights.

What is a deprecated package?

The maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.

Research the state of the package and determine if there are non-deprecated versions that can be used, or if it should be replaced with a new, supported solution.

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of ecosystem/package-name@version specifiers. e.g. @SocketSecurity ignore npm/foo@1.0.0 or ignore all packages with @SocketSecurity ignore-all

  • @SocketSecurity ignore npm/@stdlib/assert-has-tostringtag-support@0.0.9
  • @SocketSecurity ignore npm/@stdlib/assert-is-object-like@0.0.8
  • @SocketSecurity ignore npm/@stdlib/assert-is-regexp-string@0.0.9
  • @SocketSecurity ignore npm/@stdlib/assert-is-string@0.0.8
  • @SocketSecurity ignore npm/@stdlib/buffer-from-string@0.0.8
  • @SocketSecurity ignore npm/@stdlib/constants-float64-exponent-bias@0.0.8
  • @SocketSecurity ignore npm/@stdlib/constants-float64-high-word-exponent-mask@0.0.8
  • @SocketSecurity ignore npm/@stdlib/constants-float64-max-base2-exponent@0.0.8
  • @SocketSecurity ignore npm/@stdlib/constants-float64-max-base2-exponent-subnormal@0.0.8
  • @SocketSecurity ignore npm/@stdlib/constants-float64-min-base2-exponent-subnormal@0.0.8
  • @SocketSecurity ignore npm/@stdlib/constants-float64-ninf@0.0.8
  • @SocketSecurity ignore npm/@stdlib/constants-float64-pinf@0.0.8
  • @SocketSecurity ignore npm/@stdlib/constants-float64-smallest-normal@0.0.8
  • @SocketSecurity ignore npm/@stdlib/math-base-napi-unary@0.0.9
  • @SocketSecurity ignore npm/@stdlib/math-base-special-copysign@0.0.7
  • @SocketSecurity ignore npm/@stdlib/number-float64-base-to-float32@0.0.7
  • @SocketSecurity ignore npm/@stdlib/number-float64-base-to-words@0.0.7
  • @SocketSecurity ignore npm/@stdlib/regexp-regexp@0.0.8
  • @SocketSecurity ignore npm/@stdlib/string-lowercase@0.0.9
  • @SocketSecurity ignore npm/@stdlib/string-replace@0.0.11
  • @SocketSecurity ignore npm/@stdlib/utils-escape-regexp-string@0.0.9
  • @SocketSecurity ignore npm/@stdlib/utils-regexp-from-string@0.0.9
  • @SocketSecurity ignore npm/@segment/tsub@2.0.0
  • @SocketSecurity ignore npm/@segment/analytics-react-native@2.17.0

@NicolasMassart NicolasMassart changed the title Feat: use Segment (batch) feat: use Segment (batch) Dec 12, 2023
@NicolasMassart NicolasMassart added the DO-NOT-MERGE Pull requests that should not be merged label Dec 12, 2023
@codecov-commenter
Copy link

codecov-commenter commented Dec 12, 2023

Codecov Report

Attention: 113 lines in your changes are missing coverage. Please review.

Comparison is base (542af2c) 41.05% compared to head (af34152) 41.44%.
Report is 6 commits behind head on main.

Files Patch % Lines
app/core/Analytics/MetaMetrics.ts 88.19% 11 Missing and 6 partials ⚠️
app/components/UI/OptinMetrics/index.js 0.00% 15 Missing ⚠️
...csMetaData/generateUserProfileAnalyticsMetaData.ts 9.09% 10 Missing ⚠️
app/components/Views/Onboarding/index.js 0.00% 9 Missing ⚠️
...ents/Views/ImportFromSecretRecoveryPhrase/index.js 0.00% 8 Missing ⚠️
...ews/Settings/SecuritySettings/SecuritySettings.tsx 42.85% 8 Missing ⚠️
app/components/Views/ChoosePassword/index.js 0.00% 7 Missing ⚠️
app/components/Views/AccountBackupStep1/index.js 0.00% 6 Missing ⚠️
app/components/Views/OnboardingCarousel/index.js 0.00% 6 Missing ⚠️
...ecuritySettings/Sections/DeleteMetaMetricsData.tsx 66.66% 5 Missing and 1 partial ⚠️
... and 7 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8067      +/-   ##
==========================================
+ Coverage   41.05%   41.44%   +0.38%     
==========================================
  Files        1247     1254       +7     
  Lines       30371    30566     +195     
  Branches     2965     3001      +36     
==========================================
+ Hits        12468    12667     +199     
+ Misses      17158    17146      -12     
- Partials      745      753       +8     

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

NicolasMassart and others added 4 commits December 14, 2023 01:32
# Conflicts:
#	app/components/Views/AccountBackupStep1/index.js
#	app/components/Views/AccountBackupStep1B/index.js
#	app/components/Views/ChoosePassword/index.js
#	app/components/Views/ManualBackupStep1/index.js
#	app/components/Views/ManualBackupStep2/index.js
#	app/components/Views/ManualBackupStep3/index.js
# Conflicts:
#	app/components/Views/Settings/SecuritySettings/SecuritySettings.tsx
@metamaskbot metamaskbot added needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) and removed in-progress labels Jan 9, 2024
@metamaskbot metamaskbot removed the needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) label Jan 10, 2024
@NicolasMassart NicolasMassart marked this pull request as ready for review February 16, 2024 18:29
@NicolasMassart NicolasMassart requested a review from a team as a code owner February 16, 2024 18:29
@github-actions github-actions bot added the Run Smoke E2E Triggers smoke e2e on Bitrise label Feb 16, 2024
Copy link
Contributor

E2E test started on Bitrise: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/88255595-f8ea-4a47-ba22-73df25fca7b2
You can also kick off another Bitrise E2E smoke test by removing and re-applying the (Run Smoke E2E) label

Copy link
Contributor

@tommasini tommasini left a comment

Choose a reason for hiding this comment

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

AMAZING WORK! LGTM! Just left a nit pick that i've found but it's okay to merge it without it!

Copy link
Contributor

@tommasini tommasini left a comment

Choose a reason for hiding this comment

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

Actually it seems that the unit tests are failing! We will need to address that

remove useless async
move log to configure
fix trackEvent param type
update test
tommasini
tommasini previously approved these changes Feb 20, 2024
Copy link
Contributor

@tommasini tommasini 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

sonarcloud bot commented Feb 20, 2024

Copy link
Contributor

@tommasini tommasini left a comment

Choose a reason for hiding this comment

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

LGTM!

@NicolasMassart NicolasMassart changed the title feat: use Segment (batch) feat: use Segment (batch 1) Feb 20, 2024
@NicolasMassart NicolasMassart added needs-smoke-e2e Run Smoke E2E Triggers smoke e2e on Bitrise and removed Run Smoke E2E Triggers smoke e2e on Bitrise labels Feb 20, 2024
Copy link
Contributor

E2E test started on Bitrise: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/0e74e625-dee6-4c29-b021-2756941883f2
You can also kick off another Bitrise E2E smoke test by removing and re-applying the (Run Smoke E2E) label

@NicolasMassart NicolasMassart merged commit 9d6f8ee into main Feb 20, 2024
35 checks passed
@NicolasMassart NicolasMassart deleted the feat/batch_1129_segment branch February 20, 2024 14:36
@github-actions github-actions bot locked and limited conversation to collaborators Feb 20, 2024
@metamaskbot metamaskbot added the release-7.18.0 Issue or pull request that will be included in release 7.18.0 label Feb 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
in-progress needs-smoke-e2e release-7.18.0 Issue or pull request that will be included in release 7.18.0 Run Smoke E2E Triggers smoke e2e on Bitrise team-mobile-platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants