-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
feature(addon-google-analytics) utilise storybook addonParameter instead of window/global scope. #11336
feature(addon-google-analytics) utilise storybook addonParameter instead of window/global scope. #11336
Conversation
@alexanderjeurissen thanks for the PR -- def a big improvement over the current version! @ndelangen does this belong in |
@shilman you're welcome, I'm currently working around some of these limitations more specifically the extensibility of the current google analytics package in our storybook at HackerOne. This is a first step to get there, after this gets merged I want to explore expanding the CORE events that we track. I envision that users should be able to specify what Storybook events they want to track, And maybe allow for a callback so that they can further customise the behaviour. I also want to explore putting React GA in a provider so that we can also consume ReactGA in stories directly without having to re-initialize. I recently authored http://npmjs.com/@alexanderjeurissen/use-reactga which could help with this specifically. |
@shilman @ndelangen I'm not sure if this belongs in |
@alexanderjeurissen i agree that parameters make more sense if we want to vary these things per story. is that something you have planned? one other thing. this is a breaking change, so we should make sure to get it in before 6.0 goes out if we're going to do it. if you're planning on making more breaking changes in the near future, please consider that as well! |
Yes I think it makes sense to allow for this given the minimal overhead that this introduces. I think that extending the current "global" parameters to allow for story specific ones is a non-breaking change as it only requires re-initializing a central
That makes sense, do you have an estimate as to when you expect a feature freeze for the 6.0 release to take effect ? That way I can plan some of these changes accordingly. |
"@storybook/angular": "6.0.0-beta.37", | ||
"@storybook/aurelia": "6.0.0-beta.37", | ||
"@storybook/ember": "6.0.0-beta.37", | ||
"@storybook/html": "6.0.0-beta.37", | ||
"@storybook/marionette": "6.0.0-beta.37", | ||
"@storybook/marko": "6.0.0-beta.37", | ||
"@storybook/mithril": "6.0.0-beta.37", | ||
"@storybook/preact": "6.0.0-beta.37", | ||
"@storybook/rax": "6.0.0-beta.37", | ||
"@storybook/react": "6.0.0-beta.37", | ||
"@storybook/riot": "6.0.0-beta.37", | ||
"@storybook/server": "6.0.0-beta.37", | ||
"@storybook/svelte": "6.0.0-beta.37", | ||
"@storybook/vue": "6.0.0-beta.37", | ||
"@storybook/web-components": "6.0.0-beta.37" |
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.
Not sure where these changes are coming from 🤔
@shilman is there anything I need to do for the |
@alexanderjeurissen We’re scheduled to do the first RC this week. I think we can fudge it a bit for analytics because it’s not as widely used as some addons. We can also add this as a feature in 6.1 as needed as long as we provide back compat, which wouldn’t be hard in this case |
Re: danger, don’t worry about it. It always fails on PRs from forks |
@shilman I made some changes, The default assignment in the Can you sanity check and if backwards compatibility looks good remove the |
I also created a followup PR that is based on this one (#11340) Let me know how you want to move forward with merging / releasing. |
@shilman I respect that you and the other maintainers are currently very busy getting Storybook 6.0 ready to ship. I wanted to inquire if there is any remaining action required on my end, or if this PR is ready to review as is. |
@alexanderjeurissen Looking good AFAIK. I’ll try to review today |
addParameters({ | ||
analytics: { | ||
reactGAId: 'UA-000000-01', | ||
reactGAOptions: {}, | ||
}, | ||
}); |
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.
setConfig would make more sense.
Even more would defining this in main.js
, and have a preset push it into the proper place where the runtime expects it. (such as setConfig)
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.
@ndelangen can you elaborate why setConfig
would be better in this scenario ?
If I understand correctly, setConfig
does not allow for local story overrides. I can think of future enhancements where we would want to allow users to specify different reactGA options or tracking codes for certain stories. Would that still work with a setConfig approach ?
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.
allow users to specify different reactGA options or tracking codes for certain stories
I suspect there's no need for that.. Do you?
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.
I do, having different tracking codes is likely desired in cases where a medium to big UI library is published to different scoped NPM packages but hosted in a single repository.
for instance say we have a UI kit that is split up across the following NPM packages:
@same_fancy_library/components
@same_fancy_library/layout
@some_fancy_library/utils
This pattern of co-located but separately published packages is getting more popular/common. In those cases one could make the case for separate storybook instances, however I think that having a single storybook instance that hosts all stories is preferable from a end user UX perspective.
Furthermore, I've seen instances where submodules of big component libraries are maintained by different teams who each have their own GA View / property that they want to observe.
I think that the overhead of enabling this use-case is so small that it is likely worth exploring.
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.
@ndelangen WDYT ?
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.
I gave this some more thought, and given that storybook will get composition soon (#9210) the use-case I described is likely better served by using composition and defining a per "nested" storybook configuration.
I'll look into updating this PR to use setConfig
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.
👍
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks! |
Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook! |
What I did
I changed the google analytics add-on to utilise
addonParameters
instead of globals.This has several benefits:
How to test