@aem-sdk/tracker 0.1.0-beta.2 → 0.1.0-beta.3
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/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});function e(e){let n=[],r={parent:e,tokens:n,get firstToken(){return n.length===0?null:n[0]},getNewToken(i){let a=t();return n.push(a),a.previousToken=i===void 0?n.length>1?n[n.length-2]:null:i,e&&(e.properties=r),a},getLastToken(){return n.length===0?null:n[n.length-1]},getFirstToken(){return n.length===0?null:n[0]},isEmpty(){return n.length===0}};return r}function t(){let e=[],t=[],n=[],r=null,i=null,a=null,o=!0,s=!0,c=!0,l=null,u={get key(){return o&&(r=e.join(``),o=!1),r},get value(){return s&&(i=t.join(``),s=!1),i},get originValue(){return c&&(a=n.join(``),c=!1),a},previousToken:null,properties:null,appendKey(t){e.push(t),o=!0},appendValue(e){t.push(e===`_`?`.`:e),n.push(e),s=!0,c=!0,l=null},getSplitValue(e){if(l===null){let e=u.value;l=e===``?[]:e.split(`/`)}return e>=0&&e<l.length?l[e]:null},getPreviousNTokens(e){let t=[],n=u;for(let r=0;r<e;r++){if(n==null)return null;t.unshift(n.key),n=n.previousToken}return t.join(` `)}};return u}function n(){return{appName:null,appVersion:null,browserName:null,browserVersion:null,engineName:null,engineVersion:null,deviceBrand:null,deviceModel:null,deviceType:`mobile`,osName:null,osVersion:null,platform:`web`,tokenGroup:e(null)}}const r=new Set(` ;,"'`.split(``)),i=new Set(`/=:`.split(``)),a=new Set([`Mozilla`,`AppleWebKit`,`Safari`,`Opera`,`Dalvik`,`com.ss.android.ugc.aweme`]);function o(e){return e.length===1&&r.has(e)}function s(e){return e.length===1&&i.has(e)}function c(e,t,n,r){if(e==null)return;let i=t.parent,o=e.key,s=null;if(i!=null){let e=i.key;if(a.has(e)){var c;s=(c=r.commentHandlerMap.get(o))==null?null:c,s==null&&(s=r.getSpecialCommentHandler(o)),s==null&&o.endsWith(` Build`)&&(s=r.getDefaultModelHandler())}else{var l;s=(l=r.productHandlerMap.get(o))==null?r.getSpecialProductHandler(o):l}}else{var u;s=(u=r.productHandlerMap.get(o))==null?r.getSpecialProductHandler(o):u}if(s!=null)try{s(e,n)}catch(e){}}function l(t,n,r,i,a){let u=null,d=null,f,p=!1,m=t.length,h=n>0?t[n-1]:`\0`;for(f=n;f<m;f++){let g=t[f];if(o(g)){let e=h!==`\0`&&o(h);if(!p&&n>0&&g===` `&&!e){let e=f+1;if(e<m){let n=t[e];/\d/.test(n)||n===`-`?p=!0:d!=null&&d.appendKey(g)}else d!=null&&d.appendKey(g)}else d!=null&&(u=d,d=null);h=g}else if(g===`(`){if(h===`(`){h=g;continue}let n=e(r.getLastToken()),o=f;f=l(t,f+1,n,i,a),d!=null&&(u=d,d=null),h=t[o]}else if(g===`)`){if(n===0){h=g;continue}break}else d==null&&(c(r.getLastToken(),r,i,a),d=r.getNewToken(u),p=!1),s(g)?(p&&d.appendValue(g),p=!0):p?d.appendValue(g):d.appendKey(g),h=g}return c(r.getLastToken(),r,i,a),f}function u(e,t,n){if(e==null)throw Error(`input can not be null`);return l(e,0,t.tokenGroup,t,n),t}const d=(e,t)=>{t.appName=`BaiduSpider`,t.appVersion=e.value,t.deviceBrand=`Baidu`,t.deviceType=`bot`,t.platform=`other`},f=(e,t)=>{t.appName=`360 Spider`,t.appVersion=e.value,t.deviceBrand=`360`,t.deviceType=`bot`,t.platform=`other`},p=(e,t)=>{t.appName=`BingBot`,t.appVersion=e.value,t.deviceBrand=`Microsoft`,t.deviceType=`bot`,t.platform=`other`},m=(e,t)=>{t.appName=`Googlebot`,t.appVersion=e.value,t.deviceBrand=`Google`,t.deviceType=`bot`,t.platform=`other`},h=(e,t)=>{t.appName=`YandexBot`,t.appVersion=e.value,t.deviceBrand=`Yandex`,t.deviceType=`bot`,t.platform=`other`},g=(e,t)=>{e.getPreviousNTokens(3)===`Sogou web spider`&&(t.deviceBrand=`Sogou.com`,t.appName=`SogouSpider`),t.appVersion=e.value,t.deviceType=`bot`},ee=(e,t)=>{t.appName=`DataproviderBot`,t.appVersion=e.value,t.deviceBrand=`Dataprovider.com`,t.deviceType=`bot`,t.platform=`other`},te=(e,t)=>{t.appName=`AhrefsBot`,t.appVersion=e.value,t.deviceBrand=`Ahrefs`,t.deviceType=`bot`,t.platform=`other`},ne=(e,t)=>{t.appName=`BitSightBot`,t.appVersion=e.value,t.deviceBrand=`Bitsight`,t.deviceType=`bot`,t.platform=`other`},re=(e,t)=>{t.appName=`oBot`,t.appVersion=e.value,t.deviceBrand=`IBM`,t.deviceType=`bot`,t.platform=`other`},ie=(e,t)=>{t.appName=`Cincraw`,t.appVersion=e.value,t.deviceBrand=`CINC`,t.deviceType=`bot`,t.platform=`other`},ae=(e,t)=>{t.appName=`DingTalkBot`,t.appVersion=e.value,t.deviceBrand=`Alibaba`,t.deviceType=`bot`,t.platform=`other`},oe=(e,t)=>{t.appName=`YisouSpider`,t.appVersion=e.value,t.deviceBrand=`Alibaba`,t.deviceType=`bot`,t.platform=`other`},se=(e,t)=>{t.appName=`ByteSpider`,t.appVersion=e.value,t.deviceBrand=`ByteDance`,t.deviceType=`bot`,t.platform=`other`},ce=(e,t)=>{t.appName=`HeadlineCrawler`,t.appVersion=e.value,t.deviceBrand=`Headline.com`,t.deviceType=`bot`,t.platform=`other`},le=(e,t)=>{t.appName=`BitDiscoveryBot`,t.appVersion=e.value,t.deviceBrand=`Tenable`,t.deviceType=`bot`,t.platform=`other`},ue=(e,t)=>{e.getPreviousNTokens(4)===`Screaming Frog SEO Spider`&&(t.deviceBrand=`Screaming Frog`,t.appName=`Screaming Frog`),t.appVersion=e.value,t.deviceType=`bot`},de=(e,t)=>{t.appName=`Ai2Bot`,t.appVersion=e.value,t.deviceBrand=`Ai2`,t.deviceType=`bot`,t.platform=`other`},fe=(e,t)=>{t.appName=`DianjingAdSpider`,t.appVersion=e.value,t.deviceBrand=`Dianjing`,t.deviceType=`bot`,t.platform=`other`},_=(e,t)=>{t.appName=`BaiduSpider`,t.appVersion=e.value,t.deviceBrand=`Baidu`,t.deviceType=`bot`,t.platform=`other`},v=(e,t)=>{t.appName=`360 Spider`,t.appVersion=e.value,t.deviceBrand=`360`,t.deviceType=`bot`,t.platform=`other`},pe=(e,t)=>{t.appName=`BingBot`,t.appVersion=e.value,t.deviceBrand=`Microsoft`,t.deviceType=`bot`,t.platform=`other`},me=(e,t)=>{t.appName=`Googlebot`,t.appVersion=e.value,t.deviceBrand=`Google`,t.deviceType=`bot`,t.platform=`other`},he=(e,t)=>{t.appName=`YandexBot`,t.appVersion=e.value,t.deviceBrand=`Yandex`,t.deviceType=`bot`,t.platform=`other`},ge=(e,t)=>{e.getPreviousNTokens(3)===`Sogou web spider`&&(t.deviceBrand=`Sogou.com`,t.appName=`SogouSpider`),t.appVersion=e.value,t.deviceType=`bot`},_e=(e,t)=>{t.appName=`DataproviderBot`,t.appVersion=e.value,t.deviceBrand=`Dataprovider.com`,t.deviceType=`bot`,t.platform=`other`},ve=(e,t)=>{t.appName=`AhrefsBot`,t.appVersion=e.value,t.deviceBrand=`Ahrefs`,t.deviceType=`bot`,t.platform=`other`},ye=(e,t)=>{t.appName=`BitSightBot`,t.appVersion=e.value,t.deviceBrand=`Bitsight`,t.deviceType=`bot`,t.platform=`other`},be=(e,t)=>{t.appName=`oBot`,t.appVersion=e.value,t.deviceBrand=`IBM`,t.deviceType=`bot`,t.platform=`other`},xe=(e,t)=>{t.appName=`Cincraw`,t.appVersion=e.value,t.deviceBrand=`CINC`,t.deviceType=`bot`,t.platform=`other`},Se=(e,t)=>{t.appName=`DingTalkBot`,t.appVersion=e.value,t.deviceBrand=`Alibaba`,t.deviceType=`bot`,t.platform=`other`},Ce=(e,t)=>{t.appName=`YisouSpider`,t.appVersion=e.value,t.deviceBrand=`Alibaba`,t.deviceType=`bot`,t.platform=`other`},we=(e,t)=>{t.appName=`ByteSpider`,t.appVersion=e.value,t.deviceBrand=`ByteDance`,t.deviceType=`bot`,t.platform=`other`},Te=(e,t)=>{t.appName=`HeadlineCrawler`,t.appVersion=e.value,t.deviceBrand=`Headline.com`,t.deviceType=`bot`,t.platform=`other`},Ee=(e,t)=>{t.appName=`BitDiscoveryBot`,t.appVersion=e.value,t.deviceBrand=`Tenable`,t.deviceType=`bot`,t.platform=`other`},De=(e,t)=>{e.getPreviousNTokens(4)===`Screaming Frog SEO Spider`&&(t.deviceBrand=`Screaming Frog`,t.appName=`Screaming Frog`),t.appVersion=e.value,t.deviceType=`bot`},Oe=(e,t)=>{t.appName=`Ai2Bot`,t.appVersion=e.value,t.deviceBrand=`Ai2`,t.deviceType=`bot`,t.platform=`other`},ke=(e,t)=>{t.appName=`DianjingAdSpider`,t.appVersion=e.value,t.deviceBrand=`Dianjing`,t.deviceType=`bot`,t.platform=`other`},y=new Map,b=new Map;function Ae(){y.set(`Baiduspider-render`,d),y.set(`Baiduspider+`,d),y.set(`Baiduspider-image+`,d),y.set(`360Spider`,f),y.set(`360Spider-Image`,f),y.set(`bingbot`,p),y.set(`Googlebot`,m),y.set(`YandexRenderResourcesBot`,h),y.set(`spider`,g),y.set(`Dataprovider.com`,ee),y.set(`AhrefsBot`,te),y.set(`BitSightBot`,ne),y.set(`oBot`,re),y.set(`Cincraw`,ie),y.set(`DingTalkBot-LinkService`,ae),y.set(`YisouSpider`,oe),y.set(`Bytespider`,se),y.set(`ev-crawler`,ce),y.set(`bitdiscovery`,le),y.set(`Spider`,ue),y.set(`Ai2Bot-Dolma`,de),y.set(`dianjing_ad_spider`,fe),b.set(`Baiduspider-render`,_),b.set(`Baiduspider+`,_),b.set(`Baiduspider-image+`,_),b.set(`360Spider`,v),b.set(`360Spider-Image`,v),b.set(`bingbot`,pe),b.set(`Googlebot`,me),b.set(`YandexRenderResourcesBot`,he),b.set(`spider`,ge),b.set(`Dataprovider.com`,_e),b.set(`AhrefsBot`,ve),b.set(`BitSightBot`,ye),b.set(`oBot`,be),b.set(`Cincraw`,xe),b.set(`DingTalkBot-LinkService`,Se),b.set(`YisouSpider`,Ce),b.set(`Bytespider`,we),b.set(`ev-crawler`,Te),b.set(`bitdiscovery`,Ee),b.set(`Spider`,De),b.set(`Ai2Bot-Dolma`,Oe),b.set(`dianjing_ad_spider`,ke)}Ae();const je={productHandlerMap:y,commentHandlerMap:b,getSpecialProductHandler:()=>null,getSpecialCommentHandler:()=>null,getDefaultModelHandler:()=>null};function Me(e){let t=n();return u(e,t,je),t.deviceType===`bot`}function Ne(e){return Me(e)}function x(){return typeof globalThis<`u`&&globalThis?globalThis:typeof window<`u`&&window?window:typeof self<`u`&&self?self:{}}function S(e,t){return t&&Object.keys(t).forEach(n=>{e[n]=t[n]}),e}function C(e){return Object.prototype.toString.call(e)===`[object Object]`}function w(e,t){return!C(e)||!C(t)?!1:Object.keys(e).every(n=>{let r=e[n],i=t[n];return C(r)?w(r,i):r===i})}function T(e){let t=Object.prototype.toString.call(e);if(t===`[object String]`)return e?String(e):void 0;if(t===`[object Number]`||t===`[object Boolean]`)return String(e);if(t===`[object Object]`||t===`[object Array]`)try{return JSON.stringify(e)}catch(e){return}}function Pe(e){let t={};return Object.keys(e).forEach(n=>{let r=e[n];if(r===void 0)return;let i=T(r);i!==void 0&&(t[n]=i)}),t}function E(e=20,t=``){if(!e)return t;let n=Math.floor(Math.random()*60);return E(e-1,`0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz`.charAt(n)+t)}function Fe(e,t){let n;return function(){if(n)return;let r=Array.prototype.slice.call(arguments);n=setTimeout(()=>{n=void 0},t),e.apply(this,r)}}function Ie(e){try{let t=x().requestIdleCallback;if(typeof t==`function`){t(e,{timeout:1e3});return}}catch(e){}setTimeout(e,0)}function D(e){return!!e&&typeof e.then==`function`}function Le(){try{return typeof location<`u`&&location.href.indexOf(`aes_debug`)>-1}catch(e){return!1}}function Re(){try{return typeof navigator>`u`||!navigator.userAgent?!1:Ne(navigator.userAgent)}catch(e){return!1}}const ze=`brands,fullVersionList,mobile,model,platform,platformVersion`.split(`,`);function Be(e){if(e.getConfig(`collectClientHints`)!==!1)try{if(typeof navigator>`u`)return;let t=navigator.userAgentData;if(!t||typeof t.getHighEntropyValues!=`function`)return;let n=t.getHighEntropyValues(ze);if(!D(n)||typeof Promise!=`function`)return;let r=!1,i=new Promise(i=>{let a=()=>{r||(r=!0,i())};n.then(n=>{O(e,n,t),a()},()=>{O(e,t,t),a()}),setTimeout(a,2e3)});typeof e.before==`function`&&typeof e.log==`function`&&(e.log=e.before(e.log,(e,t,n)=>r?[e,t,n]:i.then(()=>[e,t,n])))}catch(e){return}}function O(e,t,n){let r=Ve(t,n);r&&e.setConfig({user_agent_data:r})}function Ve(e,t){let n=e&&Object(e),r={mobile:k(n,t,`mobile`),model:k(n,t,`model`),platform:k(n,t,`platform`),platformVersion:k(n,t,`platformVersion`)},i=k(n,t,`fullVersionList`),a=k(n,t,`brands`);He(i)?r.fullVersionList=i:r.brands=a;try{let e=JSON.stringify(r);return e===`{}`?void 0:e}catch(e){return}}function He(e){return!!e&&e.length>0}function k(e,t,n){return e[n]===void 0?t[n]:e[n]}function Ue(e){if(e.getConfig(`excludeCrawlers`)!==!0||!Re())return;let t=e.send;e.send=e.before(t,()=>K)}const A=3*1024*1024,j=4096,M=`AEM_TRACKER_UNIQUE_PVID`,We={collectClientHints:!0,debug:!0,endpoint:!0,excludeCrawlers:!0,logstore:!0,maxLogsPerRequest:!0,maxPayloadSize:!0,maxQueueLength:!0,maxUrlLength:!0,mergeRequestInterval:!0,project:!0,queueGlobalName:!0,requiredFields:!0};function Ge(){let e={collectClientHints:!0,debug:Le(),endpoint:`log-global.aliyuncs.com`,excludeCrawlers:!1,hash:I(),language:R(`language`),logstore:`raw-records`,maxLogsPerRequest:j,maxPayloadSize:A,maxQueueLength:50,mergeRequestInterval:500,origin_url:F(),platform:`web`,project:`aem-se-sg`,queueGlobalName:`AES_QUEUE`,sdk_version:`0.1.0-beta.2`,sr:et(),title:L(),timezone_offset:new Date().getTimezoneOffset(),ua:R(`userAgent`)},t=$e();return t!==void 0&&(e.dpi=t),Xe(e),Ye(e),e}function Ke(e){let t=Ge();return S(t,Qe()),S(t,Ze()),S(t,e),t}function N(e){let t=String(e.project||`aem-se-sg`),n=String(e.endpoint||`log-global.aliyuncs.com`),r=String(e.logstore||`raw-records`);return`https://`+t+`.`+n+`/logstores/`+r+`/track`}function qe(e){let t={};return Object.keys(e).forEach(n=>{if(We[n]||n.indexOf(`plugin`)===0)return;let r=e[n];if(r===``||r==null)return;let i=T(r);i!==void 0&&(t[n]=i)}),t}function Je(e){let t={},n=I(),r=F(),i=L();return n!==void 0&&n!==e.hash&&(t.hash=n),r!==void 0&&r!==e.origin_url&&(t.origin_url=r),i!==void 0&&i!==e.title&&(t.title=i),t}function Ye(e){S(e,P())}function P(){let e={},t=tt();return t?(t.effectiveType&&(e.net_type=t.effectiveType),t.downlink!==void 0&&(e.downlink=t.downlink),e):e}function Xe(e){Object.defineProperty(e,"pv_id",{configurable:!0,enumerable:!0,get(){let e=x();return e.AEM_TRACKER_UNIQUE_PVID||(e[M]=E()),String(e[M])},set(e){x()[M]=e}})}function Ze(){try{if(typeof window<`u`)return window.AES_CONFIG}catch(e){return}}function Qe(){let e={};try{if(typeof document>`u`)return e;let t=document.querySelector(`meta[name="aes-config"]`),n=t&&t.getAttribute(`content`);if(!n)return e;n.split(`&`).forEach(t=>{let n=t.split(`=`),r=n[0],i=n[1];if(!r)return;let a=i===void 0?``:decodeURIComponent(i),o=r.indexOf(`.`);if(o===-1){e[r]=a;return}let s=r.slice(0,o),c=r.slice(o+1),l=e[s]||{};l[c]=a,e[s]=l})}catch(t){return e}return e}function F(){try{return typeof location<`u`?location.href:void 0}catch(e){return}}function I(){try{return typeof location<`u`?location.hash:void 0}catch(e){return}}function L(){try{return typeof document<`u`?document.title:void 0}catch(e){return}}function R(e){try{return typeof navigator<`u`?navigator[e]:void 0}catch(e){return}}function $e(){try{return typeof window<`u`?window.devicePixelRatio:void 0}catch(e){return}}function et(){try{return typeof screen>`u`?void 0:String(screen.width)+`x`+String(screen.height)}catch(e){return}}function tt(){try{if(typeof navigator>`u`)return;let e=navigator;return e.connection||e.mozConnection||e.webkitConnection}catch(e){return}}function z(e,t){let n=[];return e.forEach(e=>{let r={};Object.keys(t).forEach(e=>{r[e]=t[e]}),Object.keys(e).forEach(t=>{r[t]=e[t]});let i=nt(t.ext,e.ext);i!==void 0&&(r.ext=i),n.push(r)}),{__logs__:n,__source__:`web-sdk`,__topic__:`/aes.1.1`}}function nt(e,t){if(e===void 0)return t;if(t===void 0)return e;let n=B(e),r=B(t);if(!n||!r)return t;let i=Object.create(null);return Object.keys(n).forEach(e=>{i[e]=n[e]}),Object.keys(r).forEach(e=>{i[e]=r[e]}),JSON.stringify(i)}function B(e){try{let t=JSON.parse(e);if(Object.prototype.toString.call(t)===`[object Object]`)return t}catch(e){return}}function V(e,t,n){return{body:JSON.stringify(t),mode:n,url:e}}function H(e){!rt(e.url,e.body)&&e.mode!==`pagehide`&&it(e.url,e.body)}function rt(e,t){try{return typeof navigator>`u`||typeof navigator.sendBeacon!=`function`?!1:navigator.sendBeacon(e,at(t))===!0}catch(e){return!1}}function it(e,t){try{if(typeof XMLHttpRequest>`u`)return;let n=new XMLHttpRequest;n.open(`POST`,e,!0),n.setRequestHeader(`Content-Type`,`text/plain`),n.send(t)}catch(e){return}}function at(e){try{if(typeof Blob==`function`)return new Blob([e],{type:`text/plain`})}catch(t){return e}return e}var ot=class{constructor(e){st(this,{getCommonFields:e.getCommonFields,getConfig:e.getConfig,getUrl:e.getUrl,logs:[],sendRequest:e.sendRequest,timeout:void 0})}push(e){let t=W(this);if(t.logs.push(e),t.logs.length>=G(t.getConfig().maxQueueLength,50)){this.flush(`normal`);return}if(!t.timeout){let e=G(t.getConfig().mergeRequestInterval,500);t.timeout=setTimeout(()=>{this.flush(`normal`)},e)}}sendSingle(e){this.sendLogs([e],`normal`)}flush(e=`normal`){let t=W(this);if(t.timeout&&(clearTimeout(t.timeout),t.timeout=void 0),!t.logs.length)return;let n=t.logs.slice();t.logs=[],this.sendLogs(n,e)}sendLogs(e,t){let n=W(this),r=n.getCommonFields(),i=n.getUrl(),a=n.getConfig(),o=ct(a),s=G(a.maxLogsPerRequest,j),c=[];for(let a=0;a<e.length;a+=1){let l=e[a],u=c.concat([l]),d=V(i,z(u,r),t);c.length&&(d.body.length>o||u.length>s)?(n.sendRequest(V(i,z(c,r),t)),c=[l]):c=u}c.length&&n.sendRequest(V(i,z(c,r),t))}};const U=`__aemQueueState`;function st(e,t){Object.defineProperty(e,U,{configurable:!1,enumerable:!1,value:t})}function W(e){return e[U]}function G(e,t){let n=Number(e);return n>0?n:t}function ct(e){let t=G(e.maxPayloadSize,A);return t===3145728?G(e.maxUrlLength,A):t}const K=Object.freeze({__aesBeforeSkip:1});var q=class{constructor(e={}){let t={config:Ke(e),currentRequest:void 0,offlineQueue:[],plugins:[],reqQueue:[],subscribers:{onConfigUpdated:[]},queue:void 0};t.queue=new ot({getCommonFields:()=>qe(t.config),getConfig:()=>t.config,getUrl:()=>N(t.config),sendRequest:e=>{this.dispatchRequest(e)}}),dt(this,t),this.use(Ue),this.use(Be),ht(this),gt(this),_t(this),vt(this),yt(this),xt(this)}log(e,t={},n={}){if(!e)return;this.applyBrowserDynamicConfig();let r={};Object.keys(t).forEach(e=>{if(e===`ts`){r.client_ts===void 0&&(r.client_ts=t[e]);return}r[e]=t[e]}),r.client_ts===void 0&&(r.client_ts=new Date().getTime()),r.type=e,this.print(`[AES] log`,e,r);let i=Pe(r),a=Z(this);if(ft(a.config)){a.reqQueue.length<1e3&&a.reqQueue.push({combo:n.combo,log:i});return}this.enqueue(i,n.combo)}setConfig(e,t){let n={};t!==void 0&&typeof e==`string`?n[e]=t:C(e)&&S(n,e),this.updateConfig(n)}getConfig(e){let t=Z(this).config;return e?t[e]:t}use(e,t){return Object.prototype.toString.call(e)===`[object Array]`?e.map(e=>{if(Object.prototype.toString.call(e)===`[object Array]`){let t=e;return Q(this,t[0],t[1])}return Q(this,e)}):Q(this,e,t)}before(e,t){return(...n)=>{let r=t.apply(this,n);if(r!==K){if(D(r)){r.then(t=>{t!==K&&e.apply(this,t||n)});return}e.apply(this,r||n)}}}after(e,t){return(...n)=>{e.apply(this,n),t.apply(this,n)}}updatePVID(){ut()}onConfigUpdated(e){Z(this).subscribers.onConfigUpdated.push(e)}send(e){let t=Z(this);if(J()){lt(t,e);return}H(t.currentRequest||{body:e,mode:`normal`,url:N(t.config)}),this.print(`[AES] send`,e)}sendTo(e,t){let n=Z(this).config,r=String(n.project||`aem-se-sg`),i=String(n.endpoint||`log-global.aliyuncs.com`),a=`https://`+r+`.`+i+`/logstores/`+e+`/track`;H({body:JSON.stringify({__topic__:t.topic,__logs__:t.logs}),mode:`normal`,url:a})}_sendAll(){bt(this,`normal`)}enqueue(e,t){let n=Z(this).queue;n&&(t===!1?n.sendSingle(e):n.push(e))}dispatchRequest(e){let t=Z(this);t.currentRequest=e;try{this.send(e.body)}finally{t.currentRequest=void 0}}updateConfig(e){let t=Z(this),n=!w(e,t.config),r=()=>{n&&(Object.keys(e).forEach(n=>{let r=e[n];if(C(r)){let e=C(t.config[n])?t.config[n]:{};t.config[n]=S(e,r)}else t.config[n]=r}),pt(t,e))};if(t.reqQueue.length){if(r(),!ft(t.config)){let e=t.reqQueue.slice();t.reqQueue=[],e.forEach(e=>{this.enqueue(e.log,e.combo)})}return}if(n){var i;(i=t.queue)==null||i.flush(`normal`)}r()}applyBrowserDynamicConfig(){let e=Je(Z(this).config);Object.keys(e).length&&this.updateConfig(e)}print(...e){Z(this).config.debug&&typeof console<`u`&&console.log.apply(console,e)}};function lt(e,t){e.offlineQueue.length>500&&e.offlineQueue.shift(),e.offlineQueue.push(t)}function J(){try{return typeof navigator<`u`&&navigator.onLine===!1}catch(e){return!1}}function Y(e){if(J())return;let t=Z(e);if(!t.offlineQueue.length)return;let n=t.offlineQueue.slice();t.offlineQueue=[],n.forEach(t=>{Ie(()=>{e.send(t)})})}const X=`__aemTrackerState`,ut=Fe(()=>{x()[M]=E()},200);function dt(e,t){Object.defineProperty(e,X,{configurable:!1,enumerable:!1,value:t})}function Z(e){return e[X]}function ft(e){return(e.requiredFields||[]).concat([`pid`]).some(t=>e[t]===void 0)}function pt(e,t){e.subscribers.onConfigUpdated.forEach(n=>{n(t,e.config)})}function Q(e,t,n){let r=Z(e),i=r.plugins.filter(e=>e.plugin===t)[0];if(i)return i.instance;let a;try{a=new t(e,n)}catch(r){if(!mt(r))throw r;a=t(e,n)}return r.plugins.push({instance:a,plugin:t}),a}function mt(e){return e instanceof TypeError?String(e.message).indexOf(`not a constructor`)!==-1:!1}function ht(e){try{if(typeof window>`u`||!window.addEventListener)return;window.addEventListener(`hashchange`,()=>{e.setConfig({hash:location.hash})})}catch(e){return}}function gt(e){try{if(typeof navigator>`u`)return;let t=navigator,n=t.connection||t.mozConnection||t.webkitConnection;if(!n||typeof n.addEventListener!=`function`)return;n.addEventListener(`change`,()=>{let t=P();Object.keys(t).length&&e.setConfig(t),Y(e)})}catch(e){return}}function _t(e){try{if(typeof window>`u`||!window.addEventListener)return;window.addEventListener(`online`,()=>{Y(e)})}catch(e){return}}function vt(e){try{if(typeof document>`u`||typeof MutationObserver>`u`)return;let t=()=>{let t=document.querySelector(`title`);t&&new MutationObserver(()=>{e.setConfig({title:document.title})}).observe(t,{characterData:!0,childList:!0,subtree:!0})};document.querySelector(`title`)?t():document.addEventListener(`DOMContentLoaded`,t)}catch(e){return}}function yt(e){try{if(typeof window>`u`||!window.addEventListener)return;window.addEventListener(`pagehide`,()=>{bt(e,`pagehide`)})}catch(e){return}}function bt(e,t){var n;(n=Z(e).queue)==null||n.flush(t)}function xt(e){try{if(typeof window>`u`)return;let t=String(e.getConfig(`queueGlobalName`)||`AES_QUEUE`),n=window,r=n[t],i=Object.prototype.toString.call(r)===`[object Array]`?r:[];i.forEach(t=>{$(e,t)});let a=i.push.bind(i);i.push=function(t){return $(e,t),a(t)},n[t]=i}catch(e){return}}function $(e,t){if(typeof t==`function`){t(e);return}let n=t;if(!n||typeof n.action!=`string`)return;let r=e[n.action];typeof r==`function`&&r.apply(e,n.arguments||[])}exports.AES=q,exports.default=q,exports.AES_SKIP_BEFORE_ORIGIN=K;
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});function e(e){let n=[],r={parent:e,tokens:n,get firstToken(){return n.length===0?null:n[0]},getNewToken(i){let a=t();return n.push(a),a.previousToken=i===void 0?n.length>1?n[n.length-2]:null:i,e&&(e.properties=r),a},getLastToken(){return n.length===0?null:n[n.length-1]},getFirstToken(){return n.length===0?null:n[0]},isEmpty(){return n.length===0}};return r}function t(){let e=[],t=[],n=[],r=null,i=null,a=null,o=!0,s=!0,c=!0,l=null,u={get key(){return o&&(r=e.join(``),o=!1),r},get value(){return s&&(i=t.join(``),s=!1),i},get originValue(){return c&&(a=n.join(``),c=!1),a},previousToken:null,properties:null,appendKey(t){e.push(t),o=!0},appendValue(e){t.push(e===`_`?`.`:e),n.push(e),s=!0,c=!0,l=null},getSplitValue(e){if(l===null){let e=u.value;l=e===``?[]:e.split(`/`)}return e>=0&&e<l.length?l[e]:null},getPreviousNTokens(e){let t=[],n=u;for(let r=0;r<e;r++){if(n==null)return null;t.unshift(n.key),n=n.previousToken}return t.join(` `)}};return u}function n(){return{appName:null,appVersion:null,browserName:null,browserVersion:null,engineName:null,engineVersion:null,deviceBrand:null,deviceModel:null,deviceType:`mobile`,osName:null,osVersion:null,platform:`web`,tokenGroup:e(null)}}const r=new Set(` ;,"'`.split(``)),i=new Set(`/=:`.split(``)),a=new Set([`Mozilla`,`AppleWebKit`,`Safari`,`Opera`,`Dalvik`,`com.ss.android.ugc.aweme`]);function o(e){return e.length===1&&r.has(e)}function s(e){return e.length===1&&i.has(e)}function c(e,t,n,r){if(e==null)return;let i=t.parent,o=e.key,s=null;if(i!=null){let e=i.key;if(a.has(e)){var c;s=(c=r.commentHandlerMap.get(o))==null?null:c,s==null&&(s=r.getSpecialCommentHandler(o)),s==null&&o.endsWith(` Build`)&&(s=r.getDefaultModelHandler())}else{var l;s=(l=r.productHandlerMap.get(o))==null?r.getSpecialProductHandler(o):l}}else{var u;s=(u=r.productHandlerMap.get(o))==null?r.getSpecialProductHandler(o):u}if(s!=null)try{s(e,n)}catch(e){}}function l(t,n,r,i,a){let u=null,d=null,f,p=!1,m=t.length,h=n>0?t[n-1]:`\0`;for(f=n;f<m;f++){let g=t[f];if(o(g)){let e=h!==`\0`&&o(h);if(!p&&n>0&&g===` `&&!e){let e=f+1;if(e<m){let n=t[e];/\d/.test(n)||n===`-`?p=!0:d!=null&&d.appendKey(g)}else d!=null&&d.appendKey(g)}else d!=null&&(u=d,d=null);h=g}else if(g===`(`){if(h===`(`){h=g;continue}let n=e(r.getLastToken()),o=f;f=l(t,f+1,n,i,a),d!=null&&(u=d,d=null),h=t[o]}else if(g===`)`){if(n===0){h=g;continue}break}else d==null&&(c(r.getLastToken(),r,i,a),d=r.getNewToken(u),p=!1),s(g)?(p&&d.appendValue(g),p=!0):p?d.appendValue(g):d.appendKey(g),h=g}return c(r.getLastToken(),r,i,a),f}function u(e,t,n){if(e==null)throw Error(`input can not be null`);return l(e,0,t.tokenGroup,t,n),t}const d=(e,t)=>{t.appName=`BaiduSpider`,t.appVersion=e.value,t.deviceBrand=`Baidu`,t.deviceType=`bot`,t.platform=`other`},f=(e,t)=>{t.appName=`360 Spider`,t.appVersion=e.value,t.deviceBrand=`360`,t.deviceType=`bot`,t.platform=`other`},p=(e,t)=>{t.appName=`BingBot`,t.appVersion=e.value,t.deviceBrand=`Microsoft`,t.deviceType=`bot`,t.platform=`other`},m=(e,t)=>{t.appName=`Googlebot`,t.appVersion=e.value,t.deviceBrand=`Google`,t.deviceType=`bot`,t.platform=`other`},h=(e,t)=>{t.appName=`YandexBot`,t.appVersion=e.value,t.deviceBrand=`Yandex`,t.deviceType=`bot`,t.platform=`other`},g=(e,t)=>{e.getPreviousNTokens(3)===`Sogou web spider`&&(t.deviceBrand=`Sogou.com`,t.appName=`SogouSpider`),t.appVersion=e.value,t.deviceType=`bot`},ee=(e,t)=>{t.appName=`DataproviderBot`,t.appVersion=e.value,t.deviceBrand=`Dataprovider.com`,t.deviceType=`bot`,t.platform=`other`},te=(e,t)=>{t.appName=`AhrefsBot`,t.appVersion=e.value,t.deviceBrand=`Ahrefs`,t.deviceType=`bot`,t.platform=`other`},ne=(e,t)=>{t.appName=`BitSightBot`,t.appVersion=e.value,t.deviceBrand=`Bitsight`,t.deviceType=`bot`,t.platform=`other`},re=(e,t)=>{t.appName=`oBot`,t.appVersion=e.value,t.deviceBrand=`IBM`,t.deviceType=`bot`,t.platform=`other`},ie=(e,t)=>{t.appName=`Cincraw`,t.appVersion=e.value,t.deviceBrand=`CINC`,t.deviceType=`bot`,t.platform=`other`},ae=(e,t)=>{t.appName=`DingTalkBot`,t.appVersion=e.value,t.deviceBrand=`Alibaba`,t.deviceType=`bot`,t.platform=`other`},oe=(e,t)=>{t.appName=`YisouSpider`,t.appVersion=e.value,t.deviceBrand=`Alibaba`,t.deviceType=`bot`,t.platform=`other`},se=(e,t)=>{t.appName=`ByteSpider`,t.appVersion=e.value,t.deviceBrand=`ByteDance`,t.deviceType=`bot`,t.platform=`other`},ce=(e,t)=>{t.appName=`HeadlineCrawler`,t.appVersion=e.value,t.deviceBrand=`Headline.com`,t.deviceType=`bot`,t.platform=`other`},le=(e,t)=>{t.appName=`BitDiscoveryBot`,t.appVersion=e.value,t.deviceBrand=`Tenable`,t.deviceType=`bot`,t.platform=`other`},ue=(e,t)=>{e.getPreviousNTokens(4)===`Screaming Frog SEO Spider`&&(t.deviceBrand=`Screaming Frog`,t.appName=`Screaming Frog`),t.appVersion=e.value,t.deviceType=`bot`},de=(e,t)=>{t.appName=`Ai2Bot`,t.appVersion=e.value,t.deviceBrand=`Ai2`,t.deviceType=`bot`,t.platform=`other`},fe=(e,t)=>{t.appName=`DianjingAdSpider`,t.appVersion=e.value,t.deviceBrand=`Dianjing`,t.deviceType=`bot`,t.platform=`other`},_=(e,t)=>{t.appName=`BaiduSpider`,t.appVersion=e.value,t.deviceBrand=`Baidu`,t.deviceType=`bot`,t.platform=`other`},v=(e,t)=>{t.appName=`360 Spider`,t.appVersion=e.value,t.deviceBrand=`360`,t.deviceType=`bot`,t.platform=`other`},pe=(e,t)=>{t.appName=`BingBot`,t.appVersion=e.value,t.deviceBrand=`Microsoft`,t.deviceType=`bot`,t.platform=`other`},me=(e,t)=>{t.appName=`Googlebot`,t.appVersion=e.value,t.deviceBrand=`Google`,t.deviceType=`bot`,t.platform=`other`},he=(e,t)=>{t.appName=`YandexBot`,t.appVersion=e.value,t.deviceBrand=`Yandex`,t.deviceType=`bot`,t.platform=`other`},ge=(e,t)=>{e.getPreviousNTokens(3)===`Sogou web spider`&&(t.deviceBrand=`Sogou.com`,t.appName=`SogouSpider`),t.appVersion=e.value,t.deviceType=`bot`},_e=(e,t)=>{t.appName=`DataproviderBot`,t.appVersion=e.value,t.deviceBrand=`Dataprovider.com`,t.deviceType=`bot`,t.platform=`other`},ve=(e,t)=>{t.appName=`AhrefsBot`,t.appVersion=e.value,t.deviceBrand=`Ahrefs`,t.deviceType=`bot`,t.platform=`other`},ye=(e,t)=>{t.appName=`BitSightBot`,t.appVersion=e.value,t.deviceBrand=`Bitsight`,t.deviceType=`bot`,t.platform=`other`},be=(e,t)=>{t.appName=`oBot`,t.appVersion=e.value,t.deviceBrand=`IBM`,t.deviceType=`bot`,t.platform=`other`},xe=(e,t)=>{t.appName=`Cincraw`,t.appVersion=e.value,t.deviceBrand=`CINC`,t.deviceType=`bot`,t.platform=`other`},Se=(e,t)=>{t.appName=`DingTalkBot`,t.appVersion=e.value,t.deviceBrand=`Alibaba`,t.deviceType=`bot`,t.platform=`other`},Ce=(e,t)=>{t.appName=`YisouSpider`,t.appVersion=e.value,t.deviceBrand=`Alibaba`,t.deviceType=`bot`,t.platform=`other`},we=(e,t)=>{t.appName=`ByteSpider`,t.appVersion=e.value,t.deviceBrand=`ByteDance`,t.deviceType=`bot`,t.platform=`other`},Te=(e,t)=>{t.appName=`HeadlineCrawler`,t.appVersion=e.value,t.deviceBrand=`Headline.com`,t.deviceType=`bot`,t.platform=`other`},Ee=(e,t)=>{t.appName=`BitDiscoveryBot`,t.appVersion=e.value,t.deviceBrand=`Tenable`,t.deviceType=`bot`,t.platform=`other`},De=(e,t)=>{e.getPreviousNTokens(4)===`Screaming Frog SEO Spider`&&(t.deviceBrand=`Screaming Frog`,t.appName=`Screaming Frog`),t.appVersion=e.value,t.deviceType=`bot`},Oe=(e,t)=>{t.appName=`Ai2Bot`,t.appVersion=e.value,t.deviceBrand=`Ai2`,t.deviceType=`bot`,t.platform=`other`},ke=(e,t)=>{t.appName=`DianjingAdSpider`,t.appVersion=e.value,t.deviceBrand=`Dianjing`,t.deviceType=`bot`,t.platform=`other`},y=new Map,b=new Map;function Ae(){y.set(`Baiduspider-render`,d),y.set(`Baiduspider+`,d),y.set(`Baiduspider-image+`,d),y.set(`360Spider`,f),y.set(`360Spider-Image`,f),y.set(`bingbot`,p),y.set(`Googlebot`,m),y.set(`YandexRenderResourcesBot`,h),y.set(`spider`,g),y.set(`Dataprovider.com`,ee),y.set(`AhrefsBot`,te),y.set(`BitSightBot`,ne),y.set(`oBot`,re),y.set(`Cincraw`,ie),y.set(`DingTalkBot-LinkService`,ae),y.set(`YisouSpider`,oe),y.set(`Bytespider`,se),y.set(`ev-crawler`,ce),y.set(`bitdiscovery`,le),y.set(`Spider`,ue),y.set(`Ai2Bot-Dolma`,de),y.set(`dianjing_ad_spider`,fe),b.set(`Baiduspider-render`,_),b.set(`Baiduspider+`,_),b.set(`Baiduspider-image+`,_),b.set(`360Spider`,v),b.set(`360Spider-Image`,v),b.set(`bingbot`,pe),b.set(`Googlebot`,me),b.set(`YandexRenderResourcesBot`,he),b.set(`spider`,ge),b.set(`Dataprovider.com`,_e),b.set(`AhrefsBot`,ve),b.set(`BitSightBot`,ye),b.set(`oBot`,be),b.set(`Cincraw`,xe),b.set(`DingTalkBot-LinkService`,Se),b.set(`YisouSpider`,Ce),b.set(`Bytespider`,we),b.set(`ev-crawler`,Te),b.set(`bitdiscovery`,Ee),b.set(`Spider`,De),b.set(`Ai2Bot-Dolma`,Oe),b.set(`dianjing_ad_spider`,ke)}Ae();const je={productHandlerMap:y,commentHandlerMap:b,getSpecialProductHandler:()=>null,getSpecialCommentHandler:()=>null,getDefaultModelHandler:()=>null};function Me(e){let t=n();return u(e,t,je),t.deviceType===`bot`}function Ne(e){return Me(e)}function x(){return typeof globalThis<`u`&&globalThis?globalThis:typeof window<`u`&&window?window:typeof self<`u`&&self?self:{}}function S(e,t){return t&&Object.keys(t).forEach(n=>{e[n]=t[n]}),e}function C(e){return Object.prototype.toString.call(e)===`[object Object]`}function w(e,t){return!C(e)||!C(t)?!1:Object.keys(e).every(n=>{let r=e[n],i=t[n];return C(r)?w(r,i):r===i})}function T(e){let t=Object.prototype.toString.call(e);if(t===`[object String]`)return e?String(e):void 0;if(t===`[object Number]`||t===`[object Boolean]`)return String(e);if(t===`[object Object]`||t===`[object Array]`)try{return JSON.stringify(e)}catch(e){return}}function Pe(e){let t={};return Object.keys(e).forEach(n=>{let r=e[n];if(r===void 0)return;let i=T(r);i!==void 0&&(t[n]=i)}),t}function E(e=20,t=``){if(!e)return t;let n=Math.floor(Math.random()*60);return E(e-1,`0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz`.charAt(n)+t)}function Fe(e,t){let n;return function(){if(n)return;let r=Array.prototype.slice.call(arguments);n=setTimeout(()=>{n=void 0},t),e.apply(this,r)}}function Ie(e){try{let t=x().requestIdleCallback;if(typeof t==`function`){t(e,{timeout:1e3});return}}catch(e){}setTimeout(e,0)}function D(e){return!!e&&typeof e.then==`function`}function Le(){try{return typeof location<`u`&&location.href.indexOf(`aes_debug`)>-1}catch(e){return!1}}function Re(){try{return typeof navigator>`u`||!navigator.userAgent?!1:Ne(navigator.userAgent)}catch(e){return!1}}const ze=`brands,fullVersionList,mobile,model,platform,platformVersion`.split(`,`);function Be(e){if(e.getConfig(`collectClientHints`)!==!1)try{if(typeof navigator>`u`)return;let t=navigator.userAgentData;if(!t||typeof t.getHighEntropyValues!=`function`)return;let n=t.getHighEntropyValues(ze);if(!D(n)||typeof Promise!=`function`)return;let r=!1,i=new Promise(i=>{let a=()=>{r||(r=!0,i())};n.then(n=>{O(e,n,t),a()},()=>{O(e,t,t),a()}),setTimeout(a,2e3)});typeof e.before==`function`&&typeof e.log==`function`&&(e.log=e.before(e.log,(e,t,n)=>r?[e,t,n]:i.then(()=>[e,t,n])))}catch(e){return}}function O(e,t,n){let r=Ve(t,n);r&&e.setConfig({user_agent_data:r})}function Ve(e,t){let n=e&&Object(e),r={mobile:k(n,t,`mobile`),model:k(n,t,`model`),platform:k(n,t,`platform`),platformVersion:k(n,t,`platformVersion`)},i=k(n,t,`fullVersionList`),a=k(n,t,`brands`);He(i)?r.fullVersionList=i:r.brands=a;try{let e=JSON.stringify(r);return e===`{}`?void 0:e}catch(e){return}}function He(e){return!!e&&e.length>0}function k(e,t,n){return e[n]===void 0?t[n]:e[n]}function Ue(e){if(e.getConfig(`excludeCrawlers`)!==!0||!Re())return;let t=e.send;e.send=e.before(t,()=>K)}const A=3*1024*1024,j=4096,M=`AEM_TRACKER_UNIQUE_PVID`,We={collectClientHints:!0,debug:!0,endpoint:!0,excludeCrawlers:!0,logstore:!0,maxLogsPerRequest:!0,maxPayloadSize:!0,maxQueueLength:!0,maxUrlLength:!0,mergeRequestInterval:!0,project:!0,queueGlobalName:!0,requiredFields:!0};function Ge(){let e={collectClientHints:!0,debug:Le(),endpoint:`log-global.aliyuncs.com`,excludeCrawlers:!1,hash:I(),language:R(`language`),logstore:`raw-records`,maxLogsPerRequest:j,maxPayloadSize:A,maxQueueLength:50,mergeRequestInterval:500,origin_url:F(),platform:`web`,project:`aem-se-sg`,queueGlobalName:`AES_QUEUE`,sdk_version:`0.1.0-beta.3`,sr:tt(),title:L(),timezone_offset:new Date().getTimezoneOffset(),ua:R(`userAgent`)},t=et();return t!==void 0&&(e.dpi=t),Xe(e),Ye(e),e}function Ke(e){let t=Ge();return S(t,Qe()),S(t,Ze()),S(t,e),t}function N(e){let t=String(e.project||`aem-se-sg`),n=String(e.endpoint||`log-global.aliyuncs.com`),r=String(e.logstore||`raw-records`);return`https://`+t+`.`+n+`/logstores/`+r+`/track`}function qe(e){let t={};if(Object.keys(e).forEach(n=>{if(We[n]||n.indexOf(`plugin`)===0)return;let r=e[n];if(r===``||r==null)return;let i=T(r);i!==void 0&&(t[n]=i)}),!t.device_id){let e=$e(`cna`);e&&(t.device_id=e)}return t}function Je(e){let t={},n=I(),r=F(),i=L();return n!==void 0&&n!==e.hash&&(t.hash=n),r!==void 0&&r!==e.origin_url&&(t.origin_url=r),i!==void 0&&i!==e.title&&(t.title=i),t}function Ye(e){S(e,P())}function P(){let e={},t=nt();return t?(t.effectiveType&&(e.net_type=t.effectiveType),t.downlink!==void 0&&(e.downlink=t.downlink),e):e}function Xe(e){Object.defineProperty(e,"pv_id",{configurable:!0,enumerable:!0,get(){let e=x();return e.AEM_TRACKER_UNIQUE_PVID||(e[M]=E()),String(e[M])},set(e){x()[M]=e}})}function Ze(){try{if(typeof window<`u`)return window.AES_CONFIG}catch(e){return}}function Qe(){let e={};try{if(typeof document>`u`)return e;let t=document.querySelector(`meta[name="aes-config"]`),n=t&&t.getAttribute(`content`);if(!n)return e;n.split(`&`).forEach(t=>{let n=t.split(`=`),r=n[0],i=n[1];if(!r)return;let a=i===void 0?``:decodeURIComponent(i),o=r.indexOf(`.`);if(o===-1){e[r]=a;return}let s=r.slice(0,o),c=r.slice(o+1),l=e[s]||{};l[c]=a,e[s]=l})}catch(t){return e}return e}function F(){try{return typeof location<`u`?location.href:void 0}catch(e){return}}function I(){try{return typeof location<`u`?location.hash:void 0}catch(e){return}}function L(){try{return typeof document<`u`?document.title:void 0}catch(e){return}}function $e(e){try{if(typeof document>`u`||!document.cookie)return;let t=RegExp(`(?:^|; )`+e+`=([^;]*)`).exec(document.cookie);return t?t[1]:void 0}catch(e){return}}function R(e){try{return typeof navigator<`u`?navigator[e]:void 0}catch(e){return}}function et(){try{return typeof window<`u`?window.devicePixelRatio:void 0}catch(e){return}}function tt(){try{return typeof screen>`u`?void 0:String(screen.width)+`x`+String(screen.height)}catch(e){return}}function nt(){try{if(typeof navigator>`u`)return;let e=navigator;return e.connection||e.mozConnection||e.webkitConnection}catch(e){return}}function z(e,t){let n=[];return e.forEach(e=>{let r={};Object.keys(t).forEach(e=>{r[e]=t[e]}),Object.keys(e).forEach(t=>{r[t]=e[t]});let i=rt(t.ext,e.ext);i!==void 0&&(r.ext=i),n.push(r)}),{__logs__:n,__source__:`web-sdk`,__topic__:`/aes.1.1`}}function rt(e,t){if(e===void 0)return t;if(t===void 0)return e;let n=B(e),r=B(t);if(!n||!r)return t;let i=Object.create(null);return Object.keys(n).forEach(e=>{i[e]=n[e]}),Object.keys(r).forEach(e=>{i[e]=r[e]}),JSON.stringify(i)}function B(e){try{let t=JSON.parse(e);if(Object.prototype.toString.call(t)===`[object Object]`)return t}catch(e){return}}function V(e,t,n){return{body:JSON.stringify(t),mode:n,url:e}}function H(e){!it(e.url,e.body)&&e.mode!==`pagehide`&&at(e.url,e.body)}function it(e,t){try{return typeof navigator>`u`||typeof navigator.sendBeacon!=`function`?!1:navigator.sendBeacon(e,ot(t))===!0}catch(e){return!1}}function at(e,t){try{if(typeof XMLHttpRequest>`u`)return;let n=new XMLHttpRequest;n.open(`POST`,e,!0),n.setRequestHeader(`Content-Type`,`text/plain`),n.send(t)}catch(e){return}}function ot(e){try{if(typeof Blob==`function`)return new Blob([e],{type:`text/plain`})}catch(t){return e}return e}var st=class{constructor(e){ct(this,{getCommonFields:e.getCommonFields,getConfig:e.getConfig,getUrl:e.getUrl,logs:[],sendRequest:e.sendRequest,timeout:void 0})}push(e){let t=W(this);if(t.logs.push(e),t.logs.length>=G(t.getConfig().maxQueueLength,50)){this.flush(`normal`);return}if(!t.timeout){let e=G(t.getConfig().mergeRequestInterval,500);t.timeout=setTimeout(()=>{this.flush(`normal`)},e)}}sendSingle(e){this.sendLogs([e],`normal`)}flush(e=`normal`){let t=W(this);if(t.timeout&&(clearTimeout(t.timeout),t.timeout=void 0),!t.logs.length)return;let n=t.logs.slice();t.logs=[],this.sendLogs(n,e)}sendLogs(e,t){let n=W(this),r=n.getCommonFields(),i=n.getUrl(),a=n.getConfig(),o=lt(a),s=G(a.maxLogsPerRequest,j),c=[];for(let a=0;a<e.length;a+=1){let l=e[a],u=c.concat([l]),d=V(i,z(u,r),t);c.length&&(d.body.length>o||u.length>s)?(n.sendRequest(V(i,z(c,r),t)),c=[l]):c=u}c.length&&n.sendRequest(V(i,z(c,r),t))}};const U=`__aemQueueState`;function ct(e,t){Object.defineProperty(e,U,{configurable:!1,enumerable:!1,value:t})}function W(e){return e[U]}function G(e,t){let n=Number(e);return n>0?n:t}function lt(e){let t=G(e.maxPayloadSize,A);return t===3145728?G(e.maxUrlLength,A):t}const K=Object.freeze({__aesBeforeSkip:1});var q=class{constructor(e={}){let t={config:Ke(e),currentRequest:void 0,offlineQueue:[],plugins:[],reqQueue:[],subscribers:{onConfigUpdated:[]},queue:void 0};t.queue=new st({getCommonFields:()=>qe(t.config),getConfig:()=>t.config,getUrl:()=>N(t.config),sendRequest:e=>{this.dispatchRequest(e)}}),ft(this,t),this.use(Ue),this.use(Be),gt(this),_t(this),vt(this),yt(this),bt(this),St(this)}log(e,t={},n={}){if(!e)return;this.applyBrowserDynamicConfig();let r={};Object.keys(t).forEach(e=>{if(e===`ts`){r.client_ts===void 0&&(r.client_ts=t[e]);return}r[e]=t[e]}),r.client_ts===void 0&&(r.client_ts=new Date().getTime()),r.type=e,this.print(`[AES] log`,e,r);let i=Pe(r),a=Z(this);if(pt(a.config)){a.reqQueue.length<1e3&&a.reqQueue.push({combo:n.combo,log:i});return}this.enqueue(i,n.combo)}setConfig(e,t){let n={};t!==void 0&&typeof e==`string`?n[e]=t:C(e)&&S(n,e),this.updateConfig(n)}getConfig(e){let t=Z(this).config;return e?t[e]:t}use(e,t){return Object.prototype.toString.call(e)===`[object Array]`?e.map(e=>{if(Object.prototype.toString.call(e)===`[object Array]`){let t=e;return Q(this,t[0],t[1])}return Q(this,e)}):Q(this,e,t)}before(e,t){return(...n)=>{let r=t.apply(this,n);if(r!==K){if(D(r)){r.then(t=>{t!==K&&e.apply(this,t||n)});return}e.apply(this,r||n)}}}after(e,t){return(...n)=>{e.apply(this,n),t.apply(this,n)}}updatePVID(){dt()}onConfigUpdated(e){Z(this).subscribers.onConfigUpdated.push(e)}send(e){let t=Z(this);if(J()){ut(t,e);return}H(t.currentRequest||{body:e,mode:`normal`,url:N(t.config)}),this.print(`[AES] send`,e)}sendTo(e,t){let n=Z(this).config,r=String(n.project||`aem-se-sg`),i=String(n.endpoint||`log-global.aliyuncs.com`),a=`https://`+r+`.`+i+`/logstores/`+e+`/track`;H({body:JSON.stringify({__topic__:t.topic,__logs__:t.logs}),mode:`normal`,url:a})}_sendAll(){xt(this,`normal`)}enqueue(e,t){let n=Z(this).queue;n&&(t===!1?n.sendSingle(e):n.push(e))}dispatchRequest(e){let t=Z(this);t.currentRequest=e;try{this.send(e.body)}finally{t.currentRequest=void 0}}updateConfig(e){let t=Z(this),n=!w(e,t.config),r=()=>{n&&(Object.keys(e).forEach(n=>{let r=e[n];if(C(r)){let e=C(t.config[n])?t.config[n]:{};t.config[n]=S(e,r)}else t.config[n]=r}),mt(t,e))};if(t.reqQueue.length){if(r(),!pt(t.config)){let e=t.reqQueue.slice();t.reqQueue=[],e.forEach(e=>{this.enqueue(e.log,e.combo)})}return}if(n){var i;(i=t.queue)==null||i.flush(`normal`)}r()}applyBrowserDynamicConfig(){let e=Je(Z(this).config);Object.keys(e).length&&this.updateConfig(e)}print(...e){Z(this).config.debug&&typeof console<`u`&&console.log.apply(console,e)}};function ut(e,t){e.offlineQueue.length>500&&e.offlineQueue.shift(),e.offlineQueue.push(t)}function J(){try{return typeof navigator<`u`&&navigator.onLine===!1}catch(e){return!1}}function Y(e){if(J())return;let t=Z(e);if(!t.offlineQueue.length)return;let n=t.offlineQueue.slice();t.offlineQueue=[],n.forEach(t=>{Ie(()=>{e.send(t)})})}const X=`__aemTrackerState`,dt=Fe(()=>{x()[M]=E()},200);function ft(e,t){Object.defineProperty(e,X,{configurable:!1,enumerable:!1,value:t})}function Z(e){return e[X]}function pt(e){return(e.requiredFields||[]).concat([`pid`]).some(t=>e[t]===void 0)}function mt(e,t){e.subscribers.onConfigUpdated.forEach(n=>{n(t,e.config)})}function Q(e,t,n){let r=Z(e),i=r.plugins.filter(e=>e.plugin===t)[0];if(i)return i.instance;let a;try{a=new t(e,n)}catch(r){if(!ht(r))throw r;a=t(e,n)}return r.plugins.push({instance:a,plugin:t}),a}function ht(e){return e instanceof TypeError?String(e.message).indexOf(`not a constructor`)!==-1:!1}function gt(e){try{if(typeof window>`u`||!window.addEventListener)return;window.addEventListener(`hashchange`,()=>{e.setConfig({hash:location.hash})})}catch(e){return}}function _t(e){try{if(typeof navigator>`u`)return;let t=navigator,n=t.connection||t.mozConnection||t.webkitConnection;if(!n||typeof n.addEventListener!=`function`)return;n.addEventListener(`change`,()=>{let t=P();Object.keys(t).length&&e.setConfig(t),Y(e)})}catch(e){return}}function vt(e){try{if(typeof window>`u`||!window.addEventListener)return;window.addEventListener(`online`,()=>{Y(e)})}catch(e){return}}function yt(e){try{if(typeof document>`u`||typeof MutationObserver>`u`)return;let t=()=>{let t=document.querySelector(`title`);t&&new MutationObserver(()=>{e.setConfig({title:document.title})}).observe(t,{characterData:!0,childList:!0,subtree:!0})};document.querySelector(`title`)?t():document.addEventListener(`DOMContentLoaded`,t)}catch(e){return}}function bt(e){try{if(typeof window>`u`||!window.addEventListener)return;window.addEventListener(`pagehide`,()=>{xt(e,`pagehide`)})}catch(e){return}}function xt(e,t){var n;(n=Z(e).queue)==null||n.flush(t)}function St(e){try{if(typeof window>`u`)return;let t=String(e.getConfig(`queueGlobalName`)||`AES_QUEUE`),n=window,r=n[t],i=Object.prototype.toString.call(r)===`[object Array]`?r:[];i.forEach(t=>{$(e,t)});let a=i.push.bind(i);i.push=function(t){return $(e,t),a(t)},n[t]=i}catch(e){return}}function $(e,t){if(typeof t==`function`){t(e);return}let n=t;if(!n||typeof n.action!=`string`)return;let r=e[n.action];typeof r==`function`&&r.apply(e,n.arguments||[])}exports.AES=q,exports.default=q,exports.AES_SKIP_BEFORE_ORIGIN=K;
|
package/dist/index.d.ts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e){let n=[],r={parent:e,tokens:n,get firstToken(){return n.length===0?null:n[0]},getNewToken(i){let a=t();return n.push(a),a.previousToken=i===void 0?n.length>1?n[n.length-2]:null:i,e&&(e.properties=r),a},getLastToken(){return n.length===0?null:n[n.length-1]},getFirstToken(){return n.length===0?null:n[0]},isEmpty(){return n.length===0}};return r}function t(){let e=[],t=[],n=[],r=null,i=null,a=null,o=!0,s=!0,c=!0,l=null,u={get key(){return o&&(r=e.join(``),o=!1),r},get value(){return s&&(i=t.join(``),s=!1),i},get originValue(){return c&&(a=n.join(``),c=!1),a},previousToken:null,properties:null,appendKey(t){e.push(t),o=!0},appendValue(e){t.push(e===`_`?`.`:e),n.push(e),s=!0,c=!0,l=null},getSplitValue(e){if(l===null){let e=u.value;l=e===``?[]:e.split(`/`)}return e>=0&&e<l.length?l[e]:null},getPreviousNTokens(e){let t=[],n=u;for(let r=0;r<e;r++){if(n==null)return null;t.unshift(n.key),n=n.previousToken}return t.join(` `)}};return u}function n(){return{appName:null,appVersion:null,browserName:null,browserVersion:null,engineName:null,engineVersion:null,deviceBrand:null,deviceModel:null,deviceType:`mobile`,osName:null,osVersion:null,platform:`web`,tokenGroup:e(null)}}const r=new Set(` ;,"'`.split(``)),i=new Set(`/=:`.split(``)),a=new Set([`Mozilla`,`AppleWebKit`,`Safari`,`Opera`,`Dalvik`,`com.ss.android.ugc.aweme`]);function o(e){return e.length===1&&r.has(e)}function s(e){return e.length===1&&i.has(e)}function c(e,t,n,r){if(e==null)return;let i=t.parent,o=e.key,s=null;if(i!=null){let e=i.key;if(a.has(e)){var c;s=(c=r.commentHandlerMap.get(o))==null?null:c,s==null&&(s=r.getSpecialCommentHandler(o)),s==null&&o.endsWith(` Build`)&&(s=r.getDefaultModelHandler())}else{var l;s=(l=r.productHandlerMap.get(o))==null?r.getSpecialProductHandler(o):l}}else{var u;s=(u=r.productHandlerMap.get(o))==null?r.getSpecialProductHandler(o):u}if(s!=null)try{s(e,n)}catch(e){}}function l(t,n,r,i,a){let u=null,d=null,f,p=!1,m=t.length,h=n>0?t[n-1]:`\0`;for(f=n;f<m;f++){let g=t[f];if(o(g)){let e=h!==`\0`&&o(h);if(!p&&n>0&&g===` `&&!e){let e=f+1;if(e<m){let n=t[e];/\d/.test(n)||n===`-`?p=!0:d!=null&&d.appendKey(g)}else d!=null&&d.appendKey(g)}else d!=null&&(u=d,d=null);h=g}else if(g===`(`){if(h===`(`){h=g;continue}let n=e(r.getLastToken()),o=f;f=l(t,f+1,n,i,a),d!=null&&(u=d,d=null),h=t[o]}else if(g===`)`){if(n===0){h=g;continue}break}else d==null&&(c(r.getLastToken(),r,i,a),d=r.getNewToken(u),p=!1),s(g)?(p&&d.appendValue(g),p=!0):p?d.appendValue(g):d.appendKey(g),h=g}return c(r.getLastToken(),r,i,a),f}function u(e,t,n){if(e==null)throw Error(`input can not be null`);return l(e,0,t.tokenGroup,t,n),t}const d=(e,t)=>{t.appName=`BaiduSpider`,t.appVersion=e.value,t.deviceBrand=`Baidu`,t.deviceType=`bot`,t.platform=`other`},f=(e,t)=>{t.appName=`360 Spider`,t.appVersion=e.value,t.deviceBrand=`360`,t.deviceType=`bot`,t.platform=`other`},p=(e,t)=>{t.appName=`BingBot`,t.appVersion=e.value,t.deviceBrand=`Microsoft`,t.deviceType=`bot`,t.platform=`other`},m=(e,t)=>{t.appName=`Googlebot`,t.appVersion=e.value,t.deviceBrand=`Google`,t.deviceType=`bot`,t.platform=`other`},h=(e,t)=>{t.appName=`YandexBot`,t.appVersion=e.value,t.deviceBrand=`Yandex`,t.deviceType=`bot`,t.platform=`other`},g=(e,t)=>{e.getPreviousNTokens(3)===`Sogou web spider`&&(t.deviceBrand=`Sogou.com`,t.appName=`SogouSpider`),t.appVersion=e.value,t.deviceType=`bot`},ee=(e,t)=>{t.appName=`DataproviderBot`,t.appVersion=e.value,t.deviceBrand=`Dataprovider.com`,t.deviceType=`bot`,t.platform=`other`},te=(e,t)=>{t.appName=`AhrefsBot`,t.appVersion=e.value,t.deviceBrand=`Ahrefs`,t.deviceType=`bot`,t.platform=`other`},ne=(e,t)=>{t.appName=`BitSightBot`,t.appVersion=e.value,t.deviceBrand=`Bitsight`,t.deviceType=`bot`,t.platform=`other`},re=(e,t)=>{t.appName=`oBot`,t.appVersion=e.value,t.deviceBrand=`IBM`,t.deviceType=`bot`,t.platform=`other`},ie=(e,t)=>{t.appName=`Cincraw`,t.appVersion=e.value,t.deviceBrand=`CINC`,t.deviceType=`bot`,t.platform=`other`},ae=(e,t)=>{t.appName=`DingTalkBot`,t.appVersion=e.value,t.deviceBrand=`Alibaba`,t.deviceType=`bot`,t.platform=`other`},oe=(e,t)=>{t.appName=`YisouSpider`,t.appVersion=e.value,t.deviceBrand=`Alibaba`,t.deviceType=`bot`,t.platform=`other`},se=(e,t)=>{t.appName=`ByteSpider`,t.appVersion=e.value,t.deviceBrand=`ByteDance`,t.deviceType=`bot`,t.platform=`other`},ce=(e,t)=>{t.appName=`HeadlineCrawler`,t.appVersion=e.value,t.deviceBrand=`Headline.com`,t.deviceType=`bot`,t.platform=`other`},le=(e,t)=>{t.appName=`BitDiscoveryBot`,t.appVersion=e.value,t.deviceBrand=`Tenable`,t.deviceType=`bot`,t.platform=`other`},ue=(e,t)=>{e.getPreviousNTokens(4)===`Screaming Frog SEO Spider`&&(t.deviceBrand=`Screaming Frog`,t.appName=`Screaming Frog`),t.appVersion=e.value,t.deviceType=`bot`},de=(e,t)=>{t.appName=`Ai2Bot`,t.appVersion=e.value,t.deviceBrand=`Ai2`,t.deviceType=`bot`,t.platform=`other`},fe=(e,t)=>{t.appName=`DianjingAdSpider`,t.appVersion=e.value,t.deviceBrand=`Dianjing`,t.deviceType=`bot`,t.platform=`other`},_=(e,t)=>{t.appName=`BaiduSpider`,t.appVersion=e.value,t.deviceBrand=`Baidu`,t.deviceType=`bot`,t.platform=`other`},v=(e,t)=>{t.appName=`360 Spider`,t.appVersion=e.value,t.deviceBrand=`360`,t.deviceType=`bot`,t.platform=`other`},pe=(e,t)=>{t.appName=`BingBot`,t.appVersion=e.value,t.deviceBrand=`Microsoft`,t.deviceType=`bot`,t.platform=`other`},me=(e,t)=>{t.appName=`Googlebot`,t.appVersion=e.value,t.deviceBrand=`Google`,t.deviceType=`bot`,t.platform=`other`},he=(e,t)=>{t.appName=`YandexBot`,t.appVersion=e.value,t.deviceBrand=`Yandex`,t.deviceType=`bot`,t.platform=`other`},ge=(e,t)=>{e.getPreviousNTokens(3)===`Sogou web spider`&&(t.deviceBrand=`Sogou.com`,t.appName=`SogouSpider`),t.appVersion=e.value,t.deviceType=`bot`},_e=(e,t)=>{t.appName=`DataproviderBot`,t.appVersion=e.value,t.deviceBrand=`Dataprovider.com`,t.deviceType=`bot`,t.platform=`other`},ve=(e,t)=>{t.appName=`AhrefsBot`,t.appVersion=e.value,t.deviceBrand=`Ahrefs`,t.deviceType=`bot`,t.platform=`other`},ye=(e,t)=>{t.appName=`BitSightBot`,t.appVersion=e.value,t.deviceBrand=`Bitsight`,t.deviceType=`bot`,t.platform=`other`},be=(e,t)=>{t.appName=`oBot`,t.appVersion=e.value,t.deviceBrand=`IBM`,t.deviceType=`bot`,t.platform=`other`},xe=(e,t)=>{t.appName=`Cincraw`,t.appVersion=e.value,t.deviceBrand=`CINC`,t.deviceType=`bot`,t.platform=`other`},Se=(e,t)=>{t.appName=`DingTalkBot`,t.appVersion=e.value,t.deviceBrand=`Alibaba`,t.deviceType=`bot`,t.platform=`other`},Ce=(e,t)=>{t.appName=`YisouSpider`,t.appVersion=e.value,t.deviceBrand=`Alibaba`,t.deviceType=`bot`,t.platform=`other`},we=(e,t)=>{t.appName=`ByteSpider`,t.appVersion=e.value,t.deviceBrand=`ByteDance`,t.deviceType=`bot`,t.platform=`other`},Te=(e,t)=>{t.appName=`HeadlineCrawler`,t.appVersion=e.value,t.deviceBrand=`Headline.com`,t.deviceType=`bot`,t.platform=`other`},Ee=(e,t)=>{t.appName=`BitDiscoveryBot`,t.appVersion=e.value,t.deviceBrand=`Tenable`,t.deviceType=`bot`,t.platform=`other`},De=(e,t)=>{e.getPreviousNTokens(4)===`Screaming Frog SEO Spider`&&(t.deviceBrand=`Screaming Frog`,t.appName=`Screaming Frog`),t.appVersion=e.value,t.deviceType=`bot`},Oe=(e,t)=>{t.appName=`Ai2Bot`,t.appVersion=e.value,t.deviceBrand=`Ai2`,t.deviceType=`bot`,t.platform=`other`},ke=(e,t)=>{t.appName=`DianjingAdSpider`,t.appVersion=e.value,t.deviceBrand=`Dianjing`,t.deviceType=`bot`,t.platform=`other`},y=new Map,b=new Map;function Ae(){y.set(`Baiduspider-render`,d),y.set(`Baiduspider+`,d),y.set(`Baiduspider-image+`,d),y.set(`360Spider`,f),y.set(`360Spider-Image`,f),y.set(`bingbot`,p),y.set(`Googlebot`,m),y.set(`YandexRenderResourcesBot`,h),y.set(`spider`,g),y.set(`Dataprovider.com`,ee),y.set(`AhrefsBot`,te),y.set(`BitSightBot`,ne),y.set(`oBot`,re),y.set(`Cincraw`,ie),y.set(`DingTalkBot-LinkService`,ae),y.set(`YisouSpider`,oe),y.set(`Bytespider`,se),y.set(`ev-crawler`,ce),y.set(`bitdiscovery`,le),y.set(`Spider`,ue),y.set(`Ai2Bot-Dolma`,de),y.set(`dianjing_ad_spider`,fe),b.set(`Baiduspider-render`,_),b.set(`Baiduspider+`,_),b.set(`Baiduspider-image+`,_),b.set(`360Spider`,v),b.set(`360Spider-Image`,v),b.set(`bingbot`,pe),b.set(`Googlebot`,me),b.set(`YandexRenderResourcesBot`,he),b.set(`spider`,ge),b.set(`Dataprovider.com`,_e),b.set(`AhrefsBot`,ve),b.set(`BitSightBot`,ye),b.set(`oBot`,be),b.set(`Cincraw`,xe),b.set(`DingTalkBot-LinkService`,Se),b.set(`YisouSpider`,Ce),b.set(`Bytespider`,we),b.set(`ev-crawler`,Te),b.set(`bitdiscovery`,Ee),b.set(`Spider`,De),b.set(`Ai2Bot-Dolma`,Oe),b.set(`dianjing_ad_spider`,ke)}Ae();const je={productHandlerMap:y,commentHandlerMap:b,getSpecialProductHandler:()=>null,getSpecialCommentHandler:()=>null,getDefaultModelHandler:()=>null};function Me(e){let t=n();return u(e,t,je),t.deviceType===`bot`}function Ne(e){return Me(e)}function x(){return typeof globalThis<`u`&&globalThis?globalThis:typeof window<`u`&&window?window:typeof self<`u`&&self?self:{}}function S(e,t){return t&&Object.keys(t).forEach(n=>{e[n]=t[n]}),e}function C(e){return Object.prototype.toString.call(e)===`[object Object]`}function w(e,t){return!C(e)||!C(t)?!1:Object.keys(e).every(n=>{let r=e[n],i=t[n];return C(r)?w(r,i):r===i})}function T(e){let t=Object.prototype.toString.call(e);if(t===`[object String]`)return e?String(e):void 0;if(t===`[object Number]`||t===`[object Boolean]`)return String(e);if(t===`[object Object]`||t===`[object Array]`)try{return JSON.stringify(e)}catch(e){return}}function Pe(e){let t={};return Object.keys(e).forEach(n=>{let r=e[n];if(r===void 0)return;let i=T(r);i!==void 0&&(t[n]=i)}),t}function E(e=20,t=``){if(!e)return t;let n=Math.floor(Math.random()*60);return E(e-1,`0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz`.charAt(n)+t)}function Fe(e,t){let n;return function(){if(n)return;let r=Array.prototype.slice.call(arguments);n=setTimeout(()=>{n=void 0},t),e.apply(this,r)}}function Ie(e){try{let t=x().requestIdleCallback;if(typeof t==`function`){t(e,{timeout:1e3});return}}catch(e){}setTimeout(e,0)}function D(e){return!!e&&typeof e.then==`function`}function Le(){try{return typeof location<`u`&&location.href.indexOf(`aes_debug`)>-1}catch(e){return!1}}function Re(){try{return typeof navigator>`u`||!navigator.userAgent?!1:Ne(navigator.userAgent)}catch(e){return!1}}const ze=`brands,fullVersionList,mobile,model,platform,platformVersion`.split(`,`);function Be(e){if(e.getConfig(`collectClientHints`)!==!1)try{if(typeof navigator>`u`)return;let t=navigator.userAgentData;if(!t||typeof t.getHighEntropyValues!=`function`)return;let n=t.getHighEntropyValues(ze);if(!D(n)||typeof Promise!=`function`)return;let r=!1,i=new Promise(i=>{let a=()=>{r||(r=!0,i())};n.then(n=>{O(e,n,t),a()},()=>{O(e,t,t),a()}),setTimeout(a,2e3)});typeof e.before==`function`&&typeof e.log==`function`&&(e.log=e.before(e.log,(e,t,n)=>r?[e,t,n]:i.then(()=>[e,t,n])))}catch(e){return}}function O(e,t,n){let r=Ve(t,n);r&&e.setConfig({user_agent_data:r})}function Ve(e,t){let n=e&&Object(e),r={mobile:k(n,t,`mobile`),model:k(n,t,`model`),platform:k(n,t,`platform`),platformVersion:k(n,t,`platformVersion`)},i=k(n,t,`fullVersionList`),a=k(n,t,`brands`);He(i)?r.fullVersionList=i:r.brands=a;try{let e=JSON.stringify(r);return e===`{}`?void 0:e}catch(e){return}}function He(e){return!!e&&e.length>0}function k(e,t,n){return e[n]===void 0?t[n]:e[n]}function Ue(e){if(e.getConfig(`excludeCrawlers`)!==!0||!Re())return;let t=e.send;e.send=e.before(t,()=>K)}const A=3*1024*1024,j=4096,M=`AEM_TRACKER_UNIQUE_PVID`,We={collectClientHints:!0,debug:!0,endpoint:!0,excludeCrawlers:!0,logstore:!0,maxLogsPerRequest:!0,maxPayloadSize:!0,maxQueueLength:!0,maxUrlLength:!0,mergeRequestInterval:!0,project:!0,queueGlobalName:!0,requiredFields:!0};function Ge(){let e={collectClientHints:!0,debug:Le(),endpoint:`log-global.aliyuncs.com`,excludeCrawlers:!1,hash:I(),language:R(`language`),logstore:`raw-records`,maxLogsPerRequest:j,maxPayloadSize:A,maxQueueLength:50,mergeRequestInterval:500,origin_url:F(),platform:`web`,project:`aem-se-sg`,queueGlobalName:`AES_QUEUE`,sdk_version:`0.1.0-beta.2`,sr:et(),title:L(),timezone_offset:new Date().getTimezoneOffset(),ua:R(`userAgent`)},t=$e();return t!==void 0&&(e.dpi=t),Xe(e),Ye(e),e}function Ke(e){let t=Ge();return S(t,Qe()),S(t,Ze()),S(t,e),t}function N(e){let t=String(e.project||`aem-se-sg`),n=String(e.endpoint||`log-global.aliyuncs.com`),r=String(e.logstore||`raw-records`);return`https://`+t+`.`+n+`/logstores/`+r+`/track`}function qe(e){let t={};return Object.keys(e).forEach(n=>{if(We[n]||n.indexOf(`plugin`)===0)return;let r=e[n];if(r===``||r==null)return;let i=T(r);i!==void 0&&(t[n]=i)}),t}function Je(e){let t={},n=I(),r=F(),i=L();return n!==void 0&&n!==e.hash&&(t.hash=n),r!==void 0&&r!==e.origin_url&&(t.origin_url=r),i!==void 0&&i!==e.title&&(t.title=i),t}function Ye(e){S(e,P())}function P(){let e={},t=tt();return t?(t.effectiveType&&(e.net_type=t.effectiveType),t.downlink!==void 0&&(e.downlink=t.downlink),e):e}function Xe(e){Object.defineProperty(e,"pv_id",{configurable:!0,enumerable:!0,get(){let e=x();return e.AEM_TRACKER_UNIQUE_PVID||(e[M]=E()),String(e[M])},set(e){x()[M]=e}})}function Ze(){try{if(typeof window<`u`)return window.AES_CONFIG}catch(e){return}}function Qe(){let e={};try{if(typeof document>`u`)return e;let t=document.querySelector(`meta[name="aes-config"]`),n=t&&t.getAttribute(`content`);if(!n)return e;n.split(`&`).forEach(t=>{let n=t.split(`=`),r=n[0],i=n[1];if(!r)return;let a=i===void 0?``:decodeURIComponent(i),o=r.indexOf(`.`);if(o===-1){e[r]=a;return}let s=r.slice(0,o),c=r.slice(o+1),l=e[s]||{};l[c]=a,e[s]=l})}catch(t){return e}return e}function F(){try{return typeof location<`u`?location.href:void 0}catch(e){return}}function I(){try{return typeof location<`u`?location.hash:void 0}catch(e){return}}function L(){try{return typeof document<`u`?document.title:void 0}catch(e){return}}function R(e){try{return typeof navigator<`u`?navigator[e]:void 0}catch(e){return}}function $e(){try{return typeof window<`u`?window.devicePixelRatio:void 0}catch(e){return}}function et(){try{return typeof screen>`u`?void 0:String(screen.width)+`x`+String(screen.height)}catch(e){return}}function tt(){try{if(typeof navigator>`u`)return;let e=navigator;return e.connection||e.mozConnection||e.webkitConnection}catch(e){return}}function z(e,t){let n=[];return e.forEach(e=>{let r={};Object.keys(t).forEach(e=>{r[e]=t[e]}),Object.keys(e).forEach(t=>{r[t]=e[t]});let i=nt(t.ext,e.ext);i!==void 0&&(r.ext=i),n.push(r)}),{__logs__:n,__source__:`web-sdk`,__topic__:`/aes.1.1`}}function nt(e,t){if(e===void 0)return t;if(t===void 0)return e;let n=B(e),r=B(t);if(!n||!r)return t;let i=Object.create(null);return Object.keys(n).forEach(e=>{i[e]=n[e]}),Object.keys(r).forEach(e=>{i[e]=r[e]}),JSON.stringify(i)}function B(e){try{let t=JSON.parse(e);if(Object.prototype.toString.call(t)===`[object Object]`)return t}catch(e){return}}function V(e,t,n){return{body:JSON.stringify(t),mode:n,url:e}}function H(e){!rt(e.url,e.body)&&e.mode!==`pagehide`&&it(e.url,e.body)}function rt(e,t){try{return typeof navigator>`u`||typeof navigator.sendBeacon!=`function`?!1:navigator.sendBeacon(e,at(t))===!0}catch(e){return!1}}function it(e,t){try{if(typeof XMLHttpRequest>`u`)return;let n=new XMLHttpRequest;n.open(`POST`,e,!0),n.setRequestHeader(`Content-Type`,`text/plain`),n.send(t)}catch(e){return}}function at(e){try{if(typeof Blob==`function`)return new Blob([e],{type:`text/plain`})}catch(t){return e}return e}var ot=class{constructor(e){st(this,{getCommonFields:e.getCommonFields,getConfig:e.getConfig,getUrl:e.getUrl,logs:[],sendRequest:e.sendRequest,timeout:void 0})}push(e){let t=W(this);if(t.logs.push(e),t.logs.length>=G(t.getConfig().maxQueueLength,50)){this.flush(`normal`);return}if(!t.timeout){let e=G(t.getConfig().mergeRequestInterval,500);t.timeout=setTimeout(()=>{this.flush(`normal`)},e)}}sendSingle(e){this.sendLogs([e],`normal`)}flush(e=`normal`){let t=W(this);if(t.timeout&&(clearTimeout(t.timeout),t.timeout=void 0),!t.logs.length)return;let n=t.logs.slice();t.logs=[],this.sendLogs(n,e)}sendLogs(e,t){let n=W(this),r=n.getCommonFields(),i=n.getUrl(),a=n.getConfig(),o=ct(a),s=G(a.maxLogsPerRequest,j),c=[];for(let a=0;a<e.length;a+=1){let l=e[a],u=c.concat([l]),d=V(i,z(u,r),t);c.length&&(d.body.length>o||u.length>s)?(n.sendRequest(V(i,z(c,r),t)),c=[l]):c=u}c.length&&n.sendRequest(V(i,z(c,r),t))}};const U=`__aemQueueState`;function st(e,t){Object.defineProperty(e,U,{configurable:!1,enumerable:!1,value:t})}function W(e){return e[U]}function G(e,t){let n=Number(e);return n>0?n:t}function ct(e){let t=G(e.maxPayloadSize,A);return t===3145728?G(e.maxUrlLength,A):t}const K=Object.freeze({__aesBeforeSkip:1});var q=class{constructor(e={}){let t={config:Ke(e),currentRequest:void 0,offlineQueue:[],plugins:[],reqQueue:[],subscribers:{onConfigUpdated:[]},queue:void 0};t.queue=new ot({getCommonFields:()=>qe(t.config),getConfig:()=>t.config,getUrl:()=>N(t.config),sendRequest:e=>{this.dispatchRequest(e)}}),dt(this,t),this.use(Ue),this.use(Be),ht(this),gt(this),_t(this),vt(this),yt(this),xt(this)}log(e,t={},n={}){if(!e)return;this.applyBrowserDynamicConfig();let r={};Object.keys(t).forEach(e=>{if(e===`ts`){r.client_ts===void 0&&(r.client_ts=t[e]);return}r[e]=t[e]}),r.client_ts===void 0&&(r.client_ts=new Date().getTime()),r.type=e,this.print(`[AES] log`,e,r);let i=Pe(r),a=Z(this);if(ft(a.config)){a.reqQueue.length<1e3&&a.reqQueue.push({combo:n.combo,log:i});return}this.enqueue(i,n.combo)}setConfig(e,t){let n={};t!==void 0&&typeof e==`string`?n[e]=t:C(e)&&S(n,e),this.updateConfig(n)}getConfig(e){let t=Z(this).config;return e?t[e]:t}use(e,t){return Object.prototype.toString.call(e)===`[object Array]`?e.map(e=>{if(Object.prototype.toString.call(e)===`[object Array]`){let t=e;return Q(this,t[0],t[1])}return Q(this,e)}):Q(this,e,t)}before(e,t){return(...n)=>{let r=t.apply(this,n);if(r!==K){if(D(r)){r.then(t=>{t!==K&&e.apply(this,t||n)});return}e.apply(this,r||n)}}}after(e,t){return(...n)=>{e.apply(this,n),t.apply(this,n)}}updatePVID(){ut()}onConfigUpdated(e){Z(this).subscribers.onConfigUpdated.push(e)}send(e){let t=Z(this);if(J()){lt(t,e);return}H(t.currentRequest||{body:e,mode:`normal`,url:N(t.config)}),this.print(`[AES] send`,e)}sendTo(e,t){let n=Z(this).config,r=String(n.project||`aem-se-sg`),i=String(n.endpoint||`log-global.aliyuncs.com`),a=`https://`+r+`.`+i+`/logstores/`+e+`/track`;H({body:JSON.stringify({__topic__:t.topic,__logs__:t.logs}),mode:`normal`,url:a})}_sendAll(){bt(this,`normal`)}enqueue(e,t){let n=Z(this).queue;n&&(t===!1?n.sendSingle(e):n.push(e))}dispatchRequest(e){let t=Z(this);t.currentRequest=e;try{this.send(e.body)}finally{t.currentRequest=void 0}}updateConfig(e){let t=Z(this),n=!w(e,t.config),r=()=>{n&&(Object.keys(e).forEach(n=>{let r=e[n];if(C(r)){let e=C(t.config[n])?t.config[n]:{};t.config[n]=S(e,r)}else t.config[n]=r}),pt(t,e))};if(t.reqQueue.length){if(r(),!ft(t.config)){let e=t.reqQueue.slice();t.reqQueue=[],e.forEach(e=>{this.enqueue(e.log,e.combo)})}return}if(n){var i;(i=t.queue)==null||i.flush(`normal`)}r()}applyBrowserDynamicConfig(){let e=Je(Z(this).config);Object.keys(e).length&&this.updateConfig(e)}print(...e){Z(this).config.debug&&typeof console<`u`&&console.log.apply(console,e)}};function lt(e,t){e.offlineQueue.length>500&&e.offlineQueue.shift(),e.offlineQueue.push(t)}function J(){try{return typeof navigator<`u`&&navigator.onLine===!1}catch(e){return!1}}function Y(e){if(J())return;let t=Z(e);if(!t.offlineQueue.length)return;let n=t.offlineQueue.slice();t.offlineQueue=[],n.forEach(t=>{Ie(()=>{e.send(t)})})}const X=`__aemTrackerState`,ut=Fe(()=>{x()[M]=E()},200);function dt(e,t){Object.defineProperty(e,X,{configurable:!1,enumerable:!1,value:t})}function Z(e){return e[X]}function ft(e){return(e.requiredFields||[]).concat([`pid`]).some(t=>e[t]===void 0)}function pt(e,t){e.subscribers.onConfigUpdated.forEach(n=>{n(t,e.config)})}function Q(e,t,n){let r=Z(e),i=r.plugins.filter(e=>e.plugin===t)[0];if(i)return i.instance;let a;try{a=new t(e,n)}catch(r){if(!mt(r))throw r;a=t(e,n)}return r.plugins.push({instance:a,plugin:t}),a}function mt(e){return e instanceof TypeError?String(e.message).indexOf(`not a constructor`)!==-1:!1}function ht(e){try{if(typeof window>`u`||!window.addEventListener)return;window.addEventListener(`hashchange`,()=>{e.setConfig({hash:location.hash})})}catch(e){return}}function gt(e){try{if(typeof navigator>`u`)return;let t=navigator,n=t.connection||t.mozConnection||t.webkitConnection;if(!n||typeof n.addEventListener!=`function`)return;n.addEventListener(`change`,()=>{let t=P();Object.keys(t).length&&e.setConfig(t),Y(e)})}catch(e){return}}function _t(e){try{if(typeof window>`u`||!window.addEventListener)return;window.addEventListener(`online`,()=>{Y(e)})}catch(e){return}}function vt(e){try{if(typeof document>`u`||typeof MutationObserver>`u`)return;let t=()=>{let t=document.querySelector(`title`);t&&new MutationObserver(()=>{e.setConfig({title:document.title})}).observe(t,{characterData:!0,childList:!0,subtree:!0})};document.querySelector(`title`)?t():document.addEventListener(`DOMContentLoaded`,t)}catch(e){return}}function yt(e){try{if(typeof window>`u`||!window.addEventListener)return;window.addEventListener(`pagehide`,()=>{bt(e,`pagehide`)})}catch(e){return}}function bt(e,t){var n;(n=Z(e).queue)==null||n.flush(t)}function xt(e){try{if(typeof window>`u`)return;let t=String(e.getConfig(`queueGlobalName`)||`AES_QUEUE`),n=window,r=n[t],i=Object.prototype.toString.call(r)===`[object Array]`?r:[];i.forEach(t=>{$(e,t)});let a=i.push.bind(i);i.push=function(t){return $(e,t),a(t)},n[t]=i}catch(e){return}}function $(e,t){if(typeof t==`function`){t(e);return}let n=t;if(!n||typeof n.action!=`string`)return;let r=e[n.action];typeof r==`function`&&r.apply(e,n.arguments||[])}export{q as AES,q as default,K as AES_SKIP_BEFORE_ORIGIN};
|
|
1
|
+
function e(e){let n=[],r={parent:e,tokens:n,get firstToken(){return n.length===0?null:n[0]},getNewToken(i){let a=t();return n.push(a),a.previousToken=i===void 0?n.length>1?n[n.length-2]:null:i,e&&(e.properties=r),a},getLastToken(){return n.length===0?null:n[n.length-1]},getFirstToken(){return n.length===0?null:n[0]},isEmpty(){return n.length===0}};return r}function t(){let e=[],t=[],n=[],r=null,i=null,a=null,o=!0,s=!0,c=!0,l=null,u={get key(){return o&&(r=e.join(``),o=!1),r},get value(){return s&&(i=t.join(``),s=!1),i},get originValue(){return c&&(a=n.join(``),c=!1),a},previousToken:null,properties:null,appendKey(t){e.push(t),o=!0},appendValue(e){t.push(e===`_`?`.`:e),n.push(e),s=!0,c=!0,l=null},getSplitValue(e){if(l===null){let e=u.value;l=e===``?[]:e.split(`/`)}return e>=0&&e<l.length?l[e]:null},getPreviousNTokens(e){let t=[],n=u;for(let r=0;r<e;r++){if(n==null)return null;t.unshift(n.key),n=n.previousToken}return t.join(` `)}};return u}function n(){return{appName:null,appVersion:null,browserName:null,browserVersion:null,engineName:null,engineVersion:null,deviceBrand:null,deviceModel:null,deviceType:`mobile`,osName:null,osVersion:null,platform:`web`,tokenGroup:e(null)}}const r=new Set(` ;,"'`.split(``)),i=new Set(`/=:`.split(``)),a=new Set([`Mozilla`,`AppleWebKit`,`Safari`,`Opera`,`Dalvik`,`com.ss.android.ugc.aweme`]);function o(e){return e.length===1&&r.has(e)}function s(e){return e.length===1&&i.has(e)}function c(e,t,n,r){if(e==null)return;let i=t.parent,o=e.key,s=null;if(i!=null){let e=i.key;if(a.has(e)){var c;s=(c=r.commentHandlerMap.get(o))==null?null:c,s==null&&(s=r.getSpecialCommentHandler(o)),s==null&&o.endsWith(` Build`)&&(s=r.getDefaultModelHandler())}else{var l;s=(l=r.productHandlerMap.get(o))==null?r.getSpecialProductHandler(o):l}}else{var u;s=(u=r.productHandlerMap.get(o))==null?r.getSpecialProductHandler(o):u}if(s!=null)try{s(e,n)}catch(e){}}function l(t,n,r,i,a){let u=null,d=null,f,p=!1,m=t.length,h=n>0?t[n-1]:`\0`;for(f=n;f<m;f++){let g=t[f];if(o(g)){let e=h!==`\0`&&o(h);if(!p&&n>0&&g===` `&&!e){let e=f+1;if(e<m){let n=t[e];/\d/.test(n)||n===`-`?p=!0:d!=null&&d.appendKey(g)}else d!=null&&d.appendKey(g)}else d!=null&&(u=d,d=null);h=g}else if(g===`(`){if(h===`(`){h=g;continue}let n=e(r.getLastToken()),o=f;f=l(t,f+1,n,i,a),d!=null&&(u=d,d=null),h=t[o]}else if(g===`)`){if(n===0){h=g;continue}break}else d==null&&(c(r.getLastToken(),r,i,a),d=r.getNewToken(u),p=!1),s(g)?(p&&d.appendValue(g),p=!0):p?d.appendValue(g):d.appendKey(g),h=g}return c(r.getLastToken(),r,i,a),f}function u(e,t,n){if(e==null)throw Error(`input can not be null`);return l(e,0,t.tokenGroup,t,n),t}const d=(e,t)=>{t.appName=`BaiduSpider`,t.appVersion=e.value,t.deviceBrand=`Baidu`,t.deviceType=`bot`,t.platform=`other`},f=(e,t)=>{t.appName=`360 Spider`,t.appVersion=e.value,t.deviceBrand=`360`,t.deviceType=`bot`,t.platform=`other`},p=(e,t)=>{t.appName=`BingBot`,t.appVersion=e.value,t.deviceBrand=`Microsoft`,t.deviceType=`bot`,t.platform=`other`},m=(e,t)=>{t.appName=`Googlebot`,t.appVersion=e.value,t.deviceBrand=`Google`,t.deviceType=`bot`,t.platform=`other`},h=(e,t)=>{t.appName=`YandexBot`,t.appVersion=e.value,t.deviceBrand=`Yandex`,t.deviceType=`bot`,t.platform=`other`},g=(e,t)=>{e.getPreviousNTokens(3)===`Sogou web spider`&&(t.deviceBrand=`Sogou.com`,t.appName=`SogouSpider`),t.appVersion=e.value,t.deviceType=`bot`},ee=(e,t)=>{t.appName=`DataproviderBot`,t.appVersion=e.value,t.deviceBrand=`Dataprovider.com`,t.deviceType=`bot`,t.platform=`other`},te=(e,t)=>{t.appName=`AhrefsBot`,t.appVersion=e.value,t.deviceBrand=`Ahrefs`,t.deviceType=`bot`,t.platform=`other`},ne=(e,t)=>{t.appName=`BitSightBot`,t.appVersion=e.value,t.deviceBrand=`Bitsight`,t.deviceType=`bot`,t.platform=`other`},re=(e,t)=>{t.appName=`oBot`,t.appVersion=e.value,t.deviceBrand=`IBM`,t.deviceType=`bot`,t.platform=`other`},ie=(e,t)=>{t.appName=`Cincraw`,t.appVersion=e.value,t.deviceBrand=`CINC`,t.deviceType=`bot`,t.platform=`other`},ae=(e,t)=>{t.appName=`DingTalkBot`,t.appVersion=e.value,t.deviceBrand=`Alibaba`,t.deviceType=`bot`,t.platform=`other`},oe=(e,t)=>{t.appName=`YisouSpider`,t.appVersion=e.value,t.deviceBrand=`Alibaba`,t.deviceType=`bot`,t.platform=`other`},se=(e,t)=>{t.appName=`ByteSpider`,t.appVersion=e.value,t.deviceBrand=`ByteDance`,t.deviceType=`bot`,t.platform=`other`},ce=(e,t)=>{t.appName=`HeadlineCrawler`,t.appVersion=e.value,t.deviceBrand=`Headline.com`,t.deviceType=`bot`,t.platform=`other`},le=(e,t)=>{t.appName=`BitDiscoveryBot`,t.appVersion=e.value,t.deviceBrand=`Tenable`,t.deviceType=`bot`,t.platform=`other`},ue=(e,t)=>{e.getPreviousNTokens(4)===`Screaming Frog SEO Spider`&&(t.deviceBrand=`Screaming Frog`,t.appName=`Screaming Frog`),t.appVersion=e.value,t.deviceType=`bot`},de=(e,t)=>{t.appName=`Ai2Bot`,t.appVersion=e.value,t.deviceBrand=`Ai2`,t.deviceType=`bot`,t.platform=`other`},fe=(e,t)=>{t.appName=`DianjingAdSpider`,t.appVersion=e.value,t.deviceBrand=`Dianjing`,t.deviceType=`bot`,t.platform=`other`},_=(e,t)=>{t.appName=`BaiduSpider`,t.appVersion=e.value,t.deviceBrand=`Baidu`,t.deviceType=`bot`,t.platform=`other`},v=(e,t)=>{t.appName=`360 Spider`,t.appVersion=e.value,t.deviceBrand=`360`,t.deviceType=`bot`,t.platform=`other`},pe=(e,t)=>{t.appName=`BingBot`,t.appVersion=e.value,t.deviceBrand=`Microsoft`,t.deviceType=`bot`,t.platform=`other`},me=(e,t)=>{t.appName=`Googlebot`,t.appVersion=e.value,t.deviceBrand=`Google`,t.deviceType=`bot`,t.platform=`other`},he=(e,t)=>{t.appName=`YandexBot`,t.appVersion=e.value,t.deviceBrand=`Yandex`,t.deviceType=`bot`,t.platform=`other`},ge=(e,t)=>{e.getPreviousNTokens(3)===`Sogou web spider`&&(t.deviceBrand=`Sogou.com`,t.appName=`SogouSpider`),t.appVersion=e.value,t.deviceType=`bot`},_e=(e,t)=>{t.appName=`DataproviderBot`,t.appVersion=e.value,t.deviceBrand=`Dataprovider.com`,t.deviceType=`bot`,t.platform=`other`},ve=(e,t)=>{t.appName=`AhrefsBot`,t.appVersion=e.value,t.deviceBrand=`Ahrefs`,t.deviceType=`bot`,t.platform=`other`},ye=(e,t)=>{t.appName=`BitSightBot`,t.appVersion=e.value,t.deviceBrand=`Bitsight`,t.deviceType=`bot`,t.platform=`other`},be=(e,t)=>{t.appName=`oBot`,t.appVersion=e.value,t.deviceBrand=`IBM`,t.deviceType=`bot`,t.platform=`other`},xe=(e,t)=>{t.appName=`Cincraw`,t.appVersion=e.value,t.deviceBrand=`CINC`,t.deviceType=`bot`,t.platform=`other`},Se=(e,t)=>{t.appName=`DingTalkBot`,t.appVersion=e.value,t.deviceBrand=`Alibaba`,t.deviceType=`bot`,t.platform=`other`},Ce=(e,t)=>{t.appName=`YisouSpider`,t.appVersion=e.value,t.deviceBrand=`Alibaba`,t.deviceType=`bot`,t.platform=`other`},we=(e,t)=>{t.appName=`ByteSpider`,t.appVersion=e.value,t.deviceBrand=`ByteDance`,t.deviceType=`bot`,t.platform=`other`},Te=(e,t)=>{t.appName=`HeadlineCrawler`,t.appVersion=e.value,t.deviceBrand=`Headline.com`,t.deviceType=`bot`,t.platform=`other`},Ee=(e,t)=>{t.appName=`BitDiscoveryBot`,t.appVersion=e.value,t.deviceBrand=`Tenable`,t.deviceType=`bot`,t.platform=`other`},De=(e,t)=>{e.getPreviousNTokens(4)===`Screaming Frog SEO Spider`&&(t.deviceBrand=`Screaming Frog`,t.appName=`Screaming Frog`),t.appVersion=e.value,t.deviceType=`bot`},Oe=(e,t)=>{t.appName=`Ai2Bot`,t.appVersion=e.value,t.deviceBrand=`Ai2`,t.deviceType=`bot`,t.platform=`other`},ke=(e,t)=>{t.appName=`DianjingAdSpider`,t.appVersion=e.value,t.deviceBrand=`Dianjing`,t.deviceType=`bot`,t.platform=`other`},y=new Map,b=new Map;function Ae(){y.set(`Baiduspider-render`,d),y.set(`Baiduspider+`,d),y.set(`Baiduspider-image+`,d),y.set(`360Spider`,f),y.set(`360Spider-Image`,f),y.set(`bingbot`,p),y.set(`Googlebot`,m),y.set(`YandexRenderResourcesBot`,h),y.set(`spider`,g),y.set(`Dataprovider.com`,ee),y.set(`AhrefsBot`,te),y.set(`BitSightBot`,ne),y.set(`oBot`,re),y.set(`Cincraw`,ie),y.set(`DingTalkBot-LinkService`,ae),y.set(`YisouSpider`,oe),y.set(`Bytespider`,se),y.set(`ev-crawler`,ce),y.set(`bitdiscovery`,le),y.set(`Spider`,ue),y.set(`Ai2Bot-Dolma`,de),y.set(`dianjing_ad_spider`,fe),b.set(`Baiduspider-render`,_),b.set(`Baiduspider+`,_),b.set(`Baiduspider-image+`,_),b.set(`360Spider`,v),b.set(`360Spider-Image`,v),b.set(`bingbot`,pe),b.set(`Googlebot`,me),b.set(`YandexRenderResourcesBot`,he),b.set(`spider`,ge),b.set(`Dataprovider.com`,_e),b.set(`AhrefsBot`,ve),b.set(`BitSightBot`,ye),b.set(`oBot`,be),b.set(`Cincraw`,xe),b.set(`DingTalkBot-LinkService`,Se),b.set(`YisouSpider`,Ce),b.set(`Bytespider`,we),b.set(`ev-crawler`,Te),b.set(`bitdiscovery`,Ee),b.set(`Spider`,De),b.set(`Ai2Bot-Dolma`,Oe),b.set(`dianjing_ad_spider`,ke)}Ae();const je={productHandlerMap:y,commentHandlerMap:b,getSpecialProductHandler:()=>null,getSpecialCommentHandler:()=>null,getDefaultModelHandler:()=>null};function Me(e){let t=n();return u(e,t,je),t.deviceType===`bot`}function Ne(e){return Me(e)}function x(){return typeof globalThis<`u`&&globalThis?globalThis:typeof window<`u`&&window?window:typeof self<`u`&&self?self:{}}function S(e,t){return t&&Object.keys(t).forEach(n=>{e[n]=t[n]}),e}function C(e){return Object.prototype.toString.call(e)===`[object Object]`}function w(e,t){return!C(e)||!C(t)?!1:Object.keys(e).every(n=>{let r=e[n],i=t[n];return C(r)?w(r,i):r===i})}function T(e){let t=Object.prototype.toString.call(e);if(t===`[object String]`)return e?String(e):void 0;if(t===`[object Number]`||t===`[object Boolean]`)return String(e);if(t===`[object Object]`||t===`[object Array]`)try{return JSON.stringify(e)}catch(e){return}}function Pe(e){let t={};return Object.keys(e).forEach(n=>{let r=e[n];if(r===void 0)return;let i=T(r);i!==void 0&&(t[n]=i)}),t}function E(e=20,t=``){if(!e)return t;let n=Math.floor(Math.random()*60);return E(e-1,`0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz`.charAt(n)+t)}function Fe(e,t){let n;return function(){if(n)return;let r=Array.prototype.slice.call(arguments);n=setTimeout(()=>{n=void 0},t),e.apply(this,r)}}function Ie(e){try{let t=x().requestIdleCallback;if(typeof t==`function`){t(e,{timeout:1e3});return}}catch(e){}setTimeout(e,0)}function D(e){return!!e&&typeof e.then==`function`}function Le(){try{return typeof location<`u`&&location.href.indexOf(`aes_debug`)>-1}catch(e){return!1}}function Re(){try{return typeof navigator>`u`||!navigator.userAgent?!1:Ne(navigator.userAgent)}catch(e){return!1}}const ze=`brands,fullVersionList,mobile,model,platform,platformVersion`.split(`,`);function Be(e){if(e.getConfig(`collectClientHints`)!==!1)try{if(typeof navigator>`u`)return;let t=navigator.userAgentData;if(!t||typeof t.getHighEntropyValues!=`function`)return;let n=t.getHighEntropyValues(ze);if(!D(n)||typeof Promise!=`function`)return;let r=!1,i=new Promise(i=>{let a=()=>{r||(r=!0,i())};n.then(n=>{O(e,n,t),a()},()=>{O(e,t,t),a()}),setTimeout(a,2e3)});typeof e.before==`function`&&typeof e.log==`function`&&(e.log=e.before(e.log,(e,t,n)=>r?[e,t,n]:i.then(()=>[e,t,n])))}catch(e){return}}function O(e,t,n){let r=Ve(t,n);r&&e.setConfig({user_agent_data:r})}function Ve(e,t){let n=e&&Object(e),r={mobile:k(n,t,`mobile`),model:k(n,t,`model`),platform:k(n,t,`platform`),platformVersion:k(n,t,`platformVersion`)},i=k(n,t,`fullVersionList`),a=k(n,t,`brands`);He(i)?r.fullVersionList=i:r.brands=a;try{let e=JSON.stringify(r);return e===`{}`?void 0:e}catch(e){return}}function He(e){return!!e&&e.length>0}function k(e,t,n){return e[n]===void 0?t[n]:e[n]}function Ue(e){if(e.getConfig(`excludeCrawlers`)!==!0||!Re())return;let t=e.send;e.send=e.before(t,()=>K)}const A=3*1024*1024,j=4096,M=`AEM_TRACKER_UNIQUE_PVID`,We={collectClientHints:!0,debug:!0,endpoint:!0,excludeCrawlers:!0,logstore:!0,maxLogsPerRequest:!0,maxPayloadSize:!0,maxQueueLength:!0,maxUrlLength:!0,mergeRequestInterval:!0,project:!0,queueGlobalName:!0,requiredFields:!0};function Ge(){let e={collectClientHints:!0,debug:Le(),endpoint:`log-global.aliyuncs.com`,excludeCrawlers:!1,hash:I(),language:R(`language`),logstore:`raw-records`,maxLogsPerRequest:j,maxPayloadSize:A,maxQueueLength:50,mergeRequestInterval:500,origin_url:F(),platform:`web`,project:`aem-se-sg`,queueGlobalName:`AES_QUEUE`,sdk_version:`0.1.0-beta.3`,sr:tt(),title:L(),timezone_offset:new Date().getTimezoneOffset(),ua:R(`userAgent`)},t=et();return t!==void 0&&(e.dpi=t),Xe(e),Ye(e),e}function Ke(e){let t=Ge();return S(t,Qe()),S(t,Ze()),S(t,e),t}function N(e){let t=String(e.project||`aem-se-sg`),n=String(e.endpoint||`log-global.aliyuncs.com`),r=String(e.logstore||`raw-records`);return`https://`+t+`.`+n+`/logstores/`+r+`/track`}function qe(e){let t={};if(Object.keys(e).forEach(n=>{if(We[n]||n.indexOf(`plugin`)===0)return;let r=e[n];if(r===``||r==null)return;let i=T(r);i!==void 0&&(t[n]=i)}),!t.device_id){let e=$e(`cna`);e&&(t.device_id=e)}return t}function Je(e){let t={},n=I(),r=F(),i=L();return n!==void 0&&n!==e.hash&&(t.hash=n),r!==void 0&&r!==e.origin_url&&(t.origin_url=r),i!==void 0&&i!==e.title&&(t.title=i),t}function Ye(e){S(e,P())}function P(){let e={},t=nt();return t?(t.effectiveType&&(e.net_type=t.effectiveType),t.downlink!==void 0&&(e.downlink=t.downlink),e):e}function Xe(e){Object.defineProperty(e,"pv_id",{configurable:!0,enumerable:!0,get(){let e=x();return e.AEM_TRACKER_UNIQUE_PVID||(e[M]=E()),String(e[M])},set(e){x()[M]=e}})}function Ze(){try{if(typeof window<`u`)return window.AES_CONFIG}catch(e){return}}function Qe(){let e={};try{if(typeof document>`u`)return e;let t=document.querySelector(`meta[name="aes-config"]`),n=t&&t.getAttribute(`content`);if(!n)return e;n.split(`&`).forEach(t=>{let n=t.split(`=`),r=n[0],i=n[1];if(!r)return;let a=i===void 0?``:decodeURIComponent(i),o=r.indexOf(`.`);if(o===-1){e[r]=a;return}let s=r.slice(0,o),c=r.slice(o+1),l=e[s]||{};l[c]=a,e[s]=l})}catch(t){return e}return e}function F(){try{return typeof location<`u`?location.href:void 0}catch(e){return}}function I(){try{return typeof location<`u`?location.hash:void 0}catch(e){return}}function L(){try{return typeof document<`u`?document.title:void 0}catch(e){return}}function $e(e){try{if(typeof document>`u`||!document.cookie)return;let t=RegExp(`(?:^|; )`+e+`=([^;]*)`).exec(document.cookie);return t?t[1]:void 0}catch(e){return}}function R(e){try{return typeof navigator<`u`?navigator[e]:void 0}catch(e){return}}function et(){try{return typeof window<`u`?window.devicePixelRatio:void 0}catch(e){return}}function tt(){try{return typeof screen>`u`?void 0:String(screen.width)+`x`+String(screen.height)}catch(e){return}}function nt(){try{if(typeof navigator>`u`)return;let e=navigator;return e.connection||e.mozConnection||e.webkitConnection}catch(e){return}}function z(e,t){let n=[];return e.forEach(e=>{let r={};Object.keys(t).forEach(e=>{r[e]=t[e]}),Object.keys(e).forEach(t=>{r[t]=e[t]});let i=rt(t.ext,e.ext);i!==void 0&&(r.ext=i),n.push(r)}),{__logs__:n,__source__:`web-sdk`,__topic__:`/aes.1.1`}}function rt(e,t){if(e===void 0)return t;if(t===void 0)return e;let n=B(e),r=B(t);if(!n||!r)return t;let i=Object.create(null);return Object.keys(n).forEach(e=>{i[e]=n[e]}),Object.keys(r).forEach(e=>{i[e]=r[e]}),JSON.stringify(i)}function B(e){try{let t=JSON.parse(e);if(Object.prototype.toString.call(t)===`[object Object]`)return t}catch(e){return}}function V(e,t,n){return{body:JSON.stringify(t),mode:n,url:e}}function H(e){!it(e.url,e.body)&&e.mode!==`pagehide`&&at(e.url,e.body)}function it(e,t){try{return typeof navigator>`u`||typeof navigator.sendBeacon!=`function`?!1:navigator.sendBeacon(e,ot(t))===!0}catch(e){return!1}}function at(e,t){try{if(typeof XMLHttpRequest>`u`)return;let n=new XMLHttpRequest;n.open(`POST`,e,!0),n.setRequestHeader(`Content-Type`,`text/plain`),n.send(t)}catch(e){return}}function ot(e){try{if(typeof Blob==`function`)return new Blob([e],{type:`text/plain`})}catch(t){return e}return e}var st=class{constructor(e){ct(this,{getCommonFields:e.getCommonFields,getConfig:e.getConfig,getUrl:e.getUrl,logs:[],sendRequest:e.sendRequest,timeout:void 0})}push(e){let t=W(this);if(t.logs.push(e),t.logs.length>=G(t.getConfig().maxQueueLength,50)){this.flush(`normal`);return}if(!t.timeout){let e=G(t.getConfig().mergeRequestInterval,500);t.timeout=setTimeout(()=>{this.flush(`normal`)},e)}}sendSingle(e){this.sendLogs([e],`normal`)}flush(e=`normal`){let t=W(this);if(t.timeout&&(clearTimeout(t.timeout),t.timeout=void 0),!t.logs.length)return;let n=t.logs.slice();t.logs=[],this.sendLogs(n,e)}sendLogs(e,t){let n=W(this),r=n.getCommonFields(),i=n.getUrl(),a=n.getConfig(),o=lt(a),s=G(a.maxLogsPerRequest,j),c=[];for(let a=0;a<e.length;a+=1){let l=e[a],u=c.concat([l]),d=V(i,z(u,r),t);c.length&&(d.body.length>o||u.length>s)?(n.sendRequest(V(i,z(c,r),t)),c=[l]):c=u}c.length&&n.sendRequest(V(i,z(c,r),t))}};const U=`__aemQueueState`;function ct(e,t){Object.defineProperty(e,U,{configurable:!1,enumerable:!1,value:t})}function W(e){return e[U]}function G(e,t){let n=Number(e);return n>0?n:t}function lt(e){let t=G(e.maxPayloadSize,A);return t===3145728?G(e.maxUrlLength,A):t}const K=Object.freeze({__aesBeforeSkip:1});var q=class{constructor(e={}){let t={config:Ke(e),currentRequest:void 0,offlineQueue:[],plugins:[],reqQueue:[],subscribers:{onConfigUpdated:[]},queue:void 0};t.queue=new st({getCommonFields:()=>qe(t.config),getConfig:()=>t.config,getUrl:()=>N(t.config),sendRequest:e=>{this.dispatchRequest(e)}}),ft(this,t),this.use(Ue),this.use(Be),gt(this),_t(this),vt(this),yt(this),bt(this),St(this)}log(e,t={},n={}){if(!e)return;this.applyBrowserDynamicConfig();let r={};Object.keys(t).forEach(e=>{if(e===`ts`){r.client_ts===void 0&&(r.client_ts=t[e]);return}r[e]=t[e]}),r.client_ts===void 0&&(r.client_ts=new Date().getTime()),r.type=e,this.print(`[AES] log`,e,r);let i=Pe(r),a=Z(this);if(pt(a.config)){a.reqQueue.length<1e3&&a.reqQueue.push({combo:n.combo,log:i});return}this.enqueue(i,n.combo)}setConfig(e,t){let n={};t!==void 0&&typeof e==`string`?n[e]=t:C(e)&&S(n,e),this.updateConfig(n)}getConfig(e){let t=Z(this).config;return e?t[e]:t}use(e,t){return Object.prototype.toString.call(e)===`[object Array]`?e.map(e=>{if(Object.prototype.toString.call(e)===`[object Array]`){let t=e;return Q(this,t[0],t[1])}return Q(this,e)}):Q(this,e,t)}before(e,t){return(...n)=>{let r=t.apply(this,n);if(r!==K){if(D(r)){r.then(t=>{t!==K&&e.apply(this,t||n)});return}e.apply(this,r||n)}}}after(e,t){return(...n)=>{e.apply(this,n),t.apply(this,n)}}updatePVID(){dt()}onConfigUpdated(e){Z(this).subscribers.onConfigUpdated.push(e)}send(e){let t=Z(this);if(J()){ut(t,e);return}H(t.currentRequest||{body:e,mode:`normal`,url:N(t.config)}),this.print(`[AES] send`,e)}sendTo(e,t){let n=Z(this).config,r=String(n.project||`aem-se-sg`),i=String(n.endpoint||`log-global.aliyuncs.com`),a=`https://`+r+`.`+i+`/logstores/`+e+`/track`;H({body:JSON.stringify({__topic__:t.topic,__logs__:t.logs}),mode:`normal`,url:a})}_sendAll(){xt(this,`normal`)}enqueue(e,t){let n=Z(this).queue;n&&(t===!1?n.sendSingle(e):n.push(e))}dispatchRequest(e){let t=Z(this);t.currentRequest=e;try{this.send(e.body)}finally{t.currentRequest=void 0}}updateConfig(e){let t=Z(this),n=!w(e,t.config),r=()=>{n&&(Object.keys(e).forEach(n=>{let r=e[n];if(C(r)){let e=C(t.config[n])?t.config[n]:{};t.config[n]=S(e,r)}else t.config[n]=r}),mt(t,e))};if(t.reqQueue.length){if(r(),!pt(t.config)){let e=t.reqQueue.slice();t.reqQueue=[],e.forEach(e=>{this.enqueue(e.log,e.combo)})}return}if(n){var i;(i=t.queue)==null||i.flush(`normal`)}r()}applyBrowserDynamicConfig(){let e=Je(Z(this).config);Object.keys(e).length&&this.updateConfig(e)}print(...e){Z(this).config.debug&&typeof console<`u`&&console.log.apply(console,e)}};function ut(e,t){e.offlineQueue.length>500&&e.offlineQueue.shift(),e.offlineQueue.push(t)}function J(){try{return typeof navigator<`u`&&navigator.onLine===!1}catch(e){return!1}}function Y(e){if(J())return;let t=Z(e);if(!t.offlineQueue.length)return;let n=t.offlineQueue.slice();t.offlineQueue=[],n.forEach(t=>{Ie(()=>{e.send(t)})})}const X=`__aemTrackerState`,dt=Fe(()=>{x()[M]=E()},200);function ft(e,t){Object.defineProperty(e,X,{configurable:!1,enumerable:!1,value:t})}function Z(e){return e[X]}function pt(e){return(e.requiredFields||[]).concat([`pid`]).some(t=>e[t]===void 0)}function mt(e,t){e.subscribers.onConfigUpdated.forEach(n=>{n(t,e.config)})}function Q(e,t,n){let r=Z(e),i=r.plugins.filter(e=>e.plugin===t)[0];if(i)return i.instance;let a;try{a=new t(e,n)}catch(r){if(!ht(r))throw r;a=t(e,n)}return r.plugins.push({instance:a,plugin:t}),a}function ht(e){return e instanceof TypeError?String(e.message).indexOf(`not a constructor`)!==-1:!1}function gt(e){try{if(typeof window>`u`||!window.addEventListener)return;window.addEventListener(`hashchange`,()=>{e.setConfig({hash:location.hash})})}catch(e){return}}function _t(e){try{if(typeof navigator>`u`)return;let t=navigator,n=t.connection||t.mozConnection||t.webkitConnection;if(!n||typeof n.addEventListener!=`function`)return;n.addEventListener(`change`,()=>{let t=P();Object.keys(t).length&&e.setConfig(t),Y(e)})}catch(e){return}}function vt(e){try{if(typeof window>`u`||!window.addEventListener)return;window.addEventListener(`online`,()=>{Y(e)})}catch(e){return}}function yt(e){try{if(typeof document>`u`||typeof MutationObserver>`u`)return;let t=()=>{let t=document.querySelector(`title`);t&&new MutationObserver(()=>{e.setConfig({title:document.title})}).observe(t,{characterData:!0,childList:!0,subtree:!0})};document.querySelector(`title`)?t():document.addEventListener(`DOMContentLoaded`,t)}catch(e){return}}function bt(e){try{if(typeof window>`u`||!window.addEventListener)return;window.addEventListener(`pagehide`,()=>{xt(e,`pagehide`)})}catch(e){return}}function xt(e,t){var n;(n=Z(e).queue)==null||n.flush(t)}function St(e){try{if(typeof window>`u`)return;let t=String(e.getConfig(`queueGlobalName`)||`AES_QUEUE`),n=window,r=n[t],i=Object.prototype.toString.call(r)===`[object Array]`?r:[];i.forEach(t=>{$(e,t)});let a=i.push.bind(i);i.push=function(t){return $(e,t),a(t)},n[t]=i}catch(e){return}}function $(e,t){if(typeof t==`function`){t(e);return}let n=t;if(!n||typeof n.action!=`string`)return;let r=e[n.action];typeof r==`function`&&r.apply(e,n.arguments||[])}export{q as AES,q as default,K as AES_SKIP_BEFORE_ORIGIN};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aem-sdk/tracker",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.3",
|
|
4
4
|
"description": "AEM Web SDK browser runtime",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aem",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"registry": "https://registry.npmjs.org"
|
|
30
30
|
},
|
|
31
31
|
"aemSizeBudget": {
|
|
32
|
-
"gzipBytes":
|
|
32
|
+
"gzipBytes": 13568
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "tsdown",
|