@@ -9,6 +9,7 @@ import { ApplicationRoutes } from 'src/app/constants'
99import { TogglzService } from 'src/app/core/togglz/togglz.service'
1010import { InboxService } from '../../core/inbox/inbox.service'
1111import { first } from 'rxjs/operators'
12+ import { CustomEventService } from 'src/app/core/observability-events/observability-events.service'
1213
1314@Component ( {
1415 selector : 'app-user-menu' ,
@@ -25,16 +26,20 @@ export class UserMenuComponent implements OnInit {
2526 platform : PlatformInfo
2627 labelSigninRegister = $localize `:@@layout.ariaLabelSigninRegister:Sign in to ORCID or register for your ORCID iD`
2728 labelUserMenu = $localize `:@@layout.ariaLabelUserMenu:User menu`
29+ notificationTooltipActive = $localize `:@@layout.notificationTooltip:You have unread notifications`
30+ notificationTooltip = $localize `:@@layout.notificationTooltipInactive:Notifications inbox`
2831 isAccountDelegate : boolean
2932 inboxUnread = 0
33+ userJourney ! : 'orcid_with_notifications' | 'orcid_without_notifications'
3034
3135 constructor (
3236 private _router : Router ,
3337 private _userInfo : UserService ,
3438 @Inject ( WINDOW ) private window : Window ,
3539 _platform : PlatformInfoService ,
3640 private _inboxService : InboxService ,
37- private _togglz : TogglzService
41+ private _togglz : TogglzService ,
42+ private observabilityEventService : CustomEventService
3843 ) {
3944 _userInfo . getUserSession ( ) . subscribe ( ( data ) => {
4045 if ( data . loggedIn ) {
@@ -56,15 +61,27 @@ export class UserMenuComponent implements OnInit {
5661 this . _inboxService
5762 . retrieveUnreadCount ( )
5863 . pipe ( first ( ) )
59- . subscribe ( ( inboxUnread ) => ( this . inboxUnread = inboxUnread ) )
64+ . subscribe ( ( inboxUnread ) => {
65+ ; ( this . userJourney =
66+ inboxUnread > 0
67+ ? 'orcid_with_notifications'
68+ : 'orcid_without_notifications' ) ,
69+ this . observabilityEventService . startJourney (
70+ this . userJourney ,
71+
72+ { inboxUnread }
73+ )
74+ this . inboxUnread = inboxUnread
75+ } )
6076 }
6177
62- goto ( url ) {
78+ goto ( url , from ?: string ) {
6379 if ( url === 'my-orcid' ) {
6480 this . _router . navigate ( [ ApplicationRoutes . myOrcid ] )
6581 } else if ( url === 'signin' ) {
6682 this . _router . navigate ( [ ApplicationRoutes . signin ] )
6783 } else if ( url === 'inbox' ) {
84+ this . observabilityEventService . recordEvent ( this . userJourney , from )
6885 this . _router . navigate ( [ ApplicationRoutes . inbox ] )
6986 } else if ( url === 'account' ) {
7087 this . _router . navigate ( [ ApplicationRoutes . account ] )
0 commit comments