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
feat(dashboard-v2): share a dashboard link with the current variable selection (#12198)
Ashwin Bhatkalcc45c1bef18e
diff --git a/frontend/src/components/HeaderRightSection/HeaderRightSection.tsx b/frontend/src/components/HeaderRightSection/HeaderRightSection.tsxindex 20facefc09..5037c0ef1a 100644--- a/frontend/src/components/HeaderRightSection/HeaderRightSection.tsx+++ b/frontend/src/components/HeaderRightSection/HeaderRightSection.tsx@@ -20,7 +20,7 @@ import { Globe, Inbox, SquarePen } from '@signozhq/icons';import AnnouncementsModal from './AnnouncementsModal';import FeedbackModal from './FeedbackModal';-import ShareURLModal from './ShareURLModal';+import ShareURLModal, { type ShareURLExtraOption } from './ShareURLModal';import './HeaderRightSection.styles.scss';import { Typography } from '@signozhq/ui/typography';@@ -29,12 +29,15 @@ interface HeaderRightSectionProps {enableAnnouncements: boolean;enableShare: boolean;enableFeedback: boolean;+ /** Optional page-specific toggle for the share dialog (e.g. "Include variables"). */+ shareModalExtraOption?: ShareURLExtraOption;}function HeaderRightSection({enableAnnouncements,enableShare,enableFeedback,+ shareModalExtraOption,}: HeaderRightSectionProps): JSX.Element | null {const location = useLocation();@@ -185,7 +188,7 @@ function HeaderRightSection({rootClassName="header-section-popover-root"className="shareable-link-popover"placement="bottomRight"- content={<ShareURLModal />}+ content={<ShareURLModal extraOption={shareModalExtraOption} />}open={openShareURLModal}destroyTooltipOnHidearrow={false}diff --git a/frontend/src/components/HeaderRightSection/ShareURLModal.tsx b/frontend/src/components/HeaderRightSection/ShareURLModal.tsxindex c4892bca1a..3edc201f3a 100644--- a/frontend/src/components/HeaderRightSection/ShareURLModal.tsx+++ b/frontend/src/components/HeaderRightSection/ShareURLModal.tsx@@ -24,7 +24,22 @@ const routesToBeSharedWithTime = [ROUTES.METER_EXPLORER,];-function ShareURLModal(): JSX.Element {+/**+ * An optional, page-specific toggle in the share dialog (e.g. a dashboard's+ * "Include variables"). When enabled, `apply` mutates the URL params that go into+ * the shared link. Keeps this shared modal generic — the page owns what it adds.+ */+export interface ShareURLExtraOption {+ label: string;+ defaultEnabled?: boolean;+ apply: (params: URLSearchParams) => void;+}++interface ShareURLModalProps {+ extraOption?: ShareURLExtraOption;+}++function ShareURLModal({ extraOption }: ShareURLModalProps): JSX.Element {const urlQuery = useUrlQuery();const location = useLocation();const { selectedTime } = useSelector<AppState, GlobalReducer>(@@ -34,6 +49,9 @@ function ShareURLModal(): JSX.Element {const [enableAbsoluteTime, setEnableAbsoluteTime] = useState(selectedTime !== 'custom',);+ const [enableExtraOption, setEnableExtraOption] = useState(+ extraOption?.defaultEnabled ?? false,+ );const startTime = urlQuery.get(QueryParams.startTime);const endTime = urlQuery.get(QueryParams.endTime);@@ -93,6 +111,11 @@ function ShareURLModal(): JSX.Element {}}+ if (extraOption && enableExtraOption) {+ extraOption.apply(urlQuery);+ currentUrl = getAbsoluteUrl(`${location.pathname}?${urlQuery.toString()}`);+ }+return currentUrl;};@@ -143,6 +166,20 @@ function ShareURLModal(): JSX.Element {</>)}+ {extraOption && (+ <div className="absolute-relative-time-toggler-container">+ <Typography.Text className="absolute-relative-time-toggler-label">+ {extraOption.label}+ </Typography.Text>+ <div className="absolute-relative-time-toggler">+ <Switch+ value={enableExtraOption}+ onChange={(): void => setEnableExtraOption((prev) => !prev)}+ />+ </div>+ </div>+ )}+<div className="share-link"><div className="url-share-container"><div className="url-share-container-header">diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/components/DashboardPageHeader/DashboardPageHeader.tsx b/frontend/src/pages/DashboardPageV2/DashboardContainer/components/DashboardPageHeader/DashboardPageHeader.tsxindex ab54738c6e..ae338760c2 100644--- a/frontend/src/pages/DashboardPageV2/DashboardContainer/components/DashboardPageHeader/DashboardPageHeader.tsx+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/components/DashboardPageHeader/DashboardPageHeader.tsx@@ -2,6 +2,7 @@ import { memo } from 'react';import HeaderRightSection from 'components/HeaderRightSection/HeaderRightSection';import DashboardPageBreadcrumbs from './DashboardPageBreadcrumbs';+import { useShareVariablesOption } from './useShareVariablesOption';import styles from './DashboardPageHeader.module.scss';@@ -14,10 +15,16 @@ function DashboardPageHeader({title,image,}: DashboardPageHeaderProps): JSX.Element {+ const shareVariablesOption = useShareVariablesOption();return (<div className={styles.dashboardPageHeader}><DashboardPageBreadcrumbs title={title} image={image} />- <HeaderRightSection enableAnnouncements={false} enableShare enableFeedback />+ <HeaderRightSection+ enableAnnouncements={false}+ enableShare+ enableFeedback+ shareModalExtraOption={shareVariablesOption}+ /></div>);}diff --git a/frontend/src/pages/DashboardPageV2/DashboardContainer/components/DashboardPageHeader/useShareVariablesOption.ts b/frontend/src/pages/DashboardPageV2/DashboardContainer/components/DashboardPageHeader/useShareVariablesOption.tsnew file mode 100644index 0000000000..db7b096a70--- /dev/null+++ b/frontend/src/pages/DashboardPageV2/DashboardContainer/components/DashboardPageHeader/useShareVariablesOption.ts@@ -0,0 +1,41 @@+import { useMemo } from 'react';+import type { ShareURLExtraOption } from 'components/HeaderRightSection/ShareURLModal';++import type { SelectedVariableValue } from '../../VariablesBar/selectionTypes';+import {+ ALL_SELECTED,+ variablesUrlParser,+} from '../../VariablesBar/utils/variablesUrlState';+import { selectVariableValues } from '../../store/slices/variableSelectionSlice';+import { useDashboardStore } from '../../store/useDashboardStore';++/**+ * The share-dialog "Include variables" option: serializes the current variable+ * selection into the `?variables=` param (ALL encoded as the sentinel) so a shared+ * link reproduces it for the recipient — who hydrates it into local storage on load,+ * after which the param is cleared (see useSeedVariableSelection). Returns undefined+ * when there is nothing selected to share.+ */+export function useShareVariablesOption(): ShareURLExtraOption | undefined {+ const dashboardId = useDashboardStore((s) => s.dashboardId);+ const selections = useDashboardStore(selectVariableValues(dashboardId ?? ''));++ return useMemo(() => {+ const names = Object.keys(selections);+ if (names.length === 0) {+ return undefined;+ }+ const urlShape: Record<string, SelectedVariableValue> = {};+ names.forEach((name) => {+ const selection = selections[name];+ urlShape[name] = selection.allSelected ? ALL_SELECTED : selection.value;+ });+ const serialized = variablesUrlParser.serialize(urlShape);+ return {+ label: 'Include variables',+ apply: (params): void => {+ params.set('variables', serialized);+ },+ };+ }, [selections]);+}