@loopkit/javascript
Advanced tools
@@ -1,1 +0,1 @@ | ||
| !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).LoopKit={})}(this,(function(e){"use strict";function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function r(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function n(e){return function(){var t=this,n=arguments;return new Promise((function(i,o){var a=e.apply(t,n);function s(e){r(a,i,o,s,u,"next",e)}function u(e){r(a,i,o,s,u,"throw",e)}s(void 0)}))}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,f(n.key),n)}}function a(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e,t,r){return(t=f(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function c(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?u(Object(r),!0).forEach((function(t){s(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function l(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return g(c,"_invoke",function(r,n,i){var o,s,u,c=0,l=i||[],g=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,r){return o=t,s=0,u=e,h.n=r,a}};function f(r,n){for(s=r,u=n,t=0;!g&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=r<2&&f<o[1])?(s=0,h.v=n,h.n=o[1]):f<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw g=!0,n}return function(i,l,d){if(c>1)throw TypeError("Generator is already running");for(g&&1===l&&f(l,d),s=l,u=d;(t=s<2?e:u)||!g;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(g=h.n<0)?u:r.call(n,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:g}}}(r,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var h=[][n]?t(t([][n]())):(g(t={},n,(function(){return this})),t),f=c.prototype=s.prototype=Object.create(h);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,g(e,i,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=c,g(f,"constructor",c),g(c,"constructor",u),u.displayName="GeneratorFunction",g(c,i,"GeneratorFunction"),g(f),g(f,i,"Generator"),g(f,n,(function(){return this})),g(f,"toString",(function(){return"[object Generator]"})),(l=function(){return{w:o,m:d}})()}function g(e,t,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}g=function(e,t,r,n){if(t)i?i(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r;else{function o(t,r){g(e,t,(function(e){return this._invoke(t,r,e)}))}o("next",0),o("throw",1),o("return",2)}},g(e,t,r,n)}function h(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,r){if(e){if("string"==typeof e)return t(e,r);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(e,r):void 0}}(e)||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 f(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function d(e){return d="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},d(e)}var v=function(){return a((function e(){i(this,e)}),null,[{key:"validate",value:function(e){if(void 0!==e.batchSize&&e.batchSize<=0)throw new Error("batchSize must be greater than 0");if(void 0!==e.flushInterval&&e.flushInterval<0)throw new Error("flushInterval must be >= 0");if(void 0!==e.maxQueueSize&&e.maxQueueSize<=0)throw new Error("maxQueueSize must be greater than 0");if(void 0!==e.requestTimeout&&e.requestTimeout<=0)throw new Error("requestTimeout must be greater than 0");if(void 0!==e.maxRetries&&e.maxRetries<0)throw new Error("maxRetries must be >= 0");if(void 0!==e.sessionTimeout&&e.sessionTimeout<=0)throw new Error("sessionTimeout must be greater than 0")}}])}(),p=function(){return a((function e(t){i(this,e),this.config=t}),[{key:"updateConfig",value:function(e){this.config=e}},{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)}},{key:"log",value:function(e,t,r){if(this.shouldLog(e)){var n=new Date,i=n.toLocaleDateString("en-US")+" "+n.toLocaleTimeString("en-US")+"."+n.getMilliseconds();if(r){var o=c(c({},r),{},{timestamp:i,version:"1.1.0"}),a="[LoopKit] ".concat(t);console[e](a,o)}else console[e]("[LoopKit] ".concat(t),{timestamp:i,version:"1.1.0"})}}},{key:"shouldLog",value:function(e){if(!this.config.debug)return!1;var t=["error","warn","info","debug"],r=this.config.logLevel||"debug",n=t.indexOf(r);return t.indexOf(e)<=n}}])}(),y=function(){return a((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()}}])}(),k=function(){return a((function e(t,r){i(this,e),this.config=t,this.logger=r}),[{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 r={version:"1.1.0",events:e,timestamp:Date.now()};t.setItem("loopkit_queue",JSON.stringify(r))}catch(e){this.logger.warn("Failed to persist queue",{error: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 r=JSON.parse(t);if(Array.isArray(r)){if(this.logger.debug("Legacy event format detected, clearing queue"),e)try{e.removeItem("loopkit_queue")}catch(e){this.logger.warn("Failed to clear persisted queue",{error:e})}return[]}if(r&&"object"===d(r)&&r.version&&r.events){var n="1.1.0";if(r.version!==n){if(this.logger.debug("Version mismatch detected (stored: ".concat(r.version,", current: ").concat(n,"), clearing queue")),e)try{e.removeItem("loopkit_queue")}catch(e){this.logger.warn("Failed to clear persisted queue",{error:e})}return[]}if(Array.isArray(r.events))return this.logger.debug("Loaded ".concat(r.events.length," events from storage (version: ").concat(r.version,")")),r.events}}}catch(e){this.logger.warn("Failed to load persisted queue, clearing corrupted data",{error: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",{error: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",{error: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",{error: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",{error:e})}}}},{key:"clearAll",value:function(){this.clearQueue(),this.clearAnonymousId()}}])}(),m=function(){return a((function e(t,r,n,o){i(this,e),this.config=t,this.logger=r,this.idGenerator=n,this.storageManager=o,this.lastActivityTime=Date.now(),this.anonymousId=this.loadOrCreateAnonymousId(),this.sessionId=this.idGenerator.generateSessionId(),this.startSession(),this.logger.debug("Session initialized",{sessionId:this.sessionId,anonymousId:this.anonymousId})}),[{key:"getSessionId",value:function(){return this.updateActivity(),this.sessionId}},{key:"getAnonymousId",value:function(){return this.updateActivity(),this.anonymousId}},{key:"startSession",value:function(){this.sessionId=this.idGenerator.generateSessionId(),this.lastActivityTime=Date.now(),this.logger.debug("New session started: ".concat(this.sessionId))}},{key:"endSession",value:function(){this.logger.debug("Session ended: ".concat(this.sessionId)),this.sessionId=this.idGenerator.generateSessionId(),this.lastActivityTime=Date.now()}},{key:"isSessionActive",value:function(){return!this.config.enableSessionTracking||Date.now()-this.lastActivityTime<1e3*this.config.sessionTimeout}},{key:"updateActivity",value:function(){var e=Date.now(),t=e-this.lastActivityTime,r=1e3*this.config.sessionTimeout;this.config.enableSessionTracking&&t>=r?(this.logger.debug("Session timeout detected, starting new session"),this.startSession()):this.lastActivityTime=e}},{key:"updateConfig",value:function(e){this.config=e}},{key:"reset",value:function(){this.logger.debug("Resetting session manager"),this.startSession()}},{key:"loadOrCreateAnonymousId",value:function(){var e=this.storageManager.loadAnonymousId();return e?this.logger.debug("Loaded existing anonymous ID: ".concat(e)):(e=this.idGenerator.generateAnonymousId(),this.storageManager.saveAnonymousId(e),this.logger.debug("Generated new anonymous ID: ".concat(e))),e}}])}(),b=function(){return a((function e(t,r,n){i(this,e),this.eventQueue=[],this.isInitialized=!1,this.config=t,this.logger=r,this.storageManager=n,this.loadPersistedQueue(),this.isInitialized=!0}),[{key:"enqueueEvent",value:function(e){if(this.isInitialized){var t={type:"name"in e?"track":"groupId"in e?"group":"identify",event:e};this.eventQueue.length>=this.config.maxQueueSize&&(this.logger.warn("Queue size limit reached (".concat(this.config.maxQueueSize,"), dropping oldest event")),this.eventQueue.shift()),this.eventQueue.push(t),this.logger.debug("Event queued. Queue size: ".concat(this.eventQueue.length)),this.persistQueue(),this.eventQueue.length>=this.config.batchSize&&(this.logger.debug("Batch size reached (".concat(this.config.batchSize,"), auto-flushing")),this.flush(this.networkManager))}else this.logger.warn("QueueManager not initialized")}},{key:"flush",value:(e=n(l().m((function e(t){var r,n,i,o,a,s,u,c,g,f,d,v,p=this;return l().w((function(e){for(;;)switch(e.n){case 0:if(t){e.n=1;break}return this.logger.warn("NetworkManager not set, cannot flush"),e.a(2);case 1:if(0!==this.eventQueue.length){e.n=2;break}return this.logger.debug("No events to flush"),e.a(2);case 2:return r=h(this.eventQueue),this.eventQueue=[],this.persistQueue(),e.p=3,n=[],i=[],o=[],r.forEach((function(e){var t=e.type,r=e.event;switch(t){case"track":n.push(r);break;case"identify":i.push(r);break;case"group":o.push(r)}})),a=[],n.length>0&&(s="".concat(this.config.baseURL,"/tracks"),u={tracks:n},a.push(t.sendEvents(s,u))),i.length>0&&(c="".concat(this.config.baseURL,"/identities"),g={identifies:i},a.push(t.sendEvents(c,g))),o.length>0&&(f="".concat(this.config.baseURL,"/groups"),d={groups:o},a.push(t.sendEvents(f,d))),e.n=4,Promise.all(a);case 4:this.logger.debug("Successfully flushed ".concat(r.length," events")),this.config.onAfterTrack&&r.forEach((function(e){var t=e.type,r=e.event;"track"===t&&p.config.onAfterTrack(r,!0)})),e.n=6;break;case 5:throw e.p=5,v=e.v,this.logger.error("Failed to flush events",{error:v}),this.eventQueue=[].concat(h(r),h(this.eventQueue)),this.persistQueue(),this.config.onAfterTrack&&r.forEach((function(e){var t=e.type,r=e.event;"track"===t&&p.config.onAfterTrack(r,!1)})),this.config.onError&&this.config.onError(v),v;case 6:return e.a(2)}}),e,this,[[3,5]])}))),function(t){return e.apply(this,arguments)})},{key:"getQueue",value:function(){return h(this.eventQueue)}},{key:"getQueueSize",value:function(){return this.eventQueue.length}},{key:"clearQueue",value:function(){this.eventQueue=[],this.persistQueue(),this.logger.debug("Queue cleared")}},{key:"reset",value:function(){this.clearQueue(),this.stopAutoFlush(),this.storageManager.clearQueue()}},{key:"updateConfig",value:function(e){this.config=e}},{key:"setNetworkManager",value:function(e){this.networkManager=e}},{key:"scheduleFlush",value:function(){var e=this;this.config.flushInterval>0&&(this.flushTimer=setInterval((function(){e.eventQueue.length>0&&e.networkManager&&(e.logger.debug("Auto-flush triggered"),e.flush(e.networkManager))}),1e3*this.config.flushInterval))}},{key:"restartAutoFlush",value:function(){this.stopAutoFlush(),this.scheduleFlush()}},{key:"stopAutoFlush",value:function(){this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=void 0)}},{key:"persistQueue",value:function(){if(this.config.enableLocalStorage)try{this.storageManager.persistQueue(this.eventQueue)}catch(e){this.logger.warn("Failed to persist queue",{error:e})}}},{key:"loadPersistedQueue",value:function(){if(this.config.enableLocalStorage)try{var e=this.storageManager.loadQueue();Array.isArray(e)&&e.length>0&&(this.eventQueue=e,this.logger.debug("Loaded ".concat(this.eventQueue.length," persisted events")))}catch(e){this.logger.warn("Failed to load persisted queue",{error:e})}}}]);var e}(),w=function(){return a((function e(){i(this,e)}),null,[{key:"isDoNotTrackEnabled",value:function(){if("undefined"==typeof navigator)return!1;var e=navigator.doNotTrack||window.doNotTrack||navigator.msDoNotTrack;return"1"===e||"yes"===e||!0===e}}])}(),S=function(){return a((function e(t,r,n,o,a){i(this,e),this.config=t,this.logger=r,this.queueManager=n,this.sessionManager=o,this.idGenerator=a}),[{key:"track",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(e&&"string"==typeof e)if(this.config.respectDoNotTrack&&w.isDoNotTrackEnabled())this.logger.debug("Do Not Track is enabled, skipping event tracking");else try{var i=c(c({},this.createBaseEvent(r.timestamp)),{},{name:e,properties:c({},t)},n.userId&&{userId:n.userId}),o=i;if(this.config.onBeforeTrack)try{var a=this.config.onBeforeTrack(i);a&&(o=a)}catch(e){this.logger.error("Error in onBeforeTrack callback",{error:e})}this.queueManager.enqueueEvent(o),this.logger.debug("Tracked event: ".concat(e),o)}catch(t){this.logger.error("Failed to track event",{eventName:e,error:t}),this.config.onError&&this.config.onError(t)}else this.logger.warn("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]:{};if(e&&"string"==typeof e)if(this.config.respectDoNotTrack&&w.isDoNotTrackEnabled())this.logger.debug("Do Not Track is enabled, skipping user identification");else try{var r=c(c({},this.createBaseEvent()),{},{userId:e,properties:c({},t)});this.queueManager.enqueueEvent(r),this.logger.debug("Identified user: ".concat(e),r)}catch(t){this.logger.error("Failed to identify user",{userId:e,error:t}),this.config.onError&&this.config.onError(t)}else this.logger.warn("User ID is required and must be a string")}},{key:"group",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"organization",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(e&&"string"==typeof e)if(this.config.respectDoNotTrack&&w.isDoNotTrackEnabled())this.logger.debug("Do Not Track is enabled, skipping group association");else try{var i=c(c({},this.createBaseEvent()),{},{groupId:e,groupType:r,properties:c({},t)},n.userId&&{userId:n.userId});this.queueManager.enqueueEvent(i),this.logger.debug("Associated with group: ".concat(e),i)}catch(t){this.logger.error("Failed to associate with group",{groupId:e,error:t}),this.config.onError&&this.config.onError(t)}else this.logger.warn("Group ID is required and must be a string")}},{key:"updateConfig",value:function(e){this.config=e}},{key:"createBaseEvent",value:function(e){var t=e||(new Date).toISOString();return{anonymousId:this.sessionManager.getAnonymousId(),timestamp:t,system:this.createSystemInfo()}}},{key:"createSystemInfo",value:function(){var e={sdk:{name:"@loopkit/javascript",version:"1.1.0"},sessionId:this.sessionManager.getSessionId()};return"undefined"!=typeof window&&(e.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}}),e}}])}(),T=function(){return a((function e(t,r){i(this,e),this.config=t,this.logger=r}),[{key:"sendEvents",value:(e=n(l().m((function e(t,r){var n,i,o,a,s,u,c,g,h,f,d,v,p,y,k,m,b=arguments;return l().w((function(e){for(;;)switch(e.n){case 0:return n=b.length>2&&void 0!==b[2]?b[2]:0,e.p=1,i={"Content-Type":"application/json","User-Agent":"@loopkit/javascript"},this.config.enableCompression&&(i["Accept-Encoding"]="gzip, deflate"),(o=new URL(t)).searchParams.set("apiKey",this.config.apiKey),a=o.toString(),s={method:"POST",headers:i,body:JSON.stringify(r)},this.config.requestTimeout&&this.config.requestTimeout>0&&(u=new AbortController,s.signal=u.signal,setTimeout((function(){return u.abort()}),this.config.requestTimeout)),c=this.getEventCountFromPayload(r),this.logger.debug("Sending ".concat(c," event(s) to ").concat(a),{retryCount:n,payload:r}),g=null,e.p=2,e.n=3,fetch(a,s);case 3:g=e.v,e.n=7;break;case 4:if(e.p=4,k=e.v,this.logger.error("Network error during sendEvents (attempt ".concat(n+1,")"),{endpoint:t,error:k instanceof Error?k.message:k,retryCount:n}),!(n<this.config.maxRetries)){e.n=6;break}return h=this.calculateRetryDelay(n),this.logger.debug("Retrying in ".concat(h,"ms (attempt ").concat(n+2,")")),e.n=5,this.sleep(h);case 5:return e.a(2,this.sendEvents(t,r,n+1));case 6:throw k;case 7:if(g&&g.ok){e.n=10;break}if(f=(null==g?void 0:g.status)||"unknown",d=(null==g?void 0:g.statusText)||"unknown error",v=new Error("HTTP ".concat(f,": ").concat(d)),this.logger.error("HTTP error during sendEvents (attempt ".concat(n+1,")"),{endpoint:t,status:f,statusText:d,retryCount:n}),!(n<this.config.maxRetries)){e.n=9;break}return p=this.calculateRetryDelay(n),this.logger.debug("Retrying in ".concat(p,"ms (attempt ").concat(n+2,")")),e.n=8,this.sleep(p);case 8:return e.a(2,this.sendEvents(t,r,n+1));case 9:throw v;case 10:return e.p=10,e.n=11,g.json();case 11:y=e.v,e.n=13;break;case 12:e.p=12,e.v,y={};case 13:return this.logger.debug("Events sent successfully",{result:y}),e.a(2,y);case 14:throw e.p=14,m=e.v,this.logger.error("Unexpected error in sendEvents",{endpoint:t,error:m instanceof Error?m.message:m,retryCount:n}),m;case 15:return e.a(2)}}),e,this,[[10,12],[2,4],[1,14]])}))),function(t,r){return e.apply(this,arguments)})},{key:"sendBeacon",value:function(e,t){if("undefined"==typeof navigator||!navigator.sendBeacon)return this.logger.warn("sendBeacon not available"),!1;try{var r=new URL(e);r.searchParams.set("apiKey",this.config.apiKey);var n=r.toString(),i=JSON.stringify(t),o=new Blob([i],{type:"application/json"}),a=navigator.sendBeacon(n,o);return a?this.logger.debug("Beacon sent successfully",{endpoint:n,payload:t}):this.logger.warn("Beacon failed to send",{endpoint:n}),a}catch(e){return this.logger.error("Beacon send error",{error:e}),!1}}},{key:"updateConfig",value:function(e){this.config=e}},{key:"calculateRetryDelay",value:function(e){return"linear"===this.config.retryBackoff?1e3*(e+1):1e3*Math.pow(2,e)}},{key:"sleep",value:function(e){return new Promise((function(t){return setTimeout(t,e)}))}},{key:"getEventCountFromPayload",value:function(e){return e&&"object"===d(e)?e.tracks&&Array.isArray(e.tracks)?e.tracks.length:e.identifies&&Array.isArray(e.identifies)?e.identifies.length:e.groups&&Array.isArray(e.groups)?e.groups.length:1:0}}]);var e}(),I=function(){return a((function e(t,r,n,o,a){i(this,e),this.config=t,this.logger=r,this.eventTracker=n,this.sessionManager=o,this.queueManager=a}),[{key:"setupFeatures",value:function(){"undefined"!=typeof window?(this.config.enableAutoClickTracking&&this.setupAutoClickTracking(),this.config.enableAutoCapture&&this.setupAutoPageViews(),this.config.enableErrorTracking&&this.setupErrorTracking(),this.setupPageUnloadHandling(),this.logger.debug("Browser features setup complete")):this.logger.debug("Not in browser environment, skipping browser features")}},{key:"setupAutoClickTracking",value:function(){var e=this;"undefined"!=typeof document&&(this.clickHandler=function(t){try{var r=t.target;if(!r)return;var n=e.findClickableElement(r);if(!n)return;var i=e.extractClickProperties(n,t);e.eventTracker.track("click",i)}catch(t){e.logger.error("Error in click tracking",{error:t})}},document.addEventListener("click",this.clickHandler,{capture:!0}),this.logger.debug("Auto-click tracking enabled"))}},{key:"setupAutoPageViews",value:function(){var e=this;if("undefined"!=typeof window){this.trackPageView();var t=history.pushState,r=history.replaceState;history.pushState=function(){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];t.apply(history,n),setTimeout((function(){return e.trackPageView()}),0)},history.replaceState=function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];r.apply(history,n),setTimeout((function(){return e.trackPageView()}),0)},window.addEventListener("popstate",(function(){setTimeout((function(){return e.trackPageView()}),0)})),this.logger.debug("Auto page view tracking enabled")}}},{key:"setupErrorTracking",value:function(){var e=this;"undefined"!=typeof window&&(this.errorHandler=function(t){var r;try{e.eventTracker.track("error",{message:t.message,filename:t.filename,lineno:t.lineno,colno:t.colno,stack:null===(r=t.error)||void 0===r?void 0:r.stack,timestamp:(new Date).toISOString()})}catch(t){e.logger.error("Error in error tracking",{error:t})}},window.addEventListener("error",this.errorHandler),this.logger.debug("Error tracking enabled"))}},{key:"setupPageUnloadHandling",value:function(){var e=this;"undefined"!=typeof window&&(this.unloadHandler=function(){try{if(e.queueManager.getQueueSize()>0&&e.networkManager){var t=e.queueManager.getQueue();if(t.length>0){var r=[],n=[],i=[];if(t.forEach((function(e){var t=e.type,o=e.event;switch(t){case"track":r.push(o);break;case"identify":n.push(o);break;case"group":i.push(o)}})),r.length>0){var o="".concat(e.config.baseURL,"/tracks"),a={tracks:r};e.networkManager.sendBeacon(o,a)}if(n.length>0){var s="".concat(e.config.baseURL,"/identities"),u={identifies:n};e.networkManager.sendBeacon(s,u)}if(i.length>0){var c="".concat(e.config.baseURL,"/groups"),l={groups:i};e.networkManager.sendBeacon(c,l)}}}}catch(t){e.logger.error("Error in unload handler",{error:t})}},window.addEventListener("beforeunload",this.unloadHandler),this.logger.debug("Page unload handling enabled"))}},{key:"updateConfig",value:function(e){this.config=e}},{key:"setNetworkManager",value:function(e){this.networkManager=e}},{key:"trackPageView",value:function(){this.eventTracker.track("page_view",{url:window.location.href,path:window.location.pathname,search:window.location.search,title:document.title,referrer:document.referrer})}},{key:"findClickableElement",value:function(e){for(var t=e,r=0;t&&r<5;){var n=t.tagName.toLowerCase();if("a"===n||"button"===n||"button"===t.getAttribute("role")||t.onclick||"pointer"===t.style.cursor)return t;t=t.parentElement,r++}return e}},{key:"extractClickProperties",value:function(e,t){return e.getBoundingClientRect(),{element_type:this.getElementType(e),element_text:this.getElementText(e),element_id:e.id||null,element_class:e.className||null,element_tag:e.tagName.toLowerCase(),element_href:e.href||void 0,element_aria_label:e.getAttribute("aria-label")||void 0,page:window.location.pathname,page_title:document.title,page_url:window.location.href,position:{x:Math.round(t.clientX),y:Math.round(t.clientY)}}}},{key:"getElementType",value:function(e){var t=e.tagName.toLowerCase();return"a"===t?"link":"button"===t||"button"===e.getAttribute("role")?"button":"input"===t?"input":"form"===t?"form":"element"}},{key:"getElementText",value:function(e){return(e.innerText||e.textContent||e.getAttribute("aria-label")||e.getAttribute("title")||e.getAttribute("alt")||"").trim().substring(0,255)}}])}(),A=function(){return a((function e(){i(this,e),this.version="1.1.0",this.config={apiKey:"",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"},this.initialized=!1,this.userId=null,this.userProperties={},this.groupId=null,this.groupProperties={}}),[{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.config=c(c(c({},this.config),t),{},{apiKey:e}),v.validate(this.config),this.logger=new p(this.config),this.idGenerator=new y,this.storageManager=new k(this.config,this.logger),this.sessionManager=new m(this.config,this.logger,this.idGenerator,this.storageManager),this.queueManager=new b(this.config,this.logger,this.storageManager),this.eventTracker=new S(this.config,this.logger,this.queueManager,this.sessionManager,this.idGenerator),this.networkManager=new T(this.config,this.logger),"undefined"!=typeof window&&(this.browserFeatures=new I(this.config,this.logger,this.eventTracker,this.sessionManager,this.queueManager)),this.queueManager.setNetworkManager(this.networkManager),this.queueManager.scheduleFlush(),this.browserFeatures&&(this.browserFeatures.setNetworkManager(this.networkManager),this.browserFeatures.setupFeatures()),this.initialized=!0,this.logger.debug("LoopKit configured",this.config),this.logger.info("LoopKit initialized",{apiKey:this.config.apiKey.substring(0,8)+"...",version:this.version}),this}},{key:"configure",value:function(e){var t,r,n,i,o,a,s,u;return v.validate(e),this.config=c(c({},this.config),e),this.initialized&&(null===(t=this.logger)||void 0===t||t.updateConfig(this.config),null===(r=this.storageManager)||void 0===r||r.updateConfig(this.config),null===(n=this.sessionManager)||void 0===n||n.updateConfig(this.config),null===(i=this.queueManager)||void 0===i||i.updateConfig(this.config),null===(o=this.eventTracker)||void 0===o||o.updateConfig(this.config),null===(a=this.networkManager)||void 0===a||a.updateConfig(this.config),null===(s=this.browserFeatures)||void 0===s||s.updateConfig(this.config),null===(u=this.queueManager)||void 0===u||u.restartAutoFlush()),this}},{key:"getConfig",value:function(){return c({},this.config)}},{key:"track",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.initialized?e&&"string"==typeof e?(this.eventTracker.track(e,t,r,{userId:this.userId,userProperties:this.userProperties,groupId:this.groupId,groupProperties:this.groupProperties}),this):(this.logger.warn("Event name 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&&"object"===d(e)&&e.name&&t.track(e.name,e.properties||{},e.options||{})})),this):(this.logger.error("trackBatch expects an array of events"),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=c(c({},this.userProperties),t),this.eventTracker.identify(e,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]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"organization";return this.initialized?e&&"string"==typeof e?(this.groupId=e,this.groupProperties=c(c({},this.groupProperties),t),this.eventTracker.group(e,t,r,{userId:this.userId}),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:"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.initialized?this.queueManager.getQueueSize():0}},{key:"reset",value:function(){var e,t,r;this.initialized&&(this.userId=null,this.userProperties={},this.groupId=null,this.groupProperties={},null===(e=this.queueManager)||void 0===e||e.reset(),null===(t=this.storageManager)||void 0===t||t.clearAll(),null===(r=this.sessionManager)||void 0===r||r.reset(),this.logger.debug("SDK state reset"))}},{key:"resetForTesting",value:function(){var e,t,r;this.initialized&&(null===(e=this.queueManager)||void 0===e||e.reset(),null===(t=this.storageManager)||void 0===t||t.clearAll(),null===(r=this.sessionManager)||void 0===r||r.reset()),this.initialized=!1,this.userId=null,this.userProperties={},this.groupId=null,this.groupProperties={},this.config={apiKey:"",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"}}}]);var e}(),E=new A;"undefined"!=typeof module&&module.exports?module.exports=E:"undefined"!=typeof window&&(window.LoopKit=E),e.LoopKit=A,e.default=E,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
| !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).LoopKit={})}(this,(function(e){"use strict";function t(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function r(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function n(e){return function(){var t=this,n=arguments;return new Promise((function(i,o){var a=e.apply(t,n);function s(e){r(a,i,o,s,u,"next",e)}function u(e){r(a,i,o,s,u,"throw",e)}s(void 0)}))}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,f(n.key),n)}}function a(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e,t,r){return(t=f(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function c(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?u(Object(r),!0).forEach((function(t){s(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function l(){var e,t,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",i=r.toStringTag||"@@toStringTag";function o(r,n,i,o){var u=n&&n.prototype instanceof s?n:s,c=Object.create(u.prototype);return g(c,"_invoke",function(r,n,i){var o,s,u,c=0,l=i||[],g=!1,h={p:0,n:0,v:e,a:f,f:f.bind(e,4),d:function(t,r){return o=t,s=0,u=e,h.n=r,a}};function f(r,n){for(s=r,u=n,t=0;!g&&c&&!i&&t<l.length;t++){var i,o=l[t],f=h.p,d=o[2];r>3?(i=d===n)&&(u=o[(s=o[4])?5:(s=3,3)],o[4]=o[5]=e):o[0]<=f&&((i=r<2&&f<o[1])?(s=0,h.v=n,h.n=o[1]):f<d&&(i=r<3||o[0]>n||n>d)&&(o[4]=r,o[5]=n,h.n=d,s=0))}if(i||r>1)return a;throw g=!0,n}return function(i,l,d){if(c>1)throw TypeError("Generator is already running");for(g&&1===l&&f(l,d),s=l,u=d;(t=s<2?e:u)||!g;){o||(s?s<3?(s>1&&(h.n=-1),f(s,u)):h.n=u:h.v=u);try{if(c=2,o){if(s||(i="next"),t=o[i]){if(!(t=t.call(o,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,s<2&&(s=0)}else 1===s&&(t=o.return)&&t.call(o),s<2&&(u=TypeError("The iterator does not provide a '"+i+"' method"),s=1);o=e}else if((t=(g=h.n<0)?u:r.call(n,h))!==a)break}catch(t){o=e,s=1,u=t}finally{c=1}}return{value:t,done:g}}}(r,i,o),!0),c}var a={};function s(){}function u(){}function c(){}t=Object.getPrototypeOf;var h=[][n]?t(t([][n]())):(g(t={},n,(function(){return this})),t),f=c.prototype=s.prototype=Object.create(h);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,c):(e.__proto__=c,g(e,i,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=c,g(f,"constructor",c),g(c,"constructor",u),u.displayName="GeneratorFunction",g(c,i,"GeneratorFunction"),g(f),g(f,i,"Generator"),g(f,n,(function(){return this})),g(f,"toString",(function(){return"[object Generator]"})),(l=function(){return{w:o,m:d}})()}function g(e,t,r,n){var i=Object.defineProperty;try{i({},"",{})}catch(e){i=0}g=function(e,t,r,n){if(t)i?i(e,t,{value:r,enumerable:!n,configurable:!n,writable:!n}):e[t]=r;else{function o(t,r){g(e,t,(function(e){return this._invoke(t,r,e)}))}o("next",0),o("throw",1),o("return",2)}},g(e,t,r,n)}function h(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,r){if(e){if("string"==typeof e)return t(e,r);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t(e,r):void 0}}(e)||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 f(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t);if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e,"string");return"symbol"==typeof t?t:t+""}function d(e){return d="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},d(e)}var v=function(){return a((function e(){i(this,e)}),null,[{key:"validate",value:function(e){if(void 0!==e.batchSize&&e.batchSize<=0)throw new Error("batchSize must be greater than 0");if(void 0!==e.flushInterval&&e.flushInterval<0)throw new Error("flushInterval must be >= 0");if(void 0!==e.maxQueueSize&&e.maxQueueSize<=0)throw new Error("maxQueueSize must be greater than 0");if(void 0!==e.requestTimeout&&e.requestTimeout<=0)throw new Error("requestTimeout must be greater than 0");if(void 0!==e.maxRetries&&e.maxRetries<0)throw new Error("maxRetries must be >= 0");if(void 0!==e.sessionTimeout&&e.sessionTimeout<=0)throw new Error("sessionTimeout must be greater than 0")}}])}(),p=function(){return a((function e(t){i(this,e),this.config=t}),[{key:"updateConfig",value:function(e){this.config=e}},{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)}},{key:"log",value:function(e,t,r){if(this.shouldLog(e)){var n=new Date,i=n.toLocaleDateString("en-US")+" "+n.toLocaleTimeString("en-US")+"."+n.getMilliseconds();if(r){var o=c(c({},r),{},{timestamp:i,version:"1.1.1"}),a="[LoopKit] ".concat(t);console[e](a,o)}else console[e]("[LoopKit] ".concat(t),{timestamp:i,version:"1.1.1"})}}},{key:"shouldLog",value:function(e){if(!this.config.debug)return!1;var t=["error","warn","info","debug"],r=this.config.logLevel||"debug",n=t.indexOf(r);return t.indexOf(e)<=n}}])}(),y=function(){return a((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()}}])}(),k=function(){return a((function e(t,r){i(this,e),this.config=t,this.logger=r}),[{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 r={version:"1.1.1",events:e,timestamp:Date.now()};t.setItem("loopkit_queue",JSON.stringify(r))}catch(e){this.logger.warn("Failed to persist queue",{error: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 r=JSON.parse(t);if(Array.isArray(r)){if(this.logger.debug("Legacy event format detected, clearing queue"),e)try{e.removeItem("loopkit_queue")}catch(e){this.logger.warn("Failed to clear persisted queue",{error:e})}return[]}if(r&&"object"===d(r)&&r.version&&r.events){var n="1.1.1";if(r.version!==n){if(this.logger.debug("Version mismatch detected (stored: ".concat(r.version,", current: ").concat(n,"), clearing queue")),e)try{e.removeItem("loopkit_queue")}catch(e){this.logger.warn("Failed to clear persisted queue",{error:e})}return[]}if(Array.isArray(r.events))return this.logger.debug("Loaded ".concat(r.events.length," events from storage (version: ").concat(r.version,")")),r.events}}}catch(e){this.logger.warn("Failed to load persisted queue, clearing corrupted data",{error: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",{error: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",{error: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",{error: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",{error:e})}}}},{key:"clearAll",value:function(){this.clearQueue(),this.clearAnonymousId()}}])}(),m=function(){return a((function e(t,r,n,o){i(this,e),this.config=t,this.logger=r,this.idGenerator=n,this.storageManager=o,this.lastActivityTime=Date.now(),this.anonymousId=this.loadOrCreateAnonymousId(),this.sessionId=this.idGenerator.generateSessionId(),this.startSession(),this.logger.debug("Session initialized",{sessionId:this.sessionId,anonymousId:this.anonymousId})}),[{key:"getSessionId",value:function(){return this.updateActivity(),this.sessionId}},{key:"getAnonymousId",value:function(){return this.updateActivity(),this.anonymousId}},{key:"startSession",value:function(){this.sessionId=this.idGenerator.generateSessionId(),this.lastActivityTime=Date.now(),this.logger.debug("New session started: ".concat(this.sessionId))}},{key:"endSession",value:function(){this.logger.debug("Session ended: ".concat(this.sessionId)),this.sessionId=this.idGenerator.generateSessionId(),this.lastActivityTime=Date.now()}},{key:"isSessionActive",value:function(){return!this.config.enableSessionTracking||Date.now()-this.lastActivityTime<1e3*this.config.sessionTimeout}},{key:"updateActivity",value:function(){var e=Date.now(),t=e-this.lastActivityTime,r=1e3*this.config.sessionTimeout;this.config.enableSessionTracking&&t>=r?(this.logger.debug("Session timeout detected, starting new session"),this.startSession()):this.lastActivityTime=e}},{key:"updateConfig",value:function(e){this.config=e}},{key:"reset",value:function(){this.logger.debug("Resetting session manager"),this.startSession()}},{key:"loadOrCreateAnonymousId",value:function(){var e=this.storageManager.loadAnonymousId();return e?this.logger.debug("Loaded existing anonymous ID: ".concat(e)):(e=this.idGenerator.generateAnonymousId(),this.storageManager.saveAnonymousId(e),this.logger.debug("Generated new anonymous ID: ".concat(e))),e}}])}(),b=function(){return a((function e(t,r,n){i(this,e),this.eventQueue=[],this.isInitialized=!1,this.config=t,this.logger=r,this.storageManager=n,this.loadPersistedQueue(),this.isInitialized=!0}),[{key:"enqueueEvent",value:function(e){if(this.isInitialized){var t={type:"name"in e?"track":"groupId"in e?"group":"identify",event:e};this.eventQueue.length>=this.config.maxQueueSize&&(this.logger.warn("Queue size limit reached (".concat(this.config.maxQueueSize,"), dropping oldest event")),this.eventQueue.shift()),this.eventQueue.push(t),this.logger.debug("Event queued. Queue size: ".concat(this.eventQueue.length)),this.persistQueue(),this.eventQueue.length>=this.config.batchSize&&(this.logger.debug("Batch size reached (".concat(this.config.batchSize,"), auto-flushing")),this.flush(this.networkManager))}else this.logger.warn("QueueManager not initialized")}},{key:"flush",value:(e=n(l().m((function e(t){var r,n,i,o,a,s,u,c,g,f,d,v,p=this;return l().w((function(e){for(;;)switch(e.n){case 0:if(t){e.n=1;break}return this.logger.warn("NetworkManager not set, cannot flush"),e.a(2);case 1:if(0!==this.eventQueue.length){e.n=2;break}return this.logger.debug("No events to flush"),e.a(2);case 2:return r=h(this.eventQueue),this.eventQueue=[],this.persistQueue(),e.p=3,n=[],i=[],o=[],r.forEach((function(e){var t=e.type,r=e.event;switch(t){case"track":n.push(r);break;case"identify":i.push(r);break;case"group":o.push(r)}})),a=[],n.length>0&&(s="".concat(this.config.baseURL,"/tracks"),u={tracks:n},a.push(t.sendEvents(s,u))),i.length>0&&(c="".concat(this.config.baseURL,"/identifies"),g={identifies:i},a.push(t.sendEvents(c,g))),o.length>0&&(f="".concat(this.config.baseURL,"/groups"),d={groups:o},a.push(t.sendEvents(f,d))),e.n=4,Promise.all(a);case 4:this.logger.debug("Successfully flushed ".concat(r.length," events")),this.config.onAfterTrack&&r.forEach((function(e){var t=e.type,r=e.event;"track"===t&&p.config.onAfterTrack(r,!0)})),e.n=6;break;case 5:throw e.p=5,v=e.v,this.logger.error("Failed to flush events",{error:v}),this.eventQueue=[].concat(h(r),h(this.eventQueue)),this.persistQueue(),this.config.onAfterTrack&&r.forEach((function(e){var t=e.type,r=e.event;"track"===t&&p.config.onAfterTrack(r,!1)})),this.config.onError&&this.config.onError(v),v;case 6:return e.a(2)}}),e,this,[[3,5]])}))),function(t){return e.apply(this,arguments)})},{key:"getQueue",value:function(){return h(this.eventQueue)}},{key:"getQueueSize",value:function(){return this.eventQueue.length}},{key:"clearQueue",value:function(){this.eventQueue=[],this.persistQueue(),this.logger.debug("Queue cleared")}},{key:"reset",value:function(){this.clearQueue(),this.stopAutoFlush(),this.storageManager.clearQueue()}},{key:"updateConfig",value:function(e){this.config=e}},{key:"setNetworkManager",value:function(e){this.networkManager=e}},{key:"scheduleFlush",value:function(){var e=this;this.config.flushInterval>0&&(this.flushTimer=setInterval((function(){e.eventQueue.length>0&&e.networkManager&&(e.logger.debug("Auto-flush triggered"),e.flush(e.networkManager))}),1e3*this.config.flushInterval))}},{key:"restartAutoFlush",value:function(){this.stopAutoFlush(),this.scheduleFlush()}},{key:"stopAutoFlush",value:function(){this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=void 0)}},{key:"persistQueue",value:function(){if(this.config.enableLocalStorage)try{this.storageManager.persistQueue(this.eventQueue)}catch(e){this.logger.warn("Failed to persist queue",{error:e})}}},{key:"loadPersistedQueue",value:function(){if(this.config.enableLocalStorage)try{var e=this.storageManager.loadQueue();Array.isArray(e)&&e.length>0&&(this.eventQueue=e,this.logger.debug("Loaded ".concat(this.eventQueue.length," persisted events")))}catch(e){this.logger.warn("Failed to load persisted queue",{error:e})}}}]);var e}(),w=function(){return a((function e(){i(this,e)}),null,[{key:"isDoNotTrackEnabled",value:function(){if("undefined"==typeof navigator)return!1;var e=navigator.doNotTrack||window.doNotTrack||navigator.msDoNotTrack;return"1"===e||"yes"===e||!0===e}}])}(),S=function(){return a((function e(t,r,n,o,a){i(this,e),this.config=t,this.logger=r,this.queueManager=n,this.sessionManager=o,this.idGenerator=a}),[{key:"track",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(e&&"string"==typeof e)if(this.config.respectDoNotTrack&&w.isDoNotTrackEnabled())this.logger.debug("Do Not Track is enabled, skipping event tracking");else try{var i=c(c({},this.createBaseEvent(r.timestamp)),{},{name:e,properties:c({},t)},n.userId&&{userId:n.userId}),o=i;if(this.config.onBeforeTrack)try{var a=this.config.onBeforeTrack(i);a&&(o=a)}catch(e){this.logger.error("Error in onBeforeTrack callback",{error:e})}this.queueManager.enqueueEvent(o),this.logger.debug("Tracked event: ".concat(e),o)}catch(t){this.logger.error("Failed to track event",{eventName:e,error:t}),this.config.onError&&this.config.onError(t)}else this.logger.warn("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]:{};if(e&&"string"==typeof e)if(this.config.respectDoNotTrack&&w.isDoNotTrackEnabled())this.logger.debug("Do Not Track is enabled, skipping user identification");else try{var r=c(c({},this.createBaseEvent()),{},{userId:e,properties:c({},t)});this.queueManager.enqueueEvent(r),this.logger.debug("Identified user: ".concat(e),r)}catch(t){this.logger.error("Failed to identify user",{userId:e,error:t}),this.config.onError&&this.config.onError(t)}else this.logger.warn("User ID is required and must be a string")}},{key:"group",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"organization",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(e&&"string"==typeof e)if(this.config.respectDoNotTrack&&w.isDoNotTrackEnabled())this.logger.debug("Do Not Track is enabled, skipping group association");else try{var i=c(c({},this.createBaseEvent()),{},{groupId:e,groupType:r,properties:c({},t)},n.userId&&{userId:n.userId});this.queueManager.enqueueEvent(i),this.logger.debug("Associated with group: ".concat(e),i)}catch(t){this.logger.error("Failed to associate with group",{groupId:e,error:t}),this.config.onError&&this.config.onError(t)}else this.logger.warn("Group ID is required and must be a string")}},{key:"updateConfig",value:function(e){this.config=e}},{key:"createBaseEvent",value:function(e){var t=e||(new Date).toISOString();return{anonymousId:this.sessionManager.getAnonymousId(),timestamp:t,system:this.createSystemInfo()}}},{key:"createSystemInfo",value:function(){var e={sdk:{name:"@loopkit/javascript",version:"1.1.1"},sessionId:this.sessionManager.getSessionId()};return"undefined"!=typeof window&&(e.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}}),e}}])}(),T=function(){return a((function e(t,r){i(this,e),this.config=t,this.logger=r}),[{key:"sendEvents",value:(e=n(l().m((function e(t,r){var n,i,o,a,s,u,c,g,h,f,d,v,p,y,k,m,b=arguments;return l().w((function(e){for(;;)switch(e.n){case 0:return n=b.length>2&&void 0!==b[2]?b[2]:0,e.p=1,i={"Content-Type":"application/json","User-Agent":"@loopkit/javascript"},this.config.enableCompression&&(i["Accept-Encoding"]="gzip, deflate"),(o=new URL(t)).searchParams.set("apiKey",this.config.apiKey),a=o.toString(),s={method:"POST",headers:i,body:JSON.stringify(r)},this.config.requestTimeout&&this.config.requestTimeout>0&&(u=new AbortController,s.signal=u.signal,setTimeout((function(){return u.abort()}),this.config.requestTimeout)),c=this.getEventCountFromPayload(r),this.logger.debug("Sending ".concat(c," event(s) to ").concat(a),{retryCount:n,payload:r}),g=null,e.p=2,e.n=3,fetch(a,s);case 3:g=e.v,e.n=7;break;case 4:if(e.p=4,k=e.v,this.logger.error("Network error during sendEvents (attempt ".concat(n+1,")"),{endpoint:t,error:k instanceof Error?k.message:k,retryCount:n}),!(n<this.config.maxRetries)){e.n=6;break}return h=this.calculateRetryDelay(n),this.logger.debug("Retrying in ".concat(h,"ms (attempt ").concat(n+2,")")),e.n=5,this.sleep(h);case 5:return e.a(2,this.sendEvents(t,r,n+1));case 6:throw k;case 7:if(g&&g.ok){e.n=10;break}if(f=(null==g?void 0:g.status)||"unknown",d=(null==g?void 0:g.statusText)||"unknown error",v=new Error("HTTP ".concat(f,": ").concat(d)),this.logger.error("HTTP error during sendEvents (attempt ".concat(n+1,")"),{endpoint:t,status:f,statusText:d,retryCount:n}),!(n<this.config.maxRetries)){e.n=9;break}return p=this.calculateRetryDelay(n),this.logger.debug("Retrying in ".concat(p,"ms (attempt ").concat(n+2,")")),e.n=8,this.sleep(p);case 8:return e.a(2,this.sendEvents(t,r,n+1));case 9:throw v;case 10:return e.p=10,e.n=11,g.json();case 11:y=e.v,e.n=13;break;case 12:e.p=12,e.v,y={};case 13:return this.logger.debug("Events sent successfully",{result:y}),e.a(2,y);case 14:throw e.p=14,m=e.v,this.logger.error("Unexpected error in sendEvents",{endpoint:t,error:m instanceof Error?m.message:m,retryCount:n}),m;case 15:return e.a(2)}}),e,this,[[10,12],[2,4],[1,14]])}))),function(t,r){return e.apply(this,arguments)})},{key:"sendBeacon",value:function(e,t){if("undefined"==typeof navigator||!navigator.sendBeacon)return this.logger.warn("sendBeacon not available"),!1;try{var r=new URL(e);r.searchParams.set("apiKey",this.config.apiKey);var n=r.toString(),i=JSON.stringify(t),o=new Blob([i],{type:"application/json"}),a=navigator.sendBeacon(n,o);return a?this.logger.debug("Beacon sent successfully",{endpoint:n,payload:t}):this.logger.warn("Beacon failed to send",{endpoint:n}),a}catch(e){return this.logger.error("Beacon send error",{error:e}),!1}}},{key:"updateConfig",value:function(e){this.config=e}},{key:"calculateRetryDelay",value:function(e){return"linear"===this.config.retryBackoff?1e3*(e+1):1e3*Math.pow(2,e)}},{key:"sleep",value:function(e){return new Promise((function(t){return setTimeout(t,e)}))}},{key:"getEventCountFromPayload",value:function(e){return e&&"object"===d(e)?e.tracks&&Array.isArray(e.tracks)?e.tracks.length:e.identifies&&Array.isArray(e.identifies)?e.identifies.length:e.groups&&Array.isArray(e.groups)?e.groups.length:1:0}}]);var e}(),I=function(){return a((function e(t,r,n,o,a){i(this,e),this.config=t,this.logger=r,this.eventTracker=n,this.sessionManager=o,this.queueManager=a}),[{key:"setupFeatures",value:function(){"undefined"!=typeof window?(this.config.enableAutoClickTracking&&this.setupAutoClickTracking(),this.config.enableAutoCapture&&this.setupAutoPageViews(),this.config.enableErrorTracking&&this.setupErrorTracking(),this.setupPageUnloadHandling(),this.logger.debug("Browser features setup complete")):this.logger.debug("Not in browser environment, skipping browser features")}},{key:"setupAutoClickTracking",value:function(){var e=this;"undefined"!=typeof document&&(this.clickHandler=function(t){try{var r=t.target;if(!r)return;var n=e.findClickableElement(r);if(!n)return;var i=e.extractClickProperties(n,t);e.eventTracker.track("click",i)}catch(t){e.logger.error("Error in click tracking",{error:t})}},document.addEventListener("click",this.clickHandler,{capture:!0}),this.logger.debug("Auto-click tracking enabled"))}},{key:"setupAutoPageViews",value:function(){var e=this;if("undefined"!=typeof window){this.trackPageView();var t=history.pushState,r=history.replaceState;history.pushState=function(){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];t.apply(history,n),setTimeout((function(){return e.trackPageView()}),0)},history.replaceState=function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];r.apply(history,n),setTimeout((function(){return e.trackPageView()}),0)},window.addEventListener("popstate",(function(){setTimeout((function(){return e.trackPageView()}),0)})),this.logger.debug("Auto page view tracking enabled")}}},{key:"setupErrorTracking",value:function(){var e=this;"undefined"!=typeof window&&(this.errorHandler=function(t){var r;try{e.eventTracker.track("error",{message:t.message,filename:t.filename,lineno:t.lineno,colno:t.colno,stack:null===(r=t.error)||void 0===r?void 0:r.stack,timestamp:(new Date).toISOString()})}catch(t){e.logger.error("Error in error tracking",{error:t})}},window.addEventListener("error",this.errorHandler),this.logger.debug("Error tracking enabled"))}},{key:"setupPageUnloadHandling",value:function(){var e=this;"undefined"!=typeof window&&(this.unloadHandler=function(){try{if(e.queueManager.getQueueSize()>0&&e.networkManager){var t=e.queueManager.getQueue();if(t.length>0){var r=[],n=[],i=[];if(t.forEach((function(e){var t=e.type,o=e.event;switch(t){case"track":r.push(o);break;case"identify":n.push(o);break;case"group":i.push(o)}})),r.length>0){var o="".concat(e.config.baseURL,"/tracks"),a={tracks:r};e.networkManager.sendBeacon(o,a)}if(n.length>0){var s="".concat(e.config.baseURL,"/identifies"),u={identifies:n};e.networkManager.sendBeacon(s,u)}if(i.length>0){var c="".concat(e.config.baseURL,"/groups"),l={groups:i};e.networkManager.sendBeacon(c,l)}}}}catch(t){e.logger.error("Error in unload handler",{error:t})}},window.addEventListener("beforeunload",this.unloadHandler),this.logger.debug("Page unload handling enabled"))}},{key:"updateConfig",value:function(e){this.config=e}},{key:"setNetworkManager",value:function(e){this.networkManager=e}},{key:"trackPageView",value:function(){this.eventTracker.track("page_view",{url:window.location.href,path:window.location.pathname,search:window.location.search,title:document.title,referrer:document.referrer})}},{key:"findClickableElement",value:function(e){for(var t=e,r=0;t&&r<5;){var n=t.tagName.toLowerCase();if("a"===n||"button"===n||"button"===t.getAttribute("role")||t.onclick||"pointer"===t.style.cursor)return t;t=t.parentElement,r++}return e}},{key:"extractClickProperties",value:function(e,t){return e.getBoundingClientRect(),{element_type:this.getElementType(e),element_text:this.getElementText(e),element_id:e.id||null,element_class:e.className||null,element_tag:e.tagName.toLowerCase(),element_href:e.href||void 0,element_aria_label:e.getAttribute("aria-label")||void 0,page:window.location.pathname,page_title:document.title,page_url:window.location.href,position:{x:Math.round(t.clientX),y:Math.round(t.clientY)}}}},{key:"getElementType",value:function(e){var t=e.tagName.toLowerCase();return"a"===t?"link":"button"===t||"button"===e.getAttribute("role")?"button":"input"===t?"input":"form"===t?"form":"element"}},{key:"getElementText",value:function(e){return(e.innerText||e.textContent||e.getAttribute("aria-label")||e.getAttribute("title")||e.getAttribute("alt")||"").trim().substring(0,255)}}])}(),A=function(){return a((function e(){i(this,e),this.version="1.1.1",this.config={apiKey:"",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"},this.initialized=!1,this.userId=null,this.userProperties={},this.groupId=null,this.groupProperties={}}),[{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.config=c(c(c({},this.config),t),{},{apiKey:e}),v.validate(this.config),this.logger=new p(this.config),this.idGenerator=new y,this.storageManager=new k(this.config,this.logger),this.sessionManager=new m(this.config,this.logger,this.idGenerator,this.storageManager),this.queueManager=new b(this.config,this.logger,this.storageManager),this.eventTracker=new S(this.config,this.logger,this.queueManager,this.sessionManager,this.idGenerator),this.networkManager=new T(this.config,this.logger),"undefined"!=typeof window&&(this.browserFeatures=new I(this.config,this.logger,this.eventTracker,this.sessionManager,this.queueManager)),this.queueManager.setNetworkManager(this.networkManager),this.queueManager.scheduleFlush(),this.browserFeatures&&(this.browserFeatures.setNetworkManager(this.networkManager),this.browserFeatures.setupFeatures()),this.initialized=!0,this.logger.debug("LoopKit configured",this.config),this.logger.info("LoopKit initialized",{apiKey:this.config.apiKey.substring(0,8)+"...",version:this.version}),this}},{key:"configure",value:function(e){var t,r,n,i,o,a,s,u;return v.validate(e),this.config=c(c({},this.config),e),this.initialized&&(null===(t=this.logger)||void 0===t||t.updateConfig(this.config),null===(r=this.storageManager)||void 0===r||r.updateConfig(this.config),null===(n=this.sessionManager)||void 0===n||n.updateConfig(this.config),null===(i=this.queueManager)||void 0===i||i.updateConfig(this.config),null===(o=this.eventTracker)||void 0===o||o.updateConfig(this.config),null===(a=this.networkManager)||void 0===a||a.updateConfig(this.config),null===(s=this.browserFeatures)||void 0===s||s.updateConfig(this.config),null===(u=this.queueManager)||void 0===u||u.restartAutoFlush()),this}},{key:"getConfig",value:function(){return c({},this.config)}},{key:"track",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.initialized?e&&"string"==typeof e?(this.eventTracker.track(e,t,r,{userId:this.userId,userProperties:this.userProperties,groupId:this.groupId,groupProperties:this.groupProperties}),this):(this.logger.warn("Event name 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&&"object"===d(e)&&e.name&&t.track(e.name,e.properties||{},e.options||{})})),this):(this.logger.error("trackBatch expects an array of events"),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=c(c({},this.userProperties),t),this.eventTracker.identify(e,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]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"organization";return this.initialized?e&&"string"==typeof e?(this.groupId=e,this.groupProperties=c(c({},this.groupProperties),t),this.eventTracker.group(e,t,r,{userId:this.userId}),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:"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.initialized?this.queueManager.getQueueSize():0}},{key:"reset",value:function(){var e,t,r;this.initialized&&(this.userId=null,this.userProperties={},this.groupId=null,this.groupProperties={},null===(e=this.queueManager)||void 0===e||e.reset(),null===(t=this.storageManager)||void 0===t||t.clearAll(),null===(r=this.sessionManager)||void 0===r||r.reset(),this.logger.debug("SDK state reset"))}},{key:"resetForTesting",value:function(){var e,t,r;this.initialized&&(null===(e=this.queueManager)||void 0===e||e.reset(),null===(t=this.storageManager)||void 0===t||t.clearAll(),null===(r=this.sessionManager)||void 0===r||r.reset()),this.initialized=!1,this.userId=null,this.userProperties={},this.groupId=null,this.groupProperties={},this.config={apiKey:"",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"}}}]);var e}(),E=new A;"undefined"!=typeof module&&module.exports?module.exports=E:"undefined"!=typeof window&&(window.LoopKit=E),e.LoopKit=A,e.default=E,Object.defineProperty(e,"__esModule",{value:!0})})); |
+1
-1
| { | ||
| "name": "@loopkit/javascript", | ||
| "version": "1.1.0", | ||
| "version": "1.1.1", | ||
| "description": "JavaScript SDK for LoopKit analytics platform", | ||
@@ -5,0 +5,0 @@ "type": "module", |
+1
-1
@@ -210,3 +210,3 @@ # LoopKit JavaScript SDK | ||
| - **Track Events**: `POST /tracks` with payload `{ tracks: [...] }` | ||
| - **User Identification**: `POST /identities` with payload `{ identifies: [...] }` | ||
| - **User Identification**: `POST /identifies` with payload `{ identifies: [...] }` | ||
| - **Group Association**: `POST /groups` with payload `{ groups: [...] }` | ||
@@ -213,0 +213,0 @@ |
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
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package