New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Interactions: Run conditionally based on query param #18706
Changes from 2 commits
2f8d6ee
f0af160
162a28f
b899f1e
98ec2ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -584,8 +584,13 @@ 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; | ||||||
// 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) { | ||||||
const params = new URLSearchParams(global.window.location.search); | ||||||
if (!params.get('interactions')) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
It's not just for interactions, and I'm thinking perhaps we should support the inverse as well. So if you set |
||||||
return obj; | ||||||
} | ||||||
} | ||||||
|
||||||
// Only create an instance if we don't have one (singleton) yet. | ||||||
if (!global.window.__STORYBOOK_ADDON_INTERACTIONS_INSTRUMENTER__) { | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this work in IE? Not sure a polyfill is generated.