File tree Expand file tree Collapse file tree 4 files changed +46
-4
lines changed
OverlayManager/Overlay/NavBarOverlayWrapper
components/UI/AccountDropdown
screens/MetaMaskPortfolio Expand file tree Collapse file tree 4 files changed +46
-4
lines changed Original file line number Diff line number Diff line change @@ -416,6 +416,12 @@ export interface ClientUpdateDownloaded {
416
416
sensitiveProperties ?: never
417
417
}
418
418
419
+ export interface AccountDropdownPortfolioClicked {
420
+ event : 'Portfolio Clicked in Account Dropdown'
421
+ properties ?: never
422
+ sensitiveProperties ?: never
423
+ }
424
+
419
425
export type PossibleMetricPayloads =
420
426
| MetricsOptIn
421
427
| MetricsOptOut
@@ -458,5 +464,6 @@ export type PossibleMetricPayloads =
458
464
| PatchingSuccess
459
465
| PatchingFailed
460
466
| PatchingTooSlow
467
+ | AccountDropdownPortfolioClicked
461
468
462
469
export type PossibleMetricEventNames = PossibleMetricPayloads [ 'event' ]
Original file line number Diff line number Diff line change 1
- import React , { useState } from 'react'
1
+ import React , { useEffect , useState } from 'react'
2
2
import styles from './index.module.scss'
3
3
import {
4
4
NavBarOverlay ,
@@ -15,12 +15,22 @@ import { useFlags } from 'launchdarkly-react-client-sdk'
15
15
16
16
export function NavBarOverlayWrapper ( { appName, runner } : BrowserGameProps ) {
17
17
const location = useLocation ( )
18
- const { pathname } = location
18
+ const { pathname, search } = location
19
19
const [ collapsed , setCollapsed ] = useState ( false )
20
20
const { t } = useTranslation ( )
21
21
const comingSoonText = t ( 'overlay.comingSoon' , 'Coming Soon' )
22
22
const flags = useFlags ( )
23
23
24
+ const searchParams = new URLSearchParams ( search )
25
+ const urlQueryParam = searchParams . get ( 'url' )
26
+
27
+ useEffect ( ( ) => {
28
+ window . api . trackScreen ( 'Overlay Page' , {
29
+ pathname : pathname === '/' ? '/quests' : pathname ,
30
+ url : urlQueryParam ?? undefined
31
+ } )
32
+ } , [ pathname ] )
33
+
24
34
const linkItems : NavBarOverlayProps [ 'linkItems' ] = [
25
35
< NavItem
26
36
title = { 'Quests' }
Original file line number Diff line number Diff line change @@ -114,6 +114,11 @@ const WalletDropdown: React.FC = observer(() => {
114
114
? 'topElementWalletDropdown'
115
115
: undefined
116
116
}
117
+ onClick = { async ( ) =>
118
+ window . api . trackEvent ( {
119
+ event : 'Portfolio Clicked in Account Dropdown'
120
+ } )
121
+ }
117
122
>
118
123
< div className = { `body ${ styles . itemContents } ` } >
119
124
{ t ( 'hyperplay.viewPortfolio' , `View portfolio` ) }
Original file line number Diff line number Diff line change 1
- import React , { useRef } from 'react'
1
+ import React , { useEffect , useRef } from 'react'
2
2
import MetaMaskPortfolioStyles from './index.module.scss'
3
3
import { useParams } from 'react-router-dom'
4
4
import { getMetaMaskPortfolioPageUrl } from 'common/constants'
5
+ import { DidNavigateInPageEvent , WebviewTag } from 'electron'
5
6
6
7
const MetaMaskPortfolio = function ( ) {
7
8
const trueAsStr = 'true' as unknown as boolean | undefined
8
9
const { page = '' } = useParams ( ) as { page : string }
9
- const webviewRef = useRef < HTMLWebViewElement > ( null )
10
+ const webviewRef = useRef < WebviewTag > ( null )
11
+
12
+ useEffect ( ( ) => {
13
+ const handleNavigation = ( e : DidNavigateInPageEvent ) => {
14
+ const url = new URL ( e . url )
15
+ window . api . trackScreen ( 'MetaMask Portfolio' , {
16
+ pathname : url . pathname
17
+ } )
18
+ }
19
+ webviewRef . current ?. addEventListener (
20
+ 'did-navigate-in-page' ,
21
+ handleNavigation
22
+ )
23
+ return ( ) => {
24
+ webviewRef . current ?. removeEventListener (
25
+ 'did-navigate-in-page' ,
26
+ handleNavigation
27
+ )
28
+ }
29
+ } , [ webviewRef ] )
10
30
11
31
return (
12
32
< >
You can’t perform that action at this time.
0 commit comments