Skip to content

Commit

Permalink
allow interactions to run conditionally when interactions query param…
Browse files Browse the repository at this point in the history
… is set
  • Loading branch information
JonathanKolnik committed Jul 14, 2022
1 parent 3929b4a commit 2f8d6ee
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/instrumenter/src/instrumenter.ts
Expand Up @@ -584,8 +584,10 @@ export function instrument<TObj extends Record<string, any>>(
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__) {
Expand Down

0 comments on commit 2f8d6ee

Please sign in to comment.