src/app/@core/utils/analytics.service.ts
        
                        Properties | 
                
                        
  | 
                
                        Methods | 
                
constructor(location: Location, router: Router)
                     | 
                
| 
                                 Defined in src/app/@core/utils/analytics.service.ts:10 
                             | 
                        
| trackEvent | ||||||
trackEvent(eventName: string)
                     | 
                ||||||
| 
                                     Defined in src/app/@core/utils/analytics.service.ts:27 
                             | 
                        ||||||
| 
                             
                                    Parameters :
                                     
                            
 
                                Returns :      
                                void
                             | 
                
| trackPageViews | 
trackPageViews()
                     | 
                
| 
                                     Defined in src/app/@core/utils/analytics.service.ts:16 
                             | 
                        
| 
                             
                                Returns :      
                    void
                             | 
                
| Private enabled | 
                        enabled:     
                     | 
                
                            Type :     boolean
                         | 
                    
| 
                                     Defined in src/app/@core/utils/analytics.service.ts:10 
                             | 
                        
import { Injectable } from '@angular/core';
import { NavigationEnd, Router } from '@angular/router';
import { Location } from '@angular/common';
import { filter } from 'rxjs/operators';
declare const ga: any;
@Injectable()
export class AnalyticsService {
  private enabled: boolean;
  constructor(private location: Location, private router: Router) {
    this.enabled = false;
  }
  trackPageViews() {
    if (this.enabled) {
      this.router.events.pipe(
        filter((event) => event instanceof NavigationEnd),
      )
        .subscribe(() => {
          ga('send', {hitType: 'pageview', page: this.location.path()});
        });
    }
  }
  trackEvent(eventName: string) {
    if (this.enabled) {
      ga('send', 'event', eventName);
    }
  }
}