Ionic 2 RC.0 - Google Analytics

I finally upgraded my app to Ionic 2 RC0 and when i run the app on my Device i get a error in Google Analtycs (work on latest beta)

The plugin is installed

image

Any have managed to work with RC,0?

Thanks
Baltazar

Did you manage to get this working?

Struggling with the same problemā€¦

Thanks!

Matthias

I have a issue open to resolve this problem.

and are your waiting in your source code that the platform is ready before you are using the plugin?

// wait for `ondeviceready` or use `platform.ready()` if you're using Ionic Framework 2
this.platform().then(() => { // we're assuming you injected platform in your constructor
  Camera.getPicture().then(
    res => console.log("We have taken a picture!"),
    err => console.error("Error taking picture", err)
  );
});
1 Like

Yes. Off Course!

Works now!

But not sure, what exactly caused the problemā€¦

First I ran this (suggested by mlynch here https://github.com/driftyco/ionic-native/issues/602):

ionic state reset
rm -rf node_modules
npm install

But I also had an error in my code:
I didnā€™t wait for the platform/plugins to be ready in my root page.
There I just executed GoogleAnalytics.trackView(ā€˜xxxā€™) in the constructor.

Matthias

Ok, the solution for me must have been the steps suggested by mlynch.

The code error (calling trackView in the rootpage before device ready) didnā€™t cause the complete failure of the analytics plugin.
Iā€™ve tested it, all other calls to the analytics plugin, which are executed on other pages and after the device is ready, do run into google analytics correctly.

And where you put this code?

GoogleAnalytics.startTrackerWithId(ā€œUA-XXX-XXā€);

i have in App.Component.ts and have the same error!

yes, have this code after platform ready in the constructor of app.component.ts too

So for me, donĀ“t workā€¦! It is strange, i have after platform ready and appears to be called beforeā€¦