@firestitch/analytics
Advanced tools
Comparing version 12.0.0 to 12.0.1
@@ -380,20 +380,22 @@ (function (global, factory) { | ||
var _this = this; | ||
var script = document.createElement('script'); | ||
script.src = "https://www.googletagmanager.com/gtag/js?id=" + this.trackingId; | ||
script.setAttribute('async', ''); | ||
document.getElementsByTagName('head')[0].appendChild(script); | ||
this.window.dataLayer = this.window.dataLayer || []; | ||
this.window.gtag = function () { | ||
window.dataLayer.push(arguments); | ||
console.log(window.dataLayer); | ||
}; | ||
gtag('js', new Date()); | ||
gtag('config', this.trackingId, { path_path: this._router.url }); | ||
this._router.events.pipe(rxjs.skip(1), rxjs.filter(function (event) { return event instanceof i1.NavigationEnd; })) | ||
.subscribe(function (event) { | ||
gtag('event', 'page_view', { | ||
page_path: event.urlAfterRedirects, | ||
send_to: _this.trackingId | ||
if (this.trackingId) { | ||
var script = document.createElement('script'); | ||
script.src = "https://www.googletagmanager.com/gtag/js?id=" + this.trackingId; | ||
script.setAttribute('async', ''); | ||
document.getElementsByTagName('head')[0].appendChild(script); | ||
this.window.dataLayer = this.window.dataLayer || []; | ||
this.window.gtag = function () { | ||
window.dataLayer.push(arguments); | ||
console.log(window.dataLayer); | ||
}; | ||
gtag('js', new Date()); | ||
gtag('config', this.trackingId, { path_path: this._router.url }); | ||
this._router.events.pipe(operators.skip(1), operators.filter(function (event) { return event instanceof i1.NavigationEnd; })) | ||
.subscribe(function (event) { | ||
gtag('event', 'page_view', { | ||
page_path: event.urlAfterRedirects, | ||
send_to: _this.trackingId | ||
}); | ||
}); | ||
}); | ||
} | ||
}; | ||
@@ -400,0 +402,0 @@ GoogleAnalyticsProvider.prototype.gtag = function (name, value, options) { |
import { Provider } from "./provider"; | ||
import { filter, skip } from "rxjs"; | ||
import { filter, skip } from 'rxjs/operators'; | ||
import { NavigationEnd } from "@angular/router"; | ||
export class GoogleAnalyticsProvider extends Provider { | ||
init() { | ||
var script = document.createElement('script'); | ||
script.src = `https://www.googletagmanager.com/gtag/js?id=${this.trackingId}`; | ||
script.setAttribute('async', ''); | ||
document.getElementsByTagName('head')[0].appendChild(script); | ||
this.window.dataLayer = this.window.dataLayer || []; | ||
this.window.gtag = function () { | ||
window.dataLayer.push(arguments); | ||
console.log(window.dataLayer); | ||
}; | ||
gtag('js', new Date()); | ||
gtag('config', this.trackingId, { path_path: this._router.url }); | ||
this._router.events.pipe(skip(1), filter(event => event instanceof NavigationEnd)) | ||
.subscribe((event) => { | ||
gtag('event', 'page_view', { | ||
page_path: event.urlAfterRedirects, | ||
send_to: this.trackingId | ||
if (this.trackingId) { | ||
var script = document.createElement('script'); | ||
script.src = `https://www.googletagmanager.com/gtag/js?id=${this.trackingId}`; | ||
script.setAttribute('async', ''); | ||
document.getElementsByTagName('head')[0].appendChild(script); | ||
this.window.dataLayer = this.window.dataLayer || []; | ||
this.window.gtag = function () { | ||
window.dataLayer.push(arguments); | ||
console.log(window.dataLayer); | ||
}; | ||
gtag('js', new Date()); | ||
gtag('config', this.trackingId, { path_path: this._router.url }); | ||
this._router.events.pipe(skip(1), filter(event => event instanceof NavigationEnd)) | ||
.subscribe((event) => { | ||
gtag('event', 'page_view', { | ||
page_path: event.urlAfterRedirects, | ||
send_to: this.trackingId | ||
}); | ||
}); | ||
}); | ||
} | ||
} | ||
@@ -40,2 +42,2 @@ gtag(name, value, options = {}) { | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ29vZ2xlLWFuYWx5dGljcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9hcHAvcHJvdmlkZXJzL2dvb2dsZS1hbmFseXRpY3MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLFFBQVEsRUFBRSxNQUFNLFlBQVksQ0FBQztBQUV0QyxPQUFPLEVBQUUsTUFBTSxFQUFFLElBQUksRUFBRSxNQUFNLE1BQU0sQ0FBQztBQUNwQyxP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dvb2dsZUFuYWx5dGljcz8ubWVhc3VyZW1lbnRJZDtcbiAgfVxufSJdfQ== |
import * as i0 from '@angular/core'; | ||
import { InjectionToken, Injectable, Inject, Directive, Input, NgModule } from '@angular/core'; | ||
import { skip, filter, Subject, fromEvent } from 'rxjs'; | ||
import { takeUntil } from 'rxjs/operators'; | ||
import { Subject, fromEvent } from 'rxjs'; | ||
import { skip, filter, takeUntil } from 'rxjs/operators'; | ||
import * as i1 from '@angular/router'; | ||
@@ -23,20 +23,22 @@ import { NavigationEnd } from '@angular/router'; | ||
init() { | ||
var script = document.createElement('script'); | ||
script.src = `https://www.googletagmanager.com/gtag/js?id=${this.trackingId}`; | ||
script.setAttribute('async', ''); | ||
document.getElementsByTagName('head')[0].appendChild(script); | ||
this.window.dataLayer = this.window.dataLayer || []; | ||
this.window.gtag = function () { | ||
window.dataLayer.push(arguments); | ||
console.log(window.dataLayer); | ||
}; | ||
gtag('js', new Date()); | ||
gtag('config', this.trackingId, { path_path: this._router.url }); | ||
this._router.events.pipe(skip(1), filter(event => event instanceof NavigationEnd)) | ||
.subscribe((event) => { | ||
gtag('event', 'page_view', { | ||
page_path: event.urlAfterRedirects, | ||
send_to: this.trackingId | ||
if (this.trackingId) { | ||
var script = document.createElement('script'); | ||
script.src = `https://www.googletagmanager.com/gtag/js?id=${this.trackingId}`; | ||
script.setAttribute('async', ''); | ||
document.getElementsByTagName('head')[0].appendChild(script); | ||
this.window.dataLayer = this.window.dataLayer || []; | ||
this.window.gtag = function () { | ||
window.dataLayer.push(arguments); | ||
console.log(window.dataLayer); | ||
}; | ||
gtag('js', new Date()); | ||
gtag('config', this.trackingId, { path_path: this._router.url }); | ||
this._router.events.pipe(skip(1), filter(event => event instanceof NavigationEnd)) | ||
.subscribe((event) => { | ||
gtag('event', 'page_view', { | ||
page_path: event.urlAfterRedirects, | ||
send_to: this.trackingId | ||
}); | ||
}); | ||
}); | ||
} | ||
} | ||
@@ -43,0 +45,0 @@ gtag(name, value, options = {}) { |
{ | ||
"name": "@firestitch/analytics", | ||
"version": "12.0.0", | ||
"version": "12.0.1", | ||
"repository": { | ||
@@ -5,0 +5,0 @@ "type": "git", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
115777
952