New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@loopkit/javascript

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@loopkit/javascript - npm Package Compare versions

Comparing version
1.0.5
to
1.0.6
+2
-2
dist/loopkit.min.js
/*!
* LoopKit JavaScript SDK v1.0.5
* LoopKit JavaScript SDK v1.0.6
* (c) 2025 LoopKit
* Released under the MIT License
*/
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).LoopKit=t()}(this,(function(){"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function t(e,t,n,i,r,o,s){try{var a=e[o](s),u=a.value}catch(e){return void n(e)}a.done?t(u):Promise.resolve(u).then(i,r)}function n(e){return function(){var n=this,i=arguments;return new Promise((function(r,o){var s=e.apply(n,i);function a(e){t(s,r,o,a,u,"next",e)}function u(e){t(s,r,o,a,u,"throw",e)}a(void 0)}))}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,h(i.key),i)}}function o(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e,t,n){return(t=h(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function u(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(Object(n),!0).forEach((function(t){s(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function l(){var e,t,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",r=n.toStringTag||"@@toStringTag";function o(n,i,r,o){var u=i&&i.prototype instanceof a?i:a,l=Object.create(u.prototype);return c(l,"_invoke",function(n,i,r){var o,a,u,l=0,c=r||[],g=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,a=0,u=e,h.n=n,s}};function f(n,i){for(a=n,u=i,t=0;!g&&l&&!r&&t<c.length;t++){var r,o=c[t],f=h.p,d=o[2];n>3?(r=d===i)&&(u=o[(a=o[4])?5:(a=3,3)],o[4]=o[5]=e):o[0]<=f&&((r=n<2&&f<o[1])?(a=0,h.v=i,h.n=o[1]):f<d&&(r=n<3||o[0]>i||i>d)&&(o[4]=n,o[5]=i,h.n=d,a=0))}if(r||n>1)return s;throw g=!0,i}return function(r,c,d){if(l>1)throw TypeError("Generator is already running");for(g&&1===c&&f(c,d),a=c,u=d;(t=a<2?e:u)||!g;){o||(a?a<3?(a>1&&(h.n=-1),f(a,u)):h.n=u:h.v=u);try{if(l=2,o){if(a||(r="next"),t=o[r]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,a<2&&(a=0)}else 1===a&&(t=o.return)&&t.call(o),a<2&&(u=TypeError("The iterator does not provide a '"+r+"' method"),a=1);o=e}else if((t=(g=h.n<0)?u:n.call(i,h))!==s)break}catch(t){o=e,a=1,u=t}finally{l=1}}return{value:t,done:g}}}(n,r,o),!0),l}var s={};function a(){}function u(){}function g(){}t=Object.getPrototypeOf;var h=[][i]?t(t([][i]())):(c(t={},i,(function(){return this})),t),f=g.prototype=a.prototype=Object.create(h);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,g):(e.__proto__=g,c(e,r,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=g,c(f,"constructor",g),c(g,"constructor",u),u.displayName="GeneratorFunction",c(g,r,"GeneratorFunction"),c(f),c(f,r,"Generator"),c(f,i,(function(){return this})),c(f,"toString",(function(){return"[object Generator]"})),(l=function(){return{w:o,m:d}})()}function c(e,t,n,i){var r=Object.defineProperty;try{r({},"",{})}catch(e){r=0}c=function(e,t,n,i){if(t)r?r(e,t,{value:n,enumerable:!i,configurable:!i,writable:!i}):e[t]=n;else{function o(t,n){c(e,t,(function(e){return this._invoke(t,n,e)}))}o("next",0),o("throw",1),o("return",2)}},c(e,t,n,i)}function g(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(t,n){if(t){if("string"==typeof t)return e(t,n);var i={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?e(t,n):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}var f=function(){return o((function e(){i(this,e)}),null,[{key:"isDoNotTrackEnabled",value:function(){return"undefined"!=typeof navigator&&"undefined"!=typeof window&&("1"===navigator.doNotTrack||"1"===window.doNotTrack||"1"===navigator.msDoNotTrack)}}])}(),d=function(){return o((function e(t,n,r,o,s){i(this,e),this.config=t,this.logger=n,this.queueManager=r,this.sessionManager=o,this.idGenerator=s}),[{key:"updateConfig",value:function(e){this.config=e}},{key:"track",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(e&&"string"==typeof e){if(!this.config.respectDoNotTrack||!f.isDoNotTrackEnabled()){var r=this.createEvent("track",u({name:e,properties:u({},t)},n),i),o=r;if(this.config.onBeforeTrack&&"function"==typeof this.config.onBeforeTrack)try{o=this.config.onBeforeTrack(r)||r}catch(e){this.logger.error("Error in onBeforeTrack callback",e)}return this.queueManager.enqueueEvent(o),this.logger.debug("Event tracked",{name:e,properties:t}),this}this.logger.info("Tracking disabled due to Do Not Track")}else this.logger.error("Event name is required and must be a string")}},{key:"identify",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.createEvent("identify",{userId:e,properties:u({},t)});return this.queueManager.enqueueEvent(n),this}},{key:"group",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"organization",i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=this.createEvent("group",{groupId:e,groupType:n,properties:u({},t)},i);return this.queueManager.enqueueEvent(r),this}},{key:"createEvent",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i={id:this.idGenerator.generateEventId(),timestamp:Date.now(),anonymousId:this.sessionManager.getAnonymousId(),page:{path:"undefined"!=typeof window?window.location.pathname:null,url:"undefined"!=typeof window?window.location.href:null,title:"undefined"!=typeof document?document.title:null,referrer:"undefined"!=typeof document?document.referrer:null},sdk:{name:"@loopkit/javascript",version:"1.0.5"},sessionId:this.sessionManager.getSessionId()};return"undefined"!=typeof window&&(i.context={userAgent:navigator.userAgent,screen:{width:window.screen.width,height:window.screen.height},viewport:{width:window.innerWidth,height:window.innerHeight}}),"track"===e?u(u({},i),{},{userId:n.userId,name:t.name,properties:t.properties}):"identify"===e?u(u({},i),{},{userId:t.userId,properties:t.properties}):"group"===e?u(u({},i),{},{userId:n.userId,groupId:t.groupId,groupType:t.groupType,properties:t.properties}):u(u({},i),{},{type:e},t)}}])}(),p=function(){return o((function e(t,n,r){i(this,e),this.config=t,this.logger=n,this.storageManager=r,this.eventQueue=[],this.flushTimer=null,this.flushTimerStartTime=null,this.networkManager=null}),[{key:"updateConfig",value:function(e){this.config=e}},{key:"setNetworkManager",value:function(e){this.networkManager=e}},{key:"getQueueSize",value:function(){return this.eventQueue.length}},{key:"enqueueEvent",value:function(e){var t=this;if(this.eventQueue.length>=this.config.maxQueueSize&&(this.logger.warn("Event queue full, dropping oldest event"),this.eventQueue.shift()),this.eventQueue.push(e),this.config.debug){var n=this.eventQueue.length,i=n>=this.config.batchSize,r=null;if(!i&&this.config.flushInterval>0){var o=Date.now();if(this.flushTimerStartTime){var s=o-this.flushTimerStartTime,a=1e3*this.config.flushInterval;r=Math.max(0,a-s%a)}else r=1e3*this.config.flushInterval}var u={eventType:e.name?"track":e.userId&&!e.groupId?"identify":"group",eventName:e.name||(e.userId&&!e.groupId?"identify":"group"),queueSize:n,batchSize:this.config.batchSize,willAutoFlush:i,timeUntilNextFlushMs:r,timeUntilNextFlushSeconds:r?Math.round(r/1e3):null};this.logger.debug("Event added to queue".concat(i?" - triggering immediate flush":""),u)}this.config.enableLocalStorage&&this.storageManager.persistQueue(this.eventQueue),this.eventQueue.length>=this.config.batchSize&&this.flush(this.networkManager).catch((function(e){t.logger.error("Auto-flush failed",e)}))}},{key:"flush",value:(e=n(l().m((function e(t){var n,i,r,o,s,a,u,c,h=this;return l().w((function(e){for(;;)switch(e.n){case 0:if(0!==this.eventQueue.length){e.n=1;break}return this.logger.debug("No events to flush"),e.a(2);case 1:return n=g(this.eventQueue),this.eventQueue=[],i=Date.now(),this.logger.debug("Starting flush of ".concat(n.length," events")),r={tracks:[],identifies:[],groups:[]},n.forEach((function(e){void 0!==e.name?r.tracks.push(e):e.userId&&void 0===e.groupId?r.identifies.push(e):e.groupId&&r.groups.push(e)})),this.config.debug&&this.logger.debug("Events grouped for batch sending",{tracksCount:r.tracks.length,identifiesCount:r.identifies.length,groupsCount:r.groups.length,totalEvents:n.length}),e.p=2,o=[],r.tracks.length>0&&o.push(t.sendEvents("tracks",r.tracks)),r.identifies.length>0&&o.push(t.sendEvents("identifies",r.identifies)),r.groups.length>0&&o.push(t.sendEvents("groups",r.groups)),e.n=3,Promise.all(o);case 3:s=Date.now()-i,this.config.debug&&this.logger.debug("Batch flush completed successfully",{eventsCount:n.length,tracksCount:r.tracks.length,identifiesCount:r.identifies.length,groupsCount:r.groups.length,flushDurationMs:s,endpointsSent:o.length,queueSizeAfterFlush:this.eventQueue.length}),this.config.enableLocalStorage&&this.storageManager.clearQueue(),this.config.onAfterTrack&&"function"==typeof this.config.onAfterTrack&&n.forEach((function(e){try{h.config.onAfterTrack(e,!0)}catch(e){h.logger.error("Error in onAfterTrack callback",e)}})),e.n=5;break;case 4:if(e.p=4,c=e.v,u=Date.now()-i,this.config.debug?this.logger.error("Batch flush failed",{eventsCount:n.length,tracksCount:r.tracks.length,identifiesCount:r.identifies.length,groupsCount:r.groups.length,flushDurationMs:u,errorMessage:c.message,errorType:c.constructor.name,queueSizeAfterRequeue:this.eventQueue.length+n.length}):this.logger.error("Failed to flush events",c),(a=this.eventQueue).unshift.apply(a,g(n)),this.config.onAfterTrack&&"function"==typeof this.config.onAfterTrack&&n.forEach((function(e){try{h.config.onAfterTrack(e,!1)}catch(e){h.logger.error("Error in onAfterTrack callback",e)}})),this.config.onError&&"function"==typeof this.config.onError)try{this.config.onError(c)}catch(e){this.logger.error("Error in onError callback",e)}throw c;case 5:return e.a(2)}}),e,this,[[2,4]])}))),function(t){return e.apply(this,arguments)})},{key:"scheduleFlush",value:function(){var e=this;this.config.flushInterval>0&&!this.flushTimer&&(this.flushTimerStartTime=Date.now(),this.flushTimer=setTimeout((function(){e.eventQueue.length>0&&e.flush(e.networkManager).catch((function(t){e.logger.error("Scheduled flush failed",t)}))}),1e3*this.config.flushInterval))}},{key:"loadPersistedQueue",value:function(){var e,t=this.storageManager.loadQueue();t&&Array.isArray(t)&&((e=this.eventQueue).push.apply(e,g(t)),this.logger.debug("Loaded ".concat(t.length," events from storage")))}},{key:"clearFlushTimer",value:function(){this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=null,this.flushTimerStartTime=null)}},{key:"reset",value:function(){this.eventQueue=[],this.clearFlushTimer()}},{key:"restartAutoFlush",value:function(){this.clearFlushTimer(),this.scheduleFlush()}}]);var e}(),v=function(){return o((function e(t,n){i(this,e),this.config=t,this.logger=n}),[{key:"updateConfig",value:function(e){this.config=e}},{key:"sendEvents",value:(e=n(l().m((function e(t,n){var i,r,o,s,a,u,c,g,h,f,d,p,v,y,m=arguments;return l().w((function(e){for(;;)switch(e.n){case 0:if(i=m.length>2&&void 0!==m[2]?m[2]:0,r="".concat(this.config.baseURL,"/").concat(t,"?apiKey=").concat(encodeURIComponent(this.config.apiKey)),o=Date.now(),"tracks"!==t){e.n=1;break}s={tracks:n},e.n=4;break;case 1:if("identifies"!==t){e.n=2;break}s={identifies:n},e.n=4;break;case 2:if("groups"!==t){e.n=3;break}s={groups:n},e.n=4;break;case 3:throw new Error("Invalid endpoint: ".concat(t));case 4:return a={"Content-Type":"application/json"},this.config.debug&&this.logger.debug("Sending ".concat(n.length," events to ").concat(t," endpoint").concat(i>0?" (retry ".concat(i,")"):""),{endpoint:t,eventsCount:n.length,retryAttempt:i,url:r.replace(/apiKey=[^&]+/,"apiKey=***"),payloadSize:JSON.stringify(s).length}),e.p=5,u=new AbortController,c=setTimeout((function(){return u.abort()}),this.config.requestTimeout),e.n=6,fetch(r,{method:"POST",headers:a,body:JSON.stringify(s),signal:u.signal});case 6:if(g=e.v,clearTimeout(c),h=Date.now()-o,g&&g.ok){e.n=7;break}throw f=g?g.statusText:"Network error",d=g?g.status:0,new Error(d?"HTTP ".concat(d,": ").concat(f):f);case 7:this.config.debug?this.logger.debug("Successfully sent ".concat(n.length," ").concat(t," events"),{endpoint:t,eventsCount:n.length,sendDurationMs:h,responseStatus:g.status,retryAttempt:i}):this.logger.debug("Successfully sent ".concat(n.length," ").concat(t," events")),e.n=11;break;case 8:if(e.p=8,y=e.v,p=Date.now()-o,this.config.debug?this.logger.error("Failed to send ".concat(t," events (attempt ").concat(i+1,")"),{endpoint:t,eventsCount:n.length,sendDurationMs:p,retryAttempt:i+1,maxRetries:this.config.maxRetries,errorMessage:y.message,errorType:y.constructor.name}):this.logger.error("Failed to send ".concat(t," events (attempt ").concat(i+1,")"),y),!(i<this.config.maxRetries)){e.n=10;break}return v=this.calculateRetryDelay(i),this.config.debug?this.logger.debug("Retrying ".concat(t," endpoint in ").concat(v,"ms"),{endpoint:t,retryDelay:v,nextRetryAttempt:i+2,maxRetries:this.config.maxRetries}):this.logger.debug("Retrying in ".concat(v,"ms")),e.n=9,new Promise((function(e){return setTimeout(e,v)}));case 9:return e.a(2,this.sendEvents(t,n,i+1));case 10:throw y;case 11:return e.a(2)}}),e,this,[[5,8]])}))),function(t,n){return e.apply(this,arguments)})},{key:"calculateRetryDelay",value:function(e){return"exponential"===this.config.retryBackoff?Math.min(1e3*Math.pow(2,e),3e4):1e3*(e+1)}},{key:"sendBeacon",value:function(e){if(!navigator.sendBeacon||0===e.length)return!1;var t={tracks:[],identifies:[],groups:[]};e.forEach((function(e){void 0!==e.name?t.tracks.push(e):e.userId&&void 0===e.groupId?t.identifies.push(e):e.groupId&&t.groups.push(e)}));var n=0;if(t.tracks.length>0){var i="".concat(this.config.baseURL,"/tracks?apiKey=").concat(encodeURIComponent(this.config.apiKey)),r={tracks:t.tracks};navigator.sendBeacon(i,JSON.stringify(r))&&n++}if(t.identifies.length>0){var o="".concat(this.config.baseURL,"/identifies?apiKey=").concat(encodeURIComponent(this.config.apiKey)),s={identifies:t.identifies};navigator.sendBeacon(o,JSON.stringify(s))&&n++}if(t.groups.length>0){var a="".concat(this.config.baseURL,"/groups?apiKey=").concat(encodeURIComponent(this.config.apiKey)),u={groups:t.groups};navigator.sendBeacon(a,JSON.stringify(u))&&n++}return n>0&&(this.logger.debug("Events sent via beacon to ".concat(n," endpoints")),!0)}}]);var e}(),y=function(){return o((function e(t,n,r,o,s){i(this,e),this.config=t,this.logger=n,this.eventTracker=r,this.sessionManager=o,this.queueManager=s,this.networkManager=null}),[{key:"updateConfig",value:function(e){this.config=e}},{key:"setNetworkManager",value:function(e){this.networkManager=e}},{key:"setupFeatures",value:function(){this.config.enableAutoCapture&&this.setupAutoPageViews(),this.config.enableAutoClickTracking&&this.setupAutoClickTracking(),this.config.enableErrorTracking&&this.setupErrorTracking(),this.setupPageUnloadHandling(),this.logger.debug("Browser features setup completed")}},{key:"setupAutoPageViews",value:function(){var e=this;window.addEventListener("load",(function(){e.eventTracker.track("page_view",{page:window.location.pathname,title:document.title,referrer:document.referrer})})),window.addEventListener("popstate",(function(){e.eventTracker.track("page_view",{page:window.location.pathname,title:document.title})})),this.logger.debug("Auto page view tracking enabled")}},{key:"setupAutoClickTracking",value:function(){var e=this;if("undefined"!=typeof document){var t={pathname:window.location.pathname,title:document.title,href:window.location.href},n=function(){t={pathname:window.location.pathname,title:document.title,href:window.location.href}};window.addEventListener("popstate",n),window.addEventListener("pushstate",n),window.addEventListener("replacestate",n),document.addEventListener("click",(function(i){try{var r=t.pathname,o=t.title,s=t.href;n();for(var a=i.target,u=null,l=0;a&&a.tagName&&l<5&&!(u=e.getClickableElementInfo(a));)a=a.parentElement,l++;if(u){var c={element_type:u.type,element_text:u.text,element_id:u.id,element_class:u.className,element_tag:u.tag,page:r,page_title:o,page_url:s,position:{x:i.clientX,y:i.clientY}};u.href&&(c.element_href=u.href),u.ariaLabel&&(c.element_aria_label=u.ariaLabel),e.config.debug&&l>0&&(c.traversal_depth=l,c.original_target_tag=i.target.tagName.toLowerCase()),e.eventTracker.track("element_click",c)}}catch(t){e.logger.warn("Error in auto click tracking",t)}}),{capture:!0,passive:!0}),this.logger.debug("Auto click tracking enabled with capture phase")}}},{key:"getClickableElementInfo",value:function(e){if(!e||!e.tagName)return null;var t=e.tagName.toLowerCase();if(!this.isClickableElement(e))return null;var n="";e.innerText?n=e.innerText.trim():e.textContent?n=e.textContent.trim():e.value?n=e.value.trim():e.alt?n=e.alt.trim():e.title&&(n=e.title.trim()),n.length>100&&(n=n.substring(0,97)+"...");var i=t;"input"===t?i=e.type||"input":"button"===t?i="submit"===e.type?"submit_button":"button":"a"===t&&(i="link");var r=null;e.href?r=e.href:e.getAttribute&&e.getAttribute("href")&&(r=e.getAttribute("href"));var o=null;e.getAttribute&&e.getAttribute("aria-label")&&(o=e.getAttribute("aria-label").trim());var s={type:i,text:n,id:e.id||null,className:e.className||null,tag:t};return r&&(s.href=r),o&&(s.ariaLabel=o),s}},{key:"isClickableElement",value:function(e){var t=e.tagName.toLowerCase();if(["button","a","input","select","textarea"].includes(t))return!0;if(e.onclick||"button"===e.getAttribute("role")||"link"===e.getAttribute("role")||null!==e.getAttribute("tabindex")||"pointer"===e.style.cursor)return!0;var n=e.className||"";return!!["btn","button","link","clickable","interactive"].some((function(e){return n.toLowerCase().includes(e)}))||!!(e.hasAttribute("data-click")||e.hasAttribute("data-action")||e.hasAttribute("ng-click")||e.hasAttribute("@click")||e.hasAttribute("v-on:click"))}},{key:"setupErrorTracking",value:function(){var e=this;window.addEventListener("error",(function(t){var n;e.eventTracker.track("javascript_error",{message:t.message,filename:t.filename,line:t.lineno,column:t.colno,stack:null===(n=t.error)||void 0===n?void 0:n.stack})})),window.addEventListener("unhandledrejection",(function(t){var n,i;e.eventTracker.track("promise_rejection",{reason:null===(n=t.reason)||void 0===n?void 0:n.toString(),stack:null===(i=t.reason)||void 0===i?void 0:i.stack})})),this.logger.debug("Auto error tracking enabled")}},{key:"setupPageUnloadHandling",value:function(){var e=this;window.addEventListener("beforeunload",(function(){e.config.enableSessionTracking&&e.sessionManager.endSession(),e.queueManager.getQueueSize()>0&&e.sendBeacon()})),document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&e.queueManager.getQueueSize()>0&&e.sendBeacon()})),this.logger.debug("Page unload handling enabled")}},{key:"sendBeacon",value:function(){if(this.networkManager&&this.queueManager.getQueueSize()>0){var e=g(this.queueManager.eventQueue);this.networkManager.sendBeacon(e)&&(this.queueManager.eventQueue=[])}}}])}(),m=function(){return o((function e(t,n){i(this,e),this.config=t,this.logger=n}),[{key:"updateConfig",value:function(e){this.config=e}},{key:"getStorage",value:function(){return"undefined"!=typeof global&&global.localStorage?global.localStorage:"undefined"!=typeof localStorage?localStorage:null}},{key:"persistQueue",value:function(e){if(this.config.enableLocalStorage){var t=this.getStorage();if(t)try{t.setItem("loopkit_queue",JSON.stringify(e))}catch(e){this.logger.warn("Failed to persist queue",e)}}}},{key:"loadQueue",value:function(){if(!this.config.enableLocalStorage)return[];var e=this.getStorage();if(e)try{var t=e.getItem("loopkit_queue");if(t){var n=JSON.parse(t);if(Array.isArray(n))return n}}catch(e){this.logger.warn("Failed to load persisted queue",e)}return[]}},{key:"clearQueue",value:function(){if(this.config.enableLocalStorage){var e=this.getStorage();if(e)try{e.removeItem("loopkit_queue")}catch(e){this.logger.warn("Failed to clear persisted queue",e)}}}},{key:"loadAnonymousId",value:function(){if(!this.config.enableLocalStorage)return null;var e=this.getStorage();if(e)try{var t=e.getItem("loopkit_anonymousId");if(t)return t}catch(e){this.logger.warn("Failed to load anonymous ID",e)}return null}},{key:"saveAnonymousId",value:function(e){if(this.config.enableLocalStorage){var t=this.getStorage();if(t)try{t.setItem("loopkit_anonymousId",e)}catch(e){this.logger.warn("Failed to save anonymous ID",e)}}}},{key:"clearAnonymousId",value:function(){if(this.config.enableLocalStorage){var e=this.getStorage();if(e)try{e.removeItem("loopkit_anonymousId")}catch(e){this.logger.warn("Failed to clear anonymous ID",e)}}}},{key:"clearAll",value:function(){this.clearQueue(),this.clearAnonymousId()}}])}(),k=function(){return o((function e(t,n,r,o){i(this,e),this.config=t,this.logger=n,this.idGenerator=r,this.storageManager=o,this.sessionId=this.idGenerator.generateSessionId(),this.anonymousId=this.loadOrGenerateAnonymousId(),this.sessionStarted=!1,this.lastActivityTime=Date.now(),this.sessionTimer=null}),[{key:"updateConfig",value:function(e){this.config=e}},{key:"getSessionId",value:function(){return this.sessionId}},{key:"getAnonymousId",value:function(){return this.anonymousId}},{key:"loadOrGenerateAnonymousId",value:function(){if(this.storageManager){var e=this.storageManager.loadAnonymousId();if(e)return e}var t=this.idGenerator.generateAnonymousId();return this.storageManager&&this.storageManager.saveAnonymousId(t),t}},{key:"startSession",value:function(){this.sessionStarted||(this.sessionStarted=!0,this.lastActivityTime=Date.now(),this.setupActivityTracking(),this.logger.debug("Session started",{sessionId:this.sessionId}))}},{key:"endSession",value:function(){if(this.sessionStarted){var e=Math.round((Date.now()-this.lastActivityTime)/1e3);this.sessionStarted=!1,this.sessionTimer&&(clearTimeout(this.sessionTimer),this.sessionTimer=null),this.logger.debug("Session ended",{sessionId:this.sessionId,duration:e})}}},{key:"updateActivity",value:function(){var e=this;this.lastActivityTime=Date.now(),this.sessionTimer&&clearTimeout(this.sessionTimer),this.sessionTimer=setTimeout((function(){e.endSession()}),1e3*this.config.sessionTimeout)}},{key:"setupActivityTracking",value:function(){var e=this;if("undefined"!=typeof window){var t=this.throttle((function(){e.updateActivity()}),5e3);["mousedown","mousemove","keypress","scroll","touchstart","click"].forEach((function(e){window.addEventListener(e,t,{passive:!0})})),this.updateActivity()}}},{key:"throttle",value:function(e,t){var n;return function(){var i=arguments;n||(e.apply(this,i),n=!0,setTimeout((function(){return n=!1}),t))}}},{key:"reset",value:function(){this.sessionTimer&&(clearTimeout(this.sessionTimer),this.sessionTimer=null),this.sessionId=this.idGenerator.generateSessionId(),this.anonymousId=this.loadOrGenerateAnonymousId(),this.sessionStarted=!1,this.lastActivityTime=Date.now()}}])}(),b=function(){return o((function e(t){i(this,e),this.config=t}),[{key:"updateConfig",value:function(e){this.config=e}},{key:"log",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(this.config.debug){var i=["error","warn","info","debug"],r=i.indexOf(this.config.logLevel);if(i.indexOf(e)<=r){var o=new Date,s="".concat(o.toLocaleDateString()," ").concat(o.toLocaleTimeString(),".").concat(o.getMilliseconds().toString().padStart(3,"0")),a=u(u({},n),{},{timestamp:s,version:"1.0.5"}),l="[LoopKit] ".concat(t);n?console[e](l,a):console[e](l,{timestamp:s,version:"1.0.5"})}}}},{key:"error",value:function(e,t){this.log("error",e,t)}},{key:"warn",value:function(e,t){this.log("warn",e,t)}},{key:"info",value:function(e,t){this.log("info",e,t)}},{key:"debug",value:function(e,t){this.log("debug",e,t)}}])}(),w=function(){return o((function e(){i(this,e)}),[{key:"validate",value:function(e){if(e.batchSize<=0)throw new Error("batchSize must be greater than 0");if(e.flushInterval<0)throw new Error("flushInterval must be >= 0");if(e.maxQueueSize<=0)throw new Error("maxQueueSize must be greater than 0");if(e.requestTimeout<=0)throw new Error("requestTimeout must be greater than 0");if(e.maxRetries<0)throw new Error("maxRetries must be >= 0");if(e.sessionTimeout<=0)throw new Error("sessionTimeout must be greater than 0")}}])}(),T=function(){return o((function e(){i(this,e)}),[{key:"generateSessionId",value:function(){return"sess_"+Math.random().toString(36).substr(2,9)+"_"+Date.now()}},{key:"generateAnonymousId",value:function(){return"anon_"+Math.random().toString(36).substr(2,9)+"_"+Date.now()}},{key:"generateEventId",value:function(){return"evt_"+Math.random().toString(36).substr(2,9)+"_"+Date.now()}}])}(),S=function(){return o((function e(){i(this,e),this.version="1.0.5",this.config={apiKey:null,baseURL:"https://drain.loopkit.ai/v1",batchSize:50,flushInterval:30,maxQueueSize:1e3,enableCompression:!0,requestTimeout:1e4,debug:!1,logLevel:"debug",enableAutoCapture:!0,enableAutoClickTracking:!0,enableErrorTracking:!0,enableSessionTracking:!0,sessionTimeout:1800,respectDoNotTrack:!0,enableLocalStorage:!0,maxRetries:3,retryBackoff:"exponential",onBeforeTrack:null,onAfterTrack:null,onError:null},this.initialized=!1,this.userId=null,this.userProperties={},this.groupId=null,this.groupProperties={},this.logger=new b(this.config),this.configValidator=new w,this.idGenerator=new T,this.storageManager=new m(this.config,this.logger),this.queueManager=new p(this.config,this.logger,this.storageManager),this.networkManager=new v(this.config,this.logger),this.sessionManager=new k(this.config,this.logger,this.idGenerator,this.storageManager),this.eventTracker=new d(this.config,this.logger,this.queueManager,this.sessionManager,this.idGenerator),"undefined"!=typeof window&&(this.browserFeatures=new y(this.config,this.logger,this.eventTracker,this.sessionManager,this.queueManager)),this.track=this.track.bind(this),this.identify=this.identify.bind(this),this.group=this.group.bind(this),this.trackBatch=this.trackBatch.bind(this),this.flush=this.flush.bind(this)}),[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e||"string"!=typeof e)throw new Error("LoopKit: API key is required and must be a string");return this.initialized&&this.queueManager.stopAutoFlush(),this.config.apiKey=e,this.configure(t),this.initialized=!0,this.updateModuleConfigs(),this.logger.info("LoopKit initialized",{apiKey:e.substring(0,8)+"...",version:this.version}),this.queueManager.setNetworkManager(this.networkManager),this.queueManager.scheduleFlush(),this.config.enableLocalStorage&&this.queueManager.loadPersistedQueue(),this.config.enableSessionTracking&&this.sessionManager.startSession(),this.browserFeatures&&(this.browserFeatures.setNetworkManager(this.networkManager),this.browserFeatures.setupFeatures()),this}},{key:"configure",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this.config.flushInterval;return this.config=u(u({},this.config),e),this.configValidator.validate(this.config),this.updateModuleConfigs(),this.logger.debug("LoopKit configured",this.config),this.initialized&&void 0!==e.flushInterval&&t!==this.config.flushInterval&&this.queueManager.restartAutoFlush(),this}},{key:"track",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.initialized?(this.eventTracker.track(e,t,n,{userId:this.userId,userProperties:this.userProperties,groupId:this.groupId,groupProperties:this.groupProperties}),this):(this.logger.warn("LoopKit not initialized. Call init() first."),this)}},{key:"identify",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.initialized?e&&"string"==typeof e?(this.userId=e,this.userProperties=u(u({},this.userProperties),t),this.eventTracker.identify(e,t),this.logger.debug("User identified",{userId:e,properties:t}),this):(this.logger.error("User ID is required and must be a string"),this):(this.logger.warn("LoopKit not initialized. Call init() first."),this)}},{key:"group",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"organization";return this.initialized?e&&"string"==typeof e?n&&"string"==typeof n?(this.groupId=e,this.groupProperties=u(u({},this.groupProperties),t),this.eventTracker.group(e,t,n,{userId:this.userId}),this.logger.debug("User grouped",{groupId:e,groupType:n,properties:t}),this):(this.logger.error("Group type is required and must be a string"),this):(this.logger.error("Group ID is required and must be a string"),this):(this.logger.warn("LoopKit not initialized. Call init() first."),this)}},{key:"trackBatch",value:function(e){var t=this;return this.initialized?Array.isArray(e)?(e.forEach((function(e){e.name&&e.properties?t.track(e.name,e.properties):t.logger.warn("Invalid event in batch",e)})),this):(this.logger.error("Events must be an array"),this):(this.logger.warn("LoopKit not initialized. Call init() first."),this)}},{key:"flush",value:(e=n(l().m((function e(){return l().w((function(e){for(;;)switch(e.n){case 0:if(this.initialized){e.n=1;break}return this.logger.warn("LoopKit not initialized. Call init() first."),e.a(2);case 1:return e.a(2,this.queueManager.flush(this.networkManager))}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"getQueueSize",value:function(){return this.queueManager.getQueueSize()}},{key:"getConfig",value:function(){return u({},this.config)}},{key:"getVersion",value:function(){return this.version}},{key:"reset",value:function(){return this.userId=null,this.userProperties={},this.groupId=null,this.groupProperties={},this.queueManager.reset(),this.sessionManager.reset(),this.storageManager.clearAll(),this.initialized=!1,this.logger.debug("SDK state reset"),this}},{key:"resetForTesting",value:function(){return this.reset(),this.config={apiKey:null,baseURL:"https://drain.loopkit.ai/v1",batchSize:50,flushInterval:30,maxQueueSize:1e3,enableCompression:!0,requestTimeout:1e4,debug:!1,logLevel:"debug",enableAutoCapture:!1,enableAutoClickTracking:!1,enableErrorTracking:!1,enableSessionTracking:!0,sessionTimeout:1800,respectDoNotTrack:!0,enableLocalStorage:!0,maxRetries:3,retryBackoff:"exponential",onBeforeTrack:null,onAfterTrack:null,onError:null},this.updateModuleConfigs(),this.logger.debug("SDK state reset for testing"),this}},{key:"updateModuleConfigs",value:function(){this.logger.updateConfig(this.config),this.storageManager.updateConfig(this.config),this.queueManager.updateConfig(this.config),this.networkManager.updateConfig(this.config),this.sessionManager.updateConfig(this.config),this.eventTracker.updateConfig(this.config),this.browserFeatures&&this.browserFeatures.updateConfig(this.config)}}]);var e}(),I=new S;return"undefined"!=typeof module&&module.exports?module.exports=I:"undefined"!=typeof window&&(window.LoopKit=I),I}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).LoopKit=t()}(this,(function(){"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function t(e,t,n,i,r,o,s){try{var a=e[o](s),u=a.value}catch(e){return void n(e)}a.done?t(u):Promise.resolve(u).then(i,r)}function n(e){return function(){var n=this,i=arguments;return new Promise((function(r,o){var s=e.apply(n,i);function a(e){t(s,r,o,a,u,"next",e)}function u(e){t(s,r,o,a,u,"throw",e)}a(void 0)}))}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,h(i.key),i)}}function o(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e,t,n){return(t=h(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function u(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(Object(n),!0).forEach((function(t){s(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function c(){var e,t,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",r=n.toStringTag||"@@toStringTag";function o(n,i,r,o){var u=i&&i.prototype instanceof a?i:a,c=Object.create(u.prototype);return l(c,"_invoke",function(n,i,r){var o,a,u,c=0,l=r||[],g=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,n){return o=t,a=0,u=e,h.n=n,s}};function f(n,i){for(a=n,u=i,t=0;!g&&c&&!r&&t<l.length;t++){var r,o=l[t],f=h.p,d=o[2];n>3?(r=d===i)&&(u=o[(a=o[4])?5:(a=3,3)],o[4]=o[5]=e):o[0]<=f&&((r=n<2&&f<o[1])?(a=0,h.v=i,h.n=o[1]):f<d&&(r=n<3||o[0]>i||i>d)&&(o[4]=n,o[5]=i,h.n=d,a=0))}if(r||n>1)return s;throw g=!0,i}return function(r,l,d){if(c>1)throw TypeError("Generator is already running");for(g&&1===l&&f(l,d),a=l,u=d;(t=a<2?e:u)||!g;){o||(a?a<3?(a>1&&(h.n=-1),f(a,u)):h.n=u:h.v=u);try{if(c=2,o){if(a||(r="next"),t=o[r]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,a<2&&(a=0)}else 1===a&&(t=o.return)&&t.call(o),a<2&&(u=TypeError("The iterator does not provide a '"+r+"' method"),a=1);o=e}else if((t=(g=h.n<0)?u:n.call(i,h))!==s)break}catch(t){o=e,a=1,u=t}finally{c=1}}return{value:t,done:g}}}(n,r,o),!0),c}var s={};function a(){}function u(){}function g(){}t=Object.getPrototypeOf;var h=[][i]?t(t([][i]())):(l(t={},i,(function(){return this})),t),f=g.prototype=a.prototype=Object.create(h);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,g):(e.__proto__=g,l(e,r,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=g,l(f,"constructor",g),l(g,"constructor",u),u.displayName="GeneratorFunction",l(g,r,"GeneratorFunction"),l(f),l(f,r,"Generator"),l(f,i,(function(){return this})),l(f,"toString",(function(){return"[object Generator]"})),(c=function(){return{w:o,m:d}})()}function l(e,t,n,i){var r=Object.defineProperty;try{r({},"",{})}catch(e){r=0}l=function(e,t,n,i){if(t)r?r(e,t,{value:n,enumerable:!i,configurable:!i,writable:!i}):e[t]=n;else{function o(t,n){l(e,t,(function(e){return this._invoke(t,n,e)}))}o("next",0),o("throw",1),o("return",2)}},l(e,t,n,i)}function g(t){return function(t){if(Array.isArray(t))return e(t)}(t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(t,n){if(t){if("string"==typeof t)return e(t,n);var i={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?e(t,n):void 0}}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function h(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function f(e){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},f(e)}var d=function(){return o((function e(){i(this,e)}),null,[{key:"isDoNotTrackEnabled",value:function(){return"undefined"!=typeof navigator&&"undefined"!=typeof window&&("1"===navigator.doNotTrack||"1"===window.doNotTrack||"1"===navigator.msDoNotTrack)}}])}(),p=function(){return o((function e(t,n,r,o,s){i(this,e),this.config=t,this.logger=n,this.queueManager=r,this.sessionManager=o,this.idGenerator=s}),[{key:"updateConfig",value:function(e){this.config=e}},{key:"track",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(e&&"string"==typeof e){if(!this.config.respectDoNotTrack||!d.isDoNotTrackEnabled()){var r=this.createEvent("track",u({name:e,properties:u({},t)},n),i),o=r;if(this.config.onBeforeTrack&&"function"==typeof this.config.onBeforeTrack)try{o=this.config.onBeforeTrack(r)||r}catch(e){this.logger.error("Error in onBeforeTrack callback",e)}return this.queueManager.enqueueEvent(o),this.logger.debug("Event tracked",{name:e,properties:t}),this}this.logger.info("Tracking disabled due to Do Not Track")}else this.logger.error("Event name is required and must be a string")}},{key:"identify",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.createEvent("identify",{userId:e,properties:u({},t)});return this.queueManager.enqueueEvent(n),this}},{key:"group",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"organization",i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},r=this.createEvent("group",{groupId:e,groupType:n,properties:u({},t)},i);return this.queueManager.enqueueEvent(r),this}},{key:"createEvent",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i={anonymousId:this.sessionManager.getAnonymousId(),timestamp:(new Date).toISOString()},r={sdk:{name:"@loopkit/javascript",version:"1.0.6"},sessionId:this.sessionManager.getSessionId()};return"undefined"!=typeof window&&(r.context={page:{url:window.location.href,path:window.location.pathname,search:window.location.search,title:document.title,referrer:document.referrer},userAgent:navigator.userAgent,screen:{width:window.screen.width,height:window.screen.height},viewport:{width:window.innerWidth,height:window.innerHeight}}),"track"===e?u(u({},i),{},{userId:n.userId,name:t.name,properties:t.properties,system:r}):"identify"===e?u(u({},i),{},{userId:t.userId,properties:t.properties,system:r}):"group"===e?u(u({},i),{},{userId:n.userId,groupId:t.groupId,groupType:t.groupType,properties:t.properties,system:r}):u(u(u({},i),{},{type:e},t),{},{system:r})}}])}(),v=function(){return o((function e(t,n,r){i(this,e),this.config=t,this.logger=n,this.storageManager=r,this.eventQueue=[],this.flushTimer=null,this.flushTimerStartTime=null,this.networkManager=null}),[{key:"updateConfig",value:function(e){this.config=e}},{key:"setNetworkManager",value:function(e){this.networkManager=e}},{key:"getQueueSize",value:function(){return this.eventQueue.length}},{key:"enqueueEvent",value:function(e){var t=this;if(this.eventQueue.length>=this.config.maxQueueSize&&(this.logger.warn("Event queue full, dropping oldest event"),this.eventQueue.shift()),this.eventQueue.push(e),this.config.debug){var n=this.eventQueue.length,i=n>=this.config.batchSize,r=null;if(!i&&this.config.flushInterval>0){var o=Date.now();if(this.flushTimerStartTime){var s=o-this.flushTimerStartTime,a=1e3*this.config.flushInterval;r=Math.max(0,a-s%a)}else r=1e3*this.config.flushInterval}var u={eventType:e.name?"track":e.userId&&!e.groupId?"identify":"group",eventName:e.name||(e.userId&&!e.groupId?"identify":"group"),queueSize:n,batchSize:this.config.batchSize,willAutoFlush:i,timeUntilNextFlushMs:r,timeUntilNextFlushSeconds:r?Math.round(r/1e3):null};this.logger.debug("Event added to queue".concat(i?" - triggering immediate flush":""),u)}this.config.enableLocalStorage&&this.storageManager.persistQueue(this.eventQueue),this.eventQueue.length>=this.config.batchSize&&this.flush(this.networkManager).catch((function(e){t.logger.error("Auto-flush failed",e)}))}},{key:"flush",value:(e=n(c().m((function e(t){var n,i,r,o,s,a,u,l,h=this;return c().w((function(e){for(;;)switch(e.n){case 0:if(0!==this.eventQueue.length){e.n=1;break}return this.logger.debug("No events to flush"),e.a(2);case 1:return n=g(this.eventQueue),this.eventQueue=[],i=Date.now(),this.logger.debug("Starting flush of ".concat(n.length," events")),r={tracks:[],identifies:[],groups:[]},n.forEach((function(e){void 0!==e.name?r.tracks.push(e):e.userId&&void 0===e.groupId?r.identifies.push(e):e.groupId&&r.groups.push(e)})),this.config.debug&&this.logger.debug("Events grouped for batch sending",{tracksCount:r.tracks.length,identifiesCount:r.identifies.length,groupsCount:r.groups.length,totalEvents:n.length}),e.p=2,o=[],r.tracks.length>0&&o.push(t.sendEvents("tracks",r.tracks)),r.identifies.length>0&&o.push(t.sendEvents("identifies",r.identifies)),r.groups.length>0&&o.push(t.sendEvents("groups",r.groups)),e.n=3,Promise.all(o);case 3:s=Date.now()-i,this.config.debug&&this.logger.debug("Batch flush completed successfully",{eventsCount:n.length,tracksCount:r.tracks.length,identifiesCount:r.identifies.length,groupsCount:r.groups.length,flushDurationMs:s,endpointsSent:o.length,queueSizeAfterFlush:this.eventQueue.length}),this.config.enableLocalStorage&&this.storageManager.clearQueue(),this.config.onAfterTrack&&"function"==typeof this.config.onAfterTrack&&n.forEach((function(e){try{h.config.onAfterTrack(e,!0)}catch(e){h.logger.error("Error in onAfterTrack callback",e)}})),e.n=5;break;case 4:if(e.p=4,l=e.v,u=Date.now()-i,this.config.debug?this.logger.error("Batch flush failed",{eventsCount:n.length,tracksCount:r.tracks.length,identifiesCount:r.identifies.length,groupsCount:r.groups.length,flushDurationMs:u,errorMessage:l.message,errorType:l.constructor.name,queueSizeAfterRequeue:this.eventQueue.length+n.length}):this.logger.error("Failed to flush events",l),(a=this.eventQueue).unshift.apply(a,g(n)),this.config.onAfterTrack&&"function"==typeof this.config.onAfterTrack&&n.forEach((function(e){try{h.config.onAfterTrack(e,!1)}catch(e){h.logger.error("Error in onAfterTrack callback",e)}})),this.config.onError&&"function"==typeof this.config.onError)try{this.config.onError(l)}catch(e){this.logger.error("Error in onError callback",e)}throw l;case 5:return e.a(2)}}),e,this,[[2,4]])}))),function(t){return e.apply(this,arguments)})},{key:"scheduleFlush",value:function(){var e=this;this.config.flushInterval>0&&!this.flushTimer&&(this.flushTimerStartTime=Date.now(),this.flushTimer=setTimeout((function(){e.eventQueue.length>0&&e.flush(e.networkManager).catch((function(t){e.logger.error("Scheduled flush failed",t)}))}),1e3*this.config.flushInterval))}},{key:"loadPersistedQueue",value:function(){var e,t=this.storageManager.loadQueue();t&&Array.isArray(t)&&((e=this.eventQueue).push.apply(e,g(t)),this.logger.debug("Loaded ".concat(t.length," events from storage")))}},{key:"clearFlushTimer",value:function(){this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=null,this.flushTimerStartTime=null)}},{key:"reset",value:function(){this.eventQueue=[],this.clearFlushTimer()}},{key:"restartAutoFlush",value:function(){this.clearFlushTimer(),this.scheduleFlush()}}]);var e}(),y=function(){return o((function e(t,n){i(this,e),this.config=t,this.logger=n}),[{key:"updateConfig",value:function(e){this.config=e}},{key:"sendEvents",value:(e=n(c().m((function e(t,n){var i,r,o,s,a,u,l,g,h,f,d,p,v,y,m=arguments;return c().w((function(e){for(;;)switch(e.n){case 0:if(i=m.length>2&&void 0!==m[2]?m[2]:0,r="".concat(this.config.baseURL,"/").concat(t,"?apiKey=").concat(encodeURIComponent(this.config.apiKey)),o=Date.now(),"tracks"!==t){e.n=1;break}s={tracks:n},e.n=4;break;case 1:if("identifies"!==t){e.n=2;break}s={identifies:n},e.n=4;break;case 2:if("groups"!==t){e.n=3;break}s={groups:n},e.n=4;break;case 3:throw new Error("Invalid endpoint: ".concat(t));case 4:return a={"Content-Type":"application/json"},this.config.debug&&this.logger.debug("Sending ".concat(n.length," events to ").concat(t," endpoint").concat(i>0?" (retry ".concat(i,")"):""),{endpoint:t,eventsCount:n.length,retryAttempt:i,url:r.replace(/apiKey=[^&]+/,"apiKey=***"),payloadSize:JSON.stringify(s).length}),e.p=5,u=new AbortController,l=setTimeout((function(){return u.abort()}),this.config.requestTimeout),e.n=6,fetch(r,{method:"POST",headers:a,body:JSON.stringify(s),signal:u.signal});case 6:if(g=e.v,clearTimeout(l),h=Date.now()-o,g&&g.ok){e.n=7;break}throw f=g?g.statusText:"Network error",d=g?g.status:0,new Error(d?"HTTP ".concat(d,": ").concat(f):f);case 7:this.config.debug?this.logger.debug("Successfully sent ".concat(n.length," ").concat(t," events"),{endpoint:t,eventsCount:n.length,sendDurationMs:h,responseStatus:g.status,retryAttempt:i}):this.logger.debug("Successfully sent ".concat(n.length," ").concat(t," events")),e.n=11;break;case 8:if(e.p=8,y=e.v,p=Date.now()-o,this.config.debug?this.logger.error("Failed to send ".concat(t," events (attempt ").concat(i+1,")"),{endpoint:t,eventsCount:n.length,sendDurationMs:p,retryAttempt:i+1,maxRetries:this.config.maxRetries,errorMessage:y.message,errorType:y.constructor.name}):this.logger.error("Failed to send ".concat(t," events (attempt ").concat(i+1,")"),y),!(i<this.config.maxRetries)){e.n=10;break}return v=this.calculateRetryDelay(i),this.config.debug?this.logger.debug("Retrying ".concat(t," endpoint in ").concat(v,"ms"),{endpoint:t,retryDelay:v,nextRetryAttempt:i+2,maxRetries:this.config.maxRetries}):this.logger.debug("Retrying in ".concat(v,"ms")),e.n=9,new Promise((function(e){return setTimeout(e,v)}));case 9:return e.a(2,this.sendEvents(t,n,i+1));case 10:throw y;case 11:return e.a(2)}}),e,this,[[5,8]])}))),function(t,n){return e.apply(this,arguments)})},{key:"calculateRetryDelay",value:function(e){return"exponential"===this.config.retryBackoff?Math.min(1e3*Math.pow(2,e),3e4):1e3*(e+1)}},{key:"sendBeacon",value:function(e){if(!navigator.sendBeacon||0===e.length)return!1;var t={tracks:[],identifies:[],groups:[]};e.forEach((function(e){void 0!==e.name?t.tracks.push(e):e.userId&&void 0===e.groupId?t.identifies.push(e):e.groupId&&t.groups.push(e)}));var n=0;if(t.tracks.length>0){var i="".concat(this.config.baseURL,"/tracks?apiKey=").concat(encodeURIComponent(this.config.apiKey)),r={tracks:t.tracks};navigator.sendBeacon(i,JSON.stringify(r))&&n++}if(t.identifies.length>0){var o="".concat(this.config.baseURL,"/identifies?apiKey=").concat(encodeURIComponent(this.config.apiKey)),s={identifies:t.identifies};navigator.sendBeacon(o,JSON.stringify(s))&&n++}if(t.groups.length>0){var a="".concat(this.config.baseURL,"/groups?apiKey=").concat(encodeURIComponent(this.config.apiKey)),u={groups:t.groups};navigator.sendBeacon(a,JSON.stringify(u))&&n++}return n>0&&(this.logger.debug("Events sent via beacon to ".concat(n," endpoints")),!0)}}]);var e}(),m=function(){return o((function e(t,n,r,o,s){i(this,e),this.config=t,this.logger=n,this.eventTracker=r,this.sessionManager=o,this.queueManager=s,this.networkManager=null}),[{key:"updateConfig",value:function(e){this.config=e}},{key:"setNetworkManager",value:function(e){this.networkManager=e}},{key:"setupFeatures",value:function(){this.config.enableAutoCapture&&this.setupAutoPageViews(),this.config.enableAutoClickTracking&&this.setupAutoClickTracking(),this.config.enableErrorTracking&&this.setupErrorTracking(),this.setupPageUnloadHandling(),this.logger.debug("Browser features setup completed")}},{key:"setupAutoPageViews",value:function(){var e=this;window.addEventListener("load",(function(){e.eventTracker.track("page_view",{page:window.location.pathname,title:document.title,referrer:document.referrer})})),window.addEventListener("popstate",(function(){e.eventTracker.track("page_view",{page:window.location.pathname,title:document.title})})),this.logger.debug("Auto page view tracking enabled")}},{key:"setupAutoClickTracking",value:function(){var e=this;if("undefined"!=typeof document){var t={pathname:window.location.pathname,title:document.title,href:window.location.href},n=function(){t={pathname:window.location.pathname,title:document.title,href:window.location.href}};window.addEventListener("popstate",n),window.addEventListener("pushstate",n),window.addEventListener("replacestate",n),document.addEventListener("click",(function(i){try{var r=t.pathname,o=t.title,s=t.href;n();for(var a=i.target,u=null,c=0;a&&a.tagName&&c<5&&!(u=e.getClickableElementInfo(a));)a=a.parentElement,c++;if(u){var l={element_type:u.type,element_text:u.text,element_id:u.id,element_class:u.className,element_tag:u.tag,page:r,page_title:o,page_url:s,position:{x:i.clientX,y:i.clientY}};u.href&&(l.element_href=u.href),u.ariaLabel&&(l.element_aria_label=u.ariaLabel),e.config.debug&&c>0&&(l.traversal_depth=c,l.original_target_tag=i.target.tagName.toLowerCase()),e.eventTracker.track("element_click",l)}}catch(t){e.logger.warn("Error in auto click tracking",t)}}),{capture:!0,passive:!0}),this.logger.debug("Auto click tracking enabled with capture phase")}}},{key:"getClickableElementInfo",value:function(e){if(!e||!e.tagName)return null;var t=e.tagName.toLowerCase();if(!this.isClickableElement(e))return null;var n="";e.innerText?n=e.innerText.trim():e.textContent?n=e.textContent.trim():e.value?n=e.value.trim():e.alt?n=e.alt.trim():e.title&&(n=e.title.trim()),n.length>100&&(n=n.substring(0,97)+"...");var i=t;"input"===t?i=e.type||"input":"button"===t?i="submit"===e.type?"submit_button":"button":"a"===t&&(i="link");var r=null;e.href?r=e.href:e.getAttribute&&e.getAttribute("href")&&(r=e.getAttribute("href"));var o=null;e.getAttribute&&e.getAttribute("aria-label")&&(o=e.getAttribute("aria-label").trim());var s={type:i,text:n,id:e.id||null,className:e.className||null,tag:t};return r&&(s.href=r),o&&(s.ariaLabel=o),s}},{key:"isClickableElement",value:function(e){var t=e.tagName.toLowerCase();if(["button","a","input","select","textarea"].includes(t))return!0;if(e.onclick||"button"===e.getAttribute("role")||"link"===e.getAttribute("role")||null!==e.getAttribute("tabindex")||"pointer"===e.style.cursor)return!0;var n=e.className||"";return!!["btn","button","link","clickable","interactive"].some((function(e){return n.toLowerCase().includes(e)}))||!!(e.hasAttribute("data-click")||e.hasAttribute("data-action")||e.hasAttribute("ng-click")||e.hasAttribute("@click")||e.hasAttribute("v-on:click"))}},{key:"setupErrorTracking",value:function(){var e=this;window.addEventListener("error",(function(t){var n;e.eventTracker.track("javascript_error",{message:t.message,filename:t.filename,line:t.lineno,column:t.colno,stack:null===(n=t.error)||void 0===n?void 0:n.stack})})),window.addEventListener("unhandledrejection",(function(t){var n,i;e.eventTracker.track("promise_rejection",{reason:null===(n=t.reason)||void 0===n?void 0:n.toString(),stack:null===(i=t.reason)||void 0===i?void 0:i.stack})})),this.logger.debug("Auto error tracking enabled")}},{key:"setupPageUnloadHandling",value:function(){var e=this;window.addEventListener("beforeunload",(function(){e.config.enableSessionTracking&&e.sessionManager.endSession(),e.queueManager.getQueueSize()>0&&e.sendBeacon()})),document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&e.queueManager.getQueueSize()>0&&e.sendBeacon()})),this.logger.debug("Page unload handling enabled")}},{key:"sendBeacon",value:function(){if(this.networkManager&&this.queueManager.getQueueSize()>0){var e=g(this.queueManager.eventQueue);this.networkManager.sendBeacon(e)&&(this.queueManager.eventQueue=[])}}}])}(),k=function(){return o((function e(t,n){i(this,e),this.config=t,this.logger=n}),[{key:"updateConfig",value:function(e){this.config=e}},{key:"getStorage",value:function(){return"undefined"!=typeof global&&global.localStorage?global.localStorage:"undefined"!=typeof localStorage?localStorage:null}},{key:"persistQueue",value:function(e){if(this.config.enableLocalStorage){var t=this.getStorage();if(t)try{var n={version:"1.0.6",events:e,timestamp:Date.now()};t.setItem("loopkit_queue",JSON.stringify(n))}catch(e){this.logger.warn("Failed to persist queue",e)}}}},{key:"loadQueue",value:function(){if(!this.config.enableLocalStorage)return[];var e=this.getStorage();if(e)try{var t=e.getItem("loopkit_queue");if(t){var n=JSON.parse(t);if(Array.isArray(n))return this.logger.debug("Legacy event format detected, clearing queue"),this.clearQueue(),[];if(n&&"object"===f(n)&&n.version&&n.events){var i="1.0.6";if(n.version!==i)return this.logger.debug("Version mismatch detected (stored: ".concat(n.version,", current: ").concat(i,"), clearing queue")),this.clearQueue(),[];if(Array.isArray(n.events))return this.logger.debug("Loaded ".concat(n.events.length," events from storage (version: ").concat(n.version,")")),n.events}}}catch(e){this.logger.warn("Failed to load persisted queue, clearing corrupted data",e),this.clearQueue()}return[]}},{key:"clearQueue",value:function(){if(this.config.enableLocalStorage){var e=this.getStorage();if(e)try{e.removeItem("loopkit_queue")}catch(e){this.logger.warn("Failed to clear persisted queue",e)}}}},{key:"loadAnonymousId",value:function(){if(!this.config.enableLocalStorage)return null;var e=this.getStorage();if(e)try{var t=e.getItem("loopkit_anonymousId");if(t)return t}catch(e){this.logger.warn("Failed to load anonymous ID",e)}return null}},{key:"saveAnonymousId",value:function(e){if(this.config.enableLocalStorage){var t=this.getStorage();if(t)try{t.setItem("loopkit_anonymousId",e)}catch(e){this.logger.warn("Failed to save anonymous ID",e)}}}},{key:"clearAnonymousId",value:function(){if(this.config.enableLocalStorage){var e=this.getStorage();if(e)try{e.removeItem("loopkit_anonymousId")}catch(e){this.logger.warn("Failed to clear anonymous ID",e)}}}},{key:"clearAll",value:function(){this.clearQueue(),this.clearAnonymousId()}}])}(),b=function(){return o((function e(t,n,r,o){i(this,e),this.config=t,this.logger=n,this.idGenerator=r,this.storageManager=o,this.sessionId=this.idGenerator.generateSessionId(),this.anonymousId=this.loadOrGenerateAnonymousId(),this.sessionStarted=!1,this.lastActivityTime=Date.now(),this.sessionTimer=null}),[{key:"updateConfig",value:function(e){this.config=e}},{key:"getSessionId",value:function(){return this.sessionId}},{key:"getAnonymousId",value:function(){return this.anonymousId}},{key:"loadOrGenerateAnonymousId",value:function(){if(this.storageManager){var e=this.storageManager.loadAnonymousId();if(e)return e}var t=this.idGenerator.generateAnonymousId();return this.storageManager&&this.storageManager.saveAnonymousId(t),t}},{key:"startSession",value:function(){this.sessionStarted||(this.sessionStarted=!0,this.lastActivityTime=Date.now(),this.setupActivityTracking(),this.logger.debug("Session started",{sessionId:this.sessionId}))}},{key:"endSession",value:function(){if(this.sessionStarted){var e=Math.round((Date.now()-this.lastActivityTime)/1e3);this.sessionStarted=!1,this.sessionTimer&&(clearTimeout(this.sessionTimer),this.sessionTimer=null),this.logger.debug("Session ended",{sessionId:this.sessionId,duration:e})}}},{key:"updateActivity",value:function(){var e=this;this.lastActivityTime=Date.now(),this.sessionTimer&&clearTimeout(this.sessionTimer),this.sessionTimer=setTimeout((function(){e.endSession()}),1e3*this.config.sessionTimeout)}},{key:"setupActivityTracking",value:function(){var e=this;if("undefined"!=typeof window){var t=this.throttle((function(){e.updateActivity()}),5e3);["mousedown","mousemove","keypress","scroll","touchstart","click"].forEach((function(e){window.addEventListener(e,t,{passive:!0})})),this.updateActivity()}}},{key:"throttle",value:function(e,t){var n;return function(){var i=arguments;n||(e.apply(this,i),n=!0,setTimeout((function(){return n=!1}),t))}}},{key:"reset",value:function(){this.sessionTimer&&(clearTimeout(this.sessionTimer),this.sessionTimer=null),this.sessionId=this.idGenerator.generateSessionId(),this.anonymousId=this.loadOrGenerateAnonymousId(),this.sessionStarted=!1,this.lastActivityTime=Date.now()}}])}(),w=function(){return o((function e(t){i(this,e),this.config=t}),[{key:"updateConfig",value:function(e){this.config=e}},{key:"log",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(this.config.debug){var i=["error","warn","info","debug"],r=i.indexOf(this.config.logLevel);if(i.indexOf(e)<=r){var o=new Date,s="".concat(o.toLocaleDateString()," ").concat(o.toLocaleTimeString(),".").concat(o.getMilliseconds().toString().padStart(3,"0")),a=u(u({},n),{},{timestamp:s,version:"1.0.6"}),c="[LoopKit] ".concat(t);n?console[e](c,a):console[e](c,{timestamp:s,version:"1.0.6"})}}}},{key:"error",value:function(e,t){this.log("error",e,t)}},{key:"warn",value:function(e,t){this.log("warn",e,t)}},{key:"info",value:function(e,t){this.log("info",e,t)}},{key:"debug",value:function(e,t){this.log("debug",e,t)}}])}(),T=function(){return o((function e(){i(this,e)}),[{key:"validate",value:function(e){if(e.batchSize<=0)throw new Error("batchSize must be greater than 0");if(e.flushInterval<0)throw new Error("flushInterval must be >= 0");if(e.maxQueueSize<=0)throw new Error("maxQueueSize must be greater than 0");if(e.requestTimeout<=0)throw new Error("requestTimeout must be greater than 0");if(e.maxRetries<0)throw new Error("maxRetries must be >= 0");if(e.sessionTimeout<=0)throw new Error("sessionTimeout must be greater than 0")}}])}(),S=function(){return o((function e(){i(this,e)}),[{key:"generateSessionId",value:function(){return"sess_"+Math.random().toString(36).substr(2,9)+"_"+Date.now()}},{key:"generateAnonymousId",value:function(){return"anon_"+Math.random().toString(36).substr(2,9)+"_"+Date.now()}},{key:"generateEventId",value:function(){return"evt_"+Math.random().toString(36).substr(2,9)+"_"+Date.now()}}])}(),I=function(){return o((function e(){i(this,e),this.version="1.0.6",this.config={apiKey:null,baseURL:"https://drain.loopkit.ai/v1",batchSize:50,flushInterval:30,maxQueueSize:1e3,enableCompression:!0,requestTimeout:1e4,debug:!1,logLevel:"debug",enableAutoCapture:!0,enableAutoClickTracking:!0,enableErrorTracking:!0,enableSessionTracking:!0,sessionTimeout:1800,respectDoNotTrack:!0,enableLocalStorage:!0,maxRetries:3,retryBackoff:"exponential",onBeforeTrack:null,onAfterTrack:null,onError:null},this.initialized=!1,this.userId=null,this.userProperties={},this.groupId=null,this.groupProperties={},this.logger=new w(this.config),this.configValidator=new T,this.idGenerator=new S,this.storageManager=new k(this.config,this.logger),this.queueManager=new v(this.config,this.logger,this.storageManager),this.networkManager=new y(this.config,this.logger),this.sessionManager=new b(this.config,this.logger,this.idGenerator,this.storageManager),this.eventTracker=new p(this.config,this.logger,this.queueManager,this.sessionManager,this.idGenerator),"undefined"!=typeof window&&(this.browserFeatures=new m(this.config,this.logger,this.eventTracker,this.sessionManager,this.queueManager)),this.track=this.track.bind(this),this.identify=this.identify.bind(this),this.group=this.group.bind(this),this.trackBatch=this.trackBatch.bind(this),this.flush=this.flush.bind(this)}),[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e||"string"!=typeof e)throw new Error("LoopKit: API key is required and must be a string");return this.initialized&&this.queueManager.stopAutoFlush(),this.config.apiKey=e,this.configure(t),this.initialized=!0,this.updateModuleConfigs(),this.logger.info("LoopKit initialized",{apiKey:e.substring(0,8)+"...",version:this.version}),this.queueManager.setNetworkManager(this.networkManager),this.queueManager.scheduleFlush(),this.config.enableLocalStorage&&this.queueManager.loadPersistedQueue(),this.config.enableSessionTracking&&this.sessionManager.startSession(),this.browserFeatures&&(this.browserFeatures.setNetworkManager(this.networkManager),this.browserFeatures.setupFeatures()),this}},{key:"configure",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=this.config.flushInterval;return this.config=u(u({},this.config),e),this.configValidator.validate(this.config),this.updateModuleConfigs(),this.logger.debug("LoopKit configured",this.config),this.initialized&&void 0!==e.flushInterval&&t!==this.config.flushInterval&&this.queueManager.restartAutoFlush(),this}},{key:"track",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.initialized?(this.eventTracker.track(e,t,n,{userId:this.userId,userProperties:this.userProperties,groupId:this.groupId,groupProperties:this.groupProperties}),this):(this.logger.warn("LoopKit not initialized. Call init() first."),this)}},{key:"identify",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return this.initialized?e&&"string"==typeof e?(this.userId=e,this.userProperties=u(u({},this.userProperties),t),this.eventTracker.identify(e,t),this.logger.debug("User identified",{userId:e,properties:t}),this):(this.logger.error("User ID is required and must be a string"),this):(this.logger.warn("LoopKit not initialized. Call init() first."),this)}},{key:"group",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"organization";return this.initialized?e&&"string"==typeof e?n&&"string"==typeof n?(this.groupId=e,this.groupProperties=u(u({},this.groupProperties),t),this.eventTracker.group(e,t,n,{userId:this.userId}),this.logger.debug("User grouped",{groupId:e,groupType:n,properties:t}),this):(this.logger.error("Group type is required and must be a string"),this):(this.logger.error("Group ID is required and must be a string"),this):(this.logger.warn("LoopKit not initialized. Call init() first."),this)}},{key:"trackBatch",value:function(e){var t=this;return this.initialized?Array.isArray(e)?(e.forEach((function(e){e.name&&e.properties?t.track(e.name,e.properties):t.logger.warn("Invalid event in batch",e)})),this):(this.logger.error("Events must be an array"),this):(this.logger.warn("LoopKit not initialized. Call init() first."),this)}},{key:"flush",value:(e=n(c().m((function e(){return c().w((function(e){for(;;)switch(e.n){case 0:if(this.initialized){e.n=1;break}return this.logger.warn("LoopKit not initialized. Call init() first."),e.a(2);case 1:return e.a(2,this.queueManager.flush(this.networkManager))}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"getQueueSize",value:function(){return this.queueManager.getQueueSize()}},{key:"getConfig",value:function(){return u({},this.config)}},{key:"getVersion",value:function(){return this.version}},{key:"reset",value:function(){return this.userId=null,this.userProperties={},this.groupId=null,this.groupProperties={},this.queueManager.reset(),this.sessionManager.reset(),this.storageManager.clearAll(),this.initialized=!1,this.logger.debug("SDK state reset"),this}},{key:"resetForTesting",value:function(){return this.reset(),this.config={apiKey:null,baseURL:"https://drain.loopkit.ai/v1",batchSize:50,flushInterval:30,maxQueueSize:1e3,enableCompression:!0,requestTimeout:1e4,debug:!1,logLevel:"debug",enableAutoCapture:!1,enableAutoClickTracking:!1,enableErrorTracking:!1,enableSessionTracking:!0,sessionTimeout:1800,respectDoNotTrack:!0,enableLocalStorage:!0,maxRetries:3,retryBackoff:"exponential",onBeforeTrack:null,onAfterTrack:null,onError:null},this.updateModuleConfigs(),this.logger.debug("SDK state reset for testing"),this}},{key:"updateModuleConfigs",value:function(){this.logger.updateConfig(this.config),this.storageManager.updateConfig(this.config),this.queueManager.updateConfig(this.config),this.networkManager.updateConfig(this.config),this.sessionManager.updateConfig(this.config),this.eventTracker.updateConfig(this.config),this.browserFeatures&&this.browserFeatures.updateConfig(this.config)}}]);var e}(),A=new I;return"undefined"!=typeof module&&module.exports?module.exports=A:"undefined"!=typeof window&&(window.LoopKit=A),A}));
{
"name": "@loopkit/javascript",
"version": "1.0.5",
"version": "1.0.6",
"description": "LoopKit JavaScript SDK for tracking events and user analytics",

@@ -5,0 +5,0 @@ "main": "dist/loopkit.js",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display