Support initialize call without id or expose a bool to check if ga has been initialized?
#255 opened on 2018年5月4日
説明
- I have a scenario where events happen before I get the google analytics id to create the tracker.
- Current react-ga does support ReactGA.ga('create', ID,..) to create track.
- initialize from react-ga does call 'create' command directly, which is not necessary, all I want is to loadGA so that ga is in global name space and start to queue the commands..
why dont we support initialize function without specific id? All I need is to loadGA and start to queue the commands.
Or can we just export the loadGA function ?
---------More-------- I realize it makes no sense to queue other commands before the first 'create' since they will be lost. My problem is that
- I want to apply a middleware for the google analytics to the redux store (e.g. to fire action based events to GA).
- The google analytics ID will be async loaded, so I can only
createa analytics instance after store creation. - To ensure the
pureprinciple of redux, middleware should/could not be applied dynamically during the runtime.
Before the ID is fetched, some actions have already fired and went through the middleware, however, currently I can't check whether ga instance has been created from react-ga. I know I can use window.ga to check it but it will be great if react-ga can expose a bool/function for that so I dont need to write window keyword in my code.
-------Another More----- Ok react-ga does return window.ga by the ReactGA.ga function with empty arguments, but can we have a more explicit function for checking if ga is available?