chore: add analytics events for trace funnels (#7638)

This commit is contained in:
Shaheer Kochai 2025-05-19 13:52:35 +04:30 committed by GitHub
parent a0d896557e
commit 88e1e42bf0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 27 additions and 1 deletions

View File

@ -1,6 +1,7 @@
import './TraceDetailV2.styles.scss'; import './TraceDetailV2.styles.scss';
import { Button, Tabs } from 'antd'; import { Button, Tabs } from 'antd';
import logEvent from 'api/common/logEvent';
import ROUTES from 'constants/routes'; import ROUTES from 'constants/routes';
import history from 'lib/history'; import history from 'lib/history';
import { Compass, Cone, TowerControl, Undo } from 'lucide-react'; import { Compass, Cone, TowerControl, Undo } from 'lucide-react';
@ -34,6 +35,7 @@ function NewTraceDetail(props: INewTraceDetailProps): JSX.Element {
history.push(ROUTES.TRACES_EXPLORER); history.push(ROUTES.TRACES_EXPLORER);
} }
if (activeKey === 'funnels') { if (activeKey === 'funnels') {
logEvent('Trace Funnels: visited from trace details page', {});
history.push(ROUTES.TRACES_FUNNELS); history.push(ROUTES.TRACES_FUNNELS);
} }
}} }}

View File

@ -1,6 +1,7 @@
import './StepsContent.styles.scss'; import './StepsContent.styles.scss';
import { Button, Steps } from 'antd'; import { Button, Steps } from 'antd';
import logEvent from 'api/common/logEvent';
import OverlayScrollbar from 'components/OverlayScrollbar/OverlayScrollbar'; import OverlayScrollbar from 'components/OverlayScrollbar/OverlayScrollbar';
import { PlusIcon, Undo2 } from 'lucide-react'; import { PlusIcon, Undo2 } from 'lucide-react';
import { useFunnelContext } from 'pages/TracesFunnels/FunnelContext'; import { useFunnelContext } from 'pages/TracesFunnels/FunnelContext';
@ -28,6 +29,10 @@ function StepsContent({
if (stepWasAdded) { if (stepWasAdded) {
handleReplaceStep(steps.length, span.serviceName, span.name); handleReplaceStep(steps.length, span.serviceName, span.name);
} }
logEvent(
'Trace Funnels: span added for a new step from trace details page',
{},
);
}, [span, handleAddStep, handleReplaceStep, steps.length]); }, [span, handleAddStep, handleReplaceStep, steps.length]);
return ( return (

View File

@ -1,3 +1,4 @@
import logEvent from 'api/common/logEvent';
import { ValidateFunnelResponse } from 'api/traceFunnels'; import { ValidateFunnelResponse } from 'api/traceFunnels';
import { REACT_QUERY_KEY } from 'constants/reactQueryKeys'; import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
import { Time } from 'container/TopNav/DateTimeSelection/config'; import { Time } from 'container/TopNav/DateTimeSelection/config';
@ -152,6 +153,7 @@ export function FunnelProvider({
service_name: serviceName, service_name: serviceName,
span_name: spanName, span_name: spanName,
}); });
logEvent('Trace Funnels: span added (replaced) from trace details page', {});
}, },
[handleStepUpdate], [handleStepUpdate],
); );

View File

@ -1,6 +1,7 @@
import '../RenameFunnel/RenameFunnel.styles.scss'; import '../RenameFunnel/RenameFunnel.styles.scss';
import { Input } from 'antd'; import { Input } from 'antd';
import logEvent from 'api/common/logEvent';
import { AxiosError } from 'axios'; import { AxiosError } from 'axios';
import SignozModal from 'components/SignozModal/SignozModal'; import SignozModal from 'components/SignozModal/SignozModal';
import { REACT_QUERY_KEY } from 'constants/reactQueryKeys'; import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';
@ -11,7 +12,7 @@ import { useSafeNavigate } from 'hooks/useSafeNavigate';
import { Check, X } from 'lucide-react'; import { Check, X } from 'lucide-react';
import { useState } from 'react'; import { useState } from 'react';
import { useQueryClient } from 'react-query'; import { useQueryClient } from 'react-query';
import { generatePath } from 'react-router-dom'; import { generatePath, matchPath, useLocation } from 'react-router-dom';
interface CreateFunnelProps { interface CreateFunnelProps {
isOpen: boolean; isOpen: boolean;
@ -29,6 +30,7 @@ function CreateFunnel({
const { notifications } = useNotifications(); const { notifications } = useNotifications();
const queryClient = useQueryClient(); const queryClient = useQueryClient();
const { safeNavigate } = useSafeNavigate(); const { safeNavigate } = useSafeNavigate();
const { pathname } = useLocation();
const handleCreate = (): void => { const handleCreate = (): void => {
createFunnelMutation.mutate( createFunnelMutation.mutate(
@ -41,6 +43,13 @@ function CreateFunnel({
notifications.success({ notifications.success({
message: 'Funnel created successfully', message: 'Funnel created successfully',
}); });
const eventMessage = matchPath(pathname, ROUTES.TRACE_DETAIL)
? 'Trace Funnels: Funnel created from trace details page'
: 'Trace Funnels: Funnel created from trace funnels list page';
logEvent(eventMessage, {});
setFunnelName(''); setFunnelName('');
queryClient.invalidateQueries([REACT_QUERY_KEY.GET_FUNNELS_LIST]); queryClient.invalidateQueries([REACT_QUERY_KEY.GET_FUNNELS_LIST]);
onClose(data?.payload?.funnel_id); onClose(data?.payload?.funnel_id);

View File

@ -1,5 +1,6 @@
import './TracesModulePage.styles.scss'; import './TracesModulePage.styles.scss';
import logEvent from 'api/common/logEvent';
import RouteTab from 'components/RouteTab'; import RouteTab from 'components/RouteTab';
import { TabRoutes } from 'components/RouteTab/types'; import { TabRoutes } from 'components/RouteTab/types';
import ROUTES from 'constants/routes'; import ROUTES from 'constants/routes';
@ -18,6 +19,12 @@ function TracesModulePage(): JSX.Element {
tracesSaveView, tracesSaveView,
].filter(Boolean) as TabRoutes[]; ].filter(Boolean) as TabRoutes[];
const handleTabChange = (activeRoute: string): void => {
if (activeRoute === ROUTES.TRACES_FUNNELS) {
logEvent('Trace Funnels: visited from trace explorer page', {});
}
};
return ( return (
<div className="traces-module-container"> <div className="traces-module-container">
<RouteTab <RouteTab
@ -26,6 +33,7 @@ function TracesModulePage(): JSX.Element {
pathname.includes(ROUTES.TRACES_FUNNELS) ? ROUTES.TRACES_FUNNELS : pathname pathname.includes(ROUTES.TRACES_FUNNELS) ? ROUTES.TRACES_FUNNELS : pathname
} }
history={history} history={history}
onChangeHandler={handleTabChange}
/> />
</div> </div>
); );