@@ -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,21 @@ 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+ labelInbox = $localize `:@@layout.ariaLabelInbox:Inbox`
30+ notificationTooltipActive = $localize `:@@layout.notificationTooltip:You have unread notifications`
31+ notificationTooltip = $localize `:@@layout.notificationTooltipInactive:Notifications inbox`
2832 isAccountDelegate : boolean
2933 inboxUnread = 0
34+ userJourney ! : 'orcid_with_notifications' | 'orcid_without_notifications'
3035
3136 constructor (
3237 private _router : Router ,
3338 private _userInfo : UserService ,
3439 @Inject ( WINDOW ) private window : Window ,
3540 _platform : PlatformInfoService ,
3641 private _inboxService : InboxService ,
37- private _togglz : TogglzService
42+ private _togglz : TogglzService ,
43+ private observabilityEventService : CustomEventService
3844 ) {
3945 _userInfo . getUserSession ( ) . subscribe ( ( data ) => {
4046 if ( data . loggedIn ) {
@@ -56,15 +62,27 @@ export class UserMenuComponent implements OnInit {
5662 this . _inboxService
5763 . retrieveUnreadCount ( )
5864 . pipe ( first ( ) )
59- . subscribe ( ( inboxUnread ) => ( this . inboxUnread = inboxUnread ) )
65+ . subscribe ( ( inboxUnread ) => {
66+ ; ( this . userJourney =
67+ inboxUnread > 0
68+ ? 'orcid_with_notifications'
69+ : 'orcid_without_notifications' ) ,
70+ this . observabilityEventService . startJourney (
71+ this . userJourney ,
72+
73+ { inboxUnread }
74+ )
75+ this . inboxUnread = inboxUnread
76+ } )
6077 }
6178
62- goto ( url ) {
79+ goto ( url , from ?: string ) {
6380 if ( url === 'my-orcid' ) {
6481 this . _router . navigate ( [ ApplicationRoutes . myOrcid ] )
6582 } else if ( url === 'signin' ) {
6683 this . _router . navigate ( [ ApplicationRoutes . signin ] )
6784 } else if ( url === 'inbox' ) {
85+ this . observabilityEventService . recordEvent ( this . userJourney , from )
6886 this . _router . navigate ( [ ApplicationRoutes . inbox ] )
6987 } else if ( url === 'account' ) {
7088 this . _router . navigate ( [ ApplicationRoutes . account ] )
0 commit comments