Ionic - Basic usage not working.
See original GitHub issueFirst let me say I’m new to ionic so I may be doing something backwards or wrong.
I setup a simple project with the latest cordova and ionic. Placed the startTrackingWithId call in the MyApp constructor and a trackView call in the HomePage constructor (see below).
When running the app on my device the follow errors occur.
If this is not the right place to be posting this type of question/issue, my apologizes, please let me know where to post in the future.
2017-03-14 16:50:43.612543 analytics[2806:989870] ERROR: Unhandled Promise rejection: Tracker not started ; Zone: <root> ; Task: setTimeout ; Value: Tracker not started
2017-03-14 16:50:43.612702 analytics[2806:989870] ERROR: error JSON.stringify()ing argument: TypeError: JSON.stringify cannot serialize cyclic structures.
2017-03-14 16:50:43.710839 analytics[2806:989870] Google analytics is ready now
ionic start --v2 analytics blank
Your system information:
Cordova CLI: 6.5.0
Ionic Framework Version: 2.2.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.1.4
ios-deploy version: 1.9.1
ios-sim version: 5.0.13
OS: OS X El Capitan
Node Version: v6.1.0
Xcode version: Xcode 8.2.1 Build version 8C1002
app.component.ts
import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar, Splashscreen, GoogleAnalytics } from 'ionic-native';
import { HomePage } from '../pages/home/home';
@Component({
templateUrl: 'app.html'
})
export class MyApp {
rootPage = HomePage;
constructor(platform: Platform) {
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
StatusBar.styleDefault();
Splashscreen.hide();
// Note: A real id was used during testing.
GoogleAnalytics.startTrackerWithId('UA-XXXXXXXX-1')
.then(() => {
console.log('Google analytics is ready now');
// 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));
});
}
}
home.ts
import { Component } from '@angular/core';
import { GoogleAnalytics } from 'ionic-native';
import { NavController, Platform } from 'ionic-angular';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(public navCtrl: NavController, public platform: Platform) {
this.platform.ready().then(() => {
GoogleAnalytics.trackView('page-home');
});
}
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:5
Top Results From Across the Web
Component not working - Ionic Forum
I'm having trouble getting a basic component to work. ... You can use that module file for fast import(just import module in app.module.ts...
Read more >Ionic 4 basic ngClass not working as expected [duplicate]
Posting a solution if anyone ever stumbles across this: Basically I was trying to change the variable outside of the "angular zone" after ......
Read more >The 9 Most Common Mistakes That Ionic Developers Make
Common Mistake #9: Prototyping Ionic Applications Manually They are actually rather minimal and have a good aesthetic. Presenting wireframes and mockups with ......
Read more >10 Common Ionic Problems & Error Messages (And How to ...
10 Common Ionic Problems & Error Messages (And How to Fix Them) Last update: 2018-01-16 · 1. Cannot read property 'xyz' of undefined...
Read more >Ionicons Usage Guide
Usage. Ionicons is a completely open-source icon set with 1,300 icons crafted for web, iOS, Android, and desktop apps. Ionicons was made for...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
instead of using the constructor like:
use the ionViewDidEnter method like this:
that will fix the issue
Check the readme file for more doc updates