feat: demo version additions

This commit is contained in:
Sergey Andrievskiy 2019-07-15 18:52:01 +03:00
parent 06cda13fd0
commit 62e6828680
36 changed files with 1494 additions and 65 deletions

View file

@ -0,0 +1,45 @@
import { Injectable } from '@angular/core';
import { fromEvent as observableFromEvent } from 'rxjs/observable/fromEvent';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
import { Observable } from 'rxjs/Observable';
import { filter } from 'rxjs/operators/filter';
@Injectable()
export class AbService {
static readonly VARIANT_THEME_DEFAULT = 'theme-change-default';
static readonly VARIANT_THEME_COSMIC = 'theme-change-cosmic';
static readonly VARIANT_THEME_DARK = 'theme-change-dark';
static readonly VARIANT_THEME_CORPORATE = 'theme-change-corporate';
static readonly VARIANT_HIGHLIGHT_HIRE = 'highlight-hire';
static readonly VARIANT_DEVELOPERS_HIRE = 'developers-hire';
static readonly VARIANT_SOLUTION_HIRE = 'solution-hire';
static readonly VARIANT_HIDE_CALL_ACTION = 'call-action-hide';
// static readonly VARIANT_BANNER_HIRE = 'banner-hire';
private static readonly EVENT_NAME = 'ab-variant';
private static readonly AB_ENABLED = true;
private events$ = new BehaviorSubject<{ name: string }>(null);
constructor() {
if (AbService.AB_ENABLED) {
observableFromEvent<any>(document, AbService.EVENT_NAME)
.subscribe((e: { detail: any }) => {
if (e && e.detail) {
this.events$.next(e.detail);
}
});
}
}
onAbEvent(name: string = ''): Observable<{ name: string }> {
return this.events$.asObservable()
.pipe(
filter(e => !!(e && e.name)),
filter(e => name ? e.name === name : true),
);
}
}

View file

@ -1,16 +1,17 @@
import { Injectable } from '@angular/core';
import { Inject, Injectable } from '@angular/core';
import { NavigationEnd, Router } from '@angular/router';
import { Location } from '@angular/common';
import { filter } from 'rxjs/operators';
declare const ga: any;
import { NB_WINDOW } from '@nebular/theme';
@Injectable()
export class AnalyticsService {
private enabled: boolean;
private enabled = false;
constructor(private location: Location, private router: Router) {
this.enabled = false;
constructor(@Inject(NB_WINDOW) private window,
private location: Location,
private router: Router) {
this.enabled = this.window.location.href.indexOf('akveo.com') >= 0;
}
trackPageViews() {
@ -19,14 +20,18 @@ export class AnalyticsService {
filter((event) => event instanceof NavigationEnd),
)
.subscribe(() => {
ga('send', {hitType: 'pageview', page: this.location.path()});
this.gtmPushToDataLayer({event: 'pageView' , path: this.location.path()});
});
}
}
trackEvent(eventName: string) {
trackEvent(eventName: string, eventVal: string = '') {
if (this.enabled) {
ga('send', 'event', eventName);
this.gtmPushToDataLayer({ event: eventName, eventValue: eventVal });
}
}
private gtmPushToDataLayer(params) {
this.window.dataLayer.push(params);
}
}

View file

@ -1,11 +1,4 @@
import { LayoutService } from './layout.service';
import { AnalyticsService } from './analytics.service';
import { PlayerService } from './player.service';
import { StateService } from './state.service';
export {
LayoutService,
AnalyticsService,
PlayerService,
StateService,
};
export { LayoutService } from './layout.service';
export { AnalyticsService } from './analytics.service';
export { PlayerService } from './player.service';
export { StateService } from './state.service';