mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 01:39:44 +01:00
Detect and track UI customizations on Personal Sign Requests (#16222)
* detect and track ui customizations on personal sign requests * add feature flag check to metrics * clean up comments * get data only if it exists * updated with PR feedback * moved constants * lint * Apply suggestions from code review Co-authored-by: Ariella Vu <20778143+digiwand@users.noreply.github.com> --------- Co-authored-by: Ariella Vu <20778143+digiwand@users.noreply.github.com>
This commit is contained in:
parent
3233f76041
commit
53205b6bff
@ -1,6 +1,12 @@
|
||||
import { MESSAGE_TYPE, ORIGIN_METAMASK } from '../../../shared/constants/app';
|
||||
import { EVENT, EVENT_NAMES } from '../../../shared/constants/metametrics';
|
||||
import { SECOND } from '../../../shared/constants/time';
|
||||
import { detectSIWE } from '../../../shared/modules/siwe';
|
||||
import {
|
||||
EVENT,
|
||||
EVENT_NAMES,
|
||||
METAMETRIC_KEY_OPTIONS,
|
||||
METAMETRIC_KEY,
|
||||
} from '../../../shared/constants/metametrics';
|
||||
|
||||
/**
|
||||
* These types determine how the method tracking middleware handles incoming
|
||||
@ -160,6 +166,16 @@ export default function createRPCMethodTrackingMiddleware({
|
||||
properties.method = method;
|
||||
}
|
||||
|
||||
if (process.env.SIWE_V1 && method === MESSAGE_TYPE.PERSONAL_SIGN) {
|
||||
const data = req?.params?.[0];
|
||||
const { isSIWEMessage } = detectSIWE({ data });
|
||||
if (isSIWEMessage) {
|
||||
properties.ui_customizations = [
|
||||
METAMETRIC_KEY_OPTIONS[METAMETRIC_KEY.UI_CUSTOMIZATIONS].SIWE,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
trackEvent({
|
||||
event,
|
||||
category: EVENT.CATEGORIES.INPAGE_PROVIDER,
|
||||
@ -192,6 +208,16 @@ export default function createRPCMethodTrackingMiddleware({
|
||||
properties.method = method;
|
||||
}
|
||||
|
||||
if (process.env.SIWE_V1 && method === MESSAGE_TYPE.PERSONAL_SIGN) {
|
||||
const data = req?.params?.[0];
|
||||
const { isSIWEMessage } = detectSIWE({ data });
|
||||
if (isSIWEMessage) {
|
||||
properties.ui_customizations = [
|
||||
METAMETRIC_KEY_OPTIONS[METAMETRIC_KEY.UI_CUSTOMIZATIONS].SIWE,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
trackEvent({
|
||||
event,
|
||||
category: EVENT.CATEGORIES.INPAGE_PROVIDER,
|
||||
|
@ -451,3 +451,19 @@ export const EVENT = {
|
||||
export const CONTEXT_PROPS = {
|
||||
PAGE_TITLE: 'location',
|
||||
};
|
||||
|
||||
/**
|
||||
* These types correspond to the keys in the METAMETRIC_KEY_OPTIONS object
|
||||
*/
|
||||
export const METAMETRIC_KEY = {
|
||||
UI_CUSTOMIZATIONS: `ui_customizations`,
|
||||
};
|
||||
|
||||
/**
|
||||
* This object maps a method name to a METAMETRIC_KEY
|
||||
*/
|
||||
export const METAMETRIC_KEY_OPTIONS = {
|
||||
[METAMETRIC_KEY.UI_CUSTOMIZATIONS]: {
|
||||
SIWE: 'sign_in_with_ethereum',
|
||||
},
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user