Feature Highlights: add RS event for nav items (#45470)

This commit is contained in:
Agnès Toulet
2022-02-17 14:20:37 +01:00
committed by GitHub
parent 815ccb1a03
commit 8835020457
3 changed files with 10 additions and 1 deletions

View File

@@ -1,4 +1,4 @@
import React, { ReactElement, useState } from 'react';
import React, { ReactElement, useEffect, useState } from 'react';
import { css, cx } from '@emotion/css';
import { Icon, IconName, Link, useTheme2 } from '@grafana/ui';
import { GrafanaTheme2, NavModelItem } from '@grafana/data';
@@ -13,6 +13,7 @@ import { FocusScope } from '@react-aria/focus';
import { NavBarItemMenuContext } from './context';
import { NavFeatureHighlight } from './NavFeatureHighlight';
import { reportExperimentView } from '@grafana/runtime';
export interface NavBarItemMenuTriggerProps extends MenuTriggerProps {
children: ReactElement;
@@ -34,6 +35,12 @@ export function NavBarItemMenuTrigger(props: NavBarItemMenuTriggerProps): ReactE
const ref = React.useRef<HTMLButtonElement>(null);
const { menuTriggerProps, menuProps } = useMenuTrigger({}, state, ref);
useEffect(() => {
if (item.highlightId) {
reportExperimentView(`feature-highlights-${item.highlightId}-nav`, 'test', '');
}
}, [item.highlightId]);
const { hoverProps } = useHover({
onHoverChange: (isHovering) => {
if (isHovering) {