ngx-hotjar
Version:
A simple ng-6 wrapper to load hotjar dependency by angular way
2 lines • 3.48 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core")):"function"==typeof define&&define.amd?define("ngx-hotjar",["exports","@angular/core"],e):e(t["ngx-hotjar"]={},t.ng.core)}(this,function(t,a){"use strict";function r(n,o){var i,a,c,t,u={label:0,sent:function(){if(1&c[0])throw c[1];return c[1]},trys:[],ops:[]};return t={next:e(0),"throw":e(1),"return":e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(e){return function(t){return function r(t){if(i)throw new TypeError("Generator is already executing.");for(;u;)try{if(i=1,a&&(c=2&t[0]?a["return"]:t[0]?a["throw"]||((c=a["return"])&&c.call(a),0):a.next)&&!(c=c.call(a,t[1])).done)return c;switch(a=0,c&&(t=[2&t[0],c.value]),t[0]){case 0:case 1:c=t;break;case 4:return u.label++,{value:t[1],done:!1};case 5:u.label++,a=t[1],t=[0];continue;case 7:t=u.ops.pop(),u.trys.pop();continue;default:if(!(c=0<(c=u.trys).length&&c[c.length-1])&&(6===t[0]||2===t[0])){u=0;continue}if(3===t[0]&&(!c||t[1]>c[0]&&t[1]<c[3])){u.label=t[1];break}if(6===t[0]&&u.label<c[1]){u.label=c[1],c=t;break}if(c&&u.label<c[2]){u.label=c[2],u.ops.push(t);break}c[2]&&u.ops.pop(),u.trys.pop();continue}t=o.call(n,u)}catch(e){t=[6,e],a=0}finally{i=c=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([e,t])}}}var n=new a.InjectionToken("ngx-hotjar-settings",{factory:function(){return{trackingCode:"",version:6}}}),o={provide:a.APP_INITIALIZER,multi:!0,useFactory:e,deps:[n]};function e(i){var e=this;return function(){return function t(e,a,c,u){return new(c||(c=Promise))(function(t,r){function n(t){try{i(u.next(t))}catch(e){r(e)}}function o(t){try{i(u["throw"](t))}catch(e){r(e)}}function i(e){e.done?t(e.value):new c(function(t){t(e.value)}).then(n,o)}i((u=u.apply(e,a||[])).next())})}(e,void 0,void 0,function(){return r(this,function(t){return i.trackingCode?(e=window,r=document,e.hj=e.hj||function(){(e.hj.q=e.hj.q||[]).push(arguments)},e._hjSettings={hjid:i.trackingCode,hjsv:i.version||6},n=r.getElementsByTagName("head")[0],(o=r.createElement("script")).async=1,o.src="https://static.hotjar.com/c/hotjar-"+e._hjSettings.hjid+".js?sv="+e._hjSettings.hjsv,n.appendChild(o)):a.isDevMode()||console.error("Empty tracking code for Hotjar. Make sure to provide one when initializing NgxHotjarModule."),[2];var e,r,n,o})})}}var i=function(){function t(){}return t.prototype.virtualPageView=function(t){try{hj("vpv",t)}catch(e){this.error(e)}},t.prototype.trigger=function(t){try{hj("trigger",t)}catch(e){this.error(e)}},t.prototype.tagRecording=function(t){try{hj("tagRecording",t)}catch(e){this.error(e)}},t.prototype.stateChange=function(t){try{hj("stateChange",t)}catch(e){this.error(e)}},t.prototype.error=function(t){throw new Error("Hotjar is not loaded")},t.decorators=[{type:a.Injectable,args:[{providedIn:"root"}]}],t.ctorParameters=function(){return[]},t.ngInjectableDef=a.defineInjectable({factory:function(){return new t},token:t,providedIn:"root"}),t}(),c=function(){function r(){}return r.forRoot=function(t,e){return void 0===e&&(e=6),{ngModule:r,providers:[{provide:n,useValue:{trackingCode:t,version:e}},o]}},r.decorators=[{type:a.NgModule,args:[{imports:[],declarations:[],exports:[],providers:[]}]}],r}();t.HotjarInitializer=e,t.NGX_HOTJAR_INITIALIZER_PROVIDER=o,t.NgxHotjarService=i,t.NGX_HOTJAR_SETTINGS_TOKEN=n,t.NgxHotjarModule=c,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=ngx-hotjar.umd.min.js.map