|
|
|
@ -6,6 +6,7 @@ import { ShowModalReactEvent } from '../../../../types/events'; |
|
|
|
|
import appEvents from '../../../app_events'; |
|
|
|
|
import { getFooterLinks } from '../../Footer/Footer'; |
|
|
|
|
import { HelpModal } from '../../help/HelpModal'; |
|
|
|
|
import { MegaMenuState } from '../AppChromeService'; |
|
|
|
|
|
|
|
|
|
export const enrichHelpItem = (helpItem: NavModelItem) => { |
|
|
|
|
let menuItems = helpItem.children || []; |
|
|
|
@ -29,19 +30,19 @@ export const enrichHelpItem = (helpItem: NavModelItem) => { |
|
|
|
|
return helpItem; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
export const enrichWithInteractionTracking = (item: NavModelItem, expandedState: boolean) => { |
|
|
|
|
export const enrichWithInteractionTracking = (item: NavModelItem, megaMenuState: MegaMenuState) => { |
|
|
|
|
// creating a new object here to not mutate the original item object
|
|
|
|
|
const newItem = { ...item }; |
|
|
|
|
const onClick = newItem.onClick; |
|
|
|
|
newItem.onClick = () => { |
|
|
|
|
reportInteraction('grafana_navigation_item_clicked', { |
|
|
|
|
path: newItem.url ?? newItem.id, |
|
|
|
|
state: expandedState ? 'expanded' : 'collapsed', |
|
|
|
|
state: megaMenuState, |
|
|
|
|
}); |
|
|
|
|
onClick?.(); |
|
|
|
|
}; |
|
|
|
|
if (newItem.children) { |
|
|
|
|
newItem.children = newItem.children.map((item) => enrichWithInteractionTracking(item, expandedState)); |
|
|
|
|
newItem.children = newItem.children.map((item) => enrichWithInteractionTracking(item, megaMenuState)); |
|
|
|
|
} |
|
|
|
|
return newItem; |
|
|
|
|
}; |
|
|
|
|