fix(analytics): update analytics service, add detection if google analytics was loaded

This commit is contained in:
denStrigo 2018-11-22 18:14:43 +03:00 committed by Sergey Andrievskiy
parent c998d679d5
commit c019de67c6

View file

@ -28,8 +28,14 @@ export class AnalyticsService {
} }
trackEvent(eventName: string, eventVal: string = '') { trackEvent(eventName: string, eventVal: string = '') {
if (this.enabled) { if (this.enabled && this.window.ga) {
ga('send', 'event', eventName, eventVal); ga('send', 'event', eventName, eventVal);
} }
if (!this.window.ga) {
setTimeout(() => {
this.trackEvent(eventName, eventVal);
}, 500);
}
} }
} }