-
Notifications
You must be signed in to change notification settings - Fork 5k
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
identify desktop is paired in the metrics event #17892
Conversation
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. |
e396ade
to
e5d59e5
Compare
I have read the CLA Document and I hereby sign the CLA |
Builds ready [e5d59e5]
Page Load Metrics (1823 ± 85 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
@worldlyjohn have you been consulted on these changes? |
///: BEGIN:ONLY_INCLUDE_IN(desktop) | ||
desktop_paired: this.getDesktopEnabled(), | ||
///: END:ONLY_INCLUDE_IN |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
desktop_paired seems more like a user trait then a property we want on every event. @worldlyjohn thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reviewing my PR 🙇
If more appropriate I can move it to user traits.
if (typeof trackEvent === 'function') { | ||
trackEvent({ | ||
category: EVENT.CATEGORIES.ERROR, | ||
event: `Error: ${text}`, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we tracking errors in segment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal here was to measure the errors while using the desktop app as a companion but you are right, It is already collected by Sentry and if necessary in Segment, it can be tracked by using the trackPage
method. I will remove it and push the changes.
if (onClick) { | ||
onClick(); | ||
if (typeof trackEvent === 'function') { | ||
trackEvent({ | ||
category: EVENT.CATEGORIES.DESKTOP, | ||
event: `${text} Button Clicked`, | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These types of dynamic event names are not acceptable....They end up creating variadic events that make it very hard to derive meaning from. @worldlyjohn will advise you on if we want this event or not and if so how to add properties to cover the use cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One quick update on this case. I pushed some changes so that instead of using the text it uses the id of the button to determine the event name. In case, more properties need to be added it's possible to extend this function to also include specific properties for each event.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id also not sufficient as it's easy for an element id to change and unintended consequence is the event is now changed too. usually when you want to do this, the best practice is a more generic event name and using this value as a property (though the id field should probably be validated that it matches one element in a predefined set)
Builds ready [f436b74]
Page Load Metrics (1510 ± 50 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [0a8eacb]
Page Load Metrics (1479 ± 35 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
0a8eacb
to
c7a1773
Compare
Builds ready [c7a1773]
Page Load Metrics (1748 ± 79 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [3dee418]
Page Load Metrics (1618 ± 51 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
@@ -61,10 +74,57 @@ export function renderDesktopError({ | |||
); | |||
}; | |||
|
|||
const getEventNameById = (id) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
none of these events follow our naming conventions defined here: https://www.notion.so/Naming-Conventions-95bf27517033451888053f7ab654d327
if (typeof trackEvent === 'function') { | ||
trackEvent({ | ||
category: EVENT.CATEGORIES.DESKTOP, | ||
event: `${getEventNameById(id)} Button Clicked`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using dynamic event names is frowned upon as it will create N new tables. can this be a single event name and use dynamic id (if truely necessary) as a property instead? (though even that is less than ideal, better if you run this through a defined list of possible values)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙏 Great thanks!
I changed it to a single event Desktop Button Clicked
and also included an additional parameter in the renderCTA
that will be the value of the property to identify the CTA performed by the user.
@@ -40,6 +43,10 @@ export default function DesktopEnableButton() { | |||
if (desktopEnabled) { | |||
await disableDesktop(); | |||
setDesktopEnabled(false); | |||
trackEvent({ | |||
category: EVENT.CATEGORIES.DESKTOP, | |||
event: `Disable Desktop Button Clicked`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of separate events for enable/disabled, these should be properties of the same event. another option is that this is actually a setting change.
either of these works:
event name: Desktop Button Clicked
properties: {enabled: true|false}
or
event name: Settings Updated
properties: {desktop_enabled: true|false}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've opted for the settings change as you suggested:
event name: Settings Updated
properties: {desktop_enabled: true|false}
dd78de7
to
380f8b2
Compare
Builds ready [380f8b2]
Page Load Metrics (1667 ± 54 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
380f8b2
to
ca1be4e
Compare
ca1be4e
to
e98a6ee
Compare
Builds ready [e98a6ee]
Page Load Metrics (1501 ± 42 ms)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
works for me! |
Explanation
Adds the metrics code needed to support tracking usage of the MetaMask Desktop app.
The aim of this PR is to identify if the desktop app is paired with the extension on MetaMetrics to track key operations such as swaps, snaps, transfers, and interaction with dapps. It also includes desktop-related events.
Changes include:
metametrics
: includeddesktop_enabled
in traits to identify whenever the user pairs/unpairs the extension and the desktop app.DESKTOP
Manual Testing Steps
desktop_enabled: true
Example:
Pre-merge author checklist
Pre-merge reviewer checklist
If further QA is required (e.g. new feature, complex testing steps, large refactor), add the
Extension QA Board
label.In this case, a QA Engineer approval will be be required.