Commit 6f6627e8 by Nabil Sadki

Add Google analytics

parent 12c49ee4
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "atapp",
"version": "1.0.8.1",
"version": "1.0.8-1",
"author": "Allo Testeurs",
"homepage": "http://www.allo-testeurs.com/",
"scripts": {
......@@ -25,6 +25,7 @@
"@ionic-native/background-mode": "^5.11.0",
"@ionic-native/core": "^5.0.0",
"@ionic-native/diagnostic": "^5.8.0",
"@ionic-native/google-analytics": "^5.15.0",
"@ionic-native/google-plus": "^5.0.0",
"@ionic-native/http": "^5.8.0",
"@ionic-native/local-notifications": "^5.11.0",
......@@ -40,6 +41,7 @@
"cordova-plugin-background-mode": "git+https://github.com/sercatven/cordova-plugin-background-mode.git",
"cordova-plugin-badge": "^0.8.8",
"cordova-plugin-file": "^6.0.1",
"cordova-plugin-google-analytics": "^1.8.6",
"cordova-plugin-googleplus": "^8.0.0",
"cordova-plugin-local-notification": "^0.9.0-beta.2",
"cordova-plugin-play-games-services": "^1.1.2",
......@@ -93,7 +95,7 @@
"fs": false,
"module": false
},
"description": "An Ionic project",
"description": "Allo Testeurs application",
"cordova": {
"plugins": {
"cordova-sqlite-storage": {},
......
......@@ -6,6 +6,8 @@ import { Platform } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';
import { LocalNotifications } from '@ionic-native/local-notifications/ngx';
import { GoogleAnalytics } from '@ionic-native/google-analytics/ngx';
import { AppVersion } from '@ionic-native/app-version/ngx';
import { TripService } from './services/trip-service';
// import { LocationService } from './services/location-service';
......@@ -24,7 +26,9 @@ export class AppComponent {
private splashScreen: SplashScreen,
private statusBar: StatusBar,
private router: Router,
private _STOR: Storage
private storage: Storage,
private ga: GoogleAnalytics,
private appVersion: AppVersion
// private _LOCAT: LocationService
) {
this.initializeApp();
......@@ -36,15 +40,23 @@ export class AppComponent {
this.statusBar.styleDefault();
this.splashScreen.hide();
// Start GA tracking
this.ga.startTrackerWithId('UA-129706772-2')
.then(() => {
this.appVersion.getVersionNumber().then((versionNumber) => {
this.ga.setAppVersion(versionNumber);
});
}).catch(e => alert('Error starting GoogleAnalytics == ' + e));
// Set params
this.setDefaultParams();
// Set locator
// this.setLocator();
// this._STOR.get('PARAM_mainslider').then((prmMainslider) => {
// this.storage.get('PARAM_mainslider').then((prmMainslider) => {
// if (prmMainslider) {
// this._STOR.get('isLoggedIn').then((isLoggedIn) => {
// this.storage.get('isLoggedIn').then((isLoggedIn) => {
// if (isLoggedIn) {
// this.router.navigateByUrl('/app/dashboard', { replaceUrl: true });
// } else {
......@@ -53,48 +65,48 @@ export class AppComponent {
// });
// } else {
// this.router.navigateByUrl('/mainslider', { replaceUrl: true });
// this._STOR.set('PARAM_mainslider', true);
// this.storage.set('PARAM_mainslider', true);
// }
// });
});
}
setDefaultParams() {
this._STOR.get('PARAM_geolocate').then((val) => {
this.storage.get('PARAM_geolocate').then((val) => {
if (val === null) {
this._STOR.set('PARAM_geolocate', true);
this.storage.set('PARAM_geolocate', true);
}
});
this._STOR.get('PARAM_geoarea').then((val) => {
this.storage.get('PARAM_geoarea').then((val) => {
if (val === null) {
this._STOR.set('PARAM_geoarea', 1000);
this.storage.set('PARAM_geoarea', 1000);
}
});
this._STOR.get('PARAM_notiftime').then((val) => {
this.storage.get('PARAM_notiftime').then((val) => {
if (val === null) {
this._STOR.set('PARAM_notiftime', 2880);
this.storage.set('PARAM_notiftime', 2880);
}
});
this._STOR.get('PARAM_trackdelay').then((val) => {
this.storage.get('PARAM_trackdelay').then((val) => {
if (val === null) {
this._STOR.set('PARAM_trackdelay', 60000);
this.storage.set('PARAM_trackdelay', 60000);
}
});
this._STOR.get('PARAM_notifnbr').then((val) => {
this.storage.get('PARAM_notifnbr').then((val) => {
if (val === null) {
this._STOR.set('PARAM_notifnbr', 'all');
this.storage.set('PARAM_notifnbr', 'all');
}
});
this._STOR.get('NOTIF_shownpartners').then((val) => {
this.storage.get('NOTIF_shownpartners').then((val) => {
if (val === null) {
this._STOR.set('NOTIF_shownpartners', []);
this.storage.set('NOTIF_shownpartners', []);
}
});
}
setLocator() {
// Start locator if ON
// this._STOR.get('PARAM_geolocate').then((val) => {
// this.storage.get('PARAM_geolocate').then((val) => {
// if (val !== null) {
// this._LOCAT.restartTracking();
// }
......
......@@ -18,7 +18,7 @@ import { LocalNotifications } from '@ionic-native/local-notifications/ngx';
import { BackgroundMode } from '@ionic-native/background-mode/ngx';
import { BackgroundGeolocation } from '@ionic-native/background-geolocation/ngx';
import { AppVersion } from '@ionic-native/app-version/ngx';
import { GooglePlus } from '@ionic-native/google-plus/ngx';
import { GoogleAnalytics } from '@ionic-native/google-analytics/ngx';
@NgModule({
declarations: [AppComponent],
......@@ -44,7 +44,7 @@ import { GooglePlus } from '@ionic-native/google-plus/ngx';
BackgroundMode,
BackgroundGeolocation,
AppVersion,
GooglePlus
GoogleAnalytics
],
bootstrap: [AppComponent]
})
......
......@@ -2,6 +2,7 @@ import { Component, ViewChild, OnInit } from '@angular/core';
import { Platform, NavController, IonSlides } from '@ionic/angular';
import { Storage } from '@ionic/storage';
import { Router } from '@angular/router';
import { GoogleAnalytics } from '@ionic-native/google-analytics/ngx';
// import { DashboardPage } from "../dashboard/dashboard";
import { PermService } from '../../services/perm-service';
import { LocationService } from '../../services/location-service';
......@@ -34,8 +35,9 @@ export class MainsliderPage implements OnInit {
private _PERM: PermService,
private _LOCATE: LocationService,
// private _ALLO: AlloService,
private _STOR: Storage,
private router: Router
private storage: Storage,
private router: Router,
private ga: GoogleAnalytics
) {
this.prmMainslider = false;
}
......@@ -46,32 +48,10 @@ export class MainsliderPage implements OnInit {
});
}
// gpsStart() {
// this._LOCATE.startTracking();
// }
// gpsStop() {
// this._LOCATE.stopTracking();
// }
// gpsStatus() {
// this._LOCATE.checkStatus();
// }
// gpsLocations() {
// this._LOCATE.getLocations();
// }
// gpsLogEntries() {
// this._LOCATE.getLogEntries();
// }
// setParam() {
// console.log(this.prmMainslider);
// this._STOR.set('PARAM_mainslider', this.prmMainslider);
// }
skipPresentation($event) {
if (this.platform.is('cordova')) {
this.ga.trackEvent('Presentation', 'Tapped button', 'Skip presentation');
}
this.mainSlider.getActiveIndex().then(index => {
this.hideSlider = true;
this.mainSlider.slideTo(4, 1000);
......@@ -81,142 +61,15 @@ export class MainsliderPage implements OnInit {
getGps() {
if (this.platform.is('cordova')) {
console.log('cord');
this.ga.trackEvent('Presentation', 'Tapped button', 'Continue with GPS');
this._PERM.checkGps();
this._LOCATE.initLocator();
}
this._STOR.set('PARAM_geolocate', true);
this.goToDashboard();
}
getDashboard() {
this._STOR.set('PARAM_geolocate', false);
this.storage.set('PARAM_geolocate', true);
this.goToDashboard();
}
goToDashboard() {
this.router.navigateByUrl('/app/dashboard');
}
ionViewDidEnter() {
console.log('ionViewDidEnter Mainslider');
// this._ALLO.presentLoading();
}
ionViewDidLoad() {
console.log('ionViewDidLoad Mainslider');
// this._ALLO.dismissLoading();
}
// getNearby() {
// this._STOR.get('REST_services').then((services) => {
// if ('object' === typeof services && services.hasOwnProperty('brands')) {
// let brands = this._ALLO.jsonToArray(services.brands);
// this._STOR.get('PARAM_geoarea').then((area) => {
// if (area === null) {
// area = 400;
// }
// this._STOR.get('NOTIF_shownpartners').then((shown) => {
// let shown_notifs = [];
// if (shown !== null) {
// shown_notifs = shown;
// }
// let notifs = [];
// brands.forEach(partner => {
// if (this.checkNotifTime(partner.id, shown_notifs)) {
// let lat1 = partner.latitude;
// let lon1 = partner.longitude;
// let lat2 = 34.253968;
// let lon2 = -6.580888;
// let distance = this._LOCATE.calculateDistance(lat1, lon1, lat2, lon2);
// if (distance <= (area / 1000)) {
// notifs.push({
// id: partner.id,
// title: 'Spotted ! ' + partner.label,
// text: 'Vous êtes tout prêt de ce partenaire!',
// led: 'FFFFFF',
// attachments: [partner.thumb],
// sound: null
// });
// let current_date = new Date();
// shown_notifs.push({
// id: partner.id,
// time: current_date.getTime()
// });
// }
// }
// });
// shown_notifs = this.makeUnique(shown_notifs);
// this._STOR.set('NOTIF_shownpartners', shown_notifs);
// if (notifs) {
// this.showMultipleNotification(notifs);
// }
// });
// });
// }
// });
// }
// makeUnique(shown) {
// let filtred = [];
// shown.forEach(notif => {
// let exist = filtred.filter(obj => {
// return obj.id === notif.id;
// });
// if (exist.length == 0) {
// filtred.push(notif);
// } else {
// filtred = filtred.filter(function (obj) {
// return obj.id !== notif.id;
// });
// filtred.push(notif);
// }
// });
// return filtred;
// }
// checkNotifTime(id, shown) {
// let valid = true;
// let notifs_count = shown.length;
// let i = 0;
// for (i = 0; i < notifs_count; i++) {
// let notif = shown[i];
// let notif_date = new Date(notif.time);
// let current_date = new Date();
// if (notif.id == id && ((current_date.getTime() - notif_date.getTime()) / 1000) <= 3600) {
// valid = false;
// break;
// }
// }
// return valid;
// }
// showNotification(title, text) {
// this.LN.requestPermission().then((granted) => {
// console.log(granted);
// if (granted) {
// this.LN.schedule({
// title: title,
// text: text,
// led: 'FFFFFF',
// sound: null
// });
// }
// });
// }
// showMultipleNotification(notifs) {
// this.LN.requestPermission().then((granted) => {
// if (granted) {
// this.LN.schedule(notifs);
// }
// });
// }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment