@macroui/event-tracker 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +343 -0
- package/bin/event-tracker-suggest.mjs +141 -0
- package/bin/event-tracker.mjs +157 -0
- package/dist/event-tracker.cjs +3449 -0
- package/dist/event-tracker.js +3455 -0
- package/dist/event-tracker.min.js +1 -0
- package/dist/event-tracker.mjs +3402 -0
- package/dist/plugin/auto-track.cjs +201 -0
- package/dist/plugin/auto-track.mjs +199 -0
- package/dist/plugin/debug-sender.cjs +214 -0
- package/dist/plugin/debug-sender.mjs +211 -0
- package/dist/plugin/encrypt.cjs +284 -0
- package/dist/plugin/encrypt.mjs +275 -0
- package/dist/plugin/exposure.cjs +121 -0
- package/dist/plugin/exposure.mjs +119 -0
- package/dist/plugin/indexeddb-sender.cjs +94 -0
- package/dist/plugin/indexeddb-sender.mjs +92 -0
- package/dist/plugin/pageleave.cjs +74 -0
- package/dist/plugin/pageleave.mjs +72 -0
- package/dist/plugin/pageload.cjs +198 -0
- package/dist/plugin/pageload.mjs +196 -0
- package/dist/plugin/session-event.cjs +142 -0
- package/dist/plugin/session-event.mjs +140 -0
- package/dist/plugin/webview-bridge.cjs +111 -0
- package/dist/plugin/webview-bridge.mjs +109 -0
- package/dist/types/core/env.d.ts +10 -0
- package/dist/types/core/errors.d.ts +76 -0
- package/dist/types/core/failed-queue.d.ts +24 -0
- package/dist/types/core/identity-api.d.ts +6 -0
- package/dist/types/core/identity.d.ts +39 -0
- package/dist/types/core/instance-channel.d.ts +34 -0
- package/dist/types/core/lifecycle.d.ts +26 -0
- package/dist/types/core/logger.d.ts +13 -0
- package/dist/types/core/plugin.d.ts +60 -0
- package/dist/types/core/profile-api.d.ts +6 -0
- package/dist/types/core/profile-store.d.ts +23 -0
- package/dist/types/core/register-api.d.ts +22 -0
- package/dist/types/core/retry-policy.d.ts +33 -0
- package/dist/types/core/send-pipeline.d.ts +55 -0
- package/dist/types/core/signed-identity.d.ts +29 -0
- package/dist/types/core/stage.d.ts +48 -0
- package/dist/types/core/track-api.d.ts +6 -0
- package/dist/types/core/tracker.d.ts +130 -0
- package/dist/types/core/uuid.d.ts +4 -0
- package/dist/types/index.d.ts +40 -0
- package/dist/types/plugins/auto-track/index.d.ts +21 -0
- package/dist/types/plugins/debug-sender/index.d.ts +24 -0
- package/dist/types/plugins/encrypt/index.d.ts +56 -0
- package/dist/types/plugins/exposure/index.d.ts +18 -0
- package/dist/types/plugins/indexeddb-sender/index.d.ts +15 -0
- package/dist/types/plugins/pageleave/index.d.ts +12 -0
- package/dist/types/plugins/pageload/index.d.ts +14 -0
- package/dist/types/plugins/session-event/index.d.ts +14 -0
- package/dist/types/plugins/webview-bridge/index.d.ts +33 -0
- package/dist/types/presets/preset-properties.d.ts +25 -0
- package/dist/types/send/ajax-sender.d.ts +11 -0
- package/dist/types/send/batch-sender.d.ts +17 -0
- package/dist/types/send/beacon-sender.d.ts +10 -0
- package/dist/types/send/encode.d.ts +8 -0
- package/dist/types/send/image-sender.d.ts +10 -0
- package/dist/types/send/sender.d.ts +20 -0
- package/dist/types/storage/indexeddb-store.d.ts +14 -0
- package/dist/types/storage/store.d.ts +56 -0
- package/dist/types/types/common.d.ts +26 -0
- package/dist/types/types/config.d.ts +117 -0
- package/dist/types/types/constants.d.ts +110 -0
- package/dist/types/types/index.d.ts +25 -0
- package/dist/types/types.test-d.d.ts +5 -0
- package/dist/types.test-d.ts +103 -0
- package/package.json +218 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).EventTracker={})}(this,function(t){"use strict";var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},e(t,n)};function n(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r=function(){return r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},r.apply(this,arguments)};function i(t,e,n,r){return new(n||(n=Promise))(function(i,o){function s(t){try{c(r.next(t))}catch(t){o(t)}}function a(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(s,a)}c((r=r.apply(t,e||[])).next())})}function o(t,e){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=e.call(t,o)}catch(t){a=[6,t],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function s(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}function a(){return"undefined"!=typeof window&&void 0!==window.document}function c(){try{if(!a()||!window.localStorage)return!1;var t="__et_test__";return window.localStorage.setItem(t,"1"),window.localStorage.removeItem(t),!0}catch(t){return!1}}function u(){return a()&&"function"==typeof Image}function l(){if("undefined"!=typeof crypto&&"function"==typeof crypto.getRandomValues){var t=new Uint8Array(16);crypto.getRandomValues(t),t[6]=15&t[6]|64,t[8]=63&t[8]|128;var e=Array.from(t,function(t){return t.toString(16).padStart(2,"0")});return e.slice(0,4).join("")+"-"+e.slice(4,6).join("")+"-"+e.slice(6,8).join("")+"-"+e.slice(8,10).join("")+"-"+e.slice(10,16).join("")}var n=Date.now(),r="undefined"!=typeof performance&&performance.now&&1e3*performance.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random();return n>0?(e=(n+e)%16|0,n=Math.floor(n/16)):(e=(r+e)%16|0,r=Math.floor(r/16)),("x"===t?e:3&e|8).toString(16)})}"function"==typeof SuppressedError&&SuppressedError;var d=function(){function t(t){this.config=t}return t.prototype.log=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.shouldLog("log",t)&&this.out("log",t)},t.prototype.warn=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.shouldLog("warn",t)&&this.out("warn",t)},t.prototype.error=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.shouldLog("error",t)&&this.out("error",t)},t.prototype.shouldLog=function(t,e){if(2===this.config.debug){if("error"===t)throw e[0]instanceof Error?e[0]:new Error(String(e[0]));return!0}return 1===this.config.debug&&("warn"===t||"error"===t)||!(!this.config.show_log||"log"!==t)},t.prototype.out=function(t,e){var n="undefined"!=typeof console&&console[t]?console[t]:console.log;try{n.call.apply(n,s([console,"[EventTracker]"],e,!1))}catch(t){}},t}(),f="et_distinct_id",p="et_anonymous_id",h="et_login_id",g="et_original_id",y=function(){function t(t,e){void 0===e&&(e={});var n=this;this.store=t,this.opts=e,this.loginId="",this.originalId="",this.anonymousId=this.readOrCreate(p,function(){return l()},this.opts.getAnonymousId,this.opts.setAnonymousId),this.firstId=this.readOrCreate("et_first_id",function(){return l()},this.opts.getFirstId,this.opts.setFirstId),this.distinctId=this.readOrCreate(f,function(){return n.anonymousId},this.opts.getDistinctId,this.opts.setDistinctId)}return t.prototype.readOrCreate=function(t,e,n,r){if(n)try{var i=n();if(i)return i}catch(t){}var o=this.store.get(t);if(o)return o;var s=e();return this.persist(t,s,r),s},t.prototype.persist=function(t,e,n){if(n)try{return void n(e)}catch(t){}this.store.set(t,e)},t.prototype.getDistinctId=function(){return this.distinctId},t.prototype.getAnonymousId=function(){return this.anonymousId},t.prototype.getFirstId=function(){return this.firstId},t.prototype.getLoginId=function(){return this.loginId},t.prototype.getOriginalId=function(){return this.originalId},t.prototype.identify=function(t,e){if(void 0===e&&(e=!0),t!==this.loginId){var n=this.distinctId;this.distinctId=t,this.loginId=t,this.originalId=n,this.persist(f,t,this.opts.setDistinctId),e?this.persist(h,t):this.store.remove(h),this.persist(g,n)}},t.prototype.resetAnonymousIdentity=function(t){this.distinctId=t||this.anonymousId,this.loginId="",this.originalId="",this.persist(f,this.distinctId,this.opts.setDistinctId),this.store.remove(h),this.store.remove(g),t&&(this.anonymousId=t,this.persist(p,t,this.opts.setAnonymousId))},t.prototype.login=function(t){this.identify(t,!0)},t.prototype.logout=function(){this.resetAnonymousIdentity()},t}(),v={PageView:"$pageview",WebPageLoad:"$WebPageLoad",WebPageLeave:"$WebPageLeave",WebClick:"$WebClick",WebStay:"$WebStay",SignUp:"$SignUp",BindID:"$BindID",UnbindID:"$UnbindID",ABTestTrigger:"$ABTestTrigger",PlanPopupClick:"$PlanPopupClick",PlanPopupDisplay:"$PlanPopupDisplay",ChannelLinkReaching:"$ChannelLinkReaching",ElementExposure:"$element_exposure",ScrollDepth:"$scrolldepth",ExitClick:"$exit_click",PageLeave:"$page_leave",HeatmapEvent:"$heatmap_event"},_={AppId:"$app_id",AppVersion:"$app_version",Lib:"$lib",LibMethod:"$lib_method",LibDetail:"$lib_detail",LibVersion:"$lib_version",ScreenWidth:"$screen_width",ScreenHeight:"$screen_height",ViewportWidth:"$viewport_width",ViewportHeight:"$viewport_height",TimezoneOffset:"$timezone_offset",UserAgent:"$user_agent",Language:"$language",FirstBrowserCharset:"$first_browser_charset",FirstBrowserLanguage:"$first_browser_language",URL:"$url",URLPath:"$url_path",Title:"$title",Referrer:"$referrer",ReferrerHost:"$referrer_host",LatestReferrer:"$latest_referrer",LatestReferrerHost:"$latest_referrer_host",LatestLandingPage:"$latest_landing_page",LatestSearchKeyword:"$latest_search_keyword",LatestTrafficSourceType:"$latest_traffic_source_type",FirstReferrer:"$first_referrer",FirstReferrerHost:"$first_referrer_host",FirstSearchKeyword:"$first_search_keyword",FirstTrafficSourceType:"$first_traffic_source_type",FirstVisitTime:"$first_visit_time",SearchKeywordId:"$search_keyword_id",SearchKeywordIdHash:"$search_keyword_id_hash",SearchKeywordIdType:"$search_keyword_id_type",IsFirstDay:"$is_first_day",IsFirstTime:"$is_first_time",LatestUtmSource:"$latest_utm_source",LatestUtmMedium:"$latest_utm_medium",LatestUtmCampaign:"$latest_utm_campaign",LatestUtmContent:"$latest_utm_content",LatestUtmTerm:"$latest_utm_term",Utms:"$utms",DistinctId:"$distinct_id",AnonymousId:"$anonymous_id",FirstId:"$first_id",OriginalId:"$original_id",LoginId:"$login_id",IsLoginId:"$is_login_id",IdentityLoginId:"$identity_login_id",IdentityAnonymousId:"$identity_anonymous_id",IdentityCookieId:"$identity_cookie_id",IdentityEmail:"$identity_email",IdentityMobile:"$identity_mobile",ElementSelector:"$element_selector",ElementPath:"$element_path",ElementType:"$element_type",ElementId:"$element_id",ElementClassName:"$element_class_name",ElementName:"$element_name",ElementContent:"$element_content",ElementTargetUrl:"$element_target_url",ElementPosition:"$element_position",PageX:"$page_x",PageY:"$page_y",PageHeight:"$page_height",PageResourceSize:"$page_resource_size",EventDuration:"$event_duration",ViewportPosition:"$viewport_position",LatestWxAdClickId:"$latest_wx_ad_click_id",LatestWxAdCallbacks:"$latest_wx_ad_callbacks",LatestWxAdHashKey:"$latest_wx_ad_hash_key",IsChannelCallbackEvent:"$is_channel_callback_event",EventSessionId:"$event_session_id",Time:"$time",Event:"$event",Option:"$option",Project:"$project",Token:"$token",SignupMethod:"$signup_method"},m="event-tracker",b="1.1.0",w=function(){function t(){this.preset={}}return t.prototype.setPreset=function(t){this.preset=r({},t)},t.prototype.register=function(t){Object.assign(this.preset,t)},t.prototype.registerOnce=function(t){for(var e=0,n=Object.keys(t);e<n.length;e++){var r=n[e];r in this.preset||(this.preset[r]=t[r])}},t.prototype.clearRegister=function(){this.preset={}},t.prototype.unsetRegister=function(t){Object.prototype.hasOwnProperty.call(this.preset,t)&&delete this.preset[t]},t.prototype.getPreset=function(){return r({},this.preset)},t.prototype.build=function(t,e){void 0===e&&(e={});var n=r(r({},this.preset),e);if(n[_.Lib]=t.lib_name||"event-tracker",n[_.LibVersion]=t.lib_version||"0.1.0",t.app_id&&(n[_.AppId]=t.app_id),t.app_version&&(n[_.AppVersion]=t.app_version),a())try{n[_.URL]=location.href,n[_.URLPath]=location.pathname,n[_.Title]=document.title,document.referrer&&(n[_.Referrer]=document.referrer);var i=window.screen&&window.screen.width||0,o=window.screen&&window.screen.height||0;i&&(n[_.ScreenWidth]=i),o&&(n[_.ScreenHeight]=o);var s=window.innerWidth||document.documentElement&&document.documentElement.clientWidth||0,c=window.innerHeight||document.documentElement&&document.documentElement.clientHeight||0;s&&(n[_.ViewportWidth]=s),c&&(n[_.ViewportHeight]=c),navigator&&(n[_.Language]=navigator.language||"",n[_.UserAgent]=t.user_agent||navigator.userAgent||"",n[_.TimezoneOffset]=(new Date).getTimezoneOffset())}catch(t){}if(a()&&!1!==t.is_collect_utm){for(var u=function(t){var e={};if(!t)return e;for(var n=(t.startsWith("?")?t.substring(1):t).split("&"),r=0,i=n;r<i.length;r++){var o=i[r],s=o.indexOf("=");if(-1!==s){var a=decodeURIComponent(o.substring(0,s)),c=decodeURIComponent(o.substring(s+1));a.startsWith("utm_")&&(e[a]=c)}}return e}(location.search),l=0,d=Object.entries(u);l<d.length;l++){var f=d[l],p=f[0],h=f[1];n[_.LatestUtmSource.replace("Source",k(p.replace("utm_","")))]=h}n[_.LatestTrafficSourceType]=n[_.LatestUtmSource]?"付费广告流量":"直接流量"}return n},t}();function k(t){return t.charAt(0).toUpperCase()+t.slice(1)}var I=function(){function t(){this.backing=new Map}return t.prototype.get=function(t){return this.backing.has(t)?this.backing.get(t):null},t.prototype.set=function(t,e){this.backing.set(t,e)},t.prototype.remove=function(t){this.backing.delete(t)},t.prototype.keys=function(t){return void 0===t&&(t=""),Array.from(this.backing.keys()).filter(function(e){return e.startsWith(t)})},t}(),S=function(){function t(t,e,n){void 0===e&&(e=!0),void 0===n&&(n=!1),this.domain=t,this.crossSubdomain=e,this.secure=n}return t.prototype.get=function(t){for(var e=encodeURIComponent(t)+"=",n=document.cookie.split(";"),r=0;r<n.length;r++){for(var i=n[r];" "===i.charAt(0);)i=i.substring(1);if(0===i.indexOf(e))return decodeURIComponent(i.substring(e.length,i.length))}return null},t.prototype.set=function(t,e,n){void 0===n&&(n=365);var r="";if(n){var i=new Date;i.setTime(i.getTime()+24*n*60*60*1e3),r="; expires="+i.toUTCString()}var o=encodeURIComponent(t)+"="+encodeURIComponent(e)+r+"; path=/";this.domain&&this.crossSubdomain&&(o+="; domain="+this.domain),this.secure&&(o+="; Secure"),document.cookie=o},t.prototype.remove=function(t){this.set(t,"",-1)},t.prototype.keys=function(t){return void 0===t&&(t=""),document.cookie.split(";").map(function(t){var e=t.indexOf("=");return decodeURIComponent((e>-1?t.substring(0,e):t).trim())}).filter(function(e){return e.startsWith(t)})},t}(),E=function(){function t(){}return t.prototype.get=function(t){try{return window.localStorage.getItem(t)}catch(t){return null}},t.prototype.set=function(t,e){try{window.localStorage.setItem(t,e)}catch(t){}},t.prototype.remove=function(t){try{window.localStorage.removeItem(t)}catch(t){}},t.prototype.keys=function(t){void 0===t&&(t="");var e=[];try{for(var n=0;n<window.localStorage.length;n++){var r=window.localStorage.key(n);r&&r.startsWith(t)&&e.push(r)}}catch(t){}return e},t}();function A(t){return function(){if(!a()||!document.cookie)return!1;document.cookie="__et_test__=1";var t=-1!==document.cookie.indexOf("__et_test__");return document.cookie="__et_test__=; expires=Thu, 01 Jan 1970 00:00:00 GMT",t}()?new S(null==t?void 0:t.cookieDomain,null==t?void 0:t.cookieCrossSubdomain,null==t?void 0:t.secureCookie):c()?new E:new I}function $(t,e){var n=JSON.stringify(t);return e?e(n):n}function P(t,e){var n=JSON.stringify(t);return e?e(n):n}function T(t,e,n){var r=Array.isArray(t)?t[0]||"":t,i=r.indexOf("?")>=0;return"".concat(r).concat(i?"&":"?","data=").concat(encodeURIComponent(e))}var x=function(){function t(){this.name="image"}return t.prototype.canUse=function(){return u()},t.prototype.send=function(t,e){return i(this,void 0,void 0,function(){var n,r,i;return o(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,Promise.resolve($(t,e.config.encryptor))];case 1:return n=o.sent(),r=T(e.config.server_url||"",n),[4,new Promise(function(t){var e,n="function"==typeof(e=((0,eval)("this")||globalThis).Image)?new e:{src:"",onload:void 0,onerror:void 0,onabort:void 0},i=function(){return t()};n.onload=i,n.onerror=i,n.onabort=i,n.src=r,setTimeout(i,3e3)})];case 2:return o.sent(),[3,4];case 3:return i=o.sent(),e.logger.error("ImageSender failed:",i),[3,4];case 4:return[2]}})})},t}(),L=function(){function t(){this.name="beacon"}return t.prototype.canUse=function(){return a()&&"undefined"!=typeof navigator&&"function"==typeof navigator.sendBeacon},t.prototype.send=function(t,e){return i(this,void 0,void 0,function(){var n,r,i,s;return o(this,function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,Promise.resolve($(t,e.config.encryptor))];case 1:return n=o.sent(),r=T(e.config.server_url||"",n),i=new Blob([n],{type:"application/x-www-form-urlencoded"}),navigator.sendBeacon(r,i)||e.logger.warn("BeaconSender returned false, URL:",r.slice(0,80)),[3,3];case 2:return s=o.sent(),e.logger.error("BeaconSender failed:",s),[3,3];case 3:return[2]}})})},t}(),C=function(){function t(){this.name="ajax"}return t.prototype.canUse=function(){return a()&&"function"==typeof fetch},t.prototype.send=function(t,e){return i(this,void 0,void 0,function(){var n,r,i,s,a,c,u,l,d,f,p;return o(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,Promise.resolve($(t,e.config.encryptor))];case 1:return n=o.sent(),r=Array.isArray(e.config.server_url)?e.config.server_url[0]:e.config.server_url,i="data=".concat(encodeURIComponent(n)),[4,fetch(r,{method:"POST",mode:"cors",credentials:"omit",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:i,keepalive:!0})];case 2:return(s=o.sent()).ok?null===(d=(l=e.config).callback)||void 0===d||d.call(l,t):(e.logger.warn("AjaxSender non-2xx:",s.status),null===(u=(c=e.config).on_error)||void 0===u||u.call(c,new Error("HTTP ".concat(s.status)),t)),[3,4];case 3:return a=o.sent(),e.logger.error("AjaxSender failed:",a),null===(p=(f=e.config).on_error)||void 0===p||p.call(f,a,t),[3,4];case 4:return[2]}})})},t.prototype.sendBatch=function(t,e){return i(this,void 0,void 0,function(){var n,r,i,s;return o(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,Promise.resolve(P(t,e.config.encryptor))];case 1:return n=o.sent(),r=Array.isArray(e.config.server_url)?e.config.server_url[0]:e.config.server_url,i="data=".concat(encodeURIComponent(n),"&batch=1"),[4,fetch(r,{method:"POST",mode:"cors",credentials:"omit",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:i,keepalive:!0})];case 2:return o.sent(),[3,4];case 3:return s=o.sent(),e.logger.error("AjaxSender.sendBatch failed:",s),[3,4];case 4:return[2]}})})},t}(),D=Object.freeze({__proto__:null,AjaxSender:C}),O="et_batch_queue",U=function(){function t(){this.name="batch",this.timer=null}return t.prototype.canUse=function(){return"undefined"!=typeof window&&!!window.localStorage},t.prototype.start=function(t){var e=this;if(this.canUse()){var n=t.config.batch_send,r="object"==typeof n&&(null==n?void 0:n.send_interval)||t.config.datasend_timeout||6e3;this.timer=setInterval(function(){return e.flush(t)},r)}},t.prototype.stop=function(){this.timer&&clearInterval(this.timer),this.timer=null},t.prototype.send=function(t,e){return i(this,void 0,void 0,function(){var n,r;return o(this,function(i){switch(i.label){case 0:return this.enqueue(t,e.config),n="object"==typeof e.config.batch_send&&(null===(r=e.config.batch_send)||void 0===r?void 0:r.max_length)||50,this.read(e.config).length>=n?[4,this.flush(e)]:[3,2];case 1:i.sent(),i.label=2;case 2:return[2]}})})},t.prototype.enqueue=function(t,e){var n=this.read(e);n.push(t),this.write(n,e)},t.prototype.read=function(t){try{var e=window.localStorage.getItem(O);if(!e)return[];var n=JSON.parse(e);return Array.isArray(n)?n:[]}catch(t){return[]}},t.prototype.write=function(t,e){try{var n=P(t,e.encryptor),r="string"==typeof n?n:JSON.stringify(t);window.localStorage.setItem(O,r)}catch(n){var i=t.slice(Math.floor(t.length/2));try{var o=P(i,e.encryptor),s="string"==typeof o?o:JSON.stringify(i);window.localStorage.setItem(O,s)}catch(t){}}},t.prototype.flush=function(t){return i(this,void 0,void 0,function(){var e,n,r,i,s,a;return o(this,function(o){switch(o.label){case 0:if(!(e=this.read(t.config)).length)return[2];try{window.localStorage.removeItem(O)}catch(t){}return[4,Promise.resolve().then(function(){return D})];case 1:return(n=new(o.sent().AjaxSender)).canUse()?[4,n.sendBatch(e,t)]:[3,3];case 2:return o.sent(),[3,7];case 3:r=new L,i=0,s=e,o.label=4;case 4:return i<s.length?(a=s[i],[4,r.send(a,t)]):[3,7];case 5:o.sent(),o.label=6;case 6:return i++,[3,4];case 7:return[2]}})})},t}(),R=function(){function t(t){this.stage=t,this.list=[],this.stopped=!1,this.stopFlag=!1}return t.prototype.register=function(t){var e;this.unregister(t.name),this.list.push({priority:null!==(e=t.priority)&&void 0!==e?e:100,spec:t}),this.list.sort(function(t,e){return t.priority-e.priority})},t.prototype.unregister=function(t){this.list=this.list.filter(function(e){return e.spec.name!==t})},t.prototype.list2=function(){return this.list.map(function(t){return"".concat(t.spec.name,"@").concat(t.priority)})},t.prototype.reset=function(){this.stopFlag=!1},t.prototype.run=function(t,e){var n=this;this.stopFlag=!1;for(var r={data:t,meta:{stage:this.stage},cancellationToken:{stop:function(){n.stopFlag=!0}},owner:e},i=0,o=this.list;i<o.length;i++){var s=o[i].spec;if(this.stopFlag)break;var a=s.entry(r);void 0!==a&&(r.data=a)}return r.data},t}(),j=function(){function t(){this.hooks={sdkReady:new Set,sdkInitPara:new Set,sdkAfterInitPara:new Set,sdkInitAPI:new Set,sdkAfterInitAPI:new Set,changeDistinctId:new Set,switch:new Set}}return t.prototype.on=function(t,e){var n=this;if(!this.hooks[t])throw new Error("[Lifecycle] unknown hook: ".concat(t));return this.hooks[t].add(e),function(){return n.off(t,e)}},t.prototype.off=function(t,e){var n;null===(n=this.hooks[t])||void 0===n||n.delete(e)},t.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=this.hooks[t];if(r)for(var i=0,o=Array.from(r);i<o.length;i++){var s=o[i];try{s.apply(void 0,e)}catch(e){"undefined"!=typeof console&&console.error&&console.error("[EventTracker] hook ".concat(t," error:"),e)}}},t.prototype.clear=function(){for(var t=0,e=Object.keys(this.hooks);t<e.length;t++){var n=e[t];this.hooks[n].clear()}},t.prototype.inspect=function(){for(var t={},e=0,n=Object.keys(this.hooks);e<n.length;e++){var r=n[e];t[r]=this.hooks[r].size}return t},t}(),N=function(){function t(){this.lifecycle=new j,this.plugins=[],this.commonWays={},this.stages={buildDataStage:new R("buildDataStage"),businessStage:new R("businessStage"),sendDataStage:new R("sendDataStage")}}return t.prototype.on=function(t,e){return this.lifecycle.on(t,e)},t.prototype.off=function(t,e){this.lifecycle.off(t,e)},t.prototype.emit=function(t){for(var e,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];(e=this.lifecycle).emit.apply(e,s([t],n,!1))},t.prototype.intercept=function(t,e){this.stages[t].register(e)},t.prototype.invoke=function(t){for(var e,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];(e=this.lifecycle).emit.apply(e,s([t],n,!1))},t.prototype.install=function(t,e){var n=this.plugins.findIndex(function(e){return e.name===t.name});if(n>=0&&(this.uninstall(this.plugins[n]),this.plugins.splice(n,1)),this.plugins.push(t),t.install){var i=r(r({},e),{registry:this,stages:this.stages});try{t.install(i)}catch(e){"undefined"!=typeof console&&console.error&&console.error("[EventTracker] plugin ".concat(t.name," install failed:"),e)}}},t.prototype.uninstall=function(t,e){var n;try{null===(n=t.uninstall)||void 0===n||n.call(t,e)}catch(e){"undefined"!=typeof console&&console.error&&console.error("[EventTracker] plugin ".concat(t.name," uninstall failed:"),e)}},t.prototype.list=function(){return this.plugins.map(function(t){return t.name})},t}(),M="event-tracker",B=function(){function t(){this.bc=null,this.listeners=new Set,this.sourceId="".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,8)),this.localStorageKey="et_channel_".concat(M),this.pollTimer=null,this.initBroadcastChannel(),this.bc||this.initLocalStoragePolling()}return t.prototype.initBroadcastChannel=function(){var t=this;if("undefined"!=typeof BroadcastChannel)try{this.bc=new BroadcastChannel(M),this.bc.onmessage=function(e){var n;(null===(n=e.data)||void 0===n?void 0:n.source)!==t.sourceId&&t.listeners.forEach(function(t){return t(e.data)})}}catch(t){this.bc=null}},t.prototype.initLocalStoragePolling=function(){var t=this;"undefined"!=typeof window&&window.addEventListener("storage",function(e){if(e.key===t.localStorageKey&&e.newValue)try{var n=JSON.parse(e.newValue);if(n.source===t.sourceId)return;t.listeners.forEach(function(t){return t(n)})}catch(t){}})},t.prototype.post=function(t,e){var n={type:t,source:this.sourceId,payload:e};if(this.bc)try{this.bc.postMessage(n)}catch(t){}else try{localStorage.setItem(this.localStorageKey,JSON.stringify(n))}catch(t){}},t.prototype.on=function(t){var e=this;return this.listeners.add(t),function(){return e.listeners.delete(t)}},t.prototype.close=function(){if(this.bc){try{this.bc.close()}catch(t){}this.bc=null}this.listeners.clear(),this.pollTimer&&(clearInterval(this.pollTimer),this.pollTimer=null)},t.prototype.getSourceId=function(){return this.sourceId},t}(),W=function(){function t(t,e){this.config=t,this.logger=e}return t.prototype.backoff=function(t){return Math.min(1e3*Math.pow(2,t),3e4)},t.prototype.execute=function(t){return i(this,arguments,void 0,function(t,e,n){var r,i,s,a,c,u,l,d;return void 0===e&&(e=function(){return!0}),o(this,function(o){switch(o.label){case 0:r=null!==(l=this.config.max_retry_count)&&void 0!==l?l:3,i=null!==(d=this.config.max_retry_duration)&&void 0!==d?d:6e4,s=Date.now(),a=null,c=0,o.label=1;case 1:if(!(c<=r))return[3,8];o.label=2;case 2:return o.trys.push([2,4,,7]),[4,t()];case 3:return o.sent(),[2,{ok:!0,attempts:c+1,finalErr:null}];case 4:return u=o.sent(),e(a=u)?Date.now()-s+this.backoff(c)>i?(this.logger.warn("[EventTracker] max_retry_duration reached, give up"),null==n||n(a,c+1),[2,{ok:!1,attempts:c+1,finalErr:a}]):c<r?[4,this.sleep(this.backoff(c))]:[3,6]:[2,{ok:!1,attempts:c+1,finalErr:a}];case 5:o.sent(),o.label=6;case 6:return[3,7];case 7:return c++,[3,1];case 8:return null==n||n(a,r+1),[2,{ok:!1,attempts:r+1,finalErr:a}]}})})},t.prototype.sleep=function(t){return new Promise(function(e){return setTimeout(e,t)})},t}(),F="et_failed_queue",H=function(){function t(t){var e;void 0===t&&(t={}),this.config={max:null!==(e=t.max)&&void 0!==e?e:50,encryptor:t.encryptor}}return t.prototype.read=function(){if(!a()||!c())return[];try{var t=localStorage.getItem(F);if(!t)return[];var e=JSON.parse(t);return Array.isArray(e)?e:[]}catch(t){return[]}},t.prototype.enqueue=function(t){if(a()&&c()){var e=this.read();e.push(t),e.length>this.config.max&&e.splice(0,e.length-this.config.max);try{this.config.encryptor;var n=JSON.stringify(e);localStorage.setItem(F,n)}catch(t){var r=e.slice(Math.floor(e.length/2));try{localStorage.setItem(F,JSON.stringify(r))}catch(t){}}}},t.prototype.clear=function(){if(a()&&c())try{localStorage.removeItem(F)}catch(t){}},t.prototype.takeAll=function(){var t=this.read();return this.clear(),t},t}(),V=function(t){function e(e,n,r){void 0===r&&(r={});var i=t.call(this,n)||this;return i.name=i.constructor.name,i.code=e,i.cause=r.cause,i.context=r.context,i.timestamp=Date.now(),"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(i,i.constructor),i}return n(e,t),e.prototype.toJSON=function(){return{name:this.name,code:this.code,message:this.message,timestamp:this.timestamp,context:this.context,stack:this.stack}},e}(Error),q=function(t){function e(e,n){return t.call(this,"INIT",e,n)||this}return n(e,t),e}(V),z=function(t){function e(e,n,r){var i=t.call(this,"SEND",e,r)||this;return i.attempts=n,i}return n(e,t),e}(V),J=function(t){function e(e,n){return t.call(this,"ENCRYPT",e,n)||this}return n(e,t),e}(V),K=function(t){function e(e,n){return t.call(this,"IDENTITY",e,n)||this}return n(e,t),e}(V),G=function(t){function e(e,n){return t.call(this,"STORAGE",e,n)||this}return n(e,t),e}(V),Y=function(t){function e(e,n,r){var i=t.call(this,"PLUGIN",n,r)||this;return i.plugin=e,i}return n(e,t),e}(V),Q=function(t){function e(e,n){return t.call(this,"CONFIG",e,n)||this}return n(e,t),e}(V);var X=function(){if("undefined"!=typeof globalThis&&globalThis.TextEncoder)return new globalThis.TextEncoder;var t=require("util").TextEncoder;return globalThis.TextEncoder=t,new t}();function Z(t){if("undefined"!=typeof btoa){for(var e="",n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e)}return Buffer.from(t).toString("base64")}function tt(t,e){for(var n=2166136261,r=3421674724,i=0;i<t.length;i++)n^=t.charCodeAt(i),n=Math.imul(n,16777619)>>>0,r^=e.charCodeAt(i%e.length),r=Math.imul(r,1099511628211)>>>0;return(BigInt(n)<<32n|BigInt(r)).toString(36)}function et(t,e){return i(this,void 0,void 0,function(){var n,r,i;return o(this,function(o){switch(o.label){case 0:return n=function(){var t;if("undefined"!=typeof globalThis&&(null===(t=globalThis.crypto)||void 0===t?void 0:t.subtle))return globalThis.crypto.subtle;var e=require("crypto").webcrypto;return globalThis.crypto=e,e.subtle}(),[4,n.importKey("raw",X.encode(e),{name:"HMAC",hash:"SHA-256"},!1,["sign"])];case 1:return r=o.sent(),i=Uint8Array.bind,[4,n.sign("HMAC",r,X.encode(t))];case 2:return[2,Z(new(i.apply(Uint8Array,[void 0,o.sent()])))]}})})}function nt(t,e,n){return i(this,void 0,void 0,function(){var r,i,s;return o(this,function(o){switch(o.label){case 0:return[4,et(t,e)];case 1:if((r=o.sent()).length!==n.length)return[2,!1];for(i=0,s=0;s<r.length;s++)i|=r.charCodeAt(s)^n.charCodeAt(s);return[2,0===i]}})})}function rt(t){var e=this;if(!t)throw new V("IDENTITY","createSignedIdentity: secret is required",{context:{hint:"set config.identity_secret to enable signed identity"}});return{sign:function(e){return tt(e,t)},signAsync:function(e){return et(e,t)},verify:function(e,n){return tt(e,t)===n},verifyAsync:function(e,n){return nt(e,t,n)},encode:function(e){return"".concat(e,"|").concat(tt(e,t))},decode:function(e){var n=e.lastIndexOf("|");if(n<=0)return null;var r=e.slice(0,n),i=e.slice(n+1);return tt(r,t)!==i?null:r},encodeAsync:function(n){return i(e,void 0,void 0,function(){var e,r;return o(this,function(i){switch(i.label){case 0:return r=(e="".concat(n,"|")).concat,[4,et(n,t)];case 1:return[2,r.apply(e,[i.sent()])]}})})},decodeAsync:function(n){return i(e,void 0,void 0,function(){var e,r,i;return o(this,function(o){switch(o.label){case 0:return(e=n.lastIndexOf("|"))<=0?[2,null]:(r=n.slice(0,e),i=n.slice(e+1),[4,nt(r,t,i)]);case 1:return o.sent()?[2,r]:[2,null]}})})}}}var it=function(){function t(t,e,n,r,i,o,s){this.config=t,this.registry=e,this.identity=n,this.presetProps=r,this.retryPolicy=i,this.failedQueue=o,this.logger=s,this.pending=[],this.senders=[],this.abortControllers=new Map}return t.prototype.setSenders=function(t){this.senders=t},t.prototype.setBatchSender=function(t){this.batchSender=t},t.prototype.buildEvent=function(t,e){var n,r;void 0===e&&(e={});var i=(null===(r=(n=this.config).get_client_timestamp)||void 0===r?void 0:r.call(n))||Date.now(),o=this.presetProps.build(this.config,e.properties||{}),s={type:t,time:i,distinct_id:this.identity.getDistinctId(),anonymous_id:this.identity.getAnonymousId(),first_id:this.identity.getFirstId(),login_id:this.identity.getLoginId()||void 0,original_id:this.identity.getOriginalId()||void 0,properties:o,lib:{$lib:this.config.lib_name||m,$lib_version:this.config.lib_version||b},token:this.config.app_id,project:this.config.app_id};return e.event&&(s.event=e.event),s},t.prototype.send=function(t,e){var n=this;if(this.config.disabled)null==e||e(null);else{this.registry.invoke("sdkInitAPI",t);var r=this.config.encryptEvent;if(r)try{var i=r(t);i&&"object"==typeof i&&(t=i)}catch(t){this.logger.error("encryptEvent hook failed:",t)}if(this.config.encryptor)try{var o=this.config.encryptor(JSON.stringify(t));"string"==typeof o?(t._encrypted=o,this.dispatchAfterEncrypt(t,e)):o.then(function(r){t._encrypted=r,n.dispatchAfterEncrypt(t,e)},function(r){n.logger.error(new J("async encryptor failed",{cause:r})),n.dispatchAfterEncrypt(t,e)})}catch(n){this.logger.error(new J("encryptor threw",{cause:n})),this.dispatchAfterEncrypt(t,e)}else this.dispatchAfterEncrypt(t,e)}},t.prototype.dispatchAfterEncrypt=function(t,e){var n=this;if(t.properties=this.registry.stages.sendDataStage.run(t.properties,this),"batch"===this.config.send_type&&this.batchSender){var r=Promise.resolve(this.batchSender.send(t,{config:this.config,logger:this.logger})).then(function(){return null==e?void 0:e(null)}).catch(function(t){return null==e?void 0:e(t)});this.trackPending(r)}else{var i=this.pickSender(),o=this.retryPolicy.execute(function(){return Promise.resolve(i.send(t,{config:n.config,logger:n.logger}))},function(){return!0},function(e){n.failedQueue.enqueue(t),n.logger.warn("event send failed, queued:",e.message)}).then(function(t){null==e||e(t.ok?null:t.finalErr)});this.trackPending(o)}},t.prototype.pickSender=function(){var t=this.config.send_type;if(t&&"batch"!==t){var e=this.senders.find(function(e){return e.name===t&&e.canUse()});if(e)return e}return this.senders.find(function(t){return"beacon"===t.name&&t.canUse()})||this.senders.find(function(t){return"ajax"===t.name&&t.canUse()})||this.senders.find(function(t){return"image"===t.name&&t.canUse()})||this.senders[0]},t.prototype.trackPending=function(t){var e={promise:t,resolve:function(){},reject:function(){}};new Promise(function(t,n){e.resolve=t,e.reject=n}),t.then(function(){return e.resolve()},function(t){return e.reject(t)}),this.pending.push(e)},t.prototype.flush=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(e){switch(e.label){case 0:if(!this.batchSender)return[3,4];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,this.batchSender.flush({config:this.config,logger:this.logger})];case 2:return e.sent(),[3,4];case 3:return t=e.sent(),this.logger.warn("batch flush failed:",t),[3,4];case 4:return[4,this.waitUntilIdle()];case 5:return e.sent(),[2]}})})},t.prototype.waitUntilIdle=function(){return i(this,void 0,void 0,function(){var t;return o(this,function(e){switch(e.label){case 0:return this.pending.length?(t=this.pending.splice(0),[4,Promise.allSettled(t.map(function(t){return t.promise}))]):[3,2];case 1:return e.sent(),[3,0];case 2:return[2]}})})},t.prototype.abortAll=function(t){for(var e=0,n=this.abortControllers;e<n.length;e++){n[e][1].abort(t)}this.abortControllers.clear(),this.pending=[]},t.prototype.takeAbortController=function(t){var e=new AbortController;return this.abortControllers.set(t,e),e},t.prototype.releaseAbortController=function(t){this.abortControllers.delete(t)},t}(),ot={send_type:"image",max_retry_count:3,debug:0,storage_type:"memory",is_collect_utm:!0,send_timeout:5e3,max_retry_duration:3e4},st=function(){function t(){this.lib_name=m,this.lib_version=b,this.DEFAULT_SEND_TYPE="image",this._senders=[],this._inited=!1,this.__noop=function(){},this.instanceId="".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,8))}return t.prototype.init=function(t){var e;if(this._inited)null===(e=this._logger)||void 0===e||e.warn("EventTracker already initialized, re-init ignored");else{if(this._config=r(r({},ot),t),this._config.lib_name=this._config.lib_name||m,this._config.lib_version=this._config.lib_version||b,!this._config.server_url)throw new q("server_url is required");if(!this._config.app_id)throw new q("app_id is required");var n,i;this._logger=new d({debug:this._config.debug,show_log:this._config.show_log}),this._store=A({cookieDomain:this._config.cookie_domain,cookieCrossSubdomain:this._config.cookie_cross_subdomain,secureCookie:this._config.secure_cookie}),this._config.identity_secret&&(this._signedIdentity=rt(this._config.identity_secret)),this._identity=new y(this._store,{getDistinctId:this._config.get_distinct_id,setDistinctId:this._config.set_distinct_id,getAnonymousId:this._config.get_anonymous_id,setAnonymousId:this._config.set_anonymous_id,getFirstId:this._config.get_first_id,setFirstId:this._config.set_first_id}),this._presetProps=new w,this._config.preset_properties&&this._presetProps.setPreset(this._config.preset_properties),this._registry=new N,this._channel=new B,this._retryPolicy=new W(this._config,this._logger),this._failedQueue=new H({max:200,encryptor:this._config.encryptor}),this._senders=[new x,new L,new C],this._batchSender=new U,this._pipeline=new it(this._config,this._registry,this._identity,this._presetProps,this._retryPolicy,this._failedQueue,this._logger),this._pipeline.setSenders(this._senders),this._pipeline.setBatchSender(this._batchSender),"batch"===this._config.send_type&&this._batchSender.start({config:this._config,logger:this._logger}),n=this,i=this._presetProps,n._registerAttached||(n._registerAttached=!0,n.register=function(t){return i.register(t),this},n.registerOnce=function(t){return i.registerOnce(t),this},n.clearAllRegister=function(){return i.clearRegister(),this},n.unsetRegister=function(t){return i.unsetRegister(t),this},n.registerPage=function(t){return i.registerOnce(t),this},n.registerSession=function(t){return i.register(t),this},n.registerSessionOnce=function(t){return i.registerOnce(t),this}),function(t,e){t._identityAttached||(t._identityAttached=!0,t.identify=function(n,r){return void 0===r&&(r=!0),e.identify(n,r),t.getRegistry().invoke("changeDistinctId",n),this},t.login=function(n){return e.login(n),t.getRegistry().invoke("changeDistinctId",n),this},t.logout=function(n){return e.resetAnonymousIdentity(n),t.getRegistry().invoke("changeDistinctId",e.getDistinctId()),this},t.resetAnonymousIdentity=t.logout,t.alias=function(n,r){(r||e.getDistinctId())!==n&&(e.identify(n,!0),t.track("$SignUp",{$signup_method:"alias"}),t.getRegistry().invoke("changeDistinctId",n))},t.getDistinctId=function(){return e.getDistinctId()},t.getAnonymousId=function(){return e.getAnonymousId()},t.getFirstId=function(){return e.getFirstId()},t.getLoginId=function(){return e.getLoginId()},t.getOriginalId=function(){return e.getOriginalId()})}(this,this._identity),function(t,e){if(!t._profileAttached){t._profileAttached=!0;var n=function(t,n,r){var i=e.buildEvent(t,{properties:n});e.send(i,r)};t.setProfile=function(t,e){return n("profile_set",t,e)},t.setOnceProfile=function(t,e){return n("profile_set_once",t,e)},t.incrementProfile=function(t,e){return n("profile_increment",t,e)},t.appendProfile=function(t,e){return n("profile_append",t,e)},t.unsetProfile=function(t,e){var r;return n("profile_unset",((r={})[t]=!0,r),e)},t.deleteProfile=function(t){return n("profile_delete",{},t)}}}(this,this._pipeline),function(t,e){t._trackAttached||(t._trackAttached=!0,t.track=function(t,n,r){void 0===n&&(n={});var i=e.buildEvent("track",{event:t,properties:n});e.send(i,r)},t.trackSignup=function(n,i,o){void 0===i&&(i={});var s=e.buildEvent("track_signup",{event:"$SignUp",properties:r(r({},i),{$signup_method:i.$signup_method||""})});s.original_id=t.getOriginalId(),t.identify(n,!0),s.distinct_id=n,s.login_id=n,e.send(s,o)},t.trackLinkage=function(e,n){t.track("$Linkage",e,n)},t.trackLink=function(e,n,i){if(void 0===n&&(n={}),a()){var o="string"==typeof e?document.querySelector(e):e;o&&o.addEventListener("click",function(){t.track("$WebClick",r(r({},n),{$element_selector:o.id?"#".concat(o.id):o.tagName.toLowerCase(),$element_target_url:o instanceof HTMLAnchorElement?o.href:void 0}),i)},{once:!0})}},t.trackLinks=function(e,n,r){if(void 0===n&&(n={}),a())for(var i=0,o=("string"==typeof e?Array.from(document.querySelectorAll(e)):e&&"length"in e&&!("click"in e)?Array.from(e):e);i<o.length;i++){var s=o[i];t.trackLink(s,n,r)}},t.trackHeatMap=function(e,n){return t.track("$heatmap_event",e,n)},t.trackWebClick=function(e,n){return t.track("$WebClick",e,n)},t.trackWebStay=function(e,n){return t.track("$WebStay",e,n)})}(this,this._pipeline),this._registry.invoke("sdkReady",this._config),this._registry.invoke("sdkInitPara",this._config),this._inited=!0,this._logger.log("EventTracker initialized:",{app_id:this._config.app_id,send_type:this._config.send_type}),this._registry.invoke("sdkAfterInitPara",this._config),this._registry.invoke("sdkInitAPI",this),this._registry.invoke("sdkAfterInitAPI",this)}},t.prototype.use=function(t){var e=this;if(!this._inited)return setTimeout(function(){return e.use(t)},0),this;var n={config:this._config,registry:this._registry,stages:this._registry.stages,sdk:this,kit:{},channel:this._channel,store:this._store,uninstall:function(){return e._registry.uninstall(t,n)}};return this._registry.install(t,n),this},t.prototype.track=function(t,e,n){},t.prototype.trackSignup=function(t,e,n){},t.prototype.trackLinkage=function(t,e){},t.prototype.trackLink=function(t,e,n){},t.prototype.trackLinks=function(t,e,n){},t.prototype.trackHeatMap=function(t,e){},t.prototype.trackWebClick=function(t,e){},t.prototype.trackWebStay=function(t,e){},t.prototype.identify=function(t,e){return this},t.prototype.login=function(t){return this},t.prototype.logout=function(t){return this},t.prototype.resetAnonymousIdentity=function(t){return this},t.prototype.alias=function(t,e){},t.prototype.getDistinctId=function(){return""},t.prototype.getAnonymousId=function(){return""},t.prototype.getFirstId=function(){return""},t.prototype.getLoginId=function(){return""},t.prototype.getOriginalId=function(){return""},t.prototype.register=function(t){return this},t.prototype.registerOnce=function(t){return this},t.prototype.clearAllRegister=function(){return this},t.prototype.unsetRegister=function(t){return this},t.prototype.registerPage=function(t){return this},t.prototype.registerSession=function(t){return this},t.prototype.registerSessionOnce=function(t){return this},t.prototype.setProfile=function(t,e){},t.prototype.setOnceProfile=function(t,e){},t.prototype.incrementProfile=function(t,e){},t.prototype.appendProfile=function(t,e){},t.prototype.unsetProfile=function(t,e){},t.prototype.deleteProfile=function(t){},t.prototype.disable=function(){return this._config.disabled=!0,this._logger.warn("EventTracker disabled"),this},t.prototype.enable=function(){return this._config.disabled=!1,this},t.prototype.setServerURL=function(t){return this.switchServer(t)},t.prototype.switchServer=function(t){return t?(this._config.server_url=t,this._registry.invoke("switch",t),this):this},t.prototype.flush=function(){return i(this,void 0,void 0,function(){return o(this,function(t){switch(t.label){case 0:return this._inited?[4,this._pipeline.flush()]:[2];case 1:return t.sent(),[2]}})})},t.prototype.waitUntilIdle=function(){return i(this,void 0,void 0,function(){return o(this,function(t){switch(t.label){case 0:return this._inited?[4,this._pipeline.waitUntilIdle()]:[2];case 1:return t.sent(),[2]}})})},t.prototype.abort=function(t){this._pipeline.abortAll(t)},t.prototype.close=function(){var t,e;null===(t=this._batchSender)||void 0===t||t.stop(),null===(e=this._channel)||void 0===e||e.close(),this.abort("closed")},t.prototype.uuid=function(){return l()},t.prototype.getPresetProperties=function(){return this._presetProps.build(this._config,{})},t.prototype.shutdown=function(){this.close()},t.prototype.getConfig=function(){return r({},this._config)},t.prototype.getLogger=function(){return this._logger},t.prototype.getRegistry=function(){return this._registry},t.prototype.getRetryPolicy=function(){return this._retryPolicy},t.prototype.getFailedQueue=function(){return this._failedQueue},t.prototype.getChannel=function(){return this._channel},t.prototype.getPipeline=function(){return this._pipeline},t.prototype.getSignedIdentity=function(){return this._signedIdentity},t.prototype.isBrowser=function(){return a()},t.prototype.isInitialized=function(){return this._inited},t}(),at=new Map;"undefined"!=typeof window&&(window.eventTracker=new st);var ct="et_session_id",ut="et_session_last_active";function lt(t){return function(e){return function(t,e){for(var n=e||"default",r="",i=0;i<t.length;i++)r+=String.fromCharCode(t.charCodeAt(i)^n.charCodeAt(i%n.length));return"undefined"!=typeof btoa?btoa(r):Buffer.from(r,"binary").toString("base64")}(e,t)}}function dt(t){return function(e){for(var n="undefined"!=typeof atob?atob(e):Buffer.from(e,"base64").toString("binary"),r="",i=t||"default",o=0;o<n.length;o++)r+=String.fromCharCode(n.charCodeAt(o)^i.charCodeAt(o%i.length));return r}}var ft=new TextEncoder,pt=new TextDecoder;function ht(t){if("undefined"!=typeof btoa){for(var e="",n=0;n<t.length;n++)e+=String.fromCharCode(t[n]);return btoa(e)}return Buffer.from(t).toString("base64")}function gt(t){return i(this,void 0,void 0,function(){var e,n;return o(this,function(r){switch(r.label){case 0:return[4,(e=yt()).digest("SHA-256",ft.encode(t))];case 1:return n=r.sent(),[2,e.importKey("raw",n,{name:"AES-GCM"},!1,["encrypt","decrypt"])]}})})}function yt(){var t;if("undefined"!=typeof globalThis&&(null===(t=globalThis.crypto)||void 0===t?void 0:t.subtle))return globalThis.crypto.subtle;try{var e=require("crypto").webcrypto;return globalThis.crypto=e,e.subtle}catch(t){throw new Error("[encrypt] Web Crypto API not available (need https/localhost or Node 18+)")}}function vt(t){return{name:"encryptor",install:function(e){var n=e.sdk,r=e.config;r.encryptor=t.encrypt,r.decoder=t.decrypt;var i=r;i.encryptEvent=t.encryptEvent,i.decryptEvent=t.decryptEvent;var o=n;o.__encryptor=t.encrypt,o.__decoder=t.decrypt,o.__encryptEvent=t.encryptEvent,o.__decryptEvent=t.decryptEvent},uninstall:function(t){if(t){var e=t.config,n=t.sdk;delete e.encryptor,delete e.decoder;var r=e;delete r.encryptEvent,delete r.decryptEvent;var i=n;delete i.__encryptor,delete i.__decoder,delete i.__encryptEvent,delete i.__decryptEvent}}}}var _t=new st;"undefined"!=typeof window&&(window.eventTracker=_t),t.ConfigError=Q,t.EncryptError=J,t.EventTracker=st,t.FailedQueue=H,t.IdentityError=K,t.IdentityManager=y,t.InitError=q,t.InstanceChannel=B,t.LIB_NAME=m,t.LIB_VERSION=b,t.Logger=d,t.PluginError=Y,t.PluginRegistry=N,t.PresetEvent=v,t.PresetProperty=_,t.PresetPropertyBuilder=w,t.RetryPolicy=W,t.SDKError=V,t.SendError=z,t.SendPipeline=it,t.StorageError=G,t.aesGcmDecryptAsync=function(t){var e=this,n=null;return function(r){return i(e,void 0,void 0,function(){var e,i,s,a,c,u;return o(this,function(o){switch(o.label){case 0:return n||(n=gt(t)),[4,n];case 1:return e=o.sent(),i=yt(),s=function(t){if("undefined"!=typeof atob){for(var e=atob(t),n=new Uint8Array(e.length),r=0;r<e.length;r++)n[r]=e.charCodeAt(r);return n}return new Uint8Array(Buffer.from(t,"base64"))}(r),a=s.slice(0,12),c=s.slice(12),[4,i.decrypt({name:"AES-GCM",iv:a},e,c)];case 2:return u=o.sent(),[2,pt.decode(u)]}})})}},t.aesGcmEncryptAsync=function(t){var e=this,n=null;return function(r){return i(e,void 0,void 0,function(){var e,i,s,a,c,u;return o(this,function(o){switch(o.label){case 0:return n||(n=gt(t)),[4,n];case 1:return e=o.sent(),i=yt(),s=globalThis.crypto.getRandomValues(new Uint8Array(12)),c=Uint8Array.bind,[4,i.encrypt({name:"AES-GCM",iv:s},e,ft.encode(r))];case 2:return a=new(c.apply(Uint8Array,[void 0,o.sent()])),(u=new Uint8Array(s.length+a.length)).set(s,0),u.set(a,s.length),[2,ht(u)]}})})}},t.autoTrack=function(t){var e;void 0===t&&(t={});var n=null,r=Date.now(),i=new Set,o=null!==(e=t.scrollThresholds)&&void 0!==e?e:[25,50,75,100];function s(t,e){void 0===e&&(e={}),n&&n.track(t,e)}function c(){try{return location.pathname+location.search+location.hash}catch(t){return""}}function u(t,e){document.addEventListener("click",function(n){var r,i=n.target;if(i){var o=i.closest(t||"a, button, [data-track-click]");if(o){var a=((r={})[_.ElementSelector]=function(t){if(t.id)return"#".concat(t.id);var e=[],n=t,r=function(){var t=n,r=t.tagName.toLowerCase();t.classList&&t.classList.length&&(r+="."+Array.from(t.classList).slice(0,2).join("."));var i=t.parentElement;if(i){var o=Array.from(i.children).filter(function(e){return e instanceof Element&&e.tagName===t.tagName});o.length>1&&(r+=":nth-of-type(".concat(o.indexOf(t)+1,")"))}e.unshift(r),n=i};for(;n&&n!==document.body&&e.length<5;)r();return e.join(" > ")}(o),r[_.ElementType]=o.tagName.toLowerCase(),r[_.ElementContent]=(o.textContent||"").trim().slice(0,100),r[_.ElementId]=o.id||void 0,r[_.ElementClassName]=o.className||void 0,r);o instanceof HTMLAnchorElement&&(a.$element_href=o.href);for(var c=0,u=e;c<u.length;c++){var l=u[c],d=o.getAttribute(l);null!=d&&(a[l]=d)}s(v.WebClick,a)}}},!0)}function l(){var t=function(){var t,e=Date.now()-r;s(v.WebStay,((t={})[_.EventDuration]=e,t[_.URLPath]=c(),t))};window.addEventListener("beforeunload",t),document.addEventListener("visibilitychange",function(){"hidden"===document.visibilityState?t():r=Date.now()})}return{name:"auto-track",install:function(e){var r=e.sdk;a()&&(n=r,!1!==t.pageview&&function(){var t=function(){var t;s(v.PageView,((t={})[_.URLPath]=c(),t[_.Title]=document.title,t[_.Referrer]=document.referrer,t))};setTimeout(t,0);var e=function(e){var n=history[e];history[e]=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];var i=n.apply(this,e);return setTimeout(t,0),i}};e("pushState"),e("replaceState"),window.addEventListener("popstate",function(){return setTimeout(t,0)}),window.addEventListener("hashchange",function(){return setTimeout(t,0)})}(),!1!==t.webclick&&u(t.webclickSelector,t.webclickAttrs||["data-track-id","data-sensors-click"]),!1!==t.webstay&&l(),t.scrolldepth&&(i=new Set,window.addEventListener("scroll",function(){var t,e=document.documentElement.scrollHeight-window.innerHeight;if(!(e<=0))for(var n=Math.min(100,Math.round(window.scrollY/e*100)),r=0,a=o;r<a.length;r++){var u=a[r];n>=u&&!i.has(u)&&(i.add(u),s("$scroll_depth",((t={percent:u})[_.URLPath]=c(),t)))}},{passive:!0})))}}},t.createSignedIdentity=rt,t.debugSender=function(t){return void 0===t&&(t={}),{name:"debug-sender",install:function(e){var n,r,i,o,s,a=e.config,c=e.stages,l=e.registry,d=e.sdk;if(null!==(n=t.enable)&&void 0!==n?n:!!a.debug_mode){var f,p,h=null!==(i=null!==(r=t.url)&&void 0!==r?r:a.debug_mode_url)&&void 0!==i?i:(f=a.server_url,(p=Array.isArray(f)?f[0]:f).includes("?")?p+"&debug":p+"?debug"),g=null!==(s=null!==(o=t.upload)&&void 0!==o?o:a.debug_mode_upload)&&void 0!==s?s:"true";c.sendDataStage.register({name:"debug-sender",priority:30,entry:function(e){var n=e.data;try{var r=$(n,a.encryptor);Promise.resolve(r).then(function(r){var i=T(h,r);if(u()){var o=new Image(1,1);o.onload=function(){var e;try{null===(e=t.onSuccess)||void 0===e||e.call(t,n)}catch(t){}try{"undefined"!=typeof alert&&alert("debug数据发送成功"+(n.event||""))}catch(t){}},o.onerror=function(){var e,r=new Error("Image load failed");try{null===(e=t.onError)||void 0===e||e.call(t,r,n)}catch(t){}try{"undefined"!=typeof alert&&alert("debug失败 错误原因"+JSON.stringify({message:r.message}))}catch(t){}},o.src=i}else e.cancellationToken.stop()}).catch(function(t){d.getLogger().error("debug-sender error:",t)})}catch(t){d.getLogger().error("debug-sender error:",t)}return n}}),l.on("sdkAfterInitAPI",function(){Object.defineProperty(globalThis,"__et_debug_upload__",{value:g,writable:!0})})}},uninstall:function(){try{delete globalThis.__et_debug_upload__}catch(t){}}}},t.default=_t,t.defaultDecryptor=dt,t.defaultEncryptor=lt,t.encryptor=vt,t.exposure=function(t){void 0===t&&(t={});var e=null,n=null,r=new WeakSet;function i(){var i,o;if("IntersectionObserver"in window){var s=null!==(i=t.threshold)&&void 0!==i?i:.5,a=null!==(o=t.duration)&&void 0!==o?o:500;if(n=new IntersectionObserver(function(n){for(var i=function(n){if(n.intersectionRatio>=s){var i=n.target,o=setTimeout(function(){var o;if(!r.has(i)&&(r.add(i),e)){var s=((o={})[_.ElementSelector]=function(t){if(t.id)return"#".concat(t.id);for(var e=[],n=t;n&&n!==document.body&&e.length<5;){var r=n.tagName.toLowerCase();n.classList&&n.classList.length&&(r+="."+Array.from(n.classList).slice(0,2).join(".")),e.unshift(r),n=n.parentElement}return e.join(" > ")}(i),o[_.ElementType]=i.tagName.toLowerCase(),o.$intersection_ratio=n.intersectionRatio,o.$exposure_duration=a,o);if(i instanceof HTMLElement&&i.dataset)for(var c=t.attrPrefix||"data-exp-",u=0,l=Object.keys(i.dataset);u<l.length;u++){var d=l[u];d.startsWith(c)&&(s[d]=i.dataset[d])}e.track(v.ElementExposure,s)}},a),c=function(){clearTimeout(o),i.removeEventListener("mouseleave",c)};i.addEventListener("mouseleave",c)}},o=0,c=n;o<c.length;o++){i(c[o])}},{threshold:[s]}),t.selector)document.querySelectorAll(t.selector).forEach(function(t){return n.observe(t)})}}return{name:"exposure",install:function(t){var n=t.sdk;a()&&(e=n,"complete"===document.readyState?i():window.addEventListener("load",i,{once:!0}))},uninstall:function(){null==n||n.disconnect(),n=null,e=null}}},t.hmacSignAsync=et,t.hmacVerifyAsync=nt,t.indexedDBSender=function(t){void 0===t&&(t={});var e=t.dbName||"event-tracker-outbox",n=t.storeName||"outbox",r=t.max||500,i=null,o={name:"indexeddb-sender",priority:60,entry:function(t){if("sendDataStage"===t.meta.stage){var o=t.data;return null!=i||(i=a()&&"undefined"!=typeof indexedDB?new Promise(function(t){try{var r=indexedDB.open(e,1);r.onupgradeneeded=function(){var t=r.result;t.objectStoreNames.contains(n)||t.createObjectStore(n,{autoIncrement:!0})},r.onsuccess=function(){return t(r.result)},r.onerror=function(){return t(null)}}catch(e){t(null)}}):Promise.resolve(null)),i.then(function(t){if(t)try{var e=t.transaction(n,"readwrite").objectStore(n),i=$(o),s=e.count();s.onsuccess=function(){s.result>=r&&e.delete(IDBKeyRange.lowerBound(0,!0)),e.add({time:Date.now(),payload:i})}}catch(t){}}).catch(function(){}),o}}};return{name:"indexeddb-sender",install:function(t){var e=t.stages;a()&&e.sendDataStage.register(o)},uninstall:function(){i=null}}},t.initPara=function(t){var e=t.client_id||"instance-".concat(at.size+1),n=at.get(e);return n?(n.switchServer(t.server_url),t.app_id&&(n.getConfig().app_id=t.app_id),n):((n=new st).init(t),at.set(e,n),n)},t.isSDKError=function(t){return t instanceof V},t.listInstances=function(){return Array.from(at.values())},t.pageLeave=function(t){var e=null,n=Date.now();function r(t){var r;if(e){var i=Date.now()-n;e.track(v.WebPageLeave,((r={})[_.EventDuration]=i,r[_.URLPath]=location.pathname+location.search+location.hash,r[_.Title]=document.title,r[_.ViewportPosition]=window.scrollY||0,r.$page_leave_reason=t,r))}}return{name:"pageleave",install:function(t){var i=t.sdk;if(a()){e=i,n=Date.now();document.addEventListener("visibilitychange",function(){"visible"===document.visibilityState&&(n=Date.now())}),window.addEventListener("pagehide",function(){return r("pagehide")}),window.addEventListener("beforeunload",function(){return r("unload")}),document.addEventListener("visibilitychange",function(){"hidden"===document.visibilityState&&r("hidden")})}},uninstall:function(){e=null}}},t.pageLoad=function(t){void 0===t&&(t={});var e=null;function n(){var t;if(e){var n=((t={})[_.URLPath]=location.pathname+location.search+location.hash,t[_.Title]=document.title,t);try{var r="undefined"!=typeof performance?performance:null;if(r){var i=r.getEntriesByType("navigation")[0];i&&("number"==typeof i.domContentLoadedEventEnd&&(n.$dom_ready_time=Math.round(i.domContentLoadedEventEnd-i.startTime)),"number"==typeof i.domInteractive&&(n.$dom_interactive_time=Math.round(i.domInteractive-i.startTime)),"number"==typeof i.loadEventEnd&&"number"==typeof i.startTime&&(n.$load_time=Math.round(i.loadEventEnd-i.startTime)),"number"==typeof i.responseEnd&&"number"==typeof i.requestStart&&(n.$response_time=Math.round(i.responseEnd-i.requestStart)),"number"==typeof i.transferSize&&(n[_.PageResourceSize]=i.transferSize));var o=r.getEntriesByName("first-paint")[0],s=r.getEntriesByName("first-contentful-paint")[0];o&&(n.$first_paint=Math.round(o.startTime)),s&&(n.$first_contentful_paint=Math.round(s.startTime))}}catch(t){}try{document.documentElement&&(n[_.PageHeight]=document.documentElement.scrollHeight,n[_.ViewportPosition]=window.scrollY||0)}catch(t){}e.track(v.WebPageLoad,n)}}return{name:"pageload",install:function(r){var i=r.sdk;if(a()){e=i;var o=!1!==t.immediate;"complete"===document.readyState?o?n():window.addEventListener("load",n,{once:!0}):window.addEventListener("load",function(){o?n():setTimeout(n,0)},{once:!0})}}}},t.registerAppid=function(t){return at.get(t)},t.sessionEvent=function(t){var e;void 0===t&&(t={});var n=null!==(e=t.timeout)&&void 0!==e?e:18e5,r=null,i=null,o="",s=0;function c(t){o=l(),s=Date.now(),i&&(i.set(ct,o),i.set(ut,String(s))),r&&"start"===t&&r.track("$session_start",{$event_session_id:o})}var u={name:"session-event",priority:10,entry:function(t){if("buildDataStage"===t.meta.stage){var e;e=Date.now(),(!o||s&&e-s>n)&&c(e-s>n?"timeout":"start"),s=e,i&&i.set(ut,String(s));var r=t.data;r&&r.properties&&(r.properties[_.EventSessionId]=o)}}};return{name:"session-event",install:function(t){var e=t.sdk,l=t.stages,d=t.store;if(a()){r=e,i=d;var f=d.get(ct),p=Number(d.get(ut)||"0");f&&p&&Date.now()-p<n?(o=f,s=p):c("start"),l.buildDataStage.register(u),window.addEventListener("storage",function(t){t.key!==ct||t.newValue||(o="")})}},uninstall:function(){r=null,i=null}}},t.tracker=_t,t.webviewBridge=function(t){return void 0===t&&(t={}),{name:"webview-bridge",install:function(e){var n=e.sdk,r=e.config;if(a()){var i=window[t.defineName||"vapph5define"];if(i&&"function"==typeof i.call){var o={call:function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return i.call.apply(i,s([t],e,!1))},on:function(t,e){return i.handle(t,e)},isInApp:function(){return!0===i.isInApp||!0===i.call("isInApp")}};if(n.bridge=o,r.is_webview=!0,!1!==t.fetchOnInit)try{var c=t.protocolName||"getAppInfo",u=i.call(c);if(u&&"object"==typeof u){for(var l=t.fieldMap||{},d=0,f=Object.entries(l);d<f.length;d++){var p=f[d],h=p[0],g=u[p[1]];null!=g&&(r[h]=g)}n.register({$app_version:u.app_version||u.appVersion,$app_id:u.app_id||u.appId,$channel:u.channel,$lib:u.lib||u.lib_name||u.libName})}}catch(t){}}}}}},t.xorEncryptor=function(t){return vt({encrypt:lt(t),decrypt:dt(t)})},Object.defineProperty(t,"__esModule",{value:!0})});
|