From 520ad057905fa1912c6d7daa2c3ddc20a2be757b Mon Sep 17 00:00:00 2001 From: Brad Decker Date: Tue, 17 Nov 2020 16:49:19 -0600 Subject: [PATCH] fix METAMASK-GH2B (#9900) --- ui/app/contexts/metametrics.new.js | 27 +++++++++++++-------------- ui/app/helpers/constants/routes.js | 2 ++ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/ui/app/contexts/metametrics.new.js b/ui/app/contexts/metametrics.new.js index dd8759458..f8596b796 100644 --- a/ui/app/contexts/metametrics.new.js +++ b/ui/app/contexts/metametrics.new.js @@ -127,7 +127,8 @@ export function MetaMetricsProvider({ children }) { location.pathname.startsWith('/initialize')) || participateInMetaMetrics ) { - // Events that happen during initialization before the user opts into MetaMetrics will be anonymous + // Events that happen during initialization before the user opts into + // MetaMetrics will be anonymous const idTrait = metaMetricsId ? 'userId' : 'anonymousId' const idValue = metaMetricsId ?? METAMETRICS_ANONYMOUS_ID const match = matchPath(location.pathname, { @@ -135,19 +136,15 @@ export function MetaMetricsProvider({ children }) { exact: true, strict: true, }) - // Start by checking for a missing match route. If this falls through to the else if, then we know we - // have a matched route for tracking. + // Start by checking for a missing match route. If this falls through to + // the else if, then we know we have a matched route for tracking. if (!match) { - // We have more specific pages for each type of transaction confirmation - // The user lands on /confirm-transaction first, then is redirected based on - // the contents of state. - if (location.pathname !== '/confirm-transaction') { - // Otherwise we are legitimately missing a matching route - captureMessage(`Segment page tracking found unmatched route`, { + captureMessage(`Segment page tracking found unmatched route`, { + extra: { previousMatch, currentPath: location.pathname, - }) - } + }, + }) } else if ( previousMatch.current !== match.path && !( @@ -156,9 +153,11 @@ export function MetaMetricsProvider({ children }) { previousMatch.current === undefined ) ) { - // When a notification window is open by a Dapp we do not want to track the initial home route load that can - // sometimes happen. To handle this we keep track of the previousMatch, and we skip the event track in the event - // that we are dealing with the initial load of the homepage + // When a notification window is open by a Dapp we do not want to track + // the initial home route load that can sometimes happen. To handle + // this we keep track of the previousMatch, and we skip the event track + // in the event that we are dealing with the initial load of the + // homepage const { path, params } = match const name = PATH_NAME_MAP[path] segment.page({ diff --git a/ui/app/helpers/constants/routes.js b/ui/app/helpers/constants/routes.js index efd09c151..d3b5904c5 100644 --- a/ui/app/helpers/constants/routes.js +++ b/ui/app/helpers/constants/routes.js @@ -99,6 +99,8 @@ const PATH_NAME_MAP = { [`${CONNECT_ROUTE}/:id${CONNECT_CONFIRM_PERMISSIONS_ROUTE}`]: 'Grant Connected Site Permissions Confirmation Page', [CONNECTED_ROUTE]: 'Sites Connected To This Account Page', [CONNECTED_ACCOUNTS_ROUTE]: 'Accounts Connected To This Site Page', + [`${CONFIRM_TRANSACTION_ROUTE}/:id`]: 'Confirmation Root Page', + [CONFIRM_TRANSACTION_ROUTE]: 'Confirmation Root Page', [`${CONFIRM_TRANSACTION_ROUTE}/:id${CONFIRM_TOKEN_METHOD_PATH}`]: 'Confirm Token Method Transaction Page', [`${CONFIRM_TRANSACTION_ROUTE}/:id${CONFIRM_SEND_ETHER_PATH}`]: 'Confirm Send Ether Transaction Page', [`${CONFIRM_TRANSACTION_ROUTE}/:id${CONFIRM_SEND_TOKEN_PATH}`]: 'Confirm Send Token Transaction Page',