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.

4.0 KB
Raw Blame
<!--
	`index.html` links Inter from Google Fonts here. The link is parsed before the
	msw worker has started, so that one request escapes the iframe while every
	other font request the app makes is answered with an empty stylesheet; the
	local faces stand in for both.
-->
<link rel="stylesheet" href="storybook-fonts.css" />

<!--
	Third-party frames are the one thing msw cannot answer: a cross-origin iframe
	navigates outside the service worker's scope, so the YouTube embeds and the
	docs pane in onboarding reach the real network. Same intent as the boot data
	below, enforced by the browser instead.
-->
<meta
	http-equiv="Content-Security-Policy"
	content="frame-src 'self' blob: data:"
/>

<link rel="stylesheet" href="css/uPlot.min.css" />

<script>
	// i18n's language detector would pick the browser locale (e.g. `en-US`), which
	// /public/locales does not ship; pin it to the bundled language instead.
	window.localStorage.setItem('i18nextLng', 'en');

	// The Go backend injects this at boot; every integration it enables is off in
	// Storybook so no third-party script loads inside the iframe.
	window.signozBootData = {
		settings: {
			posthog: { enabled: false, apiHost: '', key: '', uiHost: '' },
			appcues: { enabled: false, appId: '' },
			sentry: { enabled: false, dsn: '', tunnel: '' },
			pylon: { enabled: false, appId: '', identitySecret: '' },
		},
	};
</script>

<script>
	// The wall clock every story reads. Chart windows, `4 mins ago` labels and
	// trial countdowns all derive from `now`, and Chromatic does not freeze the
	// clock, so a live one redraws every chart axis between two builds of the
	// same code. `performance.now` and the timers keep running, so anything
	// waiting on a timeout still resolves. `?storyClock=live`, or an ISO
	// instant, overrides it.
	//
	// `new Date()` is the frozen instant, which is what the app renders from.
	// `Date.now()` runs on from it instead, because it is also what code measures
	// elapsed time with: `lodash.debounce` compares two `Date.now()` readings to
	// decide its trailing call is due, so a frozen one re-arms its timer forever
	// and every debounced input in the app (the onboarding catalogue search, the
	// pipelines search, the log filter) silently stops filtering.
	(() => {
		const asked = new URLSearchParams(window.location.search).get('storyClock');
		if (asked === 'live') return;

		const frozen = Date.parse(asked || '2026-06-15T12:00:00.000Z');
		if (Number.isNaN(frozen)) return;

		const RealDate = Date;
		const started = performance.now();
		class FrozenDate extends RealDate {
			constructor(...args) {
				super(...(args.length ? args : [frozen]));
			}
			static now() {
				return frozen + (performance.now() - started);
			}
		}
		Object.defineProperty(window, 'Date', { value: FrozenDate, writable: true });
	})();
</script>

<script>
	// Storybook has no microphone. Chromium's recognizer asks for one and for
	// Google's speech service, and the `not-allowed` or `network` it reports makes
	// the assistant hide its mic for the rest of the tab. This one starts
	// listening at once and hears only what a story passes to `hear`.
	(() => {
		class StorySpeechRecognition extends EventTarget {
			static listening = null;
			lang = 'en-US';
			continuous = false;
			interimResults = false;
			onstart = null;
			onresult = null;
			onerror = null;
			onend = null;

			start() {
				StorySpeechRecognition.listening = this;
				setTimeout(() => this.onstart?.());
			}

			stop() {
				if (StorySpeechRecognition.listening === this) {
					StorySpeechRecognition.listening = null;
				}
				setTimeout(() => this.onend?.());
			}

			abort() {
				this.stop();
			}

			/** An interim result: the words so far, still listening. */
			hear(transcript) {
				const result = Object.assign([{ transcript, confidence: 1 }], {
					isFinal: false,
				});
				this.onresult?.({ resultIndex: 0, results: [result] });
			}
		}

		window.SpeechRecognition = StorySpeechRecognition;
		window.webkitSpeechRecognition = StorySpeechRecognition;
	})();
</script>