I'm stuck setting up google analytics in my ionic application. Main problem is that application won't work with error "Object(...) is not a function". Did someone get this error before?
I tried to reinstall the plugin and follow more than once the ionic and google documentations. I also tried to reinstall all the node modules. I was looking for the solution here and around internet but there is no posts yet (at least, the ones that I found).
@Injectable()
export class GAProvider {
constructor(private ga: GoogleAnalytics) {
this.ga.startTrackerWithId('xx-xxxxxxx-x')
.then(() => {
console.log('Google analytics is ready now');
this.ga.trackView('test');
// Tracker is ready
// You can now track pages or set additional information such as
AppVersion or UserId
})
.catch(e => console.log('Error starting GoogleAnalytics', e));
}
}
this is my app.module.ts
@NgModule({
declarations: [
....
],
imports: [
BrowserModule,
HttpClientModule,
HttpModule,
StarRatingModule,
IonicModule.forRoot(MyApp),
AngularFireModule.initializeApp(firebaseConfig.fire),
AngularFireDatabaseModule,
Ionic2RatingModule,
AngularFireStorageModule,
GooglePlacesAutocompleteComponentModule
],
bootstrap: [IonicApp],
entryComponents: [
....
],
providers: [
...
GoogleAnalytics,
GAProvider,
...
]
})
This is my error
Error: Uncaught (in promise): TypeError: Object(...) is not a function
TypeError: Object(...) is not a function
at GoogleAnalytics.startTrackerWithId (http://localhost:8100/build/vendor.js:56910:152)
at new GAProvider (http://localhost:8100/build/main.js:2000:17)
at _createClass (http://localhost:8100/build/vendor.js:11307:20)
Thank you in advanced and hope it could be useful for someone else.