added analytics code

MOHEMM-SFH-COLORS
umasoodch 4 years ago
parent b91f0a8044
commit 23eb5652e8

@ -9,9 +9,10 @@ import { PushService } from '../../src/app/hmg-common/services/push/push.service
import { LazyLoadingService } from './hmg-common/services/lazy-loading/lazy-loading.service'; import { LazyLoadingService } from './hmg-common/services/lazy-loading/lazy-loading.service';
import { DomSanitizer } from '@angular/platform-browser'; import { DomSanitizer } from '@angular/platform-browser';
import { SplashScreen } from '@ionic-native/splash-screen/ngx'; import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { Router } from '@angular/router'; import { Router, NavigationEnd } from '@angular/router';
import { DigitalIdComponent } from './authentication/digital-id/digital-id.component'; import { DigitalIdComponent } from './authentication/digital-id/digital-id.component';
import { checkAndUpdatePureExpressionInline } from '@angular/core/src/view/pure_expression'; import { checkAndUpdatePureExpressionInline } from '@angular/core/src/view/pure_expression';
import { FirebaseX } from '@ionic-native/firebase-x/ngx';
@Component({ @Component({
selector: 'app-root', selector: 'app-root',
@ -56,6 +57,7 @@ export class AppComponent implements OnInit {
public router: Router, public router: Router,
public modalController: ModalController, public modalController: ModalController,
public nav: NavController, public nav: NavController,
public firebasex: FirebaseX
) { ) {
this.events.subscribe('img-change', displayImg => { this.events.subscribe('img-change', displayImg => {
console.log('app compont: ' + displayImg); console.log('app compont: ' + displayImg);
@ -83,6 +85,7 @@ export class AppComponent implements OnInit {
this.ts.loadResources(() => { this.ts.loadResources(() => {
this.isIOS = this.platform.is('ios') ? true : false; this.isIOS = this.platform.is('ios') ? true : false;
this.initializeDirection(); this.initializeDirection();
this.monitorAnalytics();
this.start = true; this.start = true;
if (this.isIOS) { if (this.isIOS) {
this.monitUrlChange(); this.monitUrlChange();
@ -105,6 +108,25 @@ export class AppComponent implements OnInit {
}); });
} }
public monitorAnalytics() {
this.router.events.subscribe((val) => {
if (val instanceof NavigationEnd) {
const lastIndex = val.urlAfterRedirects.lastIndexOf('/');
const currentPageName = val.urlAfterRedirects.substr(lastIndex + 1);
console.log(currentPageName + ' umarrrrrrrr');
this.setScreenNameAnalytics(currentPageName);
}
});
}
public setScreenNameAnalytics(currentPageName: string) {
try {
this.firebasex.setScreenName(currentPageName).then((result)=>{
console.log(result);
});
} catch (Error) { }
}
private startReceivingPushService() { private startReceivingPushService() {
this.pushService.startReceiving(); this.pushService.startReceiving();
setTimeout(() => { setTimeout(() => {

Loading…
Cancel
Save