diff --git a/code/lib/instrumenter/src/instrumenter.ts b/code/lib/instrumenter/src/instrumenter.ts index 3fd338f3db21..ea41efe879c8 100644 --- a/code/lib/instrumenter/src/instrumenter.ts +++ b/code/lib/instrumenter/src/instrumenter.ts @@ -601,8 +601,19 @@ export function instrument>( options: Options = {} ): TObj { try { - // Don't do any instrumentation if not loaded in an iframe. - if (global.window.parent === global.window) return obj; + let forceInstrument = false; + let skipInstrument = false; + + if (global.window.location?.search?.includes('instrument=true')) { + forceInstrument = true; + } else if (global.window.location?.search?.includes('instrument=false')) { + skipInstrument = true; + } + + // Don't do any instrumentation if not loaded in an iframe unless it's forced - instrumentation can also be skipped. + if ((global.window.parent === global.window && !forceInstrument) || skipInstrument) { + return obj; + } // Only create an instance if we don't have one (singleton) yet. if (!global.window.__STORYBOOK_ADDON_INTERACTIONS_INSTRUMENTER__) { diff --git a/docs/configure/features-and-behavior.md b/docs/configure/features-and-behavior.md index e7f5c8228e17..d9e720e252c1 100644 --- a/docs/configure/features-and-behavior.md +++ b/docs/configure/features-and-behavior.md @@ -56,3 +56,4 @@ You can use URL parameters to configure some of the available features: | **showPanel** | `panel` | `false`, `right`, `bottom` | | **selectedPanel** | `addonPanel` | Any panel ID | | **showTabs** | `tabs` | `true` | +| --- | `instrument` | `false`, `true` |