@firestitch/analytics
Advanced tools
Comparing version 12.2.0 to 12.2.1
@@ -0,0 +0,0 @@ import { ElementRef, OnDestroy, OnInit } from '@angular/core'; |
export * from './analytics.directive'; |
@@ -0,0 +0,0 @@ import { ModuleWithProviders } from '@angular/core'; |
import { InjectionToken } from '@angular/core'; | ||
export declare const FS_ANALYTICS_CONFIG: InjectionToken<any>; |
export * from './analytics-config.injector'; |
@@ -11,2 +11,5 @@ export interface FsAnalyticsConfig { | ||
}; | ||
klaviyo?: { | ||
publicApiKey: string; | ||
}; | ||
} |
export * from './analytics-config'; |
@@ -5,5 +5,6 @@ import { Provider } from "./provider"; | ||
trackEvent(action: any, value?: any, options?: any): void; | ||
addScript(): void; | ||
addScript(): Promise<void>; | ||
trackPage(path: string): void; | ||
addImg(): void; | ||
get pixelId(): string; | ||
} |
import { Provider } from "./provider"; | ||
export declare class GoogleAnalyticsProvider extends Provider { | ||
init(): void; | ||
trackPage(path: string): void; | ||
gtag(name: any, value: any, options?: {}): void; | ||
@@ -5,0 +6,0 @@ trackEvent(action: any, value?: any, options?: any): void; |
import { Provider } from "./provider"; | ||
export declare class GoogleTagsProvider extends Provider { | ||
init(): void; | ||
trackPage(path: string): void; | ||
gtag(name: any, value: any, options?: {}): void; | ||
@@ -5,0 +6,0 @@ trackEvent(action: any, value?: any, options?: any): void; |
@@ -10,6 +10,7 @@ import { Injector } from "@angular/core"; | ||
abstract trackEvent(action: any, value?: any, catgegory?: any, label?: any): void; | ||
abstract trackPage(path: any): void; | ||
constructor(_injector: Injector, _config: FsAnalyticsConfig, _router: Router); | ||
get window(): any; | ||
addScript(src: any, onload?: any): void; | ||
addScript(src: any): Promise<void>; | ||
appendHead(el: any): void; | ||
} |
@@ -0,0 +0,0 @@ import { Injector } from '@angular/core'; |
@@ -28,2 +28,4 @@ (function (global, factory) { | ||
var FS_ANALYTICS_CONFIG = new i0.InjectionToken('fs-analytics-config'); | ||
/****************************************************************************** | ||
@@ -358,5 +360,10 @@ Copyright (c) Microsoft Corporation. | ||
function Provider(_injector, _config, _router) { | ||
var _this = this; | ||
this._injector = _injector; | ||
this._config = _config; | ||
this._router = _router; | ||
this._router.events.pipe(operators.skip(1), operators.filter(function (event) { return event instanceof i1.NavigationEnd; })) | ||
.subscribe(function (event) { | ||
_this.trackPage(event.urlAfterRedirects); | ||
}); | ||
} | ||
@@ -370,13 +377,16 @@ Object.defineProperty(Provider.prototype, "window", { | ||
}); | ||
Provider.prototype.addScript = function (src, onload) { | ||
if (onload === void 0) { onload = null; } | ||
var script = document.createElement('script'); | ||
script.src = src; | ||
script.setAttribute('async', ''); | ||
if (onload) { | ||
Provider.prototype.addScript = function (src) { | ||
var _this = this; | ||
return new Promise(function (resolve, error) { | ||
var script = document.createElement('script'); | ||
script.src = src; | ||
script.setAttribute('async', ''); | ||
script.onload = function () { | ||
onload(); | ||
resolve(); | ||
}; | ||
} | ||
this.appendHead(script); | ||
script.onerror = function () { | ||
error(); | ||
}; | ||
_this.appendHead(script); | ||
}); | ||
}; | ||
@@ -389,2 +399,30 @@ Provider.prototype.appendHead = function (el) { | ||
var KlaviyoProvider = /** @class */ (function (_super) { | ||
__extends(KlaviyoProvider, _super); | ||
function KlaviyoProvider() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
KlaviyoProvider.prototype.init = function () { | ||
window._learnq = window._learnq || []; | ||
if (this.publicApiKey) { | ||
this.addScript("https://static.klaviyo.com/onsite/js/klaviyo.js?company_id=" + this.publicApiKey); | ||
} | ||
}; | ||
KlaviyoProvider.prototype.trackPage = function (path) { | ||
this.trackEvent('PageView', { path: path }); | ||
}; | ||
KlaviyoProvider.prototype.trackEvent = function (action, value) { | ||
window._learnq.push([action, value]); | ||
}; | ||
Object.defineProperty(KlaviyoProvider.prototype, "publicApiKey", { | ||
get: function () { | ||
var _a; | ||
return (_a = this._config.klaviyo) === null || _a === void 0 ? void 0 : _a.publicApiKey; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
return KlaviyoProvider; | ||
}(Provider)); | ||
var FacebookPixelProvider = /** @class */ (function (_super) { | ||
@@ -415,12 +453,15 @@ __extends(FacebookPixelProvider, _super); | ||
n.queue = []; | ||
var onload = function () { | ||
fbq('init', _this.pixelId); | ||
_this.trackEvent('PageView'); | ||
_this._router.events.pipe(operators.filter(function (event) { return event instanceof i1.NavigationEnd; })) | ||
.subscribe(function (event) { | ||
return new Promise(function (resolve, error) { | ||
_super.prototype.addScript.call(_this, "https://connect.facebook.net/en_US/fbevents.js") | ||
.then(function () { | ||
fbq('init', _this.pixelId); | ||
_this.trackEvent('PageView'); | ||
}); | ||
}; | ||
_super.prototype.addScript.call(this, "https://connect.facebook.net/en_US/fbevents.js", onload); | ||
resolve(); | ||
}) | ||
.catch(error); | ||
}); | ||
}; | ||
FacebookPixelProvider.prototype.trackPage = function (path) { | ||
this.trackEvent('PageView', { path: path }); | ||
}; | ||
FacebookPixelProvider.prototype.addImg = function () { | ||
@@ -453,3 +494,2 @@ var img = document.createElement('img'); | ||
GoogleAnalyticsProvider.prototype.init = function () { | ||
var _this = this; | ||
if (this.measurementId) { | ||
@@ -463,11 +503,10 @@ this.addScript("https://www.googletagmanager.com/gtag/js?id=" + this.measurementId); | ||
gtag('config', this.measurementId, { 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.measurementId | ||
}); | ||
}); | ||
} | ||
}; | ||
GoogleAnalyticsProvider.prototype.trackPage = function (path) { | ||
gtag('event', 'page_view', { | ||
page_path: path, | ||
send_to: this.measurementId | ||
}); | ||
}; | ||
GoogleAnalyticsProvider.prototype.gtag = function (name, value, options) { | ||
@@ -501,3 +540,2 @@ if (options === void 0) { options = {}; } | ||
GoogleTagsProvider.prototype.init = function () { | ||
var _this = this; | ||
if (this.containerId) { | ||
@@ -517,11 +555,10 @@ this.addScript("https://www.googletagmanager.com/gtm.js?id=" + this.containerId); | ||
gtag('config', this.containerId, { 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.containerId | ||
}); | ||
}); | ||
} | ||
}; | ||
GoogleTagsProvider.prototype.trackPage = function (path) { | ||
gtag('event', 'page_view', { | ||
page_path: path, | ||
send_to: this.containerId | ||
}); | ||
}; | ||
GoogleTagsProvider.prototype.gtag = function (name, value, options) { | ||
@@ -549,4 +586,2 @@ if (options === void 0) { options = {}; } | ||
var FS_ANALYTICS_CONFIG = new i0.InjectionToken('fs-analytics-config'); | ||
var FsAnalytics = /** @class */ (function () { | ||
@@ -569,2 +604,5 @@ function FsAnalytics(_config, _injector, _router) { | ||
} | ||
if (this._config.klaviyo) { | ||
this._providers.push(new KlaviyoProvider(this._injector, this._config, this._router)); | ||
} | ||
this._providers.forEach(function (provider) { | ||
@@ -571,0 +609,0 @@ provider.init(); |
@@ -0,0 +0,0 @@ import { Directive, ElementRef, Input } from '@angular/core'; |
export * from './analytics.directive'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9zcmMvYXBwL2RpcmVjdGl2ZXMvYW5hbHl0aWNzL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLGNBQWMsdUJBQXVCLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgKiBmcm9tICcuL2FuYWx5dGljcy5kaXJlY3RpdmUnO1xuIl19 |
@@ -0,0 +0,0 @@ import { NgModule } from '@angular/core'; |
import { InjectionToken } from '@angular/core'; | ||
export const FS_ANALYTICS_CONFIG = new InjectionToken('fs-analytics-config'); | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW5hbHl0aWNzLWNvbmZpZy5pbmplY3Rvci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9hcHAvaW5qZWN0b3JzL2FuYWx5dGljcy1jb25maWcuaW5qZWN0b3IudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFFLGNBQWMsRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUUvQyxNQUFNLENBQUMsTUFBTSxtQkFBbUIsR0FBRyxJQUFJLGNBQWMsQ0FBTSxxQkFBcUIsQ0FBQyxDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgSW5qZWN0aW9uVG9rZW4gfSBmcm9tICdAYW5ndWxhci9jb3JlJztcblxuZXhwb3J0IGNvbnN0IEZTX0FOQUxZVElDU19DT05GSUcgPSBuZXcgSW5qZWN0aW9uVG9rZW48YW55PignZnMtYW5hbHl0aWNzLWNvbmZpZycpO1xuIl19 |
export * from './analytics-config.injector'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvYXBwL2luamVjdG9ycy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLDZCQUE2QixDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiZXhwb3J0ICogZnJvbSAnLi9hbmFseXRpY3MtY29uZmlnLmluamVjdG9yJztcbiJdfQ== |
export {}; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW5hbHl0aWNzLWNvbmZpZy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9hcHAvaW50ZXJmYWNlcy9hbmFseXRpY3MtY29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgaW50ZXJmYWNlIEZzQW5hbHl0aWNzQ29uZmlnIHtcbiAgZ29vZ2xlQW5hbHl0aWNzPzoge1xuICAgIG1lYXN1cmVtZW50SWQ6IHN0cmluZyxcbiAgfSxcbiAgZ29vZ2xlVGFncz86IHtcbiAgICBjb250YWluZXJJZDogc3RyaW5nLFxuICB9LFxuICBmYWNlYm9va1BpeGVsPzoge1xuICAgIHBpeGVsSWQ6IHN0cmluZyxcbiAgfVxufVxuIl19 | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW5hbHl0aWNzLWNvbmZpZy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9hcHAvaW50ZXJmYWNlcy9hbmFseXRpY3MtY29uZmlnLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgaW50ZXJmYWNlIEZzQW5hbHl0aWNzQ29uZmlnIHtcbiAgZ29vZ2xlQW5hbHl0aWNzPzoge1xuICAgIG1lYXN1cmVtZW50SWQ6IHN0cmluZyxcbiAgfSxcbiAgZ29vZ2xlVGFncz86IHtcbiAgICBjb250YWluZXJJZDogc3RyaW5nLFxuICB9LFxuICBmYWNlYm9va1BpeGVsPzoge1xuICAgIHBpeGVsSWQ6IHN0cmluZyxcbiAgfSxcbiAga2xhdml5bz86IHtcbiAgICBwdWJsaWNBcGlLZXk6IHN0cmluZyxcbiAgfVxufVxuIl19 |
export * from './analytics-config'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvYXBwL2ludGVyZmFjZXMvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYyxvQkFBb0IsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCAqIGZyb20gJy4vYW5hbHl0aWNzLWNvbmZpZyc7Il19 |
import { Provider } from "./provider"; | ||
import { filter } from 'rxjs/operators'; | ||
import { NavigationEnd } from "@angular/router"; | ||
export class FacebookPixelProvider extends Provider { | ||
@@ -24,12 +22,15 @@ init() { | ||
n.queue = []; | ||
const onload = () => { | ||
fbq('init', this.pixelId); | ||
this.trackEvent('PageView'); | ||
this._router.events.pipe(filter(event => event instanceof NavigationEnd)) | ||
.subscribe((event) => { | ||
return new Promise((resolve, error) => { | ||
super.addScript(`https://connect.facebook.net/en_US/fbevents.js`) | ||
.then(() => { | ||
fbq('init', this.pixelId); | ||
this.trackEvent('PageView'); | ||
}); | ||
}; | ||
super.addScript(`https://connect.facebook.net/en_US/fbevents.js`, onload); | ||
resolve(); | ||
}) | ||
.catch(error); | ||
}); | ||
} | ||
trackPage(path) { | ||
this.trackEvent('PageView', { path }); | ||
} | ||
addImg() { | ||
@@ -50,2 +51,2 @@ var img = document.createElement('img'); | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZmFjZWJvb2stcGl4ZWwuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvYXBwL3Byb3ZpZGVycy9mYWNlYm9vay1waXhlbC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0sWUFBWSxDQUFDO0FBRXRDLE9BQU8sRUFBRSxNQUFNLEVBQUUsTUFBTSxnQkFBZ0IsQ0FBQztBQUN4QyxPQUFPLEVBQUUsYUFBYSxFQUFFLE1BQU0saUJBQWlCLENBQUM7QUFLaEQsTUFBTSxPQUFP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UoJ2hlaWdodCcsJzEnKTtcbiAgICBpbWcuc2V0QXR0cmlidXRlKCd3aWR0aCcsJzEnKTtcbiAgICBpbWcuc2V0QXR0cmlidXRlKCdzdHlsZScsJ2Rpc3BsYXk6bm9uZScpO1xuICAgIGltZy5zZXRBdHRyaWJ1dGUoJ3NyYycsYGh0dHBzOi8vd3d3LmZhY2Vib29rLmNvbS90cj9pZD0ke3RoaXMucGl4ZWxJZH0mZXY9UGFnZVZpZXcmbm9zY3JpcHQ9MWApO1xuICAgIHZhciBub3NjcmlwdCA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ25vc2NyaXB0Jyk7XG4gICAgbm9zY3JpcHQuYXBwZW5kKGltZyk7XG4gICAgdGhpcy5hcHBlbmRIZWFkKG5vc2NyaXB0KTtcbiAgfVxuXG4gIHB1YmxpYyBnZXQgcGl4ZWxJZCgpIHtcbiAgICByZXR1cm4gdGhpcy5fY29uZmlnLmZhY2Vib29rUGl4ZWw/LnBpeGVsSWQ7XG4gIH1cbn0iXX0= |
import { Provider } from "./provider"; | ||
import { filter, skip } from 'rxjs/operators'; | ||
import { NavigationEnd } from "@angular/router"; | ||
export class GoogleAnalyticsProvider extends Provider { | ||
@@ -14,11 +12,10 @@ init() { | ||
gtag('config', this.measurementId, { 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.measurementId | ||
}); | ||
}); | ||
} | ||
} | ||
trackPage(path) { | ||
gtag('event', 'page_view', { | ||
page_path: path, | ||
send_to: this.measurementId | ||
}); | ||
} | ||
gtag(name, value, options = {}) { | ||
@@ -39,2 +36,2 @@ this.window.gtag(name, value, options); | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ29vZ2xlLWFuYWx5dGljcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3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ZlbnQnLCAncGFnZV92aWV3Jywge1xuICAgICAgcGFnZV9wYXRoOiBwYXRoLFxuICAgICAgc2VuZF90bzogdGhpcy5tZWFzdXJlbWVudElkXG4gICAgfSk7XG4gIH1cblxuICBwdWJsaWMgZ3RhZyhuYW1lLCB2YWx1ZSwgb3B0aW9ucyA9IHt9KSB7XG4gICAgdGhpcy53aW5kb3cuZ3RhZyhuYW1lLCB2YWx1ZSwgb3B0aW9ucyk7XG4gIH1cblxuICBwdWJsaWMgdHJhY2tFdmVudChhY3Rpb246IGFueSwgdmFsdWU/LCBvcHRpb25zPyk6IHZvaWQge1xuICAgIHRoaXMuZ3RhZygnZXZlbnQnLCBhY3Rpb24sIHtcbiAgICAgICdldmVudF9jYXRlZ29yeSc6IG9wdGlvbnM/LmNhdGVnb3J5LFxuICAgICAgJ2V2ZW50X2xhYmVsJzogb3B0aW9ucz8ubGFiZWwsXG4gICAgICAndmFsdWUnOiB2YWx1ZVxuICAgIH0pO1xuICB9XG5cbiAgcHVibGljIGdldCBtZWFzdXJlbWVudElkKCkge1xuICAgIHJldHVybiB0aGlzLl9jb25maWcuZ29vZ2xlQW5hbHl0aWNzPy5tZWFzdXJlbWVudElkO1xuICB9XG59Il19 |
import { Provider } from "./provider"; | ||
import { filter, skip } from 'rxjs/operators'; | ||
import { NavigationEnd } from "@angular/router"; | ||
export class GoogleTagsProvider extends Provider { | ||
@@ -20,11 +18,10 @@ init() { | ||
gtag('config', this.containerId, { 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.containerId | ||
}); | ||
}); | ||
} | ||
} | ||
trackPage(path) { | ||
gtag('event', 'page_view', { | ||
page_path: path, | ||
send_to: this.containerId | ||
}); | ||
} | ||
gtag(name, value, options = {}) { | ||
@@ -45,2 +42,2 @@ this.window.gtag(name, value, options); | ||
} | ||
//# sourceMappingURL=data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iB0aGlzLl9yb3V0ZXIudXJsIH0pO1xuICAgIH1cbiAgfVxuXG4gIHB1YmxpYyB0cmFja1BhZ2UocGF0aDogc3RyaW5nKTogdm9pZCB7XG4gICAgZ3RhZygnZXZlbnQnLCAncGFnZV92aWV3Jywge1xuICAgICAgcGFnZV9wYXRoOiBwYXRoLFxuICAgICAgc2VuZF90bzogdGhpcy5jb250YWluZXJJZFxuICAgIH0pO1xuICB9XG5cbiAgcHVibGljIGd0YWcobmFtZSwgdmFsdWUsIG9wdGlvbnMgPSB7fSkge1xuICAgIHRoaXMud2luZG93Lmd0YWcobmFtZSwgdmFsdWUsIG9wdGlvbnMpO1xuICB9XG5cbiAgcHVibGljIHRyYWNrRXZlbnQoYWN0aW9uOiBhbnksIHZhbHVlPywgb3B0aW9ucz8pOiB2b2lkIHtcbiAgICB0aGlzLmd0YWcoJ2V2ZW50JywgYWN0aW9uLCB7XG4gICAgICAnZXZlbnRfY2F0ZWdvcnknOiBvcHRpb25zPy5jYXRlZ29yeSxcbiAgICAgICdldmVudF9sYWJlbCc6IG9wdGlvbnM/LmxhYmVsLFxuICAgICAgJ3ZhbHVlJzogdmFsdWVcbiAgICB9KTtcbiAgfVxuXG4gIHB1YmxpYyBnZXQgY29udGFpbmVySWQoKSB7XG4gICAgcmV0dXJuIHRoaXMuX2NvbmZpZy5nb29nbGVUYWdzPy5jb250YWluZXJJZDtcbiAgfVxufSJdfQ== |
@@ -0,1 +1,3 @@ | ||
import { NavigationEnd } from "@angular/router"; | ||
import { filter, skip } from "rxjs/operators"; | ||
export class Provider { | ||
@@ -6,2 +8,6 @@ constructor(_injector, _config, _router) { | ||
this._router = _router; | ||
this._router.events.pipe(skip(1), filter(event => event instanceof NavigationEnd)) | ||
.subscribe((event) => { | ||
this.trackPage(event.urlAfterRedirects); | ||
}); | ||
} | ||
@@ -11,12 +17,15 @@ get window() { | ||
} | ||
addScript(src, onload = null) { | ||
var script = document.createElement('script'); | ||
script.src = src; | ||
script.setAttribute('async', ''); | ||
if (onload) { | ||
addScript(src) { | ||
return new Promise((resolve, error) => { | ||
var script = document.createElement('script'); | ||
script.src = src; | ||
script.setAttribute('async', ''); | ||
script.onload = () => { | ||
onload(); | ||
resolve(); | ||
}; | ||
} | ||
this.appendHead(script); | ||
script.onerror = () => { | ||
error(); | ||
}; | ||
this.appendHead(script); | ||
}); | ||
} | ||
@@ -27,2 +36,2 @@ appendHead(el) { | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvdmlkZXIuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi9zcmMvYXBwL3Byb3ZpZGVycy9wcm92aWRlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFNQSxNQUFNLE9BQWdCLFFBQVE7SUFLNUIsWUFDWSxTQUFtQixFQUNuQixPQUEwQixFQUMxQixPQUFlO1FBRmYsY0FBUyxHQUFULFNBQVMsQ0FBVTtRQUNuQixZQUFPLEdBQVAsT0FBTyxDQUFtQjtRQUMxQixZQUFPLEdBQVAsT0FBTyxDQUFRO0lBQ3hCLENBQUM7SUFFSixJQUFXLE1BQU07UUFDZixPQUFRLE1BQWMsQ0FBQztJQUN6QixDQUFDO0lBRU0sU0FBUyxDQUFDLEdBQUcsRUFBRSxNQUFNLEdBQUcsSUFBSTtRQUNqQyxJQUFJLE1BQU0sR0FBRyxRQUFRLENBQUMsYUFBYSxDQUFDLFFBQVEsQ0FBQyxDQUFDO1FBQzlDLE1BQU0sQ0FBQyxHQUFHLEdBQUcsR0FBRyxDQUFDO1FBQ2pCLE1BQU0sQ0FBQyxZQUFZLENBQUMsT0FBTyxFQUFDLEVBQUUsQ0FBQyxDQUFDO1FBRWhDLElBQUcsTUFBTSxFQUFFO1lBQ1QsTUFBTSxDQUFDLE1BQU0sR0FBRyxHQUFHLEVBQUU7Z0JBQ25CLE1BQU0sRUFBRSxDQUFDO1lBQ1gsQ0FBQy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pYyBhZGRTY3JpcHQoc3JjKTogUHJvbWlzZTx2b2lkPiB7XG4gICAgcmV0dXJuIG5ldyBQcm9taXNlKChyZXNvbHZlLCBlcnJvcikgPT4ge1xuICAgICAgdmFyIHNjcmlwdCA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ3NjcmlwdCcpOyAgICBcbiAgICAgIHNjcmlwdC5zcmMgPSBzcmM7XG4gICAgICBzY3JpcHQuc2V0QXR0cmlidXRlKCdhc3luYycsJycpO1xuICBcbiAgICAgIHNjcmlwdC5vbmxvYWQgPSAoKSA9PiB7XG4gICAgICAgIHJlc29sdmUoKTtcbiAgICAgIH07XG5cbiAgICAgIHNjcmlwdC5vbmVycm9yID0gKCkgPT4ge1xuICAgICAgICBlcnJvcigpO1xuICAgICAgfTtcbiAgXG4gICAgICB0aGlzLmFwcGVuZEhlYWQoc2NyaXB0KTtcbiAgICB9KTtcbiAgfVxuXG4gIHB1YmxpYyBhcHBlbmRIZWFkKGVsKSB7XG4gICAgZG9jdW1lbnQuZ2V0RWxlbWVudHNCeVRhZ05hbWUoJ2hlYWQnKVswXS5hcHBlbmRDaGlsZChlbCk7XG4gIH1cbn0iXX0= |
import { Inject, Injectable, Injector } from '@angular/core'; | ||
import { Router } from '@angular/router'; | ||
import { FacebookPixelProvider } from '../providers/facebook-pixel'; | ||
import { GoogleAnalyticsProvider } from '../providers/google-analytics'; | ||
import { GoogleTagsProvider } from '../providers/google-tags'; | ||
import { FS_ANALYTICS_CONFIG } from '../injectors'; | ||
import { FacebookPixelProvider, GoogleAnalyticsProvider, GoogleTagsProvider, KlaviyoProvider } from '../providers'; | ||
import * as i0 from "@angular/core"; | ||
@@ -26,2 +24,5 @@ import * as i1 from "@angular/router"; | ||
} | ||
if (this._config.klaviyo) { | ||
this._providers.push(new KlaviyoProvider(this._injector, this._config, this._router)); | ||
} | ||
this._providers.forEach((provider) => { | ||
@@ -48,2 +49,2 @@ provider.init(); | ||
}] }, { type: i0.Injector }, { type: i1.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gICB0aGlzLl9wcm92aWRlcnMucHVzaChuZXcgR29vZ2xlVGFnc1Byb3ZpZGVyKHRoaXMuX2luamVjdG9yLCB0aGlzLl9jb25maWcsIHRoaXMuX3JvdXRlcikpO1xuICAgIH1cblxuICAgIGlmICh0aGlzLl9jb25maWcuZmFjZWJvb2tQaXhlbCkge1xuICAgICAgdGhpcy5fcHJvdmlkZXJzLnB1c2gobmV3IEZhY2Vib29rUGl4ZWxQcm92aWRlcih0aGlzLl9pbmplY3RvciwgdGhpcy5fY29uZmlnLCB0aGlzLl9yb3V0ZXIpKTtcbiAgICB9XG5cbiAgICBpZiAodGhpcy5fY29uZmlnLmtsYXZpeW8pIHtcbiAgICAgIHRoaXMuX3Byb3ZpZGVycy5wdXNoKG5ldyBLbGF2aXlvUHJvdmlkZXIodGhpcy5faW5qZWN0b3IsIHRoaXMuX2NvbmZpZywgdGhpcy5fcm91dGVyKSk7XG4gICAgfVxuXG4gICAgdGhpcy5fcHJvdmlkZXJzLmZvckVhY2goKHByb3ZpZGVyKSA9PiB7XG4gICAgICBwcm92aWRlci5pbml0KCk7XG4gICAgfSk7XG4gIH1cblxuICBwdWJsaWMgdHJhY2tFdmVudChhY3Rpb246IHN0cmluZywgZGF0YT86IGFueSkge1xuICAgIHRoaXMuX3Byb3ZpZGVycy5mb3JFYWNoKChwcm92aWRlcikgPT4ge1xuICAgICAgcHJvdmlkZXIudHJhY2tFdmVudChhY3Rpb24sIGRhdGEpO1xuICAgIH0pO1xuICB9XG59XG4iXX0= |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ export { FsAnalyticsModule } from './app/fs-analytics.module'; |
import * as i0 from '@angular/core'; | ||
import { InjectionToken, Injectable, Inject, Directive, Input, NgModule } from '@angular/core'; | ||
import { Subject, fromEvent } from 'rxjs'; | ||
import { filter, skip, takeUntil } from 'rxjs/operators'; | ||
import { skip, filter, takeUntil } from 'rxjs/operators'; | ||
import * as i1 from '@angular/router'; | ||
import { NavigationEnd } from '@angular/router'; | ||
const FS_ANALYTICS_CONFIG = new InjectionToken('fs-analytics-config'); | ||
class Provider { | ||
@@ -13,2 +15,6 @@ constructor(_injector, _config, _router) { | ||
this._router = _router; | ||
this._router.events.pipe(skip(1), filter(event => event instanceof NavigationEnd)) | ||
.subscribe((event) => { | ||
this.trackPage(event.urlAfterRedirects); | ||
}); | ||
} | ||
@@ -18,12 +24,15 @@ get window() { | ||
} | ||
addScript(src, onload = null) { | ||
var script = document.createElement('script'); | ||
script.src = src; | ||
script.setAttribute('async', ''); | ||
if (onload) { | ||
addScript(src) { | ||
return new Promise((resolve, error) => { | ||
var script = document.createElement('script'); | ||
script.src = src; | ||
script.setAttribute('async', ''); | ||
script.onload = () => { | ||
onload(); | ||
resolve(); | ||
}; | ||
} | ||
this.appendHead(script); | ||
script.onerror = () => { | ||
error(); | ||
}; | ||
this.appendHead(script); | ||
}); | ||
} | ||
@@ -35,2 +44,21 @@ appendHead(el) { | ||
class KlaviyoProvider extends Provider { | ||
init() { | ||
window._learnq = window._learnq || []; | ||
if (this.publicApiKey) { | ||
this.addScript(`https://static.klaviyo.com/onsite/js/klaviyo.js?company_id=${this.publicApiKey}`); | ||
} | ||
} | ||
trackPage(path) { | ||
this.trackEvent('PageView', { path }); | ||
} | ||
trackEvent(action, value) { | ||
window._learnq.push([action, value]); | ||
} | ||
get publicApiKey() { | ||
var _a; | ||
return (_a = this._config.klaviyo) === null || _a === void 0 ? void 0 : _a.publicApiKey; | ||
} | ||
} | ||
class FacebookPixelProvider extends Provider { | ||
@@ -56,12 +84,15 @@ init() { | ||
n.queue = []; | ||
const onload = () => { | ||
fbq('init', this.pixelId); | ||
this.trackEvent('PageView'); | ||
this._router.events.pipe(filter(event => event instanceof NavigationEnd)) | ||
.subscribe((event) => { | ||
return new Promise((resolve, error) => { | ||
super.addScript(`https://connect.facebook.net/en_US/fbevents.js`) | ||
.then(() => { | ||
fbq('init', this.pixelId); | ||
this.trackEvent('PageView'); | ||
}); | ||
}; | ||
super.addScript(`https://connect.facebook.net/en_US/fbevents.js`, onload); | ||
resolve(); | ||
}) | ||
.catch(error); | ||
}); | ||
} | ||
trackPage(path) { | ||
this.trackEvent('PageView', { path }); | ||
} | ||
addImg() { | ||
@@ -93,11 +124,10 @@ var img = document.createElement('img'); | ||
gtag('config', this.measurementId, { 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.measurementId | ||
}); | ||
}); | ||
} | ||
} | ||
trackPage(path) { | ||
gtag('event', 'page_view', { | ||
page_path: path, | ||
send_to: this.measurementId | ||
}); | ||
} | ||
gtag(name, value, options = {}) { | ||
@@ -135,11 +165,10 @@ this.window.gtag(name, value, options); | ||
gtag('config', this.containerId, { 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.containerId | ||
}); | ||
}); | ||
} | ||
} | ||
trackPage(path) { | ||
gtag('event', 'page_view', { | ||
page_path: path, | ||
send_to: this.containerId | ||
}); | ||
} | ||
gtag(name, value, options = {}) { | ||
@@ -161,4 +190,2 @@ this.window.gtag(name, value, options); | ||
const FS_ANALYTICS_CONFIG = new InjectionToken('fs-analytics-config'); | ||
class FsAnalytics { | ||
@@ -181,2 +208,5 @@ constructor(_config, _injector, _router) { | ||
} | ||
if (this._config.klaviyo) { | ||
this._providers.push(new KlaviyoProvider(this._injector, this._config, this._router)); | ||
} | ||
this._providers.forEach((provider) => { | ||
@@ -183,0 +213,0 @@ provider.init(); |
@@ -0,0 +0,0 @@ /** |
{ | ||
"name": "@firestitch/analytics", | ||
"version": "12.2.0", | ||
"version": "12.2.1", | ||
"repository": { | ||
@@ -5,0 +5,0 @@ "type": "git", |
@@ -0,0 +0,0 @@ export { FsAnalyticsModule } from './app/fs-analytics.module'; |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
163704
38
1379
0