From 2f8d6eea324c8c1f717eefa1e5f1b8816e05ec2c Mon Sep 17 00:00:00 2001 From: Jono Kolnik <1164060+JonathanKolnik@users.noreply.github.com> Date: Wed, 13 Jul 2022 20:41:45 -0400 Subject: [PATCH] allow interactions to run conditionally when interactions query param is set --- lib/instrumenter/src/instrumenter.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/instrumenter/src/instrumenter.ts b/lib/instrumenter/src/instrumenter.ts index 86b5f64cc4b1..13b69a73851f 100644 --- a/lib/instrumenter/src/instrumenter.ts +++ b/lib/instrumenter/src/instrumenter.ts @@ -584,8 +584,10 @@ 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; + const params = new URLSearchParams(global.window.location.search); + + // Don't do any instrumentation if not loaded in an iframe and it's not running in a capture. + if (global.window.parent === global.window && !params.get('interactions')) return obj; // Only create an instance if we don't have one (singleton) yet. if (!global.window.__STORYBOOK_ADDON_INTERACTIONS_INSTRUMENTER__) {