diff --git a/docs/configure/features-and-behavior.md b/docs/configure/features-and-behavior.md index d936e062d962..d9e720e252c1 100644 --- a/docs/configure/features-and-behavior.md +++ b/docs/configure/features-and-behavior.md @@ -55,4 +55,5 @@ You can use URL parameters to configure some of the available features: | **showNav** | `nav` | `false` | | **showPanel** | `panel` | `false`, `right`, `bottom` | | **selectedPanel** | `addonPanel` | Any panel ID | -| **showTabs** | `tabs` | `true` | \ No newline at end of file +| **showTabs** | `tabs` | `true` | +| --- | `instrument` | `false`, `true` | diff --git a/lib/instrumenter/src/instrumenter.ts b/lib/instrumenter/src/instrumenter.ts index 9e54071bab64..7a841bf678f2 100644 --- a/lib/instrumenter/src/instrumenter.ts +++ b/lib/instrumenter/src/instrumenter.ts @@ -543,8 +543,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__) {