ngx-google-analytics
Advanced tools
Comparing version 11.2.0 to 11.2.1
@@ -754,5 +754,5 @@ (function (global, factory) { | ||
return function () { return __awaiter(_this, void 0, void 0, function () { | ||
var initialCommands, _a, _b, command, s, head; | ||
var e_1, _c; | ||
return __generator(this, function (_d) { | ||
var _a, _b, _c, command, s, head; | ||
var e_1, _d; | ||
return __generator(this, function (_e) { | ||
if (!settings.trackingCode) { | ||
@@ -777,10 +777,15 @@ if (!i0.isDevMode()) { | ||
settings.uri = settings.uri || "https://www.googletagmanager.com/gtag/js?id=" + settings.trackingCode; | ||
initialCommands = [ | ||
{ command: 'js', values: [new Date()] }, | ||
{ command: 'config', values: [settings.trackingCode] } | ||
]; | ||
settings.initCommands = __spread(initialCommands, (settings.initCommands || [])); | ||
// these commands should run first! | ||
settings.initCommands = (_a = settings === null || settings === void 0 ? void 0 : settings.initCommands) !== null && _a !== void 0 ? _a : []; | ||
// assert config command | ||
if (!settings.initCommands.find(function (x) { return x.command === 'config'; })) { | ||
settings.initCommands.unshift({ command: 'config', values: [settings.trackingCode] }); | ||
} | ||
// assert js command | ||
if (!settings.initCommands.find(function (x) { return x.command === 'js'; })) { | ||
settings.initCommands.unshift({ command: 'js', values: [new Date()] }); | ||
} | ||
try { | ||
for (_a = __values(settings.initCommands), _b = _a.next(); !_b.done; _b = _a.next()) { | ||
command = _b.value; | ||
for (_b = __values(settings.initCommands), _c = _b.next(); !_c.done; _c = _b.next()) { | ||
command = _c.value; | ||
gtag.apply(void 0, __spread([command.command], command.values)); | ||
@@ -792,3 +797,3 @@ } | ||
try { | ||
if (_b && !_b.done && (_c = _a.return)) _c.call(_a); | ||
if (_c && !_c.done && (_d = _b.return)) _d.call(_b); | ||
} | ||
@@ -795,0 +800,0 @@ finally { if (e_1) throw e_1.error; } |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common"),require("rxjs"),require("@angular/router"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("ngx-google-analytics",["exports","@angular/core","@angular/common","rxjs","@angular/router","rxjs/operators"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["ngx-google-analytics"]={},e.ng.core,e.ng.common,e.rxjs,e.ng.router,e.rxjs.operators)}(this,(function(e,t,n,r,o,i){"use strict";var a=function(){};a.decorators=[{type:t.Directive,args:[{selector:"[gaEvent][gaCategory],\n [gaCategory]",exportAs:"gaCategory"}]}],a.ctorParameters=function(){return[]},a.propDecorators={gaCategory:[{type:t.Input}]};function c(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{s(r.next(e))}catch(e){i(e)}}function c(e){try{s(r.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,c)}s((r=r.apply(e,t||[])).next())}))}function s(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}Object.create;function u(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function l(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function g(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(l(arguments[t]));return e}Object.create;var p=new t.InjectionToken("ngx-google-analytics-settings",{factory:function(){return{trackingCode:"",enableTracing:!1}}});function f(e){return n.isPlatformBrowser(e)?window:null}var d=new t.InjectionToken("ngx-window",{providedIn:"root",factory:function(){return f(t.inject(t.PLATFORM_ID))}});function y(e){return e?e.dataLayer=e.dataLayer||[]:null}var v=new t.InjectionToken("ngx-data-layer",{providedIn:"root",factory:function(){return y(t.inject(d))}});function h(e,t){return e?e.gtag=e.gtag||function(){t.push(arguments)}:null}var _=new t.InjectionToken("ngx-gtag-fn",{providedIn:"root",factory:function(){return h(t.inject(d),t.inject(v))}}),m=function(){function e(e,t,n){this.settings=e,this._document=t,this._gtag=n}return Object.defineProperty(e.prototype,"document",{get:function(){return this._document},enumerable:!1,configurable:!0}),e.prototype.throw=function(e){(this.settings.enableTracing||t.isDevMode())&&console&&console.error&&console.error(e)},e.prototype.toKeyValue=function(e){return e.size>0?Array.from(e).reduce((function(e,t){var n=l(t,2),r=n[0],o=n[1];return Object.defineProperty(e,r,{value:o,enumerable:!0})}),{}):void 0},e.prototype.gtag=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{this._gtag.apply(this,g(e.filter((function(e){return void 0!==e}))))}catch(e){this.throw(e)}},e.prototype.event=function(e,t,n,r,o){try{var i=new Map;t&&i.set("event_category",t),n&&i.set("event_label",n),r&&i.set("value",r),void 0!==o&&i.set("interaction",o);var a=this.toKeyValue(i);a?this.gtag("event",e,a):this.gtag("event",e)}catch(e){this.throw(e)}},e.prototype.pageView=function(e,t,n,r){try{var o=new Map([["page_path",e]]);t&&o.set("page_title",t),(n||this.document)&&o.set("page_location",n||this.document.location.href),r&&Object.entries(r).map((function(e){var t=l(e,2),n=t[0],r=t[1];return o.set(n,r)})),this.gtag("config",this.settings.trackingCode,this.toKeyValue(o))}catch(e){this.throw(e)}},e.prototype.appView=function(e,t,n,r,o){try{var i=new Map([["screen_name",e],["app_name",t]]);n&&i.set("app_id",n),r&&i.set("app_version",r),o&&i.set("app_installer_id",o),this.gtag("event","screen_view",this.toKeyValue(i))}catch(e){this.throw(e)}},e.prototype.set=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{this._gtag.apply(this,g(["set"],e))}catch(e){this.throw(e)}},e.prototype.exception=function(e,t){try{var n=new Map;e&&n.set("description",e),t&&n.set("fatal",t),this.toKeyValue(n)?this.gtag("event","exception",this.toKeyValue(n)):this.gtag("event","exception")}catch(e){this.throw(e)}},e}();m.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new m(t.ɵɵinject(p),t.ɵɵinject(n.DOCUMENT),t.ɵɵinject(_))},token:m,providedIn:"root"}),m.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],m.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[p]}]},{type:void 0,decorators:[{type:t.Inject,args:[n.DOCUMENT]}]},{type:void 0,decorators:[{type:t.Inject,args:[_]}]}]};var E=function(){function e(e,t,n,r){this.gaCategoryDirective=e,this.gaService=t,this.settings=n,this.el=r,this.gaBind="click"}return Object.defineProperty(e.prototype,"gaBind",{get:function(){return this._gaBind},set:function(e){var t=this;this.bindSubscription&&this.bindSubscription.unsubscribe(),this._gaBind=e,this.bindSubscription=r.fromEvent(this.el.nativeElement,e).subscribe((function(){return t.trigger()}))},enumerable:!1,configurable:!0}),e.prototype.ngOnDestroy=function(){this.bindSubscription&&this.bindSubscription.unsubscribe()},e.prototype.trigger=function(){try{if(!this.gaAction&&!this.gaEvent)throw new Error("You must provide a gaAction attribute to identify this event.");this.gaService.event(this.gaAction||this.gaEvent,this.gaCategoryDirective?this.gaCategoryDirective.gaCategory:void 0,this.gaLabel||this.label,this.gaValue,this.gaInteraction)}catch(e){this.throw(e)}},e.prototype.throw=function(e){(t.isDevMode()||this.settings.enableTracing)&&console&&console.warn&&console.warn(e)},e}();E.decorators=[{type:t.Directive,args:[{selector:"[gaEvent]",exportAs:"gaEvent"}]}],E.ctorParameters=function(){return[{type:a,decorators:[{type:t.Optional}]},{type:m},{type:void 0,decorators:[{type:t.Inject,args:[p]}]},{type:t.ElementRef}]},E.propDecorators={gaAction:[{type:t.Input}],gaLabel:[{type:t.Input}],label:[{type:t.Input}],gaValue:[{type:t.Input}],gaInteraction:[{type:t.Input}],gaEvent:[{type:t.Input}],gaBind:[{type:t.Input}]};var b,I=function(){function e(e){this.gaEvent=e,this.gaBind="focus"}return Object.defineProperty(e.prototype,"gaBind",{set:function(e){this.gaEvent&&(this.gaEvent.gaBind=e)},enumerable:!1,configurable:!0}),e}();I.decorators=[{type:t.Directive,args:[{selector:"input[gaEvent],\n select[gaEvent],\n textarea[gaEvent]"}]}],I.ctorParameters=function(){return[{type:E,decorators:[{type:t.Host},{type:t.Optional}]}]},I.propDecorators={gaBind:[{type:t.Input}]},(b=e.GaActionEnum||(e.GaActionEnum={})).ADD_PAYMENT_INFO="add_payment_info",b.ADD_TO_CART="add_to_cart",b.ADD_TO_WISHLIST="add_to_wishlist",b.BEGIN_CHECKOUT="begin_checkout",b.CHECKOUT_PROGRESS="checkout_progress",b.GENERATE_LEAD="generate_lead",b.LOGIN="login",b.PURCHASE="purchase",b.REFUND="refund",b.REMOVE_FROM_CART="remove_from_cart",b.SEARCH="search",b.SELECT_CONTENT="select_content",b.SET_CHECKOUT_OPTION="set_checkout_option",b.SHARE="share",b.SIGN_UP="sign_up",b.VIEW_ITEM="view_item",b.VIEW_ITEM_LIST="view_item_list",b.VIEW_PROMOTION="view_promotion",b.VIEW_SEARCH_RESULT="view_search_results",b.VIEW_SEARCH_RESULTS="view_search_results";var w={provide:t.APP_INITIALIZER,multi:!0,useFactory:T,deps:[p,_,n.DOCUMENT]};function T(e,n,r){var o=this;return function(){return c(o,void 0,void 0,(function(){var o,i,a,c,l,p,f;return s(this,(function(s){if(!e.trackingCode)return t.isDevMode()||console.error("Empty tracking code for Google Analytics. Make sure to provide one when initializing NgxGoogleAnalyticsModule."),[2];if(!n)return t.isDevMode()||console.error("Was not possible create or read gtag() fn. Make sure this module is running on a Browser w/ access to Window interface."),[2];r||t.isDevMode()||console.error("Was not possible to access Document interface. Make sure this module is running on a Browser w/ access do Document interface."),e.uri=e.uri||"https://www.googletagmanager.com/gtag/js?id="+e.trackingCode,o=[{command:"js",values:[new Date]},{command:"config",values:[e.trackingCode]}],e.initCommands=g(o,e.initCommands||[]);try{for(i=u(e.initCommands),a=i.next();!a.done;a=i.next())c=a.value,n.apply(void 0,g([c.command],c.values))}catch(e){p={error:e}}finally{try{a&&!a.done&&(f=i.return)&&f.call(i)}finally{if(p)throw p.error}}return(l=r.createElement("script")).async=!0,l.src=e.uri,e.nonce&&l.setAttribute("nonce",e.nonce),r.getElementsByTagName("head")[0].appendChild(l),[2]}))}))}}var A=new t.InjectionToken("ngx-google-analytics-routing-settings",{factory:function(){return{}}}),O={provide:t.APP_BOOTSTRAP_LISTENER,multi:!0,useFactory:N,deps:[A,m]};function N(e,t){var n=this;return function(r){return c(n,void 0,void 0,(function(){var n,a,c,u,l,g,p,f,d;return s(this,(function(s){return n=r.injector.get(o.Router),c=(a=null!=e?e:{}).include,u=void 0===c?[]:c,l=a.exclude,g=void 0===l?[]:l,p=C(u),f=C(g),d=n.events.pipe(i.filter((function(e){return e instanceof o.NavigationEnd})),i.skip(1),i.filter((function(e){return!(p.length>0)||p.some((function(t){return t.test(e.urlAfterRedirects)}))})),i.filter((function(e){return!(f.length>0)||!f.some((function(t){return t.test(e.urlAfterRedirects)}))}))).subscribe((function(e){return t.pageView(e.urlAfterRedirects,void 0)})),r.onDestroy((function(){return d.unsubscribe()})),[2]}))}))}}function C(e){return e.map((function(e){return e instanceof RegExp?e:new RegExp("^"+e.replace("*",".*")+"$","i")}))}var R=function(){function e(){}return e.forRoot=function(t,n,r,o,i){return void 0===n&&(n=[]),{ngModule:e,providers:[{provide:p,useValue:{trackingCode:t,initCommands:n,uri:r,enableTracing:o,nonce:i}},w]}},e}();R.decorators=[{type:t.NgModule,args:[{imports:[],declarations:[E,a,I],exports:[E,a,I]}]}];var S=function(){function e(){}return e.forRoot=function(t){return{ngModule:e,providers:[{provide:A,useValue:null!=t?t:{}}]}},e}();S.decorators=[{type:t.NgModule,args:[{imports:[n.CommonModule,R],providers:[O],declarations:[]}]}],e.GaEventCategoryDirective=a,e.GaEventDirective=E,e.GaEventFormInputDirective=I,e.GoogleAnalyticsInitializer=T,e.GoogleAnalyticsRouterInitializer=N,e.GoogleAnalyticsService=m,e.NGX_DATA_LAYER=v,e.NGX_GOOGLE_ANALYTICS_INITIALIZER_PROVIDER=w,e.NGX_GOOGLE_ANALYTICS_ROUTER_INITIALIZER_PROVIDER=O,e.NGX_GOOGLE_ANALYTICS_ROUTING_SETTINGS_TOKEN=A,e.NGX_GOOGLE_ANALYTICS_SETTINGS_TOKEN=p,e.NGX_GTAG_FN=_,e.NGX_WINDOW=d,e.NgxGoogleAnalyticsModule=R,e.NgxGoogleAnalyticsRouterModule=S,e.getDataLayerFn=y,e.getGtagFn=h,e.getWindow=f,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/common"),require("rxjs"),require("@angular/router"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("ngx-google-analytics",["exports","@angular/core","@angular/common","rxjs","@angular/router","rxjs/operators"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self)["ngx-google-analytics"]={},t.ng.core,t.ng.common,t.rxjs,t.ng.router,t.rxjs.operators)}(this,(function(t,e,n,r,o,i){"use strict";var a=function(){};a.decorators=[{type:e.Directive,args:[{selector:"[gaEvent][gaCategory],\n [gaCategory]",exportAs:"gaCategory"}]}],a.ctorParameters=function(){return[]},a.propDecorators={gaCategory:[{type:e.Input}]};function c(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function c(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,c)}s((r=r.apply(t,e||[])).next())}))}function s(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}Object.create;function u(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function l(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function g(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(l(arguments[e]));return t}Object.create;var p=new e.InjectionToken("ngx-google-analytics-settings",{factory:function(){return{trackingCode:"",enableTracing:!1}}});function f(t){return n.isPlatformBrowser(t)?window:null}var d=new e.InjectionToken("ngx-window",{providedIn:"root",factory:function(){return f(e.inject(e.PLATFORM_ID))}});function y(t){return t?t.dataLayer=t.dataLayer||[]:null}var v=new e.InjectionToken("ngx-data-layer",{providedIn:"root",factory:function(){return y(e.inject(d))}});function h(t,e){return t?t.gtag=t.gtag||function(){e.push(arguments)}:null}var _=new e.InjectionToken("ngx-gtag-fn",{providedIn:"root",factory:function(){return h(e.inject(d),e.inject(v))}}),m=function(){function t(t,e,n){this.settings=t,this._document=e,this._gtag=n}return Object.defineProperty(t.prototype,"document",{get:function(){return this._document},enumerable:!1,configurable:!0}),t.prototype.throw=function(t){(this.settings.enableTracing||e.isDevMode())&&console&&console.error&&console.error(t)},t.prototype.toKeyValue=function(t){return t.size>0?Array.from(t).reduce((function(t,e){var n=l(e,2),r=n[0],o=n[1];return Object.defineProperty(t,r,{value:o,enumerable:!0})}),{}):void 0},t.prototype.gtag=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];try{this._gtag.apply(this,g(t.filter((function(t){return void 0!==t}))))}catch(t){this.throw(t)}},t.prototype.event=function(t,e,n,r,o){try{var i=new Map;e&&i.set("event_category",e),n&&i.set("event_label",n),r&&i.set("value",r),void 0!==o&&i.set("interaction",o);var a=this.toKeyValue(i);a?this.gtag("event",t,a):this.gtag("event",t)}catch(t){this.throw(t)}},t.prototype.pageView=function(t,e,n,r){try{var o=new Map([["page_path",t]]);e&&o.set("page_title",e),(n||this.document)&&o.set("page_location",n||this.document.location.href),r&&Object.entries(r).map((function(t){var e=l(t,2),n=e[0],r=e[1];return o.set(n,r)})),this.gtag("config",this.settings.trackingCode,this.toKeyValue(o))}catch(t){this.throw(t)}},t.prototype.appView=function(t,e,n,r,o){try{var i=new Map([["screen_name",t],["app_name",e]]);n&&i.set("app_id",n),r&&i.set("app_version",r),o&&i.set("app_installer_id",o),this.gtag("event","screen_view",this.toKeyValue(i))}catch(t){this.throw(t)}},t.prototype.set=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];try{this._gtag.apply(this,g(["set"],t))}catch(t){this.throw(t)}},t.prototype.exception=function(t,e){try{var n=new Map;t&&n.set("description",t),e&&n.set("fatal",e),this.toKeyValue(n)?this.gtag("event","exception",this.toKeyValue(n)):this.gtag("event","exception")}catch(t){this.throw(t)}},t}();m.ɵprov=e.ɵɵdefineInjectable({factory:function(){return new m(e.ɵɵinject(p),e.ɵɵinject(n.DOCUMENT),e.ɵɵinject(_))},token:m,providedIn:"root"}),m.decorators=[{type:e.Injectable,args:[{providedIn:"root"}]}],m.ctorParameters=function(){return[{type:void 0,decorators:[{type:e.Inject,args:[p]}]},{type:void 0,decorators:[{type:e.Inject,args:[n.DOCUMENT]}]},{type:void 0,decorators:[{type:e.Inject,args:[_]}]}]};var E=function(){function t(t,e,n,r){this.gaCategoryDirective=t,this.gaService=e,this.settings=n,this.el=r,this.gaBind="click"}return Object.defineProperty(t.prototype,"gaBind",{get:function(){return this._gaBind},set:function(t){var e=this;this.bindSubscription&&this.bindSubscription.unsubscribe(),this._gaBind=t,this.bindSubscription=r.fromEvent(this.el.nativeElement,t).subscribe((function(){return e.trigger()}))},enumerable:!1,configurable:!0}),t.prototype.ngOnDestroy=function(){this.bindSubscription&&this.bindSubscription.unsubscribe()},t.prototype.trigger=function(){try{if(!this.gaAction&&!this.gaEvent)throw new Error("You must provide a gaAction attribute to identify this event.");this.gaService.event(this.gaAction||this.gaEvent,this.gaCategoryDirective?this.gaCategoryDirective.gaCategory:void 0,this.gaLabel||this.label,this.gaValue,this.gaInteraction)}catch(t){this.throw(t)}},t.prototype.throw=function(t){(e.isDevMode()||this.settings.enableTracing)&&console&&console.warn&&console.warn(t)},t}();E.decorators=[{type:e.Directive,args:[{selector:"[gaEvent]",exportAs:"gaEvent"}]}],E.ctorParameters=function(){return[{type:a,decorators:[{type:e.Optional}]},{type:m},{type:void 0,decorators:[{type:e.Inject,args:[p]}]},{type:e.ElementRef}]},E.propDecorators={gaAction:[{type:e.Input}],gaLabel:[{type:e.Input}],label:[{type:e.Input}],gaValue:[{type:e.Input}],gaInteraction:[{type:e.Input}],gaEvent:[{type:e.Input}],gaBind:[{type:e.Input}]};var b,I=function(){function t(t){this.gaEvent=t,this.gaBind="focus"}return Object.defineProperty(t.prototype,"gaBind",{set:function(t){this.gaEvent&&(this.gaEvent.gaBind=t)},enumerable:!1,configurable:!0}),t}();I.decorators=[{type:e.Directive,args:[{selector:"input[gaEvent],\n select[gaEvent],\n textarea[gaEvent]"}]}],I.ctorParameters=function(){return[{type:E,decorators:[{type:e.Host},{type:e.Optional}]}]},I.propDecorators={gaBind:[{type:e.Input}]},(b=t.GaActionEnum||(t.GaActionEnum={})).ADD_PAYMENT_INFO="add_payment_info",b.ADD_TO_CART="add_to_cart",b.ADD_TO_WISHLIST="add_to_wishlist",b.BEGIN_CHECKOUT="begin_checkout",b.CHECKOUT_PROGRESS="checkout_progress",b.GENERATE_LEAD="generate_lead",b.LOGIN="login",b.PURCHASE="purchase",b.REFUND="refund",b.REMOVE_FROM_CART="remove_from_cart",b.SEARCH="search",b.SELECT_CONTENT="select_content",b.SET_CHECKOUT_OPTION="set_checkout_option",b.SHARE="share",b.SIGN_UP="sign_up",b.VIEW_ITEM="view_item",b.VIEW_ITEM_LIST="view_item_list",b.VIEW_PROMOTION="view_promotion",b.VIEW_SEARCH_RESULT="view_search_results",b.VIEW_SEARCH_RESULTS="view_search_results";var w={provide:e.APP_INITIALIZER,multi:!0,useFactory:T,deps:[p,_,n.DOCUMENT]};function T(t,n,r){var o=this;return function(){return c(o,void 0,void 0,(function(){var o,i,a,c,l,p,f;return s(this,(function(s){if(!t.trackingCode)return e.isDevMode()||console.error("Empty tracking code for Google Analytics. Make sure to provide one when initializing NgxGoogleAnalyticsModule."),[2];if(!n)return e.isDevMode()||console.error("Was not possible create or read gtag() fn. Make sure this module is running on a Browser w/ access to Window interface."),[2];r||e.isDevMode()||console.error("Was not possible to access Document interface. Make sure this module is running on a Browser w/ access do Document interface."),t.uri=t.uri||"https://www.googletagmanager.com/gtag/js?id="+t.trackingCode,t.initCommands=null!==(o=null==t?void 0:t.initCommands)&&void 0!==o?o:[],t.initCommands.find((function(t){return"config"===t.command}))||t.initCommands.unshift({command:"config",values:[t.trackingCode]}),t.initCommands.find((function(t){return"js"===t.command}))||t.initCommands.unshift({command:"js",values:[new Date]});try{for(i=u(t.initCommands),a=i.next();!a.done;a=i.next())c=a.value,n.apply(void 0,g([c.command],c.values))}catch(t){p={error:t}}finally{try{a&&!a.done&&(f=i.return)&&f.call(i)}finally{if(p)throw p.error}}return(l=r.createElement("script")).async=!0,l.src=t.uri,t.nonce&&l.setAttribute("nonce",t.nonce),r.getElementsByTagName("head")[0].appendChild(l),[2]}))}))}}var A=new e.InjectionToken("ngx-google-analytics-routing-settings",{factory:function(){return{}}}),O={provide:e.APP_BOOTSTRAP_LISTENER,multi:!0,useFactory:C,deps:[A,m]};function C(t,e){var n=this;return function(r){return c(n,void 0,void 0,(function(){var n,a,c,u,l,g,p,f,d;return s(this,(function(s){return n=r.injector.get(o.Router),c=(a=null!=t?t:{}).include,u=void 0===c?[]:c,l=a.exclude,g=void 0===l?[]:l,p=N(u),f=N(g),d=n.events.pipe(i.filter((function(t){return t instanceof o.NavigationEnd})),i.skip(1),i.filter((function(t){return!(p.length>0)||p.some((function(e){return e.test(t.urlAfterRedirects)}))})),i.filter((function(t){return!(f.length>0)||!f.some((function(e){return e.test(t.urlAfterRedirects)}))}))).subscribe((function(t){return e.pageView(t.urlAfterRedirects,void 0)})),r.onDestroy((function(){return d.unsubscribe()})),[2]}))}))}}function N(t){return t.map((function(t){return t instanceof RegExp?t:new RegExp("^"+t.replace("*",".*")+"$","i")}))}var R=function(){function t(){}return t.forRoot=function(e,n,r,o,i){return void 0===n&&(n=[]),{ngModule:t,providers:[{provide:p,useValue:{trackingCode:e,initCommands:n,uri:r,enableTracing:o,nonce:i}},w]}},t}();R.decorators=[{type:e.NgModule,args:[{imports:[],declarations:[E,a,I],exports:[E,a,I]}]}];var S=function(){function t(){}return t.forRoot=function(e){return{ngModule:t,providers:[{provide:A,useValue:null!=e?e:{}}]}},t}();S.decorators=[{type:e.NgModule,args:[{imports:[n.CommonModule,R],providers:[O],declarations:[]}]}],t.GaEventCategoryDirective=a,t.GaEventDirective=E,t.GaEventFormInputDirective=I,t.GoogleAnalyticsInitializer=T,t.GoogleAnalyticsRouterInitializer=C,t.GoogleAnalyticsService=m,t.NGX_DATA_LAYER=v,t.NGX_GOOGLE_ANALYTICS_INITIALIZER_PROVIDER=w,t.NGX_GOOGLE_ANALYTICS_ROUTER_INITIALIZER_PROVIDER=O,t.NGX_GOOGLE_ANALYTICS_ROUTING_SETTINGS_TOKEN=A,t.NGX_GOOGLE_ANALYTICS_SETTINGS_TOKEN=p,t.NGX_GTAG_FN=_,t.NGX_WINDOW=d,t.NgxGoogleAnalyticsModule=R,t.NgxGoogleAnalyticsRouterModule=S,t.getDataLayerFn=y,t.getGtagFn=h,t.getWindow=f,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=ngx-google-analytics.umd.min.js.map |
# CHANGELOG | ||
* [11.2.1](#11.2.1) | ||
* [11.2.0](#11.2.0) | ||
@@ -21,2 +22,6 @@ * [11.1.0](#11.1.0) | ||
## 11.2.1 | ||
* Allow override initial commands | ||
## 11.2.0 | ||
@@ -23,0 +28,0 @@ |
@@ -25,2 +25,3 @@ import { __awaiter } from "tslib"; | ||
return () => __awaiter(this, void 0, void 0, function* () { | ||
var _a; | ||
if (!settings.trackingCode) { | ||
@@ -46,7 +47,11 @@ if (!isDevMode()) { | ||
// these commands should run first! | ||
const initialCommands = [ | ||
{ command: 'js', values: [new Date()] }, | ||
{ command: 'config', values: [settings.trackingCode] } | ||
]; | ||
settings.initCommands = [...initialCommands, ...(settings.initCommands || [])]; | ||
settings.initCommands = (_a = settings === null || settings === void 0 ? void 0 : settings.initCommands) !== null && _a !== void 0 ? _a : []; | ||
// assert config command | ||
if (!settings.initCommands.find(x => x.command === 'config')) { | ||
settings.initCommands.unshift({ command: 'config', values: [settings.trackingCode] }); | ||
} | ||
// assert js command | ||
if (!settings.initCommands.find(x => x.command === 'js')) { | ||
settings.initCommands.unshift({ command: 'js', values: [new Date()] }); | ||
} | ||
for (const command of settings.initCommands) { | ||
@@ -65,2 +70,2 @@ gtag(command.command, ...command.values); | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ29vZ2xlLWFuYWx5dGljcy5pbml0aWFsaXplci5qcyIsInNvdXJjZVJvb3QiOiIuLi8uLi8uLi9wcm9qZWN0cy9uZ3gtZ29vZ2xlLWFuYWx5dGljcy9zcmMvIiwic291cmNlcyI6WyJsaWIvaW5pdGlhbGl6ZXJzL2dvb2dsZS1hbmFseXRpY3MuaW5pdGlhbGl6ZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE9BQU8sRUFBWSxlQUFlLEVBQUUsU0FBUyxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBQ3JFLE9BQU8sRUFBRSxtQ0FBbUMsRUFB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29tbWFuZDogJ2NvbmZpZycsIHZhbHVlczogWyBzZXR0aW5ncy50cmFja2luZ0NvZGUgXSB9KVxuICAgIH1cblxuICAgIC8vIGFzc2VydCBqcyBjb21tYW5kXG4gICAgaWYgKCFzZXR0aW5ncy5pbml0Q29tbWFuZHMuZmluZCh4ID0+IHguY29tbWFuZCA9PT0gJ2pzJykpXG4gICAge1xuICAgICAgc2V0dGluZ3MuaW5pdENvbW1hbmRzLnVuc2hpZnQoeyBjb21tYW5kOiAnanMnLCB2YWx1ZXM6IFsgbmV3IERhdGUoKSBdIH0pXG4gICAgfVxuXG4gICAgZm9yIChjb25zdCBjb21tYW5kIG9mIHNldHRpbmdzLmluaXRDb21tYW5kcykge1xuICAgICAgZ3RhZyhjb21tYW5kLmNvbW1hbmQsIC4uLmNvbW1hbmQudmFsdWVzKTtcbiAgICB9XG5cbiAgICBjb25zdCBzOiBIVE1MU2NyaXB0RWxlbWVudCA9IGRvY3VtZW50LmNyZWF0ZUVsZW1lbnQoJ3NjcmlwdCcpO1xuICAgIHMuYXN5bmMgPSB0cnVlO1xuICAgIHMuc3JjID0gc2V0dGluZ3MudXJpO1xuXG4gICAgaWYgKHNldHRpbmdzLm5vbmNlKSB7XG4gICAgICBzLnNldEF0dHJpYnV0ZSgnbm9uY2UnLCBzZXR0aW5ncy5ub25jZSk7XG4gICAgfVxuXG4gICAgY29uc3QgaGVhZDogSFRNTEhlYWRFbGVtZW50ID0gZG9jdW1lbnQuZ2V0RWxlbWVudHNCeVRhZ05hbWUoJ2hlYWQnKVswXTtcbiAgICBoZWFkLmFwcGVuZENoaWxkKHMpO1xuICB9O1xufVxuIl19 |
@@ -425,2 +425,3 @@ import { Directive, Input, InjectionToken, inject, PLATFORM_ID, isDevMode, ɵɵdefineInjectable, ɵɵinject, Injectable, Inject, Optional, ElementRef, Host, APP_INITIALIZER, APP_BOOTSTRAP_LISTENER, NgModule } from '@angular/core'; | ||
return () => __awaiter(this, void 0, void 0, function* () { | ||
var _a; | ||
if (!settings.trackingCode) { | ||
@@ -446,7 +447,11 @@ if (!isDevMode()) { | ||
// these commands should run first! | ||
const initialCommands = [ | ||
{ command: 'js', values: [new Date()] }, | ||
{ command: 'config', values: [settings.trackingCode] } | ||
]; | ||
settings.initCommands = [...initialCommands, ...(settings.initCommands || [])]; | ||
settings.initCommands = (_a = settings === null || settings === void 0 ? void 0 : settings.initCommands) !== null && _a !== void 0 ? _a : []; | ||
// assert config command | ||
if (!settings.initCommands.find(x => x.command === 'config')) { | ||
settings.initCommands.unshift({ command: 'config', values: [settings.trackingCode] }); | ||
} | ||
// assert js command | ||
if (!settings.initCommands.find(x => x.command === 'js')) { | ||
settings.initCommands.unshift({ command: 'js', values: [new Date()] }); | ||
} | ||
for (const command of settings.initCommands) { | ||
@@ -453,0 +458,0 @@ gtag(command.command, ...command.values); |
{ | ||
"name": "ngx-google-analytics", | ||
"version": "11.2.0", | ||
"version": "11.2.1", | ||
"description": "A simple ng-9 wrapper to load Google Analytics dependency by angular way", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
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
360522
2735