UNPKG

ngx-hotjar

Version:

A simple ng wrapper to load hotjar dependency by angular way

16 lines (14 loc) 6.83 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/router"),require("@angular/common")):"function"==typeof define&&define.amd?define("ngx-hotjar",["exports","@angular/core","@angular/router","@angular/common"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["ngx-hotjar"]={},e.ng.core,e.ng.router,e.ng.common)}(this,(function(e,t,r,n){"use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */function o(e,t,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{u(n.next(e))}catch(e){i(e)}}function c(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,c)}u((n=n.apply(e,t||[])).next())}))}function i(e,t){var r,n,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(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(o=2&i[0]?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=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++,n=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],n=0}finally{r=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,c])}}}Object.create;function a(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}function c(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(a(arguments[t]));return e}Object.create;function u(e){return n.isPlatformBrowser(e)?window:null}var s=new t.InjectionToken("hj-window",{factory:function(){return u(t.inject(t.PLATFORM_ID))}});function l(e){return e?e.hj:null}var f=new t.InjectionToken("ngx-hj-fn",{providedIn:"root",factory:function(){return l(t.inject(s))}}),d=new t.InjectionToken("ngx-hotjar-settings",{factory:function(){return{trackingCode:"",version:6,ennableTracing:!1}}}),h=function(){function e(e,t){this._hj=e,this.settings=t}return Object.defineProperty(e.prototype,"lib",{get:function(){return this._hj},enumerable:!1,configurable:!0}),e.prototype.hj=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];try{this._hj.apply(this,c(e))}catch(e){(t.isDevMode()||this.settings.ennableTracing)&&console.error(e.message)}},e.prototype.virtualPageView=function(e){this.hj("vpv",e)},e.prototype.trigger=function(e){this.hj("trigger",e)},e.prototype.tagRecording=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];Array.isArray(e)||(e=[e]),this.hj("tagRecording",e.concat.apply(e,c(t)))},e.prototype.stateChange=function(e){this.hj("stateChange",e)},e.prototype.formSubmitSuccessful=function(){this.hj("formSubmitSuccessful")},e.prototype.formSubmitFailed=function(){this.hj("formSubmitFailed")},e}();h.ɵprov=t.ɵɵdefineInjectable({factory:function(){return new h(t.ɵɵinject(f),t.ɵɵinject(d))},token:h,providedIn:"root"}),h.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],h.ctorParameters=function(){return[{type:void 0,decorators:[{type:t.Inject,args:[f]}]},{type:void 0,decorators:[{type:t.Inject,args:[d]}]}]};var p={provide:t.APP_BOOTSTRAP_LISTENER,multi:!0,useFactory:g,deps:[h]};function g(e){var t=this;return function(n){return o(t,void 0,void 0,(function(){var t,o;return i(this,(function(i){return t=n.injector.get(r.Router),o=t.events.subscribe((function(t){t instanceof r.NavigationEnd&&e.stateChange(t.urlAfterRedirects)})),n.onDestroy((function(){return o.unsubscribe()})),[2]}))}))}}var v={provide:t.APP_INITIALIZER,multi:!0,useFactory:y,deps:[d,n.DOCUMENT,s]};function y(e,r,n){var a=this;return function(){return o(a,void 0,void 0,(function(){var o,a,c;return i(this,(function(i){return e.trackingCode?r?n?(Object.defineProperty(n,"hj",{value:n.hj||function(){(n.hj.q=n.hj.q||[]).push(arguments)},configurable:!0,writable:!0}),Object.defineProperty(n,"_hjSettings",{value:{hjid:e.trackingCode,hjsv:e.version||6},configurable:!0,writable:!0}),o=r.querySelector("head"),a=r.createElement("script"),c="https://static.hotjar.com/c/hotjar-"+n._hjSettings.hjid+".js?sv="+n._hjSettings.hjsv,a.async=!0,a.src=e.uri||c,o.appendChild(a),[2]):(t.isDevMode()&&console.error("Was not possible to access `window` api. Make sure this environment works like a browser."),[2]):(t.isDevMode()&&console.error("Was not possible to access `document` instance. Make shure this environment works on a Broser like API"),[2]):(t.isDevMode()&&console.error("Empty tracking code for Hotjar. Make sure to provide one when initializing NgxHotjarModule."),[2])}))}))}}var j=function(){function e(){}return e.forRoot=function(t,r,n){return void 0===r&&(r=6),{ngModule:e,providers:[{provide:d,useValue:{trackingCode:t,version:r,uri:n}},v]}},e}();j.decorators=[{type:t.NgModule,args:[{imports:[],declarations:[],exports:[]}]}];var b=function(){};b.decorators=[{type:t.NgModule,args:[{imports:[n.CommonModule,j],providers:[p],declarations:[]}]}],e.HotjarRouterInitializer=g,e.NGX_HJ_FN=f,e.NGX_HOTJAR_INITIALIZER_PROVIDER=v,e.NGX_HOTJAR_ROUTER_INITIALIZER_PROVIDER=p,e.NGX_HOTJAR_SETTINGS_TOKEN=d,e.NgxHotjarModule=j,e.NgxHotjarRouterModule=b,e.NgxHotjarService=h,e.WINDOW=s,e.getHjFn=l,e.getWindow=u,e.hotjarInitializer=y,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=ngx-hotjar.umd.min.js.map