core icon indicating copy to clipboard operation
core copied to clipboard

feat(identity): create metametrics event library for profile-sync-controller

Open fabiobozzo opened this issue 7 months ago • 0 comments

Explanation

This PR addresses the issue of magic strings being used inconsistently across MetaMask clients when tracking MetaMetrics events related to profile-sync-controller functionality. Currently, both extension and mobile clients use hardcoded string literals for feature names and actions, leading to inconsistencies (e.g., extension uses 'Backup And Sync' while mobile uses 'Contacts Sync' for the same feature).

The solution creates a centralized MetaMetrics event library within the profile-sync-controller package that exports standardized constants and helper functions. This library provides:

  • ProfileSyncFeatureNames - Constants for all feature names used in profile-sync events
  • ProfileSyncActions - Constants for all action names used in profile-sync events
  • ProfileSyncEventProperties - Pre-built property sets for common events
  • createProfileSyncEventProperties() - Helper function for creating custom event properties

Clients can now import these type-safe constants instead of maintaining their own string definitions.

References

This PR is part of the effort to standardize MetaMetrics event tracking across MetaMask clients and improve maintainability of analytics code.

Changelog

Checklist

  • [x] I've updated the test suite for new or updated code as appropriate
  • [x] I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • [ ] I've communicated my changes to consumers by updating changelogs for packages I've changed, highlighting breaking changes as necessary
  • [ ] I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

fabiobozzo avatar Jun 27 '25 16:06 fabiobozzo