Skip to content

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.

555 B
Raw Blame
import { useMemo } from 'react';
import { parsePath } from 'history';

import { setStoryLocation } from '../navigation/pageScope';

/**
 * Places the story's history at its route before the router mounts and hands
 * back the search params for the nuqs testing adapter.
 */
export const useStoryRoute = (
	route: string,
	routeState?: unknown,
): URLSearchParams =>
	useMemo(() => {
		setStoryLocation({ ...parsePath(route), state: routeState });
		const [, search = ''] = route.split('?');
		return new URLSearchParams(search);
	}, [route, routeState]);