SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
chore: trace funnels bugfixes/improvements (#8114)
Shaheer Kochai53f9e7d81134
diff --git a/frontend/src/api/traceFunnels/index.ts b/frontend/src/api/traceFunnels/index.tsindex ee78e744f3..d1cb0a2057 100644--- a/frontend/src/api/traceFunnels/index.ts+++ b/frontend/src/api/traceFunnels/index.ts@@ -196,8 +196,6 @@ export interface FunnelOverviewResponse {avg_rate: number;conversion_rate: number | null;errors: number;- // TODO(shaheer): remove p99_latency once we have support for latency- p99_latency: number;latency: number;};}>;diff --git a/frontend/src/container/TraceWaterfall/AddSpanToFunnelModal/AddSpanToFunnelModal.styles.scss b/frontend/src/container/TraceWaterfall/AddSpanToFunnelModal/AddSpanToFunnelModal.styles.scssindex 7ad5314548..1e90d6b50b 100644--- a/frontend/src/container/TraceWaterfall/AddSpanToFunnelModal/AddSpanToFunnelModal.styles.scss+++ b/frontend/src/container/TraceWaterfall/AddSpanToFunnelModal/AddSpanToFunnelModal.styles.scss@@ -16,11 +16,51 @@&-body {padding: 14px 16px !important;+ padding-bottom: 0 !important;+ border-bottom-left-radius: 0;+ border-bottom-right-radius: 0;}- }- &--details {- .ant-modal-content {- height: 710px;++ &-footer {+ margin-top: 0;+ background: var(--bg-ink-400);+ border-top: 1px solid var(--bg-slate-500);+ padding: 16px !important;+ .add-span-to-funnel-modal {+ &__save-button {+ display: flex;+ align-items: center;+ justify-content: center;+ gap: 4px;+ color: var(--bg-vanilla-100);+ font-size: 12px;+ font-weight: 500;+ line-height: 24px;+ width: 135px;++ .ant-btn-icon {+ display: flex;+ }+ &:disabled {+ color: var(--bg-vanilla-400);+ .ant-btn-icon {+ svg {+ stroke: var(--bg-vanilla-400);+ }+ }+ }+ }+ &__discard-button {+ background: var(--bg-slate-500);+ }+ }+ .ant-btn {+ border-radius: 2px;+ padding: 4px 8px;+ margin: 0 !important;+ border: none;+ box-shadow: none;+ }}}}diff --git a/frontend/src/container/TraceWaterfall/AddSpanToFunnelModal/AddSpanToFunnelModal.tsx b/frontend/src/container/TraceWaterfall/AddSpanToFunnelModal/AddSpanToFunnelModal.tsxindex 5d54541cec..4e4f89c558 100644--- a/frontend/src/container/TraceWaterfall/AddSpanToFunnelModal/AddSpanToFunnelModal.tsx+++ b/frontend/src/container/TraceWaterfall/AddSpanToFunnelModal/AddSpanToFunnelModal.tsx@@ -9,14 +9,18 @@ import {useFunnelDetails,useFunnelsList,} from 'hooks/TracesFunnels/useFunnels';-import { ArrowLeft, Plus, Search } from 'lucide-react';+import { isEqual } from 'lodash-es';+import { ArrowLeft, Check, Plus, Search } from 'lucide-react';import FunnelConfiguration from 'pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelConfiguration';import { TracesFunnelsContentRenderer } from 'pages/TracesFunnels';import CreateFunnel from 'pages/TracesFunnels/components/CreateFunnel/CreateFunnel';import { FunnelListItem } from 'pages/TracesFunnels/components/FunnelsList/FunnelsList';-import { FunnelProvider } from 'pages/TracesFunnels/FunnelContext';+import {+ FunnelProvider,+ useFunnelContext,+} from 'pages/TracesFunnels/FunnelContext';import { filterFunnelsByQuery } from 'pages/TracesFunnels/utils';-import { ChangeEvent, useMemo, useState } from 'react';+import { ChangeEvent, useEffect, useMemo, useState } from 'react';import { Span } from 'types/api/trace/getTraceV2';import { FunnelData } from 'types/api/traceFunnels';@@ -28,10 +32,35 @@ enum ModalView {function FunnelDetailsView({funnel,span,+ triggerAutoSave,+ showNotifications,+ onChangesDetected,+ triggerDiscard,}: {funnel: FunnelData;span: Span;+ triggerAutoSave: boolean;+ showNotifications: boolean;+ onChangesDetected: (hasChanges: boolean) => void;+ triggerDiscard: boolean;}): JSX.Element {+ const { handleRestoreSteps, steps } = useFunnelContext();++ // Track changes between current steps and original steps+ useEffect(() => {+ const hasChanges = !isEqual(steps, funnel.steps);+ if (onChangesDetected) {+ onChangesDetected(hasChanges);+ }+ }, [steps, funnel.steps, onChangesDetected]);++ // Handle discard when triggered from parent+ useEffect(() => {+ if (triggerDiscard && funnel.steps) {+ handleRestoreSteps(funnel.steps);+ }+ }, [triggerDiscard, funnel.steps, handleRestoreSteps]);+return (<div className="add-span-to-funnel-modal__details"><FunnelListItem@@ -39,10 +68,18 @@ function FunnelDetailsView({shouldRedirectToTracesListOnDeleteSuccess={false}isSpanDetailsPage/>- <FunnelConfiguration funnel={funnel} isTraceDetailsPage span={span} />+ <FunnelConfiguration+ funnel={funnel}+ isTraceDetailsPage+ span={span}+ disableAutoSave+ triggerAutoSave={triggerAutoSave}+ showNotifications={showNotifications}+ /></div>);}+interface AddSpanToFunnelModalProps {isOpen: boolean;onClose: () => void;@@ -60,6 +97,9 @@ function AddSpanToFunnelModal({undefined,);const [isCreateModalOpen, setIsCreateModalOpen] = useState<boolean>(false);+ const [triggerSave, setTriggerSave] = useState<boolean>(false);+ const [isUnsavedChanges, setIsUnsavedChanges] = useState<boolean>(false);+ const [triggerDiscard, setTriggerDiscard] = useState<boolean>(false);const handleSearch = (e: ChangeEvent<HTMLInputElement>): void => {setSearchQuery(e.target.value);@@ -92,12 +132,26 @@ function AddSpanToFunnelModal({const handleBack = (): void => {setActiveView(ModalView.LIST);setSelectedFunnelId(undefined);+ setIsUnsavedChanges(false);+ setTriggerSave(false);};const handleCreateNewClick = (): void => {setIsCreateModalOpen(true);};+ const handleSaveFunnel = (): void => {+ setTriggerSave(true);+ // Reset trigger after a brief moment to allow the save to be processed+ setTimeout(() => setTriggerSave(false), 100);+ };++ const handleDiscard = (): void => {+ setTriggerDiscard(true);+ // Reset trigger after a brief moment+ setTimeout(() => setTriggerDiscard(false), 100);+ };+const renderListView = (): JSX.Element => (<div className="add-span-to-funnel-modal">{!!filteredData?.length && (@@ -156,7 +210,14 @@ function AddSpanToFunnelModal({<div className="traces-funnel-details__steps-config">{selectedFunnelId && funnelDetails?.payload && (<FunnelProvider funnelId={selectedFunnelId}>- <FunnelDetailsView funnel={funnelDetails.payload} span={span} />+ <FunnelDetailsView+ funnel={funnelDetails.payload}+ span={span}+ triggerAutoSave={triggerSave}+ showNotifications+ onChangesDetected={setIsUnsavedChanges}+ triggerDiscard={triggerDiscard}+ /></FunnelProvider>)}</div>@@ -175,18 +236,43 @@ function AddSpanToFunnelModal({'add-span-to-funnel-modal-container--details':activeView === ModalView.DETAILS,})}- okText="Save Funnel"footer={- activeView === ModalView.LIST && !!filteredData?.length ? (- <Button- type="default"- className="add-span-to-funnel-modal__create-button"- onClick={handleCreateNewClick}- icon={<Plus size={14} />}- >- Create new funnel- </Button>- ) : null+ activeView === ModalView.DETAILS+ ? [+ <Button key="close" onClick={onClose}>+ Close+ </Button>,+ <Button+ type="default"+ key="discard"+ onClick={handleDiscard}+ className="add-span-to-funnel-modal__discard-button"+ disabled={!isUnsavedChanges}+ >+ Discard+ </Button>,+ <Button+ key="save"+ type="primary"+ className="add-span-to-funnel-modal__save-button"+ onClick={handleSaveFunnel}+ disabled={!isUnsavedChanges}+ icon={<Check size={14} color="var(--bg-vanilla-100)" />}+ >+ Save Funnel+ </Button>,+ ]+ : [+ <Button+ key="create"+ type="default"+ className="add-span-to-funnel-modal__create-button"+ onClick={handleCreateNewClick}+ icon={<Plus size={14} />}+ >+ Create new funnel+ </Button>,+ ]}>{activeView === ModalView.LISTdiff --git a/frontend/src/hooks/TracesFunnels/useFunnelConfiguration.tsx b/frontend/src/hooks/TracesFunnels/useFunnelConfiguration.tsxindex 5e2c7324b6..8b027eef45 100644--- a/frontend/src/hooks/TracesFunnels/useFunnelConfiguration.tsx+++ b/frontend/src/hooks/TracesFunnels/useFunnelConfiguration.tsx@@ -36,8 +36,14 @@ const normalizeSteps = (steps: FunnelStepData[]): FunnelStepData[] => {// eslint-disable-next-line sonarjs/cognitive-complexityexport default function useFunnelConfiguration({funnel,+ disableAutoSave = false,+ triggerAutoSave = false,+ showNotifications = false,}: {funnel: FunnelData;+ disableAutoSave?: boolean;+ triggerAutoSave?: boolean;+ showNotifications?: boolean;}): UseFunnelConfiguration {const { notifications } = useNotifications();const {@@ -45,6 +51,7 @@ export default function useFunnelConfiguration({initialSteps,hasIncompleteStepFields,handleRestoreSteps,+ handleRunFunnel,} = useFunnelContext();// State management@@ -82,13 +89,23 @@ export default function useFunnelConfiguration({step.service_name !== nextStep.service_name ||step.span_name !== nextStep.span_name ||!isEqual(step.filters, nextStep.filters) ||- step.has_errors !== nextStep.has_errors+ step.has_errors !== nextStep.has_errors ||+ step.latency_pointer !== nextStep.latency_pointer);});},[],);+ const hasFunnelLatencyTypeChanged = useCallback(+ (prevSteps: FunnelStepData[], nextSteps: FunnelStepData[]): boolean =>+ prevSteps.some((step, index) => {+ const nextStep = nextSteps[index];+ return step.latency_type !== nextStep.latency_type;+ }),+ [],+ );+// Mutation payload preparationconst getUpdatePayload = useCallback(() => ({@@ -106,8 +123,20 @@ export default function useFunnelConfiguration({() => [REACT_QUERY_KEY.VALIDATE_FUNNEL_STEPS, funnel.funnel_id, selectedTime],[funnel.funnel_id, selectedTime],);+ // eslint-disable-next-line sonarjs/cognitive-complexityuseEffect(() => {- if (hasStepsChanged() && !hasIncompleteStepFields) {+ // Determine if we should save based on the mode+ let shouldSave = false;++ if (disableAutoSave) {+ // Manual save mode: only save when explicitly triggered+ shouldSave = triggerAutoSave;+ } else {+ // Auto-save mode: save when steps have changed and no incomplete fields+ shouldSave = hasStepsChanged() && !hasIncompleteStepFields;+ }++ if (shouldSave && !isEqual(debouncedSteps, lastValidatedSteps)) {updateStepsMutation.mutate(getUpdatePayload(), {onSuccess: (data) => {const updatedFunnelSteps = data?.payload?.steps;@@ -116,13 +145,16 @@ export default function useFunnelConfiguration({queryClient.setQueryData([REACT_QUERY_KEY.GET_FUNNEL_DETAILS, funnel.funnel_id],- (oldData: any) => ({- ...oldData,- payload: {- ...oldData.payload,- steps: updatedFunnelSteps,- },- }),+ (oldData: any) => {+ if (!oldData?.payload) return oldData;+ return {+ ...oldData,+ payload: {+ ...oldData.payload,+ steps: updatedFunnelSteps,+ },+ };+ },);lastSavedStepsStateRef.current = updatedFunnelSteps;@@ -131,17 +163,29 @@ export default function useFunnelConfiguration({(step) => step.service_name === '' || step.span_name === '',);- // Only validate if service_name or span_name changed- if (+ if (hasFunnelLatencyTypeChanged(lastValidatedSteps, debouncedSteps)) {+ handleRunFunnel();+ setLastValidatedSteps(debouncedSteps);+ }+ // Only validate if funnel steps definitions+ else if (!hasIncompleteStepFields &&hasFunnelStepDefinitionsChanged(lastValidatedSteps, debouncedSteps)) {queryClient.refetchQueries(validateStepsQueryKey);setLastValidatedSteps(debouncedSteps);}++ // Show success notification only when requested+ if (showNotifications) {+ notifications.success({+ message: 'Success',+ description: 'Funnel configuration updated successfully',+ });+ }},- onError: () => {+ onError: (error: any) => {handleRestoreSteps(lastSavedStepsStateRef.current);queryClient.setQueryData([REACT_QUERY_KEY.GET_FUNNEL_DETAILS, funnel.funnel_id],@@ -153,6 +197,16 @@ export default function useFunnelConfiguration({},}),);++ // Show error notification only when requested+ if (showNotifications) {+ notifications.error({+ message: 'Failed to update funnel',+ description:+ error?.message ||+ 'An error occurred while updating the funnel configuration',+ });+ }},});}@@ -165,6 +219,9 @@ export default function useFunnelConfiguration({lastValidatedSteps,queryClient,validateStepsQueryKey,+ triggerAutoSave,+ showNotifications,+ disableAutoSave,]);return {diff --git a/frontend/src/hooks/TracesFunnels/useFunnelMetrics.ts b/frontend/src/hooks/TracesFunnels/useFunnelMetrics.tsindex db4a13e446..0b232d0a66 100644--- a/frontend/src/hooks/TracesFunnels/useFunnelMetrics.ts+++ b/frontend/src/hooks/TracesFunnels/useFunnelMetrics.ts@@ -49,11 +49,7 @@ export function useFunnelMetrics({},{title: `P99 Latency`,- value: getYAxisFormattedValue(- // TODO(shaheer): remove p99_latency once we have support for latency- (sourceData.latency ?? sourceData.p99_latency).toString(),- 'ms',- ),+ value: getYAxisFormattedValue(sourceData.latency.toString(), 'ms'),},];}, [overviewData?.payload?.data]);@@ -95,7 +91,10 @@ export function useFunnelStepsMetrics({} = useFunnelStepsOverview(funnelId, payload);const latencyType = useMemo(- () => (stepStart ? steps[stepStart]?.latency_type : LatencyOptions.P99),+ () =>+ stepStart+ ? steps[stepStart]?.latency_type ?? LatencyOptions.P99+ : LatencyOptions.P99,[stepStart, steps],);@@ -117,10 +116,9 @@ export function useFunnelStepsMetrics({),},{- title: `${latencyType?.toUpperCase()} Latency`,+ title: `${latencyType.toUpperCase()} Latency`,value: getYAxisFormattedValue(- // TODO(shaheer): remove p99_latency once we have support for latency- ((sourceData.latency ?? sourceData.p99_latency) * 1_000_000).toString(),+ (sourceData.latency * 1_000_000).toString(),'ns',),},diff --git a/frontend/src/hooks/useLocalStorage.ts b/frontend/src/hooks/useLocalStorage.tsindex f71e2676ba..89af2f5f03 100644--- a/frontend/src/hooks/useLocalStorage.ts+++ b/frontend/src/hooks/useLocalStorage.ts@@ -1,4 +1,4 @@-import { useCallback, useEffect, useState } from 'react';+import { useCallback, useEffect, useRef, useState } from 'react';/*** A React hook for interacting with localStorage.@@ -6,35 +6,47 @@ import { useCallback, useEffect, useState } from 'react';** @template T The type of the value to be stored.* @param {string} key The localStorage key.- * @param {T | (() => T)} initialValue The initial value to use if no value is found in localStorage,+ * @param {T | (() => T)} defaultValue The default value to use if no value is found in localStorage,* @returns {[T, (value: T | ((prevState: T) => T)) => void, () => void]}* A tuple containing:* - The current value from state (and localStorage).* - A function to set the value (updates state and localStorage).- * - A function to remove the value from localStorage and reset state to initialValue.+ * - A function to remove the value from localStorage and reset state to defaultValue.*/export function useLocalStorage<T>(key: string,- initialValue: T | (() => T),+ defaultValue: T | (() => T),): [T, (value: T | ((prevState: T) => T)) => void, () => void] {- // This function resolves the initialValue if it's a function,+ // Stabilize the defaultValue to prevent unnecessary re-renders+ const defaultValueRef = useRef<T | (() => T)>(defaultValue);++ // Update the ref if defaultValue changes (for cases where it's intentionally dynamic)+ useEffect(() => {+ if (defaultValueRef.current !== defaultValue) {+ defaultValueRef.current = defaultValue;+ }+ }, [defaultValue]);++ // This function resolves the defaultValue if it's a function,// and handles potential errors during localStorage access or JSON parsing.const readValueFromStorage = useCallback((): T => {- const resolvedInitialValue =- initialValue instanceof Function ? initialValue() : initialValue;+ const resolveddefaultValue =+ defaultValueRef.current instanceof Function+ ? (defaultValueRef.current as () => T)()+ : defaultValueRef.current;try {const item = window.localStorage.getItem(key);- // If item exists, parse it, otherwise return the resolved initial value.+ // If item exists, parse it, otherwise return the resolved default value.if (item) {return JSON.parse(item) as T;}} catch (error) {- // Log error and fall back to initial value if reading/parsing fails.+ // Log error and fall back to default value if reading/parsing fails.console.warn(`Error reading localStorage key "${key}":`, error);}- return resolvedInitialValue;- }, [key, initialValue]);+ return resolveddefaultValue;+ }, [key]);// Initialize state by reading from localStorage.const [storedValue, setStoredValue] = useState<T>(readValueFromStorage);@@ -63,17 +75,19 @@ export function useLocalStorage<T>(const removeValue = useCallback(() => {try {window.localStorage.removeItem(key);- // Reset state to the (potentially resolved) initialValue.+ // Reset state to the (potentially resolved) defaultValue.setStoredValue(- initialValue instanceof Function ? initialValue() : initialValue,+ defaultValueRef.current instanceof Function+ ? (defaultValueRef.current as () => T)()+ : defaultValueRef.current,);} catch (error) {console.warn(`Error removing localStorage key "${key}":`, error);}- }, [key, initialValue]);+ }, [key]);// useEffect to update the storedValue if the key changes,- // or if the initialValue prop changes causing readValueFromStorage to change.+ // or if the defaultValue prop changes causing readValueFromStorage to change.// This ensures the hook reflects the correct localStorage item if its key prop dynamically changes.useEffect(() => {setStoredValue(readValueFromStorage());diff --git a/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/DeleteFunnelStep.tsx b/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/DeleteFunnelStep.tsxindex 3892b83b13..72590ef65e 100644--- a/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/DeleteFunnelStep.tsx+++ b/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/DeleteFunnelStep.tsx@@ -27,7 +27,7 @@ function DeleteFunnelStep({onCancel={onClose}rootClassName="funnel-modal delete-funnel-modal"cancelText="Cancel"- okText="Delete Funnel"+ okText="Delete Step"okButtonProps={{icon: <Trash2 size={14} />,type: 'primary',diff --git a/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelConfiguration.styles.scss b/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelConfiguration.styles.scssindex 0c60f330e2..b71218531e 100644--- a/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelConfiguration.styles.scss+++ b/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelConfiguration.styles.scss@@ -2,8 +2,13 @@&__steps-wrapper {display: flex;flex-direction: column;- justify-content: space-between;- height: 100%;+ justify-content: flex-start;+ &.funnel-details-page {+ height: calc(+ 100vh - 170px+ ); // 64px bottom bar + 61px configuration header + 45px page navbar+ overflow: auto;+ }}&__header {@@ -38,13 +43,26 @@}}}+ &__description-wrapper {+ padding: 16px 16px 0 16px;+ .funnel {+ &-title {+ color: var(--bg-vanilla-500);+ font-size: 16px;+ font-weight: 500;+ line-height: 24px; /* 150% */+ letter-spacing: -0.08px;+ }+ &-description {+ color: var(--bg-vanilla-400);+ font-size: 12px;+ line-height: 18px; /* 150% */+ letter-spacing: -0.06px;+ }+ }+ }&__description {- padding: 16px 16px 0 16px;- color: var(--bg-vanilla-400);- font-size: 12px;- line-height: 18px; /* 150% */- letter-spacing: -0.06px;}.funnel-item__action-icon {diff --git a/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelConfiguration.tsx b/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelConfiguration.tsxindex b8ad64e547..a1764369bd 100644--- a/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelConfiguration.tsx+++ b/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelConfiguration.tsx@@ -1,6 +1,8 @@import './FunnelConfiguration.styles.scss';import { Button, Divider, Tooltip } from 'antd';+import cx from 'classnames';+import OverlayScrollbar from 'components/OverlayScrollbar/OverlayScrollbar';import useFunnelConfiguration from 'hooks/TracesFunnels/useFunnelConfiguration';import { PencilLine } from 'lucide-react';import FunnelItemPopover from 'pages/TracesFunnels/components/FunnelsList/FunnelItemPopover';@@ -19,15 +21,24 @@ interface FunnelConfigurationProps {funnel: FunnelData;isTraceDetailsPage?: boolean;span?: Span;+ disableAutoSave?: boolean;+ triggerAutoSave?: boolean;+ showNotifications?: boolean;}function FunnelConfiguration({funnel,isTraceDetailsPage,span,+ disableAutoSave,+ triggerAutoSave,+ showNotifications,}: FunnelConfigurationProps): JSX.Element {const { isPopoverOpen, setIsPopoverOpen, steps } = useFunnelConfiguration({funnel,+ disableAutoSave,+ triggerAutoSave,+ showNotifications,});const [isDescriptionModalOpen, setIsDescriptionModalOpen] = useState<boolean>(false,@@ -40,55 +51,69 @@ function FunnelConfiguration({return (<div className="funnel-configuration">{!isTraceDetailsPage && (- <>- <div className="funnel-configuration__header">- <div className="funnel-configuration__header-left">- <FunnelBreadcrumb funnelName={funnel.funnel_name} />- </div>- <div className="funnel-configuration__header-right">- <Tooltip- title={- funnel?.description- ? 'Edit funnel description'- : 'Add funnel description'- }- >- <Button- type="text"- className="funnel-item__action-btn funnel-configuration__rename-btn"- icon={<PencilLine size={14} />}- onClick={(): void => setIsDescriptionModalOpen(true)}- aria-label="Edit Funnel Description"- />- </Tooltip>- <CopyToClipboard textToCopy={window.location.href} />- <Divider type="vertical" />- <FunnelItemPopover- isPopoverOpen={isPopoverOpen}- setIsPopoverOpen={setIsPopoverOpen}- funnel={funnel}- />- </div>+ <div className="funnel-configuration__header">+ <div className="funnel-configuration__header-left">+ <FunnelBreadcrumb funnelName={funnel.funnel_name} /></div>- <div className="funnel-configuration__description">- {funnel?.description}+ <div className="funnel-configuration__header-right">+ <Tooltip+ title={+ funnel?.description+ ? 'Edit funnel description'+ : 'Add funnel description'+ }+ >+ <Button+ type="text"+ className="funnel-item__action-btn funnel-configuration__rename-btn"+ icon={<PencilLine size={14} />}+ onClick={(): void => setIsDescriptionModalOpen(true)}+ aria-label="Edit Funnel Description"+ />+ </Tooltip>+ <CopyToClipboard textToCopy={window.location.href} />+ <Divider type="vertical" />+ <FunnelItemPopover+ isPopoverOpen={isPopoverOpen}+ setIsPopoverOpen={setIsPopoverOpen}+ funnel={funnel}+ /></div>- </>- )}- <div className="funnel-configuration__steps-wrapper">- <div className="funnel-configuration__steps">- {!isTraceDetailsPage && <StepsHeader />}- <StepsContent isTraceDetailsPage={isTraceDetailsPage} span={span} /></div>- {!isTraceDetailsPage && <StepsFooter stepsCount={steps.length} />}+ )}+ <div+ className={cx('funnel-configuration__steps-wrapper', {+ 'funnel-details-page': !isTraceDetailsPage,+ })}+ >+ <OverlayScrollbar>+ <>+ {!isTraceDetailsPage && (+ <div className="funnel-configuration__description-wrapper">+ <div className="funnel-title">{funnel.funnel_name}</div>+ <div className="funnel-description">+ {funnel?.description ?? 'No description added.'}+ </div>+ </div>+ )}+ <div className="funnel-configuration__steps">+ {!isTraceDetailsPage && <StepsHeader />}+ <StepsContent isTraceDetailsPage={isTraceDetailsPage} span={span} />+ </div>+ </>+ </OverlayScrollbar></div>+{!isTraceDetailsPage && (- <AddFunnelDescriptionModal- isOpen={isDescriptionModalOpen}- onClose={handleDescriptionModalClose}- funnelId={funnel.funnel_id}- funnelDescription={funnel?.description || ''}- />+ <>+ <StepsFooter stepsCount={steps.length} />+ <AddFunnelDescriptionModal+ isOpen={isDescriptionModalOpen}+ onClose={handleDescriptionModalClose}+ funnelId={funnel.funnel_id}+ funnelDescription={funnel?.description || ''}+ />+ </>)}</div>);@@ -97,6 +122,9 @@ function FunnelConfiguration({FunnelConfiguration.defaultProps = {isTraceDetailsPage: false,span: undefined,+ disableAutoSave: false,+ triggerAutoSave: false,+ showNotifications: false,};export default memo(FunnelConfiguration);diff --git a/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelStep.styles.scss b/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelStep.styles.scssindex 345368c198..aaec5b89f3 100644--- a/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelStep.styles.scss+++ b/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelStep.styles.scss@@ -33,6 +33,16 @@display: flex;flex-direction: column;gap: 4px;+ &__title-container {+ display: flex;+ align-items: center;+ gap: 6px;+ .drag-icon {+ cursor: grab;+ display: flex;+ align-items: center;+ }+ }&__title {color: var(--bg-vanilla-400);font-size: 14px;@@ -69,14 +79,12 @@align-items: baseline;gap: 6px;padding: 16px;- padding-left: 6px;+ padding-left: 12px;.ant-form-item {margin: 0;width: 100%;}- .drag-icon {- cursor: grab;- }+.filters {display: flex;flex-direction: column;diff --git a/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelStep.tsx b/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelStep.tsxindex ef0c121206..f7eb60ae08 100644--- a/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelStep.tsx+++ b/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/FunnelStep.tsx@@ -1,13 +1,11 @@import './FunnelStep.styles.scss';-import { Button, Divider, Dropdown, Form, Space, Switch, Tooltip } from 'antd';-import { MenuProps } from 'antd/lib';+import { Button, Divider, Form, Switch, Tooltip } from 'antd';import { FilterSelect } from 'components/CeleryOverview/CeleryOverviewConfigOptions/CeleryOverviewConfigOptions';import { QueryParams } from 'constants/query';import { initialQueriesMap } from 'constants/queryBuilder';import QueryBuilderSearchV2 from 'container/QueryBuilder/filters/QueryBuilderSearchV2/QueryBuilderSearchV2';-import { ChevronDown, GripVertical, HardHat, PencilLine } from 'lucide-react';-import { LatencyPointers } from 'pages/TracesFunnelDetails/constants';+import { HardHat, PencilLine } from 'lucide-react';import { useFunnelContext } from 'pages/TracesFunnels/FunnelContext';import { useMemo, useState } from 'react';import { FunnelStepData } from 'types/api/traceFunnels';@@ -37,16 +35,17 @@ function FunnelStep({false,);- const latencyPointerItems: MenuProps['items'] = LatencyPointers.map(- (option) => ({- key: option.value,- label: option.key,- style:- option.value === stepData.latency_pointer- ? { backgroundColor: 'var(--bg-slate-100)' }- : {},- }),- );+ // temporarily hide latency pointer, as it breaks some edge cases (ref: https://signoz-team.slack.com/archives/C089MNX4Y90/p1748600682066499?thread_ts=1748599673.171759&cid=C089MNX4Y90)+ // const latencyPointerItems: MenuProps['items'] = LatencyPointers.map(+ // (option) => ({+ // key: option.value,+ // label: option.key,+ // style:+ // option.value === stepData.latency_pointer+ // ? { backgroundColor: 'var(--bg-slate-100)' }+ // : {},+ // }),+ // );const updatedCurrentQuery = useMemo(() => ({@@ -75,11 +74,17 @@ function FunnelStep({<Form form={form}><div className="funnel-step__header"><div className="funnel-step-details">- {stepData.name ? (- <div className="funnel-step-details__title">{stepData.name}</div>- ) : (- <div className="funnel-step-details__title">Step {index + 1}</div>- )}+ <div className="funnel-step-details__title-container">+ {/* TODO(shaheer): uncomment after adding support for dragging the steps */}+ {/* <div className="drag-icon">+ <GripVertical size={14} color="var(--bg-slate-200)" />+ </div> */}+ {stepData.name ? (+ <div className="funnel-step-details__title">{stepData.name}</div>+ ) : (+ <div className="funnel-step-details__title">Step {index + 1}</div>+ )}+ </div>{!!stepData.description && (<div className="funnel-step-details__description">{stepData.description}@@ -113,9 +118,6 @@ function FunnelStep({</div></div><div className="funnel-step__content">- <div className="drag-icon">- <GripVertical size={14} color="var(--bg-slate-200)" />- </div><div className="filters"><div className="filters__service-and-span"><div className="service">@@ -176,7 +178,8 @@ function FunnelStep({/><div className="error__label">Errors</div></div>- <div className="latency-pointer">+ {/* temporarily hide latency pointer, as it breaks some edge cases (ref: https://signoz-team.slack.com/archives/C089MNX4Y90/p1748600682066499?thread_ts=1748599673.171759&cid=C089MNX4Y90) */}+ {/* <div className="latency-pointer"><div className="latency-pointer__label">Latency pointer</div><Dropdownmenu={{@@ -197,7 +200,7 @@ function FunnelStep({<ChevronDown size={14} color="var(--bg-vanilla-400)" /></Space></Dropdown>- </div>+ </div> */}</div></Form></div>diff --git a/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/StepsContent.styles.scss b/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/StepsContent.styles.scssindex 819a1f04de..eeadcb72c4 100644--- a/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/StepsContent.styles.scss+++ b/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/StepsContent.styles.scss@@ -1,8 +1,4 @@.steps-content {- height: calc(- 100vh - 253px- ); // 64px (footer) + 12 (steps gap) + 32 (steps header) + 16 (steps padding) + 50 (breadcrumb) + 34 (description) + 45 (steps footer) = 219px- overflow-y: auto;.ant-btn {box-shadow: none;&-icon {diff --git a/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/StepsContent.tsx b/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/StepsContent.tsxindex 7e6a18ddc1..cd72c44eb1 100644--- a/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/StepsContent.tsx+++ b/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/StepsContent.tsx@@ -2,7 +2,6 @@ import './StepsContent.styles.scss';import { Button, Steps } from 'antd';import logEvent from 'api/common/logEvent';-import OverlayScrollbar from 'components/OverlayScrollbar/OverlayScrollbar';import { PlusIcon, Undo2 } from 'lucide-react';import { useFunnelContext } from 'pages/TracesFunnels/FunnelContext';import { memo, useCallback } from 'react';@@ -37,70 +36,68 @@ function StepsContent({return (<div className="steps-content">- <OverlayScrollbar>- <Steps direction="vertical">- {steps.map((step, index) => (- <Step- key={`step-${index + 1}`}- description={- <div className="steps-content__description">- <div className="funnel-step-wrapper">- <FunnelStep stepData={step} index={index} stepsCount={steps.length} />- {isTraceDetailsPage && span && (- <Button- type="default"- className="funnel-step-wrapper__replace-button"- icon={<Undo2 size={12} />}- disabled={- step.service_name === span.serviceName &&- step.span_name === span.name- }- onClick={(): void =>- handleReplaceStep(index, span.serviceName, span.name)- }- >- Replace- </Button>- )}- </div>- {/* Display InterStepConfig only between steps */}- {index < steps.length - 1 && (- // the latency type should be sent with the n+1th step- <InterStepConfig index={index + 1} step={steps[index + 1]} />+ <Steps direction="vertical">+ {steps.map((step, index) => (+ <Step+ key={`step-${index + 1}`}+ description={+ <div className="steps-content__description">+ <div className="funnel-step-wrapper">+ <FunnelStep stepData={step} index={index} stepsCount={steps.length} />+ {isTraceDetailsPage && span && (+ <Button+ type="default"+ className="funnel-step-wrapper__replace-button"+ icon={<Undo2 size={12} />}+ disabled={+ step.service_name === span.serviceName &&+ step.span_name === span.name+ }+ onClick={(): void =>+ handleReplaceStep(index, span.serviceName, span.name)+ }+ >+ Replace+ </Button>)}</div>- }- />- ))}- {/* For now we are only supporting 3 steps */}- {steps.length < 3 && (- <Step- className="steps-content__add-step"- description={- !isTraceDetailsPage ? (- <Button- type="default"- className="steps-content__add-btn"- onClick={handleAddStep}- icon={<PlusIcon size={14} />}- >- Add Funnel Step- </Button>- ) : (- <Button- type="default"- className="steps-content__add-btn"- onClick={handleAddForNewStep}- icon={<PlusIcon size={14} />}- >- Add for new Step- </Button>- )- }- />- )}- </Steps>- </OverlayScrollbar>+ {/* Display InterStepConfig only between steps */}+ {index < steps.length - 1 && (+ // the latency type should be sent with the n+1th step+ <InterStepConfig index={index + 1} step={steps[index + 1]} />+ )}+ </div>+ }+ />+ ))}+ {/* For now we are only supporting 3 steps */}+ {steps.length < 3 && (+ <Step+ className="steps-content__add-step"+ description={+ !isTraceDetailsPage ? (+ <Button+ type="default"+ className="steps-content__add-btn"+ onClick={handleAddStep}+ icon={<PlusIcon size={14} />}+ >+ Add Funnel Step+ </Button>+ ) : (+ <Button+ type="default"+ className="steps-content__add-btn"+ onClick={handleAddForNewStep}+ icon={<PlusIcon size={14} />}+ >+ Add for new Step+ </Button>+ )+ }+ />+ )}+ </Steps></div>);}diff --git a/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/StepsFooter.styles.scss b/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/StepsFooter.styles.scssindex 2dc6569851..8215c1df17 100644--- a/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/StepsFooter.styles.scss+++ b/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/StepsFooter.styles.scss@@ -48,6 +48,13 @@&--run {background-color: var(--bg-robin-500);}+ &--updating {+ display: flex;+ align-items: center;+ gap: 4px;+ color: var(--bg-vanilla-400);+ font-size: 12px;+ }}}diff --git a/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/StepsFooter.tsx b/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/StepsFooter.tsxindex 9aa70f2db8..41c41507e5 100644--- a/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/StepsFooter.tsx+++ b/frontend/src/pages/TracesFunnelDetails/components/FunnelConfiguration/StepsFooter.tsx@@ -1,11 +1,12 @@import './StepsFooter.styles.scss';-import { Button, Skeleton } from 'antd';+import { LoadingOutlined } from '@ant-design/icons';+import { Button, Skeleton, Spin } from 'antd';import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';import { Cone, Play, RefreshCcw } from 'lucide-react';import { useFunnelContext } from 'pages/TracesFunnels/FunnelContext';-import { useEffect, useMemo } from 'react';-import { useIsFetching, useQueryClient } from 'react-query';+import { useMemo } from 'react';+import { useIsFetching, useIsMutating } from 'react-query';const useFunnelResultsLoading = (): boolean => {const { funnelId } = useFunnelContext();@@ -56,25 +57,11 @@ function ValidTracesCount(): JSX.Element {hasIncompleteStepFields,validTracesCount,funnelId,- selectedTime,} = useFunnelContext();- const queryClient = useQueryClient();- const validationQueryKey = useMemo(- () => [REACT_QUERY_KEY.VALIDATE_FUNNEL_STEPS, funnelId, selectedTime],- [funnelId, selectedTime],- );- const validationStatus = queryClient.getQueryData(validationQueryKey);- useEffect(() => {- // Show loading state immediately when fields become valid- if (hasIncompleteStepFields && validationStatus !== 'pending') {- queryClient.setQueryData(validationQueryKey, 'pending');- }- }, [- hasIncompleteStepFields,- queryClient,- validationQueryKey,- validationStatus,+ const isFunnelUpdateMutating = useIsMutating([+ REACT_QUERY_KEY.UPDATE_FUNNEL_STEPS,+ funnelId,]);if (hasAllEmptyStepFields) {@@ -91,7 +78,7 @@ function ValidTracesCount(): JSX.Element {);}- if (isValidateStepsLoading || validationStatus === 'pending') {+ if (isValidateStepsLoading || isFunnelUpdateMutating) {return <Skeleton.Button size="small" />;}@@ -111,10 +98,16 @@ function StepsFooter({ stepsCount }: StepsFooterProps): JSX.Element {validTracesCount,handleRunFunnel,hasFunnelBeenExecuted,+ funnelId,} = useFunnelContext();const isFunnelResultsLoading = useFunnelResultsLoading();+ const isFunnelUpdateMutating = useIsMutating([+ REACT_QUERY_KEY.UPDATE_FUNNEL_STEPS,+ funnelId,+ ]);+return (<div className="steps-footer"><div className="steps-footer__left">@@ -124,6 +117,16 @@ function StepsFooter({ stepsCount }: StepsFooterProps): JSX.Element {<ValidTracesCount /></div><div className="steps-footer__right">+ {!!isFunnelUpdateMutating && (+ <div className="steps-footer__button steps-footer__button--updating">+ <Spin+ indicator={<LoadingOutlined style={{ color: 'grey' }} />}+ size="small"+ />+ Updating+ </div>+ )}+{!hasFunnelBeenExecuted ? (<Buttondisabled={validTracesCount === 0}diff --git a/frontend/src/pages/TracesFunnelDetails/components/FunnelResults/FunnelResults.tsx b/frontend/src/pages/TracesFunnelDetails/components/FunnelResults/FunnelResults.tsxindex 8c47d961e5..2b2ce59c36 100644--- a/frontend/src/pages/TracesFunnelDetails/components/FunnelResults/FunnelResults.tsx+++ b/frontend/src/pages/TracesFunnelDetails/components/FunnelResults/FunnelResults.tsx@@ -3,7 +3,7 @@ import './FunnelResults.styles.scss';import Spinner from 'components/Spinner';import { REACT_QUERY_KEY } from 'constants/reactQueryKeys';import { useFunnelContext } from 'pages/TracesFunnels/FunnelContext';-import { useQueryClient } from 'react-query';+import { useIsMutating } from 'react-query';import EmptyFunnelResults from './EmptyFunnelResults';import FunnelGraph from './FunnelGraph';@@ -18,14 +18,11 @@ function FunnelResults(): JSX.Element {hasAllEmptyStepFields,hasFunnelBeenExecuted,funnelId,- selectedTime,} = useFunnelContext();- const queryClient = useQueryClient();- const validateQueryData = queryClient.getQueryData([- REACT_QUERY_KEY.VALIDATE_FUNNEL_STEPS,+ const isFunnelUpdateMutating = useIsMutating([+ REACT_QUERY_KEY.UPDATE_FUNNEL_STEPS,funnelId,- selectedTime,]);if (hasAllEmptyStepFields) return <EmptyFunnelResults />;@@ -38,7 +35,7 @@ function FunnelResults(): JSX.Element {/>);- if (isValidateStepsLoading || validateQueryData === 'pending') {+ if (isValidateStepsLoading || isFunnelUpdateMutating) {return <Spinner size="large" />;}diff --git a/frontend/src/pages/TracesFunnels/FunnelContext.tsx b/frontend/src/pages/TracesFunnels/FunnelContext.tsxindex 96d5a05f21..423f339668 100644--- a/frontend/src/pages/TracesFunnels/FunnelContext.tsx+++ b/frontend/src/pages/TracesFunnels/FunnelContext.tsx@@ -170,6 +170,10 @@ export function FunnelProvider({handleStepUpdate(index, {service_name: serviceName,span_name: spanName,+ filters: {+ items: [],+ op: 'AND',+ },});logEvent('Trace Funnels: span added (replaced) from trace details page', {});},@@ -191,6 +195,11 @@ export function FunnelProvider({funnelId,selectedTime,]);+ queryClient.refetchQueries([+ REACT_QUERY_KEY.GET_FUNNEL_STEPS_OVERVIEW,+ funnelId,+ selectedTime,+ ]);queryClient.refetchQueries([REACT_QUERY_KEY.GET_FUNNEL_STEPS_GRAPH_DATA,funnelId,