diff --git a/CHANGELOG.md b/CHANGELOG.md index 71cab37..c092c8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ -## 1.16.1(2021-12-3) +## 1.16.2(2021-12-22) 1. 新增 - 支持 `ID-Mapping 3.0` 用户关联协议 + - 获取预置属性接口返回新增是否首次属性 `$is_first_time` +2. 修复 + - 修复 `Component` 传空对象,不采集页面浏览事件的问题 + - 修复批量发送的 `time` 和 `_flush_time` 相同的问题 + - 修复部分场景下 `$url_path` 取值不准确的问题 ## 1.15.1(2021-12-2) 1. 新增 diff --git a/package.json b/package.json index b3f1953..5e5492c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sa-sdk-miniprogram", - "version": "1.16.1", + "version": "1.16.2", "description": "sensorsdata miniprogram sdk", "main": "sensorsdata.min.js", "scripts": { diff --git a/plugins/aes.cmd.min.js b/plugins/aes.cmd.min.js index dd4a3e3..5b343d5 100644 --- a/plugins/aes.cmd.min.js +++ b/plugins/aes.cmd.min.js @@ -1 +1 @@ -"use strict";var _CryptoJS={};_CryptoJS.CryptoJS=function(t,e){var r;if("undefined"!=typeof window&&window.crypto&&(r=window.crypto),"undefined"!=typeof self&&self.crypto&&(r=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(r=globalThis.crypto),!r&&"undefined"!=typeof window&&window.msCrypto&&(r=window.msCrypto),!r&&"undefined"!=typeof global&&global.crypto&&(r=global.crypto),!r&&"function"==typeof require)try{r=require("crypto")}catch(t){}var n=function(){if(r){if("function"==typeof r.getRandomValues)try{return r.getRandomValues(new Uint32Array(1))[0]}catch(t){}if("function"==typeof r.randomBytes)try{return r.randomBytes(4).readInt32LE()}catch(t){}}throw new Error("Native crypto module could not be used to get secure random number.")},i=Object.create||function(){function t(){}return function(e){var r;return t.prototype=e,r=new t,t.prototype=null,r}}(),o={},a=o.lib={},c=a.Base={extend:function(t){var e=i(this);return t&&e.mixIn(t),e.hasOwnProperty("init")&&this.init!==e.init||(e.init=function(){e.$super.init.apply(this,arguments)}),e.init.prototype=e,e.$super=this,e},create:function(){var t=this.extend();return t.init.apply(t,arguments),t},init:function(){},mixIn:function(t){for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);t.hasOwnProperty("toString")&&(this.toString=t.toString)},clone:function(){return this.init.prototype.extend(this)}},s=a.WordArray=c.extend({init:function(t,e){t=this.words=t||[],this.sigBytes=null!=e?e:4*t.length},toString:function(t){return(t||u).stringify(this)},concat:function(t){var e=this.words,r=t.words,n=this.sigBytes,i=t.sigBytes;if(this.clamp(),n%4)for(var o=0;o>>2]>>>24-o%4*8&255;e[n+o>>>2]|=a<<24-(n+o)%4*8}else for(var c=0;c>>2]=r[c>>>2];return this.sigBytes+=i,this},clamp:function(){var e=this.words,r=this.sigBytes;e[r>>>2]&=4294967295<<32-r%4*8,e.length=t.ceil(r/4)},clone:function(){var t=c.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],r=0;r>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new s.init(r,e/2)}},p=f.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],i=0;i>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new s.init(r,e)}},h=f.Utf8={stringify:function(t){try{return decodeURIComponent(escape(p.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return p.parse(unescape(encodeURIComponent(t)))}},d=a.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=h.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var r,n=this._data,i=n.words,o=n.sigBytes,a=this.blockSize,c=o/(4*a),f=(c=e?t.ceil(c):t.max((0|c)-this._minBufferSize,0))*a,u=t.min(4*f,o);if(f){for(var p=0;p>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,c=t[e+0],h=t[e+1],d=t[e+2],y=t[e+3],l=t[e+4],_=t[e+5],g=t[e+6],v=t[e+7],S=t[e+8],m=t[e+9],k=t[e+10],C=t[e+11],B=t[e+12],D=t[e+13],w=t[e+14],x=t[e+15],b=o[0],E=o[1],z=o[2],J=o[3];b=s(b,E,z,J,c,7,a[0]),J=s(J,b,E,z,h,12,a[1]),z=s(z,J,b,E,d,17,a[2]),E=s(E,z,J,b,y,22,a[3]),b=s(b,E,z,J,l,7,a[4]),J=s(J,b,E,z,_,12,a[5]),z=s(z,J,b,E,g,17,a[6]),E=s(E,z,J,b,v,22,a[7]),b=s(b,E,z,J,S,7,a[8]),J=s(J,b,E,z,m,12,a[9]),z=s(z,J,b,E,k,17,a[10]),E=s(E,z,J,b,C,22,a[11]),b=s(b,E,z,J,B,7,a[12]),J=s(J,b,E,z,D,12,a[13]),z=s(z,J,b,E,w,17,a[14]),b=f(b,E=s(E,z,J,b,x,22,a[15]),z,J,h,5,a[16]),J=f(J,b,E,z,g,9,a[17]),z=f(z,J,b,E,C,14,a[18]),E=f(E,z,J,b,c,20,a[19]),b=f(b,E,z,J,_,5,a[20]),J=f(J,b,E,z,k,9,a[21]),z=f(z,J,b,E,x,14,a[22]),E=f(E,z,J,b,l,20,a[23]),b=f(b,E,z,J,m,5,a[24]),J=f(J,b,E,z,w,9,a[25]),z=f(z,J,b,E,y,14,a[26]),E=f(E,z,J,b,S,20,a[27]),b=f(b,E,z,J,D,5,a[28]),J=f(J,b,E,z,d,9,a[29]),z=f(z,J,b,E,v,14,a[30]),b=u(b,E=f(E,z,J,b,B,20,a[31]),z,J,_,4,a[32]),J=u(J,b,E,z,S,11,a[33]),z=u(z,J,b,E,C,16,a[34]),E=u(E,z,J,b,w,23,a[35]),b=u(b,E,z,J,h,4,a[36]),J=u(J,b,E,z,l,11,a[37]),z=u(z,J,b,E,v,16,a[38]),E=u(E,z,J,b,k,23,a[39]),b=u(b,E,z,J,D,4,a[40]),J=u(J,b,E,z,c,11,a[41]),z=u(z,J,b,E,y,16,a[42]),E=u(E,z,J,b,g,23,a[43]),b=u(b,E,z,J,m,4,a[44]),J=u(J,b,E,z,B,11,a[45]),z=u(z,J,b,E,x,16,a[46]),b=p(b,E=u(E,z,J,b,d,23,a[47]),z,J,c,6,a[48]),J=p(J,b,E,z,v,10,a[49]),z=p(z,J,b,E,w,15,a[50]),E=p(E,z,J,b,_,21,a[51]),b=p(b,E,z,J,B,6,a[52]),J=p(J,b,E,z,y,10,a[53]),z=p(z,J,b,E,k,15,a[54]),E=p(E,z,J,b,h,21,a[55]),b=p(b,E,z,J,S,6,a[56]),J=p(J,b,E,z,x,10,a[57]),z=p(z,J,b,E,g,15,a[58]),E=p(E,z,J,b,D,21,a[59]),b=p(b,E,z,J,l,6,a[60]),J=p(J,b,E,z,C,10,a[61]),z=p(z,J,b,E,d,15,a[62]),E=p(E,z,J,b,m,21,a[63]),o[0]=o[0]+b|0,o[1]=o[1]+E|0,o[2]=o[2]+z|0,o[3]=o[3]+J|0},_doFinalize:function(){var e=this._data,r=e.words,n=8*this._nDataBytes,i=8*e.sigBytes;r[i>>>5]|=128<<24-i%32;var o=t.floor(n/4294967296),a=n;r[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(i+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),e.sigBytes=4*(r.length+1),this._process();for(var c=this._hash,s=c.words,f=0;f<4;f++){var u=s[f];s[f]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8)}return c},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});function s(t,e,r,n,i,o,a){var c=t+(e&r|~e&n)+i+a;return(c<>>32-o)+e}function f(t,e,r,n,i,o,a){var c=t+(e&n|r&~n)+i+a;return(c<>>32-o)+e}function u(t,e,r,n,i,o,a){var c=t+(e^r^n)+i+a;return(c<>>32-o)+e}function p(t,e,r,n,i,o,a){var c=t+(r^(e|~n))+i+a;return(c<>>32-o)+e}e.MD5=i._createHelper(c),e.HmacMD5=i._createHmacHelper(c)}(Math),function(){var t=_CryptoJS.CryptoJS,e=t.lib,r=e.Base,n=e.WordArray,i=t.algo,o=i.MD5,a=i.EvpKDF=r.extend({cfg:r.extend({keySize:4,hasher:o,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var r,i=this.cfg,o=i.hasher.create(),a=n.create(),c=a.words,s=i.keySize,f=i.iterations;c.length>>2]>>>24-o%4*8&255)<<16|(e[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|e[o+2>>>2]>>>24-(o+2)%4*8&255,c=0;c<4&&o+.75*c>>6*(3-c)&63));var s=n.charAt(64);if(s)for(;i.length%4;)i.push(s);return i.join("")},parse:function(t){var r=t.length,n=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o>>6-a%4*2,f=c|s;i[o>>>2]|=f<<24-o%4*8,o++}return e.create(i,o)}(t,r,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),_CryptoJS.CryptoJS.lib.Cipher||function(t){var e=_CryptoJS.CryptoJS,r=e.lib,n=r.Base,i=r.WordArray,o=r.BufferedBlockAlgorithm,a=e.enc,c=(a.Utf8,a.Base64),s=e.algo.EvpKDF,f=r.Cipher=o.extend({cfg:n.extend(),createEncryptor:function(t,e){return this.create(this._ENC_XFORM_MODE,t,e)},createDecryptor:function(t,e){return this.create(this._DEC_XFORM_MODE,t,e)},init:function(t,e,r){this.cfg=this.cfg.extend(r),this._xformMode=t,this._key=e,this.reset()},reset:function(){o.reset.call(this),this._doReset()},process:function(t){return this._append(t),this._process()},finalize:function(t){return t&&this._append(t),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function t(t){return"string"==typeof t?v:_}return function(e){return{encrypt:function(r,n,i){return t(n).encrypt(e,r,n,i)},decrypt:function(r,n,i){return t(n).decrypt(e,r,n,i)}}}}()}),u=(r.StreamCipher=f.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),e.mode={}),p=r.BlockCipherMode=n.extend({createEncryptor:function(t,e){return this.Encryptor.create(t,e)},createDecryptor:function(t,e){return this.Decryptor.create(t,e)},init:function(t,e){this._cipher=t,this._iv=e}}),h=u.CBC=function(){var e=p.extend();function r(e,r,n){var i,o=this._iv;o?(i=o,this._iv=t):i=this._prevBlock;for(var a=0;a>>2];t.sigBytes-=e}},y=(r.BlockCipher=f.extend({cfg:f.cfg.extend({mode:h,padding:d}),reset:function(){var t;f.reset.call(this);var e=this.cfg,r=e.iv,n=e.mode;this._xformMode==this._ENC_XFORM_MODE?t=n.createEncryptor:(t=n.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==t?this._mode.init(this,r&&r.words):(this._mode=t.call(n,this,r&&r.words),this._mode.__creator=t)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t,e=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(e.pad(this._data,this.blockSize),t=this._process(!0)):(t=this._process(!0),e.unpad(t)),t},blockSize:4}),r.CipherParams=n.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}})),l=(e.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext,r=t.salt;return(r?i.create([1398893684,1701076831]).concat(r).concat(e):e).toString(c)},parse:function(t){var e,r=c.parse(t),n=r.words;return 1398893684==n[0]&&1701076831==n[1]&&(e=i.create(n.slice(2,4)),n.splice(0,4),r.sigBytes-=16),y.create({ciphertext:r,salt:e})}},_=r.SerializableCipher=n.extend({cfg:n.extend({format:l}),encrypt:function(t,e,r,n){n=this.cfg.extend(n);var i=t.createEncryptor(r,n),o=i.finalize(e),a=i.cfg;return y.create({ciphertext:o,key:r,iv:a.iv,algorithm:t,mode:a.mode,padding:a.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,r,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(r,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}}),g=(e.kdf={}).OpenSSL={execute:function(t,e,r,n){n||(n=i.random(8));var o=s.create({keySize:e+r}).compute(t,n),a=i.create(o.words.slice(e),4*r);return o.sigBytes=4*e,y.create({key:o,iv:a,salt:n})}},v=r.PasswordBasedCipher=_.extend({cfg:_.cfg.extend({kdf:g}),encrypt:function(t,e,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,t.keySize,t.ivSize);n.iv=i.iv;var o=_.encrypt.call(this,t,e,i.key,n);return o.mixIn(i),o},decrypt:function(t,e,r,n){n=this.cfg.extend(n),e=this._parse(e,n.format);var i=n.kdf.execute(r,t.keySize,t.ivSize,e.salt);return n.iv=i.iv,_.decrypt.call(this,t,e,i.key,n)}})}(),function(){var t=_CryptoJS.CryptoJS,e=t.lib.BlockCipher,r=t.algo,n=[],i=[],o=[],a=[],c=[],s=[],f=[],u=[],p=[],h=[];!function(){for(var t=[],e=0;e<256;e++)t[e]=e<128?e<<1:e<<1^283;var r=0,d=0;for(e=0;e<256;e++){var y=d^d<<1^d<<2^d<<3^d<<4;y=y>>>8^255&y^99,n[r]=y,i[y]=r;var l=t[r],_=t[l],g=t[_],v=257*t[y]^16843008*y;o[r]=v<<24|v>>>8,a[r]=v<<16|v>>>16,c[r]=v<<8|v>>>24,s[r]=v;v=16843009*g^65537*_^257*l^16843008*r;f[y]=v<<24|v>>>8,u[y]=v<<16|v>>>16,p[y]=v<<8|v>>>24,h[y]=v,r?(r=l^t[t[t[g^l]]],d^=t[t[d]]):r=d=1}}();var d=[0,1,2,4,8,16,32,64,128,27,54],y=r.AES=e.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var t=this._keyPriorReset=this._key,e=t.words,r=t.sigBytes/4,i=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],a=0;a6&&a%r==4&&(y=n[y>>>24]<<24|n[y>>>16&255]<<16|n[y>>>8&255]<<8|n[255&y]):(y=n[(y=y<<8|y>>>24)>>>24]<<24|n[y>>>16&255]<<16|n[y>>>8&255]<<8|n[255&y],y^=d[a/r|0]<<24),o[a]=o[a-r]^y);for(var c=this._invKeySchedule=[],s=0;s>>24]]^u[n[y>>>16&255]]^p[n[y>>>8&255]]^h[n[255&y]]}}},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,o,a,c,s,n)},decryptBlock:function(t,e){var r=t[e+1];t[e+1]=t[e+3],t[e+3]=r,this._doCryptBlock(t,e,this._invKeySchedule,f,u,p,h,i);r=t[e+1];t[e+1]=t[e+3],t[e+3]=r},_doCryptBlock:function(t,e,r,n,i,o,a,c){for(var s=this._nRounds,f=t[e]^r[0],u=t[e+1]^r[1],p=t[e+2]^r[2],h=t[e+3]^r[3],d=4,y=1;y>>24]^i[u>>>16&255]^o[p>>>8&255]^a[255&h]^r[d++],_=n[u>>>24]^i[p>>>16&255]^o[h>>>8&255]^a[255&f]^r[d++],g=n[p>>>24]^i[h>>>16&255]^o[f>>>8&255]^a[255&u]^r[d++],v=n[h>>>24]^i[f>>>16&255]^o[u>>>8&255]^a[255&p]^r[d++];f=l,u=_,p=g,h=v}l=(c[f>>>24]<<24|c[u>>>16&255]<<16|c[p>>>8&255]<<8|c[255&h])^r[d++],_=(c[u>>>24]<<24|c[p>>>16&255]<<16|c[h>>>8&255]<<8|c[255&f])^r[d++],g=(c[p>>>24]<<24|c[h>>>16&255]<<16|c[f>>>8&255]<<8|c[255&u])^r[d++],v=(c[h>>>24]<<24|c[f>>>16&255]<<16|c[u>>>8&255]<<8|c[255&p])^r[d++];t[e]=l,t[e+1]=_,t[e+2]=g,t[e+3]=v},keySize:8});t.AES=e._createHelper(y)}();var _iv,_sa,_config,_oldOnceData,CryptoJS=_CryptoJS.CryptoJS,getRandomBasic=function(){var t=(new Date).getTime();return function(e){return Math.ceil((t=(9301*t+49297)%233280)/233280*e)}}();function isObject(t){return null!=t&&"[object Object]"==toString.call(t)}function getRandom(){if("function"==typeof Uint32Array){var t="";if("undefined"!=typeof crypto?t=crypto:"undefined"!=typeof msCrypto&&(t=msCrypto),isObject(t)&&t.getRandomValues){var e=new Uint32Array(1);return t.getRandomValues(e)[0]/Math.pow(2,32)}}return getRandomBasic(1e19)/1e19}function buildAESOption(t){return{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7,iv:t||generateIVData()}}function encryptData(t,e,r,n){var i=buildAESOption(r),o=t;"string"!=typeof t&&(o=JSON.stringify(t)),n||(e=CryptoJS.enc.Base64.parse(e));var a=CryptoJS.enc.Utf8.parse(o),c=CryptoJS.AES.encrypt(a,e,i).toString();return i.iv.clone().concat(CryptoJS.enc.Base64.parse(c)).toString(CryptoJS.enc.Base64)}function decryptData(t,e,r){var n=CryptoJS.enc.Base64.parse(t).toString(),i=n.substr(0,32),o=CryptoJS.enc.Hex.parse(n.substr(32)).toString(CryptoJS.enc.Base64),a=buildAESOption(CryptoJS.enc.Hex.parse(i));return r||(e=CryptoJS.enc.Base64.parse(e)),CryptoJS.AES.decrypt(o,e,a).toString(CryptoJS.enc.Utf8)}function generateIVData(t){t=t||16;for(var e="";t-- >0;){var r=Math.ceil(127*getRandom()).toString(16);e+=2===r.length?r:"0"+r}return CryptoJS.enc.Hex.parse(e)}var _log=console&&console.log||function(){};function isTruthy(t,e){return!!t||(_log(e+"\u4e0d\u80fd\u4e3a\u7a7a。"),!1)}function matchType(t,e,r){return typeof t===r||(_log("\u53c2\u6570\u7c7b\u578b\u9519\u8bef,"+e+"\u5fc5\u987b\u4e3a"+r),!1)}function aesEncrypt(t){try{return encryptData(t,_config.k,_iv)}catch(e){return _log("\u6570\u636e\u52a0\u5bc6\u5f02\u5e38\uff1a"+e),_sa.para.batch_send?"":_oldOnceData.call(_sa.kit,t)}}function formatData(t){var e={key_id:_config.kid,key_hash:_config.khash,nc:1};return e[_sa.para.batch_send?"payloads":"payload"]=t,e}function encodeTrackData(t){if(_sa.para.batch_send)var e=formatData(t);else e=formatData(aesEncrypt(t));var r=JSON.stringify(e);return"data="+encodeURIComponent(r)+"&gzip=9"}function isObject$1(t){return null!=t&&"[object Object]"==toString.call(t)}function encryptStoreData(t){var e=t.length;if(e>0){for(var r=0;r>>2]>>>24-o%4*8&255;e[n+o>>>2]|=a<<24-(n+o)%4*8}else for(var c=0;c>>2]=r[c>>>2];return this.sigBytes+=i,this},clamp:function(){var e=this.words,r=this.sigBytes;e[r>>>2]&=4294967295<<32-r%4*8,e.length=t.ceil(r/4)},clone:function(){var t=c.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],r=0;r>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new s.init(r,e/2)}},p=f.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],i=0;i>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new s.init(r,e)}},h=f.Utf8={stringify:function(t){try{return decodeURIComponent(escape(p.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return p.parse(unescape(encodeURIComponent(t)))}},d=a.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=h.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var r,n=this._data,i=n.words,o=n.sigBytes,a=this.blockSize,c=o/(4*a),f=(c=e?t.ceil(c):t.max((0|c)-this._minBufferSize,0))*a,u=t.min(4*f,o);if(f){for(var p=0;p>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,c=t[e+0],h=t[e+1],d=t[e+2],y=t[e+3],l=t[e+4],_=t[e+5],g=t[e+6],v=t[e+7],S=t[e+8],m=t[e+9],k=t[e+10],C=t[e+11],B=t[e+12],D=t[e+13],w=t[e+14],x=t[e+15],b=o[0],E=o[1],z=o[2],J=o[3];b=s(b,E,z,J,c,7,a[0]),J=s(J,b,E,z,h,12,a[1]),z=s(z,J,b,E,d,17,a[2]),E=s(E,z,J,b,y,22,a[3]),b=s(b,E,z,J,l,7,a[4]),J=s(J,b,E,z,_,12,a[5]),z=s(z,J,b,E,g,17,a[6]),E=s(E,z,J,b,v,22,a[7]),b=s(b,E,z,J,S,7,a[8]),J=s(J,b,E,z,m,12,a[9]),z=s(z,J,b,E,k,17,a[10]),E=s(E,z,J,b,C,22,a[11]),b=s(b,E,z,J,B,7,a[12]),J=s(J,b,E,z,D,12,a[13]),z=s(z,J,b,E,w,17,a[14]),b=f(b,E=s(E,z,J,b,x,22,a[15]),z,J,h,5,a[16]),J=f(J,b,E,z,g,9,a[17]),z=f(z,J,b,E,C,14,a[18]),E=f(E,z,J,b,c,20,a[19]),b=f(b,E,z,J,_,5,a[20]),J=f(J,b,E,z,k,9,a[21]),z=f(z,J,b,E,x,14,a[22]),E=f(E,z,J,b,l,20,a[23]),b=f(b,E,z,J,m,5,a[24]),J=f(J,b,E,z,w,9,a[25]),z=f(z,J,b,E,y,14,a[26]),E=f(E,z,J,b,S,20,a[27]),b=f(b,E,z,J,D,5,a[28]),J=f(J,b,E,z,d,9,a[29]),z=f(z,J,b,E,v,14,a[30]),b=u(b,E=f(E,z,J,b,B,20,a[31]),z,J,_,4,a[32]),J=u(J,b,E,z,S,11,a[33]),z=u(z,J,b,E,C,16,a[34]),E=u(E,z,J,b,w,23,a[35]),b=u(b,E,z,J,h,4,a[36]),J=u(J,b,E,z,l,11,a[37]),z=u(z,J,b,E,v,16,a[38]),E=u(E,z,J,b,k,23,a[39]),b=u(b,E,z,J,D,4,a[40]),J=u(J,b,E,z,c,11,a[41]),z=u(z,J,b,E,y,16,a[42]),E=u(E,z,J,b,g,23,a[43]),b=u(b,E,z,J,m,4,a[44]),J=u(J,b,E,z,B,11,a[45]),z=u(z,J,b,E,x,16,a[46]),b=p(b,E=u(E,z,J,b,d,23,a[47]),z,J,c,6,a[48]),J=p(J,b,E,z,v,10,a[49]),z=p(z,J,b,E,w,15,a[50]),E=p(E,z,J,b,_,21,a[51]),b=p(b,E,z,J,B,6,a[52]),J=p(J,b,E,z,y,10,a[53]),z=p(z,J,b,E,k,15,a[54]),E=p(E,z,J,b,h,21,a[55]),b=p(b,E,z,J,S,6,a[56]),J=p(J,b,E,z,x,10,a[57]),z=p(z,J,b,E,g,15,a[58]),E=p(E,z,J,b,D,21,a[59]),b=p(b,E,z,J,l,6,a[60]),J=p(J,b,E,z,C,10,a[61]),z=p(z,J,b,E,d,15,a[62]),E=p(E,z,J,b,m,21,a[63]),o[0]=o[0]+b|0,o[1]=o[1]+E|0,o[2]=o[2]+z|0,o[3]=o[3]+J|0},_doFinalize:function(){var e=this._data,r=e.words,n=8*this._nDataBytes,i=8*e.sigBytes;r[i>>>5]|=128<<24-i%32;var o=t.floor(n/4294967296),a=n;r[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(i+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),e.sigBytes=4*(r.length+1),this._process();for(var c=this._hash,s=c.words,f=0;f<4;f++){var u=s[f];s[f]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8)}return c},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});function s(t,e,r,n,i,o,a){var c=t+(e&r|~e&n)+i+a;return(c<>>32-o)+e}function f(t,e,r,n,i,o,a){var c=t+(e&n|r&~n)+i+a;return(c<>>32-o)+e}function u(t,e,r,n,i,o,a){var c=t+(e^r^n)+i+a;return(c<>>32-o)+e}function p(t,e,r,n,i,o,a){var c=t+(r^(e|~n))+i+a;return(c<>>32-o)+e}e.MD5=i._createHelper(c),e.HmacMD5=i._createHmacHelper(c)}(Math),function(){var t=_CryptoJS.CryptoJS,e=t.lib,r=e.Base,n=e.WordArray,i=t.algo,o=i.MD5,a=i.EvpKDF=r.extend({cfg:r.extend({keySize:4,hasher:o,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var r,i=this.cfg,o=i.hasher.create(),a=n.create(),c=a.words,s=i.keySize,f=i.iterations;c.length>>2]>>>24-o%4*8&255)<<16|(e[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|e[o+2>>>2]>>>24-(o+2)%4*8&255,c=0;c<4&&o+.75*c>>6*(3-c)&63));var s=n.charAt(64);if(s)for(;i.length%4;)i.push(s);return i.join("")},parse:function(t){var r=t.length,n=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o>>6-a%4*2,f=c|s;i[o>>>2]|=f<<24-o%4*8,o++}return e.create(i,o)}(t,r,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),_CryptoJS.CryptoJS.lib.Cipher||function(t){var e=_CryptoJS.CryptoJS,r=e.lib,n=r.Base,i=r.WordArray,o=r.BufferedBlockAlgorithm,a=e.enc,c=(a.Utf8,a.Base64),s=e.algo.EvpKDF,f=r.Cipher=o.extend({cfg:n.extend(),createEncryptor:function(t,e){return this.create(this._ENC_XFORM_MODE,t,e)},createDecryptor:function(t,e){return this.create(this._DEC_XFORM_MODE,t,e)},init:function(t,e,r){this.cfg=this.cfg.extend(r),this._xformMode=t,this._key=e,this.reset()},reset:function(){o.reset.call(this),this._doReset()},process:function(t){return this._append(t),this._process()},finalize:function(t){return t&&this._append(t),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function t(t){return"string"==typeof t?v:_}return function(e){return{encrypt:function(r,n,i){return t(n).encrypt(e,r,n,i)},decrypt:function(r,n,i){return t(n).decrypt(e,r,n,i)}}}}()}),u=(r.StreamCipher=f.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),e.mode={}),p=r.BlockCipherMode=n.extend({createEncryptor:function(t,e){return this.Encryptor.create(t,e)},createDecryptor:function(t,e){return this.Decryptor.create(t,e)},init:function(t,e){this._cipher=t,this._iv=e}}),h=u.CBC=function(){var e=p.extend();function r(e,r,n){var i,o=this._iv;o?(i=o,this._iv=t):i=this._prevBlock;for(var a=0;a>>2];t.sigBytes-=e}},y=(r.BlockCipher=f.extend({cfg:f.cfg.extend({mode:h,padding:d}),reset:function(){var t;f.reset.call(this);var e=this.cfg,r=e.iv,n=e.mode;this._xformMode==this._ENC_XFORM_MODE?t=n.createEncryptor:(t=n.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==t?this._mode.init(this,r&&r.words):(this._mode=t.call(n,this,r&&r.words),this._mode.__creator=t)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t,e=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(e.pad(this._data,this.blockSize),t=this._process(!0)):(t=this._process(!0),e.unpad(t)),t},blockSize:4}),r.CipherParams=n.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}})),l=(e.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext,r=t.salt;return(r?i.create([1398893684,1701076831]).concat(r).concat(e):e).toString(c)},parse:function(t){var e,r=c.parse(t),n=r.words;return 1398893684==n[0]&&1701076831==n[1]&&(e=i.create(n.slice(2,4)),n.splice(0,4),r.sigBytes-=16),y.create({ciphertext:r,salt:e})}},_=r.SerializableCipher=n.extend({cfg:n.extend({format:l}),encrypt:function(t,e,r,n){n=this.cfg.extend(n);var i=t.createEncryptor(r,n),o=i.finalize(e),a=i.cfg;return y.create({ciphertext:o,key:r,iv:a.iv,algorithm:t,mode:a.mode,padding:a.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,r,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(r,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}}),g=(e.kdf={}).OpenSSL={execute:function(t,e,r,n){n||(n=i.random(8));var o=s.create({keySize:e+r}).compute(t,n),a=i.create(o.words.slice(e),4*r);return o.sigBytes=4*e,y.create({key:o,iv:a,salt:n})}},v=r.PasswordBasedCipher=_.extend({cfg:_.cfg.extend({kdf:g}),encrypt:function(t,e,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,t.keySize,t.ivSize);n.iv=i.iv;var o=_.encrypt.call(this,t,e,i.key,n);return o.mixIn(i),o},decrypt:function(t,e,r,n){n=this.cfg.extend(n),e=this._parse(e,n.format);var i=n.kdf.execute(r,t.keySize,t.ivSize,e.salt);return n.iv=i.iv,_.decrypt.call(this,t,e,i.key,n)}})}(),function(){var t=_CryptoJS.CryptoJS,e=t.lib.BlockCipher,r=t.algo,n=[],i=[],o=[],a=[],c=[],s=[],f=[],u=[],p=[],h=[];!function(){for(var t=[],e=0;e<256;e++)t[e]=e<128?e<<1:e<<1^283;var r=0,d=0;for(e=0;e<256;e++){var y=d^d<<1^d<<2^d<<3^d<<4;y=y>>>8^255&y^99,n[r]=y,i[y]=r;var l=t[r],_=t[l],g=t[_],v=257*t[y]^16843008*y;o[r]=v<<24|v>>>8,a[r]=v<<16|v>>>16,c[r]=v<<8|v>>>24,s[r]=v;v=16843009*g^65537*_^257*l^16843008*r;f[y]=v<<24|v>>>8,u[y]=v<<16|v>>>16,p[y]=v<<8|v>>>24,h[y]=v,r?(r=l^t[t[t[g^l]]],d^=t[t[d]]):r=d=1}}();var d=[0,1,2,4,8,16,32,64,128,27,54],y=r.AES=e.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var t=this._keyPriorReset=this._key,e=t.words,r=t.sigBytes/4,i=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],a=0;a6&&a%r==4&&(y=n[y>>>24]<<24|n[y>>>16&255]<<16|n[y>>>8&255]<<8|n[255&y]):(y=n[(y=y<<8|y>>>24)>>>24]<<24|n[y>>>16&255]<<16|n[y>>>8&255]<<8|n[255&y],y^=d[a/r|0]<<24),o[a]=o[a-r]^y);for(var c=this._invKeySchedule=[],s=0;s>>24]]^u[n[y>>>16&255]]^p[n[y>>>8&255]]^h[n[255&y]]}}},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,o,a,c,s,n)},decryptBlock:function(t,e){var r=t[e+1];t[e+1]=t[e+3],t[e+3]=r,this._doCryptBlock(t,e,this._invKeySchedule,f,u,p,h,i);r=t[e+1];t[e+1]=t[e+3],t[e+3]=r},_doCryptBlock:function(t,e,r,n,i,o,a,c){for(var s=this._nRounds,f=t[e]^r[0],u=t[e+1]^r[1],p=t[e+2]^r[2],h=t[e+3]^r[3],d=4,y=1;y>>24]^i[u>>>16&255]^o[p>>>8&255]^a[255&h]^r[d++],_=n[u>>>24]^i[p>>>16&255]^o[h>>>8&255]^a[255&f]^r[d++],g=n[p>>>24]^i[h>>>16&255]^o[f>>>8&255]^a[255&u]^r[d++],v=n[h>>>24]^i[f>>>16&255]^o[u>>>8&255]^a[255&p]^r[d++];f=l,u=_,p=g,h=v}l=(c[f>>>24]<<24|c[u>>>16&255]<<16|c[p>>>8&255]<<8|c[255&h])^r[d++],_=(c[u>>>24]<<24|c[p>>>16&255]<<16|c[h>>>8&255]<<8|c[255&f])^r[d++],g=(c[p>>>24]<<24|c[h>>>16&255]<<16|c[f>>>8&255]<<8|c[255&u])^r[d++],v=(c[h>>>24]<<24|c[f>>>16&255]<<16|c[u>>>8&255]<<8|c[255&p])^r[d++];t[e]=l,t[e+1]=_,t[e+2]=g,t[e+3]=v},keySize:8});t.AES=e._createHelper(y)}();var _iv,_sa,_config,_oldOnceData,CryptoJS=_CryptoJS.CryptoJS,getRandomBasic=function(){var t=(new Date).getTime();return function(e){return Math.ceil((t=(9301*t+49297)%233280)/233280*e)}}();function isObject(t){return null!=t&&"[object Object]"==toString.call(t)}function getRandom(){if("function"==typeof Uint32Array){var t="";if("undefined"!=typeof crypto?t=crypto:"undefined"!=typeof msCrypto&&(t=msCrypto),isObject(t)&&t.getRandomValues){var e=new Uint32Array(1);return t.getRandomValues(e)[0]/Math.pow(2,32)}}return getRandomBasic(1e19)/1e19}function buildAESOption(t){return{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7,iv:t||generateIVData()}}function encryptData(t,e,r,n){var i=buildAESOption(r),o=t;"string"!=typeof t&&(o=JSON.stringify(t)),n||(e=CryptoJS.enc.Base64.parse(e));var a=CryptoJS.enc.Utf8.parse(o),c=CryptoJS.AES.encrypt(a,e,i).toString();return i.iv.clone().concat(CryptoJS.enc.Base64.parse(c)).toString(CryptoJS.enc.Base64)}function decryptData(t,e,r){var n=CryptoJS.enc.Base64.parse(t).toString(),i=n.substr(0,32),o=CryptoJS.enc.Hex.parse(n.substr(32)).toString(CryptoJS.enc.Base64),a=buildAESOption(CryptoJS.enc.Hex.parse(i));return r||(e=CryptoJS.enc.Base64.parse(e)),CryptoJS.AES.decrypt(o,e,a).toString(CryptoJS.enc.Utf8)}function generateIVData(t){t=t||16;for(var e="";t-- >0;){var r=Math.ceil(127*getRandom()).toString(16);e+=2===r.length?r:"0"+r}return CryptoJS.enc.Hex.parse(e)}var _log=console&&console.log||function(){};function isTruthy(t,e){return!!t||(_log(e+"\u4e0d\u80fd\u4e3a\u7a7a。"),!1)}function matchType(t,e,r){return typeof t===r||(_log("\u53c2\u6570\u7c7b\u578b\u9519\u8bef,"+e+"\u5fc5\u987b\u4e3a"+r),!1)}function aesEncrypt(t){try{return encryptData(t,_config.k,_iv)}catch(e){return _log("\u6570\u636e\u52a0\u5bc6\u5f02\u5e38\uff1a"+e),_sa.para.batch_send?"":_oldOnceData.call(_sa.kit,t)}}function formatData(t){var e={key_id:_config.kid,key_hash:_config.khash,nc:1},r="payload";return _sa.para.batch_send&&(e.flush_time=Date.now(),r="payloads"),e[r]=t,e}function encodeTrackData(t){if(_sa.para.batch_send)var e=formatData(t);else e=formatData(aesEncrypt(t));var r=JSON.stringify(e);return"data="+encodeURIComponent(r)+"&gzip=9"}function isObject$1(t){return null!=t&&"[object Object]"==toString.call(t)}function encryptStoreData(t){var e=t.length;if(e>0){for(var r=0;r>>2]>>>24-o%4*8&255;e[n+o>>>2]|=a<<24-(n+o)%4*8}else for(var c=0;c>>2]=r[c>>>2];return this.sigBytes+=i,this},clamp:function(){var e=this.words,r=this.sigBytes;e[r>>>2]&=4294967295<<32-r%4*8,e.length=t.ceil(r/4)},clone:function(){var t=c.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],r=0;r>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new s.init(r,e/2)}},p=f.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],i=0;i>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new s.init(r,e)}},h=f.Utf8={stringify:function(t){try{return decodeURIComponent(escape(p.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return p.parse(unescape(encodeURIComponent(t)))}},d=a.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=h.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var r,n=this._data,i=n.words,o=n.sigBytes,a=this.blockSize,c=o/(4*a),f=(c=e?t.ceil(c):t.max((0|c)-this._minBufferSize,0))*a,u=t.min(4*f,o);if(f){for(var p=0;p>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,c=t[e+0],h=t[e+1],d=t[e+2],y=t[e+3],l=t[e+4],_=t[e+5],g=t[e+6],v=t[e+7],S=t[e+8],m=t[e+9],k=t[e+10],C=t[e+11],B=t[e+12],D=t[e+13],w=t[e+14],x=t[e+15],b=o[0],E=o[1],z=o[2],J=o[3];b=s(b,E,z,J,c,7,a[0]),J=s(J,b,E,z,h,12,a[1]),z=s(z,J,b,E,d,17,a[2]),E=s(E,z,J,b,y,22,a[3]),b=s(b,E,z,J,l,7,a[4]),J=s(J,b,E,z,_,12,a[5]),z=s(z,J,b,E,g,17,a[6]),E=s(E,z,J,b,v,22,a[7]),b=s(b,E,z,J,S,7,a[8]),J=s(J,b,E,z,m,12,a[9]),z=s(z,J,b,E,k,17,a[10]),E=s(E,z,J,b,C,22,a[11]),b=s(b,E,z,J,B,7,a[12]),J=s(J,b,E,z,D,12,a[13]),z=s(z,J,b,E,w,17,a[14]),b=f(b,E=s(E,z,J,b,x,22,a[15]),z,J,h,5,a[16]),J=f(J,b,E,z,g,9,a[17]),z=f(z,J,b,E,C,14,a[18]),E=f(E,z,J,b,c,20,a[19]),b=f(b,E,z,J,_,5,a[20]),J=f(J,b,E,z,k,9,a[21]),z=f(z,J,b,E,x,14,a[22]),E=f(E,z,J,b,l,20,a[23]),b=f(b,E,z,J,m,5,a[24]),J=f(J,b,E,z,w,9,a[25]),z=f(z,J,b,E,y,14,a[26]),E=f(E,z,J,b,S,20,a[27]),b=f(b,E,z,J,D,5,a[28]),J=f(J,b,E,z,d,9,a[29]),z=f(z,J,b,E,v,14,a[30]),b=u(b,E=f(E,z,J,b,B,20,a[31]),z,J,_,4,a[32]),J=u(J,b,E,z,S,11,a[33]),z=u(z,J,b,E,C,16,a[34]),E=u(E,z,J,b,w,23,a[35]),b=u(b,E,z,J,h,4,a[36]),J=u(J,b,E,z,l,11,a[37]),z=u(z,J,b,E,v,16,a[38]),E=u(E,z,J,b,k,23,a[39]),b=u(b,E,z,J,D,4,a[40]),J=u(J,b,E,z,c,11,a[41]),z=u(z,J,b,E,y,16,a[42]),E=u(E,z,J,b,g,23,a[43]),b=u(b,E,z,J,m,4,a[44]),J=u(J,b,E,z,B,11,a[45]),z=u(z,J,b,E,x,16,a[46]),b=p(b,E=u(E,z,J,b,d,23,a[47]),z,J,c,6,a[48]),J=p(J,b,E,z,v,10,a[49]),z=p(z,J,b,E,w,15,a[50]),E=p(E,z,J,b,_,21,a[51]),b=p(b,E,z,J,B,6,a[52]),J=p(J,b,E,z,y,10,a[53]),z=p(z,J,b,E,k,15,a[54]),E=p(E,z,J,b,h,21,a[55]),b=p(b,E,z,J,S,6,a[56]),J=p(J,b,E,z,x,10,a[57]),z=p(z,J,b,E,g,15,a[58]),E=p(E,z,J,b,D,21,a[59]),b=p(b,E,z,J,l,6,a[60]),J=p(J,b,E,z,C,10,a[61]),z=p(z,J,b,E,d,15,a[62]),E=p(E,z,J,b,m,21,a[63]),o[0]=o[0]+b|0,o[1]=o[1]+E|0,o[2]=o[2]+z|0,o[3]=o[3]+J|0},_doFinalize:function(){var e=this._data,r=e.words,n=8*this._nDataBytes,i=8*e.sigBytes;r[i>>>5]|=128<<24-i%32;var o=t.floor(n/4294967296),a=n;r[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(i+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),e.sigBytes=4*(r.length+1),this._process();for(var c=this._hash,s=c.words,f=0;f<4;f++){var u=s[f];s[f]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8)}return c},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});function s(t,e,r,n,i,o,a){var c=t+(e&r|~e&n)+i+a;return(c<>>32-o)+e}function f(t,e,r,n,i,o,a){var c=t+(e&n|r&~n)+i+a;return(c<>>32-o)+e}function u(t,e,r,n,i,o,a){var c=t+(e^r^n)+i+a;return(c<>>32-o)+e}function p(t,e,r,n,i,o,a){var c=t+(r^(e|~n))+i+a;return(c<>>32-o)+e}e.MD5=i._createHelper(c),e.HmacMD5=i._createHmacHelper(c)}(Math),function(){var t=_CryptoJS.CryptoJS,e=t.lib,r=e.Base,n=e.WordArray,i=t.algo,o=i.MD5,a=i.EvpKDF=r.extend({cfg:r.extend({keySize:4,hasher:o,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var r,i=this.cfg,o=i.hasher.create(),a=n.create(),c=a.words,s=i.keySize,f=i.iterations;c.length>>2]>>>24-o%4*8&255)<<16|(e[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|e[o+2>>>2]>>>24-(o+2)%4*8&255,c=0;c<4&&o+.75*c>>6*(3-c)&63));var s=n.charAt(64);if(s)for(;i.length%4;)i.push(s);return i.join("")},parse:function(t){var r=t.length,n=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o>>6-a%4*2,f=c|s;i[o>>>2]|=f<<24-o%4*8,o++}return e.create(i,o)}(t,r,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),_CryptoJS.CryptoJS.lib.Cipher||function(t){var e=_CryptoJS.CryptoJS,r=e.lib,n=r.Base,i=r.WordArray,o=r.BufferedBlockAlgorithm,a=e.enc,c=(a.Utf8,a.Base64),s=e.algo.EvpKDF,f=r.Cipher=o.extend({cfg:n.extend(),createEncryptor:function(t,e){return this.create(this._ENC_XFORM_MODE,t,e)},createDecryptor:function(t,e){return this.create(this._DEC_XFORM_MODE,t,e)},init:function(t,e,r){this.cfg=this.cfg.extend(r),this._xformMode=t,this._key=e,this.reset()},reset:function(){o.reset.call(this),this._doReset()},process:function(t){return this._append(t),this._process()},finalize:function(t){return t&&this._append(t),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function t(t){return"string"==typeof t?v:_}return function(e){return{encrypt:function(r,n,i){return t(n).encrypt(e,r,n,i)},decrypt:function(r,n,i){return t(n).decrypt(e,r,n,i)}}}}()}),u=(r.StreamCipher=f.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),e.mode={}),p=r.BlockCipherMode=n.extend({createEncryptor:function(t,e){return this.Encryptor.create(t,e)},createDecryptor:function(t,e){return this.Decryptor.create(t,e)},init:function(t,e){this._cipher=t,this._iv=e}}),h=u.CBC=function(){var e=p.extend();function r(e,r,n){var i,o=this._iv;o?(i=o,this._iv=t):i=this._prevBlock;for(var a=0;a>>2];t.sigBytes-=e}},y=(r.BlockCipher=f.extend({cfg:f.cfg.extend({mode:h,padding:d}),reset:function(){var t;f.reset.call(this);var e=this.cfg,r=e.iv,n=e.mode;this._xformMode==this._ENC_XFORM_MODE?t=n.createEncryptor:(t=n.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==t?this._mode.init(this,r&&r.words):(this._mode=t.call(n,this,r&&r.words),this._mode.__creator=t)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t,e=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(e.pad(this._data,this.blockSize),t=this._process(!0)):(t=this._process(!0),e.unpad(t)),t},blockSize:4}),r.CipherParams=n.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}})),l=(e.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext,r=t.salt;return(r?i.create([1398893684,1701076831]).concat(r).concat(e):e).toString(c)},parse:function(t){var e,r=c.parse(t),n=r.words;return 1398893684==n[0]&&1701076831==n[1]&&(e=i.create(n.slice(2,4)),n.splice(0,4),r.sigBytes-=16),y.create({ciphertext:r,salt:e})}},_=r.SerializableCipher=n.extend({cfg:n.extend({format:l}),encrypt:function(t,e,r,n){n=this.cfg.extend(n);var i=t.createEncryptor(r,n),o=i.finalize(e),a=i.cfg;return y.create({ciphertext:o,key:r,iv:a.iv,algorithm:t,mode:a.mode,padding:a.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,r,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(r,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}}),g=(e.kdf={}).OpenSSL={execute:function(t,e,r,n){n||(n=i.random(8));var o=s.create({keySize:e+r}).compute(t,n),a=i.create(o.words.slice(e),4*r);return o.sigBytes=4*e,y.create({key:o,iv:a,salt:n})}},v=r.PasswordBasedCipher=_.extend({cfg:_.cfg.extend({kdf:g}),encrypt:function(t,e,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,t.keySize,t.ivSize);n.iv=i.iv;var o=_.encrypt.call(this,t,e,i.key,n);return o.mixIn(i),o},decrypt:function(t,e,r,n){n=this.cfg.extend(n),e=this._parse(e,n.format);var i=n.kdf.execute(r,t.keySize,t.ivSize,e.salt);return n.iv=i.iv,_.decrypt.call(this,t,e,i.key,n)}})}(),function(){var t=_CryptoJS.CryptoJS,e=t.lib.BlockCipher,r=t.algo,n=[],i=[],o=[],a=[],c=[],s=[],f=[],u=[],p=[],h=[];!function(){for(var t=[],e=0;e<256;e++)t[e]=e<128?e<<1:e<<1^283;var r=0,d=0;for(e=0;e<256;e++){var y=d^d<<1^d<<2^d<<3^d<<4;y=y>>>8^255&y^99,n[r]=y,i[y]=r;var l=t[r],_=t[l],g=t[_],v=257*t[y]^16843008*y;o[r]=v<<24|v>>>8,a[r]=v<<16|v>>>16,c[r]=v<<8|v>>>24,s[r]=v;v=16843009*g^65537*_^257*l^16843008*r;f[y]=v<<24|v>>>8,u[y]=v<<16|v>>>16,p[y]=v<<8|v>>>24,h[y]=v,r?(r=l^t[t[t[g^l]]],d^=t[t[d]]):r=d=1}}();var d=[0,1,2,4,8,16,32,64,128,27,54],y=r.AES=e.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var t=this._keyPriorReset=this._key,e=t.words,r=t.sigBytes/4,i=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],a=0;a6&&a%r==4&&(y=n[y>>>24]<<24|n[y>>>16&255]<<16|n[y>>>8&255]<<8|n[255&y]):(y=n[(y=y<<8|y>>>24)>>>24]<<24|n[y>>>16&255]<<16|n[y>>>8&255]<<8|n[255&y],y^=d[a/r|0]<<24),o[a]=o[a-r]^y);for(var c=this._invKeySchedule=[],s=0;s>>24]]^u[n[y>>>16&255]]^p[n[y>>>8&255]]^h[n[255&y]]}}},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,o,a,c,s,n)},decryptBlock:function(t,e){var r=t[e+1];t[e+1]=t[e+3],t[e+3]=r,this._doCryptBlock(t,e,this._invKeySchedule,f,u,p,h,i);r=t[e+1];t[e+1]=t[e+3],t[e+3]=r},_doCryptBlock:function(t,e,r,n,i,o,a,c){for(var s=this._nRounds,f=t[e]^r[0],u=t[e+1]^r[1],p=t[e+2]^r[2],h=t[e+3]^r[3],d=4,y=1;y>>24]^i[u>>>16&255]^o[p>>>8&255]^a[255&h]^r[d++],_=n[u>>>24]^i[p>>>16&255]^o[h>>>8&255]^a[255&f]^r[d++],g=n[p>>>24]^i[h>>>16&255]^o[f>>>8&255]^a[255&u]^r[d++],v=n[h>>>24]^i[f>>>16&255]^o[u>>>8&255]^a[255&p]^r[d++];f=l,u=_,p=g,h=v}l=(c[f>>>24]<<24|c[u>>>16&255]<<16|c[p>>>8&255]<<8|c[255&h])^r[d++],_=(c[u>>>24]<<24|c[p>>>16&255]<<16|c[h>>>8&255]<<8|c[255&f])^r[d++],g=(c[p>>>24]<<24|c[h>>>16&255]<<16|c[f>>>8&255]<<8|c[255&u])^r[d++],v=(c[h>>>24]<<24|c[f>>>16&255]<<16|c[u>>>8&255]<<8|c[255&p])^r[d++];t[e]=l,t[e+1]=_,t[e+2]=g,t[e+3]=v},keySize:8});t.AES=e._createHelper(y)}();var _iv,_sa,_config,_oldOnceData,CryptoJS=_CryptoJS.CryptoJS,getRandomBasic=function(){var t=(new Date).getTime();return function(e){return Math.ceil((t=(9301*t+49297)%233280)/233280*e)}}();function isObject(t){return null!=t&&"[object Object]"==toString.call(t)}function getRandom(){if("function"==typeof Uint32Array){var t="";if("undefined"!=typeof crypto?t=crypto:"undefined"!=typeof msCrypto&&(t=msCrypto),isObject(t)&&t.getRandomValues){var e=new Uint32Array(1);return t.getRandomValues(e)[0]/Math.pow(2,32)}}return getRandomBasic(1e19)/1e19}function buildAESOption(t){return{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7,iv:t||generateIVData()}}function encryptData(t,e,r,n){var i=buildAESOption(r),o=t;"string"!=typeof t&&(o=JSON.stringify(t)),n||(e=CryptoJS.enc.Base64.parse(e));var a=CryptoJS.enc.Utf8.parse(o),c=CryptoJS.AES.encrypt(a,e,i).toString();return i.iv.clone().concat(CryptoJS.enc.Base64.parse(c)).toString(CryptoJS.enc.Base64)}function decryptData(t,e,r){var n=CryptoJS.enc.Base64.parse(t).toString(),i=n.substr(0,32),o=CryptoJS.enc.Hex.parse(n.substr(32)).toString(CryptoJS.enc.Base64),a=buildAESOption(CryptoJS.enc.Hex.parse(i));return r||(e=CryptoJS.enc.Base64.parse(e)),CryptoJS.AES.decrypt(o,e,a).toString(CryptoJS.enc.Utf8)}function generateIVData(t){t=t||16;for(var e="";t-- >0;){var r=Math.ceil(127*getRandom()).toString(16);e+=2===r.length?r:"0"+r}return CryptoJS.enc.Hex.parse(e)}var _log=console&&console.log||function(){};function isTruthy(t,e){return!!t||(_log(e+"\u4e0d\u80fd\u4e3a\u7a7a。"),!1)}function matchType(t,e,r){return typeof t===r||(_log("\u53c2\u6570\u7c7b\u578b\u9519\u8bef,"+e+"\u5fc5\u987b\u4e3a"+r),!1)}function aesEncrypt(t){try{return encryptData(t,_config.k,_iv)}catch(e){return _log("\u6570\u636e\u52a0\u5bc6\u5f02\u5e38\uff1a"+e),_sa.para.batch_send?"":_oldOnceData.call(_sa.kit,t)}}function formatData(t){var e={key_id:_config.kid,key_hash:_config.khash,nc:1};return e[_sa.para.batch_send?"payloads":"payload"]=t,e}function encodeTrackData(t){if(_sa.para.batch_send)var e=formatData(t);else e=formatData(aesEncrypt(t));var r=JSON.stringify(e);return"data="+encodeURIComponent(r)+"&gzip=9"}function isObject$1(t){return null!=t&&"[object Object]"==toString.call(t)}function encryptStoreData(t){var e=t.length;if(e>0){for(var r=0;r>>2]>>>24-o%4*8&255;e[n+o>>>2]|=a<<24-(n+o)%4*8}else for(var c=0;c>>2]=r[c>>>2];return this.sigBytes+=i,this},clamp:function(){var e=this.words,r=this.sigBytes;e[r>>>2]&=4294967295<<32-r%4*8,e.length=t.ceil(r/4)},clone:function(){var t=c.clone.call(this);return t.words=this.words.slice(0),t},random:function(t){for(var e=[],r=0;r>>2]>>>24-i%4*8&255;n.push((o>>>4).toString(16)),n.push((15&o).toString(16))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>3]|=parseInt(t.substr(n,2),16)<<24-n%8*4;return new s.init(r,e/2)}},p=f.Latin1={stringify:function(t){for(var e=t.words,r=t.sigBytes,n=[],i=0;i>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(o))}return n.join("")},parse:function(t){for(var e=t.length,r=[],n=0;n>>2]|=(255&t.charCodeAt(n))<<24-n%4*8;return new s.init(r,e)}},h=f.Utf8={stringify:function(t){try{return decodeURIComponent(escape(p.stringify(t)))}catch(t){throw new Error("Malformed UTF-8 data")}},parse:function(t){return p.parse(unescape(encodeURIComponent(t)))}},d=a.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new s.init,this._nDataBytes=0},_append:function(t){"string"==typeof t&&(t=h.parse(t)),this._data.concat(t),this._nDataBytes+=t.sigBytes},_process:function(e){var r,n=this._data,i=n.words,o=n.sigBytes,a=this.blockSize,c=o/(4*a),f=(c=e?t.ceil(c):t.max((0|c)-this._minBufferSize,0))*a,u=t.min(4*f,o);if(f){for(var p=0;p>>24)|4278255360&(i<<24|i>>>8)}var o=this._hash.words,c=t[e+0],h=t[e+1],d=t[e+2],y=t[e+3],l=t[e+4],_=t[e+5],g=t[e+6],v=t[e+7],S=t[e+8],m=t[e+9],k=t[e+10],C=t[e+11],B=t[e+12],D=t[e+13],w=t[e+14],x=t[e+15],b=o[0],E=o[1],z=o[2],J=o[3];b=s(b,E,z,J,c,7,a[0]),J=s(J,b,E,z,h,12,a[1]),z=s(z,J,b,E,d,17,a[2]),E=s(E,z,J,b,y,22,a[3]),b=s(b,E,z,J,l,7,a[4]),J=s(J,b,E,z,_,12,a[5]),z=s(z,J,b,E,g,17,a[6]),E=s(E,z,J,b,v,22,a[7]),b=s(b,E,z,J,S,7,a[8]),J=s(J,b,E,z,m,12,a[9]),z=s(z,J,b,E,k,17,a[10]),E=s(E,z,J,b,C,22,a[11]),b=s(b,E,z,J,B,7,a[12]),J=s(J,b,E,z,D,12,a[13]),z=s(z,J,b,E,w,17,a[14]),b=f(b,E=s(E,z,J,b,x,22,a[15]),z,J,h,5,a[16]),J=f(J,b,E,z,g,9,a[17]),z=f(z,J,b,E,C,14,a[18]),E=f(E,z,J,b,c,20,a[19]),b=f(b,E,z,J,_,5,a[20]),J=f(J,b,E,z,k,9,a[21]),z=f(z,J,b,E,x,14,a[22]),E=f(E,z,J,b,l,20,a[23]),b=f(b,E,z,J,m,5,a[24]),J=f(J,b,E,z,w,9,a[25]),z=f(z,J,b,E,y,14,a[26]),E=f(E,z,J,b,S,20,a[27]),b=f(b,E,z,J,D,5,a[28]),J=f(J,b,E,z,d,9,a[29]),z=f(z,J,b,E,v,14,a[30]),b=u(b,E=f(E,z,J,b,B,20,a[31]),z,J,_,4,a[32]),J=u(J,b,E,z,S,11,a[33]),z=u(z,J,b,E,C,16,a[34]),E=u(E,z,J,b,w,23,a[35]),b=u(b,E,z,J,h,4,a[36]),J=u(J,b,E,z,l,11,a[37]),z=u(z,J,b,E,v,16,a[38]),E=u(E,z,J,b,k,23,a[39]),b=u(b,E,z,J,D,4,a[40]),J=u(J,b,E,z,c,11,a[41]),z=u(z,J,b,E,y,16,a[42]),E=u(E,z,J,b,g,23,a[43]),b=u(b,E,z,J,m,4,a[44]),J=u(J,b,E,z,B,11,a[45]),z=u(z,J,b,E,x,16,a[46]),b=p(b,E=u(E,z,J,b,d,23,a[47]),z,J,c,6,a[48]),J=p(J,b,E,z,v,10,a[49]),z=p(z,J,b,E,w,15,a[50]),E=p(E,z,J,b,_,21,a[51]),b=p(b,E,z,J,B,6,a[52]),J=p(J,b,E,z,y,10,a[53]),z=p(z,J,b,E,k,15,a[54]),E=p(E,z,J,b,h,21,a[55]),b=p(b,E,z,J,S,6,a[56]),J=p(J,b,E,z,x,10,a[57]),z=p(z,J,b,E,g,15,a[58]),E=p(E,z,J,b,D,21,a[59]),b=p(b,E,z,J,l,6,a[60]),J=p(J,b,E,z,C,10,a[61]),z=p(z,J,b,E,d,15,a[62]),E=p(E,z,J,b,m,21,a[63]),o[0]=o[0]+b|0,o[1]=o[1]+E|0,o[2]=o[2]+z|0,o[3]=o[3]+J|0},_doFinalize:function(){var e=this._data,r=e.words,n=8*this._nDataBytes,i=8*e.sigBytes;r[i>>>5]|=128<<24-i%32;var o=t.floor(n/4294967296),a=n;r[15+(i+64>>>9<<4)]=16711935&(o<<8|o>>>24)|4278255360&(o<<24|o>>>8),r[14+(i+64>>>9<<4)]=16711935&(a<<8|a>>>24)|4278255360&(a<<24|a>>>8),e.sigBytes=4*(r.length+1),this._process();for(var c=this._hash,s=c.words,f=0;f<4;f++){var u=s[f];s[f]=16711935&(u<<8|u>>>24)|4278255360&(u<<24|u>>>8)}return c},clone:function(){var t=i.clone.call(this);return t._hash=this._hash.clone(),t}});function s(t,e,r,n,i,o,a){var c=t+(e&r|~e&n)+i+a;return(c<>>32-o)+e}function f(t,e,r,n,i,o,a){var c=t+(e&n|r&~n)+i+a;return(c<>>32-o)+e}function u(t,e,r,n,i,o,a){var c=t+(e^r^n)+i+a;return(c<>>32-o)+e}function p(t,e,r,n,i,o,a){var c=t+(r^(e|~n))+i+a;return(c<>>32-o)+e}e.MD5=i._createHelper(c),e.HmacMD5=i._createHmacHelper(c)}(Math),function(){var t=_CryptoJS.CryptoJS,e=t.lib,r=e.Base,n=e.WordArray,i=t.algo,o=i.MD5,a=i.EvpKDF=r.extend({cfg:r.extend({keySize:4,hasher:o,iterations:1}),init:function(t){this.cfg=this.cfg.extend(t)},compute:function(t,e){for(var r,i=this.cfg,o=i.hasher.create(),a=n.create(),c=a.words,s=i.keySize,f=i.iterations;c.length>>2]>>>24-o%4*8&255)<<16|(e[o+1>>>2]>>>24-(o+1)%4*8&255)<<8|e[o+2>>>2]>>>24-(o+2)%4*8&255,c=0;c<4&&o+.75*c>>6*(3-c)&63));var s=n.charAt(64);if(s)for(;i.length%4;)i.push(s);return i.join("")},parse:function(t){var r=t.length,n=this._map,i=this._reverseMap;if(!i){i=this._reverseMap=[];for(var o=0;o>>6-a%4*2,f=c|s;i[o>>>2]|=f<<24-o%4*8,o++}return e.create(i,o)}(t,r,i)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}}(),_CryptoJS.CryptoJS.lib.Cipher||function(t){var e=_CryptoJS.CryptoJS,r=e.lib,n=r.Base,i=r.WordArray,o=r.BufferedBlockAlgorithm,a=e.enc,c=(a.Utf8,a.Base64),s=e.algo.EvpKDF,f=r.Cipher=o.extend({cfg:n.extend(),createEncryptor:function(t,e){return this.create(this._ENC_XFORM_MODE,t,e)},createDecryptor:function(t,e){return this.create(this._DEC_XFORM_MODE,t,e)},init:function(t,e,r){this.cfg=this.cfg.extend(r),this._xformMode=t,this._key=e,this.reset()},reset:function(){o.reset.call(this),this._doReset()},process:function(t){return this._append(t),this._process()},finalize:function(t){return t&&this._append(t),this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(){function t(t){return"string"==typeof t?v:_}return function(e){return{encrypt:function(r,n,i){return t(n).encrypt(e,r,n,i)},decrypt:function(r,n,i){return t(n).decrypt(e,r,n,i)}}}}()}),u=(r.StreamCipher=f.extend({_doFinalize:function(){return this._process(!0)},blockSize:1}),e.mode={}),p=r.BlockCipherMode=n.extend({createEncryptor:function(t,e){return this.Encryptor.create(t,e)},createDecryptor:function(t,e){return this.Decryptor.create(t,e)},init:function(t,e){this._cipher=t,this._iv=e}}),h=u.CBC=function(){var e=p.extend();function r(e,r,n){var i,o=this._iv;o?(i=o,this._iv=t):i=this._prevBlock;for(var a=0;a>>2];t.sigBytes-=e}},y=(r.BlockCipher=f.extend({cfg:f.cfg.extend({mode:h,padding:d}),reset:function(){var t;f.reset.call(this);var e=this.cfg,r=e.iv,n=e.mode;this._xformMode==this._ENC_XFORM_MODE?t=n.createEncryptor:(t=n.createDecryptor,this._minBufferSize=1),this._mode&&this._mode.__creator==t?this._mode.init(this,r&&r.words):(this._mode=t.call(n,this,r&&r.words),this._mode.__creator=t)},_doProcessBlock:function(t,e){this._mode.processBlock(t,e)},_doFinalize:function(){var t,e=this.cfg.padding;return this._xformMode==this._ENC_XFORM_MODE?(e.pad(this._data,this.blockSize),t=this._process(!0)):(t=this._process(!0),e.unpad(t)),t},blockSize:4}),r.CipherParams=n.extend({init:function(t){this.mixIn(t)},toString:function(t){return(t||this.formatter).stringify(this)}})),l=(e.format={}).OpenSSL={stringify:function(t){var e=t.ciphertext,r=t.salt;return(r?i.create([1398893684,1701076831]).concat(r).concat(e):e).toString(c)},parse:function(t){var e,r=c.parse(t),n=r.words;return 1398893684==n[0]&&1701076831==n[1]&&(e=i.create(n.slice(2,4)),n.splice(0,4),r.sigBytes-=16),y.create({ciphertext:r,salt:e})}},_=r.SerializableCipher=n.extend({cfg:n.extend({format:l}),encrypt:function(t,e,r,n){n=this.cfg.extend(n);var i=t.createEncryptor(r,n),o=i.finalize(e),a=i.cfg;return y.create({ciphertext:o,key:r,iv:a.iv,algorithm:t,mode:a.mode,padding:a.padding,blockSize:t.blockSize,formatter:n.format})},decrypt:function(t,e,r,n){return n=this.cfg.extend(n),e=this._parse(e,n.format),t.createDecryptor(r,n).finalize(e.ciphertext)},_parse:function(t,e){return"string"==typeof t?e.parse(t,this):t}}),g=(e.kdf={}).OpenSSL={execute:function(t,e,r,n){n||(n=i.random(8));var o=s.create({keySize:e+r}).compute(t,n),a=i.create(o.words.slice(e),4*r);return o.sigBytes=4*e,y.create({key:o,iv:a,salt:n})}},v=r.PasswordBasedCipher=_.extend({cfg:_.cfg.extend({kdf:g}),encrypt:function(t,e,r,n){var i=(n=this.cfg.extend(n)).kdf.execute(r,t.keySize,t.ivSize);n.iv=i.iv;var o=_.encrypt.call(this,t,e,i.key,n);return o.mixIn(i),o},decrypt:function(t,e,r,n){n=this.cfg.extend(n),e=this._parse(e,n.format);var i=n.kdf.execute(r,t.keySize,t.ivSize,e.salt);return n.iv=i.iv,_.decrypt.call(this,t,e,i.key,n)}})}(),function(){var t=_CryptoJS.CryptoJS,e=t.lib.BlockCipher,r=t.algo,n=[],i=[],o=[],a=[],c=[],s=[],f=[],u=[],p=[],h=[];!function(){for(var t=[],e=0;e<256;e++)t[e]=e<128?e<<1:e<<1^283;var r=0,d=0;for(e=0;e<256;e++){var y=d^d<<1^d<<2^d<<3^d<<4;y=y>>>8^255&y^99,n[r]=y,i[y]=r;var l=t[r],_=t[l],g=t[_],v=257*t[y]^16843008*y;o[r]=v<<24|v>>>8,a[r]=v<<16|v>>>16,c[r]=v<<8|v>>>24,s[r]=v;v=16843009*g^65537*_^257*l^16843008*r;f[y]=v<<24|v>>>8,u[y]=v<<16|v>>>16,p[y]=v<<8|v>>>24,h[y]=v,r?(r=l^t[t[t[g^l]]],d^=t[t[d]]):r=d=1}}();var d=[0,1,2,4,8,16,32,64,128,27,54],y=r.AES=e.extend({_doReset:function(){if(!this._nRounds||this._keyPriorReset!==this._key){for(var t=this._keyPriorReset=this._key,e=t.words,r=t.sigBytes/4,i=4*((this._nRounds=r+6)+1),o=this._keySchedule=[],a=0;a6&&a%r==4&&(y=n[y>>>24]<<24|n[y>>>16&255]<<16|n[y>>>8&255]<<8|n[255&y]):(y=n[(y=y<<8|y>>>24)>>>24]<<24|n[y>>>16&255]<<16|n[y>>>8&255]<<8|n[255&y],y^=d[a/r|0]<<24),o[a]=o[a-r]^y);for(var c=this._invKeySchedule=[],s=0;s>>24]]^u[n[y>>>16&255]]^p[n[y>>>8&255]]^h[n[255&y]]}}},encryptBlock:function(t,e){this._doCryptBlock(t,e,this._keySchedule,o,a,c,s,n)},decryptBlock:function(t,e){var r=t[e+1];t[e+1]=t[e+3],t[e+3]=r,this._doCryptBlock(t,e,this._invKeySchedule,f,u,p,h,i);r=t[e+1];t[e+1]=t[e+3],t[e+3]=r},_doCryptBlock:function(t,e,r,n,i,o,a,c){for(var s=this._nRounds,f=t[e]^r[0],u=t[e+1]^r[1],p=t[e+2]^r[2],h=t[e+3]^r[3],d=4,y=1;y>>24]^i[u>>>16&255]^o[p>>>8&255]^a[255&h]^r[d++],_=n[u>>>24]^i[p>>>16&255]^o[h>>>8&255]^a[255&f]^r[d++],g=n[p>>>24]^i[h>>>16&255]^o[f>>>8&255]^a[255&u]^r[d++],v=n[h>>>24]^i[f>>>16&255]^o[u>>>8&255]^a[255&p]^r[d++];f=l,u=_,p=g,h=v}l=(c[f>>>24]<<24|c[u>>>16&255]<<16|c[p>>>8&255]<<8|c[255&h])^r[d++],_=(c[u>>>24]<<24|c[p>>>16&255]<<16|c[h>>>8&255]<<8|c[255&f])^r[d++],g=(c[p>>>24]<<24|c[h>>>16&255]<<16|c[f>>>8&255]<<8|c[255&u])^r[d++],v=(c[h>>>24]<<24|c[f>>>16&255]<<16|c[u>>>8&255]<<8|c[255&p])^r[d++];t[e]=l,t[e+1]=_,t[e+2]=g,t[e+3]=v},keySize:8});t.AES=e._createHelper(y)}();var _iv,_sa,_config,_oldOnceData,CryptoJS=_CryptoJS.CryptoJS,getRandomBasic=function(){var t=(new Date).getTime();return function(e){return Math.ceil((t=(9301*t+49297)%233280)/233280*e)}}();function isObject(t){return null!=t&&"[object Object]"==toString.call(t)}function getRandom(){if("function"==typeof Uint32Array){var t="";if("undefined"!=typeof crypto?t=crypto:"undefined"!=typeof msCrypto&&(t=msCrypto),isObject(t)&&t.getRandomValues){var e=new Uint32Array(1);return t.getRandomValues(e)[0]/Math.pow(2,32)}}return getRandomBasic(1e19)/1e19}function buildAESOption(t){return{mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7,iv:t||generateIVData()}}function encryptData(t,e,r,n){var i=buildAESOption(r),o=t;"string"!=typeof t&&(o=JSON.stringify(t)),n||(e=CryptoJS.enc.Base64.parse(e));var a=CryptoJS.enc.Utf8.parse(o),c=CryptoJS.AES.encrypt(a,e,i).toString();return i.iv.clone().concat(CryptoJS.enc.Base64.parse(c)).toString(CryptoJS.enc.Base64)}function decryptData(t,e,r){var n=CryptoJS.enc.Base64.parse(t).toString(),i=n.substr(0,32),o=CryptoJS.enc.Hex.parse(n.substr(32)).toString(CryptoJS.enc.Base64),a=buildAESOption(CryptoJS.enc.Hex.parse(i));return r||(e=CryptoJS.enc.Base64.parse(e)),CryptoJS.AES.decrypt(o,e,a).toString(CryptoJS.enc.Utf8)}function generateIVData(t){t=t||16;for(var e="";t-- >0;){var r=Math.ceil(127*getRandom()).toString(16);e+=2===r.length?r:"0"+r}return CryptoJS.enc.Hex.parse(e)}var _log=console&&console.log||function(){};function isTruthy(t,e){return!!t||(_log(e+"\u4e0d\u80fd\u4e3a\u7a7a。"),!1)}function matchType(t,e,r){return typeof t===r||(_log("\u53c2\u6570\u7c7b\u578b\u9519\u8bef,"+e+"\u5fc5\u987b\u4e3a"+r),!1)}function aesEncrypt(t){try{return encryptData(t,_config.k,_iv)}catch(e){return _log("\u6570\u636e\u52a0\u5bc6\u5f02\u5e38\uff1a"+e),_sa.para.batch_send?"":_oldOnceData.call(_sa.kit,t)}}function formatData(t){var e={key_id:_config.kid,key_hash:_config.khash,nc:1},r="payload";return _sa.para.batch_send&&(e.flush_time=Date.now(),r="payloads"),e[r]=t,e}function encodeTrackData(t){if(_sa.para.batch_send)var e=formatData(t);else e=formatData(aesEncrypt(t));var r=JSON.stringify(e);return"data="+encodeURIComponent(r)+"&gzip=9"}function isObject$1(t){return null!=t&&"[object Object]"==toString.call(t)}function encryptStoreData(t){var e=t.length;if(e>0){for(var r=0;r0){for(var a=0;a=500&&(sa._.logger.info("\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38"),sa.store.mem.mdata.shift());var t=Date.now();e._flush_time=t,(e=kit.processData(e))&&sa.store.mem.add(e),sa.store.mem.getLength()>=sa.para.batch_send.max_length&&this.batchSend()},wxrequest:function(e){if(sa._.isArray(e.data)&&e.data.length>0){var t=kit.batchTrackData(e.data);sa._.wxrequest({url:sa.para.server_url,method:"POST",dataType:"text",data:t,success:function(){e.success(e.len)},fail:function(){e.fail()}})}else e.success(e.len)},batchSend:function(){if(this.dataHasSend){var e,t,r=sa.store.mem.mdata;(t=(e=r.length>=100?r.slice(0,100):r).length)>0&&(this.dataHasSend=!1,this.wxrequest({data:e,len:t,success:this.batchRemove.bind(this),fail:this.sendFail.bind(this)}))}},sendFail:function(){this.dataHasSend=!0,this.failTime++},batchRemove:function(e){sa.store.mem.clear(e),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite(),this.failTime=0},is_first_batch_write:!0,batchWrite:function(){var e=this;this.dataHasChange&&(this.is_first_batch_write&&(this.is_first_batch_write=!1,setTimeout(function(){e.batchSend()},1e3)),this.dataHasChange=!1,this.syncStorage&&sa._.setStorageSync(sa.para.storage_prepare_data_key,sa.store.mem.mdata))},batchInterval:function(){var e=this;!function t(){setTimeout(function(){e.batchWrite(),t()},500)}(),function t(){setTimeout(function(){e.batchSend(),t()},sa.para.batch_send.send_timeout*Math.pow(2,e.failTime))}()}};function getSendUrl(e,t){var r=kit.onceTrackData(t);return-1!==e.indexOf("?")?e+"&"+r:e+"?"+r}function onceSend(e){e._flush_time=Date.now();var t=getSendUrl(sa.para.server_url,e);sa._.wxrequest({url:t,method:"GET"})}var saEvent={send:function(e,t){if(!sa.para.server_url)return sa._.logger.info("error: server_url \u4e0d\u80fd\u4e3a\u7a7a"),!1;if(sa.current_scene&&1154===sa.current_scene&&!sa.para.preset_events.moments_page)return!1;var r=sa.kit.buildData(e);r?(saEvent.debug(r),sa.events.emit("send",r),sa.para.batch_send?sendStrategy.send(r):onceSend(r)):sa._.logger.info("error: \u6570\u636e\u5f02\u5e38 "+r)},debug:function(e){sa._.logger.info(e)}},_={};sa.kit=kit,sa.mergeStorageData=mergeStorageData,sa.saEvent=saEvent,sa.sendStrategy=sendStrategy,sa.IDENTITY_KEY={EMAIL:"$identity_email",MOBILE:"$identity_mobile"},sa.para={name:"sensors",server_url:"",send_timeout:1e3,show_log:!1,login_id_key:"$identity_login_id",allow_amend_share_path:!0,max_string_length:500,datasend_timeout:3e3,source_channel:[],autoTrack:{appLaunch:!0,appShow:!0,appHide:!0,pageShow:!0,pageShare:!0,mpClick:!1,mpFavorite:!0,pageLeave:!1},autotrack_exclude_page:{pageShow:[]},is_persistent_save:{share:!1,utm:!1},preset_properties:{url_path:!0},preset_events:{moments_page:!1,defer_track:!1,share_info_use_string:!1},batch_send:!0,storage_store_key:"sensorsdata2015_wechat",storage_prepare_data_key:"sensors_mp_prepare_data"};var mpHook={data:1,onLoad:1,onShow:1,onReady:1,onPullDownRefresh:1,onShareAppMessage:1,onShareTimeline:1,onReachBottom:1,onPageScroll:1,onResize:1,onTabItemTap:1,onHide:1,onUnload:1},logger="object"==typeof logger?logger:{};logger.info=function(){if(sa.para.show_log&&"object"==typeof console&&console.log)try{if(3===arguments.length)return console.log(arguments[0],arguments[1],arguments[2]);if(2===arguments.length)return console.log(arguments[0],arguments[1]);if(1===arguments.length)return console.log(arguments[0])}catch(e){console.log(arguments[0])}},sa.setPara=function(e){sa.para=_.extend2Lev(sa.para,e);var t=[];if(_.isArray(sa.para.source_channel))for(var r=sa.para.source_channel.length,a=0;asa.para.max_string_length?(logger.info("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,sa.para.max_string_length)):e},_.searchObjString=function(e){_.isObject(e)&&_.each(e,function(t,r){_.isObject(t)?_.searchObjString(e[r]):_.isString(t)&&(e[r]=_.formatString(t))})},_.parseSuperProperties=function(e){_.isObject(e)&&(_.each(e,function(t,r){if(_.isFunction(t))try{e[r]=t(),_.isFunction(e[r])&&(logger.info("\u60a8\u7684\u5c5e\u6027- "+r+" \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[r])}catch(t){delete e[r],logger.info("\u60a8\u7684\u5c5e\u6027- "+r+" \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}}),_.strip_sa_properties(e))},_.unique=function(e){for(var t,r=[],a={},s=0;s255)||(logger.info("id \u957f\u5ea6\u8d85\u8fc7 255 \u4e2a\u5b57\u7b26\uff01"),!1)}},_.strip_sa_properties=function(e){return _.isObject(e)?(_.each(e,function(t,r){if(_.isArray(t)){var a=[];_.each(t,function(e){_.isString(e)?a.push(e):logger.info("\u60a8\u7684\u6570\u636e-",t,"\u7684\u6570\u7ec4\u91cc\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32,\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}),e[r]=a}_.isString(t)||_.isNumber(t)||_.isDate(t)||_.isBoolean(t)||_.isArray(t)||(logger.info("\u60a8\u7684\u6570\u636e-",t,"-\u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[r])}),e):e},_.strip_empty_properties=function(e){var t={};return _.each(e,function(e,r){null!=e&&(t[r]=e)}),t},_.utf8Encode=function(e){var t,r,a,s,i="";for(t=r=0,a=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,s=0;s127&&n<2048?String.fromCharCode(n>>6|192,63&n|128):String.fromCharCode(n>>12|224,n>>6&63|128,63&n|128),null!==o&&(r>t&&(i+=e.substring(t,r)),i+=o,t=r=s+1)}return r>t&&(i+=e.substring(t,e.length)),i},_.base64Encode=function(e){var t,r,a,s,i,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,u=0,c="",p=[];if(!e)return e;e=_.utf8Encode(e);do{t=(i=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,r=i>>12&63,a=i>>6&63,s=63&i,p[u++]=n.charAt(t)+n.charAt(r)+n.charAt(a)+n.charAt(s)}while(o255||(a=e.charCodeAt(o++))>255||(s=e.charCodeAt(o++))>255)&&logger.info("Failed to execute 'btoa' : The string to be encoded contains characters outside of the Latin1 range."),n+=i.charAt((t=r<<16|a<<8|s)>>18&63)+i.charAt(t>>12&63)+i.charAt(t>>6&63)+i.charAt(63&t);return _?n.slice(0,_-3)+"===".substring(_):n},_.urlBase64Encode=function(e){return _.btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))},_.rot13obfs=function(e,t){t="number"==typeof t?t:13;for(var r=(e=String(e)).split(""),a=0,s=r.length;a(new Date).getTime()},_.getCurrentUrl=function(e){var t=_.getCurrentPath(),r="";return _.isObject(e)&&e.sensors_mp_encode_url_query&&(r=e.sensors_mp_encode_url_query),t?r?t+"?"+r:t:"\u672a\u53d6\u5230"},_.getPath=function(e){return e="string"==typeof e?e.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"},_.getMethods=function(e){var t=[];for(var r in e)"function"!=typeof e[r]||mpHook[r]||t.push(r);return t},_.isClick=function(e){return!!{tap:1,longpress:1,longtap:1}[e]},sa.initialState={queue:[],isComplete:!1,systemIsComplete:!1,storeIsComplete:!1,checkIsComplete:function(){this.systemIsComplete&&this.storeIsComplete&&(this.isComplete=!0,this.queue.length>0&&(_.each(this.queue,function(e){sa[e[0]].apply(sa,slice.call(e[1]))}),this.queue=[]))}},_.getCustomUtmFromQuery=function(e,t,r,a){if(!_.isObject(e))return{};var s={};if(e.sa_utm)for(var i in e)"sa_utm"!==i?_.include(sa.para.source_channel,i)&&(s[r+i]=e[i]):s[a+i]=e[i];else for(var i in e)-1===(" "+source_channel_standard+" ").indexOf(" "+i+" ")?_.include(sa.para.source_channel,i)&&(s[r+i]=e[i]):s[t+i]=e[i];return s},_.getObjFromQuery=function(e){var t=e.split("?"),r=[],a={};return t&&t[1]?(_.each(t[1].split("&"),function(e){(r=e.split("="))[0]&&r[1]&&(a[r[0]]=r[1])}),a):{}},_.setStorageSync=function(e,t){var r=function(){wx.setStorageSync(e,t)};try{r()}catch(e){logger.info("set Storage fail --",e);try{r()}catch(e){logger.info("set Storage fail again --",e)}}},_.getStorageSync=function(e){var t="";try{t=wx.getStorageSync(e)}catch(r){try{t=wx.getStorageSync(e)}catch(e){logger.info("getStorage fail")}}return t},_.getMPScene=function(e){return"number"==typeof e||"string"==typeof e&&""!==e?e="wx-"+String(e):"\u672a\u53d6\u5230\u503c"},_.objToParam=function(e,t){if("[object Object]"!==Object.prototype.toString.call(e))return logger.info("\u8bf7\u4f20\u5165\u6709\u6548\u5bf9\u8c61"),"";var r=[];for(var a in e)if(e.hasOwnProperty(a)){var s=e[a];void 0===s?r.push(a+"="):(s=t?encodeURIComponent(s):s,r.push(a+"="+s))}return r.join("&")},_.delObjectKey=function(e){if("[object Object]"===Object.prototype.toString.call(e))for(var t=0;t=2?(page_route_map.shift(),page_route_map.push(e)):page_route_map.push(e)}}catch(e){logger.info(e)}},_.getRefPage=function(){var e={route:"\u76f4\u63a5\u6253\u5f00",title:""};return page_route_map.length>1&&(e.title=page_route_map[0].title,e.route=page_route_map[0].route),e},_.getCurrentPageInfo=function(){var e=_.getCurrentPage(),t={title:"",url:""};if(e&&e.route){var r=e.sensors_mp_url_query?"?"+e.sensors_mp_url_query:"";t.title=_.getPageTitle(e.route),t.url=e.route+r}return t},_.setPageRefData=function(e,t,r){var a=_.getRefPage();_.isObject(e)&&(t?page_route_map.length>0&&t?(r=r?"?"+r:"",e.$referrer=_.getPath(t)+r,e.$referrer_title=_.getPageTitle(t)):(e.$referrer="\u76f4\u63a5\u6253\u5f00",e.$referrer_title=""):(e.$referrer=a.route,e.$referrer_title=a.title))},_.getPageTitle=function(e){if("\u672a\u53d6\u5230"===e||!e)return"";var t="";try{if(__wxConfig){var r=__wxConfig,a=__wxConfig.page||{},s=a[e]||a[e+".html"],i={},n={};if(r.global&&r.global.window&&r.global.window.navigationBarTitleText&&(i.titleVal=r.global.window.navigationBarTitleText),s&&s.window&&s.window.navigationBarTitleText&&(n.titleVal=s.window.navigationBarTitleText),!n.titleVal&&__wxAppCode__){var o=__wxAppCode__[e+".json"];o&&o.navigationBarTitleText&&(n.titleVal=o.navigationBarTitleText)}if(_.each(globalTitle,function(r,a){if(a===e)return t=r}),0===t.length){var u=_.extend(i,n);t=u.titleVal||""}}}catch(e){logger.info(e)}return t},_.wxrequest=function(e){if(_.compareSDKVersion(wxSDKVersion,"2.10.0")>=0)e.timeout=sa.para.datasend_timeout,wx.request(e);else{var t=wx.request(e);setTimeout(function(){_.isObject(t)&&_.isFunction(t.abort)&&t.abort()},sa.para.datasend_timeout)}},_.getAppInfoSync=function(){if(wx.getAccountInfoSync){var e=wx.getAccountInfoSync(),t=e&&e.miniProgram?e.miniProgram:{};return{appId:t.appId,appEnv:t.envVersion,appVersion:t.version}}return{}},_.getAppId=function(){var e=_.getAppInfoSync();return e&&e.appId?e.appId:""},_.validId=function(e){return"string"!=typeof e&&"number"!=typeof e||""===e?(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1):"number"!=typeof e||(e=String(e),/^\d+$/.test(e))?!!_.check.ckeckIdLength(e)&&e:(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1)},_.compareSDKVersion=function(e,t){e=e.split("."),t=t.split(".");for(var r=Math.max(e.length,t.length);e.lengthi)return 1;if(s-1?t.system.split(" ")[1]:t.system,wxSDKVersion=t.SDKVersion,e.$mp_client_app_version=t.version,e.$mp_client_basic_library_version=wxSDKVersion},complete:function(){var t=(new Date).getTimezoneOffset(),r=_.getAppInfoSync();_.isNumber(t)&&(e.$timezone_offset=t),r.appId&&(e.$app_id=r.appId),r.appVersion&&(e.$app_version=r.appVersion),sa.initialState.systemIsComplete=!0,sa.initialState.checkIsComplete()}})}wx.getNetworkType({success:function(t){e.$network_type=_.setUpperCase(t.networkType)},complete:t})}},sa._=_,_.eventEmitter=function(){this.sub=[]},_.eventEmitter.prototype={add:function(e){this.sub.push(e)},emit:function(e,t){this.sub.forEach(function(r){r.on(e,t)})}},_.eventSub=function(e){sa.events.add(this),this._events=[],this.handle=e,this.ready=!1},_.eventSub.prototype={on:function(e,t){if(this.ready){if(_.isFunction(this.handle))try{this.handle(e,t)}catch(e){logger.info(e)}}else this._events.push({event:e,data:t})},isReady:function(){var e=this;e.ready=!0,e._events.forEach(function(t){if(_.isFunction(e.handle))try{e.handle(t.event,t.data)}catch(e){logger.info(e)}})}},sa.eventSub=_.eventSub,sa.events=new _.eventEmitter,sa.usePlugin=function(e,t){"function"==typeof e.init&&e.init(sa,t)},sa.store={storageInfo:null,getUUID:function(){return Date.now()+"-"+Math.floor(1e7*getRandom())+"-"+getRandom().toString(16).replace(".","")+"-"+String(31242*getRandom()).replace(".","").slice(0,8)},getStorage:function(){return this.storageInfo?this.storageInfo:(this.storageInfo=sa._.getStorageSync(sa.para.storage_store_key)||"",this.storageInfo)},_state:{},mem:{mdata:[],getLength:function(){return this.mdata.length},add:function(e){this.mdata.push(e)},clear:function(e){this.mdata.splice(0,e)}},toState:function(e){var t=null;_.isJSONString(e)?(t=JSON.parse(e)).distinct_id?this._state=t:this.set("distinct_id",this.getUUID()):_.isObject(e)&&(t=e).distinct_id?this._state=t:this.set("distinct_id",this.getUUID());var r=this._state._first_id||this._state.first_id,a=this._state._distinct_id||this._state.distinct_id,s=this._state.openid,i=(this._state.history_login_id?this._state.history_login_id:{}).name;if(this._state.identities&&_.isString(this._state.identities)){var n=JSON.parse(_.rot13defs(this._state.identities));this._state.identities=n}if(this._state.identities&&_.isObject(this._state.identities)&&!_.isEmptyObject(this._state.identities)?this._state.identities.hasOwnProperty("$identity_anonymous_id")&&(this._state.identities.$identity_anonymous_id=r||a):(this._state.identities={},this._state.identities.$mp_id=this.getUUID(),this._state.identities.$identity_anonymous_id=r||a),s){var o=_.getOpenidNameByAppid();this._state.identities[o]=s}if(r)if(i&&this._state.identities.hasOwnProperty(i)){if(this._state.identities[i]!==a){for(var u in this._state.identities[i]=a,this._state.identities)this._state.identities.hasOwnProperty(u)&&"$mp_id"!==u&&u!==i&&delete this._state.identities[u];this._state.history_login_id.value=a}}else{for(var u in this._state.identities[sa.para.login_id_key]=a,this._state.identities)this._state.identities.hasOwnProperty(u)&&"$mp_id"!==u&&u!==sa.para.login_id_key&&delete this._state.identities[u];this._state.history_login_id={name:sa.para.login_id_key,value:a}}else{if(this._state.identities.hasOwnProperty("$identity_login_id")||this._state.identities.hasOwnProperty(i))for(var u in this._state.identities)this._state.identities.hasOwnProperty(u)&&"$mp_id"!==u&&"$identity_anonymous_id"!==u&&delete this._state.identities[u];this._state.history_login_id={name:"",value:""}}this.save()},getFirstId:function(){return this._state._first_id||this._state.first_id},getDistinctId:function(){return this._state._distinct_id||this._state.distinct_id},getUnionId:function(){var e={},t=this._state._first_id||this._state.first_id,r=this._state._distinct_id||this._state.distinct_id;return t&&r?(e.login_id=r,e.anonymous_id=t):e.anonymous_id=r,e},getProps:function(){return this._state.props||{}},setProps:function(e,t){var r=this._state.props||{};t?this.set("props",e):(_.extend(r,e),this.set("props",r))},set:function(e,t){var r={};for(var a in"string"==typeof e?r[e]=t:"object"==typeof e&&(r=e),this._state=this._state||{},r)this._state[a]=r[a],"first_id"===a?delete this._state._first_id:"distinct_id"===a&&(delete this._state._distinct_id,sa.events.emit("changeDistinctId"));this.save()},identitiesSet:function(e,t){var r={};switch(e){case"login":r.$mp_id=sa.store._state.identities.$mp_id,r[sa.para.login_id_key]=t;break;case"logout":r.$mp_id=sa.store._state.identities.$mp_id;break;case"identify":(r=_.deepCopy(sa.store._state.identities)).$identity_anonymous_id=t}sa.store.set("identities",r)},change:function(e,t){this._state["_"+e]=t},encryptStorage:function(){var e=this.getStorage(),t="data:enc;";_.isObject(e)?e=t+_.rot13obfs(JSON.stringify(e)):_.isString(e)&&-1===e.indexOf(t)&&(e=t+_.rot13obfs(e)),sa._.setStorageSync(sa.para.storage_store_key,e)},save:function(){var e=_.deepCopy(this._state),t=_.rot13obfs(JSON.stringify(e.identities));if(e.identities=t,delete e._first_id,delete e._distinct_id,sa.para.encrypt_storage){e="data:enc;"+_.rot13obfs(JSON.stringify(e))}sa._.setStorageSync(sa.para.storage_store_key,e)},init:function(){var e=this.getStorage();if(e)_.isString(e)&&-1!==e.indexOf("data:enc;")&&(e=e.substring("data:enc;".length),e=JSON.parse(_.rot13defs(e))),this.toState(e);else{is_first_launch=!0;var t=new Date,r=t.getTime();t.setHours(23),t.setMinutes(59),t.setSeconds(60),sa.setOnceProfile({$first_visit_time:new Date}),this.set({distinct_id:this.getUUID(),first_visit_time:r,first_visit_day_time:t.getTime(),identities:{$mp_id:this.getUUID()},history_login_id:{name:"",value:""}})}}},sa.setProfile=function(e,t){sa.saEvent.send({type:"profile_set",properties:e},t)},sa.setOnceProfile=function(e,t){sa.saEvent.send({type:"profile_set_once",properties:e},t)},sa.appendProfile=function(e,t){if(!_.isObject(e))return!1;_.each(e,function(t,r){_.isString(t)?e[r]=[t]:(delete e[r],logger.info("appendProfile\u5c5e\u6027\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32\u6216\u8005\u6570\u7ec4"))}),sa.saEvent.send({type:"profile_append",properties:e},t)},sa.incrementProfile=function(e,t){if(!_.isObject(e))return!1;var r=e;_.isString(e)&&((e={})[r]=1),sa.saEvent.send({type:"profile_increment",properties:e},t)},sa.track=function(e,t,r){this.saEvent.send({type:"track",event:e,properties:t},r)},sa.identify=function(e,t){if(e=_.validId(e)){var r=sa.store.getFirstId();!0===t?r?sa.store.set("first_id",e):sa.store.set("distinct_id",e):r?sa.store.change("first_id",e):sa.store.change("distinct_id",e),sa.store.identitiesSet("identify",e)}},sa.trackSignup=function(e,t,r,a){var s=sa.store.getFirstId()||sa.store.getDistinctId();sa.store.set("distinct_id",e),sa.saEvent.send({original_id:s,distinct_id:e,type:"track_signup",event:t,properties:r},a)},sa.registerApp=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&(_.info.currentProps=_.extend(_.info.currentProps,e))},sa.register=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&sa.store.setProps(e)},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.clearAllProps=function(e){var t=sa.store.getProps(),r={};_.isArray(e)&&(_.each(t,function(t,a){_.include(e,a)||(r[a]=t)}),sa.store.setProps(r,!0))},sa.clearAppRegister=function(e){_.isArray(e)&&_.each(_.info.currentProps,function(t,r){_.include(e,r)&&delete _.info.currentProps[r]})},_.setLatestChannel=function(e){_.isEmptyObject(e)||(function(e,t){var r=!1;for(var a in t)e[t[a]]&&(r=!0);return r}(e,latest_source_channel)&&(sa.clearAppRegister(latest_source_channel),sa.clearAllProps(latest_source_channel)),sa.para.is_persistent_save.utm?sa.register(e):sa.registerApp(e))},_.setLatestShare=function(e){(e.$latest_share_depth||e.$latest_share_distinct_id||e.$latest_share_url_path||e.$latest_share_method)&&(sa.clearAppRegister(latest_share_info),sa.clearAllProps(latest_share_info),sa.para.is_persistent_save.share?sa.register(e):sa.registerApp(e))},sa.login=function(e){if(e=_.validId(e)){var t=sa.store.getFirstId(),r=sa.store.getDistinctId();if(sa.store._state.identities.hasOwnProperty(sa.para.login_id_key)&&e===t)return!1;var a=!(sa.para.login_id_key===sa.store._state.history_login_id.name&&sa.store._state.history_login_id.value===e);a&&(sa.store._state.identities[sa.para.login_id_key]=e),a&&(t?sa.trackSignup(e,"$SignUp"):(sa.store.set("first_id",r),sa.trackSignup(e,"$SignUp"))),a&&(sa.store.identitiesSet("login",e),sa.store.set("history_login_id",{name:sa.para.login_id_key,value:e}))}},sa.getAnonymousID=function(){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")},sa.logout=function(e){var t=sa.store.getFirstId();t?(sa.store.set("first_id",""),!0===e?sa.store.set("distinct_id",sa.store.getUUID()):sa.store.set("distinct_id",t)):logger.info("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25"),sa.store.identitiesSet("logout"),sa.store.set("history_login_id",{name:"",value:""})},sa.getLocation=function(){wx.getSetting({success:function(e){if(!e.authSetting["scope.userLocation"])return!1;wx.getLocation({type:sa.para.preset_properties.location.type,success:function(e){sa.registerApp({$latitude:e.latitude*Math.pow(10,6),$longitude:e.longitude*Math.pow(10,6),$geo_coordinate_system:_.setUpperCase(sa.para.preset_properties.location.type)})},fail:function(e){logger.info("\u83b7\u53d6\u4f4d\u7f6e\u5931\u8d25",e)}})}})},sa.openid={getRequest:function(e){wx.login({success:function(t){t.code&&sa.para.appid&&sa.para.openid_url?_.wxrequest({url:sa.para.openid_url+"&code="+t.code+"&appid="+sa.para.appid,method:"GET",complete:function(t){_.isObject(t)&&_.isObject(t.data)&&t.data.openid?e(t.data.openid):e()}}):e()}})},getWXStorage:function(){var e=sa.store.getStorage();if(e&&_.isObject(e))return e.openid},getOpenid:function(e){if(!sa.para.appid)return e(),!1;var t=this.getWXStorage();t?e(t):this.getRequest(e)}},sa.initial=function(){this._.info.getSystem(),this.store.init()},sa.init=function(e){if(!0===this.hasInit)return!1;this.hasInit=!0,sa.setPara(e),sa.para.encrypt_storage&&this.store.encryptStorage(),sa.para.batch_send&&sendStrategy.init(),sa.initialState.storeIsComplete=!0,sa.initialState.checkIsComplete()},sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib){var e={};_.each(_.info.currentProps,function(t,r){0===r.indexOf("$")&&(e[r]=t)});var t=_.extend(e,{$url_path:_.getCurrentPath(),$is_first_day:_.getIsFirstDay()},_.info.properties,sa.store.getProps());return delete t.$lib,t}return{}},sa.setOpenid=function(e,t){if(!(e=_.validId(e)))return!1;var r=sa.store.getFirstId();sa.store.set("openid",e),t?sa.store.set("distinct_id",e):(sa.identify(e,!0),r?sa.store.set("first_id",e):sa.store.set("distinct_id",e)),sa.bind("$mp_openid",e)},sa.unsetOpenid=function(e){var t=_.validId(e);if(!t)return!1;sa.store._state.openid===t&&sa.store.set("openid",""),sa.unbind("$mp_openid",t)},sa.setUnionid=function(e){var t=_.validId(e);t&&sa.bind("$mp_unionid",t)},sa.unsetUnionid=function(e){var t=_.validId(e);if(t){if(sa.store._state.identities.hasOwnProperty("$mp_unionid")&&t===sa.store._state.identities.$mp_unionid){var r=_.getOpenidNameByAppid();sa.store._state.identities.hasOwnProperty(r)&&(delete sa.store._state.identities[r],sa.store.save())}sa.unbind("$mp_unionid",t)}},sa.initWithOpenid=function(e,t){(e=e||{}).appid&&(sa.para.appid=e.appid),sa.openid.getOpenid(function(r){r&&sa.setOpenid(r,e.isCoverLogin),t&&_.isFunction(t)&&t(r),sa.init(e)})},sa.bind=function(e,t){if(_.isNumber(t)){if(_.isInteger(t)&&!1===_.isSafeInteger(t))return logger.info("Value must be String"),!1;t=String(t)}if(!_.isString(e))return logger.info("Key must be String"),!1;if(!_.check.checkKeyword(e)||"$identity_anonymous_id"===e||"$mp_id"===e||"$identity_login_id"===e||e===sa.para.login_id_key){var r="Key ["+e+"] is invalid";return logger.info(r),!1}if(!t||""===t)return logger.info("Value is empty or null"),!1;if(!_.isString(t))return logger.info("Value must be String"),!1;if(!_.check.ckeckIdLength(t)){r="Value ["+t+"] is beyond the maximum length 255";return logger.info(r),!1}var a=sa.store._state.identities;"$mp_openid"===e&&(e=_.getOpenidNameByAppid()),a[e]=t,sa.store.save(),sa.saEvent.send({type:"track_id_bind",event:"$BindID"})},sa.unbind=function(e,t){if(_.isNumber(t)){if(_.isInteger(t)&&!1===_.isSafeInteger(t))return logger.info("Value must be String"),!1;t=String(t)}if(!_.isString(e))return logger.info("Key must be String"),!1;if(!_.check.checkKeyword(e)||"$identity_anonymous_id"===e||"$mp_id"===e||"$identity_login_id"===e||e===sa.para.login_id_key){var r="Key ["+e+"] is invalid";return logger.info(r),!1}if(!t||""===t)return logger.info("Value is empty or null"),!1;if(!_.isString(t))return logger.info("Value must be String"),!1;if(!_.check.ckeckIdLength(t)){r="Value ["+t+"] is beyond the maximum length 255";return logger.info(r),!1}"$mp_openid"===e&&(e=_.getOpenidNameByAppid()),sa.store._state.identities.hasOwnProperty(e)&&t===sa.store._state.identities[e]&&(delete sa.store._state.identities[e],sa.store.save());var a={};a[e]=t,sa.saEvent.send({type:"track_id_unbind",event:"$UnbindID",unbind_value:a})},sa.setWebViewUrl=function(e,t){if(!_.isString(e)||""===e)return logger.info("error:\u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;if(!/^http(s)?:\/\//.test(e))return logger.info("warning: \u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;var r=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e);if(!r)return!1;var a,s=r[1]||"",i=r[2]||"",n=r[3]||"",o="",u=sa.store.getDistinctId()||"",c=sa.store.getFirstId()||"";_.urlSafeBase64&&_.urlSafeBase64.encode?u=u?_.urlSafeBase64.trim(_.urlSafeBase64.encode(_.urlBase64Encode(u))):"":this._.rot13obfs&&(u=u?_.rot13obfs(u):""),u=encodeURIComponent(u);var p=c?"f"+u:"d"+u;t?(a=n.indexOf("_sasdk"),o=n.indexOf("?")>-1?a>-1?s+i+"#"+n.substring(1,a)+"_sasdk="+p:s+i+"#"+n.substring(1)+"&_sasdk="+p:s+i+"#"+n.substring(1)+"?_sasdk="+p):(a=i.indexOf("_sasdk"),o=/^\?(\w)+/.test(i)?a>-1?s+i.replace(/(_sasdk=)([^&]*)/gi,"_sasdk="+p)+n:s+"?"+i.substring(1)+"&_sasdk="+p+n:s+"?"+i.substring(1)+"_sasdk="+p+n);return o},_.each(["setProfile","setOnceProfile","track","quick","incrementProfile","appendProfile","login","logout","registerApp","register","clearAllRegister","clearAllProps","clearAppRegister","bind","unbind"],function(e){var t=sa[e];sa[e]=function(){sa.initialState.isComplete?t.apply(sa,arguments):sa.initialState.queue.push([e,arguments])}}),_.setQuery=function(e,t){if(e&&_.isObject(e)&&!_.isEmptyObject(e)){var r=[];return _.each(e,function(e,a){"q"===a&&_.isString(e)&&0===e.indexOf("http")||(t?r.push(a+"="+e):r.push(a+"="+_.decodeURIComponent(e)))}),r.join("&")}return""},_.getUtmFromPage=function(){var e={};try{var t=_.getCurrentPage(),r=_.deepCopy(t.options);for(var a in r)r[a]=_.decodeURIComponent(r[a]);e=_.getCustomUtmFromQuery(r,"$","_","$")}catch(e){logger.info(e)}return e},_.sendPageLeave=function(){var e={},t="";try{t=(e=_.getCurrentPage())?e.route:""}catch(e){logger.info(e)}if(page_show_time>=0&&""!==t){var r={},a=_.getPageTitle(t),s=(Date.now()-page_show_time)/1e3;r.$url_query=e.sensors_mp_url_query?e.sensors_mp_url_query:"",r.$url_path=t,r.$title=a,r.event_duration=s,sa.track("$MPPageLeave",r),page_show_time=-1}},sa.autoTrackCustom={trackCustom:function(e,t,r){var a=sa.para.autoTrack[e],s="";sa.para.autoTrack&&a&&("function"==typeof a?(s=a(),_.isObject(s)&&_.extend(t,s)):_.isObject(a)&&(_.extend(t,a),sa.para.autoTrack[e]=!0),sa.track(r,t))},appLaunch:function(e,t){"object"!=typeof this||this.trackCustom||(this[sa.para.name]=sa);var r={};if(e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,r.$scene=_.getMPScene(e.scene)):r.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path){if(r.$url_path=_.getPath(e.path),r.$title=_.getPageTitle(e.path),e.query&&_.isObject(e.query)){var a=_.setQuery(e.query);a=a?"?"+a:"",r.$url=r.$url_path+a}!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:r.$url_path})}_.setShareInfo(e,r);var s=_.setUtm(e,r);is_first_launch?(r.$is_first_time=!0,_.isEmptyObject(s.pre1)||sa.setOnceProfile(s.pre1)):r.$is_first_time=!1,_.setLatestChannel(s.pre2),_.setSfSource(e,r),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(e.query),_.setPageRefData(r),t?(r=_.extend(r,t),sa.track("$MPLaunch",r)):sa.para.autoTrack&&sa.para.autoTrack.appLaunch&&sa.autoTrackCustom.trackCustom("appLaunch",r,"$MPLaunch")},appShow:function(e,t){var r={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,r.$scene=_.getMPScene(e.scene)):r.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(r.$url_path=_.getPath(e.path),r.$title=_.getPageTitle(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:r.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,r);var a=_.setUtm(e,r);_.setLatestChannel(a.pre2),_.setSfSource(e,r),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(e.query),_.setPageRefData(r,e.path,r.$url_query),e&&e.path&&(r.$url=e.path+(r.$url_query?"?"+r.$url_query:"")),t?(r=_.extend(r,t),sa.track("$MPShow",r)):sa.para.autoTrack&&sa.para.autoTrack.appShow&&sa.autoTrackCustom.trackCustom("appShow",r,"$MPShow")},appHide:function(e){var t=(new Date).getTime(),r={};r.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(r.event_duration=(t-mpshow_time)/1e3),_.setPageRefData(r),e?(r=_.extend(r,e),sa.track("$MPHide",r)):sa.para.autoTrack&&sa.para.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",r,"$MPHide"),sendStrategy.onAppHide()},pageLoad:function(e){current_scene&&1010===current_scene&&e&&(e.sampshare&&delete e.sampshare,_.delObjectKey(e)),e&&_.isObject(e)&&(this.sensors_mp_url_query=_.setQuery(e),this.sensors_mp_encode_url_query=_.setQuery(e,!0))},pageShow:function(){page_show_time=Date.now();var e={},t=_.getCurrentPath(),r=_.getPageTitle(t);_.setRefPage(),e.$url_path=t,e.$url_query=this.sensors_mp_url_query?this.sensors_mp_url_query:"",e=_.extend(e,_.getUtmFromPage()),_.setPageRefData(e),_.setPageSfSource(e),r&&(e.$title=r),sa.para.onshow?sa.para.onshow(sa,t,this):_.isObject(sa.para.autotrack_exclude_page)&&_.isArray(sa.para.autotrack_exclude_page.pageShow)&&-1!==sa.para.autotrack_exclude_page.pageShow.indexOf(t)||sa.autoTrackCustom.trackCustom("pageShow",e,"$MPViewScreen"),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:t})},pageShare:function(e){var t=e.onShareAppMessage;e.onShareAppMessage=function(){share_method="\u8f6c\u53d1\u6d88\u606f\u5361\u7247";var e=t.apply(this,arguments);if(sa.para.autoTrack&&sa.para.autoTrack.pageShare){var r={$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method};_.setPageRefData(r),sa.autoTrackCustom.trackCustom("pageShare",r,"$MPShare")}return sa.para.allow_amend_share_path&&("object"!=typeof e&&((e={}).path=_.getCurrentUrl(this)),"object"!=typeof e||void 0!==e.path&&""!==e.path||(e.path=_.getCurrentUrl(this)),"object"==typeof e&&"string"==typeof e.path&&(-1===e.path.indexOf("?")?e.path=e.path+"?":"&"!==e.path.slice(-1)&&(e.path=e.path+"&")),e.path=e.path+_.getShareInfo()),e}},pageShareTimeline:function(e){var t=e.onShareTimeline;e.onShareTimeline=function(){share_method="\u670b\u53cb\u5708\u5206\u4eab";var e=t.apply(this,arguments);if(sa.para.autoTrack&&sa.para.autoTrack.pageShare){var r={$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method};_.setPageRefData(r),sa.autoTrackCustom.trackCustom("pageShare",r,"$MPShare")}return sa.para.allow_amend_share_path&&("object"!=typeof e&&(e={}),"object"==typeof e&&void 0===e.query&&(e.query=""),"object"==typeof e&&"string"==typeof e.query&&""!==e.query&&"&"!==e.query.slice(-1)&&(e.query=e.query+"&"),e.query=e.query+_.getShareInfo()),e}},pageAddFavorites:function(){var e={};e.$url_path=_.getCurrentPath(),sa.para.autoTrack&&sa.para.autoTrack.mpFavorite&&sa.autoTrackCustom.trackCustom("mpFavorite",e,"$MPAddFavorites")}},sa.quick=function(){var e=arguments[0],t=arguments[1],r=arguments[2],a=_.isObject(r)?r:{};if("getAnonymousID"===e){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===e||"appShow"===e?t?sa.autoTrackCustom[e](t,a):logger.info("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(a=_.isObject(t)?t:{},sa.autoTrackCustom[e](a))},sa.appLaunch=function(e,t){var r={};e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,r.$scene=_.getMPScene(e.scene)):r.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(r.$url_path=_.getPath(e.path),r.$title=_.getPageTitle(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:r.$url_path})),_.setShareInfo(e,r);var a=_.setUtm(e,r);is_first_launch?(r.$is_first_time=!0,_.isEmptyObject(a.pre1)||sa.setOnceProfile(a.pre1)):r.$is_first_time=!1,_.setLatestChannel(a.pre2),_.setSfSource(e,r),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(e.query),r.$url=e.path+(r.$url_query?"?"+r.$url_query:""),_.setPageRefData(t),_.isObject(t)&&(r=_.extend(r,t)),sa.track("$MPLaunch",r)},sa.appShow=function(e,t){var r={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,r.$scene=_.getMPScene(e.scene)):r.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(r.$url_path=_.getPath(e.path),r.$title=_.getPageTitle(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:r.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,r);var a=_.setUtm(e,r);_.setLatestChannel(a.pre2),_.setSfSource(e,r),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(e.query),e&&e.path&&(r.$url=e.path+(r.$url_query?"?"+r.$url_query:"")),_.setPageRefData(r,e.path,r.$url_query),_.isObject(t)&&(r=_.extend(r,t)),sa.track("$MPShow",r)},sa.appHide=function(e){var t=(new Date).getTime(),r={};r.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(r.event_duration=(t-mpshow_time)/1e3),_.setPageRefData(r),_.isObject(e)&&(r=_.extend(r,e)),sa.track("$MPHide",r),sendStrategy.onAppHide()},sa.pageShow=function(e){var t={},r=_.getCurrentPath(),a=_.getPageTitle(r),s=_.getCurrentPage();_.setRefPage(),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:r}),a&&(t.$title=a),t.$url_path=r,t.$url_query=s.sensors_mp_url_query?s.sensors_mp_url_query:"",t=_.extend(t,_.getUtmFromPage()),_.setPageSfSource(t),_.setPageRefData(t),_.isObject(e)&&(t=_.extend(t,e)),sa.track("$MPViewScreen",t)},global&&global.sensors_data_pre_config){var key=global.sensors_data_pre_config.login_id_key;key&&_.isString(key)&&_.check.checkKeyword(key)&&"$identity_anonymous_id"!==key&&"$mp_id"!==key&&"$mp_unionid"!==key?sa.para.login_id_key=key:logger.info("\u8bbe\u7f6e\u81ea\u5b9a\u4e49\u767b\u5f55 ID \u5931\u8d25")}sa.initial();export default sa; \ No newline at end of file +var sa={};function isObject(e){return null!=e&&"[object Object]"==toString.call(e)}var getRandomBasic=function(){var e=(new Date).getTime();return function(t){return Math.ceil((e=(9301*e+49297)%233280)/233280*t)}}();function getRandom(){if("function"==typeof Uint32Array){var e="";if("undefined"!=typeof crypto?e=crypto:"undefined"!=typeof msCrypto&&(e=msCrypto),isObject(e)&&e.getRandomValues){var t=new Uint32Array(1);return e.getRandomValues(t)[0]/Math.pow(2,32)}}return getRandomBasic(1e19)/1e19}var kit={};function encodeTrackData(e){e=JSON.stringify(e);var t=sa._.base64Encode(e);return encodeURIComponent(t)}function setPublicPProperties(e){if(e&&e.properties){var t=sa._.getRefPage(),r=sa._.getCurrentPageInfo(),a={$referrer:t.route,$referrer_title:t.title,$title:r.title,$url:r.url};for(var s in!0===sa.para.preset_properties.url_path&&(a.$url_path=r.path),a)e.properties.hasOwnProperty(s)||(e.properties[s]=a[s])}}kit.buildData=function(e){var t=sa._,r={distinct_id:sa.store.getDistinctId(),identities:sa.store._state.identities,lib:{$lib:sa.lib_name,$lib_method:"code",$lib_version:sa.lib_version},properties:{}};return"track_id_unbind"===e.type&&"$UnbindID"===e.event&&(r.identities=t.deepCopy(e.unbind_value),delete e.unbind_value),t.extend(r,sa.store.getUnionId(),e),t.isObject(e.properties)&&!t.isEmptyObject(e.properties)&&t.extend(r.properties,e.properties),e.type&&"profile"===e.type.slice(0,7)||(r._track_id=Number(String(getRandom()).slice(2,5)+String(getRandom()).slice(2,4)+String(Date.now()).slice(-4)),r.properties=t.extend({},t.info.properties,sa.store.getProps(),t.info.currentProps,r.properties),"track"===e.type&&(r.properties.$is_first_day=t.getIsFirstDay()),setPublicPProperties(r)),r.properties.$time&&t.isDate(r.properties.$time)?(r.time=1*r.properties.$time,delete r.properties.$time):r.time=1*new Date,t.parseSuperProperties(r.properties),t.searchObjDate(r),t.searchObjString(r),r},kit.processData=function(e){return e},kit.onceTrackData=function(e){return"data="+encodeTrackData(e)},kit.batchTrackData=function(e){var t=Date.now();return e.forEach(function(e){e._flush_time=t}),"data_list="+encodeTrackData(e)};var mergeStorageData={getData:function(e){wx.getStorage({key:sa.para.storage_prepare_data_key,complete:function(t){var r=t.data&&sa._.isArray(t.data)?t.data:[];mergeStorageData.deleteAesData(r),e&&e()}})},deleteAesData:function(e){var t=[],r=e.length;if(r>0){for(var a=0;a=500&&(sa._.logger.info("\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38"),sa.store.mem.mdata.shift()),(e=kit.processData(e))&&sa.store.mem.add(e),sa.store.mem.getLength()>=sa.para.batch_send.max_length&&this.batchSend()},wxrequest:function(e){if(sa._.isArray(e.data)&&e.data.length>0){var t=kit.batchTrackData(e.data);sa._.wxrequest({url:sa.para.server_url,method:"POST",dataType:"text",data:t,success:function(){e.success(e.len)},fail:function(){e.fail()}})}else e.success(e.len)},batchSend:function(){if(this.dataHasSend){var e,t,r=sa.store.mem.mdata;(t=(e=r.length>=100?r.slice(0,100):r).length)>0&&(this.dataHasSend=!1,this.wxrequest({data:e,len:t,success:this.batchRemove.bind(this),fail:this.sendFail.bind(this)}))}},sendFail:function(){this.dataHasSend=!0,this.failTime++},batchRemove:function(e){sa.store.mem.clear(e),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite(),this.failTime=0},is_first_batch_write:!0,batchWrite:function(){var e=this;this.dataHasChange&&(this.is_first_batch_write&&(this.is_first_batch_write=!1,setTimeout(function(){e.batchSend()},1e3)),this.dataHasChange=!1,this.syncStorage&&sa._.setStorageSync(sa.para.storage_prepare_data_key,sa.store.mem.mdata))},batchInterval:function(){var e=this;!function t(){setTimeout(function(){e.batchWrite(),t()},500)}(),function t(){setTimeout(function(){e.batchSend(),t()},sa.para.batch_send.send_timeout*Math.pow(2,e.failTime))}()}};function getSendUrl(e,t){var r=kit.onceTrackData(t);return-1!==e.indexOf("?")?e+"&"+r:e+"?"+r}function onceSend(e){e._flush_time=Date.now();var t=getSendUrl(sa.para.server_url,e);sa._.wxrequest({url:t,method:"GET"})}var saEvent={send:function(e,t){if(!sa.para.server_url)return sa._.logger.info("error: server_url \u4e0d\u80fd\u4e3a\u7a7a"),!1;if(sa.current_scene&&1154===sa.current_scene&&!sa.para.preset_events.moments_page)return!1;var r=sa.kit.buildData(e);r?(saEvent.debug(r),sa.events.emit("send",r),sa.para.batch_send?sendStrategy.send(r):onceSend(r)):sa._.logger.info("error: \u6570\u636e\u5f02\u5e38 "+r)},debug:function(e){sa._.logger.info(e)}},_={};sa.kit=kit,sa.mergeStorageData=mergeStorageData,sa.saEvent=saEvent,sa.sendStrategy=sendStrategy,sa.IDENTITY_KEY={EMAIL:"$identity_email",MOBILE:"$identity_mobile"},sa.para={name:"sensors",server_url:"",send_timeout:1e3,show_log:!1,login_id_key:"$identity_login_id",allow_amend_share_path:!0,max_string_length:500,datasend_timeout:3e3,source_channel:[],autoTrack:{appLaunch:!0,appShow:!0,appHide:!0,pageShow:!0,pageShare:!0,mpClick:!1,mpFavorite:!0,pageLeave:!1},autotrack_exclude_page:{pageShow:[]},is_persistent_save:{share:!1,utm:!1},preset_properties:{url_path:!0},preset_events:{moments_page:!1,defer_track:!1,share_info_use_string:!1},batch_send:!0,storage_store_key:"sensorsdata2015_wechat",storage_prepare_data_key:"sensors_mp_prepare_data"};var mpHook={data:1,onLoad:1,onShow:1,onReady:1,onPullDownRefresh:1,onShareAppMessage:1,onShareTimeline:1,onReachBottom:1,onPageScroll:1,onResize:1,onTabItemTap:1,onHide:1,onUnload:1},logger="object"==typeof logger?logger:{};logger.info=function(){if(sa.para.show_log&&"object"==typeof console&&console.log)try{if(3===arguments.length)return console.log(arguments[0],arguments[1],arguments[2]);if(2===arguments.length)return console.log(arguments[0],arguments[1]);if(1===arguments.length)return console.log(arguments[0])}catch(e){console.log(arguments[0])}},sa.setPara=function(e){sa.para=_.extend2Lev(sa.para,e);var t=[];if(_.isArray(sa.para.source_channel))for(var r=sa.para.source_channel.length,a=0;asa.para.max_string_length?(logger.info("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,sa.para.max_string_length)):e},_.searchObjString=function(e){_.isObject(e)&&_.each(e,function(t,r){_.isObject(t)?_.searchObjString(e[r]):_.isString(t)&&(e[r]=_.formatString(t))})},_.parseSuperProperties=function(e){_.isObject(e)&&(_.each(e,function(t,r){if(_.isFunction(t))try{e[r]=t(),_.isFunction(e[r])&&(logger.info("\u60a8\u7684\u5c5e\u6027- "+r+" \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[r])}catch(t){delete e[r],logger.info("\u60a8\u7684\u5c5e\u6027- "+r+" \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}}),_.strip_sa_properties(e))},_.unique=function(e){for(var t,r=[],a={},s=0;s255)||(logger.info("id \u957f\u5ea6\u8d85\u8fc7 255 \u4e2a\u5b57\u7b26\uff01"),!1)}},_.strip_sa_properties=function(e){return _.isObject(e)?(_.each(e,function(t,r){if(_.isArray(t)){var a=[];_.each(t,function(e){_.isString(e)?a.push(e):logger.info("\u60a8\u7684\u6570\u636e-",t,"\u7684\u6570\u7ec4\u91cc\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32,\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}),e[r]=a}_.isString(t)||_.isNumber(t)||_.isDate(t)||_.isBoolean(t)||_.isArray(t)||(logger.info("\u60a8\u7684\u6570\u636e-",t,"-\u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[r])}),e):e},_.strip_empty_properties=function(e){var t={};return _.each(e,function(e,r){null!=e&&(t[r]=e)}),t},_.utf8Encode=function(e){var t,r,a,s,i="";for(t=r=0,a=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,s=0;s127&&n<2048?String.fromCharCode(n>>6|192,63&n|128):String.fromCharCode(n>>12|224,n>>6&63|128,63&n|128),null!==o&&(r>t&&(i+=e.substring(t,r)),i+=o,t=r=s+1)}return r>t&&(i+=e.substring(t,e.length)),i},_.base64Encode=function(e){var t,r,a,s,i,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,u=0,c="",p=[];if(!e)return e;e=_.utf8Encode(e);do{t=(i=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,r=i>>12&63,a=i>>6&63,s=63&i,p[u++]=n.charAt(t)+n.charAt(r)+n.charAt(a)+n.charAt(s)}while(o255||(a=e.charCodeAt(o++))>255||(s=e.charCodeAt(o++))>255)&&logger.info("Failed to execute 'btoa' : The string to be encoded contains characters outside of the Latin1 range."),n+=i.charAt((t=r<<16|a<<8|s)>>18&63)+i.charAt(t>>12&63)+i.charAt(t>>6&63)+i.charAt(63&t);return _?n.slice(0,_-3)+"===".substring(_):n},_.urlBase64Encode=function(e){return _.btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))},_.rot13obfs=function(e,t){t="number"==typeof t?t:13;for(var r=(e=String(e)).split(""),a=0,s=r.length;a(new Date).getTime()},_.getCurrentUrl=function(e){var t=_.getCurrentPath(),r="";return _.isObject(e)&&e.sensors_mp_encode_url_query&&(r=e.sensors_mp_encode_url_query),t?r?t+"?"+r:t:"\u672a\u53d6\u5230"},_.getPath=function(e){return e="string"==typeof e?e.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"},_.getMethods=function(e){var t=[];for(var r in e)"function"!=typeof e[r]||mpHook[r]||t.push(r);return t},_.isClick=function(e){return!!{tap:1,longpress:1,longtap:1}[e]},sa.initialState={queue:[],isComplete:!1,systemIsComplete:!1,storeIsComplete:!1,checkIsComplete:function(){this.systemIsComplete&&this.storeIsComplete&&(this.isComplete=!0,this.queue.length>0&&(_.each(this.queue,function(e){sa[e[0]].apply(sa,slice.call(e[1]))}),this.queue=[]))}},_.getCustomUtmFromQuery=function(e,t,r,a){if(!_.isObject(e))return{};var s={};if(e.sa_utm)for(var i in e)"sa_utm"!==i?_.include(sa.para.source_channel,i)&&(s[r+i]=e[i]):s[a+i]=e[i];else for(var i in e)-1===(" "+source_channel_standard+" ").indexOf(" "+i+" ")?_.include(sa.para.source_channel,i)&&(s[r+i]=e[i]):s[t+i]=e[i];return s},_.getObjFromQuery=function(e){var t=e.split("?"),r=[],a={};return t&&t[1]?(_.each(t[1].split("&"),function(e){(r=e.split("="))[0]&&r[1]&&(a[r[0]]=r[1])}),a):{}},_.setStorageSync=function(e,t){var r=function(){wx.setStorageSync(e,t)};try{r()}catch(e){logger.info("set Storage fail --",e);try{r()}catch(e){logger.info("set Storage fail again --",e)}}},_.getStorageSync=function(e){var t="";try{t=wx.getStorageSync(e)}catch(r){try{t=wx.getStorageSync(e)}catch(e){logger.info("getStorage fail")}}return t},_.getMPScene=function(e){return"number"==typeof e||"string"==typeof e&&""!==e?e="wx-"+String(e):"\u672a\u53d6\u5230\u503c"},_.objToParam=function(e,t){if("[object Object]"!==Object.prototype.toString.call(e))return logger.info("\u8bf7\u4f20\u5165\u6709\u6548\u5bf9\u8c61"),"";var r=[];for(var a in e)if(e.hasOwnProperty(a)){var s=e[a];void 0===s?r.push(a+"="):(s=t?encodeURIComponent(s):s,r.push(a+"="+s))}return r.join("&")},_.delObjectKey=function(e){if("[object Object]"===Object.prototype.toString.call(e))for(var t=0;t=2?(page_route_map.shift(),page_route_map.push(e)):page_route_map.push(e)}}catch(e){logger.info(e)}},_.getRefPage=function(){var e={route:"\u76f4\u63a5\u6253\u5f00",title:""};return page_route_map.length>1&&(e.title=page_route_map[0].title,e.route=page_route_map[0].route),e},_.getCurrentPageInfo=function(){var e=_.getCurrentPage(),t={title:"",url:"",path:"\u672a\u53d6\u5230"};if(e&&e.route){var r=e.sensors_mp_url_query?"?"+e.sensors_mp_url_query:"";t.title=_.getPageTitle(e.route),t.url=e.route+r,t.path=e.route}return t},_.setPageRefData=function(e,t,r){var a=_.getRefPage();_.isObject(e)&&(t?page_route_map.length>0&&t?(r=r?"?"+r:"",e.$referrer=_.getPath(t)+r,e.$referrer_title=_.getPageTitle(t)):(e.$referrer="\u76f4\u63a5\u6253\u5f00",e.$referrer_title=""):(e.$referrer=a.route,e.$referrer_title=a.title))},_.getPageTitle=function(e){if("\u672a\u53d6\u5230"===e||!e)return"";var t="";try{if(__wxConfig){var r=__wxConfig,a=__wxConfig.page||{},s=a[e]||a[e+".html"],i={},n={};if(r.global&&r.global.window&&r.global.window.navigationBarTitleText&&(i.titleVal=r.global.window.navigationBarTitleText),s&&s.window&&s.window.navigationBarTitleText&&(n.titleVal=s.window.navigationBarTitleText),!n.titleVal&&__wxAppCode__){var o=__wxAppCode__[e+".json"];o&&o.navigationBarTitleText&&(n.titleVal=o.navigationBarTitleText)}if(_.each(globalTitle,function(r,a){if(a===e)return t=r}),0===t.length){var u=_.extend(i,n);t=u.titleVal||""}}}catch(e){logger.info(e)}return t},_.wxrequest=function(e){if(_.compareSDKVersion(wxSDKVersion,"2.10.0")>=0)e.timeout=sa.para.datasend_timeout,wx.request(e);else{var t=wx.request(e);setTimeout(function(){_.isObject(t)&&_.isFunction(t.abort)&&t.abort()},sa.para.datasend_timeout)}},_.getAppInfoSync=function(){if(wx.getAccountInfoSync){var e=wx.getAccountInfoSync(),t=e&&e.miniProgram?e.miniProgram:{};return{appId:t.appId,appEnv:t.envVersion,appVersion:t.version}}return{}},_.getAppId=function(){var e=_.getAppInfoSync();return e&&e.appId?e.appId:""},_.validId=function(e){return"string"!=typeof e&&"number"!=typeof e||""===e?(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1):"number"!=typeof e||(e=String(e),/^\d+$/.test(e))?!!_.check.ckeckIdLength(e)&&e:(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1)},_.compareSDKVersion=function(e,t){e=e.split("."),t=t.split(".");for(var r=Math.max(e.length,t.length);e.lengthi)return 1;if(s-1?t.system.split(" ")[1]:t.system,wxSDKVersion=t.SDKVersion,e.$mp_client_app_version=t.version,e.$mp_client_basic_library_version=wxSDKVersion},complete:function(){var t=(new Date).getTimezoneOffset(),r=_.getAppInfoSync();_.isNumber(t)&&(e.$timezone_offset=t),r.appId&&(e.$app_id=r.appId),r.appVersion&&(e.$app_version=r.appVersion),sa.initialState.systemIsComplete=!0,sa.initialState.checkIsComplete()}})}wx.getNetworkType({success:function(t){e.$network_type=_.setUpperCase(t.networkType)},complete:t})}},sa._=_,_.eventEmitter=function(){this.sub=[]},_.eventEmitter.prototype={add:function(e){this.sub.push(e)},emit:function(e,t){this.sub.forEach(function(r){r.on(e,t)})}},_.eventSub=function(e){sa.events.add(this),this._events=[],this.handle=e,this.ready=!1},_.eventSub.prototype={on:function(e,t){if(this.ready){if(_.isFunction(this.handle))try{this.handle(e,t)}catch(e){logger.info(e)}}else this._events.push({event:e,data:t})},isReady:function(){var e=this;e.ready=!0,e._events.forEach(function(t){if(_.isFunction(e.handle))try{e.handle(t.event,t.data)}catch(e){logger.info(e)}})}},sa.eventSub=_.eventSub,sa.events=new _.eventEmitter,sa.usePlugin=function(e,t){"function"==typeof e.init&&e.init(sa,t)},sa.store={storageInfo:null,getUUID:function(){return Date.now()+"-"+Math.floor(1e7*getRandom())+"-"+getRandom().toString(16).replace(".","")+"-"+String(31242*getRandom()).replace(".","").slice(0,8)},getStorage:function(){return this.storageInfo?this.storageInfo:(this.storageInfo=sa._.getStorageSync(sa.para.storage_store_key)||"",this.storageInfo)},_state:{},mem:{mdata:[],getLength:function(){return this.mdata.length},add:function(e){this.mdata.push(e)},clear:function(e){this.mdata.splice(0,e)}},toState:function(e){var t=null;_.isJSONString(e)?(t=JSON.parse(e)).distinct_id?this._state=t:this.set("distinct_id",this.getUUID()):_.isObject(e)&&(t=e).distinct_id?this._state=t:this.set("distinct_id",this.getUUID());var r=this._state._first_id||this._state.first_id,a=this._state._distinct_id||this._state.distinct_id,s=this._state.openid,i=(this._state.history_login_id?this._state.history_login_id:{}).name;if(this._state.identities&&_.isString(this._state.identities)){var n=JSON.parse(_.rot13defs(this._state.identities));this._state.identities=n}var o,u,c=_.getOpenidNameByAppid();if(this._state.identities&&_.isObject(this._state.identities)&&!_.isEmptyObject(this._state.identities)){var p=(o=_.getAppId(),u="$mp_openid",o&&(u="$mp_"+o+"_openid"),u);this._state.identities.hasOwnProperty("$mp_id")&&(this._state.identities.$identity_mp_id=this._state.identities.$mp_id,delete this._state.identities.$mp_id),this._state.identities.hasOwnProperty("$mp_unionid")&&(this._state.identities.$identity_mp_unionid=this._state.identities.$mp_unionid,delete this._state.identities.$mp_unionid),this._state.identities.hasOwnProperty(p)&&(this._state.identities[c]=this._state.identities[p],delete this._state.identities[p]),this._state.identities.hasOwnProperty("$identity_anonymous_id")&&(this._state.identities.$identity_anonymous_id=r||a)}else this._state.identities={},this._state.identities.$identity_mp_id=this.getUUID(),this._state.identities.$identity_anonymous_id=r||a;if(s&&(this._state.identities[c]=s),r)if(i&&this._state.identities.hasOwnProperty(i)){if(this._state.identities[i]!==a){for(var d in this._state.identities[i]=a,this._state.identities)this._state.identities.hasOwnProperty(d)&&"$identity_mp_id"!==d&&d!==i&&delete this._state.identities[d];this._state.history_login_id.value=a}}else{for(var d in this._state.identities[sa.para.login_id_key]=a,this._state.identities)this._state.identities.hasOwnProperty(d)&&"$identity_mp_id"!==d&&d!==sa.para.login_id_key&&delete this._state.identities[d];this._state.history_login_id={name:sa.para.login_id_key,value:a}}else{if(this._state.identities.hasOwnProperty("$identity_login_id")||this._state.identities.hasOwnProperty(i))for(var d in this._state.identities)this._state.identities.hasOwnProperty(d)&&"$identity_mp_id"!==d&&"$identity_anonymous_id"!==d&&delete this._state.identities[d];this._state.history_login_id={name:"",value:""}}this.save()},getFirstId:function(){return this._state._first_id||this._state.first_id},getDistinctId:function(){return this._state._distinct_id||this._state.distinct_id},getUnionId:function(){var e={},t=this._state._first_id||this._state.first_id,r=this._state._distinct_id||this._state.distinct_id;return t&&r?(e.login_id=r,e.anonymous_id=t):e.anonymous_id=r,e},getProps:function(){return this._state.props||{}},setProps:function(e,t){var r=this._state.props||{};t?this.set("props",e):(_.extend(r,e),this.set("props",r))},set:function(e,t){var r={};for(var a in"string"==typeof e?r[e]=t:"object"==typeof e&&(r=e),this._state=this._state||{},r)this._state[a]=r[a],"first_id"===a?delete this._state._first_id:"distinct_id"===a&&(delete this._state._distinct_id,sa.events.emit("changeDistinctId"));this.save()},identitiesSet:function(e,t){var r={};switch(e){case"login":r.$identity_mp_id=sa.store._state.identities.$identity_mp_id,r[sa.para.login_id_key]=t;break;case"logout":r.$identity_mp_id=sa.store._state.identities.$identity_mp_id;break;case"identify":(r=_.deepCopy(sa.store._state.identities)).$identity_anonymous_id=t}sa.store.set("identities",r)},change:function(e,t){this._state["_"+e]=t},encryptStorage:function(){var e=this.getStorage(),t="data:enc;";_.isObject(e)?e=t+_.rot13obfs(JSON.stringify(e)):_.isString(e)&&-1===e.indexOf(t)&&(e=t+_.rot13obfs(e)),sa._.setStorageSync(sa.para.storage_store_key,e)},save:function(){var e=_.deepCopy(this._state),t=_.rot13obfs(JSON.stringify(e.identities));if(e.identities=t,delete e._first_id,delete e._distinct_id,sa.para.encrypt_storage){e="data:enc;"+_.rot13obfs(JSON.stringify(e))}sa._.setStorageSync(sa.para.storage_store_key,e)},init:function(){var e=this.getStorage();if(e)_.isString(e)&&-1!==e.indexOf("data:enc;")&&(e=e.substring("data:enc;".length),e=JSON.parse(_.rot13defs(e))),this.toState(e);else{is_first_launch=!0;var t=new Date,r=t.getTime();t.setHours(23),t.setMinutes(59),t.setSeconds(60),sa.setOnceProfile({$first_visit_time:new Date}),this.set({distinct_id:this.getUUID(),first_visit_time:r,first_visit_day_time:t.getTime(),identities:{$identity_mp_id:this.getUUID()},history_login_id:{name:"",value:""}})}}},sa.setProfile=function(e,t){sa.saEvent.send({type:"profile_set",properties:e},t)},sa.setOnceProfile=function(e,t){sa.saEvent.send({type:"profile_set_once",properties:e},t)},sa.appendProfile=function(e,t){if(!_.isObject(e))return!1;_.each(e,function(t,r){_.isString(t)?e[r]=[t]:(delete e[r],logger.info("appendProfile\u5c5e\u6027\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32\u6216\u8005\u6570\u7ec4"))}),sa.saEvent.send({type:"profile_append",properties:e},t)},sa.incrementProfile=function(e,t){if(!_.isObject(e))return!1;var r=e;_.isString(e)&&((e={})[r]=1),sa.saEvent.send({type:"profile_increment",properties:e},t)},sa.track=function(e,t,r){this.saEvent.send({type:"track",event:e,properties:t},r)},sa.identify=function(e,t){if(e=_.validId(e)){var r=sa.store.getFirstId();!0===t?r?sa.store.set("first_id",e):sa.store.set("distinct_id",e):r?sa.store.change("first_id",e):sa.store.change("distinct_id",e),sa.store.identitiesSet("identify",e)}},sa.trackSignup=function(e,t,r,a){var s=sa.store.getFirstId()||sa.store.getDistinctId();sa.store.set("distinct_id",e),sa.saEvent.send({original_id:s,distinct_id:e,type:"track_signup",event:t,properties:r},a)},sa.registerApp=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&(_.info.currentProps=_.extend(_.info.currentProps,e))},sa.register=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&sa.store.setProps(e)},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.clearAllProps=function(e){var t=sa.store.getProps(),r={};_.isArray(e)&&(_.each(t,function(t,a){_.include(e,a)||(r[a]=t)}),sa.store.setProps(r,!0))},sa.clearAppRegister=function(e){_.isArray(e)&&_.each(_.info.currentProps,function(t,r){_.include(e,r)&&delete _.info.currentProps[r]})},_.setLatestChannel=function(e){_.isEmptyObject(e)||(function(e,t){var r=!1;for(var a in t)e[t[a]]&&(r=!0);return r}(e,latest_source_channel)&&(sa.clearAppRegister(latest_source_channel),sa.clearAllProps(latest_source_channel)),sa.para.is_persistent_save.utm?sa.register(e):sa.registerApp(e))},_.setLatestShare=function(e){(e.$latest_share_depth||e.$latest_share_distinct_id||e.$latest_share_url_path||e.$latest_share_method)&&(sa.clearAppRegister(latest_share_info),sa.clearAllProps(latest_share_info),sa.para.is_persistent_save.share?sa.register(e):sa.registerApp(e))},sa.login=function(e){if(e=_.validId(e)){var t=sa.store.getFirstId(),r=sa.store.getDistinctId();if(sa.store._state.identities.hasOwnProperty(sa.para.login_id_key)&&e===t)return!1;var a=!(sa.para.login_id_key===sa.store._state.history_login_id.name&&sa.store._state.history_login_id.value===e);a&&(sa.store._state.identities[sa.para.login_id_key]=e),a&&(t?sa.trackSignup(e,"$SignUp"):(sa.store.set("first_id",r),sa.trackSignup(e,"$SignUp"))),a&&(sa.store.identitiesSet("login",e),sa.store.set("history_login_id",{name:sa.para.login_id_key,value:e}))}},sa.getAnonymousID=function(){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")},sa.logout=function(e){var t=sa.store.getFirstId();t?(sa.store.set("first_id",""),!0===e?sa.store.set("distinct_id",sa.store.getUUID()):sa.store.set("distinct_id",t)):logger.info("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25"),sa.store.identitiesSet("logout"),sa.store.set("history_login_id",{name:"",value:""})},sa.getLocation=function(){wx.getSetting({success:function(e){if(!e.authSetting["scope.userLocation"])return!1;wx.getLocation({type:sa.para.preset_properties.location.type,success:function(e){sa.registerApp({$latitude:e.latitude*Math.pow(10,6),$longitude:e.longitude*Math.pow(10,6),$geo_coordinate_system:_.setUpperCase(sa.para.preset_properties.location.type)})},fail:function(e){logger.info("\u83b7\u53d6\u4f4d\u7f6e\u5931\u8d25",e)}})}})},sa.openid={getRequest:function(e){wx.login({success:function(t){t.code&&sa.para.appid&&sa.para.openid_url?_.wxrequest({url:sa.para.openid_url+"&code="+t.code+"&appid="+sa.para.appid,method:"GET",complete:function(t){_.isObject(t)&&_.isObject(t.data)&&t.data.openid?e(t.data.openid):e()}}):e()}})},getWXStorage:function(){var e=sa.store.getStorage();if(e&&_.isObject(e))return e.openid},getOpenid:function(e){if(!sa.para.appid)return e(),!1;var t=this.getWXStorage();t?e(t):this.getRequest(e)}},sa.initial=function(){this._.info.getSystem(),this.store.init()},sa.init=function(e){if(!0===this.hasInit)return!1;this.hasInit=!0,sa.setPara(e),sa.para.encrypt_storage&&this.store.encryptStorage(),sa.para.batch_send&&sendStrategy.init(),sa.initialState.storeIsComplete=!0,sa.initialState.checkIsComplete()},sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib){var e={};_.each(_.info.currentProps,function(t,r){0===r.indexOf("$")&&(e[r]=t)});var t={$url_path:_.getCurrentPath(),$is_first_day:_.getIsFirstDay(),$is_first_time:is_first_launch},r=_.extend(e,t,_.info.properties,sa.store.getProps());return delete r.$lib,r}return{}},sa.setOpenid=function(e,t){if(!(e=_.validId(e)))return!1;t&&console.log("%c \u5f53\u524d\u7248\u672c setOpenid \u63a5\u53e3 \u5df2\u4e0d\u652f\u6301\u4f20\u5165\u7b2c\u4e8c\u4e2a\u53c2\u6570","color:#F39C12;font-size: 14px;"),sa.store.set("openid",e),sa.identify(e,!0),sa.bind("$identity_mp_openid",e)},sa.unsetOpenid=function(e){var t=_.validId(e);if(!t)return!1;sa.store._state.openid===t&&sa.store.set("openid",""),sa.unbind("$identity_mp_openid",t)},sa.setUnionid=function(e){var t=_.validId(e);t&&sa.bind("$identity_mp_unionid",t)},sa.unsetUnionid=function(e){var t=_.validId(e);if(t){if(sa.store._state.identities.hasOwnProperty("$identity_mp_unionid")&&t===sa.store._state.identities.$identity_mp_unionid){var r=_.getOpenidNameByAppid();sa.store._state.identities.hasOwnProperty(r)&&(delete sa.store._state.identities[r],delete sa.store._state.openid,sa.store.save())}sa.unbind("$identity_mp_unionid",t)}},sa.initWithOpenid=function(e,t){(e=e||{}).appid&&(sa.para.appid=e.appid),sa.openid.getOpenid(function(r){r&&sa.setOpenid(r,e.isCoverLogin),t&&_.isFunction(t)&&t(r),sa.init(e)})},sa.bind=function(e,t){if(_.isNumber(t)){if(_.isInteger(t)&&!1===_.isSafeInteger(t))return logger.info("Value must be String"),!1;t=String(t)}if(!_.isString(e))return logger.info("Key must be String"),!1;if(!_.check.checkKeyword(e)||"$identity_anonymous_id"===e||"$mp_id"===e||"$identity_mp_id"===e||"$identity_login_id"===e||e===sa.para.login_id_key){var r="Key ["+e+"] is invalid";return logger.info(r),!1}if(!t||""===t)return logger.info("Value is empty or null"),!1;if(!_.isString(t))return logger.info("Value must be String"),!1;if(!_.check.ckeckIdLength(t)){r="Value ["+t+"] is beyond the maximum length 255";return logger.info(r),!1}var a=sa.store._state.identities;"$identity_mp_openid"===e&&(e=_.getOpenidNameByAppid()),a[e]=t,sa.store.save(),sa.saEvent.send({type:"track_id_bind",event:"$BindID"})},sa.unbind=function(e,t){if(_.isNumber(t)){if(_.isInteger(t)&&!1===_.isSafeInteger(t))return logger.info("Value must be String"),!1;t=String(t)}if(!_.isString(e))return logger.info("Key must be String"),!1;if(!_.check.checkKeyword(e)||"$identity_anonymous_id"===e||"$mp_id"===e||"$identity_mp_id"===e||"$identity_login_id"===e||e===sa.para.login_id_key){var r="Key ["+e+"] is invalid";return logger.info(r),!1}if(!t||""===t)return logger.info("Value is empty or null"),!1;if(!_.isString(t))return logger.info("Value must be String"),!1;if(!_.check.ckeckIdLength(t)){r="Value ["+t+"] is beyond the maximum length 255";return logger.info(r),!1}"$identity_mp_openid"===e&&(e=_.getOpenidNameByAppid()),sa.store._state.identities.hasOwnProperty(e)&&t===sa.store._state.identities[e]&&(delete sa.store._state.identities[e],sa.store.save());var a={};a[e]=t,sa.saEvent.send({type:"track_id_unbind",event:"$UnbindID",unbind_value:a})},sa.setWebViewUrl=function(e,t){if(!_.isString(e)||""===e)return logger.info("error:\u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;if(!/^http(s)?:\/\//.test(e))return logger.info("warning: \u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;var r=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e);if(!r)return!1;var a,s=r[1]||"",i=r[2]||"",n=r[3]||"",o="",u=sa.store.getDistinctId()||"",c=sa.store.getFirstId()||"";_.urlSafeBase64&&_.urlSafeBase64.encode?u=u?_.urlSafeBase64.trim(_.urlSafeBase64.encode(_.urlBase64Encode(u))):"":this._.rot13obfs&&(u=u?_.rot13obfs(u):""),u=encodeURIComponent(u);var p=c?"f"+u:"d"+u;t?(a=n.indexOf("_sasdk"),o=n.indexOf("?")>-1?a>-1?s+i+"#"+n.substring(1,a)+"_sasdk="+p:s+i+"#"+n.substring(1)+"&_sasdk="+p:s+i+"#"+n.substring(1)+"?_sasdk="+p):(a=i.indexOf("_sasdk"),o=/^\?(\w)+/.test(i)?a>-1?s+i.replace(/(_sasdk=)([^&]*)/gi,"_sasdk="+p)+n:s+"?"+i.substring(1)+"&_sasdk="+p+n:s+"?"+i.substring(1)+"_sasdk="+p+n);return o},_.each(["setProfile","setOnceProfile","track","quick","incrementProfile","appendProfile","login","logout","registerApp","register","clearAllRegister","clearAllProps","clearAppRegister","bind","unbind","unsetOpenid","setUnionid","unsetUnionid"],function(e){var t=sa[e];sa[e]=function(){sa.initialState.isComplete?t.apply(sa,arguments):sa.initialState.queue.push([e,arguments])}}),_.setQuery=function(e,t){if(e&&_.isObject(e)&&!_.isEmptyObject(e)){var r=[];return _.each(e,function(e,a){"q"===a&&_.isString(e)&&0===e.indexOf("http")||(t?r.push(a+"="+e):r.push(a+"="+_.decodeURIComponent(e)))}),r.join("&")}return""},_.getUtmFromPage=function(){var e={};try{var t=_.getCurrentPage(),r=_.deepCopy(t.options);for(var a in r)r[a]=_.decodeURIComponent(r[a]);e=_.getCustomUtmFromQuery(r,"$","_","$")}catch(e){logger.info(e)}return e},_.sendPageLeave=function(){var e={},t="";try{t=(e=_.getCurrentPage())?e.route:""}catch(e){logger.info(e)}if(page_show_time>=0&&""!==t){var r={},a=_.getPageTitle(t),s=(Date.now()-page_show_time)/1e3;r.$url_query=e.sensors_mp_url_query?e.sensors_mp_url_query:"",r.$url_path=t,r.$title=a,r.event_duration=s,sa.track("$MPPageLeave",r),page_show_time=-1}},sa.autoTrackCustom={trackCustom:function(e,t,r){var a=sa.para.autoTrack[e],s="";sa.para.autoTrack&&a&&("function"==typeof a?(s=a(),_.isObject(s)&&_.extend(t,s)):_.isObject(a)&&(_.extend(t,a),sa.para.autoTrack[e]=!0),sa.track(r,t))},appLaunch:function(e,t){"object"!=typeof this||this.trackCustom||(this[sa.para.name]=sa);var r={};if(e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,r.$scene=_.getMPScene(e.scene)):r.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(r.$url_path=_.getPath(e.path),r.$title=_.getPageTitle(e.path),e.query&&_.isObject(e.query))){var a=_.setQuery(e.query);a=a?"?"+a:"",r.$url=r.$url_path+a}_.setShareInfo(e,r);var s=_.setUtm(e,r);is_first_launch?(r.$is_first_time=!0,_.isEmptyObject(s.pre1)||sa.setOnceProfile(s.pre1)):r.$is_first_time=!1,_.setLatestChannel(s.pre2),_.setSfSource(e,r),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(e.query),_.setPageRefData(r),t?(r=_.extend(r,t),sa.track("$MPLaunch",r)):sa.para.autoTrack&&sa.para.autoTrack.appLaunch&&sa.autoTrackCustom.trackCustom("appLaunch",r,"$MPLaunch")},appShow:function(e,t){var r={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,r.$scene=_.getMPScene(e.scene)):r.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(r.$url_path=_.getPath(e.path),r.$title=_.getPageTitle(e.path)),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,r);var a=_.setUtm(e,r);_.setLatestChannel(a.pre2),_.setSfSource(e,r),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(e.query),_.setPageRefData(r,e.path,r.$url_query),e&&e.path&&(r.$url=e.path+(r.$url_query?"?"+r.$url_query:"")),t?(r=_.extend(r,t),sa.track("$MPShow",r)):sa.para.autoTrack&&sa.para.autoTrack.appShow&&sa.autoTrackCustom.trackCustom("appShow",r,"$MPShow")},appHide:function(e){var t=(new Date).getTime(),r={};r.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(r.event_duration=(t-mpshow_time)/1e3),_.setPageRefData(r),e?(r=_.extend(r,e),sa.track("$MPHide",r)):sa.para.autoTrack&&sa.para.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",r,"$MPHide"),sendStrategy.onAppHide()},pageLoad:function(e){current_scene&&1010===current_scene&&e&&(e.sampshare&&delete e.sampshare,_.delObjectKey(e)),e&&_.isObject(e)&&(this.sensors_mp_url_query=_.setQuery(e),this.sensors_mp_encode_url_query=_.setQuery(e,!0))},pageShow:function(){page_show_time=Date.now();var e={},t=_.getCurrentPath(),r=_.getPageTitle(t);_.setRefPage(),e.$url_path=t,e.$url_query=this.sensors_mp_url_query?this.sensors_mp_url_query:"",e=_.extend(e,_.getUtmFromPage()),_.setPageRefData(e),_.setPageSfSource(e),r&&(e.$title=r),sa.para.onshow?sa.para.onshow(sa,t,this):_.isObject(sa.para.autotrack_exclude_page)&&_.isArray(sa.para.autotrack_exclude_page.pageShow)&&-1!==sa.para.autotrack_exclude_page.pageShow.indexOf(t)||sa.autoTrackCustom.trackCustom("pageShow",e,"$MPViewScreen")},pageShare:function(e){var t=e.onShareAppMessage;e.onShareAppMessage=function(){share_method="\u8f6c\u53d1\u6d88\u606f\u5361\u7247";var e=t.apply(this,arguments);if(sa.para.autoTrack&&sa.para.autoTrack.pageShare){var r={$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method};_.setPageRefData(r),sa.autoTrackCustom.trackCustom("pageShare",r,"$MPShare")}return sa.para.allow_amend_share_path&&("object"!=typeof e&&((e={}).path=_.getCurrentUrl(this)),"object"!=typeof e||void 0!==e.path&&""!==e.path||(e.path=_.getCurrentUrl(this)),"object"==typeof e&&"string"==typeof e.path&&(-1===e.path.indexOf("?")?e.path=e.path+"?":"&"!==e.path.slice(-1)&&(e.path=e.path+"&")),e.path=e.path+_.getShareInfo()),e}},pageShareTimeline:function(e){var t=e.onShareTimeline;e.onShareTimeline=function(){share_method="\u670b\u53cb\u5708\u5206\u4eab";var e=t.apply(this,arguments);if(sa.para.autoTrack&&sa.para.autoTrack.pageShare){var r={$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method};_.setPageRefData(r),sa.autoTrackCustom.trackCustom("pageShare",r,"$MPShare")}return sa.para.allow_amend_share_path&&("object"!=typeof e&&(e={}),"object"==typeof e&&void 0===e.query&&(e.query=""),"object"==typeof e&&"string"==typeof e.query&&""!==e.query&&"&"!==e.query.slice(-1)&&(e.query=e.query+"&"),e.query=e.query+_.getShareInfo()),e}},pageAddFavorites:function(){var e={};e.$url_path=_.getCurrentPath(),sa.para.autoTrack&&sa.para.autoTrack.mpFavorite&&sa.autoTrackCustom.trackCustom("mpFavorite",e,"$MPAddFavorites")}},sa.quick=function(){var e=arguments[0],t=arguments[1],r=arguments[2],a=_.isObject(r)?r:{};if("getAnonymousID"===e){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===e||"appShow"===e?t?sa.autoTrackCustom[e](t,a):logger.info("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(a=_.isObject(t)?t:{},sa.autoTrackCustom[e](a))},sa.appLaunch=function(e,t){var r={};e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,r.$scene=_.getMPScene(e.scene)):r.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(r.$url_path=_.getPath(e.path),r.$title=_.getPageTitle(e.path)),_.setShareInfo(e,r);var a=_.setUtm(e,r);is_first_launch?(r.$is_first_time=!0,_.isEmptyObject(a.pre1)||sa.setOnceProfile(a.pre1)):r.$is_first_time=!1,_.setLatestChannel(a.pre2),_.setSfSource(e,r),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(e.query),r.$url=e.path+(r.$url_query?"?"+r.$url_query:""),_.setPageRefData(t),_.isObject(t)&&(r=_.extend(r,t)),sa.track("$MPLaunch",r)},sa.appShow=function(e,t){var r={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,r.$scene=_.getMPScene(e.scene)):r.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(r.$url_path=_.getPath(e.path),r.$title=_.getPageTitle(e.path)),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,r);var a=_.setUtm(e,r);_.setLatestChannel(a.pre2),_.setSfSource(e,r),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(e.query),e&&e.path&&(r.$url=e.path+(r.$url_query?"?"+r.$url_query:"")),_.setPageRefData(r,e.path,r.$url_query),_.isObject(t)&&(r=_.extend(r,t)),sa.track("$MPShow",r)},sa.appHide=function(e){var t=(new Date).getTime(),r={};r.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(r.event_duration=(t-mpshow_time)/1e3),_.setPageRefData(r),_.isObject(e)&&(r=_.extend(r,e)),sa.track("$MPHide",r),sendStrategy.onAppHide()},sa.pageShow=function(e){var t={},r=_.getCurrentPath(),a=_.getPageTitle(r),s=_.getCurrentPage();_.setRefPage(),a&&(t.$title=a),t.$url_path=r,t.$url_query=s.sensors_mp_url_query?s.sensors_mp_url_query:"",t=_.extend(t,_.getUtmFromPage()),_.setPageSfSource(t),_.setPageRefData(t),_.isObject(e)&&(t=_.extend(t,e)),sa.track("$MPViewScreen",t)},global&&global.sensors_data_pre_config){var name=global.sensors_data_pre_config.login_id_key;name&&_.isString(name)&&_.check.checkKeyword(name)&&"$identity_anonymous_id"!==name&&"$mp_id"!==name&&"$identity_mp_id"!==name&&"$identity_mp_unionid"!==name&&"$mp_unionid"!==name&&"$identity_mp_openid"!==name&&"$mp_openid"!==name?sa.para.login_id_key=name:logger.info("\u8bbe\u7f6e\u81ea\u5b9a\u4e49\u767b\u5f55 ID \u5931\u8d25")}sa.initial();export default sa; \ No newline at end of file diff --git a/sensorsdata.custom.min.js b/sensorsdata.custom.min.js index 22f479d..559766d 100755 --- a/sensorsdata.custom.min.js +++ b/sensorsdata.custom.min.js @@ -1 +1 @@ -"use strict";var sa={};function isObject(e){return null!=e&&"[object Object]"==toString.call(e)}var getRandomBasic=function(){var e=(new Date).getTime();return function(t){return Math.ceil((e=(9301*e+49297)%233280)/233280*t)}}();function getRandom(){if("function"==typeof Uint32Array){var e="";if("undefined"!=typeof crypto?e=crypto:"undefined"!=typeof msCrypto&&(e=msCrypto),isObject(e)&&e.getRandomValues){var t=new Uint32Array(1);return e.getRandomValues(t)[0]/Math.pow(2,32)}}return getRandomBasic(1e19)/1e19}var kit={};function encodeTrackData(e){e=JSON.stringify(e);var t=sa._.base64Encode(e);return encodeURIComponent(t)}function setPublicPProperties(e){if(e&&e.properties){var t=sa._.getRefPage(),r=sa._.getCurrentPageInfo(),a={$referrer:t.route,$referrer_title:t.title,$title:r.title,$url:r.url};for(var s in a)e.properties.hasOwnProperty(s)||(e.properties[s]=a[s])}}kit.buildData=function(e){var t=sa._,r={distinct_id:sa.store.getDistinctId(),identities:sa.store._state.identities,lib:{$lib:sa.lib_name,$lib_method:"code",$lib_version:sa.lib_version},properties:{}};if("track_id_unbind"===e.type&&"$UnbindID"===e.event&&(r.identities=t.deepCopy(e.unbind_value),delete e.unbind_value),t.extend(r,sa.store.getUnionId(),e),t.isObject(e.properties)&&!t.isEmptyObject(e.properties)&&t.extend(r.properties,e.properties),!e.type||"profile"!==e.type.slice(0,7)){r._track_id=Number(String(getRandom()).slice(2,5)+String(getRandom()).slice(2,4)+String(Date.now()).slice(-4)),r.properties=t.extend({},t.info.properties,sa.store.getProps(),t.info.currentProps,r.properties),"track"===e.type&&(r.properties.$is_first_day=t.getIsFirstDay());t.getRefPage();setPublicPProperties(r)}return r.properties.$time&&t.isDate(r.properties.$time)?(r.time=1*r.properties.$time,delete r.properties.$time):r.time=1*new Date,t.parseSuperProperties(r.properties),t.searchObjDate(r),t.searchObjString(r),r},kit.processData=function(e){return e},kit.onceTrackData=function(e){return"data="+encodeTrackData(e)},kit.batchTrackData=function(e){return"data_list="+encodeTrackData(e)};var mergeStorageData={getData:function(e){wx.getStorage({key:sa.para.storage_prepare_data_key,complete:function(t){var r=t.data&&sa._.isArray(t.data)?t.data:[];mergeStorageData.deleteAesData(r),e&&e()}})},deleteAesData:function(e){var t=[],r=e.length;if(r>0){for(var a=0;a=500&&(sa._.logger.info("\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38"),sa.store.mem.mdata.shift());var t=Date.now();e._flush_time=t,(e=kit.processData(e))&&sa.store.mem.add(e),sa.store.mem.getLength()>=sa.para.batch_send.max_length&&this.batchSend()},wxrequest:function(e){if(sa._.isArray(e.data)&&e.data.length>0){var t=kit.batchTrackData(e.data);sa._.wxrequest({url:sa.para.server_url,method:"POST",dataType:"text",data:t,success:function(){e.success(e.len)},fail:function(){e.fail()}})}else e.success(e.len)},batchSend:function(){if(this.dataHasSend){var e,t,r=sa.store.mem.mdata;(t=(e=r.length>=100?r.slice(0,100):r).length)>0&&(this.dataHasSend=!1,this.wxrequest({data:e,len:t,success:this.batchRemove.bind(this),fail:this.sendFail.bind(this)}))}},sendFail:function(){this.dataHasSend=!0,this.failTime++},batchRemove:function(e){sa.store.mem.clear(e),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite(),this.failTime=0},is_first_batch_write:!0,batchWrite:function(){var e=this;this.dataHasChange&&(this.is_first_batch_write&&(this.is_first_batch_write=!1,setTimeout(function(){e.batchSend()},1e3)),this.dataHasChange=!1,this.syncStorage&&sa._.setStorageSync(sa.para.storage_prepare_data_key,sa.store.mem.mdata))},batchInterval:function(){var e=this;!function t(){setTimeout(function(){e.batchWrite(),t()},500)}(),function t(){setTimeout(function(){e.batchSend(),t()},sa.para.batch_send.send_timeout*Math.pow(2,e.failTime))}()}};function getSendUrl(e,t){var r=kit.onceTrackData(t);return-1!==e.indexOf("?")?e+"&"+r:e+"?"+r}function onceSend(e){e._flush_time=Date.now();var t=getSendUrl(sa.para.server_url,e);sa._.wxrequest({url:t,method:"GET"})}var saEvent={send:function(e,t){if(!sa.para.server_url)return sa._.logger.info("error: server_url \u4e0d\u80fd\u4e3a\u7a7a"),!1;if(sa.current_scene&&1154===sa.current_scene&&!sa.para.preset_events.moments_page)return!1;var r=sa.kit.buildData(e);r?(saEvent.debug(r),sa.events.emit("send",r),sa.para.batch_send?sendStrategy.send(r):onceSend(r)):sa._.logger.info("error: \u6570\u636e\u5f02\u5e38 "+r)},debug:function(e){sa._.logger.info(e)}},_={};sa.kit=kit,sa.mergeStorageData=mergeStorageData,sa.saEvent=saEvent,sa.sendStrategy=sendStrategy,sa.IDENTITY_KEY={EMAIL:"$identity_email",MOBILE:"$identity_mobile"},sa.para={name:"sensors",server_url:"",send_timeout:1e3,show_log:!1,login_id_key:"$identity_login_id",allow_amend_share_path:!0,max_string_length:500,datasend_timeout:3e3,source_channel:[],autoTrack:{appLaunch:!0,appShow:!0,appHide:!0,pageShow:!0,pageShare:!0,mpClick:!1,mpFavorite:!0,pageLeave:!1},autotrack_exclude_page:{pageShow:[]},is_persistent_save:{share:!1,utm:!1},preset_properties:{url_path:!0},preset_events:{moments_page:!1,defer_track:!1,share_info_use_string:!1},batch_send:!0,storage_store_key:"sensorsdata2015_wechat",storage_prepare_data_key:"sensors_mp_prepare_data"};var mpHook={data:1,onLoad:1,onShow:1,onReady:1,onPullDownRefresh:1,onShareAppMessage:1,onShareTimeline:1,onReachBottom:1,onPageScroll:1,onResize:1,onTabItemTap:1,onHide:1,onUnload:1},logger="object"==typeof logger?logger:{};logger.info=function(){if(sa.para.show_log&&"object"==typeof console&&console.log)try{if(3===arguments.length)return console.log(arguments[0],arguments[1],arguments[2]);if(2===arguments.length)return console.log(arguments[0],arguments[1]);if(1===arguments.length)return console.log(arguments[0])}catch(e){console.log(arguments[0])}},sa.setPara=function(e){sa.para=_.extend2Lev(sa.para,e);var t=[];if(_.isArray(sa.para.source_channel))for(var r=sa.para.source_channel.length,a=0;asa.para.max_string_length?(logger.info("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,sa.para.max_string_length)):e},_.searchObjString=function(e){_.isObject(e)&&_.each(e,function(t,r){_.isObject(t)?_.searchObjString(e[r]):_.isString(t)&&(e[r]=_.formatString(t))})},_.parseSuperProperties=function(e){_.isObject(e)&&(_.each(e,function(t,r){if(_.isFunction(t))try{e[r]=t(),_.isFunction(e[r])&&(logger.info("\u60a8\u7684\u5c5e\u6027- "+r+" \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[r])}catch(t){delete e[r],logger.info("\u60a8\u7684\u5c5e\u6027- "+r+" \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}}),_.strip_sa_properties(e))},_.unique=function(e){for(var t,r=[],a={},s=0;s255)||(logger.info("id \u957f\u5ea6\u8d85\u8fc7 255 \u4e2a\u5b57\u7b26\uff01"),!1)}},_.strip_sa_properties=function(e){return _.isObject(e)?(_.each(e,function(t,r){if(_.isArray(t)){var a=[];_.each(t,function(e){_.isString(e)?a.push(e):logger.info("\u60a8\u7684\u6570\u636e-",t,"\u7684\u6570\u7ec4\u91cc\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32,\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}),e[r]=a}_.isString(t)||_.isNumber(t)||_.isDate(t)||_.isBoolean(t)||_.isArray(t)||(logger.info("\u60a8\u7684\u6570\u636e-",t,"-\u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[r])}),e):e},_.strip_empty_properties=function(e){var t={};return _.each(e,function(e,r){null!=e&&(t[r]=e)}),t},_.utf8Encode=function(e){var t,r,a,s,i="";for(t=r=0,a=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,s=0;s127&&n<2048?String.fromCharCode(n>>6|192,63&n|128):String.fromCharCode(n>>12|224,n>>6&63|128,63&n|128),null!==o&&(r>t&&(i+=e.substring(t,r)),i+=o,t=r=s+1)}return r>t&&(i+=e.substring(t,e.length)),i},_.base64Encode=function(e){var t,r,a,s,i,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,u=0,c="",p=[];if(!e)return e;e=_.utf8Encode(e);do{t=(i=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,r=i>>12&63,a=i>>6&63,s=63&i,p[u++]=n.charAt(t)+n.charAt(r)+n.charAt(a)+n.charAt(s)}while(o255||(a=e.charCodeAt(o++))>255||(s=e.charCodeAt(o++))>255)&&logger.info("Failed to execute 'btoa' : The string to be encoded contains characters outside of the Latin1 range."),n+=i.charAt((t=r<<16|a<<8|s)>>18&63)+i.charAt(t>>12&63)+i.charAt(t>>6&63)+i.charAt(63&t);return _?n.slice(0,_-3)+"===".substring(_):n},_.urlBase64Encode=function(e){return _.btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))},_.rot13obfs=function(e,t){t="number"==typeof t?t:13;for(var r=(e=String(e)).split(""),a=0,s=r.length;a(new Date).getTime()},_.getCurrentUrl=function(e){var t=_.getCurrentPath(),r="";return _.isObject(e)&&e.sensors_mp_encode_url_query&&(r=e.sensors_mp_encode_url_query),t?r?t+"?"+r:t:"\u672a\u53d6\u5230"},_.getPath=function(e){return e="string"==typeof e?e.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"},_.getMethods=function(e){var t=[];for(var r in e)"function"!=typeof e[r]||mpHook[r]||t.push(r);return t},_.isClick=function(e){return!!{tap:1,longpress:1,longtap:1}[e]},sa.initialState={queue:[],isComplete:!1,systemIsComplete:!1,storeIsComplete:!1,checkIsComplete:function(){this.systemIsComplete&&this.storeIsComplete&&(this.isComplete=!0,this.queue.length>0&&(_.each(this.queue,function(e){sa[e[0]].apply(sa,slice.call(e[1]))}),this.queue=[]))}},_.getCustomUtmFromQuery=function(e,t,r,a){if(!_.isObject(e))return{};var s={};if(e.sa_utm)for(var i in e)"sa_utm"!==i?_.include(sa.para.source_channel,i)&&(s[r+i]=e[i]):s[a+i]=e[i];else for(var i in e)-1===(" "+source_channel_standard+" ").indexOf(" "+i+" ")?_.include(sa.para.source_channel,i)&&(s[r+i]=e[i]):s[t+i]=e[i];return s},_.getObjFromQuery=function(e){var t=e.split("?"),r=[],a={};return t&&t[1]?(_.each(t[1].split("&"),function(e){(r=e.split("="))[0]&&r[1]&&(a[r[0]]=r[1])}),a):{}},_.setStorageSync=function(e,t){var r=function(){wx.setStorageSync(e,t)};try{r()}catch(e){logger.info("set Storage fail --",e);try{r()}catch(e){logger.info("set Storage fail again --",e)}}},_.getStorageSync=function(e){var t="";try{t=wx.getStorageSync(e)}catch(r){try{t=wx.getStorageSync(e)}catch(e){logger.info("getStorage fail")}}return t},_.getMPScene=function(e){return"number"==typeof e||"string"==typeof e&&""!==e?e="wx-"+String(e):"\u672a\u53d6\u5230\u503c"},_.objToParam=function(e,t){if("[object Object]"!==Object.prototype.toString.call(e))return logger.info("\u8bf7\u4f20\u5165\u6709\u6548\u5bf9\u8c61"),"";var r=[];for(var a in e)if(e.hasOwnProperty(a)){var s=e[a];void 0===s?r.push(a+"="):(s=t?encodeURIComponent(s):s,r.push(a+"="+s))}return r.join("&")},_.delObjectKey=function(e){if("[object Object]"===Object.prototype.toString.call(e))for(var t=0;t=2?(page_route_map.shift(),page_route_map.push(e)):page_route_map.push(e)}}catch(e){logger.info(e)}},_.getRefPage=function(){var e={route:"\u76f4\u63a5\u6253\u5f00",title:""};return page_route_map.length>1&&(e.title=page_route_map[0].title,e.route=page_route_map[0].route),e},_.getCurrentPageInfo=function(){var e=_.getCurrentPage(),t={title:"",url:""};if(e&&e.route){var r=e.sensors_mp_url_query?"?"+e.sensors_mp_url_query:"";t.title=_.getPageTitle(e.route),t.url=e.route+r}return t},_.setPageRefData=function(e,t,r){var a=_.getRefPage();_.isObject(e)&&(t?page_route_map.length>0&&t?(r=r?"?"+r:"",e.$referrer=_.getPath(t)+r,e.$referrer_title=_.getPageTitle(t)):(e.$referrer="\u76f4\u63a5\u6253\u5f00",e.$referrer_title=""):(e.$referrer=a.route,e.$referrer_title=a.title))},_.getPageTitle=function(e){if("\u672a\u53d6\u5230"===e||!e)return"";var t="";try{if(__wxConfig){var r=__wxConfig,a=__wxConfig.page||{},s=a[e]||a[e+".html"],i={},n={};if(r.global&&r.global.window&&r.global.window.navigationBarTitleText&&(i.titleVal=r.global.window.navigationBarTitleText),s&&s.window&&s.window.navigationBarTitleText&&(n.titleVal=s.window.navigationBarTitleText),!n.titleVal&&__wxAppCode__){var o=__wxAppCode__[e+".json"];o&&o.navigationBarTitleText&&(n.titleVal=o.navigationBarTitleText)}if(_.each(globalTitle,function(r,a){if(a===e)return t=r}),0===t.length){var u=_.extend(i,n);t=u.titleVal||""}}}catch(e){logger.info(e)}return t},_.wxrequest=function(e){if(_.compareSDKVersion(wxSDKVersion,"2.10.0")>=0)e.timeout=sa.para.datasend_timeout,wx.request(e);else{var t=wx.request(e);setTimeout(function(){_.isObject(t)&&_.isFunction(t.abort)&&t.abort()},sa.para.datasend_timeout)}},_.getAppInfoSync=function(){if(wx.getAccountInfoSync){var e=wx.getAccountInfoSync(),t=e&&e.miniProgram?e.miniProgram:{};return{appId:t.appId,appEnv:t.envVersion,appVersion:t.version}}return{}},_.getAppId=function(){var e=_.getAppInfoSync();return e&&e.appId?e.appId:""},_.validId=function(e){return"string"!=typeof e&&"number"!=typeof e||""===e?(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1):"number"!=typeof e||(e=String(e),/^\d+$/.test(e))?!!_.check.ckeckIdLength(e)&&e:(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1)},_.compareSDKVersion=function(e,t){e=e.split("."),t=t.split(".");for(var r=Math.max(e.length,t.length);e.lengthi)return 1;if(s-1?t.system.split(" ")[1]:t.system,wxSDKVersion=t.SDKVersion,e.$mp_client_app_version=t.version,e.$mp_client_basic_library_version=wxSDKVersion},complete:function(){var t=(new Date).getTimezoneOffset(),r=_.getAppInfoSync();_.isNumber(t)&&(e.$timezone_offset=t),r.appId&&(e.$app_id=r.appId),r.appVersion&&(e.$app_version=r.appVersion),sa.initialState.systemIsComplete=!0,sa.initialState.checkIsComplete()}})}wx.getNetworkType({success:function(t){e.$network_type=_.setUpperCase(t.networkType)},complete:t})}},sa._=_,_.eventEmitter=function(){this.sub=[]},_.eventEmitter.prototype={add:function(e){this.sub.push(e)},emit:function(e,t){this.sub.forEach(function(r){r.on(e,t)})}},_.eventSub=function(e){sa.events.add(this),this._events=[],this.handle=e,this.ready=!1},_.eventSub.prototype={on:function(e,t){if(this.ready){if(_.isFunction(this.handle))try{this.handle(e,t)}catch(e){logger.info(e)}}else this._events.push({event:e,data:t})},isReady:function(){var e=this;e.ready=!0,e._events.forEach(function(t){if(_.isFunction(e.handle))try{e.handle(t.event,t.data)}catch(e){logger.info(e)}})}},sa.eventSub=_.eventSub,sa.events=new _.eventEmitter,sa.usePlugin=function(e,t){"function"==typeof e.init&&e.init(sa,t)},sa.store={storageInfo:null,getUUID:function(){return Date.now()+"-"+Math.floor(1e7*getRandom())+"-"+getRandom().toString(16).replace(".","")+"-"+String(31242*getRandom()).replace(".","").slice(0,8)},getStorage:function(){return this.storageInfo?this.storageInfo:(this.storageInfo=sa._.getStorageSync(sa.para.storage_store_key)||"",this.storageInfo)},_state:{},mem:{mdata:[],getLength:function(){return this.mdata.length},add:function(e){this.mdata.push(e)},clear:function(e){this.mdata.splice(0,e)}},toState:function(e){var t=null;_.isJSONString(e)?(t=JSON.parse(e)).distinct_id?this._state=t:this.set("distinct_id",this.getUUID()):_.isObject(e)&&(t=e).distinct_id?this._state=t:this.set("distinct_id",this.getUUID());var r=this._state._first_id||this._state.first_id,a=this._state._distinct_id||this._state.distinct_id,s=this._state.openid,i=(this._state.history_login_id?this._state.history_login_id:{}).name;if(this._state.identities&&_.isString(this._state.identities)){var n=JSON.parse(_.rot13defs(this._state.identities));this._state.identities=n}if(this._state.identities&&_.isObject(this._state.identities)&&!_.isEmptyObject(this._state.identities)?this._state.identities.hasOwnProperty("$identity_anonymous_id")&&(this._state.identities.$identity_anonymous_id=r||a):(this._state.identities={},this._state.identities.$mp_id=this.getUUID(),this._state.identities.$identity_anonymous_id=r||a),s){var o=_.getOpenidNameByAppid();this._state.identities[o]=s}if(r)if(i&&this._state.identities.hasOwnProperty(i)){if(this._state.identities[i]!==a){for(var u in this._state.identities[i]=a,this._state.identities)this._state.identities.hasOwnProperty(u)&&"$mp_id"!==u&&u!==i&&delete this._state.identities[u];this._state.history_login_id.value=a}}else{for(var u in this._state.identities[sa.para.login_id_key]=a,this._state.identities)this._state.identities.hasOwnProperty(u)&&"$mp_id"!==u&&u!==sa.para.login_id_key&&delete this._state.identities[u];this._state.history_login_id={name:sa.para.login_id_key,value:a}}else{if(this._state.identities.hasOwnProperty("$identity_login_id")||this._state.identities.hasOwnProperty(i))for(var u in this._state.identities)this._state.identities.hasOwnProperty(u)&&"$mp_id"!==u&&"$identity_anonymous_id"!==u&&delete this._state.identities[u];this._state.history_login_id={name:"",value:""}}this.save()},getFirstId:function(){return this._state._first_id||this._state.first_id},getDistinctId:function(){return this._state._distinct_id||this._state.distinct_id},getUnionId:function(){var e={},t=this._state._first_id||this._state.first_id,r=this._state._distinct_id||this._state.distinct_id;return t&&r?(e.login_id=r,e.anonymous_id=t):e.anonymous_id=r,e},getProps:function(){return this._state.props||{}},setProps:function(e,t){var r=this._state.props||{};t?this.set("props",e):(_.extend(r,e),this.set("props",r))},set:function(e,t){var r={};for(var a in"string"==typeof e?r[e]=t:"object"==typeof e&&(r=e),this._state=this._state||{},r)this._state[a]=r[a],"first_id"===a?delete this._state._first_id:"distinct_id"===a&&(delete this._state._distinct_id,sa.events.emit("changeDistinctId"));this.save()},identitiesSet:function(e,t){var r={};switch(e){case"login":r.$mp_id=sa.store._state.identities.$mp_id,r[sa.para.login_id_key]=t;break;case"logout":r.$mp_id=sa.store._state.identities.$mp_id;break;case"identify":(r=_.deepCopy(sa.store._state.identities)).$identity_anonymous_id=t}sa.store.set("identities",r)},change:function(e,t){this._state["_"+e]=t},encryptStorage:function(){var e=this.getStorage(),t="data:enc;";_.isObject(e)?e=t+_.rot13obfs(JSON.stringify(e)):_.isString(e)&&-1===e.indexOf(t)&&(e=t+_.rot13obfs(e)),sa._.setStorageSync(sa.para.storage_store_key,e)},save:function(){var e=_.deepCopy(this._state),t=_.rot13obfs(JSON.stringify(e.identities));if(e.identities=t,delete e._first_id,delete e._distinct_id,sa.para.encrypt_storage){e="data:enc;"+_.rot13obfs(JSON.stringify(e))}sa._.setStorageSync(sa.para.storage_store_key,e)},init:function(){var e=this.getStorage();if(e)_.isString(e)&&-1!==e.indexOf("data:enc;")&&(e=e.substring("data:enc;".length),e=JSON.parse(_.rot13defs(e))),this.toState(e);else{is_first_launch=!0;var t=new Date,r=t.getTime();t.setHours(23),t.setMinutes(59),t.setSeconds(60),sa.setOnceProfile({$first_visit_time:new Date}),this.set({distinct_id:this.getUUID(),first_visit_time:r,first_visit_day_time:t.getTime(),identities:{$mp_id:this.getUUID()},history_login_id:{name:"",value:""}})}}},sa.setProfile=function(e,t){sa.saEvent.send({type:"profile_set",properties:e},t)},sa.setOnceProfile=function(e,t){sa.saEvent.send({type:"profile_set_once",properties:e},t)},sa.appendProfile=function(e,t){if(!_.isObject(e))return!1;_.each(e,function(t,r){_.isString(t)?e[r]=[t]:(delete e[r],logger.info("appendProfile\u5c5e\u6027\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32\u6216\u8005\u6570\u7ec4"))}),sa.saEvent.send({type:"profile_append",properties:e},t)},sa.incrementProfile=function(e,t){if(!_.isObject(e))return!1;var r=e;_.isString(e)&&((e={})[r]=1),sa.saEvent.send({type:"profile_increment",properties:e},t)},sa.track=function(e,t,r){this.saEvent.send({type:"track",event:e,properties:t},r)},sa.identify=function(e,t){if(e=_.validId(e)){var r=sa.store.getFirstId();!0===t?r?sa.store.set("first_id",e):sa.store.set("distinct_id",e):r?sa.store.change("first_id",e):sa.store.change("distinct_id",e),sa.store.identitiesSet("identify",e)}},sa.trackSignup=function(e,t,r,a){var s=sa.store.getFirstId()||sa.store.getDistinctId();sa.store.set("distinct_id",e),sa.saEvent.send({original_id:s,distinct_id:e,type:"track_signup",event:t,properties:r},a)},sa.registerApp=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&(_.info.currentProps=_.extend(_.info.currentProps,e))},sa.register=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&sa.store.setProps(e)},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.clearAllProps=function(e){var t=sa.store.getProps(),r={};_.isArray(e)&&(_.each(t,function(t,a){_.include(e,a)||(r[a]=t)}),sa.store.setProps(r,!0))},sa.clearAppRegister=function(e){_.isArray(e)&&_.each(_.info.currentProps,function(t,r){_.include(e,r)&&delete _.info.currentProps[r]})},_.setLatestChannel=function(e){_.isEmptyObject(e)||(function(e,t){var r=!1;for(var a in t)e[t[a]]&&(r=!0);return r}(e,latest_source_channel)&&(sa.clearAppRegister(latest_source_channel),sa.clearAllProps(latest_source_channel)),sa.para.is_persistent_save.utm?sa.register(e):sa.registerApp(e))},_.setLatestShare=function(e){(e.$latest_share_depth||e.$latest_share_distinct_id||e.$latest_share_url_path||e.$latest_share_method)&&(sa.clearAppRegister(latest_share_info),sa.clearAllProps(latest_share_info),sa.para.is_persistent_save.share?sa.register(e):sa.registerApp(e))},sa.login=function(e){if(e=_.validId(e)){var t=sa.store.getFirstId(),r=sa.store.getDistinctId();if(sa.store._state.identities.hasOwnProperty(sa.para.login_id_key)&&e===t)return!1;var a=!(sa.para.login_id_key===sa.store._state.history_login_id.name&&sa.store._state.history_login_id.value===e);a&&(sa.store._state.identities[sa.para.login_id_key]=e),a&&(t?sa.trackSignup(e,"$SignUp"):(sa.store.set("first_id",r),sa.trackSignup(e,"$SignUp"))),a&&(sa.store.identitiesSet("login",e),sa.store.set("history_login_id",{name:sa.para.login_id_key,value:e}))}},sa.getAnonymousID=function(){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")},sa.logout=function(e){var t=sa.store.getFirstId();t?(sa.store.set("first_id",""),!0===e?sa.store.set("distinct_id",sa.store.getUUID()):sa.store.set("distinct_id",t)):logger.info("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25"),sa.store.identitiesSet("logout"),sa.store.set("history_login_id",{name:"",value:""})},sa.getLocation=function(){wx.getSetting({success:function(e){if(!e.authSetting["scope.userLocation"])return!1;wx.getLocation({type:sa.para.preset_properties.location.type,success:function(e){sa.registerApp({$latitude:e.latitude*Math.pow(10,6),$longitude:e.longitude*Math.pow(10,6),$geo_coordinate_system:_.setUpperCase(sa.para.preset_properties.location.type)})},fail:function(e){logger.info("\u83b7\u53d6\u4f4d\u7f6e\u5931\u8d25",e)}})}})},sa.openid={getRequest:function(e){wx.login({success:function(t){t.code&&sa.para.appid&&sa.para.openid_url?_.wxrequest({url:sa.para.openid_url+"&code="+t.code+"&appid="+sa.para.appid,method:"GET",complete:function(t){_.isObject(t)&&_.isObject(t.data)&&t.data.openid?e(t.data.openid):e()}}):e()}})},getWXStorage:function(){var e=sa.store.getStorage();if(e&&_.isObject(e))return e.openid},getOpenid:function(e){if(!sa.para.appid)return e(),!1;var t=this.getWXStorage();t?e(t):this.getRequest(e)}},sa.initial=function(){this._.info.getSystem(),this.store.init()},sa.init=function(e){if(!0===this.hasInit)return!1;this.hasInit=!0,sa.setPara(e),sa.para.encrypt_storage&&this.store.encryptStorage(),sa.para.batch_send&&sendStrategy.init(),sa.initialState.storeIsComplete=!0,sa.initialState.checkIsComplete()},sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib){var e={};_.each(_.info.currentProps,function(t,r){0===r.indexOf("$")&&(e[r]=t)});var t=_.extend(e,{$url_path:_.getCurrentPath(),$is_first_day:_.getIsFirstDay()},_.info.properties,sa.store.getProps());return delete t.$lib,t}return{}},sa.setOpenid=function(e,t){if(!(e=_.validId(e)))return!1;var r=sa.store.getFirstId();sa.store.set("openid",e),t?sa.store.set("distinct_id",e):(sa.identify(e,!0),r?sa.store.set("first_id",e):sa.store.set("distinct_id",e)),sa.bind("$mp_openid",e)},sa.unsetOpenid=function(e){var t=_.validId(e);if(!t)return!1;sa.store._state.openid===t&&sa.store.set("openid",""),sa.unbind("$mp_openid",t)},sa.setUnionid=function(e){var t=_.validId(e);t&&sa.bind("$mp_unionid",t)},sa.unsetUnionid=function(e){var t=_.validId(e);if(t){if(sa.store._state.identities.hasOwnProperty("$mp_unionid")&&t===sa.store._state.identities.$mp_unionid){var r=_.getOpenidNameByAppid();sa.store._state.identities.hasOwnProperty(r)&&(delete sa.store._state.identities[r],sa.store.save())}sa.unbind("$mp_unionid",t)}},sa.initWithOpenid=function(e,t){(e=e||{}).appid&&(sa.para.appid=e.appid),sa.openid.getOpenid(function(r){r&&sa.setOpenid(r,e.isCoverLogin),t&&_.isFunction(t)&&t(r),sa.init(e)})},sa.bind=function(e,t){if(_.isNumber(t)){if(_.isInteger(t)&&!1===_.isSafeInteger(t))return logger.info("Value must be String"),!1;t=String(t)}if(!_.isString(e))return logger.info("Key must be String"),!1;if(!_.check.checkKeyword(e)||"$identity_anonymous_id"===e||"$mp_id"===e||"$identity_login_id"===e||e===sa.para.login_id_key){var r="Key ["+e+"] is invalid";return logger.info(r),!1}if(!t||""===t)return logger.info("Value is empty or null"),!1;if(!_.isString(t))return logger.info("Value must be String"),!1;if(!_.check.ckeckIdLength(t)){r="Value ["+t+"] is beyond the maximum length 255";return logger.info(r),!1}var a=sa.store._state.identities;"$mp_openid"===e&&(e=_.getOpenidNameByAppid()),a[e]=t,sa.store.save(),sa.saEvent.send({type:"track_id_bind",event:"$BindID"})},sa.unbind=function(e,t){if(_.isNumber(t)){if(_.isInteger(t)&&!1===_.isSafeInteger(t))return logger.info("Value must be String"),!1;t=String(t)}if(!_.isString(e))return logger.info("Key must be String"),!1;if(!_.check.checkKeyword(e)||"$identity_anonymous_id"===e||"$mp_id"===e||"$identity_login_id"===e||e===sa.para.login_id_key){var r="Key ["+e+"] is invalid";return logger.info(r),!1}if(!t||""===t)return logger.info("Value is empty or null"),!1;if(!_.isString(t))return logger.info("Value must be String"),!1;if(!_.check.ckeckIdLength(t)){r="Value ["+t+"] is beyond the maximum length 255";return logger.info(r),!1}"$mp_openid"===e&&(e=_.getOpenidNameByAppid()),sa.store._state.identities.hasOwnProperty(e)&&t===sa.store._state.identities[e]&&(delete sa.store._state.identities[e],sa.store.save());var a={};a[e]=t,sa.saEvent.send({type:"track_id_unbind",event:"$UnbindID",unbind_value:a})},sa.setWebViewUrl=function(e,t){if(!_.isString(e)||""===e)return logger.info("error:\u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;if(!/^http(s)?:\/\//.test(e))return logger.info("warning: \u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;var r=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e);if(!r)return!1;var a,s=r[1]||"",i=r[2]||"",n=r[3]||"",o="",u=sa.store.getDistinctId()||"",c=sa.store.getFirstId()||"";_.urlSafeBase64&&_.urlSafeBase64.encode?u=u?_.urlSafeBase64.trim(_.urlSafeBase64.encode(_.urlBase64Encode(u))):"":this._.rot13obfs&&(u=u?_.rot13obfs(u):""),u=encodeURIComponent(u);var p=c?"f"+u:"d"+u;t?(a=n.indexOf("_sasdk"),o=n.indexOf("?")>-1?a>-1?s+i+"#"+n.substring(1,a)+"_sasdk="+p:s+i+"#"+n.substring(1)+"&_sasdk="+p:s+i+"#"+n.substring(1)+"?_sasdk="+p):(a=i.indexOf("_sasdk"),o=/^\?(\w)+/.test(i)?a>-1?s+i.replace(/(_sasdk=)([^&]*)/gi,"_sasdk="+p)+n:s+"?"+i.substring(1)+"&_sasdk="+p+n:s+"?"+i.substring(1)+"_sasdk="+p+n);return o},_.each(["setProfile","setOnceProfile","track","quick","incrementProfile","appendProfile","login","logout","registerApp","register","clearAllRegister","clearAllProps","clearAppRegister","bind","unbind"],function(e){var t=sa[e];sa[e]=function(){sa.initialState.isComplete?t.apply(sa,arguments):sa.initialState.queue.push([e,arguments])}}),_.setQuery=function(e,t){if(e&&_.isObject(e)&&!_.isEmptyObject(e)){var r=[];return _.each(e,function(e,a){"q"===a&&_.isString(e)&&0===e.indexOf("http")||(t?r.push(a+"="+e):r.push(a+"="+_.decodeURIComponent(e)))}),r.join("&")}return""},_.getUtmFromPage=function(){var e={};try{var t=_.getCurrentPage(),r=_.deepCopy(t.options);for(var a in r)r[a]=_.decodeURIComponent(r[a]);e=_.getCustomUtmFromQuery(r,"$","_","$")}catch(e){logger.info(e)}return e},_.sendPageLeave=function(){var e={},t="";try{t=(e=_.getCurrentPage())?e.route:""}catch(e){logger.info(e)}if(page_show_time>=0&&""!==t){var r={},a=_.getPageTitle(t),s=(Date.now()-page_show_time)/1e3;r.$url_query=e.sensors_mp_url_query?e.sensors_mp_url_query:"",r.$url_path=t,r.$title=a,r.event_duration=s,sa.track("$MPPageLeave",r),page_show_time=-1}},sa.autoTrackCustom={trackCustom:function(e,t,r){var a=sa.para.autoTrack[e],s="";sa.para.autoTrack&&a&&("function"==typeof a?(s=a(),_.isObject(s)&&_.extend(t,s)):_.isObject(a)&&(_.extend(t,a),sa.para.autoTrack[e]=!0),sa.track(r,t))},appLaunch:function(e,t){"object"!=typeof this||this.trackCustom||(this[sa.para.name]=sa);var r={};if(e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,r.$scene=_.getMPScene(e.scene)):r.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path){if(r.$url_path=_.getPath(e.path),r.$title=_.getPageTitle(e.path),e.query&&_.isObject(e.query)){var a=_.setQuery(e.query);a=a?"?"+a:"",r.$url=r.$url_path+a}!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:r.$url_path})}_.setShareInfo(e,r);var s=_.setUtm(e,r);is_first_launch?(r.$is_first_time=!0,_.isEmptyObject(s.pre1)||sa.setOnceProfile(s.pre1)):r.$is_first_time=!1,_.setLatestChannel(s.pre2),_.setSfSource(e,r),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(e.query),_.setPageRefData(r),t?(r=_.extend(r,t),sa.track("$MPLaunch",r)):sa.para.autoTrack&&sa.para.autoTrack.appLaunch&&sa.autoTrackCustom.trackCustom("appLaunch",r,"$MPLaunch")},appShow:function(e,t){var r={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,r.$scene=_.getMPScene(e.scene)):r.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(r.$url_path=_.getPath(e.path),r.$title=_.getPageTitle(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:r.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,r);var a=_.setUtm(e,r);_.setLatestChannel(a.pre2),_.setSfSource(e,r),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(e.query),_.setPageRefData(r,e.path,r.$url_query),e&&e.path&&(r.$url=e.path+(r.$url_query?"?"+r.$url_query:"")),t?(r=_.extend(r,t),sa.track("$MPShow",r)):sa.para.autoTrack&&sa.para.autoTrack.appShow&&sa.autoTrackCustom.trackCustom("appShow",r,"$MPShow")},appHide:function(e){var t=(new Date).getTime(),r={};r.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(r.event_duration=(t-mpshow_time)/1e3),_.setPageRefData(r),e?(r=_.extend(r,e),sa.track("$MPHide",r)):sa.para.autoTrack&&sa.para.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",r,"$MPHide"),sendStrategy.onAppHide()},pageLoad:function(e){current_scene&&1010===current_scene&&e&&(e.sampshare&&delete e.sampshare,_.delObjectKey(e)),e&&_.isObject(e)&&(this.sensors_mp_url_query=_.setQuery(e),this.sensors_mp_encode_url_query=_.setQuery(e,!0))},pageShow:function(){page_show_time=Date.now();var e={},t=_.getCurrentPath(),r=_.getPageTitle(t);_.setRefPage(),e.$url_path=t,e.$url_query=this.sensors_mp_url_query?this.sensors_mp_url_query:"",e=_.extend(e,_.getUtmFromPage()),_.setPageRefData(e),_.setPageSfSource(e),r&&(e.$title=r),sa.para.onshow?sa.para.onshow(sa,t,this):_.isObject(sa.para.autotrack_exclude_page)&&_.isArray(sa.para.autotrack_exclude_page.pageShow)&&-1!==sa.para.autotrack_exclude_page.pageShow.indexOf(t)||sa.autoTrackCustom.trackCustom("pageShow",e,"$MPViewScreen"),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:t})},pageShare:function(e){var t=e.onShareAppMessage;e.onShareAppMessage=function(){share_method="\u8f6c\u53d1\u6d88\u606f\u5361\u7247";var e=t.apply(this,arguments);if(sa.para.autoTrack&&sa.para.autoTrack.pageShare){var r={$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method};_.setPageRefData(r),sa.autoTrackCustom.trackCustom("pageShare",r,"$MPShare")}return sa.para.allow_amend_share_path&&("object"!=typeof e&&((e={}).path=_.getCurrentUrl(this)),"object"!=typeof e||void 0!==e.path&&""!==e.path||(e.path=_.getCurrentUrl(this)),"object"==typeof e&&"string"==typeof e.path&&(-1===e.path.indexOf("?")?e.path=e.path+"?":"&"!==e.path.slice(-1)&&(e.path=e.path+"&")),e.path=e.path+_.getShareInfo()),e}},pageShareTimeline:function(e){var t=e.onShareTimeline;e.onShareTimeline=function(){share_method="\u670b\u53cb\u5708\u5206\u4eab";var e=t.apply(this,arguments);if(sa.para.autoTrack&&sa.para.autoTrack.pageShare){var r={$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method};_.setPageRefData(r),sa.autoTrackCustom.trackCustom("pageShare",r,"$MPShare")}return sa.para.allow_amend_share_path&&("object"!=typeof e&&(e={}),"object"==typeof e&&void 0===e.query&&(e.query=""),"object"==typeof e&&"string"==typeof e.query&&""!==e.query&&"&"!==e.query.slice(-1)&&(e.query=e.query+"&"),e.query=e.query+_.getShareInfo()),e}},pageAddFavorites:function(){var e={};e.$url_path=_.getCurrentPath(),sa.para.autoTrack&&sa.para.autoTrack.mpFavorite&&sa.autoTrackCustom.trackCustom("mpFavorite",e,"$MPAddFavorites")}},sa.quick=function(){var e=arguments[0],t=arguments[1],r=arguments[2],a=_.isObject(r)?r:{};if("getAnonymousID"===e){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===e||"appShow"===e?t?sa.autoTrackCustom[e](t,a):logger.info("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(a=_.isObject(t)?t:{},sa.autoTrackCustom[e](a))},sa.appLaunch=function(e,t){var r={};e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,r.$scene=_.getMPScene(e.scene)):r.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(r.$url_path=_.getPath(e.path),r.$title=_.getPageTitle(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:r.$url_path})),_.setShareInfo(e,r);var a=_.setUtm(e,r);is_first_launch?(r.$is_first_time=!0,_.isEmptyObject(a.pre1)||sa.setOnceProfile(a.pre1)):r.$is_first_time=!1,_.setLatestChannel(a.pre2),_.setSfSource(e,r),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(e.query),r.$url=e.path+(r.$url_query?"?"+r.$url_query:""),_.setPageRefData(t),_.isObject(t)&&(r=_.extend(r,t)),sa.track("$MPLaunch",r)},sa.appShow=function(e,t){var r={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,r.$scene=_.getMPScene(e.scene)):r.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(r.$url_path=_.getPath(e.path),r.$title=_.getPageTitle(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:r.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,r);var a=_.setUtm(e,r);_.setLatestChannel(a.pre2),_.setSfSource(e,r),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(e.query),e&&e.path&&(r.$url=e.path+(r.$url_query?"?"+r.$url_query:"")),_.setPageRefData(r,e.path,r.$url_query),_.isObject(t)&&(r=_.extend(r,t)),sa.track("$MPShow",r)},sa.appHide=function(e){var t=(new Date).getTime(),r={};r.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(r.event_duration=(t-mpshow_time)/1e3),_.setPageRefData(r),_.isObject(e)&&(r=_.extend(r,e)),sa.track("$MPHide",r),sendStrategy.onAppHide()},sa.pageShow=function(e){var t={},r=_.getCurrentPath(),a=_.getPageTitle(r),s=_.getCurrentPage();_.setRefPage(),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:r}),a&&(t.$title=a),t.$url_path=r,t.$url_query=s.sensors_mp_url_query?s.sensors_mp_url_query:"",t=_.extend(t,_.getUtmFromPage()),_.setPageSfSource(t),_.setPageRefData(t),_.isObject(e)&&(t=_.extend(t,e)),sa.track("$MPViewScreen",t)},global&&global.sensors_data_pre_config){var key=global.sensors_data_pre_config.login_id_key;key&&_.isString(key)&&_.check.checkKeyword(key)&&"$identity_anonymous_id"!==key&&"$mp_id"!==key&&"$mp_unionid"!==key?sa.para.login_id_key=key:logger.info("\u8bbe\u7f6e\u81ea\u5b9a\u4e49\u767b\u5f55 ID \u5931\u8d25")}sa.initial(),module.exports=sa; \ No newline at end of file +"use strict";var sa={};function isObject(e){return null!=e&&"[object Object]"==toString.call(e)}var getRandomBasic=function(){var e=(new Date).getTime();return function(t){return Math.ceil((e=(9301*e+49297)%233280)/233280*t)}}();function getRandom(){if("function"==typeof Uint32Array){var e="";if("undefined"!=typeof crypto?e=crypto:"undefined"!=typeof msCrypto&&(e=msCrypto),isObject(e)&&e.getRandomValues){var t=new Uint32Array(1);return e.getRandomValues(t)[0]/Math.pow(2,32)}}return getRandomBasic(1e19)/1e19}var kit={};function encodeTrackData(e){e=JSON.stringify(e);var t=sa._.base64Encode(e);return encodeURIComponent(t)}function setPublicPProperties(e){if(e&&e.properties){var t=sa._.getRefPage(),r=sa._.getCurrentPageInfo(),a={$referrer:t.route,$referrer_title:t.title,$title:r.title,$url:r.url};for(var s in!0===sa.para.preset_properties.url_path&&(a.$url_path=r.path),a)e.properties.hasOwnProperty(s)||(e.properties[s]=a[s])}}kit.buildData=function(e){var t=sa._,r={distinct_id:sa.store.getDistinctId(),identities:sa.store._state.identities,lib:{$lib:sa.lib_name,$lib_method:"code",$lib_version:sa.lib_version},properties:{}};return"track_id_unbind"===e.type&&"$UnbindID"===e.event&&(r.identities=t.deepCopy(e.unbind_value),delete e.unbind_value),t.extend(r,sa.store.getUnionId(),e),t.isObject(e.properties)&&!t.isEmptyObject(e.properties)&&t.extend(r.properties,e.properties),e.type&&"profile"===e.type.slice(0,7)||(r._track_id=Number(String(getRandom()).slice(2,5)+String(getRandom()).slice(2,4)+String(Date.now()).slice(-4)),r.properties=t.extend({},t.info.properties,sa.store.getProps(),t.info.currentProps,r.properties),"track"===e.type&&(r.properties.$is_first_day=t.getIsFirstDay()),setPublicPProperties(r)),r.properties.$time&&t.isDate(r.properties.$time)?(r.time=1*r.properties.$time,delete r.properties.$time):r.time=1*new Date,t.parseSuperProperties(r.properties),t.searchObjDate(r),t.searchObjString(r),r},kit.processData=function(e){return e},kit.onceTrackData=function(e){return"data="+encodeTrackData(e)},kit.batchTrackData=function(e){var t=Date.now();return e.forEach(function(e){e._flush_time=t}),"data_list="+encodeTrackData(e)};var mergeStorageData={getData:function(e){wx.getStorage({key:sa.para.storage_prepare_data_key,complete:function(t){var r=t.data&&sa._.isArray(t.data)?t.data:[];mergeStorageData.deleteAesData(r),e&&e()}})},deleteAesData:function(e){var t=[],r=e.length;if(r>0){for(var a=0;a=500&&(sa._.logger.info("\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38"),sa.store.mem.mdata.shift()),(e=kit.processData(e))&&sa.store.mem.add(e),sa.store.mem.getLength()>=sa.para.batch_send.max_length&&this.batchSend()},wxrequest:function(e){if(sa._.isArray(e.data)&&e.data.length>0){var t=kit.batchTrackData(e.data);sa._.wxrequest({url:sa.para.server_url,method:"POST",dataType:"text",data:t,success:function(){e.success(e.len)},fail:function(){e.fail()}})}else e.success(e.len)},batchSend:function(){if(this.dataHasSend){var e,t,r=sa.store.mem.mdata;(t=(e=r.length>=100?r.slice(0,100):r).length)>0&&(this.dataHasSend=!1,this.wxrequest({data:e,len:t,success:this.batchRemove.bind(this),fail:this.sendFail.bind(this)}))}},sendFail:function(){this.dataHasSend=!0,this.failTime++},batchRemove:function(e){sa.store.mem.clear(e),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite(),this.failTime=0},is_first_batch_write:!0,batchWrite:function(){var e=this;this.dataHasChange&&(this.is_first_batch_write&&(this.is_first_batch_write=!1,setTimeout(function(){e.batchSend()},1e3)),this.dataHasChange=!1,this.syncStorage&&sa._.setStorageSync(sa.para.storage_prepare_data_key,sa.store.mem.mdata))},batchInterval:function(){var e=this;!function t(){setTimeout(function(){e.batchWrite(),t()},500)}(),function t(){setTimeout(function(){e.batchSend(),t()},sa.para.batch_send.send_timeout*Math.pow(2,e.failTime))}()}};function getSendUrl(e,t){var r=kit.onceTrackData(t);return-1!==e.indexOf("?")?e+"&"+r:e+"?"+r}function onceSend(e){e._flush_time=Date.now();var t=getSendUrl(sa.para.server_url,e);sa._.wxrequest({url:t,method:"GET"})}var saEvent={send:function(e,t){if(!sa.para.server_url)return sa._.logger.info("error: server_url \u4e0d\u80fd\u4e3a\u7a7a"),!1;if(sa.current_scene&&1154===sa.current_scene&&!sa.para.preset_events.moments_page)return!1;var r=sa.kit.buildData(e);r?(saEvent.debug(r),sa.events.emit("send",r),sa.para.batch_send?sendStrategy.send(r):onceSend(r)):sa._.logger.info("error: \u6570\u636e\u5f02\u5e38 "+r)},debug:function(e){sa._.logger.info(e)}},_={};sa.kit=kit,sa.mergeStorageData=mergeStorageData,sa.saEvent=saEvent,sa.sendStrategy=sendStrategy,sa.IDENTITY_KEY={EMAIL:"$identity_email",MOBILE:"$identity_mobile"},sa.para={name:"sensors",server_url:"",send_timeout:1e3,show_log:!1,login_id_key:"$identity_login_id",allow_amend_share_path:!0,max_string_length:500,datasend_timeout:3e3,source_channel:[],autoTrack:{appLaunch:!0,appShow:!0,appHide:!0,pageShow:!0,pageShare:!0,mpClick:!1,mpFavorite:!0,pageLeave:!1},autotrack_exclude_page:{pageShow:[]},is_persistent_save:{share:!1,utm:!1},preset_properties:{url_path:!0},preset_events:{moments_page:!1,defer_track:!1,share_info_use_string:!1},batch_send:!0,storage_store_key:"sensorsdata2015_wechat",storage_prepare_data_key:"sensors_mp_prepare_data"};var mpHook={data:1,onLoad:1,onShow:1,onReady:1,onPullDownRefresh:1,onShareAppMessage:1,onShareTimeline:1,onReachBottom:1,onPageScroll:1,onResize:1,onTabItemTap:1,onHide:1,onUnload:1},logger="object"==typeof logger?logger:{};logger.info=function(){if(sa.para.show_log&&"object"==typeof console&&console.log)try{if(3===arguments.length)return console.log(arguments[0],arguments[1],arguments[2]);if(2===arguments.length)return console.log(arguments[0],arguments[1]);if(1===arguments.length)return console.log(arguments[0])}catch(e){console.log(arguments[0])}},sa.setPara=function(e){sa.para=_.extend2Lev(sa.para,e);var t=[];if(_.isArray(sa.para.source_channel))for(var r=sa.para.source_channel.length,a=0;asa.para.max_string_length?(logger.info("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,sa.para.max_string_length)):e},_.searchObjString=function(e){_.isObject(e)&&_.each(e,function(t,r){_.isObject(t)?_.searchObjString(e[r]):_.isString(t)&&(e[r]=_.formatString(t))})},_.parseSuperProperties=function(e){_.isObject(e)&&(_.each(e,function(t,r){if(_.isFunction(t))try{e[r]=t(),_.isFunction(e[r])&&(logger.info("\u60a8\u7684\u5c5e\u6027- "+r+" \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[r])}catch(t){delete e[r],logger.info("\u60a8\u7684\u5c5e\u6027- "+r+" \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}}),_.strip_sa_properties(e))},_.unique=function(e){for(var t,r=[],a={},s=0;s255)||(logger.info("id \u957f\u5ea6\u8d85\u8fc7 255 \u4e2a\u5b57\u7b26\uff01"),!1)}},_.strip_sa_properties=function(e){return _.isObject(e)?(_.each(e,function(t,r){if(_.isArray(t)){var a=[];_.each(t,function(e){_.isString(e)?a.push(e):logger.info("\u60a8\u7684\u6570\u636e-",t,"\u7684\u6570\u7ec4\u91cc\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32,\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}),e[r]=a}_.isString(t)||_.isNumber(t)||_.isDate(t)||_.isBoolean(t)||_.isArray(t)||(logger.info("\u60a8\u7684\u6570\u636e-",t,"-\u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[r])}),e):e},_.strip_empty_properties=function(e){var t={};return _.each(e,function(e,r){null!=e&&(t[r]=e)}),t},_.utf8Encode=function(e){var t,r,a,s,i="";for(t=r=0,a=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,s=0;s127&&n<2048?String.fromCharCode(n>>6|192,63&n|128):String.fromCharCode(n>>12|224,n>>6&63|128,63&n|128),null!==o&&(r>t&&(i+=e.substring(t,r)),i+=o,t=r=s+1)}return r>t&&(i+=e.substring(t,e.length)),i},_.base64Encode=function(e){var t,r,a,s,i,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,u=0,c="",p=[];if(!e)return e;e=_.utf8Encode(e);do{t=(i=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,r=i>>12&63,a=i>>6&63,s=63&i,p[u++]=n.charAt(t)+n.charAt(r)+n.charAt(a)+n.charAt(s)}while(o255||(a=e.charCodeAt(o++))>255||(s=e.charCodeAt(o++))>255)&&logger.info("Failed to execute 'btoa' : The string to be encoded contains characters outside of the Latin1 range."),n+=i.charAt((t=r<<16|a<<8|s)>>18&63)+i.charAt(t>>12&63)+i.charAt(t>>6&63)+i.charAt(63&t);return _?n.slice(0,_-3)+"===".substring(_):n},_.urlBase64Encode=function(e){return _.btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))},_.rot13obfs=function(e,t){t="number"==typeof t?t:13;for(var r=(e=String(e)).split(""),a=0,s=r.length;a(new Date).getTime()},_.getCurrentUrl=function(e){var t=_.getCurrentPath(),r="";return _.isObject(e)&&e.sensors_mp_encode_url_query&&(r=e.sensors_mp_encode_url_query),t?r?t+"?"+r:t:"\u672a\u53d6\u5230"},_.getPath=function(e){return e="string"==typeof e?e.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"},_.getMethods=function(e){var t=[];for(var r in e)"function"!=typeof e[r]||mpHook[r]||t.push(r);return t},_.isClick=function(e){return!!{tap:1,longpress:1,longtap:1}[e]},sa.initialState={queue:[],isComplete:!1,systemIsComplete:!1,storeIsComplete:!1,checkIsComplete:function(){this.systemIsComplete&&this.storeIsComplete&&(this.isComplete=!0,this.queue.length>0&&(_.each(this.queue,function(e){sa[e[0]].apply(sa,slice.call(e[1]))}),this.queue=[]))}},_.getCustomUtmFromQuery=function(e,t,r,a){if(!_.isObject(e))return{};var s={};if(e.sa_utm)for(var i in e)"sa_utm"!==i?_.include(sa.para.source_channel,i)&&(s[r+i]=e[i]):s[a+i]=e[i];else for(var i in e)-1===(" "+source_channel_standard+" ").indexOf(" "+i+" ")?_.include(sa.para.source_channel,i)&&(s[r+i]=e[i]):s[t+i]=e[i];return s},_.getObjFromQuery=function(e){var t=e.split("?"),r=[],a={};return t&&t[1]?(_.each(t[1].split("&"),function(e){(r=e.split("="))[0]&&r[1]&&(a[r[0]]=r[1])}),a):{}},_.setStorageSync=function(e,t){var r=function(){wx.setStorageSync(e,t)};try{r()}catch(e){logger.info("set Storage fail --",e);try{r()}catch(e){logger.info("set Storage fail again --",e)}}},_.getStorageSync=function(e){var t="";try{t=wx.getStorageSync(e)}catch(r){try{t=wx.getStorageSync(e)}catch(e){logger.info("getStorage fail")}}return t},_.getMPScene=function(e){return"number"==typeof e||"string"==typeof e&&""!==e?e="wx-"+String(e):"\u672a\u53d6\u5230\u503c"},_.objToParam=function(e,t){if("[object Object]"!==Object.prototype.toString.call(e))return logger.info("\u8bf7\u4f20\u5165\u6709\u6548\u5bf9\u8c61"),"";var r=[];for(var a in e)if(e.hasOwnProperty(a)){var s=e[a];void 0===s?r.push(a+"="):(s=t?encodeURIComponent(s):s,r.push(a+"="+s))}return r.join("&")},_.delObjectKey=function(e){if("[object Object]"===Object.prototype.toString.call(e))for(var t=0;t=2?(page_route_map.shift(),page_route_map.push(e)):page_route_map.push(e)}}catch(e){logger.info(e)}},_.getRefPage=function(){var e={route:"\u76f4\u63a5\u6253\u5f00",title:""};return page_route_map.length>1&&(e.title=page_route_map[0].title,e.route=page_route_map[0].route),e},_.getCurrentPageInfo=function(){var e=_.getCurrentPage(),t={title:"",url:"",path:"\u672a\u53d6\u5230"};if(e&&e.route){var r=e.sensors_mp_url_query?"?"+e.sensors_mp_url_query:"";t.title=_.getPageTitle(e.route),t.url=e.route+r,t.path=e.route}return t},_.setPageRefData=function(e,t,r){var a=_.getRefPage();_.isObject(e)&&(t?page_route_map.length>0&&t?(r=r?"?"+r:"",e.$referrer=_.getPath(t)+r,e.$referrer_title=_.getPageTitle(t)):(e.$referrer="\u76f4\u63a5\u6253\u5f00",e.$referrer_title=""):(e.$referrer=a.route,e.$referrer_title=a.title))},_.getPageTitle=function(e){if("\u672a\u53d6\u5230"===e||!e)return"";var t="";try{if(__wxConfig){var r=__wxConfig,a=__wxConfig.page||{},s=a[e]||a[e+".html"],i={},n={};if(r.global&&r.global.window&&r.global.window.navigationBarTitleText&&(i.titleVal=r.global.window.navigationBarTitleText),s&&s.window&&s.window.navigationBarTitleText&&(n.titleVal=s.window.navigationBarTitleText),!n.titleVal&&__wxAppCode__){var o=__wxAppCode__[e+".json"];o&&o.navigationBarTitleText&&(n.titleVal=o.navigationBarTitleText)}if(_.each(globalTitle,function(r,a){if(a===e)return t=r}),0===t.length){var u=_.extend(i,n);t=u.titleVal||""}}}catch(e){logger.info(e)}return t},_.wxrequest=function(e){if(_.compareSDKVersion(wxSDKVersion,"2.10.0")>=0)e.timeout=sa.para.datasend_timeout,wx.request(e);else{var t=wx.request(e);setTimeout(function(){_.isObject(t)&&_.isFunction(t.abort)&&t.abort()},sa.para.datasend_timeout)}},_.getAppInfoSync=function(){if(wx.getAccountInfoSync){var e=wx.getAccountInfoSync(),t=e&&e.miniProgram?e.miniProgram:{};return{appId:t.appId,appEnv:t.envVersion,appVersion:t.version}}return{}},_.getAppId=function(){var e=_.getAppInfoSync();return e&&e.appId?e.appId:""},_.validId=function(e){return"string"!=typeof e&&"number"!=typeof e||""===e?(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1):"number"!=typeof e||(e=String(e),/^\d+$/.test(e))?!!_.check.ckeckIdLength(e)&&e:(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1)},_.compareSDKVersion=function(e,t){e=e.split("."),t=t.split(".");for(var r=Math.max(e.length,t.length);e.lengthi)return 1;if(s-1?t.system.split(" ")[1]:t.system,wxSDKVersion=t.SDKVersion,e.$mp_client_app_version=t.version,e.$mp_client_basic_library_version=wxSDKVersion},complete:function(){var t=(new Date).getTimezoneOffset(),r=_.getAppInfoSync();_.isNumber(t)&&(e.$timezone_offset=t),r.appId&&(e.$app_id=r.appId),r.appVersion&&(e.$app_version=r.appVersion),sa.initialState.systemIsComplete=!0,sa.initialState.checkIsComplete()}})}wx.getNetworkType({success:function(t){e.$network_type=_.setUpperCase(t.networkType)},complete:t})}},sa._=_,_.eventEmitter=function(){this.sub=[]},_.eventEmitter.prototype={add:function(e){this.sub.push(e)},emit:function(e,t){this.sub.forEach(function(r){r.on(e,t)})}},_.eventSub=function(e){sa.events.add(this),this._events=[],this.handle=e,this.ready=!1},_.eventSub.prototype={on:function(e,t){if(this.ready){if(_.isFunction(this.handle))try{this.handle(e,t)}catch(e){logger.info(e)}}else this._events.push({event:e,data:t})},isReady:function(){var e=this;e.ready=!0,e._events.forEach(function(t){if(_.isFunction(e.handle))try{e.handle(t.event,t.data)}catch(e){logger.info(e)}})}},sa.eventSub=_.eventSub,sa.events=new _.eventEmitter,sa.usePlugin=function(e,t){"function"==typeof e.init&&e.init(sa,t)},sa.store={storageInfo:null,getUUID:function(){return Date.now()+"-"+Math.floor(1e7*getRandom())+"-"+getRandom().toString(16).replace(".","")+"-"+String(31242*getRandom()).replace(".","").slice(0,8)},getStorage:function(){return this.storageInfo?this.storageInfo:(this.storageInfo=sa._.getStorageSync(sa.para.storage_store_key)||"",this.storageInfo)},_state:{},mem:{mdata:[],getLength:function(){return this.mdata.length},add:function(e){this.mdata.push(e)},clear:function(e){this.mdata.splice(0,e)}},toState:function(e){var t=null;_.isJSONString(e)?(t=JSON.parse(e)).distinct_id?this._state=t:this.set("distinct_id",this.getUUID()):_.isObject(e)&&(t=e).distinct_id?this._state=t:this.set("distinct_id",this.getUUID());var r=this._state._first_id||this._state.first_id,a=this._state._distinct_id||this._state.distinct_id,s=this._state.openid,i=(this._state.history_login_id?this._state.history_login_id:{}).name;if(this._state.identities&&_.isString(this._state.identities)){var n=JSON.parse(_.rot13defs(this._state.identities));this._state.identities=n}var o,u,c=_.getOpenidNameByAppid();if(this._state.identities&&_.isObject(this._state.identities)&&!_.isEmptyObject(this._state.identities)){var p=(o=_.getAppId(),u="$mp_openid",o&&(u="$mp_"+o+"_openid"),u);this._state.identities.hasOwnProperty("$mp_id")&&(this._state.identities.$identity_mp_id=this._state.identities.$mp_id,delete this._state.identities.$mp_id),this._state.identities.hasOwnProperty("$mp_unionid")&&(this._state.identities.$identity_mp_unionid=this._state.identities.$mp_unionid,delete this._state.identities.$mp_unionid),this._state.identities.hasOwnProperty(p)&&(this._state.identities[c]=this._state.identities[p],delete this._state.identities[p]),this._state.identities.hasOwnProperty("$identity_anonymous_id")&&(this._state.identities.$identity_anonymous_id=r||a)}else this._state.identities={},this._state.identities.$identity_mp_id=this.getUUID(),this._state.identities.$identity_anonymous_id=r||a;if(s&&(this._state.identities[c]=s),r)if(i&&this._state.identities.hasOwnProperty(i)){if(this._state.identities[i]!==a){for(var d in this._state.identities[i]=a,this._state.identities)this._state.identities.hasOwnProperty(d)&&"$identity_mp_id"!==d&&d!==i&&delete this._state.identities[d];this._state.history_login_id.value=a}}else{for(var d in this._state.identities[sa.para.login_id_key]=a,this._state.identities)this._state.identities.hasOwnProperty(d)&&"$identity_mp_id"!==d&&d!==sa.para.login_id_key&&delete this._state.identities[d];this._state.history_login_id={name:sa.para.login_id_key,value:a}}else{if(this._state.identities.hasOwnProperty("$identity_login_id")||this._state.identities.hasOwnProperty(i))for(var d in this._state.identities)this._state.identities.hasOwnProperty(d)&&"$identity_mp_id"!==d&&"$identity_anonymous_id"!==d&&delete this._state.identities[d];this._state.history_login_id={name:"",value:""}}this.save()},getFirstId:function(){return this._state._first_id||this._state.first_id},getDistinctId:function(){return this._state._distinct_id||this._state.distinct_id},getUnionId:function(){var e={},t=this._state._first_id||this._state.first_id,r=this._state._distinct_id||this._state.distinct_id;return t&&r?(e.login_id=r,e.anonymous_id=t):e.anonymous_id=r,e},getProps:function(){return this._state.props||{}},setProps:function(e,t){var r=this._state.props||{};t?this.set("props",e):(_.extend(r,e),this.set("props",r))},set:function(e,t){var r={};for(var a in"string"==typeof e?r[e]=t:"object"==typeof e&&(r=e),this._state=this._state||{},r)this._state[a]=r[a],"first_id"===a?delete this._state._first_id:"distinct_id"===a&&(delete this._state._distinct_id,sa.events.emit("changeDistinctId"));this.save()},identitiesSet:function(e,t){var r={};switch(e){case"login":r.$identity_mp_id=sa.store._state.identities.$identity_mp_id,r[sa.para.login_id_key]=t;break;case"logout":r.$identity_mp_id=sa.store._state.identities.$identity_mp_id;break;case"identify":(r=_.deepCopy(sa.store._state.identities)).$identity_anonymous_id=t}sa.store.set("identities",r)},change:function(e,t){this._state["_"+e]=t},encryptStorage:function(){var e=this.getStorage(),t="data:enc;";_.isObject(e)?e=t+_.rot13obfs(JSON.stringify(e)):_.isString(e)&&-1===e.indexOf(t)&&(e=t+_.rot13obfs(e)),sa._.setStorageSync(sa.para.storage_store_key,e)},save:function(){var e=_.deepCopy(this._state),t=_.rot13obfs(JSON.stringify(e.identities));if(e.identities=t,delete e._first_id,delete e._distinct_id,sa.para.encrypt_storage){e="data:enc;"+_.rot13obfs(JSON.stringify(e))}sa._.setStorageSync(sa.para.storage_store_key,e)},init:function(){var e=this.getStorage();if(e)_.isString(e)&&-1!==e.indexOf("data:enc;")&&(e=e.substring("data:enc;".length),e=JSON.parse(_.rot13defs(e))),this.toState(e);else{is_first_launch=!0;var t=new Date,r=t.getTime();t.setHours(23),t.setMinutes(59),t.setSeconds(60),sa.setOnceProfile({$first_visit_time:new Date}),this.set({distinct_id:this.getUUID(),first_visit_time:r,first_visit_day_time:t.getTime(),identities:{$identity_mp_id:this.getUUID()},history_login_id:{name:"",value:""}})}}},sa.setProfile=function(e,t){sa.saEvent.send({type:"profile_set",properties:e},t)},sa.setOnceProfile=function(e,t){sa.saEvent.send({type:"profile_set_once",properties:e},t)},sa.appendProfile=function(e,t){if(!_.isObject(e))return!1;_.each(e,function(t,r){_.isString(t)?e[r]=[t]:(delete e[r],logger.info("appendProfile\u5c5e\u6027\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32\u6216\u8005\u6570\u7ec4"))}),sa.saEvent.send({type:"profile_append",properties:e},t)},sa.incrementProfile=function(e,t){if(!_.isObject(e))return!1;var r=e;_.isString(e)&&((e={})[r]=1),sa.saEvent.send({type:"profile_increment",properties:e},t)},sa.track=function(e,t,r){this.saEvent.send({type:"track",event:e,properties:t},r)},sa.identify=function(e,t){if(e=_.validId(e)){var r=sa.store.getFirstId();!0===t?r?sa.store.set("first_id",e):sa.store.set("distinct_id",e):r?sa.store.change("first_id",e):sa.store.change("distinct_id",e),sa.store.identitiesSet("identify",e)}},sa.trackSignup=function(e,t,r,a){var s=sa.store.getFirstId()||sa.store.getDistinctId();sa.store.set("distinct_id",e),sa.saEvent.send({original_id:s,distinct_id:e,type:"track_signup",event:t,properties:r},a)},sa.registerApp=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&(_.info.currentProps=_.extend(_.info.currentProps,e))},sa.register=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&sa.store.setProps(e)},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.clearAllProps=function(e){var t=sa.store.getProps(),r={};_.isArray(e)&&(_.each(t,function(t,a){_.include(e,a)||(r[a]=t)}),sa.store.setProps(r,!0))},sa.clearAppRegister=function(e){_.isArray(e)&&_.each(_.info.currentProps,function(t,r){_.include(e,r)&&delete _.info.currentProps[r]})},_.setLatestChannel=function(e){_.isEmptyObject(e)||(function(e,t){var r=!1;for(var a in t)e[t[a]]&&(r=!0);return r}(e,latest_source_channel)&&(sa.clearAppRegister(latest_source_channel),sa.clearAllProps(latest_source_channel)),sa.para.is_persistent_save.utm?sa.register(e):sa.registerApp(e))},_.setLatestShare=function(e){(e.$latest_share_depth||e.$latest_share_distinct_id||e.$latest_share_url_path||e.$latest_share_method)&&(sa.clearAppRegister(latest_share_info),sa.clearAllProps(latest_share_info),sa.para.is_persistent_save.share?sa.register(e):sa.registerApp(e))},sa.login=function(e){if(e=_.validId(e)){var t=sa.store.getFirstId(),r=sa.store.getDistinctId();if(sa.store._state.identities.hasOwnProperty(sa.para.login_id_key)&&e===t)return!1;var a=!(sa.para.login_id_key===sa.store._state.history_login_id.name&&sa.store._state.history_login_id.value===e);a&&(sa.store._state.identities[sa.para.login_id_key]=e),a&&(t?sa.trackSignup(e,"$SignUp"):(sa.store.set("first_id",r),sa.trackSignup(e,"$SignUp"))),a&&(sa.store.identitiesSet("login",e),sa.store.set("history_login_id",{name:sa.para.login_id_key,value:e}))}},sa.getAnonymousID=function(){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")},sa.logout=function(e){var t=sa.store.getFirstId();t?(sa.store.set("first_id",""),!0===e?sa.store.set("distinct_id",sa.store.getUUID()):sa.store.set("distinct_id",t)):logger.info("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25"),sa.store.identitiesSet("logout"),sa.store.set("history_login_id",{name:"",value:""})},sa.getLocation=function(){wx.getSetting({success:function(e){if(!e.authSetting["scope.userLocation"])return!1;wx.getLocation({type:sa.para.preset_properties.location.type,success:function(e){sa.registerApp({$latitude:e.latitude*Math.pow(10,6),$longitude:e.longitude*Math.pow(10,6),$geo_coordinate_system:_.setUpperCase(sa.para.preset_properties.location.type)})},fail:function(e){logger.info("\u83b7\u53d6\u4f4d\u7f6e\u5931\u8d25",e)}})}})},sa.openid={getRequest:function(e){wx.login({success:function(t){t.code&&sa.para.appid&&sa.para.openid_url?_.wxrequest({url:sa.para.openid_url+"&code="+t.code+"&appid="+sa.para.appid,method:"GET",complete:function(t){_.isObject(t)&&_.isObject(t.data)&&t.data.openid?e(t.data.openid):e()}}):e()}})},getWXStorage:function(){var e=sa.store.getStorage();if(e&&_.isObject(e))return e.openid},getOpenid:function(e){if(!sa.para.appid)return e(),!1;var t=this.getWXStorage();t?e(t):this.getRequest(e)}},sa.initial=function(){this._.info.getSystem(),this.store.init()},sa.init=function(e){if(!0===this.hasInit)return!1;this.hasInit=!0,sa.setPara(e),sa.para.encrypt_storage&&this.store.encryptStorage(),sa.para.batch_send&&sendStrategy.init(),sa.initialState.storeIsComplete=!0,sa.initialState.checkIsComplete()},sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib){var e={};_.each(_.info.currentProps,function(t,r){0===r.indexOf("$")&&(e[r]=t)});var t={$url_path:_.getCurrentPath(),$is_first_day:_.getIsFirstDay(),$is_first_time:is_first_launch},r=_.extend(e,t,_.info.properties,sa.store.getProps());return delete r.$lib,r}return{}},sa.setOpenid=function(e,t){if(!(e=_.validId(e)))return!1;t&&console.log("%c \u5f53\u524d\u7248\u672c setOpenid \u63a5\u53e3 \u5df2\u4e0d\u652f\u6301\u4f20\u5165\u7b2c\u4e8c\u4e2a\u53c2\u6570","color:#F39C12;font-size: 14px;"),sa.store.set("openid",e),sa.identify(e,!0),sa.bind("$identity_mp_openid",e)},sa.unsetOpenid=function(e){var t=_.validId(e);if(!t)return!1;sa.store._state.openid===t&&sa.store.set("openid",""),sa.unbind("$identity_mp_openid",t)},sa.setUnionid=function(e){var t=_.validId(e);t&&sa.bind("$identity_mp_unionid",t)},sa.unsetUnionid=function(e){var t=_.validId(e);if(t){if(sa.store._state.identities.hasOwnProperty("$identity_mp_unionid")&&t===sa.store._state.identities.$identity_mp_unionid){var r=_.getOpenidNameByAppid();sa.store._state.identities.hasOwnProperty(r)&&(delete sa.store._state.identities[r],delete sa.store._state.openid,sa.store.save())}sa.unbind("$identity_mp_unionid",t)}},sa.initWithOpenid=function(e,t){(e=e||{}).appid&&(sa.para.appid=e.appid),sa.openid.getOpenid(function(r){r&&sa.setOpenid(r,e.isCoverLogin),t&&_.isFunction(t)&&t(r),sa.init(e)})},sa.bind=function(e,t){if(_.isNumber(t)){if(_.isInteger(t)&&!1===_.isSafeInteger(t))return logger.info("Value must be String"),!1;t=String(t)}if(!_.isString(e))return logger.info("Key must be String"),!1;if(!_.check.checkKeyword(e)||"$identity_anonymous_id"===e||"$mp_id"===e||"$identity_mp_id"===e||"$identity_login_id"===e||e===sa.para.login_id_key){var r="Key ["+e+"] is invalid";return logger.info(r),!1}if(!t||""===t)return logger.info("Value is empty or null"),!1;if(!_.isString(t))return logger.info("Value must be String"),!1;if(!_.check.ckeckIdLength(t)){r="Value ["+t+"] is beyond the maximum length 255";return logger.info(r),!1}var a=sa.store._state.identities;"$identity_mp_openid"===e&&(e=_.getOpenidNameByAppid()),a[e]=t,sa.store.save(),sa.saEvent.send({type:"track_id_bind",event:"$BindID"})},sa.unbind=function(e,t){if(_.isNumber(t)){if(_.isInteger(t)&&!1===_.isSafeInteger(t))return logger.info("Value must be String"),!1;t=String(t)}if(!_.isString(e))return logger.info("Key must be String"),!1;if(!_.check.checkKeyword(e)||"$identity_anonymous_id"===e||"$mp_id"===e||"$identity_mp_id"===e||"$identity_login_id"===e||e===sa.para.login_id_key){var r="Key ["+e+"] is invalid";return logger.info(r),!1}if(!t||""===t)return logger.info("Value is empty or null"),!1;if(!_.isString(t))return logger.info("Value must be String"),!1;if(!_.check.ckeckIdLength(t)){r="Value ["+t+"] is beyond the maximum length 255";return logger.info(r),!1}"$identity_mp_openid"===e&&(e=_.getOpenidNameByAppid()),sa.store._state.identities.hasOwnProperty(e)&&t===sa.store._state.identities[e]&&(delete sa.store._state.identities[e],sa.store.save());var a={};a[e]=t,sa.saEvent.send({type:"track_id_unbind",event:"$UnbindID",unbind_value:a})},sa.setWebViewUrl=function(e,t){if(!_.isString(e)||""===e)return logger.info("error:\u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;if(!/^http(s)?:\/\//.test(e))return logger.info("warning: \u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;var r=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e);if(!r)return!1;var a,s=r[1]||"",i=r[2]||"",n=r[3]||"",o="",u=sa.store.getDistinctId()||"",c=sa.store.getFirstId()||"";_.urlSafeBase64&&_.urlSafeBase64.encode?u=u?_.urlSafeBase64.trim(_.urlSafeBase64.encode(_.urlBase64Encode(u))):"":this._.rot13obfs&&(u=u?_.rot13obfs(u):""),u=encodeURIComponent(u);var p=c?"f"+u:"d"+u;t?(a=n.indexOf("_sasdk"),o=n.indexOf("?")>-1?a>-1?s+i+"#"+n.substring(1,a)+"_sasdk="+p:s+i+"#"+n.substring(1)+"&_sasdk="+p:s+i+"#"+n.substring(1)+"?_sasdk="+p):(a=i.indexOf("_sasdk"),o=/^\?(\w)+/.test(i)?a>-1?s+i.replace(/(_sasdk=)([^&]*)/gi,"_sasdk="+p)+n:s+"?"+i.substring(1)+"&_sasdk="+p+n:s+"?"+i.substring(1)+"_sasdk="+p+n);return o},_.each(["setProfile","setOnceProfile","track","quick","incrementProfile","appendProfile","login","logout","registerApp","register","clearAllRegister","clearAllProps","clearAppRegister","bind","unbind","unsetOpenid","setUnionid","unsetUnionid"],function(e){var t=sa[e];sa[e]=function(){sa.initialState.isComplete?t.apply(sa,arguments):sa.initialState.queue.push([e,arguments])}}),_.setQuery=function(e,t){if(e&&_.isObject(e)&&!_.isEmptyObject(e)){var r=[];return _.each(e,function(e,a){"q"===a&&_.isString(e)&&0===e.indexOf("http")||(t?r.push(a+"="+e):r.push(a+"="+_.decodeURIComponent(e)))}),r.join("&")}return""},_.getUtmFromPage=function(){var e={};try{var t=_.getCurrentPage(),r=_.deepCopy(t.options);for(var a in r)r[a]=_.decodeURIComponent(r[a]);e=_.getCustomUtmFromQuery(r,"$","_","$")}catch(e){logger.info(e)}return e},_.sendPageLeave=function(){var e={},t="";try{t=(e=_.getCurrentPage())?e.route:""}catch(e){logger.info(e)}if(page_show_time>=0&&""!==t){var r={},a=_.getPageTitle(t),s=(Date.now()-page_show_time)/1e3;r.$url_query=e.sensors_mp_url_query?e.sensors_mp_url_query:"",r.$url_path=t,r.$title=a,r.event_duration=s,sa.track("$MPPageLeave",r),page_show_time=-1}},sa.autoTrackCustom={trackCustom:function(e,t,r){var a=sa.para.autoTrack[e],s="";sa.para.autoTrack&&a&&("function"==typeof a?(s=a(),_.isObject(s)&&_.extend(t,s)):_.isObject(a)&&(_.extend(t,a),sa.para.autoTrack[e]=!0),sa.track(r,t))},appLaunch:function(e,t){"object"!=typeof this||this.trackCustom||(this[sa.para.name]=sa);var r={};if(e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,r.$scene=_.getMPScene(e.scene)):r.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(r.$url_path=_.getPath(e.path),r.$title=_.getPageTitle(e.path),e.query&&_.isObject(e.query))){var a=_.setQuery(e.query);a=a?"?"+a:"",r.$url=r.$url_path+a}_.setShareInfo(e,r);var s=_.setUtm(e,r);is_first_launch?(r.$is_first_time=!0,_.isEmptyObject(s.pre1)||sa.setOnceProfile(s.pre1)):r.$is_first_time=!1,_.setLatestChannel(s.pre2),_.setSfSource(e,r),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(e.query),_.setPageRefData(r),t?(r=_.extend(r,t),sa.track("$MPLaunch",r)):sa.para.autoTrack&&sa.para.autoTrack.appLaunch&&sa.autoTrackCustom.trackCustom("appLaunch",r,"$MPLaunch")},appShow:function(e,t){var r={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,r.$scene=_.getMPScene(e.scene)):r.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(r.$url_path=_.getPath(e.path),r.$title=_.getPageTitle(e.path)),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,r);var a=_.setUtm(e,r);_.setLatestChannel(a.pre2),_.setSfSource(e,r),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(e.query),_.setPageRefData(r,e.path,r.$url_query),e&&e.path&&(r.$url=e.path+(r.$url_query?"?"+r.$url_query:"")),t?(r=_.extend(r,t),sa.track("$MPShow",r)):sa.para.autoTrack&&sa.para.autoTrack.appShow&&sa.autoTrackCustom.trackCustom("appShow",r,"$MPShow")},appHide:function(e){var t=(new Date).getTime(),r={};r.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(r.event_duration=(t-mpshow_time)/1e3),_.setPageRefData(r),e?(r=_.extend(r,e),sa.track("$MPHide",r)):sa.para.autoTrack&&sa.para.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",r,"$MPHide"),sendStrategy.onAppHide()},pageLoad:function(e){current_scene&&1010===current_scene&&e&&(e.sampshare&&delete e.sampshare,_.delObjectKey(e)),e&&_.isObject(e)&&(this.sensors_mp_url_query=_.setQuery(e),this.sensors_mp_encode_url_query=_.setQuery(e,!0))},pageShow:function(){page_show_time=Date.now();var e={},t=_.getCurrentPath(),r=_.getPageTitle(t);_.setRefPage(),e.$url_path=t,e.$url_query=this.sensors_mp_url_query?this.sensors_mp_url_query:"",e=_.extend(e,_.getUtmFromPage()),_.setPageRefData(e),_.setPageSfSource(e),r&&(e.$title=r),sa.para.onshow?sa.para.onshow(sa,t,this):_.isObject(sa.para.autotrack_exclude_page)&&_.isArray(sa.para.autotrack_exclude_page.pageShow)&&-1!==sa.para.autotrack_exclude_page.pageShow.indexOf(t)||sa.autoTrackCustom.trackCustom("pageShow",e,"$MPViewScreen")},pageShare:function(e){var t=e.onShareAppMessage;e.onShareAppMessage=function(){share_method="\u8f6c\u53d1\u6d88\u606f\u5361\u7247";var e=t.apply(this,arguments);if(sa.para.autoTrack&&sa.para.autoTrack.pageShare){var r={$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method};_.setPageRefData(r),sa.autoTrackCustom.trackCustom("pageShare",r,"$MPShare")}return sa.para.allow_amend_share_path&&("object"!=typeof e&&((e={}).path=_.getCurrentUrl(this)),"object"!=typeof e||void 0!==e.path&&""!==e.path||(e.path=_.getCurrentUrl(this)),"object"==typeof e&&"string"==typeof e.path&&(-1===e.path.indexOf("?")?e.path=e.path+"?":"&"!==e.path.slice(-1)&&(e.path=e.path+"&")),e.path=e.path+_.getShareInfo()),e}},pageShareTimeline:function(e){var t=e.onShareTimeline;e.onShareTimeline=function(){share_method="\u670b\u53cb\u5708\u5206\u4eab";var e=t.apply(this,arguments);if(sa.para.autoTrack&&sa.para.autoTrack.pageShare){var r={$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method};_.setPageRefData(r),sa.autoTrackCustom.trackCustom("pageShare",r,"$MPShare")}return sa.para.allow_amend_share_path&&("object"!=typeof e&&(e={}),"object"==typeof e&&void 0===e.query&&(e.query=""),"object"==typeof e&&"string"==typeof e.query&&""!==e.query&&"&"!==e.query.slice(-1)&&(e.query=e.query+"&"),e.query=e.query+_.getShareInfo()),e}},pageAddFavorites:function(){var e={};e.$url_path=_.getCurrentPath(),sa.para.autoTrack&&sa.para.autoTrack.mpFavorite&&sa.autoTrackCustom.trackCustom("mpFavorite",e,"$MPAddFavorites")}},sa.quick=function(){var e=arguments[0],t=arguments[1],r=arguments[2],a=_.isObject(r)?r:{};if("getAnonymousID"===e){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===e||"appShow"===e?t?sa.autoTrackCustom[e](t,a):logger.info("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(a=_.isObject(t)?t:{},sa.autoTrackCustom[e](a))},sa.appLaunch=function(e,t){var r={};e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,r.$scene=_.getMPScene(e.scene)):r.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(r.$url_path=_.getPath(e.path),r.$title=_.getPageTitle(e.path)),_.setShareInfo(e,r);var a=_.setUtm(e,r);is_first_launch?(r.$is_first_time=!0,_.isEmptyObject(a.pre1)||sa.setOnceProfile(a.pre1)):r.$is_first_time=!1,_.setLatestChannel(a.pre2),_.setSfSource(e,r),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(e.query),r.$url=e.path+(r.$url_query?"?"+r.$url_query:""),_.setPageRefData(t),_.isObject(t)&&(r=_.extend(r,t)),sa.track("$MPLaunch",r)},sa.appShow=function(e,t){var r={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,r.$scene=_.getMPScene(e.scene)):r.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(r.$url_path=_.getPath(e.path),r.$title=_.getPageTitle(e.path)),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,r);var a=_.setUtm(e,r);_.setLatestChannel(a.pre2),_.setSfSource(e,r),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(e.query),e&&e.path&&(r.$url=e.path+(r.$url_query?"?"+r.$url_query:"")),_.setPageRefData(r,e.path,r.$url_query),_.isObject(t)&&(r=_.extend(r,t)),sa.track("$MPShow",r)},sa.appHide=function(e){var t=(new Date).getTime(),r={};r.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(r.event_duration=(t-mpshow_time)/1e3),_.setPageRefData(r),_.isObject(e)&&(r=_.extend(r,e)),sa.track("$MPHide",r),sendStrategy.onAppHide()},sa.pageShow=function(e){var t={},r=_.getCurrentPath(),a=_.getPageTitle(r),s=_.getCurrentPage();_.setRefPage(),a&&(t.$title=a),t.$url_path=r,t.$url_query=s.sensors_mp_url_query?s.sensors_mp_url_query:"",t=_.extend(t,_.getUtmFromPage()),_.setPageSfSource(t),_.setPageRefData(t),_.isObject(e)&&(t=_.extend(t,e)),sa.track("$MPViewScreen",t)},global&&global.sensors_data_pre_config){var name=global.sensors_data_pre_config.login_id_key;name&&_.isString(name)&&_.check.checkKeyword(name)&&"$identity_anonymous_id"!==name&&"$mp_id"!==name&&"$identity_mp_id"!==name&&"$identity_mp_unionid"!==name&&"$mp_unionid"!==name&&"$identity_mp_openid"!==name&&"$mp_openid"!==name?sa.para.login_id_key=name:logger.info("\u8bbe\u7f6e\u81ea\u5b9a\u4e49\u767b\u5f55 ID \u5931\u8d25")}sa.initial(),module.exports=sa; \ No newline at end of file diff --git a/sensorsdata.es6.min.js b/sensorsdata.es6.min.js index 28dfb7c..267da3e 100755 --- a/sensorsdata.es6.min.js +++ b/sensorsdata.es6.min.js @@ -1 +1 @@ -var sa={};function isObject(e){return null!=e&&"[object Object]"==toString.call(e)}var getRandomBasic=function(){var e=(new Date).getTime();return function(t){return Math.ceil((e=(9301*e+49297)%233280)/233280*t)}}();function getRandom(){if("function"==typeof Uint32Array){var e="";if("undefined"!=typeof crypto?e=crypto:"undefined"!=typeof msCrypto&&(e=msCrypto),isObject(e)&&e.getRandomValues){var t=new Uint32Array(1);return e.getRandomValues(t)[0]/Math.pow(2,32)}}return getRandomBasic(1e19)/1e19}var kit={};function encodeTrackData(e){e=JSON.stringify(e);var t=sa._.base64Encode(e);return encodeURIComponent(t)}function setPublicPProperties(e){if(e&&e.properties){var t=sa._.getRefPage(),a=sa._.getCurrentPageInfo(),r={$referrer:t.route,$referrer_title:t.title,$title:a.title,$url:a.url};for(var s in r)e.properties.hasOwnProperty(s)||(e.properties[s]=r[s])}}kit.buildData=function(e){var t=sa._,a={distinct_id:sa.store.getDistinctId(),identities:sa.store._state.identities,lib:{$lib:sa.lib_name,$lib_method:"code",$lib_version:sa.lib_version},properties:{}};if("track_id_unbind"===e.type&&"$UnbindID"===e.event&&(a.identities=t.deepCopy(e.unbind_value),delete e.unbind_value),t.extend(a,sa.store.getUnionId(),e),t.isObject(e.properties)&&!t.isEmptyObject(e.properties)&&t.extend(a.properties,e.properties),!e.type||"profile"!==e.type.slice(0,7)){a._track_id=Number(String(getRandom()).slice(2,5)+String(getRandom()).slice(2,4)+String(Date.now()).slice(-4)),a.properties=t.extend({},t.info.properties,sa.store.getProps(),t.info.currentProps,a.properties),"track"===e.type&&(a.properties.$is_first_day=t.getIsFirstDay());t.getRefPage();setPublicPProperties(a)}return a.properties.$time&&t.isDate(a.properties.$time)?(a.time=1*a.properties.$time,delete a.properties.$time):a.time=1*new Date,t.parseSuperProperties(a.properties),t.searchObjDate(a),t.searchObjString(a),a},kit.processData=function(e){return e},kit.onceTrackData=function(e){return"data="+encodeTrackData(e)},kit.batchTrackData=function(e){return"data_list="+encodeTrackData(e)};var mergeStorageData={getData:function(e){wx.getStorage({key:sa.para.storage_prepare_data_key,complete:function(t){var a=t.data&&sa._.isArray(t.data)?t.data:[];mergeStorageData.deleteAesData(a),e&&e()}})},deleteAesData:function(e){var t=[],a=e.length;if(a>0){for(var r=0;r=500&&(sa._.logger.info("\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38"),sa.store.mem.mdata.shift());var t=Date.now();e._flush_time=t,(e=kit.processData(e))&&sa.store.mem.add(e),sa.store.mem.getLength()>=sa.para.batch_send.max_length&&this.batchSend()},wxrequest:function(e){if(sa._.isArray(e.data)&&e.data.length>0){var t=kit.batchTrackData(e.data);sa._.wxrequest({url:sa.para.server_url,method:"POST",dataType:"text",data:t,success:function(){e.success(e.len)},fail:function(){e.fail()}})}else e.success(e.len)},batchSend:function(){if(this.dataHasSend){var e,t,a=sa.store.mem.mdata;(t=(e=a.length>=100?a.slice(0,100):a).length)>0&&(this.dataHasSend=!1,this.wxrequest({data:e,len:t,success:this.batchRemove.bind(this),fail:this.sendFail.bind(this)}))}},sendFail:function(){this.dataHasSend=!0,this.failTime++},batchRemove:function(e){sa.store.mem.clear(e),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite(),this.failTime=0},is_first_batch_write:!0,batchWrite:function(){var e=this;this.dataHasChange&&(this.is_first_batch_write&&(this.is_first_batch_write=!1,setTimeout(function(){e.batchSend()},1e3)),this.dataHasChange=!1,this.syncStorage&&sa._.setStorageSync(sa.para.storage_prepare_data_key,sa.store.mem.mdata))},batchInterval:function(){var e=this;!function t(){setTimeout(function(){e.batchWrite(),t()},500)}(),function t(){setTimeout(function(){e.batchSend(),t()},sa.para.batch_send.send_timeout*Math.pow(2,e.failTime))}()}};function getSendUrl(e,t){var a=kit.onceTrackData(t);return-1!==e.indexOf("?")?e+"&"+a:e+"?"+a}function onceSend(e){e._flush_time=Date.now();var t=getSendUrl(sa.para.server_url,e);sa._.wxrequest({url:t,method:"GET"})}var saEvent={send:function(e,t){if(!sa.para.server_url)return sa._.logger.info("error: server_url \u4e0d\u80fd\u4e3a\u7a7a"),!1;if(sa.current_scene&&1154===sa.current_scene&&!sa.para.preset_events.moments_page)return!1;var a=sa.kit.buildData(e);a?(saEvent.debug(a),sa.events.emit("send",a),sa.para.batch_send?sendStrategy.send(a):onceSend(a)):sa._.logger.info("error: \u6570\u636e\u5f02\u5e38 "+a)},debug:function(e){sa._.logger.info(e)}},_={};sa.kit=kit,sa.mergeStorageData=mergeStorageData,sa.saEvent=saEvent,sa.sendStrategy=sendStrategy,sa.IDENTITY_KEY={EMAIL:"$identity_email",MOBILE:"$identity_mobile"},sa.para={name:"sensors",server_url:"",send_timeout:1e3,show_log:!1,login_id_key:"$identity_login_id",allow_amend_share_path:!0,max_string_length:500,datasend_timeout:3e3,source_channel:[],autoTrack:{appLaunch:!0,appShow:!0,appHide:!0,pageShow:!0,pageShare:!0,mpClick:!1,mpFavorite:!0,pageLeave:!1},autotrack_exclude_page:{pageShow:[]},is_persistent_save:{share:!1,utm:!1},preset_properties:{url_path:!0},preset_events:{moments_page:!1,defer_track:!1,share_info_use_string:!1},batch_send:!0,storage_store_key:"sensorsdata2015_wechat",storage_prepare_data_key:"sensors_mp_prepare_data"};var deploy_para={launched:!1},mpHook={data:1,onLoad:1,onShow:1,onReady:1,onPullDownRefresh:1,onShareAppMessage:1,onShareTimeline:1,onReachBottom:1,onPageScroll:1,onResize:1,onTabItemTap:1,onHide:1,onUnload:1},logger="object"==typeof logger?logger:{};logger.info=function(){if(sa.para.show_log&&"object"==typeof console&&console.log)try{if(3===arguments.length)return console.log(arguments[0],arguments[1],arguments[2]);if(2===arguments.length)return console.log(arguments[0],arguments[1]);if(1===arguments.length)return console.log(arguments[0])}catch(e){console.log(arguments[0])}},sa.setPara=function(e){sa.para=_.extend2Lev(sa.para,e);var t=[];if(_.isArray(sa.para.source_channel))for(var a=sa.para.source_channel.length,r=0;rsa.para.max_string_length?(logger.info("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,sa.para.max_string_length)):e},_.searchObjString=function(e){_.isObject(e)&&_.each(e,function(t,a){_.isObject(t)?_.searchObjString(e[a]):_.isString(t)&&(e[a]=_.formatString(t))})},_.parseSuperProperties=function(e){_.isObject(e)&&(_.each(e,function(t,a){if(_.isFunction(t))try{e[a]=t(),_.isFunction(e[a])&&(logger.info("\u60a8\u7684\u5c5e\u6027- "+a+" \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}catch(t){delete e[a],logger.info("\u60a8\u7684\u5c5e\u6027- "+a+" \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}}),_.strip_sa_properties(e))},_.unique=function(e){for(var t,a=[],r={},s=0;s255)||(logger.info("id \u957f\u5ea6\u8d85\u8fc7 255 \u4e2a\u5b57\u7b26\uff01"),!1)}},_.strip_sa_properties=function(e){return _.isObject(e)?(_.each(e,function(t,a){if(_.isArray(t)){var r=[];_.each(t,function(e){_.isString(e)?r.push(e):logger.info("\u60a8\u7684\u6570\u636e-",t,"\u7684\u6570\u7ec4\u91cc\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32,\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}),e[a]=r}_.isString(t)||_.isNumber(t)||_.isDate(t)||_.isBoolean(t)||_.isArray(t)||(logger.info("\u60a8\u7684\u6570\u636e-",t,"-\u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}),e):e},_.strip_empty_properties=function(e){var t={};return _.each(e,function(e,a){null!=e&&(t[a]=e)}),t},_.utf8Encode=function(e){var t,a,r,s,i="";for(t=a=0,r=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,s=0;s127&&n<2048?String.fromCharCode(n>>6|192,63&n|128):String.fromCharCode(n>>12|224,n>>6&63|128,63&n|128),null!==o&&(a>t&&(i+=e.substring(t,a)),i+=o,t=a=s+1)}return a>t&&(i+=e.substring(t,e.length)),i},_.base64Encode=function(e){var t,a,r,s,i,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,c=0,u="",p=[];if(!e)return e;e=_.utf8Encode(e);do{t=(i=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,a=i>>12&63,r=i>>6&63,s=63&i,p[c++]=n.charAt(t)+n.charAt(a)+n.charAt(r)+n.charAt(s)}while(o255||(r=e.charCodeAt(o++))>255||(s=e.charCodeAt(o++))>255)&&logger.info("Failed to execute 'btoa' : The string to be encoded contains characters outside of the Latin1 range."),n+=i.charAt((t=a<<16|r<<8|s)>>18&63)+i.charAt(t>>12&63)+i.charAt(t>>6&63)+i.charAt(63&t);return _?n.slice(0,_-3)+"===".substring(_):n},_.urlBase64Encode=function(e){return _.btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))},_.rot13obfs=function(e,t){t="number"==typeof t?t:13;for(var a=(e=String(e)).split(""),r=0,s=a.length;r(new Date).getTime()},_.getCurrentUrl=function(e){var t=_.getCurrentPath(),a="";return _.isObject(e)&&e.sensors_mp_encode_url_query&&(a=e.sensors_mp_encode_url_query),t?a?t+"?"+a:t:"\u672a\u53d6\u5230"},_.getPath=function(e){return e="string"==typeof e?e.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"},_.getMethods=function(e){var t=[];for(var a in e)"function"!=typeof e[a]||mpHook[a]||t.push(a);return t},_.isClick=function(e){return!!{tap:1,longpress:1,longtap:1}[e]},sa.initialState={queue:[],isComplete:!1,systemIsComplete:!1,storeIsComplete:!1,checkIsComplete:function(){this.systemIsComplete&&this.storeIsComplete&&(this.isComplete=!0,this.queue.length>0&&(_.each(this.queue,function(e){sa[e[0]].apply(sa,slice.call(e[1]))}),this.queue=[]))}},_.getCustomUtmFromQuery=function(e,t,a,r){if(!_.isObject(e))return{};var s={};if(e.sa_utm)for(var i in e)"sa_utm"!==i?_.include(sa.para.source_channel,i)&&(s[a+i]=e[i]):s[r+i]=e[i];else for(var i in e)-1===(" "+source_channel_standard+" ").indexOf(" "+i+" ")?_.include(sa.para.source_channel,i)&&(s[a+i]=e[i]):s[t+i]=e[i];return s},_.getObjFromQuery=function(e){var t=e.split("?"),a=[],r={};return t&&t[1]?(_.each(t[1].split("&"),function(e){(a=e.split("="))[0]&&a[1]&&(r[a[0]]=a[1])}),r):{}},_.setStorageSync=function(e,t){var a=function(){wx.setStorageSync(e,t)};try{a()}catch(e){logger.info("set Storage fail --",e);try{a()}catch(e){logger.info("set Storage fail again --",e)}}},_.getStorageSync=function(e){var t="";try{t=wx.getStorageSync(e)}catch(a){try{t=wx.getStorageSync(e)}catch(e){logger.info("getStorage fail")}}return t},_.getMPScene=function(e){return"number"==typeof e||"string"==typeof e&&""!==e?e="wx-"+String(e):"\u672a\u53d6\u5230\u503c"},_.objToParam=function(e,t){if("[object Object]"!==Object.prototype.toString.call(e))return logger.info("\u8bf7\u4f20\u5165\u6709\u6548\u5bf9\u8c61"),"";var a=[];for(var r in e)if(e.hasOwnProperty(r)){var s=e[r];void 0===s?a.push(r+"="):(s=t?encodeURIComponent(s):s,a.push(r+"="+s))}return a.join("&")},_.delObjectKey=function(e){if("[object Object]"===Object.prototype.toString.call(e))for(var t=0;t=2?(page_route_map.shift(),page_route_map.push(e)):page_route_map.push(e)}}catch(e){logger.info(e)}},_.getRefPage=function(){var e={route:"\u76f4\u63a5\u6253\u5f00",title:""};return page_route_map.length>1&&(e.title=page_route_map[0].title,e.route=page_route_map[0].route),e},_.getCurrentPageInfo=function(){var e=_.getCurrentPage(),t={title:"",url:""};if(e&&e.route){var a=e.sensors_mp_url_query?"?"+e.sensors_mp_url_query:"";t.title=_.getPageTitle(e.route),t.url=e.route+a}return t},_.setPageRefData=function(e,t,a){var r=_.getRefPage();_.isObject(e)&&(t?page_route_map.length>0&&t?(a=a?"?"+a:"",e.$referrer=_.getPath(t)+a,e.$referrer_title=_.getPageTitle(t)):(e.$referrer="\u76f4\u63a5\u6253\u5f00",e.$referrer_title=""):(e.$referrer=r.route,e.$referrer_title=r.title))},_.getPageTitle=function(e){if("\u672a\u53d6\u5230"===e||!e)return"";var t="";try{if(__wxConfig){var a=__wxConfig,r=__wxConfig.page||{},s=r[e]||r[e+".html"],i={},n={};if(a.global&&a.global.window&&a.global.window.navigationBarTitleText&&(i.titleVal=a.global.window.navigationBarTitleText),s&&s.window&&s.window.navigationBarTitleText&&(n.titleVal=s.window.navigationBarTitleText),!n.titleVal&&__wxAppCode__){var o=__wxAppCode__[e+".json"];o&&o.navigationBarTitleText&&(n.titleVal=o.navigationBarTitleText)}if(_.each(globalTitle,function(a,r){if(r===e)return t=a}),0===t.length){var c=_.extend(i,n);t=c.titleVal||""}}}catch(e){logger.info(e)}return t},_.wxrequest=function(e){if(_.compareSDKVersion(wxSDKVersion,"2.10.0")>=0)e.timeout=sa.para.datasend_timeout,wx.request(e);else{var t=wx.request(e);setTimeout(function(){_.isObject(t)&&_.isFunction(t.abort)&&t.abort()},sa.para.datasend_timeout)}},_.getAppInfoSync=function(){if(wx.getAccountInfoSync){var e=wx.getAccountInfoSync(),t=e&&e.miniProgram?e.miniProgram:{};return{appId:t.appId,appEnv:t.envVersion,appVersion:t.version}}return{}},_.getAppId=function(){var e=_.getAppInfoSync();return e&&e.appId?e.appId:""},_.validId=function(e){return"string"!=typeof e&&"number"!=typeof e||""===e?(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1):"number"!=typeof e||(e=String(e),/^\d+$/.test(e))?!!_.check.ckeckIdLength(e)&&e:(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1)},_.compareSDKVersion=function(e,t){e=e.split("."),t=t.split(".");for(var a=Math.max(e.length,t.length);e.lengthi)return 1;if(s-1?t.system.split(" ")[1]:t.system,wxSDKVersion=t.SDKVersion,e.$mp_client_app_version=t.version,e.$mp_client_basic_library_version=wxSDKVersion},complete:function(){var t=(new Date).getTimezoneOffset(),a=_.getAppInfoSync();_.isNumber(t)&&(e.$timezone_offset=t),a.appId&&(e.$app_id=a.appId),a.appVersion&&(e.$app_version=a.appVersion),sa.initialState.systemIsComplete=!0,sa.initialState.checkIsComplete()}})}wx.getNetworkType({success:function(t){e.$network_type=_.setUpperCase(t.networkType)},complete:t})}},sa._=_,_.eventEmitter=function(){this.sub=[]},_.eventEmitter.prototype={add:function(e){this.sub.push(e)},emit:function(e,t){this.sub.forEach(function(a){a.on(e,t)})}},_.eventSub=function(e){sa.events.add(this),this._events=[],this.handle=e,this.ready=!1},_.eventSub.prototype={on:function(e,t){if(this.ready){if(_.isFunction(this.handle))try{this.handle(e,t)}catch(e){logger.info(e)}}else this._events.push({event:e,data:t})},isReady:function(){var e=this;e.ready=!0,e._events.forEach(function(t){if(_.isFunction(e.handle))try{e.handle(t.event,t.data)}catch(e){logger.info(e)}})}},sa.eventSub=_.eventSub,sa.events=new _.eventEmitter,sa.usePlugin=function(e,t){"function"==typeof e.init&&e.init(sa,t)},sa.store={storageInfo:null,getUUID:function(){return Date.now()+"-"+Math.floor(1e7*getRandom())+"-"+getRandom().toString(16).replace(".","")+"-"+String(31242*getRandom()).replace(".","").slice(0,8)},getStorage:function(){return this.storageInfo?this.storageInfo:(this.storageInfo=sa._.getStorageSync(sa.para.storage_store_key)||"",this.storageInfo)},_state:{},mem:{mdata:[],getLength:function(){return this.mdata.length},add:function(e){this.mdata.push(e)},clear:function(e){this.mdata.splice(0,e)}},toState:function(e){var t=null;_.isJSONString(e)?(t=JSON.parse(e)).distinct_id?this._state=t:this.set("distinct_id",this.getUUID()):_.isObject(e)&&(t=e).distinct_id?this._state=t:this.set("distinct_id",this.getUUID());var a=this._state._first_id||this._state.first_id,r=this._state._distinct_id||this._state.distinct_id,s=this._state.openid,i=(this._state.history_login_id?this._state.history_login_id:{}).name;if(this._state.identities&&_.isString(this._state.identities)){var n=JSON.parse(_.rot13defs(this._state.identities));this._state.identities=n}if(this._state.identities&&_.isObject(this._state.identities)&&!_.isEmptyObject(this._state.identities)?this._state.identities.hasOwnProperty("$identity_anonymous_id")&&(this._state.identities.$identity_anonymous_id=a||r):(this._state.identities={},this._state.identities.$mp_id=this.getUUID(),this._state.identities.$identity_anonymous_id=a||r),s){var o=_.getOpenidNameByAppid();this._state.identities[o]=s}if(a)if(i&&this._state.identities.hasOwnProperty(i)){if(this._state.identities[i]!==r){for(var c in this._state.identities[i]=r,this._state.identities)this._state.identities.hasOwnProperty(c)&&"$mp_id"!==c&&c!==i&&delete this._state.identities[c];this._state.history_login_id.value=r}}else{for(var c in this._state.identities[sa.para.login_id_key]=r,this._state.identities)this._state.identities.hasOwnProperty(c)&&"$mp_id"!==c&&c!==sa.para.login_id_key&&delete this._state.identities[c];this._state.history_login_id={name:sa.para.login_id_key,value:r}}else{if(this._state.identities.hasOwnProperty("$identity_login_id")||this._state.identities.hasOwnProperty(i))for(var c in this._state.identities)this._state.identities.hasOwnProperty(c)&&"$mp_id"!==c&&"$identity_anonymous_id"!==c&&delete this._state.identities[c];this._state.history_login_id={name:"",value:""}}this.save()},getFirstId:function(){return this._state._first_id||this._state.first_id},getDistinctId:function(){return this._state._distinct_id||this._state.distinct_id},getUnionId:function(){var e={},t=this._state._first_id||this._state.first_id,a=this._state._distinct_id||this._state.distinct_id;return t&&a?(e.login_id=a,e.anonymous_id=t):e.anonymous_id=a,e},getProps:function(){return this._state.props||{}},setProps:function(e,t){var a=this._state.props||{};t?this.set("props",e):(_.extend(a,e),this.set("props",a))},set:function(e,t){var a={};for(var r in"string"==typeof e?a[e]=t:"object"==typeof e&&(a=e),this._state=this._state||{},a)this._state[r]=a[r],"first_id"===r?delete this._state._first_id:"distinct_id"===r&&(delete this._state._distinct_id,sa.events.emit("changeDistinctId"));this.save()},identitiesSet:function(e,t){var a={};switch(e){case"login":a.$mp_id=sa.store._state.identities.$mp_id,a[sa.para.login_id_key]=t;break;case"logout":a.$mp_id=sa.store._state.identities.$mp_id;break;case"identify":(a=_.deepCopy(sa.store._state.identities)).$identity_anonymous_id=t}sa.store.set("identities",a)},change:function(e,t){this._state["_"+e]=t},encryptStorage:function(){var e=this.getStorage(),t="data:enc;";_.isObject(e)?e=t+_.rot13obfs(JSON.stringify(e)):_.isString(e)&&-1===e.indexOf(t)&&(e=t+_.rot13obfs(e)),sa._.setStorageSync(sa.para.storage_store_key,e)},save:function(){var e=_.deepCopy(this._state),t=_.rot13obfs(JSON.stringify(e.identities));if(e.identities=t,delete e._first_id,delete e._distinct_id,sa.para.encrypt_storage){e="data:enc;"+_.rot13obfs(JSON.stringify(e))}sa._.setStorageSync(sa.para.storage_store_key,e)},init:function(){var e=this.getStorage();if(e)_.isString(e)&&-1!==e.indexOf("data:enc;")&&(e=e.substring("data:enc;".length),e=JSON.parse(_.rot13defs(e))),this.toState(e);else{is_first_launch=!0;var t=new Date,a=t.getTime();t.setHours(23),t.setMinutes(59),t.setSeconds(60),sa.setOnceProfile({$first_visit_time:new Date}),this.set({distinct_id:this.getUUID(),first_visit_time:a,first_visit_day_time:t.getTime(),identities:{$mp_id:this.getUUID()},history_login_id:{name:"",value:""}})}}},sa.setProfile=function(e,t){sa.saEvent.send({type:"profile_set",properties:e},t)},sa.setOnceProfile=function(e,t){sa.saEvent.send({type:"profile_set_once",properties:e},t)},sa.appendProfile=function(e,t){if(!_.isObject(e))return!1;_.each(e,function(t,a){_.isString(t)?e[a]=[t]:(delete e[a],logger.info("appendProfile\u5c5e\u6027\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32\u6216\u8005\u6570\u7ec4"))}),sa.saEvent.send({type:"profile_append",properties:e},t)},sa.incrementProfile=function(e,t){if(!_.isObject(e))return!1;var a=e;_.isString(e)&&((e={})[a]=1),sa.saEvent.send({type:"profile_increment",properties:e},t)},sa.track=function(e,t,a){this.saEvent.send({type:"track",event:e,properties:t},a)},sa.identify=function(e,t){if(e=_.validId(e)){var a=sa.store.getFirstId();!0===t?a?sa.store.set("first_id",e):sa.store.set("distinct_id",e):a?sa.store.change("first_id",e):sa.store.change("distinct_id",e),sa.store.identitiesSet("identify",e)}},sa.trackSignup=function(e,t,a,r){var s=sa.store.getFirstId()||sa.store.getDistinctId();sa.store.set("distinct_id",e),sa.saEvent.send({original_id:s,distinct_id:e,type:"track_signup",event:t,properties:a},r)},sa.registerApp=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&(_.info.currentProps=_.extend(_.info.currentProps,e))},sa.register=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&sa.store.setProps(e)},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.clearAllProps=function(e){var t=sa.store.getProps(),a={};_.isArray(e)&&(_.each(t,function(t,r){_.include(e,r)||(a[r]=t)}),sa.store.setProps(a,!0))},sa.clearAppRegister=function(e){_.isArray(e)&&_.each(_.info.currentProps,function(t,a){_.include(e,a)&&delete _.info.currentProps[a]})},_.setLatestChannel=function(e){_.isEmptyObject(e)||(function(e,t){var a=!1;for(var r in t)e[t[r]]&&(a=!0);return a}(e,latest_source_channel)&&(sa.clearAppRegister(latest_source_channel),sa.clearAllProps(latest_source_channel)),sa.para.is_persistent_save.utm?sa.register(e):sa.registerApp(e))},_.setLatestShare=function(e){(e.$latest_share_depth||e.$latest_share_distinct_id||e.$latest_share_url_path||e.$latest_share_method)&&(sa.clearAppRegister(latest_share_info),sa.clearAllProps(latest_share_info),sa.para.is_persistent_save.share?sa.register(e):sa.registerApp(e))},sa.login=function(e){if(e=_.validId(e)){var t=sa.store.getFirstId(),a=sa.store.getDistinctId();if(sa.store._state.identities.hasOwnProperty(sa.para.login_id_key)&&e===t)return!1;var r=!(sa.para.login_id_key===sa.store._state.history_login_id.name&&sa.store._state.history_login_id.value===e);r&&(sa.store._state.identities[sa.para.login_id_key]=e),r&&(t?sa.trackSignup(e,"$SignUp"):(sa.store.set("first_id",a),sa.trackSignup(e,"$SignUp"))),r&&(sa.store.identitiesSet("login",e),sa.store.set("history_login_id",{name:sa.para.login_id_key,value:e}))}},sa.getAnonymousID=function(){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")},sa.logout=function(e){var t=sa.store.getFirstId();t?(sa.store.set("first_id",""),!0===e?sa.store.set("distinct_id",sa.store.getUUID()):sa.store.set("distinct_id",t)):logger.info("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25"),sa.store.identitiesSet("logout"),sa.store.set("history_login_id",{name:"",value:""})},sa.getLocation=function(){wx.getSetting({success:function(e){if(!e.authSetting["scope.userLocation"])return!1;wx.getLocation({type:sa.para.preset_properties.location.type,success:function(e){sa.registerApp({$latitude:e.latitude*Math.pow(10,6),$longitude:e.longitude*Math.pow(10,6),$geo_coordinate_system:_.setUpperCase(sa.para.preset_properties.location.type)})},fail:function(e){logger.info("\u83b7\u53d6\u4f4d\u7f6e\u5931\u8d25",e)}})}})},sa.openid={getRequest:function(e){wx.login({success:function(t){t.code&&sa.para.appid&&sa.para.openid_url?_.wxrequest({url:sa.para.openid_url+"&code="+t.code+"&appid="+sa.para.appid,method:"GET",complete:function(t){_.isObject(t)&&_.isObject(t.data)&&t.data.openid?e(t.data.openid):e()}}):e()}})},getWXStorage:function(){var e=sa.store.getStorage();if(e&&_.isObject(e))return e.openid},getOpenid:function(e){if(!sa.para.appid)return e(),!1;var t=this.getWXStorage();t?e(t):this.getRequest(e)}},sa.initial=function(){this._.info.getSystem(),this.store.init()},sa.init=function(e){if(!0===this.hasInit)return!1;this.hasInit=!0,sa.setPara(e),sa.para.encrypt_storage&&this.store.encryptStorage(),sa.para.batch_send&&sendStrategy.init(),sa.initialState.storeIsComplete=!0,sa.initialState.checkIsComplete()},sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib){var e={};_.each(_.info.currentProps,function(t,a){0===a.indexOf("$")&&(e[a]=t)});var t=_.extend(e,{$url_path:_.getCurrentPath(),$is_first_day:_.getIsFirstDay()},_.info.properties,sa.store.getProps());return delete t.$lib,t}return{}},sa.setOpenid=function(e,t){if(!(e=_.validId(e)))return!1;var a=sa.store.getFirstId();sa.store.set("openid",e),t?sa.store.set("distinct_id",e):(sa.identify(e,!0),a?sa.store.set("first_id",e):sa.store.set("distinct_id",e)),sa.bind("$mp_openid",e)},sa.unsetOpenid=function(e){var t=_.validId(e);if(!t)return!1;sa.store._state.openid===t&&sa.store.set("openid",""),sa.unbind("$mp_openid",t)},sa.setUnionid=function(e){var t=_.validId(e);t&&sa.bind("$mp_unionid",t)},sa.unsetUnionid=function(e){var t=_.validId(e);if(t){if(sa.store._state.identities.hasOwnProperty("$mp_unionid")&&t===sa.store._state.identities.$mp_unionid){var a=_.getOpenidNameByAppid();sa.store._state.identities.hasOwnProperty(a)&&(delete sa.store._state.identities[a],sa.store.save())}sa.unbind("$mp_unionid",t)}},sa.initWithOpenid=function(e,t){(e=e||{}).appid&&(sa.para.appid=e.appid),sa.openid.getOpenid(function(a){a&&sa.setOpenid(a,e.isCoverLogin),t&&_.isFunction(t)&&t(a),sa.init(e)})},sa.bind=function(e,t){if(_.isNumber(t)){if(_.isInteger(t)&&!1===_.isSafeInteger(t))return logger.info("Value must be String"),!1;t=String(t)}if(!_.isString(e))return logger.info("Key must be String"),!1;if(!_.check.checkKeyword(e)||"$identity_anonymous_id"===e||"$mp_id"===e||"$identity_login_id"===e||e===sa.para.login_id_key){var a="Key ["+e+"] is invalid";return logger.info(a),!1}if(!t||""===t)return logger.info("Value is empty or null"),!1;if(!_.isString(t))return logger.info("Value must be String"),!1;if(!_.check.ckeckIdLength(t)){a="Value ["+t+"] is beyond the maximum length 255";return logger.info(a),!1}var r=sa.store._state.identities;"$mp_openid"===e&&(e=_.getOpenidNameByAppid()),r[e]=t,sa.store.save(),sa.saEvent.send({type:"track_id_bind",event:"$BindID"})},sa.unbind=function(e,t){if(_.isNumber(t)){if(_.isInteger(t)&&!1===_.isSafeInteger(t))return logger.info("Value must be String"),!1;t=String(t)}if(!_.isString(e))return logger.info("Key must be String"),!1;if(!_.check.checkKeyword(e)||"$identity_anonymous_id"===e||"$mp_id"===e||"$identity_login_id"===e||e===sa.para.login_id_key){var a="Key ["+e+"] is invalid";return logger.info(a),!1}if(!t||""===t)return logger.info("Value is empty or null"),!1;if(!_.isString(t))return logger.info("Value must be String"),!1;if(!_.check.ckeckIdLength(t)){a="Value ["+t+"] is beyond the maximum length 255";return logger.info(a),!1}"$mp_openid"===e&&(e=_.getOpenidNameByAppid()),sa.store._state.identities.hasOwnProperty(e)&&t===sa.store._state.identities[e]&&(delete sa.store._state.identities[e],sa.store.save());var r={};r[e]=t,sa.saEvent.send({type:"track_id_unbind",event:"$UnbindID",unbind_value:r})},sa.setWebViewUrl=function(e,t){if(!_.isString(e)||""===e)return logger.info("error:\u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;if(!/^http(s)?:\/\//.test(e))return logger.info("warning: \u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;var a=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e);if(!a)return!1;var r,s=a[1]||"",i=a[2]||"",n=a[3]||"",o="",c=sa.store.getDistinctId()||"",u=sa.store.getFirstId()||"";_.urlSafeBase64&&_.urlSafeBase64.encode?c=c?_.urlSafeBase64.trim(_.urlSafeBase64.encode(_.urlBase64Encode(c))):"":this._.rot13obfs&&(c=c?_.rot13obfs(c):""),c=encodeURIComponent(c);var p=u?"f"+c:"d"+c;t?(r=n.indexOf("_sasdk"),o=n.indexOf("?")>-1?r>-1?s+i+"#"+n.substring(1,r)+"_sasdk="+p:s+i+"#"+n.substring(1)+"&_sasdk="+p:s+i+"#"+n.substring(1)+"?_sasdk="+p):(r=i.indexOf("_sasdk"),o=/^\?(\w)+/.test(i)?r>-1?s+i.replace(/(_sasdk=)([^&]*)/gi,"_sasdk="+p)+n:s+"?"+i.substring(1)+"&_sasdk="+p+n:s+"?"+i.substring(1)+"_sasdk="+p+n);return o},_.each(["setProfile","setOnceProfile","track","quick","incrementProfile","appendProfile","login","logout","registerApp","register","clearAllRegister","clearAllProps","clearAppRegister","bind","unbind"],function(e){var t=sa[e];sa[e]=function(){sa.initialState.isComplete?t.apply(sa,arguments):sa.initialState.queue.push([e,arguments])}}),_.setQuery=function(e,t){if(e&&_.isObject(e)&&!_.isEmptyObject(e)){var a=[];return _.each(e,function(e,r){"q"===r&&_.isString(e)&&0===e.indexOf("http")||(t?a.push(r+"="+e):a.push(r+"="+_.decodeURIComponent(e)))}),a.join("&")}return""},_.getUtmFromPage=function(){var e={};try{var t=_.getCurrentPage(),a=_.deepCopy(t.options);for(var r in a)a[r]=_.decodeURIComponent(a[r]);e=_.getCustomUtmFromQuery(a,"$","_","$")}catch(e){logger.info(e)}return e},_.sendPageLeave=function(){var e={},t="";try{t=(e=_.getCurrentPage())?e.route:""}catch(e){logger.info(e)}if(page_show_time>=0&&""!==t){var a={},r=_.getPageTitle(t),s=(Date.now()-page_show_time)/1e3;a.$url_query=e.sensors_mp_url_query?e.sensors_mp_url_query:"",a.$url_path=t,a.$title=r,a.event_duration=s,sa.track("$MPPageLeave",a),page_show_time=-1}};{var mp_proxy=function(e,t,a){var r=sa.autoTrackCustom[a];if(e[t]){var s=e[t];e[t]=function(){"onLaunch"===t&&(this[sa.para.name]=sa),!sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&!sa.para.autoTrackIsFirst[a]?(s.apply(this,arguments),r.apply(this,arguments)):(!0===sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&sa.para.autoTrackIsFirst[a])&&(r.apply(this,arguments),s.apply(this,arguments))}}else e[t]=function(){"onLaunch"===t&&(this[sa.para.name]=sa),r.apply(this,arguments)}};function clickTrack(e){var t,a={},r={},s=e.currentTarget||{},i=e.target||{};if(_.isObject(sa.para.framework)&&_.isObject(sa.para.framework.taro)&&!sa.para.framework.taro.createApp&&i.id&&s.id&&i.id!==s.id)return!1;var n=s.dataset||{};if(t=e.type,a.$element_id=s.id,a.$element_type=n.type,a.$element_content=n.content,a.$element_name=n.name,_.isObject(e.event_prop)&&(r=e.event_prop),t&&_.isClick(t)){if(sa.para.preset_events&&sa.para.preset_events.collect_element&&!1===sa.para.preset_events.collect_element(arguments[0]))return!1;a.$url_path=_.getCurrentPath(),_.setPageRefData(a),a=_.extend(a,r),sa.track("$MPClick",a)}}var click_proxy=function(e,t){var a=e[t];e[t]=function(){var e=a.apply(this,arguments),t=arguments[0];return _.isObject(t)&&(sa.para.preset_events.defer_track?setTimeout(function(){clickTrack(t)},0):clickTrack(t)),e}},tabProxy=function(e){var t=e.onTabItemTap;e.onTabItemTap=function(e){t&&t.apply(this,arguments);var a={};e&&(a.$element_content=e.text),a.$element_type="tabBar",a.$url_path=_.getCurrentPath(),_.setPageRefData(a),sa.track("$MPClick",a)}},pageLeaveProxy=function(e){var t=e.onHide;e.onHide=function(){t&&t.apply(this,arguments),_.sendPageLeave()};var a=e.onUnload;e.onUnload=function(){a&&a.apply(this,arguments),_.sendPageLeave()}}}sa.autoTrackCustom={trackCustom:function(e,t,a){var r=sa.para.autoTrack[e],s="";sa.para.autoTrack&&r&&("function"==typeof r?(s=r(),_.isObject(s)&&_.extend(t,s)):_.isObject(r)&&(_.extend(t,r),sa.para.autoTrack[e]=!0),sa.track(a,t))},appLaunch:function(e,t){"object"!=typeof this||this.trackCustom||(this[sa.para.name]=sa);var a={};if(e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path){if(a.$url_path=_.getPath(e.path),a.$title=_.getPageTitle(e.path),e.query&&_.isObject(e.query)){var r=_.setQuery(e.query);r=r?"?"+r:"",a.$url=a.$url_path+r}!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})}_.setShareInfo(e,a);var s=_.setUtm(e,a);is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(s.pre1)||sa.setOnceProfile(s.pre1)):a.$is_first_time=!1,_.setLatestChannel(s.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),_.setPageRefData(a),t?(a=_.extend(a,t),sa.track("$MPLaunch",a)):sa.para.autoTrack&&sa.para.autoTrack.appLaunch&&sa.autoTrackCustom.trackCustom("appLaunch",a,"$MPLaunch")},appShow:function(e,t){var a={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(a.$url_path=_.getPath(e.path),a.$title=_.getPageTitle(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,a);var r=_.setUtm(e,a);_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),_.setPageRefData(a,e.path,a.$url_query),e&&e.path&&(a.$url=e.path+(a.$url_query?"?"+a.$url_query:"")),t?(a=_.extend(a,t),sa.track("$MPShow",a)):sa.para.autoTrack&&sa.para.autoTrack.appShow&&sa.autoTrackCustom.trackCustom("appShow",a,"$MPShow")},appHide:function(e){var t=(new Date).getTime(),a={};a.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(a.event_duration=(t-mpshow_time)/1e3),_.setPageRefData(a),e?(a=_.extend(a,e),sa.track("$MPHide",a)):sa.para.autoTrack&&sa.para.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",a,"$MPHide"),sendStrategy.onAppHide()},pageLoad:function(e){current_scene&&1010===current_scene&&e&&(e.sampshare&&delete e.sampshare,_.delObjectKey(e)),e&&_.isObject(e)&&(this.sensors_mp_url_query=_.setQuery(e),this.sensors_mp_encode_url_query=_.setQuery(e,!0))},pageShow:function(){page_show_time=Date.now();var e={},t=_.getCurrentPath(),a=_.getPageTitle(t);_.setRefPage(),e.$url_path=t,e.$url_query=this.sensors_mp_url_query?this.sensors_mp_url_query:"",e=_.extend(e,_.getUtmFromPage()),_.setPageRefData(e),_.setPageSfSource(e),a&&(e.$title=a),sa.para.onshow?sa.para.onshow(sa,t,this):_.isObject(sa.para.autotrack_exclude_page)&&_.isArray(sa.para.autotrack_exclude_page.pageShow)&&-1!==sa.para.autotrack_exclude_page.pageShow.indexOf(t)||sa.autoTrackCustom.trackCustom("pageShow",e,"$MPViewScreen"),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:t})},pageShare:function(e){var t=e.onShareAppMessage;e.onShareAppMessage=function(){share_method="\u8f6c\u53d1\u6d88\u606f\u5361\u7247";var e=t.apply(this,arguments);if(sa.para.autoTrack&&sa.para.autoTrack.pageShare){var a={$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method};_.setPageRefData(a),sa.autoTrackCustom.trackCustom("pageShare",a,"$MPShare")}return sa.para.allow_amend_share_path&&("object"!=typeof e&&((e={}).path=_.getCurrentUrl(this)),"object"!=typeof e||void 0!==e.path&&""!==e.path||(e.path=_.getCurrentUrl(this)),"object"==typeof e&&"string"==typeof e.path&&(-1===e.path.indexOf("?")?e.path=e.path+"?":"&"!==e.path.slice(-1)&&(e.path=e.path+"&")),e.path=e.path+_.getShareInfo()),e}},pageShareTimeline:function(e){var t=e.onShareTimeline;e.onShareTimeline=function(){share_method="\u670b\u53cb\u5708\u5206\u4eab";var e=t.apply(this,arguments);if(sa.para.autoTrack&&sa.para.autoTrack.pageShare){var a={$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method};_.setPageRefData(a),sa.autoTrackCustom.trackCustom("pageShare",a,"$MPShare")}return sa.para.allow_amend_share_path&&("object"!=typeof e&&(e={}),"object"==typeof e&&void 0===e.query&&(e.query=""),"object"==typeof e&&"string"==typeof e.query&&""!==e.query&&"&"!==e.query.slice(-1)&&(e.query=e.query+"&"),e.query=e.query+_.getShareInfo()),e}},pageAddFavorites:function(){var e={};e.$url_path=_.getCurrentPath(),sa.para.autoTrack&&sa.para.autoTrack.mpFavorite&&sa.autoTrackCustom.trackCustom("mpFavorite",e,"$MPAddFavorites")}},sa.quick=function(){var e=arguments[0],t=arguments[1],a=arguments[2],r=_.isObject(a)?a:{};if("getAnonymousID"===e){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===e||"appShow"===e?t?sa.autoTrackCustom[e](t,r):logger.info("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(r=_.isObject(t)?t:{},sa.autoTrackCustom[e](r))},sa.appLaunch=function(e,t){var a={};e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(a.$url_path=_.getPath(e.path),a.$title=_.getPageTitle(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),_.setShareInfo(e,a);var r=_.setUtm(e,a);is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):a.$is_first_time=!1,_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),a.$url=e.path+(a.$url_query?"?"+a.$url_query:""),_.setPageRefData(t),_.isObject(t)&&(a=_.extend(a,t)),sa.track("$MPLaunch",a)},sa.appShow=function(e,t){var a={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(a.$url_path=_.getPath(e.path),a.$title=_.getPageTitle(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,a);var r=_.setUtm(e,a);_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),e&&e.path&&(a.$url=e.path+(a.$url_query?"?"+a.$url_query:"")),_.setPageRefData(a,e.path,a.$url_query),_.isObject(t)&&(a=_.extend(a,t)),sa.track("$MPShow",a)},sa.appHide=function(e){var t=(new Date).getTime(),a={};a.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(a.event_duration=(t-mpshow_time)/1e3),_.setPageRefData(a),_.isObject(e)&&(a=_.extend(a,e)),sa.track("$MPHide",a),sendStrategy.onAppHide()},sa.pageShow=function(e){var t={},a=_.getCurrentPath(),r=_.getPageTitle(a),s=_.getCurrentPage();_.setRefPage(),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a}),r&&(t.$title=r),t.$url_path=a,t.$url_query=s.sensors_mp_url_query?s.sensors_mp_url_query:"",t=_.extend(t,_.getUtmFromPage()),_.setPageSfSource(t),_.setPageRefData(t),_.isObject(e)&&(t=_.extend(t,e)),sa.track("$MPViewScreen",t)};var oldApp=App;App=function(e){e[sa.para.name]=sa,oldApp.apply(this,arguments)},wx.onAppShow(function(e){if(!deploy_para.launched){var t=wx.getLaunchOptionsSync()||{};sa.autoTrackCustom.appLaunch(t),deploy_para.launched=!0}sa.autoTrackCustom.appShow(e)}),wx.onAppHide(function(){sa.autoTrackCustom.appHide()});var oldPage=Page;Page=function(e){var t=sa.para.autoTrack&&sa.para.autoTrack.mpClick&&_.getMethods(e);if(t)for(var a=0,r=t.length;a0){for(var r=0;r=500&&(sa._.logger.info("\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38"),sa.store.mem.mdata.shift()),(e=kit.processData(e))&&sa.store.mem.add(e),sa.store.mem.getLength()>=sa.para.batch_send.max_length&&this.batchSend()},wxrequest:function(e){if(sa._.isArray(e.data)&&e.data.length>0){var t=kit.batchTrackData(e.data);sa._.wxrequest({url:sa.para.server_url,method:"POST",dataType:"text",data:t,success:function(){e.success(e.len)},fail:function(){e.fail()}})}else e.success(e.len)},batchSend:function(){if(this.dataHasSend){var e,t,a=sa.store.mem.mdata;(t=(e=a.length>=100?a.slice(0,100):a).length)>0&&(this.dataHasSend=!1,this.wxrequest({data:e,len:t,success:this.batchRemove.bind(this),fail:this.sendFail.bind(this)}))}},sendFail:function(){this.dataHasSend=!0,this.failTime++},batchRemove:function(e){sa.store.mem.clear(e),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite(),this.failTime=0},is_first_batch_write:!0,batchWrite:function(){var e=this;this.dataHasChange&&(this.is_first_batch_write&&(this.is_first_batch_write=!1,setTimeout(function(){e.batchSend()},1e3)),this.dataHasChange=!1,this.syncStorage&&sa._.setStorageSync(sa.para.storage_prepare_data_key,sa.store.mem.mdata))},batchInterval:function(){var e=this;!function t(){setTimeout(function(){e.batchWrite(),t()},500)}(),function t(){setTimeout(function(){e.batchSend(),t()},sa.para.batch_send.send_timeout*Math.pow(2,e.failTime))}()}};function getSendUrl(e,t){var a=kit.onceTrackData(t);return-1!==e.indexOf("?")?e+"&"+a:e+"?"+a}function onceSend(e){e._flush_time=Date.now();var t=getSendUrl(sa.para.server_url,e);sa._.wxrequest({url:t,method:"GET"})}var saEvent={send:function(e,t){if(!sa.para.server_url)return sa._.logger.info("error: server_url \u4e0d\u80fd\u4e3a\u7a7a"),!1;if(sa.current_scene&&1154===sa.current_scene&&!sa.para.preset_events.moments_page)return!1;var a=sa.kit.buildData(e);a?(saEvent.debug(a),sa.events.emit("send",a),sa.para.batch_send?sendStrategy.send(a):onceSend(a)):sa._.logger.info("error: \u6570\u636e\u5f02\u5e38 "+a)},debug:function(e){sa._.logger.info(e)}},_={};sa.kit=kit,sa.mergeStorageData=mergeStorageData,sa.saEvent=saEvent,sa.sendStrategy=sendStrategy,sa.IDENTITY_KEY={EMAIL:"$identity_email",MOBILE:"$identity_mobile"},sa.para={name:"sensors",server_url:"",send_timeout:1e3,show_log:!1,login_id_key:"$identity_login_id",allow_amend_share_path:!0,max_string_length:500,datasend_timeout:3e3,source_channel:[],autoTrack:{appLaunch:!0,appShow:!0,appHide:!0,pageShow:!0,pageShare:!0,mpClick:!1,mpFavorite:!0,pageLeave:!1},autotrack_exclude_page:{pageShow:[]},is_persistent_save:{share:!1,utm:!1},preset_properties:{url_path:!0},preset_events:{moments_page:!1,defer_track:!1,share_info_use_string:!1},batch_send:!0,storage_store_key:"sensorsdata2015_wechat",storage_prepare_data_key:"sensors_mp_prepare_data"};var deploy_para={launched:!1},mpHook={data:1,onLoad:1,onShow:1,onReady:1,onPullDownRefresh:1,onShareAppMessage:1,onShareTimeline:1,onReachBottom:1,onPageScroll:1,onResize:1,onTabItemTap:1,onHide:1,onUnload:1},logger="object"==typeof logger?logger:{};logger.info=function(){if(sa.para.show_log&&"object"==typeof console&&console.log)try{if(3===arguments.length)return console.log(arguments[0],arguments[1],arguments[2]);if(2===arguments.length)return console.log(arguments[0],arguments[1]);if(1===arguments.length)return console.log(arguments[0])}catch(e){console.log(arguments[0])}},sa.setPara=function(e){sa.para=_.extend2Lev(sa.para,e);var t=[];if(_.isArray(sa.para.source_channel))for(var a=sa.para.source_channel.length,r=0;rsa.para.max_string_length?(logger.info("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,sa.para.max_string_length)):e},_.searchObjString=function(e){_.isObject(e)&&_.each(e,function(t,a){_.isObject(t)?_.searchObjString(e[a]):_.isString(t)&&(e[a]=_.formatString(t))})},_.parseSuperProperties=function(e){_.isObject(e)&&(_.each(e,function(t,a){if(_.isFunction(t))try{e[a]=t(),_.isFunction(e[a])&&(logger.info("\u60a8\u7684\u5c5e\u6027- "+a+" \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}catch(t){delete e[a],logger.info("\u60a8\u7684\u5c5e\u6027- "+a+" \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}}),_.strip_sa_properties(e))},_.unique=function(e){for(var t,a=[],r={},s=0;s255)||(logger.info("id \u957f\u5ea6\u8d85\u8fc7 255 \u4e2a\u5b57\u7b26\uff01"),!1)}},_.strip_sa_properties=function(e){return _.isObject(e)?(_.each(e,function(t,a){if(_.isArray(t)){var r=[];_.each(t,function(e){_.isString(e)?r.push(e):logger.info("\u60a8\u7684\u6570\u636e-",t,"\u7684\u6570\u7ec4\u91cc\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32,\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}),e[a]=r}_.isString(t)||_.isNumber(t)||_.isDate(t)||_.isBoolean(t)||_.isArray(t)||(logger.info("\u60a8\u7684\u6570\u636e-",t,"-\u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}),e):e},_.strip_empty_properties=function(e){var t={};return _.each(e,function(e,a){null!=e&&(t[a]=e)}),t},_.utf8Encode=function(e){var t,a,r,s,i="";for(t=a=0,r=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,s=0;s127&&n<2048?String.fromCharCode(n>>6|192,63&n|128):String.fromCharCode(n>>12|224,n>>6&63|128,63&n|128),null!==o&&(a>t&&(i+=e.substring(t,a)),i+=o,t=a=s+1)}return a>t&&(i+=e.substring(t,e.length)),i},_.base64Encode=function(e){var t,a,r,s,i,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,c=0,u="",p=[];if(!e)return e;e=_.utf8Encode(e);do{t=(i=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,a=i>>12&63,r=i>>6&63,s=63&i,p[c++]=n.charAt(t)+n.charAt(a)+n.charAt(r)+n.charAt(s)}while(o255||(r=e.charCodeAt(o++))>255||(s=e.charCodeAt(o++))>255)&&logger.info("Failed to execute 'btoa' : The string to be encoded contains characters outside of the Latin1 range."),n+=i.charAt((t=a<<16|r<<8|s)>>18&63)+i.charAt(t>>12&63)+i.charAt(t>>6&63)+i.charAt(63&t);return _?n.slice(0,_-3)+"===".substring(_):n},_.urlBase64Encode=function(e){return _.btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))},_.rot13obfs=function(e,t){t="number"==typeof t?t:13;for(var a=(e=String(e)).split(""),r=0,s=a.length;r(new Date).getTime()},_.getCurrentUrl=function(e){var t=_.getCurrentPath(),a="";return _.isObject(e)&&e.sensors_mp_encode_url_query&&(a=e.sensors_mp_encode_url_query),t?a?t+"?"+a:t:"\u672a\u53d6\u5230"},_.getPath=function(e){return e="string"==typeof e?e.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"},_.getMethods=function(e){var t=[];for(var a in e)"function"!=typeof e[a]||mpHook[a]||t.push(a);return t},_.isClick=function(e){return!!{tap:1,longpress:1,longtap:1}[e]},sa.initialState={queue:[],isComplete:!1,systemIsComplete:!1,storeIsComplete:!1,checkIsComplete:function(){this.systemIsComplete&&this.storeIsComplete&&(this.isComplete=!0,this.queue.length>0&&(_.each(this.queue,function(e){sa[e[0]].apply(sa,slice.call(e[1]))}),this.queue=[]))}},_.getCustomUtmFromQuery=function(e,t,a,r){if(!_.isObject(e))return{};var s={};if(e.sa_utm)for(var i in e)"sa_utm"!==i?_.include(sa.para.source_channel,i)&&(s[a+i]=e[i]):s[r+i]=e[i];else for(var i in e)-1===(" "+source_channel_standard+" ").indexOf(" "+i+" ")?_.include(sa.para.source_channel,i)&&(s[a+i]=e[i]):s[t+i]=e[i];return s},_.getObjFromQuery=function(e){var t=e.split("?"),a=[],r={};return t&&t[1]?(_.each(t[1].split("&"),function(e){(a=e.split("="))[0]&&a[1]&&(r[a[0]]=a[1])}),r):{}},_.setStorageSync=function(e,t){var a=function(){wx.setStorageSync(e,t)};try{a()}catch(e){logger.info("set Storage fail --",e);try{a()}catch(e){logger.info("set Storage fail again --",e)}}},_.getStorageSync=function(e){var t="";try{t=wx.getStorageSync(e)}catch(a){try{t=wx.getStorageSync(e)}catch(e){logger.info("getStorage fail")}}return t},_.getMPScene=function(e){return"number"==typeof e||"string"==typeof e&&""!==e?e="wx-"+String(e):"\u672a\u53d6\u5230\u503c"},_.objToParam=function(e,t){if("[object Object]"!==Object.prototype.toString.call(e))return logger.info("\u8bf7\u4f20\u5165\u6709\u6548\u5bf9\u8c61"),"";var a=[];for(var r in e)if(e.hasOwnProperty(r)){var s=e[r];void 0===s?a.push(r+"="):(s=t?encodeURIComponent(s):s,a.push(r+"="+s))}return a.join("&")},_.delObjectKey=function(e){if("[object Object]"===Object.prototype.toString.call(e))for(var t=0;t=2?(page_route_map.shift(),page_route_map.push(e)):page_route_map.push(e)}}catch(e){logger.info(e)}},_.getRefPage=function(){var e={route:"\u76f4\u63a5\u6253\u5f00",title:""};return page_route_map.length>1&&(e.title=page_route_map[0].title,e.route=page_route_map[0].route),e},_.getCurrentPageInfo=function(){var e=_.getCurrentPage(),t={title:"",url:"",path:"\u672a\u53d6\u5230"};if(e&&e.route){var a=e.sensors_mp_url_query?"?"+e.sensors_mp_url_query:"";t.title=_.getPageTitle(e.route),t.url=e.route+a,t.path=e.route}return t},_.setPageRefData=function(e,t,a){var r=_.getRefPage();_.isObject(e)&&(t?page_route_map.length>0&&t?(a=a?"?"+a:"",e.$referrer=_.getPath(t)+a,e.$referrer_title=_.getPageTitle(t)):(e.$referrer="\u76f4\u63a5\u6253\u5f00",e.$referrer_title=""):(e.$referrer=r.route,e.$referrer_title=r.title))},_.getPageTitle=function(e){if("\u672a\u53d6\u5230"===e||!e)return"";var t="";try{if(__wxConfig){var a=__wxConfig,r=__wxConfig.page||{},s=r[e]||r[e+".html"],i={},n={};if(a.global&&a.global.window&&a.global.window.navigationBarTitleText&&(i.titleVal=a.global.window.navigationBarTitleText),s&&s.window&&s.window.navigationBarTitleText&&(n.titleVal=s.window.navigationBarTitleText),!n.titleVal&&__wxAppCode__){var o=__wxAppCode__[e+".json"];o&&o.navigationBarTitleText&&(n.titleVal=o.navigationBarTitleText)}if(_.each(globalTitle,function(a,r){if(r===e)return t=a}),0===t.length){var c=_.extend(i,n);t=c.titleVal||""}}}catch(e){logger.info(e)}return t},_.wxrequest=function(e){if(_.compareSDKVersion(wxSDKVersion,"2.10.0")>=0)e.timeout=sa.para.datasend_timeout,wx.request(e);else{var t=wx.request(e);setTimeout(function(){_.isObject(t)&&_.isFunction(t.abort)&&t.abort()},sa.para.datasend_timeout)}},_.getAppInfoSync=function(){if(wx.getAccountInfoSync){var e=wx.getAccountInfoSync(),t=e&&e.miniProgram?e.miniProgram:{};return{appId:t.appId,appEnv:t.envVersion,appVersion:t.version}}return{}},_.getAppId=function(){var e=_.getAppInfoSync();return e&&e.appId?e.appId:""},_.validId=function(e){return"string"!=typeof e&&"number"!=typeof e||""===e?(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1):"number"!=typeof e||(e=String(e),/^\d+$/.test(e))?!!_.check.ckeckIdLength(e)&&e:(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1)},_.compareSDKVersion=function(e,t){e=e.split("."),t=t.split(".");for(var a=Math.max(e.length,t.length);e.lengthi)return 1;if(s-1?t.system.split(" ")[1]:t.system,wxSDKVersion=t.SDKVersion,e.$mp_client_app_version=t.version,e.$mp_client_basic_library_version=wxSDKVersion},complete:function(){var t=(new Date).getTimezoneOffset(),a=_.getAppInfoSync();_.isNumber(t)&&(e.$timezone_offset=t),a.appId&&(e.$app_id=a.appId),a.appVersion&&(e.$app_version=a.appVersion),sa.initialState.systemIsComplete=!0,sa.initialState.checkIsComplete()}})}wx.getNetworkType({success:function(t){e.$network_type=_.setUpperCase(t.networkType)},complete:t})}},sa._=_,_.eventEmitter=function(){this.sub=[]},_.eventEmitter.prototype={add:function(e){this.sub.push(e)},emit:function(e,t){this.sub.forEach(function(a){a.on(e,t)})}},_.eventSub=function(e){sa.events.add(this),this._events=[],this.handle=e,this.ready=!1},_.eventSub.prototype={on:function(e,t){if(this.ready){if(_.isFunction(this.handle))try{this.handle(e,t)}catch(e){logger.info(e)}}else this._events.push({event:e,data:t})},isReady:function(){var e=this;e.ready=!0,e._events.forEach(function(t){if(_.isFunction(e.handle))try{e.handle(t.event,t.data)}catch(e){logger.info(e)}})}},sa.eventSub=_.eventSub,sa.events=new _.eventEmitter,sa.usePlugin=function(e,t){"function"==typeof e.init&&e.init(sa,t)},sa.store={storageInfo:null,getUUID:function(){return Date.now()+"-"+Math.floor(1e7*getRandom())+"-"+getRandom().toString(16).replace(".","")+"-"+String(31242*getRandom()).replace(".","").slice(0,8)},getStorage:function(){return this.storageInfo?this.storageInfo:(this.storageInfo=sa._.getStorageSync(sa.para.storage_store_key)||"",this.storageInfo)},_state:{},mem:{mdata:[],getLength:function(){return this.mdata.length},add:function(e){this.mdata.push(e)},clear:function(e){this.mdata.splice(0,e)}},toState:function(e){var t=null;_.isJSONString(e)?(t=JSON.parse(e)).distinct_id?this._state=t:this.set("distinct_id",this.getUUID()):_.isObject(e)&&(t=e).distinct_id?this._state=t:this.set("distinct_id",this.getUUID());var a=this._state._first_id||this._state.first_id,r=this._state._distinct_id||this._state.distinct_id,s=this._state.openid,i=(this._state.history_login_id?this._state.history_login_id:{}).name;if(this._state.identities&&_.isString(this._state.identities)){var n=JSON.parse(_.rot13defs(this._state.identities));this._state.identities=n}var o,c,u=_.getOpenidNameByAppid();if(this._state.identities&&_.isObject(this._state.identities)&&!_.isEmptyObject(this._state.identities)){var p=(o=_.getAppId(),c="$mp_openid",o&&(c="$mp_"+o+"_openid"),c);this._state.identities.hasOwnProperty("$mp_id")&&(this._state.identities.$identity_mp_id=this._state.identities.$mp_id,delete this._state.identities.$mp_id),this._state.identities.hasOwnProperty("$mp_unionid")&&(this._state.identities.$identity_mp_unionid=this._state.identities.$mp_unionid,delete this._state.identities.$mp_unionid),this._state.identities.hasOwnProperty(p)&&(this._state.identities[u]=this._state.identities[p],delete this._state.identities[p]),this._state.identities.hasOwnProperty("$identity_anonymous_id")&&(this._state.identities.$identity_anonymous_id=a||r)}else this._state.identities={},this._state.identities.$identity_mp_id=this.getUUID(),this._state.identities.$identity_anonymous_id=a||r;if(s&&(this._state.identities[u]=s),a)if(i&&this._state.identities.hasOwnProperty(i)){if(this._state.identities[i]!==r){for(var d in this._state.identities[i]=r,this._state.identities)this._state.identities.hasOwnProperty(d)&&"$identity_mp_id"!==d&&d!==i&&delete this._state.identities[d];this._state.history_login_id.value=r}}else{for(var d in this._state.identities[sa.para.login_id_key]=r,this._state.identities)this._state.identities.hasOwnProperty(d)&&"$identity_mp_id"!==d&&d!==sa.para.login_id_key&&delete this._state.identities[d];this._state.history_login_id={name:sa.para.login_id_key,value:r}}else{if(this._state.identities.hasOwnProperty("$identity_login_id")||this._state.identities.hasOwnProperty(i))for(var d in this._state.identities)this._state.identities.hasOwnProperty(d)&&"$identity_mp_id"!==d&&"$identity_anonymous_id"!==d&&delete this._state.identities[d];this._state.history_login_id={name:"",value:""}}this.save()},getFirstId:function(){return this._state._first_id||this._state.first_id},getDistinctId:function(){return this._state._distinct_id||this._state.distinct_id},getUnionId:function(){var e={},t=this._state._first_id||this._state.first_id,a=this._state._distinct_id||this._state.distinct_id;return t&&a?(e.login_id=a,e.anonymous_id=t):e.anonymous_id=a,e},getProps:function(){return this._state.props||{}},setProps:function(e,t){var a=this._state.props||{};t?this.set("props",e):(_.extend(a,e),this.set("props",a))},set:function(e,t){var a={};for(var r in"string"==typeof e?a[e]=t:"object"==typeof e&&(a=e),this._state=this._state||{},a)this._state[r]=a[r],"first_id"===r?delete this._state._first_id:"distinct_id"===r&&(delete this._state._distinct_id,sa.events.emit("changeDistinctId"));this.save()},identitiesSet:function(e,t){var a={};switch(e){case"login":a.$identity_mp_id=sa.store._state.identities.$identity_mp_id,a[sa.para.login_id_key]=t;break;case"logout":a.$identity_mp_id=sa.store._state.identities.$identity_mp_id;break;case"identify":(a=_.deepCopy(sa.store._state.identities)).$identity_anonymous_id=t}sa.store.set("identities",a)},change:function(e,t){this._state["_"+e]=t},encryptStorage:function(){var e=this.getStorage(),t="data:enc;";_.isObject(e)?e=t+_.rot13obfs(JSON.stringify(e)):_.isString(e)&&-1===e.indexOf(t)&&(e=t+_.rot13obfs(e)),sa._.setStorageSync(sa.para.storage_store_key,e)},save:function(){var e=_.deepCopy(this._state),t=_.rot13obfs(JSON.stringify(e.identities));if(e.identities=t,delete e._first_id,delete e._distinct_id,sa.para.encrypt_storage){e="data:enc;"+_.rot13obfs(JSON.stringify(e))}sa._.setStorageSync(sa.para.storage_store_key,e)},init:function(){var e=this.getStorage();if(e)_.isString(e)&&-1!==e.indexOf("data:enc;")&&(e=e.substring("data:enc;".length),e=JSON.parse(_.rot13defs(e))),this.toState(e);else{is_first_launch=!0;var t=new Date,a=t.getTime();t.setHours(23),t.setMinutes(59),t.setSeconds(60),sa.setOnceProfile({$first_visit_time:new Date}),this.set({distinct_id:this.getUUID(),first_visit_time:a,first_visit_day_time:t.getTime(),identities:{$identity_mp_id:this.getUUID()},history_login_id:{name:"",value:""}})}}},sa.setProfile=function(e,t){sa.saEvent.send({type:"profile_set",properties:e},t)},sa.setOnceProfile=function(e,t){sa.saEvent.send({type:"profile_set_once",properties:e},t)},sa.appendProfile=function(e,t){if(!_.isObject(e))return!1;_.each(e,function(t,a){_.isString(t)?e[a]=[t]:(delete e[a],logger.info("appendProfile\u5c5e\u6027\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32\u6216\u8005\u6570\u7ec4"))}),sa.saEvent.send({type:"profile_append",properties:e},t)},sa.incrementProfile=function(e,t){if(!_.isObject(e))return!1;var a=e;_.isString(e)&&((e={})[a]=1),sa.saEvent.send({type:"profile_increment",properties:e},t)},sa.track=function(e,t,a){this.saEvent.send({type:"track",event:e,properties:t},a)},sa.identify=function(e,t){if(e=_.validId(e)){var a=sa.store.getFirstId();!0===t?a?sa.store.set("first_id",e):sa.store.set("distinct_id",e):a?sa.store.change("first_id",e):sa.store.change("distinct_id",e),sa.store.identitiesSet("identify",e)}},sa.trackSignup=function(e,t,a,r){var s=sa.store.getFirstId()||sa.store.getDistinctId();sa.store.set("distinct_id",e),sa.saEvent.send({original_id:s,distinct_id:e,type:"track_signup",event:t,properties:a},r)},sa.registerApp=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&(_.info.currentProps=_.extend(_.info.currentProps,e))},sa.register=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&sa.store.setProps(e)},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.clearAllProps=function(e){var t=sa.store.getProps(),a={};_.isArray(e)&&(_.each(t,function(t,r){_.include(e,r)||(a[r]=t)}),sa.store.setProps(a,!0))},sa.clearAppRegister=function(e){_.isArray(e)&&_.each(_.info.currentProps,function(t,a){_.include(e,a)&&delete _.info.currentProps[a]})},_.setLatestChannel=function(e){_.isEmptyObject(e)||(function(e,t){var a=!1;for(var r in t)e[t[r]]&&(a=!0);return a}(e,latest_source_channel)&&(sa.clearAppRegister(latest_source_channel),sa.clearAllProps(latest_source_channel)),sa.para.is_persistent_save.utm?sa.register(e):sa.registerApp(e))},_.setLatestShare=function(e){(e.$latest_share_depth||e.$latest_share_distinct_id||e.$latest_share_url_path||e.$latest_share_method)&&(sa.clearAppRegister(latest_share_info),sa.clearAllProps(latest_share_info),sa.para.is_persistent_save.share?sa.register(e):sa.registerApp(e))},sa.login=function(e){if(e=_.validId(e)){var t=sa.store.getFirstId(),a=sa.store.getDistinctId();if(sa.store._state.identities.hasOwnProperty(sa.para.login_id_key)&&e===t)return!1;var r=!(sa.para.login_id_key===sa.store._state.history_login_id.name&&sa.store._state.history_login_id.value===e);r&&(sa.store._state.identities[sa.para.login_id_key]=e),r&&(t?sa.trackSignup(e,"$SignUp"):(sa.store.set("first_id",a),sa.trackSignup(e,"$SignUp"))),r&&(sa.store.identitiesSet("login",e),sa.store.set("history_login_id",{name:sa.para.login_id_key,value:e}))}},sa.getAnonymousID=function(){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")},sa.logout=function(e){var t=sa.store.getFirstId();t?(sa.store.set("first_id",""),!0===e?sa.store.set("distinct_id",sa.store.getUUID()):sa.store.set("distinct_id",t)):logger.info("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25"),sa.store.identitiesSet("logout"),sa.store.set("history_login_id",{name:"",value:""})},sa.getLocation=function(){wx.getSetting({success:function(e){if(!e.authSetting["scope.userLocation"])return!1;wx.getLocation({type:sa.para.preset_properties.location.type,success:function(e){sa.registerApp({$latitude:e.latitude*Math.pow(10,6),$longitude:e.longitude*Math.pow(10,6),$geo_coordinate_system:_.setUpperCase(sa.para.preset_properties.location.type)})},fail:function(e){logger.info("\u83b7\u53d6\u4f4d\u7f6e\u5931\u8d25",e)}})}})},sa.openid={getRequest:function(e){wx.login({success:function(t){t.code&&sa.para.appid&&sa.para.openid_url?_.wxrequest({url:sa.para.openid_url+"&code="+t.code+"&appid="+sa.para.appid,method:"GET",complete:function(t){_.isObject(t)&&_.isObject(t.data)&&t.data.openid?e(t.data.openid):e()}}):e()}})},getWXStorage:function(){var e=sa.store.getStorage();if(e&&_.isObject(e))return e.openid},getOpenid:function(e){if(!sa.para.appid)return e(),!1;var t=this.getWXStorage();t?e(t):this.getRequest(e)}},sa.initial=function(){this._.info.getSystem(),this.store.init()},sa.init=function(e){if(!0===this.hasInit)return!1;this.hasInit=!0,sa.setPara(e),sa.para.encrypt_storage&&this.store.encryptStorage(),sa.para.batch_send&&sendStrategy.init(),sa.initialState.storeIsComplete=!0,sa.initialState.checkIsComplete()},sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib){var e={};_.each(_.info.currentProps,function(t,a){0===a.indexOf("$")&&(e[a]=t)});var t={$url_path:_.getCurrentPath(),$is_first_day:_.getIsFirstDay(),$is_first_time:is_first_launch},a=_.extend(e,t,_.info.properties,sa.store.getProps());return delete a.$lib,a}return{}},sa.setOpenid=function(e,t){if(!(e=_.validId(e)))return!1;t&&console.log("%c \u5f53\u524d\u7248\u672c setOpenid \u63a5\u53e3 \u5df2\u4e0d\u652f\u6301\u4f20\u5165\u7b2c\u4e8c\u4e2a\u53c2\u6570","color:#F39C12;font-size: 14px;"),sa.store.set("openid",e),sa.identify(e,!0),sa.bind("$identity_mp_openid",e)},sa.unsetOpenid=function(e){var t=_.validId(e);if(!t)return!1;sa.store._state.openid===t&&sa.store.set("openid",""),sa.unbind("$identity_mp_openid",t)},sa.setUnionid=function(e){var t=_.validId(e);t&&sa.bind("$identity_mp_unionid",t)},sa.unsetUnionid=function(e){var t=_.validId(e);if(t){if(sa.store._state.identities.hasOwnProperty("$identity_mp_unionid")&&t===sa.store._state.identities.$identity_mp_unionid){var a=_.getOpenidNameByAppid();sa.store._state.identities.hasOwnProperty(a)&&(delete sa.store._state.identities[a],delete sa.store._state.openid,sa.store.save())}sa.unbind("$identity_mp_unionid",t)}},sa.initWithOpenid=function(e,t){(e=e||{}).appid&&(sa.para.appid=e.appid),sa.openid.getOpenid(function(a){a&&sa.setOpenid(a,e.isCoverLogin),t&&_.isFunction(t)&&t(a),sa.init(e)})},sa.bind=function(e,t){if(_.isNumber(t)){if(_.isInteger(t)&&!1===_.isSafeInteger(t))return logger.info("Value must be String"),!1;t=String(t)}if(!_.isString(e))return logger.info("Key must be String"),!1;if(!_.check.checkKeyword(e)||"$identity_anonymous_id"===e||"$mp_id"===e||"$identity_mp_id"===e||"$identity_login_id"===e||e===sa.para.login_id_key){var a="Key ["+e+"] is invalid";return logger.info(a),!1}if(!t||""===t)return logger.info("Value is empty or null"),!1;if(!_.isString(t))return logger.info("Value must be String"),!1;if(!_.check.ckeckIdLength(t)){a="Value ["+t+"] is beyond the maximum length 255";return logger.info(a),!1}var r=sa.store._state.identities;"$identity_mp_openid"===e&&(e=_.getOpenidNameByAppid()),r[e]=t,sa.store.save(),sa.saEvent.send({type:"track_id_bind",event:"$BindID"})},sa.unbind=function(e,t){if(_.isNumber(t)){if(_.isInteger(t)&&!1===_.isSafeInteger(t))return logger.info("Value must be String"),!1;t=String(t)}if(!_.isString(e))return logger.info("Key must be String"),!1;if(!_.check.checkKeyword(e)||"$identity_anonymous_id"===e||"$mp_id"===e||"$identity_mp_id"===e||"$identity_login_id"===e||e===sa.para.login_id_key){var a="Key ["+e+"] is invalid";return logger.info(a),!1}if(!t||""===t)return logger.info("Value is empty or null"),!1;if(!_.isString(t))return logger.info("Value must be String"),!1;if(!_.check.ckeckIdLength(t)){a="Value ["+t+"] is beyond the maximum length 255";return logger.info(a),!1}"$identity_mp_openid"===e&&(e=_.getOpenidNameByAppid()),sa.store._state.identities.hasOwnProperty(e)&&t===sa.store._state.identities[e]&&(delete sa.store._state.identities[e],sa.store.save());var r={};r[e]=t,sa.saEvent.send({type:"track_id_unbind",event:"$UnbindID",unbind_value:r})},sa.setWebViewUrl=function(e,t){if(!_.isString(e)||""===e)return logger.info("error:\u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;if(!/^http(s)?:\/\//.test(e))return logger.info("warning: \u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;var a=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e);if(!a)return!1;var r,s=a[1]||"",i=a[2]||"",n=a[3]||"",o="",c=sa.store.getDistinctId()||"",u=sa.store.getFirstId()||"";_.urlSafeBase64&&_.urlSafeBase64.encode?c=c?_.urlSafeBase64.trim(_.urlSafeBase64.encode(_.urlBase64Encode(c))):"":this._.rot13obfs&&(c=c?_.rot13obfs(c):""),c=encodeURIComponent(c);var p=u?"f"+c:"d"+c;t?(r=n.indexOf("_sasdk"),o=n.indexOf("?")>-1?r>-1?s+i+"#"+n.substring(1,r)+"_sasdk="+p:s+i+"#"+n.substring(1)+"&_sasdk="+p:s+i+"#"+n.substring(1)+"?_sasdk="+p):(r=i.indexOf("_sasdk"),o=/^\?(\w)+/.test(i)?r>-1?s+i.replace(/(_sasdk=)([^&]*)/gi,"_sasdk="+p)+n:s+"?"+i.substring(1)+"&_sasdk="+p+n:s+"?"+i.substring(1)+"_sasdk="+p+n);return o},_.each(["setProfile","setOnceProfile","track","quick","incrementProfile","appendProfile","login","logout","registerApp","register","clearAllRegister","clearAllProps","clearAppRegister","bind","unbind","unsetOpenid","setUnionid","unsetUnionid"],function(e){var t=sa[e];sa[e]=function(){sa.initialState.isComplete?t.apply(sa,arguments):sa.initialState.queue.push([e,arguments])}}),_.setQuery=function(e,t){if(e&&_.isObject(e)&&!_.isEmptyObject(e)){var a=[];return _.each(e,function(e,r){"q"===r&&_.isString(e)&&0===e.indexOf("http")||(t?a.push(r+"="+e):a.push(r+"="+_.decodeURIComponent(e)))}),a.join("&")}return""},_.getUtmFromPage=function(){var e={};try{var t=_.getCurrentPage(),a=_.deepCopy(t.options);for(var r in a)a[r]=_.decodeURIComponent(a[r]);e=_.getCustomUtmFromQuery(a,"$","_","$")}catch(e){logger.info(e)}return e},_.sendPageLeave=function(){var e={},t="";try{t=(e=_.getCurrentPage())?e.route:""}catch(e){logger.info(e)}if(page_show_time>=0&&""!==t){var a={},r=_.getPageTitle(t),s=(Date.now()-page_show_time)/1e3;a.$url_query=e.sensors_mp_url_query?e.sensors_mp_url_query:"",a.$url_path=t,a.$title=r,a.event_duration=s,sa.track("$MPPageLeave",a),page_show_time=-1}};{var mp_proxy=function(e,t,a){var r=sa.autoTrackCustom[a];if(e[t]){var s=e[t];e[t]=function(){"onLaunch"===t&&(this[sa.para.name]=sa),!sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&!sa.para.autoTrackIsFirst[a]?(s.apply(this,arguments),r.apply(this,arguments)):(!0===sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&sa.para.autoTrackIsFirst[a])&&(r.apply(this,arguments),s.apply(this,arguments))}}else e[t]=function(){"onLaunch"===t&&(this[sa.para.name]=sa),r.apply(this,arguments)}};function clickTrack(e){var t,a={},r={},s=e.currentTarget||{},i=e.target||{};if(_.isObject(sa.para.framework)&&_.isObject(sa.para.framework.taro)&&!sa.para.framework.taro.createApp&&i.id&&s.id&&i.id!==s.id)return!1;var n=s.dataset||{};if(t=e.type,a.$element_id=s.id,a.$element_type=n.type,a.$element_content=n.content,a.$element_name=n.name,_.isObject(e.event_prop)&&(r=e.event_prop),t&&_.isClick(t)){if(sa.para.preset_events&&sa.para.preset_events.collect_element&&!1===sa.para.preset_events.collect_element(arguments[0]))return!1;a.$url_path=_.getCurrentPath(),_.setPageRefData(a),a=_.extend(a,r),sa.track("$MPClick",a)}}var click_proxy=function(e,t){var a=e[t];e[t]=function(){var e=a.apply(this,arguments),t=arguments[0];return _.isObject(t)&&(sa.para.preset_events.defer_track?setTimeout(function(){clickTrack(t)},0):clickTrack(t)),e}},tabProxy=function(e){var t=e.onTabItemTap;e.onTabItemTap=function(e){t&&t.apply(this,arguments);var a={};e&&(a.$element_content=e.text),a.$element_type="tabBar",a.$url_path=_.getCurrentPath(),_.setPageRefData(a),sa.track("$MPClick",a)}},pageLeaveProxy=function(e){var t=e.onHide;e.onHide=function(){t&&t.apply(this,arguments),_.sendPageLeave()};var a=e.onUnload;e.onUnload=function(){a&&a.apply(this,arguments),_.sendPageLeave()}}}sa.autoTrackCustom={trackCustom:function(e,t,a){var r=sa.para.autoTrack[e],s="";sa.para.autoTrack&&r&&("function"==typeof r?(s=r(),_.isObject(s)&&_.extend(t,s)):_.isObject(r)&&(_.extend(t,r),sa.para.autoTrack[e]=!0),sa.track(a,t))},appLaunch:function(e,t){"object"!=typeof this||this.trackCustom||(this[sa.para.name]=sa);var a={};if(e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(a.$url_path=_.getPath(e.path),a.$title=_.getPageTitle(e.path),e.query&&_.isObject(e.query))){var r=_.setQuery(e.query);r=r?"?"+r:"",a.$url=a.$url_path+r}_.setShareInfo(e,a);var s=_.setUtm(e,a);is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(s.pre1)||sa.setOnceProfile(s.pre1)):a.$is_first_time=!1,_.setLatestChannel(s.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),_.setPageRefData(a),t?(a=_.extend(a,t),sa.track("$MPLaunch",a)):sa.para.autoTrack&&sa.para.autoTrack.appLaunch&&sa.autoTrackCustom.trackCustom("appLaunch",a,"$MPLaunch")},appShow:function(e,t){var a={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(a.$url_path=_.getPath(e.path),a.$title=_.getPageTitle(e.path)),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,a);var r=_.setUtm(e,a);_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),_.setPageRefData(a,e.path,a.$url_query),e&&e.path&&(a.$url=e.path+(a.$url_query?"?"+a.$url_query:"")),t?(a=_.extend(a,t),sa.track("$MPShow",a)):sa.para.autoTrack&&sa.para.autoTrack.appShow&&sa.autoTrackCustom.trackCustom("appShow",a,"$MPShow")},appHide:function(e){var t=(new Date).getTime(),a={};a.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(a.event_duration=(t-mpshow_time)/1e3),_.setPageRefData(a),e?(a=_.extend(a,e),sa.track("$MPHide",a)):sa.para.autoTrack&&sa.para.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",a,"$MPHide"),sendStrategy.onAppHide()},pageLoad:function(e){current_scene&&1010===current_scene&&e&&(e.sampshare&&delete e.sampshare,_.delObjectKey(e)),e&&_.isObject(e)&&(this.sensors_mp_url_query=_.setQuery(e),this.sensors_mp_encode_url_query=_.setQuery(e,!0))},pageShow:function(){page_show_time=Date.now();var e={},t=_.getCurrentPath(),a=_.getPageTitle(t);_.setRefPage(),e.$url_path=t,e.$url_query=this.sensors_mp_url_query?this.sensors_mp_url_query:"",e=_.extend(e,_.getUtmFromPage()),_.setPageRefData(e),_.setPageSfSource(e),a&&(e.$title=a),sa.para.onshow?sa.para.onshow(sa,t,this):_.isObject(sa.para.autotrack_exclude_page)&&_.isArray(sa.para.autotrack_exclude_page.pageShow)&&-1!==sa.para.autotrack_exclude_page.pageShow.indexOf(t)||sa.autoTrackCustom.trackCustom("pageShow",e,"$MPViewScreen")},pageShare:function(e){var t=e.onShareAppMessage;e.onShareAppMessage=function(){share_method="\u8f6c\u53d1\u6d88\u606f\u5361\u7247";var e=t.apply(this,arguments);if(sa.para.autoTrack&&sa.para.autoTrack.pageShare){var a={$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method};_.setPageRefData(a),sa.autoTrackCustom.trackCustom("pageShare",a,"$MPShare")}return sa.para.allow_amend_share_path&&("object"!=typeof e&&((e={}).path=_.getCurrentUrl(this)),"object"!=typeof e||void 0!==e.path&&""!==e.path||(e.path=_.getCurrentUrl(this)),"object"==typeof e&&"string"==typeof e.path&&(-1===e.path.indexOf("?")?e.path=e.path+"?":"&"!==e.path.slice(-1)&&(e.path=e.path+"&")),e.path=e.path+_.getShareInfo()),e}},pageShareTimeline:function(e){var t=e.onShareTimeline;e.onShareTimeline=function(){share_method="\u670b\u53cb\u5708\u5206\u4eab";var e=t.apply(this,arguments);if(sa.para.autoTrack&&sa.para.autoTrack.pageShare){var a={$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method};_.setPageRefData(a),sa.autoTrackCustom.trackCustom("pageShare",a,"$MPShare")}return sa.para.allow_amend_share_path&&("object"!=typeof e&&(e={}),"object"==typeof e&&void 0===e.query&&(e.query=""),"object"==typeof e&&"string"==typeof e.query&&""!==e.query&&"&"!==e.query.slice(-1)&&(e.query=e.query+"&"),e.query=e.query+_.getShareInfo()),e}},pageAddFavorites:function(){var e={};e.$url_path=_.getCurrentPath(),sa.para.autoTrack&&sa.para.autoTrack.mpFavorite&&sa.autoTrackCustom.trackCustom("mpFavorite",e,"$MPAddFavorites")}},sa.quick=function(){var e=arguments[0],t=arguments[1],a=arguments[2],r=_.isObject(a)?a:{};if("getAnonymousID"===e){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===e||"appShow"===e?t?sa.autoTrackCustom[e](t,r):logger.info("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(r=_.isObject(t)?t:{},sa.autoTrackCustom[e](r))},sa.appLaunch=function(e,t){var a={};e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(a.$url_path=_.getPath(e.path),a.$title=_.getPageTitle(e.path)),_.setShareInfo(e,a);var r=_.setUtm(e,a);is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):a.$is_first_time=!1,_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),a.$url=e.path+(a.$url_query?"?"+a.$url_query:""),_.setPageRefData(t),_.isObject(t)&&(a=_.extend(a,t)),sa.track("$MPLaunch",a)},sa.appShow=function(e,t){var a={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(a.$url_path=_.getPath(e.path),a.$title=_.getPageTitle(e.path)),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,a);var r=_.setUtm(e,a);_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),e&&e.path&&(a.$url=e.path+(a.$url_query?"?"+a.$url_query:"")),_.setPageRefData(a,e.path,a.$url_query),_.isObject(t)&&(a=_.extend(a,t)),sa.track("$MPShow",a)},sa.appHide=function(e){var t=(new Date).getTime(),a={};a.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(a.event_duration=(t-mpshow_time)/1e3),_.setPageRefData(a),_.isObject(e)&&(a=_.extend(a,e)),sa.track("$MPHide",a),sendStrategy.onAppHide()},sa.pageShow=function(e){var t={},a=_.getCurrentPath(),r=_.getPageTitle(a),s=_.getCurrentPage();_.setRefPage(),r&&(t.$title=r),t.$url_path=a,t.$url_query=s.sensors_mp_url_query?s.sensors_mp_url_query:"",t=_.extend(t,_.getUtmFromPage()),_.setPageSfSource(t),_.setPageRefData(t),_.isObject(e)&&(t=_.extend(t,e)),sa.track("$MPViewScreen",t)};var oldApp=App;App=function(e){e[sa.para.name]=sa,oldApp.apply(this,arguments)},wx.onAppShow(function(e){if(!deploy_para.launched){var t=wx.getLaunchOptionsSync()||{};sa.autoTrackCustom.appLaunch(t),deploy_para.launched=!0}sa.autoTrackCustom.appShow(e)}),wx.onAppHide(function(){sa.autoTrackCustom.appHide()});var oldPage=Page;Page=function(e){e||(e={});var t=sa.para.autoTrack&&sa.para.autoTrack.mpClick&&_.getMethods(e);if(t)for(var a=0,r=t.length;a0){for(var r=0;r=500&&(sa._.logger.info("\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38"),sa.store.mem.mdata.shift());var t=Date.now();e._flush_time=t,(e=kit.processData(e))&&sa.store.mem.add(e),sa.store.mem.getLength()>=sa.para.batch_send.max_length&&this.batchSend()},wxrequest:function(e){if(sa._.isArray(e.data)&&e.data.length>0){var t=kit.batchTrackData(e.data);sa._.wxrequest({url:sa.para.server_url,method:"POST",dataType:"text",data:t,success:function(){e.success(e.len)},fail:function(){e.fail()}})}else e.success(e.len)},batchSend:function(){if(this.dataHasSend){var e,t,a=sa.store.mem.mdata;(t=(e=a.length>=100?a.slice(0,100):a).length)>0&&(this.dataHasSend=!1,this.wxrequest({data:e,len:t,success:this.batchRemove.bind(this),fail:this.sendFail.bind(this)}))}},sendFail:function(){this.dataHasSend=!0,this.failTime++},batchRemove:function(e){sa.store.mem.clear(e),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite(),this.failTime=0},is_first_batch_write:!0,batchWrite:function(){var e=this;this.dataHasChange&&(this.is_first_batch_write&&(this.is_first_batch_write=!1,setTimeout(function(){e.batchSend()},1e3)),this.dataHasChange=!1,this.syncStorage&&sa._.setStorageSync(sa.para.storage_prepare_data_key,sa.store.mem.mdata))},batchInterval:function(){var e=this;!function t(){setTimeout(function(){e.batchWrite(),t()},500)}(),function t(){setTimeout(function(){e.batchSend(),t()},sa.para.batch_send.send_timeout*Math.pow(2,e.failTime))}()}};function getSendUrl(e,t){var a=kit.onceTrackData(t);return-1!==e.indexOf("?")?e+"&"+a:e+"?"+a}function onceSend(e){e._flush_time=Date.now();var t=getSendUrl(sa.para.server_url,e);sa._.wxrequest({url:t,method:"GET"})}var saEvent={send:function(e,t){if(!sa.para.server_url)return sa._.logger.info("error: server_url \u4e0d\u80fd\u4e3a\u7a7a"),!1;if(sa.current_scene&&1154===sa.current_scene&&!sa.para.preset_events.moments_page)return!1;var a=sa.kit.buildData(e);a?(saEvent.debug(a),sa.events.emit("send",a),sa.para.batch_send?sendStrategy.send(a):onceSend(a)):sa._.logger.info("error: \u6570\u636e\u5f02\u5e38 "+a)},debug:function(e){sa._.logger.info(e)}},_={};sa.kit=kit,sa.mergeStorageData=mergeStorageData,sa.saEvent=saEvent,sa.sendStrategy=sendStrategy,sa.IDENTITY_KEY={EMAIL:"$identity_email",MOBILE:"$identity_mobile"},sa.para={name:"sensors",server_url:"",send_timeout:1e3,show_log:!1,login_id_key:"$identity_login_id",allow_amend_share_path:!0,max_string_length:500,datasend_timeout:3e3,source_channel:[],autoTrack:{appLaunch:!0,appShow:!0,appHide:!0,pageShow:!0,pageShare:!0,mpClick:!1,mpFavorite:!0,pageLeave:!1},autotrack_exclude_page:{pageShow:[]},is_persistent_save:{share:!1,utm:!1},preset_properties:{url_path:!0},preset_events:{moments_page:!1,defer_track:!1,share_info_use_string:!1},batch_send:!0,storage_store_key:"sensorsdata2015_wechat",storage_prepare_data_key:"sensors_mp_prepare_data"};var deploy_para={launched:!1},mpHook={data:1,onLoad:1,onShow:1,onReady:1,onPullDownRefresh:1,onShareAppMessage:1,onShareTimeline:1,onReachBottom:1,onPageScroll:1,onResize:1,onTabItemTap:1,onHide:1,onUnload:1},logger="object"==typeof logger?logger:{};logger.info=function(){if(sa.para.show_log&&"object"==typeof console&&console.log)try{if(3===arguments.length)return console.log(arguments[0],arguments[1],arguments[2]);if(2===arguments.length)return console.log(arguments[0],arguments[1]);if(1===arguments.length)return console.log(arguments[0])}catch(e){console.log(arguments[0])}},sa.setPara=function(e){sa.para=_.extend2Lev(sa.para,e);var t=[];if(_.isArray(sa.para.source_channel))for(var a=sa.para.source_channel.length,r=0;rsa.para.max_string_length?(logger.info("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,sa.para.max_string_length)):e},_.searchObjString=function(e){_.isObject(e)&&_.each(e,function(t,a){_.isObject(t)?_.searchObjString(e[a]):_.isString(t)&&(e[a]=_.formatString(t))})},_.parseSuperProperties=function(e){_.isObject(e)&&(_.each(e,function(t,a){if(_.isFunction(t))try{e[a]=t(),_.isFunction(e[a])&&(logger.info("\u60a8\u7684\u5c5e\u6027- "+a+" \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}catch(t){delete e[a],logger.info("\u60a8\u7684\u5c5e\u6027- "+a+" \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}}),_.strip_sa_properties(e))},_.unique=function(e){for(var t,a=[],r={},s=0;s255)||(logger.info("id \u957f\u5ea6\u8d85\u8fc7 255 \u4e2a\u5b57\u7b26\uff01"),!1)}},_.strip_sa_properties=function(e){return _.isObject(e)?(_.each(e,function(t,a){if(_.isArray(t)){var r=[];_.each(t,function(e){_.isString(e)?r.push(e):logger.info("\u60a8\u7684\u6570\u636e-",t,"\u7684\u6570\u7ec4\u91cc\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32,\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}),e[a]=r}_.isString(t)||_.isNumber(t)||_.isDate(t)||_.isBoolean(t)||_.isArray(t)||(logger.info("\u60a8\u7684\u6570\u636e-",t,"-\u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}),e):e},_.strip_empty_properties=function(e){var t={};return _.each(e,function(e,a){null!=e&&(t[a]=e)}),t},_.utf8Encode=function(e){var t,a,r,s,i="";for(t=a=0,r=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,s=0;s127&&n<2048?String.fromCharCode(n>>6|192,63&n|128):String.fromCharCode(n>>12|224,n>>6&63|128,63&n|128),null!==o&&(a>t&&(i+=e.substring(t,a)),i+=o,t=a=s+1)}return a>t&&(i+=e.substring(t,e.length)),i},_.base64Encode=function(e){var t,a,r,s,i,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,c=0,u="",p=[];if(!e)return e;e=_.utf8Encode(e);do{t=(i=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,a=i>>12&63,r=i>>6&63,s=63&i,p[c++]=n.charAt(t)+n.charAt(a)+n.charAt(r)+n.charAt(s)}while(o255||(r=e.charCodeAt(o++))>255||(s=e.charCodeAt(o++))>255)&&logger.info("Failed to execute 'btoa' : The string to be encoded contains characters outside of the Latin1 range."),n+=i.charAt((t=a<<16|r<<8|s)>>18&63)+i.charAt(t>>12&63)+i.charAt(t>>6&63)+i.charAt(63&t);return _?n.slice(0,_-3)+"===".substring(_):n},_.urlBase64Encode=function(e){return _.btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))},_.rot13obfs=function(e,t){t="number"==typeof t?t:13;for(var a=(e=String(e)).split(""),r=0,s=a.length;r(new Date).getTime()},_.getCurrentUrl=function(e){var t=_.getCurrentPath(),a="";return _.isObject(e)&&e.sensors_mp_encode_url_query&&(a=e.sensors_mp_encode_url_query),t?a?t+"?"+a:t:"\u672a\u53d6\u5230"},_.getPath=function(e){return e="string"==typeof e?e.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"},_.getMethods=function(e){var t=[];for(var a in e)"function"!=typeof e[a]||mpHook[a]||t.push(a);return t},_.isClick=function(e){return!!{tap:1,longpress:1,longtap:1}[e]},sa.initialState={queue:[],isComplete:!1,systemIsComplete:!1,storeIsComplete:!1,checkIsComplete:function(){this.systemIsComplete&&this.storeIsComplete&&(this.isComplete=!0,this.queue.length>0&&(_.each(this.queue,function(e){sa[e[0]].apply(sa,slice.call(e[1]))}),this.queue=[]))}},_.getCustomUtmFromQuery=function(e,t,a,r){if(!_.isObject(e))return{};var s={};if(e.sa_utm)for(var i in e)"sa_utm"!==i?_.include(sa.para.source_channel,i)&&(s[a+i]=e[i]):s[r+i]=e[i];else for(var i in e)-1===(" "+source_channel_standard+" ").indexOf(" "+i+" ")?_.include(sa.para.source_channel,i)&&(s[a+i]=e[i]):s[t+i]=e[i];return s},_.getObjFromQuery=function(e){var t=e.split("?"),a=[],r={};return t&&t[1]?(_.each(t[1].split("&"),function(e){(a=e.split("="))[0]&&a[1]&&(r[a[0]]=a[1])}),r):{}},_.setStorageSync=function(e,t){var a=function(){wx.setStorageSync(e,t)};try{a()}catch(e){logger.info("set Storage fail --",e);try{a()}catch(e){logger.info("set Storage fail again --",e)}}},_.getStorageSync=function(e){var t="";try{t=wx.getStorageSync(e)}catch(a){try{t=wx.getStorageSync(e)}catch(e){logger.info("getStorage fail")}}return t},_.getMPScene=function(e){return"number"==typeof e||"string"==typeof e&&""!==e?e="wx-"+String(e):"\u672a\u53d6\u5230\u503c"},_.objToParam=function(e,t){if("[object Object]"!==Object.prototype.toString.call(e))return logger.info("\u8bf7\u4f20\u5165\u6709\u6548\u5bf9\u8c61"),"";var a=[];for(var r in e)if(e.hasOwnProperty(r)){var s=e[r];void 0===s?a.push(r+"="):(s=t?encodeURIComponent(s):s,a.push(r+"="+s))}return a.join("&")},_.delObjectKey=function(e){if("[object Object]"===Object.prototype.toString.call(e))for(var t=0;t=2?(page_route_map.shift(),page_route_map.push(e)):page_route_map.push(e)}}catch(e){logger.info(e)}},_.getRefPage=function(){var e={route:"\u76f4\u63a5\u6253\u5f00",title:""};return page_route_map.length>1&&(e.title=page_route_map[0].title,e.route=page_route_map[0].route),e},_.getCurrentPageInfo=function(){var e=_.getCurrentPage(),t={title:"",url:""};if(e&&e.route){var a=e.sensors_mp_url_query?"?"+e.sensors_mp_url_query:"";t.title=_.getPageTitle(e.route),t.url=e.route+a}return t},_.setPageRefData=function(e,t,a){var r=_.getRefPage();_.isObject(e)&&(t?page_route_map.length>0&&t?(a=a?"?"+a:"",e.$referrer=_.getPath(t)+a,e.$referrer_title=_.getPageTitle(t)):(e.$referrer="\u76f4\u63a5\u6253\u5f00",e.$referrer_title=""):(e.$referrer=r.route,e.$referrer_title=r.title))},_.getPageTitle=function(e){if("\u672a\u53d6\u5230"===e||!e)return"";var t="";try{if(__wxConfig){var a=__wxConfig,r=__wxConfig.page||{},s=r[e]||r[e+".html"],i={},n={};if(a.global&&a.global.window&&a.global.window.navigationBarTitleText&&(i.titleVal=a.global.window.navigationBarTitleText),s&&s.window&&s.window.navigationBarTitleText&&(n.titleVal=s.window.navigationBarTitleText),!n.titleVal&&__wxAppCode__){var o=__wxAppCode__[e+".json"];o&&o.navigationBarTitleText&&(n.titleVal=o.navigationBarTitleText)}if(_.each(globalTitle,function(a,r){if(r===e)return t=a}),0===t.length){var c=_.extend(i,n);t=c.titleVal||""}}}catch(e){logger.info(e)}return t},_.wxrequest=function(e){if(_.compareSDKVersion(wxSDKVersion,"2.10.0")>=0)e.timeout=sa.para.datasend_timeout,wx.request(e);else{var t=wx.request(e);setTimeout(function(){_.isObject(t)&&_.isFunction(t.abort)&&t.abort()},sa.para.datasend_timeout)}},_.getAppInfoSync=function(){if(wx.getAccountInfoSync){var e=wx.getAccountInfoSync(),t=e&&e.miniProgram?e.miniProgram:{};return{appId:t.appId,appEnv:t.envVersion,appVersion:t.version}}return{}},_.getAppId=function(){var e=_.getAppInfoSync();return e&&e.appId?e.appId:""},_.validId=function(e){return"string"!=typeof e&&"number"!=typeof e||""===e?(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1):"number"!=typeof e||(e=String(e),/^\d+$/.test(e))?!!_.check.ckeckIdLength(e)&&e:(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1)},_.compareSDKVersion=function(e,t){e=e.split("."),t=t.split(".");for(var a=Math.max(e.length,t.length);e.lengthi)return 1;if(s-1?t.system.split(" ")[1]:t.system,wxSDKVersion=t.SDKVersion,e.$mp_client_app_version=t.version,e.$mp_client_basic_library_version=wxSDKVersion},complete:function(){var t=(new Date).getTimezoneOffset(),a=_.getAppInfoSync();_.isNumber(t)&&(e.$timezone_offset=t),a.appId&&(e.$app_id=a.appId),a.appVersion&&(e.$app_version=a.appVersion),sa.initialState.systemIsComplete=!0,sa.initialState.checkIsComplete()}})}wx.getNetworkType({success:function(t){e.$network_type=_.setUpperCase(t.networkType)},complete:t})}},sa._=_,_.eventEmitter=function(){this.sub=[]},_.eventEmitter.prototype={add:function(e){this.sub.push(e)},emit:function(e,t){this.sub.forEach(function(a){a.on(e,t)})}},_.eventSub=function(e){sa.events.add(this),this._events=[],this.handle=e,this.ready=!1},_.eventSub.prototype={on:function(e,t){if(this.ready){if(_.isFunction(this.handle))try{this.handle(e,t)}catch(e){logger.info(e)}}else this._events.push({event:e,data:t})},isReady:function(){var e=this;e.ready=!0,e._events.forEach(function(t){if(_.isFunction(e.handle))try{e.handle(t.event,t.data)}catch(e){logger.info(e)}})}},sa.eventSub=_.eventSub,sa.events=new _.eventEmitter,sa.usePlugin=function(e,t){"function"==typeof e.init&&e.init(sa,t)},sa.store={storageInfo:null,getUUID:function(){return Date.now()+"-"+Math.floor(1e7*getRandom())+"-"+getRandom().toString(16).replace(".","")+"-"+String(31242*getRandom()).replace(".","").slice(0,8)},getStorage:function(){return this.storageInfo?this.storageInfo:(this.storageInfo=sa._.getStorageSync(sa.para.storage_store_key)||"",this.storageInfo)},_state:{},mem:{mdata:[],getLength:function(){return this.mdata.length},add:function(e){this.mdata.push(e)},clear:function(e){this.mdata.splice(0,e)}},toState:function(e){var t=null;_.isJSONString(e)?(t=JSON.parse(e)).distinct_id?this._state=t:this.set("distinct_id",this.getUUID()):_.isObject(e)&&(t=e).distinct_id?this._state=t:this.set("distinct_id",this.getUUID());var a=this._state._first_id||this._state.first_id,r=this._state._distinct_id||this._state.distinct_id,s=this._state.openid,i=(this._state.history_login_id?this._state.history_login_id:{}).name;if(this._state.identities&&_.isString(this._state.identities)){var n=JSON.parse(_.rot13defs(this._state.identities));this._state.identities=n}if(this._state.identities&&_.isObject(this._state.identities)&&!_.isEmptyObject(this._state.identities)?this._state.identities.hasOwnProperty("$identity_anonymous_id")&&(this._state.identities.$identity_anonymous_id=a||r):(this._state.identities={},this._state.identities.$mp_id=this.getUUID(),this._state.identities.$identity_anonymous_id=a||r),s){var o=_.getOpenidNameByAppid();this._state.identities[o]=s}if(a)if(i&&this._state.identities.hasOwnProperty(i)){if(this._state.identities[i]!==r){for(var c in this._state.identities[i]=r,this._state.identities)this._state.identities.hasOwnProperty(c)&&"$mp_id"!==c&&c!==i&&delete this._state.identities[c];this._state.history_login_id.value=r}}else{for(var c in this._state.identities[sa.para.login_id_key]=r,this._state.identities)this._state.identities.hasOwnProperty(c)&&"$mp_id"!==c&&c!==sa.para.login_id_key&&delete this._state.identities[c];this._state.history_login_id={name:sa.para.login_id_key,value:r}}else{if(this._state.identities.hasOwnProperty("$identity_login_id")||this._state.identities.hasOwnProperty(i))for(var c in this._state.identities)this._state.identities.hasOwnProperty(c)&&"$mp_id"!==c&&"$identity_anonymous_id"!==c&&delete this._state.identities[c];this._state.history_login_id={name:"",value:""}}this.save()},getFirstId:function(){return this._state._first_id||this._state.first_id},getDistinctId:function(){return this._state._distinct_id||this._state.distinct_id},getUnionId:function(){var e={},t=this._state._first_id||this._state.first_id,a=this._state._distinct_id||this._state.distinct_id;return t&&a?(e.login_id=a,e.anonymous_id=t):e.anonymous_id=a,e},getProps:function(){return this._state.props||{}},setProps:function(e,t){var a=this._state.props||{};t?this.set("props",e):(_.extend(a,e),this.set("props",a))},set:function(e,t){var a={};for(var r in"string"==typeof e?a[e]=t:"object"==typeof e&&(a=e),this._state=this._state||{},a)this._state[r]=a[r],"first_id"===r?delete this._state._first_id:"distinct_id"===r&&(delete this._state._distinct_id,sa.events.emit("changeDistinctId"));this.save()},identitiesSet:function(e,t){var a={};switch(e){case"login":a.$mp_id=sa.store._state.identities.$mp_id,a[sa.para.login_id_key]=t;break;case"logout":a.$mp_id=sa.store._state.identities.$mp_id;break;case"identify":(a=_.deepCopy(sa.store._state.identities)).$identity_anonymous_id=t}sa.store.set("identities",a)},change:function(e,t){this._state["_"+e]=t},encryptStorage:function(){var e=this.getStorage(),t="data:enc;";_.isObject(e)?e=t+_.rot13obfs(JSON.stringify(e)):_.isString(e)&&-1===e.indexOf(t)&&(e=t+_.rot13obfs(e)),sa._.setStorageSync(sa.para.storage_store_key,e)},save:function(){var e=_.deepCopy(this._state),t=_.rot13obfs(JSON.stringify(e.identities));if(e.identities=t,delete e._first_id,delete e._distinct_id,sa.para.encrypt_storage){e="data:enc;"+_.rot13obfs(JSON.stringify(e))}sa._.setStorageSync(sa.para.storage_store_key,e)},init:function(){var e=this.getStorage();if(e)_.isString(e)&&-1!==e.indexOf("data:enc;")&&(e=e.substring("data:enc;".length),e=JSON.parse(_.rot13defs(e))),this.toState(e);else{is_first_launch=!0;var t=new Date,a=t.getTime();t.setHours(23),t.setMinutes(59),t.setSeconds(60),sa.setOnceProfile({$first_visit_time:new Date}),this.set({distinct_id:this.getUUID(),first_visit_time:a,first_visit_day_time:t.getTime(),identities:{$mp_id:this.getUUID()},history_login_id:{name:"",value:""}})}}},sa.setProfile=function(e,t){sa.saEvent.send({type:"profile_set",properties:e},t)},sa.setOnceProfile=function(e,t){sa.saEvent.send({type:"profile_set_once",properties:e},t)},sa.appendProfile=function(e,t){if(!_.isObject(e))return!1;_.each(e,function(t,a){_.isString(t)?e[a]=[t]:(delete e[a],logger.info("appendProfile\u5c5e\u6027\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32\u6216\u8005\u6570\u7ec4"))}),sa.saEvent.send({type:"profile_append",properties:e},t)},sa.incrementProfile=function(e,t){if(!_.isObject(e))return!1;var a=e;_.isString(e)&&((e={})[a]=1),sa.saEvent.send({type:"profile_increment",properties:e},t)},sa.track=function(e,t,a){this.saEvent.send({type:"track",event:e,properties:t},a)},sa.identify=function(e,t){if(e=_.validId(e)){var a=sa.store.getFirstId();!0===t?a?sa.store.set("first_id",e):sa.store.set("distinct_id",e):a?sa.store.change("first_id",e):sa.store.change("distinct_id",e),sa.store.identitiesSet("identify",e)}},sa.trackSignup=function(e,t,a,r){var s=sa.store.getFirstId()||sa.store.getDistinctId();sa.store.set("distinct_id",e),sa.saEvent.send({original_id:s,distinct_id:e,type:"track_signup",event:t,properties:a},r)},sa.registerApp=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&(_.info.currentProps=_.extend(_.info.currentProps,e))},sa.register=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&sa.store.setProps(e)},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.clearAllProps=function(e){var t=sa.store.getProps(),a={};_.isArray(e)&&(_.each(t,function(t,r){_.include(e,r)||(a[r]=t)}),sa.store.setProps(a,!0))},sa.clearAppRegister=function(e){_.isArray(e)&&_.each(_.info.currentProps,function(t,a){_.include(e,a)&&delete _.info.currentProps[a]})},_.setLatestChannel=function(e){_.isEmptyObject(e)||(function(e,t){var a=!1;for(var r in t)e[t[r]]&&(a=!0);return a}(e,latest_source_channel)&&(sa.clearAppRegister(latest_source_channel),sa.clearAllProps(latest_source_channel)),sa.para.is_persistent_save.utm?sa.register(e):sa.registerApp(e))},_.setLatestShare=function(e){(e.$latest_share_depth||e.$latest_share_distinct_id||e.$latest_share_url_path||e.$latest_share_method)&&(sa.clearAppRegister(latest_share_info),sa.clearAllProps(latest_share_info),sa.para.is_persistent_save.share?sa.register(e):sa.registerApp(e))},sa.login=function(e){if(e=_.validId(e)){var t=sa.store.getFirstId(),a=sa.store.getDistinctId();if(sa.store._state.identities.hasOwnProperty(sa.para.login_id_key)&&e===t)return!1;var r=!(sa.para.login_id_key===sa.store._state.history_login_id.name&&sa.store._state.history_login_id.value===e);r&&(sa.store._state.identities[sa.para.login_id_key]=e),r&&(t?sa.trackSignup(e,"$SignUp"):(sa.store.set("first_id",a),sa.trackSignup(e,"$SignUp"))),r&&(sa.store.identitiesSet("login",e),sa.store.set("history_login_id",{name:sa.para.login_id_key,value:e}))}},sa.getAnonymousID=function(){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")},sa.logout=function(e){var t=sa.store.getFirstId();t?(sa.store.set("first_id",""),!0===e?sa.store.set("distinct_id",sa.store.getUUID()):sa.store.set("distinct_id",t)):logger.info("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25"),sa.store.identitiesSet("logout"),sa.store.set("history_login_id",{name:"",value:""})},sa.getLocation=function(){wx.getSetting({success:function(e){if(!e.authSetting["scope.userLocation"])return!1;wx.getLocation({type:sa.para.preset_properties.location.type,success:function(e){sa.registerApp({$latitude:e.latitude*Math.pow(10,6),$longitude:e.longitude*Math.pow(10,6),$geo_coordinate_system:_.setUpperCase(sa.para.preset_properties.location.type)})},fail:function(e){logger.info("\u83b7\u53d6\u4f4d\u7f6e\u5931\u8d25",e)}})}})},sa.openid={getRequest:function(e){wx.login({success:function(t){t.code&&sa.para.appid&&sa.para.openid_url?_.wxrequest({url:sa.para.openid_url+"&code="+t.code+"&appid="+sa.para.appid,method:"GET",complete:function(t){_.isObject(t)&&_.isObject(t.data)&&t.data.openid?e(t.data.openid):e()}}):e()}})},getWXStorage:function(){var e=sa.store.getStorage();if(e&&_.isObject(e))return e.openid},getOpenid:function(e){if(!sa.para.appid)return e(),!1;var t=this.getWXStorage();t?e(t):this.getRequest(e)}},sa.initial=function(){this._.info.getSystem(),this.store.init()},sa.init=function(e){if(!0===this.hasInit)return!1;this.hasInit=!0,sa.setPara(e),sa.para.encrypt_storage&&this.store.encryptStorage(),sa.para.batch_send&&sendStrategy.init(),sa.initialState.storeIsComplete=!0,sa.initialState.checkIsComplete()},sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib){var e={};_.each(_.info.currentProps,function(t,a){0===a.indexOf("$")&&(e[a]=t)});var t=_.extend(e,{$url_path:_.getCurrentPath(),$is_first_day:_.getIsFirstDay()},_.info.properties,sa.store.getProps());return delete t.$lib,t}return{}},sa.setOpenid=function(e,t){if(!(e=_.validId(e)))return!1;var a=sa.store.getFirstId();sa.store.set("openid",e),t?sa.store.set("distinct_id",e):(sa.identify(e,!0),a?sa.store.set("first_id",e):sa.store.set("distinct_id",e)),sa.bind("$mp_openid",e)},sa.unsetOpenid=function(e){var t=_.validId(e);if(!t)return!1;sa.store._state.openid===t&&sa.store.set("openid",""),sa.unbind("$mp_openid",t)},sa.setUnionid=function(e){var t=_.validId(e);t&&sa.bind("$mp_unionid",t)},sa.unsetUnionid=function(e){var t=_.validId(e);if(t){if(sa.store._state.identities.hasOwnProperty("$mp_unionid")&&t===sa.store._state.identities.$mp_unionid){var a=_.getOpenidNameByAppid();sa.store._state.identities.hasOwnProperty(a)&&(delete sa.store._state.identities[a],sa.store.save())}sa.unbind("$mp_unionid",t)}},sa.initWithOpenid=function(e,t){(e=e||{}).appid&&(sa.para.appid=e.appid),sa.openid.getOpenid(function(a){a&&sa.setOpenid(a,e.isCoverLogin),t&&_.isFunction(t)&&t(a),sa.init(e)})},sa.bind=function(e,t){if(_.isNumber(t)){if(_.isInteger(t)&&!1===_.isSafeInteger(t))return logger.info("Value must be String"),!1;t=String(t)}if(!_.isString(e))return logger.info("Key must be String"),!1;if(!_.check.checkKeyword(e)||"$identity_anonymous_id"===e||"$mp_id"===e||"$identity_login_id"===e||e===sa.para.login_id_key){var a="Key ["+e+"] is invalid";return logger.info(a),!1}if(!t||""===t)return logger.info("Value is empty or null"),!1;if(!_.isString(t))return logger.info("Value must be String"),!1;if(!_.check.ckeckIdLength(t)){a="Value ["+t+"] is beyond the maximum length 255";return logger.info(a),!1}var r=sa.store._state.identities;"$mp_openid"===e&&(e=_.getOpenidNameByAppid()),r[e]=t,sa.store.save(),sa.saEvent.send({type:"track_id_bind",event:"$BindID"})},sa.unbind=function(e,t){if(_.isNumber(t)){if(_.isInteger(t)&&!1===_.isSafeInteger(t))return logger.info("Value must be String"),!1;t=String(t)}if(!_.isString(e))return logger.info("Key must be String"),!1;if(!_.check.checkKeyword(e)||"$identity_anonymous_id"===e||"$mp_id"===e||"$identity_login_id"===e||e===sa.para.login_id_key){var a="Key ["+e+"] is invalid";return logger.info(a),!1}if(!t||""===t)return logger.info("Value is empty or null"),!1;if(!_.isString(t))return logger.info("Value must be String"),!1;if(!_.check.ckeckIdLength(t)){a="Value ["+t+"] is beyond the maximum length 255";return logger.info(a),!1}"$mp_openid"===e&&(e=_.getOpenidNameByAppid()),sa.store._state.identities.hasOwnProperty(e)&&t===sa.store._state.identities[e]&&(delete sa.store._state.identities[e],sa.store.save());var r={};r[e]=t,sa.saEvent.send({type:"track_id_unbind",event:"$UnbindID",unbind_value:r})},sa.setWebViewUrl=function(e,t){if(!_.isString(e)||""===e)return logger.info("error:\u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;if(!/^http(s)?:\/\//.test(e))return logger.info("warning: \u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;var a=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e);if(!a)return!1;var r,s=a[1]||"",i=a[2]||"",n=a[3]||"",o="",c=sa.store.getDistinctId()||"",u=sa.store.getFirstId()||"";_.urlSafeBase64&&_.urlSafeBase64.encode?c=c?_.urlSafeBase64.trim(_.urlSafeBase64.encode(_.urlBase64Encode(c))):"":this._.rot13obfs&&(c=c?_.rot13obfs(c):""),c=encodeURIComponent(c);var p=u?"f"+c:"d"+c;t?(r=n.indexOf("_sasdk"),o=n.indexOf("?")>-1?r>-1?s+i+"#"+n.substring(1,r)+"_sasdk="+p:s+i+"#"+n.substring(1)+"&_sasdk="+p:s+i+"#"+n.substring(1)+"?_sasdk="+p):(r=i.indexOf("_sasdk"),o=/^\?(\w)+/.test(i)?r>-1?s+i.replace(/(_sasdk=)([^&]*)/gi,"_sasdk="+p)+n:s+"?"+i.substring(1)+"&_sasdk="+p+n:s+"?"+i.substring(1)+"_sasdk="+p+n);return o},_.each(["setProfile","setOnceProfile","track","quick","incrementProfile","appendProfile","login","logout","registerApp","register","clearAllRegister","clearAllProps","clearAppRegister","bind","unbind"],function(e){var t=sa[e];sa[e]=function(){sa.initialState.isComplete?t.apply(sa,arguments):sa.initialState.queue.push([e,arguments])}}),_.setQuery=function(e,t){if(e&&_.isObject(e)&&!_.isEmptyObject(e)){var a=[];return _.each(e,function(e,r){"q"===r&&_.isString(e)&&0===e.indexOf("http")||(t?a.push(r+"="+e):a.push(r+"="+_.decodeURIComponent(e)))}),a.join("&")}return""},_.getUtmFromPage=function(){var e={};try{var t=_.getCurrentPage(),a=_.deepCopy(t.options);for(var r in a)a[r]=_.decodeURIComponent(a[r]);e=_.getCustomUtmFromQuery(a,"$","_","$")}catch(e){logger.info(e)}return e},_.sendPageLeave=function(){var e={},t="";try{t=(e=_.getCurrentPage())?e.route:""}catch(e){logger.info(e)}if(page_show_time>=0&&""!==t){var a={},r=_.getPageTitle(t),s=(Date.now()-page_show_time)/1e3;a.$url_query=e.sensors_mp_url_query?e.sensors_mp_url_query:"",a.$url_path=t,a.$title=r,a.event_duration=s,sa.track("$MPPageLeave",a),page_show_time=-1}};{var mp_proxy=function(e,t,a){var r=sa.autoTrackCustom[a];if(e[t]){var s=e[t];e[t]=function(){"onLaunch"===t&&(this[sa.para.name]=sa),!sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&!sa.para.autoTrackIsFirst[a]?(s.apply(this,arguments),r.apply(this,arguments)):(!0===sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&sa.para.autoTrackIsFirst[a])&&(r.apply(this,arguments),s.apply(this,arguments))}}else e[t]=function(){"onLaunch"===t&&(this[sa.para.name]=sa),r.apply(this,arguments)}};function clickTrack(e){var t,a={},r={},s=e.currentTarget||{},i=e.target||{};if(_.isObject(sa.para.framework)&&_.isObject(sa.para.framework.taro)&&!sa.para.framework.taro.createApp&&i.id&&s.id&&i.id!==s.id)return!1;var n=s.dataset||{};if(t=e.type,a.$element_id=s.id,a.$element_type=n.type,a.$element_content=n.content,a.$element_name=n.name,_.isObject(e.event_prop)&&(r=e.event_prop),t&&_.isClick(t)){if(sa.para.preset_events&&sa.para.preset_events.collect_element&&!1===sa.para.preset_events.collect_element(arguments[0]))return!1;a.$url_path=_.getCurrentPath(),_.setPageRefData(a),a=_.extend(a,r),sa.track("$MPClick",a)}}var click_proxy=function(e,t){var a=e[t];e[t]=function(){var e=a.apply(this,arguments),t=arguments[0];return _.isObject(t)&&(sa.para.preset_events.defer_track?setTimeout(function(){clickTrack(t)},0):clickTrack(t)),e}},tabProxy=function(e){var t=e.onTabItemTap;e.onTabItemTap=function(e){t&&t.apply(this,arguments);var a={};e&&(a.$element_content=e.text),a.$element_type="tabBar",a.$url_path=_.getCurrentPath(),_.setPageRefData(a),sa.track("$MPClick",a)}},pageLeaveProxy=function(e){var t=e.onHide;e.onHide=function(){t&&t.apply(this,arguments),_.sendPageLeave()};var a=e.onUnload;e.onUnload=function(){a&&a.apply(this,arguments),_.sendPageLeave()}}}sa.autoTrackCustom={trackCustom:function(e,t,a){var r=sa.para.autoTrack[e],s="";sa.para.autoTrack&&r&&("function"==typeof r?(s=r(),_.isObject(s)&&_.extend(t,s)):_.isObject(r)&&(_.extend(t,r),sa.para.autoTrack[e]=!0),sa.track(a,t))},appLaunch:function(e,t){"object"!=typeof this||this.trackCustom||(this[sa.para.name]=sa);var a={};if(e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path){if(a.$url_path=_.getPath(e.path),a.$title=_.getPageTitle(e.path),e.query&&_.isObject(e.query)){var r=_.setQuery(e.query);r=r?"?"+r:"",a.$url=a.$url_path+r}!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})}_.setShareInfo(e,a);var s=_.setUtm(e,a);is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(s.pre1)||sa.setOnceProfile(s.pre1)):a.$is_first_time=!1,_.setLatestChannel(s.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),_.setPageRefData(a),t?(a=_.extend(a,t),sa.track("$MPLaunch",a)):sa.para.autoTrack&&sa.para.autoTrack.appLaunch&&sa.autoTrackCustom.trackCustom("appLaunch",a,"$MPLaunch")},appShow:function(e,t){var a={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(a.$url_path=_.getPath(e.path),a.$title=_.getPageTitle(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,a);var r=_.setUtm(e,a);_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),_.setPageRefData(a,e.path,a.$url_query),e&&e.path&&(a.$url=e.path+(a.$url_query?"?"+a.$url_query:"")),t?(a=_.extend(a,t),sa.track("$MPShow",a)):sa.para.autoTrack&&sa.para.autoTrack.appShow&&sa.autoTrackCustom.trackCustom("appShow",a,"$MPShow")},appHide:function(e){var t=(new Date).getTime(),a={};a.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(a.event_duration=(t-mpshow_time)/1e3),_.setPageRefData(a),e?(a=_.extend(a,e),sa.track("$MPHide",a)):sa.para.autoTrack&&sa.para.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",a,"$MPHide"),sendStrategy.onAppHide()},pageLoad:function(e){current_scene&&1010===current_scene&&e&&(e.sampshare&&delete e.sampshare,_.delObjectKey(e)),e&&_.isObject(e)&&(this.sensors_mp_url_query=_.setQuery(e),this.sensors_mp_encode_url_query=_.setQuery(e,!0))},pageShow:function(){page_show_time=Date.now();var e={},t=_.getCurrentPath(),a=_.getPageTitle(t);_.setRefPage(),e.$url_path=t,e.$url_query=this.sensors_mp_url_query?this.sensors_mp_url_query:"",e=_.extend(e,_.getUtmFromPage()),_.setPageRefData(e),_.setPageSfSource(e),a&&(e.$title=a),sa.para.onshow?sa.para.onshow(sa,t,this):_.isObject(sa.para.autotrack_exclude_page)&&_.isArray(sa.para.autotrack_exclude_page.pageShow)&&-1!==sa.para.autotrack_exclude_page.pageShow.indexOf(t)||sa.autoTrackCustom.trackCustom("pageShow",e,"$MPViewScreen"),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:t})},pageShare:function(e){var t=e.onShareAppMessage;e.onShareAppMessage=function(){share_method="\u8f6c\u53d1\u6d88\u606f\u5361\u7247";var e=t.apply(this,arguments);if(sa.para.autoTrack&&sa.para.autoTrack.pageShare){var a={$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method};_.setPageRefData(a),sa.autoTrackCustom.trackCustom("pageShare",a,"$MPShare")}return sa.para.allow_amend_share_path&&("object"!=typeof e&&((e={}).path=_.getCurrentUrl(this)),"object"!=typeof e||void 0!==e.path&&""!==e.path||(e.path=_.getCurrentUrl(this)),"object"==typeof e&&"string"==typeof e.path&&(-1===e.path.indexOf("?")?e.path=e.path+"?":"&"!==e.path.slice(-1)&&(e.path=e.path+"&")),e.path=e.path+_.getShareInfo()),e}},pageShareTimeline:function(e){var t=e.onShareTimeline;e.onShareTimeline=function(){share_method="\u670b\u53cb\u5708\u5206\u4eab";var e=t.apply(this,arguments);if(sa.para.autoTrack&&sa.para.autoTrack.pageShare){var a={$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method};_.setPageRefData(a),sa.autoTrackCustom.trackCustom("pageShare",a,"$MPShare")}return sa.para.allow_amend_share_path&&("object"!=typeof e&&(e={}),"object"==typeof e&&void 0===e.query&&(e.query=""),"object"==typeof e&&"string"==typeof e.query&&""!==e.query&&"&"!==e.query.slice(-1)&&(e.query=e.query+"&"),e.query=e.query+_.getShareInfo()),e}},pageAddFavorites:function(){var e={};e.$url_path=_.getCurrentPath(),sa.para.autoTrack&&sa.para.autoTrack.mpFavorite&&sa.autoTrackCustom.trackCustom("mpFavorite",e,"$MPAddFavorites")}},sa.quick=function(){var e=arguments[0],t=arguments[1],a=arguments[2],r=_.isObject(a)?a:{};if("getAnonymousID"===e){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===e||"appShow"===e?t?sa.autoTrackCustom[e](t,r):logger.info("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(r=_.isObject(t)?t:{},sa.autoTrackCustom[e](r))},sa.appLaunch=function(e,t){var a={};e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(a.$url_path=_.getPath(e.path),a.$title=_.getPageTitle(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),_.setShareInfo(e,a);var r=_.setUtm(e,a);is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):a.$is_first_time=!1,_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),a.$url=e.path+(a.$url_query?"?"+a.$url_query:""),_.setPageRefData(t),_.isObject(t)&&(a=_.extend(a,t)),sa.track("$MPLaunch",a)},sa.appShow=function(e,t){var a={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(a.$url_path=_.getPath(e.path),a.$title=_.getPageTitle(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,a);var r=_.setUtm(e,a);_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),e&&e.path&&(a.$url=e.path+(a.$url_query?"?"+a.$url_query:"")),_.setPageRefData(a,e.path,a.$url_query),_.isObject(t)&&(a=_.extend(a,t)),sa.track("$MPShow",a)},sa.appHide=function(e){var t=(new Date).getTime(),a={};a.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(a.event_duration=(t-mpshow_time)/1e3),_.setPageRefData(a),_.isObject(e)&&(a=_.extend(a,e)),sa.track("$MPHide",a),sendStrategy.onAppHide()},sa.pageShow=function(e){var t={},a=_.getCurrentPath(),r=_.getPageTitle(a),s=_.getCurrentPage();_.setRefPage(),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a}),r&&(t.$title=r),t.$url_path=a,t.$url_query=s.sensors_mp_url_query?s.sensors_mp_url_query:"",t=_.extend(t,_.getUtmFromPage()),_.setPageSfSource(t),_.setPageRefData(t),_.isObject(e)&&(t=_.extend(t,e)),sa.track("$MPViewScreen",t)};var oldApp=App;App=function(e){e[sa.para.name]=sa,oldApp.apply(this,arguments)},wx.onAppShow(function(e){if(!deploy_para.launched){var t=wx.getLaunchOptionsSync()||{};sa.autoTrackCustom.appLaunch(t),deploy_para.launched=!0}sa.autoTrackCustom.appShow(e)}),wx.onAppHide(function(){sa.autoTrackCustom.appHide()});var oldPage=Page;Page=function(e){var t=sa.para.autoTrack&&sa.para.autoTrack.mpClick&&_.getMethods(e);if(t)for(var a=0,r=t.length;a0){for(var r=0;r=500&&(sa._.logger.info("\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38"),sa.store.mem.mdata.shift()),(e=kit.processData(e))&&sa.store.mem.add(e),sa.store.mem.getLength()>=sa.para.batch_send.max_length&&this.batchSend()},wxrequest:function(e){if(sa._.isArray(e.data)&&e.data.length>0){var t=kit.batchTrackData(e.data);sa._.wxrequest({url:sa.para.server_url,method:"POST",dataType:"text",data:t,success:function(){e.success(e.len)},fail:function(){e.fail()}})}else e.success(e.len)},batchSend:function(){if(this.dataHasSend){var e,t,a=sa.store.mem.mdata;(t=(e=a.length>=100?a.slice(0,100):a).length)>0&&(this.dataHasSend=!1,this.wxrequest({data:e,len:t,success:this.batchRemove.bind(this),fail:this.sendFail.bind(this)}))}},sendFail:function(){this.dataHasSend=!0,this.failTime++},batchRemove:function(e){sa.store.mem.clear(e),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite(),this.failTime=0},is_first_batch_write:!0,batchWrite:function(){var e=this;this.dataHasChange&&(this.is_first_batch_write&&(this.is_first_batch_write=!1,setTimeout(function(){e.batchSend()},1e3)),this.dataHasChange=!1,this.syncStorage&&sa._.setStorageSync(sa.para.storage_prepare_data_key,sa.store.mem.mdata))},batchInterval:function(){var e=this;!function t(){setTimeout(function(){e.batchWrite(),t()},500)}(),function t(){setTimeout(function(){e.batchSend(),t()},sa.para.batch_send.send_timeout*Math.pow(2,e.failTime))}()}};function getSendUrl(e,t){var a=kit.onceTrackData(t);return-1!==e.indexOf("?")?e+"&"+a:e+"?"+a}function onceSend(e){e._flush_time=Date.now();var t=getSendUrl(sa.para.server_url,e);sa._.wxrequest({url:t,method:"GET"})}var saEvent={send:function(e,t){if(!sa.para.server_url)return sa._.logger.info("error: server_url \u4e0d\u80fd\u4e3a\u7a7a"),!1;if(sa.current_scene&&1154===sa.current_scene&&!sa.para.preset_events.moments_page)return!1;var a=sa.kit.buildData(e);a?(saEvent.debug(a),sa.events.emit("send",a),sa.para.batch_send?sendStrategy.send(a):onceSend(a)):sa._.logger.info("error: \u6570\u636e\u5f02\u5e38 "+a)},debug:function(e){sa._.logger.info(e)}},_={};sa.kit=kit,sa.mergeStorageData=mergeStorageData,sa.saEvent=saEvent,sa.sendStrategy=sendStrategy,sa.IDENTITY_KEY={EMAIL:"$identity_email",MOBILE:"$identity_mobile"},sa.para={name:"sensors",server_url:"",send_timeout:1e3,show_log:!1,login_id_key:"$identity_login_id",allow_amend_share_path:!0,max_string_length:500,datasend_timeout:3e3,source_channel:[],autoTrack:{appLaunch:!0,appShow:!0,appHide:!0,pageShow:!0,pageShare:!0,mpClick:!1,mpFavorite:!0,pageLeave:!1},autotrack_exclude_page:{pageShow:[]},is_persistent_save:{share:!1,utm:!1},preset_properties:{url_path:!0},preset_events:{moments_page:!1,defer_track:!1,share_info_use_string:!1},batch_send:!0,storage_store_key:"sensorsdata2015_wechat",storage_prepare_data_key:"sensors_mp_prepare_data"};var deploy_para={launched:!1},mpHook={data:1,onLoad:1,onShow:1,onReady:1,onPullDownRefresh:1,onShareAppMessage:1,onShareTimeline:1,onReachBottom:1,onPageScroll:1,onResize:1,onTabItemTap:1,onHide:1,onUnload:1},logger="object"==typeof logger?logger:{};logger.info=function(){if(sa.para.show_log&&"object"==typeof console&&console.log)try{if(3===arguments.length)return console.log(arguments[0],arguments[1],arguments[2]);if(2===arguments.length)return console.log(arguments[0],arguments[1]);if(1===arguments.length)return console.log(arguments[0])}catch(e){console.log(arguments[0])}},sa.setPara=function(e){sa.para=_.extend2Lev(sa.para,e);var t=[];if(_.isArray(sa.para.source_channel))for(var a=sa.para.source_channel.length,r=0;rsa.para.max_string_length?(logger.info("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,sa.para.max_string_length)):e},_.searchObjString=function(e){_.isObject(e)&&_.each(e,function(t,a){_.isObject(t)?_.searchObjString(e[a]):_.isString(t)&&(e[a]=_.formatString(t))})},_.parseSuperProperties=function(e){_.isObject(e)&&(_.each(e,function(t,a){if(_.isFunction(t))try{e[a]=t(),_.isFunction(e[a])&&(logger.info("\u60a8\u7684\u5c5e\u6027- "+a+" \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}catch(t){delete e[a],logger.info("\u60a8\u7684\u5c5e\u6027- "+a+" \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}}),_.strip_sa_properties(e))},_.unique=function(e){for(var t,a=[],r={},s=0;s255)||(logger.info("id \u957f\u5ea6\u8d85\u8fc7 255 \u4e2a\u5b57\u7b26\uff01"),!1)}},_.strip_sa_properties=function(e){return _.isObject(e)?(_.each(e,function(t,a){if(_.isArray(t)){var r=[];_.each(t,function(e){_.isString(e)?r.push(e):logger.info("\u60a8\u7684\u6570\u636e-",t,"\u7684\u6570\u7ec4\u91cc\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32,\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}),e[a]=r}_.isString(t)||_.isNumber(t)||_.isDate(t)||_.isBoolean(t)||_.isArray(t)||(logger.info("\u60a8\u7684\u6570\u636e-",t,"-\u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}),e):e},_.strip_empty_properties=function(e){var t={};return _.each(e,function(e,a){null!=e&&(t[a]=e)}),t},_.utf8Encode=function(e){var t,a,r,s,i="";for(t=a=0,r=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,s=0;s127&&n<2048?String.fromCharCode(n>>6|192,63&n|128):String.fromCharCode(n>>12|224,n>>6&63|128,63&n|128),null!==o&&(a>t&&(i+=e.substring(t,a)),i+=o,t=a=s+1)}return a>t&&(i+=e.substring(t,e.length)),i},_.base64Encode=function(e){var t,a,r,s,i,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,c=0,u="",p=[];if(!e)return e;e=_.utf8Encode(e);do{t=(i=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,a=i>>12&63,r=i>>6&63,s=63&i,p[c++]=n.charAt(t)+n.charAt(a)+n.charAt(r)+n.charAt(s)}while(o255||(r=e.charCodeAt(o++))>255||(s=e.charCodeAt(o++))>255)&&logger.info("Failed to execute 'btoa' : The string to be encoded contains characters outside of the Latin1 range."),n+=i.charAt((t=a<<16|r<<8|s)>>18&63)+i.charAt(t>>12&63)+i.charAt(t>>6&63)+i.charAt(63&t);return _?n.slice(0,_-3)+"===".substring(_):n},_.urlBase64Encode=function(e){return _.btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))},_.rot13obfs=function(e,t){t="number"==typeof t?t:13;for(var a=(e=String(e)).split(""),r=0,s=a.length;r(new Date).getTime()},_.getCurrentUrl=function(e){var t=_.getCurrentPath(),a="";return _.isObject(e)&&e.sensors_mp_encode_url_query&&(a=e.sensors_mp_encode_url_query),t?a?t+"?"+a:t:"\u672a\u53d6\u5230"},_.getPath=function(e){return e="string"==typeof e?e.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"},_.getMethods=function(e){var t=[];for(var a in e)"function"!=typeof e[a]||mpHook[a]||t.push(a);return t},_.isClick=function(e){return!!{tap:1,longpress:1,longtap:1}[e]},sa.initialState={queue:[],isComplete:!1,systemIsComplete:!1,storeIsComplete:!1,checkIsComplete:function(){this.systemIsComplete&&this.storeIsComplete&&(this.isComplete=!0,this.queue.length>0&&(_.each(this.queue,function(e){sa[e[0]].apply(sa,slice.call(e[1]))}),this.queue=[]))}},_.getCustomUtmFromQuery=function(e,t,a,r){if(!_.isObject(e))return{};var s={};if(e.sa_utm)for(var i in e)"sa_utm"!==i?_.include(sa.para.source_channel,i)&&(s[a+i]=e[i]):s[r+i]=e[i];else for(var i in e)-1===(" "+source_channel_standard+" ").indexOf(" "+i+" ")?_.include(sa.para.source_channel,i)&&(s[a+i]=e[i]):s[t+i]=e[i];return s},_.getObjFromQuery=function(e){var t=e.split("?"),a=[],r={};return t&&t[1]?(_.each(t[1].split("&"),function(e){(a=e.split("="))[0]&&a[1]&&(r[a[0]]=a[1])}),r):{}},_.setStorageSync=function(e,t){var a=function(){wx.setStorageSync(e,t)};try{a()}catch(e){logger.info("set Storage fail --",e);try{a()}catch(e){logger.info("set Storage fail again --",e)}}},_.getStorageSync=function(e){var t="";try{t=wx.getStorageSync(e)}catch(a){try{t=wx.getStorageSync(e)}catch(e){logger.info("getStorage fail")}}return t},_.getMPScene=function(e){return"number"==typeof e||"string"==typeof e&&""!==e?e="wx-"+String(e):"\u672a\u53d6\u5230\u503c"},_.objToParam=function(e,t){if("[object Object]"!==Object.prototype.toString.call(e))return logger.info("\u8bf7\u4f20\u5165\u6709\u6548\u5bf9\u8c61"),"";var a=[];for(var r in e)if(e.hasOwnProperty(r)){var s=e[r];void 0===s?a.push(r+"="):(s=t?encodeURIComponent(s):s,a.push(r+"="+s))}return a.join("&")},_.delObjectKey=function(e){if("[object Object]"===Object.prototype.toString.call(e))for(var t=0;t=2?(page_route_map.shift(),page_route_map.push(e)):page_route_map.push(e)}}catch(e){logger.info(e)}},_.getRefPage=function(){var e={route:"\u76f4\u63a5\u6253\u5f00",title:""};return page_route_map.length>1&&(e.title=page_route_map[0].title,e.route=page_route_map[0].route),e},_.getCurrentPageInfo=function(){var e=_.getCurrentPage(),t={title:"",url:"",path:"\u672a\u53d6\u5230"};if(e&&e.route){var a=e.sensors_mp_url_query?"?"+e.sensors_mp_url_query:"";t.title=_.getPageTitle(e.route),t.url=e.route+a,t.path=e.route}return t},_.setPageRefData=function(e,t,a){var r=_.getRefPage();_.isObject(e)&&(t?page_route_map.length>0&&t?(a=a?"?"+a:"",e.$referrer=_.getPath(t)+a,e.$referrer_title=_.getPageTitle(t)):(e.$referrer="\u76f4\u63a5\u6253\u5f00",e.$referrer_title=""):(e.$referrer=r.route,e.$referrer_title=r.title))},_.getPageTitle=function(e){if("\u672a\u53d6\u5230"===e||!e)return"";var t="";try{if(__wxConfig){var a=__wxConfig,r=__wxConfig.page||{},s=r[e]||r[e+".html"],i={},n={};if(a.global&&a.global.window&&a.global.window.navigationBarTitleText&&(i.titleVal=a.global.window.navigationBarTitleText),s&&s.window&&s.window.navigationBarTitleText&&(n.titleVal=s.window.navigationBarTitleText),!n.titleVal&&__wxAppCode__){var o=__wxAppCode__[e+".json"];o&&o.navigationBarTitleText&&(n.titleVal=o.navigationBarTitleText)}if(_.each(globalTitle,function(a,r){if(r===e)return t=a}),0===t.length){var c=_.extend(i,n);t=c.titleVal||""}}}catch(e){logger.info(e)}return t},_.wxrequest=function(e){if(_.compareSDKVersion(wxSDKVersion,"2.10.0")>=0)e.timeout=sa.para.datasend_timeout,wx.request(e);else{var t=wx.request(e);setTimeout(function(){_.isObject(t)&&_.isFunction(t.abort)&&t.abort()},sa.para.datasend_timeout)}},_.getAppInfoSync=function(){if(wx.getAccountInfoSync){var e=wx.getAccountInfoSync(),t=e&&e.miniProgram?e.miniProgram:{};return{appId:t.appId,appEnv:t.envVersion,appVersion:t.version}}return{}},_.getAppId=function(){var e=_.getAppInfoSync();return e&&e.appId?e.appId:""},_.validId=function(e){return"string"!=typeof e&&"number"!=typeof e||""===e?(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1):"number"!=typeof e||(e=String(e),/^\d+$/.test(e))?!!_.check.ckeckIdLength(e)&&e:(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1)},_.compareSDKVersion=function(e,t){e=e.split("."),t=t.split(".");for(var a=Math.max(e.length,t.length);e.lengthi)return 1;if(s-1?t.system.split(" ")[1]:t.system,wxSDKVersion=t.SDKVersion,e.$mp_client_app_version=t.version,e.$mp_client_basic_library_version=wxSDKVersion},complete:function(){var t=(new Date).getTimezoneOffset(),a=_.getAppInfoSync();_.isNumber(t)&&(e.$timezone_offset=t),a.appId&&(e.$app_id=a.appId),a.appVersion&&(e.$app_version=a.appVersion),sa.initialState.systemIsComplete=!0,sa.initialState.checkIsComplete()}})}wx.getNetworkType({success:function(t){e.$network_type=_.setUpperCase(t.networkType)},complete:t})}},sa._=_,_.eventEmitter=function(){this.sub=[]},_.eventEmitter.prototype={add:function(e){this.sub.push(e)},emit:function(e,t){this.sub.forEach(function(a){a.on(e,t)})}},_.eventSub=function(e){sa.events.add(this),this._events=[],this.handle=e,this.ready=!1},_.eventSub.prototype={on:function(e,t){if(this.ready){if(_.isFunction(this.handle))try{this.handle(e,t)}catch(e){logger.info(e)}}else this._events.push({event:e,data:t})},isReady:function(){var e=this;e.ready=!0,e._events.forEach(function(t){if(_.isFunction(e.handle))try{e.handle(t.event,t.data)}catch(e){logger.info(e)}})}},sa.eventSub=_.eventSub,sa.events=new _.eventEmitter,sa.usePlugin=function(e,t){"function"==typeof e.init&&e.init(sa,t)},sa.store={storageInfo:null,getUUID:function(){return Date.now()+"-"+Math.floor(1e7*getRandom())+"-"+getRandom().toString(16).replace(".","")+"-"+String(31242*getRandom()).replace(".","").slice(0,8)},getStorage:function(){return this.storageInfo?this.storageInfo:(this.storageInfo=sa._.getStorageSync(sa.para.storage_store_key)||"",this.storageInfo)},_state:{},mem:{mdata:[],getLength:function(){return this.mdata.length},add:function(e){this.mdata.push(e)},clear:function(e){this.mdata.splice(0,e)}},toState:function(e){var t=null;_.isJSONString(e)?(t=JSON.parse(e)).distinct_id?this._state=t:this.set("distinct_id",this.getUUID()):_.isObject(e)&&(t=e).distinct_id?this._state=t:this.set("distinct_id",this.getUUID());var a=this._state._first_id||this._state.first_id,r=this._state._distinct_id||this._state.distinct_id,s=this._state.openid,i=(this._state.history_login_id?this._state.history_login_id:{}).name;if(this._state.identities&&_.isString(this._state.identities)){var n=JSON.parse(_.rot13defs(this._state.identities));this._state.identities=n}var o,c,u=_.getOpenidNameByAppid();if(this._state.identities&&_.isObject(this._state.identities)&&!_.isEmptyObject(this._state.identities)){var p=(o=_.getAppId(),c="$mp_openid",o&&(c="$mp_"+o+"_openid"),c);this._state.identities.hasOwnProperty("$mp_id")&&(this._state.identities.$identity_mp_id=this._state.identities.$mp_id,delete this._state.identities.$mp_id),this._state.identities.hasOwnProperty("$mp_unionid")&&(this._state.identities.$identity_mp_unionid=this._state.identities.$mp_unionid,delete this._state.identities.$mp_unionid),this._state.identities.hasOwnProperty(p)&&(this._state.identities[u]=this._state.identities[p],delete this._state.identities[p]),this._state.identities.hasOwnProperty("$identity_anonymous_id")&&(this._state.identities.$identity_anonymous_id=a||r)}else this._state.identities={},this._state.identities.$identity_mp_id=this.getUUID(),this._state.identities.$identity_anonymous_id=a||r;if(s&&(this._state.identities[u]=s),a)if(i&&this._state.identities.hasOwnProperty(i)){if(this._state.identities[i]!==r){for(var d in this._state.identities[i]=r,this._state.identities)this._state.identities.hasOwnProperty(d)&&"$identity_mp_id"!==d&&d!==i&&delete this._state.identities[d];this._state.history_login_id.value=r}}else{for(var d in this._state.identities[sa.para.login_id_key]=r,this._state.identities)this._state.identities.hasOwnProperty(d)&&"$identity_mp_id"!==d&&d!==sa.para.login_id_key&&delete this._state.identities[d];this._state.history_login_id={name:sa.para.login_id_key,value:r}}else{if(this._state.identities.hasOwnProperty("$identity_login_id")||this._state.identities.hasOwnProperty(i))for(var d in this._state.identities)this._state.identities.hasOwnProperty(d)&&"$identity_mp_id"!==d&&"$identity_anonymous_id"!==d&&delete this._state.identities[d];this._state.history_login_id={name:"",value:""}}this.save()},getFirstId:function(){return this._state._first_id||this._state.first_id},getDistinctId:function(){return this._state._distinct_id||this._state.distinct_id},getUnionId:function(){var e={},t=this._state._first_id||this._state.first_id,a=this._state._distinct_id||this._state.distinct_id;return t&&a?(e.login_id=a,e.anonymous_id=t):e.anonymous_id=a,e},getProps:function(){return this._state.props||{}},setProps:function(e,t){var a=this._state.props||{};t?this.set("props",e):(_.extend(a,e),this.set("props",a))},set:function(e,t){var a={};for(var r in"string"==typeof e?a[e]=t:"object"==typeof e&&(a=e),this._state=this._state||{},a)this._state[r]=a[r],"first_id"===r?delete this._state._first_id:"distinct_id"===r&&(delete this._state._distinct_id,sa.events.emit("changeDistinctId"));this.save()},identitiesSet:function(e,t){var a={};switch(e){case"login":a.$identity_mp_id=sa.store._state.identities.$identity_mp_id,a[sa.para.login_id_key]=t;break;case"logout":a.$identity_mp_id=sa.store._state.identities.$identity_mp_id;break;case"identify":(a=_.deepCopy(sa.store._state.identities)).$identity_anonymous_id=t}sa.store.set("identities",a)},change:function(e,t){this._state["_"+e]=t},encryptStorage:function(){var e=this.getStorage(),t="data:enc;";_.isObject(e)?e=t+_.rot13obfs(JSON.stringify(e)):_.isString(e)&&-1===e.indexOf(t)&&(e=t+_.rot13obfs(e)),sa._.setStorageSync(sa.para.storage_store_key,e)},save:function(){var e=_.deepCopy(this._state),t=_.rot13obfs(JSON.stringify(e.identities));if(e.identities=t,delete e._first_id,delete e._distinct_id,sa.para.encrypt_storage){e="data:enc;"+_.rot13obfs(JSON.stringify(e))}sa._.setStorageSync(sa.para.storage_store_key,e)},init:function(){var e=this.getStorage();if(e)_.isString(e)&&-1!==e.indexOf("data:enc;")&&(e=e.substring("data:enc;".length),e=JSON.parse(_.rot13defs(e))),this.toState(e);else{is_first_launch=!0;var t=new Date,a=t.getTime();t.setHours(23),t.setMinutes(59),t.setSeconds(60),sa.setOnceProfile({$first_visit_time:new Date}),this.set({distinct_id:this.getUUID(),first_visit_time:a,first_visit_day_time:t.getTime(),identities:{$identity_mp_id:this.getUUID()},history_login_id:{name:"",value:""}})}}},sa.setProfile=function(e,t){sa.saEvent.send({type:"profile_set",properties:e},t)},sa.setOnceProfile=function(e,t){sa.saEvent.send({type:"profile_set_once",properties:e},t)},sa.appendProfile=function(e,t){if(!_.isObject(e))return!1;_.each(e,function(t,a){_.isString(t)?e[a]=[t]:(delete e[a],logger.info("appendProfile\u5c5e\u6027\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32\u6216\u8005\u6570\u7ec4"))}),sa.saEvent.send({type:"profile_append",properties:e},t)},sa.incrementProfile=function(e,t){if(!_.isObject(e))return!1;var a=e;_.isString(e)&&((e={})[a]=1),sa.saEvent.send({type:"profile_increment",properties:e},t)},sa.track=function(e,t,a){this.saEvent.send({type:"track",event:e,properties:t},a)},sa.identify=function(e,t){if(e=_.validId(e)){var a=sa.store.getFirstId();!0===t?a?sa.store.set("first_id",e):sa.store.set("distinct_id",e):a?sa.store.change("first_id",e):sa.store.change("distinct_id",e),sa.store.identitiesSet("identify",e)}},sa.trackSignup=function(e,t,a,r){var s=sa.store.getFirstId()||sa.store.getDistinctId();sa.store.set("distinct_id",e),sa.saEvent.send({original_id:s,distinct_id:e,type:"track_signup",event:t,properties:a},r)},sa.registerApp=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&(_.info.currentProps=_.extend(_.info.currentProps,e))},sa.register=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&sa.store.setProps(e)},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.clearAllProps=function(e){var t=sa.store.getProps(),a={};_.isArray(e)&&(_.each(t,function(t,r){_.include(e,r)||(a[r]=t)}),sa.store.setProps(a,!0))},sa.clearAppRegister=function(e){_.isArray(e)&&_.each(_.info.currentProps,function(t,a){_.include(e,a)&&delete _.info.currentProps[a]})},_.setLatestChannel=function(e){_.isEmptyObject(e)||(function(e,t){var a=!1;for(var r in t)e[t[r]]&&(a=!0);return a}(e,latest_source_channel)&&(sa.clearAppRegister(latest_source_channel),sa.clearAllProps(latest_source_channel)),sa.para.is_persistent_save.utm?sa.register(e):sa.registerApp(e))},_.setLatestShare=function(e){(e.$latest_share_depth||e.$latest_share_distinct_id||e.$latest_share_url_path||e.$latest_share_method)&&(sa.clearAppRegister(latest_share_info),sa.clearAllProps(latest_share_info),sa.para.is_persistent_save.share?sa.register(e):sa.registerApp(e))},sa.login=function(e){if(e=_.validId(e)){var t=sa.store.getFirstId(),a=sa.store.getDistinctId();if(sa.store._state.identities.hasOwnProperty(sa.para.login_id_key)&&e===t)return!1;var r=!(sa.para.login_id_key===sa.store._state.history_login_id.name&&sa.store._state.history_login_id.value===e);r&&(sa.store._state.identities[sa.para.login_id_key]=e),r&&(t?sa.trackSignup(e,"$SignUp"):(sa.store.set("first_id",a),sa.trackSignup(e,"$SignUp"))),r&&(sa.store.identitiesSet("login",e),sa.store.set("history_login_id",{name:sa.para.login_id_key,value:e}))}},sa.getAnonymousID=function(){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")},sa.logout=function(e){var t=sa.store.getFirstId();t?(sa.store.set("first_id",""),!0===e?sa.store.set("distinct_id",sa.store.getUUID()):sa.store.set("distinct_id",t)):logger.info("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25"),sa.store.identitiesSet("logout"),sa.store.set("history_login_id",{name:"",value:""})},sa.getLocation=function(){wx.getSetting({success:function(e){if(!e.authSetting["scope.userLocation"])return!1;wx.getLocation({type:sa.para.preset_properties.location.type,success:function(e){sa.registerApp({$latitude:e.latitude*Math.pow(10,6),$longitude:e.longitude*Math.pow(10,6),$geo_coordinate_system:_.setUpperCase(sa.para.preset_properties.location.type)})},fail:function(e){logger.info("\u83b7\u53d6\u4f4d\u7f6e\u5931\u8d25",e)}})}})},sa.openid={getRequest:function(e){wx.login({success:function(t){t.code&&sa.para.appid&&sa.para.openid_url?_.wxrequest({url:sa.para.openid_url+"&code="+t.code+"&appid="+sa.para.appid,method:"GET",complete:function(t){_.isObject(t)&&_.isObject(t.data)&&t.data.openid?e(t.data.openid):e()}}):e()}})},getWXStorage:function(){var e=sa.store.getStorage();if(e&&_.isObject(e))return e.openid},getOpenid:function(e){if(!sa.para.appid)return e(),!1;var t=this.getWXStorage();t?e(t):this.getRequest(e)}},sa.initial=function(){this._.info.getSystem(),this.store.init()},sa.init=function(e){if(!0===this.hasInit)return!1;this.hasInit=!0,sa.setPara(e),sa.para.encrypt_storage&&this.store.encryptStorage(),sa.para.batch_send&&sendStrategy.init(),sa.initialState.storeIsComplete=!0,sa.initialState.checkIsComplete()},sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib){var e={};_.each(_.info.currentProps,function(t,a){0===a.indexOf("$")&&(e[a]=t)});var t={$url_path:_.getCurrentPath(),$is_first_day:_.getIsFirstDay(),$is_first_time:is_first_launch},a=_.extend(e,t,_.info.properties,sa.store.getProps());return delete a.$lib,a}return{}},sa.setOpenid=function(e,t){if(!(e=_.validId(e)))return!1;t&&console.log("%c \u5f53\u524d\u7248\u672c setOpenid \u63a5\u53e3 \u5df2\u4e0d\u652f\u6301\u4f20\u5165\u7b2c\u4e8c\u4e2a\u53c2\u6570","color:#F39C12;font-size: 14px;"),sa.store.set("openid",e),sa.identify(e,!0),sa.bind("$identity_mp_openid",e)},sa.unsetOpenid=function(e){var t=_.validId(e);if(!t)return!1;sa.store._state.openid===t&&sa.store.set("openid",""),sa.unbind("$identity_mp_openid",t)},sa.setUnionid=function(e){var t=_.validId(e);t&&sa.bind("$identity_mp_unionid",t)},sa.unsetUnionid=function(e){var t=_.validId(e);if(t){if(sa.store._state.identities.hasOwnProperty("$identity_mp_unionid")&&t===sa.store._state.identities.$identity_mp_unionid){var a=_.getOpenidNameByAppid();sa.store._state.identities.hasOwnProperty(a)&&(delete sa.store._state.identities[a],delete sa.store._state.openid,sa.store.save())}sa.unbind("$identity_mp_unionid",t)}},sa.initWithOpenid=function(e,t){(e=e||{}).appid&&(sa.para.appid=e.appid),sa.openid.getOpenid(function(a){a&&sa.setOpenid(a,e.isCoverLogin),t&&_.isFunction(t)&&t(a),sa.init(e)})},sa.bind=function(e,t){if(_.isNumber(t)){if(_.isInteger(t)&&!1===_.isSafeInteger(t))return logger.info("Value must be String"),!1;t=String(t)}if(!_.isString(e))return logger.info("Key must be String"),!1;if(!_.check.checkKeyword(e)||"$identity_anonymous_id"===e||"$mp_id"===e||"$identity_mp_id"===e||"$identity_login_id"===e||e===sa.para.login_id_key){var a="Key ["+e+"] is invalid";return logger.info(a),!1}if(!t||""===t)return logger.info("Value is empty or null"),!1;if(!_.isString(t))return logger.info("Value must be String"),!1;if(!_.check.ckeckIdLength(t)){a="Value ["+t+"] is beyond the maximum length 255";return logger.info(a),!1}var r=sa.store._state.identities;"$identity_mp_openid"===e&&(e=_.getOpenidNameByAppid()),r[e]=t,sa.store.save(),sa.saEvent.send({type:"track_id_bind",event:"$BindID"})},sa.unbind=function(e,t){if(_.isNumber(t)){if(_.isInteger(t)&&!1===_.isSafeInteger(t))return logger.info("Value must be String"),!1;t=String(t)}if(!_.isString(e))return logger.info("Key must be String"),!1;if(!_.check.checkKeyword(e)||"$identity_anonymous_id"===e||"$mp_id"===e||"$identity_mp_id"===e||"$identity_login_id"===e||e===sa.para.login_id_key){var a="Key ["+e+"] is invalid";return logger.info(a),!1}if(!t||""===t)return logger.info("Value is empty or null"),!1;if(!_.isString(t))return logger.info("Value must be String"),!1;if(!_.check.ckeckIdLength(t)){a="Value ["+t+"] is beyond the maximum length 255";return logger.info(a),!1}"$identity_mp_openid"===e&&(e=_.getOpenidNameByAppid()),sa.store._state.identities.hasOwnProperty(e)&&t===sa.store._state.identities[e]&&(delete sa.store._state.identities[e],sa.store.save());var r={};r[e]=t,sa.saEvent.send({type:"track_id_unbind",event:"$UnbindID",unbind_value:r})},sa.setWebViewUrl=function(e,t){if(!_.isString(e)||""===e)return logger.info("error:\u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;if(!/^http(s)?:\/\//.test(e))return logger.info("warning: \u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;var a=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e);if(!a)return!1;var r,s=a[1]||"",i=a[2]||"",n=a[3]||"",o="",c=sa.store.getDistinctId()||"",u=sa.store.getFirstId()||"";_.urlSafeBase64&&_.urlSafeBase64.encode?c=c?_.urlSafeBase64.trim(_.urlSafeBase64.encode(_.urlBase64Encode(c))):"":this._.rot13obfs&&(c=c?_.rot13obfs(c):""),c=encodeURIComponent(c);var p=u?"f"+c:"d"+c;t?(r=n.indexOf("_sasdk"),o=n.indexOf("?")>-1?r>-1?s+i+"#"+n.substring(1,r)+"_sasdk="+p:s+i+"#"+n.substring(1)+"&_sasdk="+p:s+i+"#"+n.substring(1)+"?_sasdk="+p):(r=i.indexOf("_sasdk"),o=/^\?(\w)+/.test(i)?r>-1?s+i.replace(/(_sasdk=)([^&]*)/gi,"_sasdk="+p)+n:s+"?"+i.substring(1)+"&_sasdk="+p+n:s+"?"+i.substring(1)+"_sasdk="+p+n);return o},_.each(["setProfile","setOnceProfile","track","quick","incrementProfile","appendProfile","login","logout","registerApp","register","clearAllRegister","clearAllProps","clearAppRegister","bind","unbind","unsetOpenid","setUnionid","unsetUnionid"],function(e){var t=sa[e];sa[e]=function(){sa.initialState.isComplete?t.apply(sa,arguments):sa.initialState.queue.push([e,arguments])}}),_.setQuery=function(e,t){if(e&&_.isObject(e)&&!_.isEmptyObject(e)){var a=[];return _.each(e,function(e,r){"q"===r&&_.isString(e)&&0===e.indexOf("http")||(t?a.push(r+"="+e):a.push(r+"="+_.decodeURIComponent(e)))}),a.join("&")}return""},_.getUtmFromPage=function(){var e={};try{var t=_.getCurrentPage(),a=_.deepCopy(t.options);for(var r in a)a[r]=_.decodeURIComponent(a[r]);e=_.getCustomUtmFromQuery(a,"$","_","$")}catch(e){logger.info(e)}return e},_.sendPageLeave=function(){var e={},t="";try{t=(e=_.getCurrentPage())?e.route:""}catch(e){logger.info(e)}if(page_show_time>=0&&""!==t){var a={},r=_.getPageTitle(t),s=(Date.now()-page_show_time)/1e3;a.$url_query=e.sensors_mp_url_query?e.sensors_mp_url_query:"",a.$url_path=t,a.$title=r,a.event_duration=s,sa.track("$MPPageLeave",a),page_show_time=-1}};{var mp_proxy=function(e,t,a){var r=sa.autoTrackCustom[a];if(e[t]){var s=e[t];e[t]=function(){"onLaunch"===t&&(this[sa.para.name]=sa),!sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&!sa.para.autoTrackIsFirst[a]?(s.apply(this,arguments),r.apply(this,arguments)):(!0===sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&sa.para.autoTrackIsFirst[a])&&(r.apply(this,arguments),s.apply(this,arguments))}}else e[t]=function(){"onLaunch"===t&&(this[sa.para.name]=sa),r.apply(this,arguments)}};function clickTrack(e){var t,a={},r={},s=e.currentTarget||{},i=e.target||{};if(_.isObject(sa.para.framework)&&_.isObject(sa.para.framework.taro)&&!sa.para.framework.taro.createApp&&i.id&&s.id&&i.id!==s.id)return!1;var n=s.dataset||{};if(t=e.type,a.$element_id=s.id,a.$element_type=n.type,a.$element_content=n.content,a.$element_name=n.name,_.isObject(e.event_prop)&&(r=e.event_prop),t&&_.isClick(t)){if(sa.para.preset_events&&sa.para.preset_events.collect_element&&!1===sa.para.preset_events.collect_element(arguments[0]))return!1;a.$url_path=_.getCurrentPath(),_.setPageRefData(a),a=_.extend(a,r),sa.track("$MPClick",a)}}var click_proxy=function(e,t){var a=e[t];e[t]=function(){var e=a.apply(this,arguments),t=arguments[0];return _.isObject(t)&&(sa.para.preset_events.defer_track?setTimeout(function(){clickTrack(t)},0):clickTrack(t)),e}},tabProxy=function(e){var t=e.onTabItemTap;e.onTabItemTap=function(e){t&&t.apply(this,arguments);var a={};e&&(a.$element_content=e.text),a.$element_type="tabBar",a.$url_path=_.getCurrentPath(),_.setPageRefData(a),sa.track("$MPClick",a)}},pageLeaveProxy=function(e){var t=e.onHide;e.onHide=function(){t&&t.apply(this,arguments),_.sendPageLeave()};var a=e.onUnload;e.onUnload=function(){a&&a.apply(this,arguments),_.sendPageLeave()}}}sa.autoTrackCustom={trackCustom:function(e,t,a){var r=sa.para.autoTrack[e],s="";sa.para.autoTrack&&r&&("function"==typeof r?(s=r(),_.isObject(s)&&_.extend(t,s)):_.isObject(r)&&(_.extend(t,r),sa.para.autoTrack[e]=!0),sa.track(a,t))},appLaunch:function(e,t){"object"!=typeof this||this.trackCustom||(this[sa.para.name]=sa);var a={};if(e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(a.$url_path=_.getPath(e.path),a.$title=_.getPageTitle(e.path),e.query&&_.isObject(e.query))){var r=_.setQuery(e.query);r=r?"?"+r:"",a.$url=a.$url_path+r}_.setShareInfo(e,a);var s=_.setUtm(e,a);is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(s.pre1)||sa.setOnceProfile(s.pre1)):a.$is_first_time=!1,_.setLatestChannel(s.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),_.setPageRefData(a),t?(a=_.extend(a,t),sa.track("$MPLaunch",a)):sa.para.autoTrack&&sa.para.autoTrack.appLaunch&&sa.autoTrackCustom.trackCustom("appLaunch",a,"$MPLaunch")},appShow:function(e,t){var a={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(a.$url_path=_.getPath(e.path),a.$title=_.getPageTitle(e.path)),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,a);var r=_.setUtm(e,a);_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),_.setPageRefData(a,e.path,a.$url_query),e&&e.path&&(a.$url=e.path+(a.$url_query?"?"+a.$url_query:"")),t?(a=_.extend(a,t),sa.track("$MPShow",a)):sa.para.autoTrack&&sa.para.autoTrack.appShow&&sa.autoTrackCustom.trackCustom("appShow",a,"$MPShow")},appHide:function(e){var t=(new Date).getTime(),a={};a.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(a.event_duration=(t-mpshow_time)/1e3),_.setPageRefData(a),e?(a=_.extend(a,e),sa.track("$MPHide",a)):sa.para.autoTrack&&sa.para.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",a,"$MPHide"),sendStrategy.onAppHide()},pageLoad:function(e){current_scene&&1010===current_scene&&e&&(e.sampshare&&delete e.sampshare,_.delObjectKey(e)),e&&_.isObject(e)&&(this.sensors_mp_url_query=_.setQuery(e),this.sensors_mp_encode_url_query=_.setQuery(e,!0))},pageShow:function(){page_show_time=Date.now();var e={},t=_.getCurrentPath(),a=_.getPageTitle(t);_.setRefPage(),e.$url_path=t,e.$url_query=this.sensors_mp_url_query?this.sensors_mp_url_query:"",e=_.extend(e,_.getUtmFromPage()),_.setPageRefData(e),_.setPageSfSource(e),a&&(e.$title=a),sa.para.onshow?sa.para.onshow(sa,t,this):_.isObject(sa.para.autotrack_exclude_page)&&_.isArray(sa.para.autotrack_exclude_page.pageShow)&&-1!==sa.para.autotrack_exclude_page.pageShow.indexOf(t)||sa.autoTrackCustom.trackCustom("pageShow",e,"$MPViewScreen")},pageShare:function(e){var t=e.onShareAppMessage;e.onShareAppMessage=function(){share_method="\u8f6c\u53d1\u6d88\u606f\u5361\u7247";var e=t.apply(this,arguments);if(sa.para.autoTrack&&sa.para.autoTrack.pageShare){var a={$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method};_.setPageRefData(a),sa.autoTrackCustom.trackCustom("pageShare",a,"$MPShare")}return sa.para.allow_amend_share_path&&("object"!=typeof e&&((e={}).path=_.getCurrentUrl(this)),"object"!=typeof e||void 0!==e.path&&""!==e.path||(e.path=_.getCurrentUrl(this)),"object"==typeof e&&"string"==typeof e.path&&(-1===e.path.indexOf("?")?e.path=e.path+"?":"&"!==e.path.slice(-1)&&(e.path=e.path+"&")),e.path=e.path+_.getShareInfo()),e}},pageShareTimeline:function(e){var t=e.onShareTimeline;e.onShareTimeline=function(){share_method="\u670b\u53cb\u5708\u5206\u4eab";var e=t.apply(this,arguments);if(sa.para.autoTrack&&sa.para.autoTrack.pageShare){var a={$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method};_.setPageRefData(a),sa.autoTrackCustom.trackCustom("pageShare",a,"$MPShare")}return sa.para.allow_amend_share_path&&("object"!=typeof e&&(e={}),"object"==typeof e&&void 0===e.query&&(e.query=""),"object"==typeof e&&"string"==typeof e.query&&""!==e.query&&"&"!==e.query.slice(-1)&&(e.query=e.query+"&"),e.query=e.query+_.getShareInfo()),e}},pageAddFavorites:function(){var e={};e.$url_path=_.getCurrentPath(),sa.para.autoTrack&&sa.para.autoTrack.mpFavorite&&sa.autoTrackCustom.trackCustom("mpFavorite",e,"$MPAddFavorites")}},sa.quick=function(){var e=arguments[0],t=arguments[1],a=arguments[2],r=_.isObject(a)?a:{};if("getAnonymousID"===e){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===e||"appShow"===e?t?sa.autoTrackCustom[e](t,r):logger.info("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(r=_.isObject(t)?t:{},sa.autoTrackCustom[e](r))},sa.appLaunch=function(e,t){var a={};e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(a.$url_path=_.getPath(e.path),a.$title=_.getPageTitle(e.path)),_.setShareInfo(e,a);var r=_.setUtm(e,a);is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):a.$is_first_time=!1,_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),a.$url=e.path+(a.$url_query?"?"+a.$url_query:""),_.setPageRefData(t),_.isObject(t)&&(a=_.extend(a,t)),sa.track("$MPLaunch",a)},sa.appShow=function(e,t){var a={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(a.$url_path=_.getPath(e.path),a.$title=_.getPageTitle(e.path)),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,a);var r=_.setUtm(e,a);_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),e&&e.path&&(a.$url=e.path+(a.$url_query?"?"+a.$url_query:"")),_.setPageRefData(a,e.path,a.$url_query),_.isObject(t)&&(a=_.extend(a,t)),sa.track("$MPShow",a)},sa.appHide=function(e){var t=(new Date).getTime(),a={};a.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(a.event_duration=(t-mpshow_time)/1e3),_.setPageRefData(a),_.isObject(e)&&(a=_.extend(a,e)),sa.track("$MPHide",a),sendStrategy.onAppHide()},sa.pageShow=function(e){var t={},a=_.getCurrentPath(),r=_.getPageTitle(a),s=_.getCurrentPage();_.setRefPage(),r&&(t.$title=r),t.$url_path=a,t.$url_query=s.sensors_mp_url_query?s.sensors_mp_url_query:"",t=_.extend(t,_.getUtmFromPage()),_.setPageSfSource(t),_.setPageRefData(t),_.isObject(e)&&(t=_.extend(t,e)),sa.track("$MPViewScreen",t)};var oldApp=App;App=function(e){e[sa.para.name]=sa,oldApp.apply(this,arguments)},wx.onAppShow(function(e){if(!deploy_para.launched){var t=wx.getLaunchOptionsSync()||{};sa.autoTrackCustom.appLaunch(t),deploy_para.launched=!0}sa.autoTrackCustom.appShow(e)}),wx.onAppHide(function(){sa.autoTrackCustom.appHide()});var oldPage=Page;Page=function(e){e||(e={});var t=sa.para.autoTrack&&sa.para.autoTrack.mpClick&&_.getMethods(e);if(t)for(var a=0,r=t.length;a0){for(var r=0;r=500&&(sa._.logger.info("\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38"),sa.store.mem.mdata.shift());var t=Date.now();e._flush_time=t,(e=kit.processData(e))&&sa.store.mem.add(e),sa.store.mem.getLength()>=sa.para.batch_send.max_length&&this.batchSend()},wxrequest:function(e){if(sa._.isArray(e.data)&&e.data.length>0){var t=kit.batchTrackData(e.data);sa._.wxrequest({url:sa.para.server_url,method:"POST",dataType:"text",data:t,success:function(){e.success(e.len)},fail:function(){e.fail()}})}else e.success(e.len)},batchSend:function(){if(this.dataHasSend){var e,t,a=sa.store.mem.mdata;(t=(e=a.length>=100?a.slice(0,100):a).length)>0&&(this.dataHasSend=!1,this.wxrequest({data:e,len:t,success:this.batchRemove.bind(this),fail:this.sendFail.bind(this)}))}},sendFail:function(){this.dataHasSend=!0,this.failTime++},batchRemove:function(e){sa.store.mem.clear(e),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite(),this.failTime=0},is_first_batch_write:!0,batchWrite:function(){var e=this;this.dataHasChange&&(this.is_first_batch_write&&(this.is_first_batch_write=!1,setTimeout(function(){e.batchSend()},1e3)),this.dataHasChange=!1,this.syncStorage&&sa._.setStorageSync(sa.para.storage_prepare_data_key,sa.store.mem.mdata))},batchInterval:function(){var e=this;!function t(){setTimeout(function(){e.batchWrite(),t()},500)}(),function t(){setTimeout(function(){e.batchSend(),t()},sa.para.batch_send.send_timeout*Math.pow(2,e.failTime))}()}};function getSendUrl(e,t){var a=kit.onceTrackData(t);return-1!==e.indexOf("?")?e+"&"+a:e+"?"+a}function onceSend(e){e._flush_time=Date.now();var t=getSendUrl(sa.para.server_url,e);sa._.wxrequest({url:t,method:"GET"})}var saEvent={send:function(e,t){if(!sa.para.server_url)return sa._.logger.info("error: server_url \u4e0d\u80fd\u4e3a\u7a7a"),!1;if(sa.current_scene&&1154===sa.current_scene&&!sa.para.preset_events.moments_page)return!1;var a=sa.kit.buildData(e);a?(saEvent.debug(a),sa.events.emit("send",a),sa.para.batch_send?sendStrategy.send(a):onceSend(a)):sa._.logger.info("error: \u6570\u636e\u5f02\u5e38 "+a)},debug:function(e){sa._.logger.info(e)}},_={};sa.kit=kit,sa.mergeStorageData=mergeStorageData,sa.saEvent=saEvent,sa.sendStrategy=sendStrategy,sa.IDENTITY_KEY={EMAIL:"$identity_email",MOBILE:"$identity_mobile"},sa.para={name:"sensors",server_url:"",send_timeout:1e3,show_log:!1,login_id_key:"$identity_login_id",allow_amend_share_path:!0,max_string_length:500,datasend_timeout:3e3,source_channel:[],autoTrack:{appLaunch:!0,appShow:!0,appHide:!0,pageShow:!0,pageShare:!0,mpClick:!1,mpFavorite:!0,pageLeave:!1},autotrack_exclude_page:{pageShow:[]},is_persistent_save:{share:!1,utm:!1},preset_properties:{url_path:!0},preset_events:{moments_page:!1,defer_track:!1,share_info_use_string:!1},batch_send:!0,storage_store_key:"sensorsdata2015_wechat",storage_prepare_data_key:"sensors_mp_prepare_data"};var deploy_para={launched:!1},mpHook={data:1,onLoad:1,onShow:1,onReady:1,onPullDownRefresh:1,onShareAppMessage:1,onShareTimeline:1,onReachBottom:1,onPageScroll:1,onResize:1,onTabItemTap:1,onHide:1,onUnload:1},logger="object"==typeof logger?logger:{};logger.info=function(){if(sa.para.show_log&&"object"==typeof console&&console.log)try{if(3===arguments.length)return console.log(arguments[0],arguments[1],arguments[2]);if(2===arguments.length)return console.log(arguments[0],arguments[1]);if(1===arguments.length)return console.log(arguments[0])}catch(e){console.log(arguments[0])}},sa.setPara=function(e){sa.para=_.extend2Lev(sa.para,e);var t=[];if(_.isArray(sa.para.source_channel))for(var a=sa.para.source_channel.length,r=0;rsa.para.max_string_length?(logger.info("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,sa.para.max_string_length)):e},_.searchObjString=function(e){_.isObject(e)&&_.each(e,function(t,a){_.isObject(t)?_.searchObjString(e[a]):_.isString(t)&&(e[a]=_.formatString(t))})},_.parseSuperProperties=function(e){_.isObject(e)&&(_.each(e,function(t,a){if(_.isFunction(t))try{e[a]=t(),_.isFunction(e[a])&&(logger.info("\u60a8\u7684\u5c5e\u6027- "+a+" \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}catch(t){delete e[a],logger.info("\u60a8\u7684\u5c5e\u6027- "+a+" \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}}),_.strip_sa_properties(e))},_.unique=function(e){for(var t,a=[],r={},s=0;s255)||(logger.info("id \u957f\u5ea6\u8d85\u8fc7 255 \u4e2a\u5b57\u7b26\uff01"),!1)}},_.strip_sa_properties=function(e){return _.isObject(e)?(_.each(e,function(t,a){if(_.isArray(t)){var r=[];_.each(t,function(e){_.isString(e)?r.push(e):logger.info("\u60a8\u7684\u6570\u636e-",t,"\u7684\u6570\u7ec4\u91cc\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32,\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}),e[a]=r}_.isString(t)||_.isNumber(t)||_.isDate(t)||_.isBoolean(t)||_.isArray(t)||(logger.info("\u60a8\u7684\u6570\u636e-",t,"-\u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}),e):e},_.strip_empty_properties=function(e){var t={};return _.each(e,function(e,a){null!=e&&(t[a]=e)}),t},_.utf8Encode=function(e){var t,a,r,s,i="";for(t=a=0,r=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,s=0;s127&&n<2048?String.fromCharCode(n>>6|192,63&n|128):String.fromCharCode(n>>12|224,n>>6&63|128,63&n|128),null!==o&&(a>t&&(i+=e.substring(t,a)),i+=o,t=a=s+1)}return a>t&&(i+=e.substring(t,e.length)),i},_.base64Encode=function(e){var t,a,r,s,i,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,c=0,u="",p=[];if(!e)return e;e=_.utf8Encode(e);do{t=(i=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,a=i>>12&63,r=i>>6&63,s=63&i,p[c++]=n.charAt(t)+n.charAt(a)+n.charAt(r)+n.charAt(s)}while(o255||(r=e.charCodeAt(o++))>255||(s=e.charCodeAt(o++))>255)&&logger.info("Failed to execute 'btoa' : The string to be encoded contains characters outside of the Latin1 range."),n+=i.charAt((t=a<<16|r<<8|s)>>18&63)+i.charAt(t>>12&63)+i.charAt(t>>6&63)+i.charAt(63&t);return _?n.slice(0,_-3)+"===".substring(_):n},_.urlBase64Encode=function(e){return _.btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))},_.rot13obfs=function(e,t){t="number"==typeof t?t:13;for(var a=(e=String(e)).split(""),r=0,s=a.length;r(new Date).getTime()},_.getCurrentUrl=function(e){var t=_.getCurrentPath(),a="";return _.isObject(e)&&e.sensors_mp_encode_url_query&&(a=e.sensors_mp_encode_url_query),t?a?t+"?"+a:t:"\u672a\u53d6\u5230"},_.getPath=function(e){return e="string"==typeof e?e.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"},_.getMethods=function(e){var t=[];for(var a in e)"function"!=typeof e[a]||mpHook[a]||t.push(a);return t},_.isClick=function(e){return!!{tap:1,longpress:1,longtap:1}[e]},sa.initialState={queue:[],isComplete:!1,systemIsComplete:!1,storeIsComplete:!1,checkIsComplete:function(){this.systemIsComplete&&this.storeIsComplete&&(this.isComplete=!0,this.queue.length>0&&(_.each(this.queue,function(e){sa[e[0]].apply(sa,slice.call(e[1]))}),this.queue=[]))}},_.getCustomUtmFromQuery=function(e,t,a,r){if(!_.isObject(e))return{};var s={};if(e.sa_utm)for(var i in e)"sa_utm"!==i?_.include(sa.para.source_channel,i)&&(s[a+i]=e[i]):s[r+i]=e[i];else for(var i in e)-1===(" "+source_channel_standard+" ").indexOf(" "+i+" ")?_.include(sa.para.source_channel,i)&&(s[a+i]=e[i]):s[t+i]=e[i];return s},_.getObjFromQuery=function(e){var t=e.split("?"),a=[],r={};return t&&t[1]?(_.each(t[1].split("&"),function(e){(a=e.split("="))[0]&&a[1]&&(r[a[0]]=a[1])}),r):{}},_.setStorageSync=function(e,t){var a=function(){wx.setStorageSync(e,t)};try{a()}catch(e){logger.info("set Storage fail --",e);try{a()}catch(e){logger.info("set Storage fail again --",e)}}},_.getStorageSync=function(e){var t="";try{t=wx.getStorageSync(e)}catch(a){try{t=wx.getStorageSync(e)}catch(e){logger.info("getStorage fail")}}return t},_.getMPScene=function(e){return"number"==typeof e||"string"==typeof e&&""!==e?e="wx-"+String(e):"\u672a\u53d6\u5230\u503c"},_.objToParam=function(e,t){if("[object Object]"!==Object.prototype.toString.call(e))return logger.info("\u8bf7\u4f20\u5165\u6709\u6548\u5bf9\u8c61"),"";var a=[];for(var r in e)if(e.hasOwnProperty(r)){var s=e[r];void 0===s?a.push(r+"="):(s=t?encodeURIComponent(s):s,a.push(r+"="+s))}return a.join("&")},_.delObjectKey=function(e){if("[object Object]"===Object.prototype.toString.call(e))for(var t=0;t=2?(page_route_map.shift(),page_route_map.push(e)):page_route_map.push(e)}}catch(e){logger.info(e)}},_.getRefPage=function(){var e={route:"\u76f4\u63a5\u6253\u5f00",title:""};return page_route_map.length>1&&(e.title=page_route_map[0].title,e.route=page_route_map[0].route),e},_.getCurrentPageInfo=function(){var e=_.getCurrentPage(),t={title:"",url:""};if(e&&e.route){var a=e.sensors_mp_url_query?"?"+e.sensors_mp_url_query:"";t.title=_.getPageTitle(e.route),t.url=e.route+a}return t},_.setPageRefData=function(e,t,a){var r=_.getRefPage();_.isObject(e)&&(t?page_route_map.length>0&&t?(a=a?"?"+a:"",e.$referrer=_.getPath(t)+a,e.$referrer_title=_.getPageTitle(t)):(e.$referrer="\u76f4\u63a5\u6253\u5f00",e.$referrer_title=""):(e.$referrer=r.route,e.$referrer_title=r.title))},_.getPageTitle=function(e){if("\u672a\u53d6\u5230"===e||!e)return"";var t="";try{if(__wxConfig){var a=__wxConfig,r=__wxConfig.page||{},s=r[e]||r[e+".html"],i={},n={};if(a.global&&a.global.window&&a.global.window.navigationBarTitleText&&(i.titleVal=a.global.window.navigationBarTitleText),s&&s.window&&s.window.navigationBarTitleText&&(n.titleVal=s.window.navigationBarTitleText),!n.titleVal&&__wxAppCode__){var o=__wxAppCode__[e+".json"];o&&o.navigationBarTitleText&&(n.titleVal=o.navigationBarTitleText)}if(_.each(globalTitle,function(a,r){if(r===e)return t=a}),0===t.length){var c=_.extend(i,n);t=c.titleVal||""}}}catch(e){logger.info(e)}return t},_.wxrequest=function(e){if(_.compareSDKVersion(wxSDKVersion,"2.10.0")>=0)e.timeout=sa.para.datasend_timeout,wx.request(e);else{var t=wx.request(e);setTimeout(function(){_.isObject(t)&&_.isFunction(t.abort)&&t.abort()},sa.para.datasend_timeout)}},_.getAppInfoSync=function(){if(wx.getAccountInfoSync){var e=wx.getAccountInfoSync(),t=e&&e.miniProgram?e.miniProgram:{};return{appId:t.appId,appEnv:t.envVersion,appVersion:t.version}}return{}},_.getAppId=function(){var e=_.getAppInfoSync();return e&&e.appId?e.appId:""},_.validId=function(e){return"string"!=typeof e&&"number"!=typeof e||""===e?(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1):"number"!=typeof e||(e=String(e),/^\d+$/.test(e))?!!_.check.ckeckIdLength(e)&&e:(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1)},_.compareSDKVersion=function(e,t){e=e.split("."),t=t.split(".");for(var a=Math.max(e.length,t.length);e.lengthi)return 1;if(s-1?t.system.split(" ")[1]:t.system,wxSDKVersion=t.SDKVersion,e.$mp_client_app_version=t.version,e.$mp_client_basic_library_version=wxSDKVersion},complete:function(){var t=(new Date).getTimezoneOffset(),a=_.getAppInfoSync();_.isNumber(t)&&(e.$timezone_offset=t),a.appId&&(e.$app_id=a.appId),a.appVersion&&(e.$app_version=a.appVersion),sa.initialState.systemIsComplete=!0,sa.initialState.checkIsComplete()}})}wx.getNetworkType({success:function(t){e.$network_type=_.setUpperCase(t.networkType)},complete:t})}},sa._=_,_.eventEmitter=function(){this.sub=[]},_.eventEmitter.prototype={add:function(e){this.sub.push(e)},emit:function(e,t){this.sub.forEach(function(a){a.on(e,t)})}},_.eventSub=function(e){sa.events.add(this),this._events=[],this.handle=e,this.ready=!1},_.eventSub.prototype={on:function(e,t){if(this.ready){if(_.isFunction(this.handle))try{this.handle(e,t)}catch(e){logger.info(e)}}else this._events.push({event:e,data:t})},isReady:function(){var e=this;e.ready=!0,e._events.forEach(function(t){if(_.isFunction(e.handle))try{e.handle(t.event,t.data)}catch(e){logger.info(e)}})}},sa.eventSub=_.eventSub,sa.events=new _.eventEmitter,sa.usePlugin=function(e,t){"function"==typeof e.init&&e.init(sa,t)},sa.store={storageInfo:null,getUUID:function(){return Date.now()+"-"+Math.floor(1e7*getRandom())+"-"+getRandom().toString(16).replace(".","")+"-"+String(31242*getRandom()).replace(".","").slice(0,8)},getStorage:function(){return this.storageInfo?this.storageInfo:(this.storageInfo=sa._.getStorageSync(sa.para.storage_store_key)||"",this.storageInfo)},_state:{},mem:{mdata:[],getLength:function(){return this.mdata.length},add:function(e){this.mdata.push(e)},clear:function(e){this.mdata.splice(0,e)}},toState:function(e){var t=null;_.isJSONString(e)?(t=JSON.parse(e)).distinct_id?this._state=t:this.set("distinct_id",this.getUUID()):_.isObject(e)&&(t=e).distinct_id?this._state=t:this.set("distinct_id",this.getUUID());var a=this._state._first_id||this._state.first_id,r=this._state._distinct_id||this._state.distinct_id,s=this._state.openid,i=(this._state.history_login_id?this._state.history_login_id:{}).name;if(this._state.identities&&_.isString(this._state.identities)){var n=JSON.parse(_.rot13defs(this._state.identities));this._state.identities=n}if(this._state.identities&&_.isObject(this._state.identities)&&!_.isEmptyObject(this._state.identities)?this._state.identities.hasOwnProperty("$identity_anonymous_id")&&(this._state.identities.$identity_anonymous_id=a||r):(this._state.identities={},this._state.identities.$mp_id=this.getUUID(),this._state.identities.$identity_anonymous_id=a||r),s){var o=_.getOpenidNameByAppid();this._state.identities[o]=s}if(a)if(i&&this._state.identities.hasOwnProperty(i)){if(this._state.identities[i]!==r){for(var c in this._state.identities[i]=r,this._state.identities)this._state.identities.hasOwnProperty(c)&&"$mp_id"!==c&&c!==i&&delete this._state.identities[c];this._state.history_login_id.value=r}}else{for(var c in this._state.identities[sa.para.login_id_key]=r,this._state.identities)this._state.identities.hasOwnProperty(c)&&"$mp_id"!==c&&c!==sa.para.login_id_key&&delete this._state.identities[c];this._state.history_login_id={name:sa.para.login_id_key,value:r}}else{if(this._state.identities.hasOwnProperty("$identity_login_id")||this._state.identities.hasOwnProperty(i))for(var c in this._state.identities)this._state.identities.hasOwnProperty(c)&&"$mp_id"!==c&&"$identity_anonymous_id"!==c&&delete this._state.identities[c];this._state.history_login_id={name:"",value:""}}this.save()},getFirstId:function(){return this._state._first_id||this._state.first_id},getDistinctId:function(){return this._state._distinct_id||this._state.distinct_id},getUnionId:function(){var e={},t=this._state._first_id||this._state.first_id,a=this._state._distinct_id||this._state.distinct_id;return t&&a?(e.login_id=a,e.anonymous_id=t):e.anonymous_id=a,e},getProps:function(){return this._state.props||{}},setProps:function(e,t){var a=this._state.props||{};t?this.set("props",e):(_.extend(a,e),this.set("props",a))},set:function(e,t){var a={};for(var r in"string"==typeof e?a[e]=t:"object"==typeof e&&(a=e),this._state=this._state||{},a)this._state[r]=a[r],"first_id"===r?delete this._state._first_id:"distinct_id"===r&&(delete this._state._distinct_id,sa.events.emit("changeDistinctId"));this.save()},identitiesSet:function(e,t){var a={};switch(e){case"login":a.$mp_id=sa.store._state.identities.$mp_id,a[sa.para.login_id_key]=t;break;case"logout":a.$mp_id=sa.store._state.identities.$mp_id;break;case"identify":(a=_.deepCopy(sa.store._state.identities)).$identity_anonymous_id=t}sa.store.set("identities",a)},change:function(e,t){this._state["_"+e]=t},encryptStorage:function(){var e=this.getStorage(),t="data:enc;";_.isObject(e)?e=t+_.rot13obfs(JSON.stringify(e)):_.isString(e)&&-1===e.indexOf(t)&&(e=t+_.rot13obfs(e)),sa._.setStorageSync(sa.para.storage_store_key,e)},save:function(){var e=_.deepCopy(this._state),t=_.rot13obfs(JSON.stringify(e.identities));if(e.identities=t,delete e._first_id,delete e._distinct_id,sa.para.encrypt_storage){e="data:enc;"+_.rot13obfs(JSON.stringify(e))}sa._.setStorageSync(sa.para.storage_store_key,e)},init:function(){var e=this.getStorage();if(e)_.isString(e)&&-1!==e.indexOf("data:enc;")&&(e=e.substring("data:enc;".length),e=JSON.parse(_.rot13defs(e))),this.toState(e);else{is_first_launch=!0;var t=new Date,a=t.getTime();t.setHours(23),t.setMinutes(59),t.setSeconds(60),sa.setOnceProfile({$first_visit_time:new Date}),this.set({distinct_id:this.getUUID(),first_visit_time:a,first_visit_day_time:t.getTime(),identities:{$mp_id:this.getUUID()},history_login_id:{name:"",value:""}})}}},sa.setProfile=function(e,t){sa.saEvent.send({type:"profile_set",properties:e},t)},sa.setOnceProfile=function(e,t){sa.saEvent.send({type:"profile_set_once",properties:e},t)},sa.appendProfile=function(e,t){if(!_.isObject(e))return!1;_.each(e,function(t,a){_.isString(t)?e[a]=[t]:(delete e[a],logger.info("appendProfile\u5c5e\u6027\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32\u6216\u8005\u6570\u7ec4"))}),sa.saEvent.send({type:"profile_append",properties:e},t)},sa.incrementProfile=function(e,t){if(!_.isObject(e))return!1;var a=e;_.isString(e)&&((e={})[a]=1),sa.saEvent.send({type:"profile_increment",properties:e},t)},sa.track=function(e,t,a){this.saEvent.send({type:"track",event:e,properties:t},a)},sa.identify=function(e,t){if(e=_.validId(e)){var a=sa.store.getFirstId();!0===t?a?sa.store.set("first_id",e):sa.store.set("distinct_id",e):a?sa.store.change("first_id",e):sa.store.change("distinct_id",e),sa.store.identitiesSet("identify",e)}},sa.trackSignup=function(e,t,a,r){var s=sa.store.getFirstId()||sa.store.getDistinctId();sa.store.set("distinct_id",e),sa.saEvent.send({original_id:s,distinct_id:e,type:"track_signup",event:t,properties:a},r)},sa.registerApp=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&(_.info.currentProps=_.extend(_.info.currentProps,e))},sa.register=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&sa.store.setProps(e)},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.clearAllProps=function(e){var t=sa.store.getProps(),a={};_.isArray(e)&&(_.each(t,function(t,r){_.include(e,r)||(a[r]=t)}),sa.store.setProps(a,!0))},sa.clearAppRegister=function(e){_.isArray(e)&&_.each(_.info.currentProps,function(t,a){_.include(e,a)&&delete _.info.currentProps[a]})},_.setLatestChannel=function(e){_.isEmptyObject(e)||(function(e,t){var a=!1;for(var r in t)e[t[r]]&&(a=!0);return a}(e,latest_source_channel)&&(sa.clearAppRegister(latest_source_channel),sa.clearAllProps(latest_source_channel)),sa.para.is_persistent_save.utm?sa.register(e):sa.registerApp(e))},_.setLatestShare=function(e){(e.$latest_share_depth||e.$latest_share_distinct_id||e.$latest_share_url_path||e.$latest_share_method)&&(sa.clearAppRegister(latest_share_info),sa.clearAllProps(latest_share_info),sa.para.is_persistent_save.share?sa.register(e):sa.registerApp(e))},sa.login=function(e){if(e=_.validId(e)){var t=sa.store.getFirstId(),a=sa.store.getDistinctId();if(sa.store._state.identities.hasOwnProperty(sa.para.login_id_key)&&e===t)return!1;var r=!(sa.para.login_id_key===sa.store._state.history_login_id.name&&sa.store._state.history_login_id.value===e);r&&(sa.store._state.identities[sa.para.login_id_key]=e),r&&(t?sa.trackSignup(e,"$SignUp"):(sa.store.set("first_id",a),sa.trackSignup(e,"$SignUp"))),r&&(sa.store.identitiesSet("login",e),sa.store.set("history_login_id",{name:sa.para.login_id_key,value:e}))}},sa.getAnonymousID=function(){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")},sa.logout=function(e){var t=sa.store.getFirstId();t?(sa.store.set("first_id",""),!0===e?sa.store.set("distinct_id",sa.store.getUUID()):sa.store.set("distinct_id",t)):logger.info("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25"),sa.store.identitiesSet("logout"),sa.store.set("history_login_id",{name:"",value:""})},sa.getLocation=function(){wx.getSetting({success:function(e){if(!e.authSetting["scope.userLocation"])return!1;wx.getLocation({type:sa.para.preset_properties.location.type,success:function(e){sa.registerApp({$latitude:e.latitude*Math.pow(10,6),$longitude:e.longitude*Math.pow(10,6),$geo_coordinate_system:_.setUpperCase(sa.para.preset_properties.location.type)})},fail:function(e){logger.info("\u83b7\u53d6\u4f4d\u7f6e\u5931\u8d25",e)}})}})},sa.openid={getRequest:function(e){wx.login({success:function(t){t.code&&sa.para.appid&&sa.para.openid_url?_.wxrequest({url:sa.para.openid_url+"&code="+t.code+"&appid="+sa.para.appid,method:"GET",complete:function(t){_.isObject(t)&&_.isObject(t.data)&&t.data.openid?e(t.data.openid):e()}}):e()}})},getWXStorage:function(){var e=sa.store.getStorage();if(e&&_.isObject(e))return e.openid},getOpenid:function(e){if(!sa.para.appid)return e(),!1;var t=this.getWXStorage();t?e(t):this.getRequest(e)}},sa.initial=function(){this._.info.getSystem(),this.store.init()},sa.init=function(e){if(!0===this.hasInit)return!1;this.hasInit=!0,sa.setPara(e),sa.para.encrypt_storage&&this.store.encryptStorage(),sa.para.batch_send&&sendStrategy.init(),sa.initialState.storeIsComplete=!0,sa.initialState.checkIsComplete()},sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib){var e={};_.each(_.info.currentProps,function(t,a){0===a.indexOf("$")&&(e[a]=t)});var t=_.extend(e,{$url_path:_.getCurrentPath(),$is_first_day:_.getIsFirstDay()},_.info.properties,sa.store.getProps());return delete t.$lib,t}return{}},sa.setOpenid=function(e,t){if(!(e=_.validId(e)))return!1;var a=sa.store.getFirstId();sa.store.set("openid",e),t?sa.store.set("distinct_id",e):(sa.identify(e,!0),a?sa.store.set("first_id",e):sa.store.set("distinct_id",e)),sa.bind("$mp_openid",e)},sa.unsetOpenid=function(e){var t=_.validId(e);if(!t)return!1;sa.store._state.openid===t&&sa.store.set("openid",""),sa.unbind("$mp_openid",t)},sa.setUnionid=function(e){var t=_.validId(e);t&&sa.bind("$mp_unionid",t)},sa.unsetUnionid=function(e){var t=_.validId(e);if(t){if(sa.store._state.identities.hasOwnProperty("$mp_unionid")&&t===sa.store._state.identities.$mp_unionid){var a=_.getOpenidNameByAppid();sa.store._state.identities.hasOwnProperty(a)&&(delete sa.store._state.identities[a],sa.store.save())}sa.unbind("$mp_unionid",t)}},sa.initWithOpenid=function(e,t){(e=e||{}).appid&&(sa.para.appid=e.appid),sa.openid.getOpenid(function(a){a&&sa.setOpenid(a,e.isCoverLogin),t&&_.isFunction(t)&&t(a),sa.init(e)})},sa.bind=function(e,t){if(_.isNumber(t)){if(_.isInteger(t)&&!1===_.isSafeInteger(t))return logger.info("Value must be String"),!1;t=String(t)}if(!_.isString(e))return logger.info("Key must be String"),!1;if(!_.check.checkKeyword(e)||"$identity_anonymous_id"===e||"$mp_id"===e||"$identity_login_id"===e||e===sa.para.login_id_key){var a="Key ["+e+"] is invalid";return logger.info(a),!1}if(!t||""===t)return logger.info("Value is empty or null"),!1;if(!_.isString(t))return logger.info("Value must be String"),!1;if(!_.check.ckeckIdLength(t)){a="Value ["+t+"] is beyond the maximum length 255";return logger.info(a),!1}var r=sa.store._state.identities;"$mp_openid"===e&&(e=_.getOpenidNameByAppid()),r[e]=t,sa.store.save(),sa.saEvent.send({type:"track_id_bind",event:"$BindID"})},sa.unbind=function(e,t){if(_.isNumber(t)){if(_.isInteger(t)&&!1===_.isSafeInteger(t))return logger.info("Value must be String"),!1;t=String(t)}if(!_.isString(e))return logger.info("Key must be String"),!1;if(!_.check.checkKeyword(e)||"$identity_anonymous_id"===e||"$mp_id"===e||"$identity_login_id"===e||e===sa.para.login_id_key){var a="Key ["+e+"] is invalid";return logger.info(a),!1}if(!t||""===t)return logger.info("Value is empty or null"),!1;if(!_.isString(t))return logger.info("Value must be String"),!1;if(!_.check.ckeckIdLength(t)){a="Value ["+t+"] is beyond the maximum length 255";return logger.info(a),!1}"$mp_openid"===e&&(e=_.getOpenidNameByAppid()),sa.store._state.identities.hasOwnProperty(e)&&t===sa.store._state.identities[e]&&(delete sa.store._state.identities[e],sa.store.save());var r={};r[e]=t,sa.saEvent.send({type:"track_id_unbind",event:"$UnbindID",unbind_value:r})},sa.setWebViewUrl=function(e,t){if(!_.isString(e)||""===e)return logger.info("error:\u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;if(!/^http(s)?:\/\//.test(e))return logger.info("warning: \u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;var a=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e);if(!a)return!1;var r,s=a[1]||"",i=a[2]||"",n=a[3]||"",o="",c=sa.store.getDistinctId()||"",u=sa.store.getFirstId()||"";_.urlSafeBase64&&_.urlSafeBase64.encode?c=c?_.urlSafeBase64.trim(_.urlSafeBase64.encode(_.urlBase64Encode(c))):"":this._.rot13obfs&&(c=c?_.rot13obfs(c):""),c=encodeURIComponent(c);var p=u?"f"+c:"d"+c;t?(r=n.indexOf("_sasdk"),o=n.indexOf("?")>-1?r>-1?s+i+"#"+n.substring(1,r)+"_sasdk="+p:s+i+"#"+n.substring(1)+"&_sasdk="+p:s+i+"#"+n.substring(1)+"?_sasdk="+p):(r=i.indexOf("_sasdk"),o=/^\?(\w)+/.test(i)?r>-1?s+i.replace(/(_sasdk=)([^&]*)/gi,"_sasdk="+p)+n:s+"?"+i.substring(1)+"&_sasdk="+p+n:s+"?"+i.substring(1)+"_sasdk="+p+n);return o},_.each(["setProfile","setOnceProfile","track","quick","incrementProfile","appendProfile","login","logout","registerApp","register","clearAllRegister","clearAllProps","clearAppRegister","bind","unbind"],function(e){var t=sa[e];sa[e]=function(){sa.initialState.isComplete?t.apply(sa,arguments):sa.initialState.queue.push([e,arguments])}}),_.setQuery=function(e,t){if(e&&_.isObject(e)&&!_.isEmptyObject(e)){var a=[];return _.each(e,function(e,r){"q"===r&&_.isString(e)&&0===e.indexOf("http")||(t?a.push(r+"="+e):a.push(r+"="+_.decodeURIComponent(e)))}),a.join("&")}return""},_.getUtmFromPage=function(){var e={};try{var t=_.getCurrentPage(),a=_.deepCopy(t.options);for(var r in a)a[r]=_.decodeURIComponent(a[r]);e=_.getCustomUtmFromQuery(a,"$","_","$")}catch(e){logger.info(e)}return e},_.sendPageLeave=function(){var e={},t="";try{t=(e=_.getCurrentPage())?e.route:""}catch(e){logger.info(e)}if(page_show_time>=0&&""!==t){var a={},r=_.getPageTitle(t),s=(Date.now()-page_show_time)/1e3;a.$url_query=e.sensors_mp_url_query?e.sensors_mp_url_query:"",a.$url_path=t,a.$title=r,a.event_duration=s,sa.track("$MPPageLeave",a),page_show_time=-1}};{var mp_proxy=function(e,t,a){var r=sa.autoTrackCustom[a];if(e[t]){var s=e[t];e[t]=function(){"onLaunch"===t&&(this[sa.para.name]=sa),!sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&!sa.para.autoTrackIsFirst[a]?(s.apply(this,arguments),r.apply(this,arguments)):(!0===sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&sa.para.autoTrackIsFirst[a])&&(r.apply(this,arguments),s.apply(this,arguments))}}else e[t]=function(){"onLaunch"===t&&(this[sa.para.name]=sa),r.apply(this,arguments)}};function clickTrack(e){var t,a={},r={},s=e.currentTarget||{},i=e.target||{};if(_.isObject(sa.para.framework)&&_.isObject(sa.para.framework.taro)&&!sa.para.framework.taro.createApp&&i.id&&s.id&&i.id!==s.id)return!1;var n=s.dataset||{};if(t=e.type,a.$element_id=s.id,a.$element_type=n.type,a.$element_content=n.content,a.$element_name=n.name,_.isObject(e.event_prop)&&(r=e.event_prop),t&&_.isClick(t)){if(sa.para.preset_events&&sa.para.preset_events.collect_element&&!1===sa.para.preset_events.collect_element(arguments[0]))return!1;a.$url_path=_.getCurrentPath(),_.setPageRefData(a),a=_.extend(a,r),sa.track("$MPClick",a)}}var click_proxy=function(e,t){var a=e[t];e[t]=function(){var e=a.apply(this,arguments),t=arguments[0];return _.isObject(t)&&(sa.para.preset_events.defer_track?setTimeout(function(){clickTrack(t)},0):clickTrack(t)),e}},tabProxy=function(e){var t=e.onTabItemTap;e.onTabItemTap=function(e){t&&t.apply(this,arguments);var a={};e&&(a.$element_content=e.text),a.$element_type="tabBar",a.$url_path=_.getCurrentPath(),_.setPageRefData(a),sa.track("$MPClick",a)}},pageLeaveProxy=function(e){var t=e.onHide;e.onHide=function(){t&&t.apply(this,arguments),_.sendPageLeave()};var a=e.onUnload;e.onUnload=function(){a&&a.apply(this,arguments),_.sendPageLeave()}}}if(sa.autoTrackCustom={trackCustom:function(e,t,a){var r=sa.para.autoTrack[e],s="";sa.para.autoTrack&&r&&("function"==typeof r?(s=r(),_.isObject(s)&&_.extend(t,s)):_.isObject(r)&&(_.extend(t,r),sa.para.autoTrack[e]=!0),sa.track(a,t))},appLaunch:function(e,t){"object"!=typeof this||this.trackCustom||(this[sa.para.name]=sa);var a={};if(e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path){if(a.$url_path=_.getPath(e.path),a.$title=_.getPageTitle(e.path),e.query&&_.isObject(e.query)){var r=_.setQuery(e.query);r=r?"?"+r:"",a.$url=a.$url_path+r}!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})}_.setShareInfo(e,a);var s=_.setUtm(e,a);is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(s.pre1)||sa.setOnceProfile(s.pre1)):a.$is_first_time=!1,_.setLatestChannel(s.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),_.setPageRefData(a),t?(a=_.extend(a,t),sa.track("$MPLaunch",a)):sa.para.autoTrack&&sa.para.autoTrack.appLaunch&&sa.autoTrackCustom.trackCustom("appLaunch",a,"$MPLaunch")},appShow:function(e,t){var a={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(a.$url_path=_.getPath(e.path),a.$title=_.getPageTitle(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,a);var r=_.setUtm(e,a);_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),_.setPageRefData(a,e.path,a.$url_query),e&&e.path&&(a.$url=e.path+(a.$url_query?"?"+a.$url_query:"")),t?(a=_.extend(a,t),sa.track("$MPShow",a)):sa.para.autoTrack&&sa.para.autoTrack.appShow&&sa.autoTrackCustom.trackCustom("appShow",a,"$MPShow")},appHide:function(e){var t=(new Date).getTime(),a={};a.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(a.event_duration=(t-mpshow_time)/1e3),_.setPageRefData(a),e?(a=_.extend(a,e),sa.track("$MPHide",a)):sa.para.autoTrack&&sa.para.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",a,"$MPHide"),sendStrategy.onAppHide()},pageLoad:function(e){current_scene&&1010===current_scene&&e&&(e.sampshare&&delete e.sampshare,_.delObjectKey(e)),e&&_.isObject(e)&&(this.sensors_mp_url_query=_.setQuery(e),this.sensors_mp_encode_url_query=_.setQuery(e,!0))},pageShow:function(){page_show_time=Date.now();var e={},t=_.getCurrentPath(),a=_.getPageTitle(t);_.setRefPage(),e.$url_path=t,e.$url_query=this.sensors_mp_url_query?this.sensors_mp_url_query:"",e=_.extend(e,_.getUtmFromPage()),_.setPageRefData(e),_.setPageSfSource(e),a&&(e.$title=a),sa.para.onshow?sa.para.onshow(sa,t,this):_.isObject(sa.para.autotrack_exclude_page)&&_.isArray(sa.para.autotrack_exclude_page.pageShow)&&-1!==sa.para.autotrack_exclude_page.pageShow.indexOf(t)||sa.autoTrackCustom.trackCustom("pageShow",e,"$MPViewScreen"),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:t})},pageShare:function(e){var t=e.onShareAppMessage;e.onShareAppMessage=function(){share_method="\u8f6c\u53d1\u6d88\u606f\u5361\u7247";var e=t.apply(this,arguments);if(sa.para.autoTrack&&sa.para.autoTrack.pageShare){var a={$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method};_.setPageRefData(a),sa.autoTrackCustom.trackCustom("pageShare",a,"$MPShare")}return sa.para.allow_amend_share_path&&("object"!=typeof e&&((e={}).path=_.getCurrentUrl(this)),"object"!=typeof e||void 0!==e.path&&""!==e.path||(e.path=_.getCurrentUrl(this)),"object"==typeof e&&"string"==typeof e.path&&(-1===e.path.indexOf("?")?e.path=e.path+"?":"&"!==e.path.slice(-1)&&(e.path=e.path+"&")),e.path=e.path+_.getShareInfo()),e}},pageShareTimeline:function(e){var t=e.onShareTimeline;e.onShareTimeline=function(){share_method="\u670b\u53cb\u5708\u5206\u4eab";var e=t.apply(this,arguments);if(sa.para.autoTrack&&sa.para.autoTrack.pageShare){var a={$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method};_.setPageRefData(a),sa.autoTrackCustom.trackCustom("pageShare",a,"$MPShare")}return sa.para.allow_amend_share_path&&("object"!=typeof e&&(e={}),"object"==typeof e&&void 0===e.query&&(e.query=""),"object"==typeof e&&"string"==typeof e.query&&""!==e.query&&"&"!==e.query.slice(-1)&&(e.query=e.query+"&"),e.query=e.query+_.getShareInfo()),e}},pageAddFavorites:function(){var e={};e.$url_path=_.getCurrentPath(),sa.para.autoTrack&&sa.para.autoTrack.mpFavorite&&sa.autoTrackCustom.trackCustom("mpFavorite",e,"$MPAddFavorites")}},sa.quick=function(){var e=arguments[0],t=arguments[1],a=arguments[2],r=_.isObject(a)?a:{};if("getAnonymousID"===e){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===e||"appShow"===e?t?sa.autoTrackCustom[e](t,r):logger.info("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(r=_.isObject(t)?t:{},sa.autoTrackCustom[e](r))},sa.appLaunch=function(e,t){var a={};e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(a.$url_path=_.getPath(e.path),a.$title=_.getPageTitle(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),_.setShareInfo(e,a);var r=_.setUtm(e,a);is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):a.$is_first_time=!1,_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),a.$url=e.path+(a.$url_query?"?"+a.$url_query:""),_.setPageRefData(t),_.isObject(t)&&(a=_.extend(a,t)),sa.track("$MPLaunch",a)},sa.appShow=function(e,t){var a={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(a.$url_path=_.getPath(e.path),a.$title=_.getPageTitle(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,a);var r=_.setUtm(e,a);_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),e&&e.path&&(a.$url=e.path+(a.$url_query?"?"+a.$url_query:"")),_.setPageRefData(a,e.path,a.$url_query),_.isObject(t)&&(a=_.extend(a,t)),sa.track("$MPShow",a)},sa.appHide=function(e){var t=(new Date).getTime(),a={};a.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(a.event_duration=(t-mpshow_time)/1e3),_.setPageRefData(a),_.isObject(e)&&(a=_.extend(a,e)),sa.track("$MPHide",a),sendStrategy.onAppHide()},sa.pageShow=function(e){var t={},a=_.getCurrentPath(),r=_.getPageTitle(a),s=_.getCurrentPage();_.setRefPage(),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a}),r&&(t.$title=r),t.$url_path=a,t.$url_query=s.sensors_mp_url_query?s.sensors_mp_url_query:"",t=_.extend(t,_.getUtmFromPage()),_.setPageSfSource(t),_.setPageRefData(t),_.isObject(e)&&(t=_.extend(t,e)),sa.track("$MPViewScreen",t)},sa.App=function(e){(e=e||{})[sa.para.name]=sa,App.apply(this,arguments)},wx.onAppShow(function(e){if(!deploy_para.launched){var t=wx.getLaunchOptionsSync()||{};sa.autoTrackCustom.appLaunch(t),deploy_para.launched=!0}sa.autoTrackCustom.appShow(e)}),wx.onAppHide(function(){sa.autoTrackCustom.appHide()}),sa.Page=function(e){var t=sa.para.autoTrack&&sa.para.autoTrack.mpClick&&_.getMethods(e);if(t)for(var a=0,r=t.length;a0){for(var r=0;r=500&&(sa._.logger.info("\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38"),sa.store.mem.mdata.shift()),(e=kit.processData(e))&&sa.store.mem.add(e),sa.store.mem.getLength()>=sa.para.batch_send.max_length&&this.batchSend()},wxrequest:function(e){if(sa._.isArray(e.data)&&e.data.length>0){var t=kit.batchTrackData(e.data);sa._.wxrequest({url:sa.para.server_url,method:"POST",dataType:"text",data:t,success:function(){e.success(e.len)},fail:function(){e.fail()}})}else e.success(e.len)},batchSend:function(){if(this.dataHasSend){var e,t,a=sa.store.mem.mdata;(t=(e=a.length>=100?a.slice(0,100):a).length)>0&&(this.dataHasSend=!1,this.wxrequest({data:e,len:t,success:this.batchRemove.bind(this),fail:this.sendFail.bind(this)}))}},sendFail:function(){this.dataHasSend=!0,this.failTime++},batchRemove:function(e){sa.store.mem.clear(e),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite(),this.failTime=0},is_first_batch_write:!0,batchWrite:function(){var e=this;this.dataHasChange&&(this.is_first_batch_write&&(this.is_first_batch_write=!1,setTimeout(function(){e.batchSend()},1e3)),this.dataHasChange=!1,this.syncStorage&&sa._.setStorageSync(sa.para.storage_prepare_data_key,sa.store.mem.mdata))},batchInterval:function(){var e=this;!function t(){setTimeout(function(){e.batchWrite(),t()},500)}(),function t(){setTimeout(function(){e.batchSend(),t()},sa.para.batch_send.send_timeout*Math.pow(2,e.failTime))}()}};function getSendUrl(e,t){var a=kit.onceTrackData(t);return-1!==e.indexOf("?")?e+"&"+a:e+"?"+a}function onceSend(e){e._flush_time=Date.now();var t=getSendUrl(sa.para.server_url,e);sa._.wxrequest({url:t,method:"GET"})}var saEvent={send:function(e,t){if(!sa.para.server_url)return sa._.logger.info("error: server_url \u4e0d\u80fd\u4e3a\u7a7a"),!1;if(sa.current_scene&&1154===sa.current_scene&&!sa.para.preset_events.moments_page)return!1;var a=sa.kit.buildData(e);a?(saEvent.debug(a),sa.events.emit("send",a),sa.para.batch_send?sendStrategy.send(a):onceSend(a)):sa._.logger.info("error: \u6570\u636e\u5f02\u5e38 "+a)},debug:function(e){sa._.logger.info(e)}},_={};sa.kit=kit,sa.mergeStorageData=mergeStorageData,sa.saEvent=saEvent,sa.sendStrategy=sendStrategy,sa.IDENTITY_KEY={EMAIL:"$identity_email",MOBILE:"$identity_mobile"},sa.para={name:"sensors",server_url:"",send_timeout:1e3,show_log:!1,login_id_key:"$identity_login_id",allow_amend_share_path:!0,max_string_length:500,datasend_timeout:3e3,source_channel:[],autoTrack:{appLaunch:!0,appShow:!0,appHide:!0,pageShow:!0,pageShare:!0,mpClick:!1,mpFavorite:!0,pageLeave:!1},autotrack_exclude_page:{pageShow:[]},is_persistent_save:{share:!1,utm:!1},preset_properties:{url_path:!0},preset_events:{moments_page:!1,defer_track:!1,share_info_use_string:!1},batch_send:!0,storage_store_key:"sensorsdata2015_wechat",storage_prepare_data_key:"sensors_mp_prepare_data"};var deploy_para={launched:!1},mpHook={data:1,onLoad:1,onShow:1,onReady:1,onPullDownRefresh:1,onShareAppMessage:1,onShareTimeline:1,onReachBottom:1,onPageScroll:1,onResize:1,onTabItemTap:1,onHide:1,onUnload:1},logger="object"==typeof logger?logger:{};logger.info=function(){if(sa.para.show_log&&"object"==typeof console&&console.log)try{if(3===arguments.length)return console.log(arguments[0],arguments[1],arguments[2]);if(2===arguments.length)return console.log(arguments[0],arguments[1]);if(1===arguments.length)return console.log(arguments[0])}catch(e){console.log(arguments[0])}},sa.setPara=function(e){sa.para=_.extend2Lev(sa.para,e);var t=[];if(_.isArray(sa.para.source_channel))for(var a=sa.para.source_channel.length,r=0;rsa.para.max_string_length?(logger.info("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,sa.para.max_string_length)):e},_.searchObjString=function(e){_.isObject(e)&&_.each(e,function(t,a){_.isObject(t)?_.searchObjString(e[a]):_.isString(t)&&(e[a]=_.formatString(t))})},_.parseSuperProperties=function(e){_.isObject(e)&&(_.each(e,function(t,a){if(_.isFunction(t))try{e[a]=t(),_.isFunction(e[a])&&(logger.info("\u60a8\u7684\u5c5e\u6027- "+a+" \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}catch(t){delete e[a],logger.info("\u60a8\u7684\u5c5e\u6027- "+a+" \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}}),_.strip_sa_properties(e))},_.unique=function(e){for(var t,a=[],r={},s=0;s255)||(logger.info("id \u957f\u5ea6\u8d85\u8fc7 255 \u4e2a\u5b57\u7b26\uff01"),!1)}},_.strip_sa_properties=function(e){return _.isObject(e)?(_.each(e,function(t,a){if(_.isArray(t)){var r=[];_.each(t,function(e){_.isString(e)?r.push(e):logger.info("\u60a8\u7684\u6570\u636e-",t,"\u7684\u6570\u7ec4\u91cc\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32,\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}),e[a]=r}_.isString(t)||_.isNumber(t)||_.isDate(t)||_.isBoolean(t)||_.isArray(t)||(logger.info("\u60a8\u7684\u6570\u636e-",t,"-\u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}),e):e},_.strip_empty_properties=function(e){var t={};return _.each(e,function(e,a){null!=e&&(t[a]=e)}),t},_.utf8Encode=function(e){var t,a,r,s,i="";for(t=a=0,r=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,s=0;s127&&n<2048?String.fromCharCode(n>>6|192,63&n|128):String.fromCharCode(n>>12|224,n>>6&63|128,63&n|128),null!==o&&(a>t&&(i+=e.substring(t,a)),i+=o,t=a=s+1)}return a>t&&(i+=e.substring(t,e.length)),i},_.base64Encode=function(e){var t,a,r,s,i,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,c=0,u="",p=[];if(!e)return e;e=_.utf8Encode(e);do{t=(i=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,a=i>>12&63,r=i>>6&63,s=63&i,p[c++]=n.charAt(t)+n.charAt(a)+n.charAt(r)+n.charAt(s)}while(o255||(r=e.charCodeAt(o++))>255||(s=e.charCodeAt(o++))>255)&&logger.info("Failed to execute 'btoa' : The string to be encoded contains characters outside of the Latin1 range."),n+=i.charAt((t=a<<16|r<<8|s)>>18&63)+i.charAt(t>>12&63)+i.charAt(t>>6&63)+i.charAt(63&t);return _?n.slice(0,_-3)+"===".substring(_):n},_.urlBase64Encode=function(e){return _.btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))},_.rot13obfs=function(e,t){t="number"==typeof t?t:13;for(var a=(e=String(e)).split(""),r=0,s=a.length;r(new Date).getTime()},_.getCurrentUrl=function(e){var t=_.getCurrentPath(),a="";return _.isObject(e)&&e.sensors_mp_encode_url_query&&(a=e.sensors_mp_encode_url_query),t?a?t+"?"+a:t:"\u672a\u53d6\u5230"},_.getPath=function(e){return e="string"==typeof e?e.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"},_.getMethods=function(e){var t=[];for(var a in e)"function"!=typeof e[a]||mpHook[a]||t.push(a);return t},_.isClick=function(e){return!!{tap:1,longpress:1,longtap:1}[e]},sa.initialState={queue:[],isComplete:!1,systemIsComplete:!1,storeIsComplete:!1,checkIsComplete:function(){this.systemIsComplete&&this.storeIsComplete&&(this.isComplete=!0,this.queue.length>0&&(_.each(this.queue,function(e){sa[e[0]].apply(sa,slice.call(e[1]))}),this.queue=[]))}},_.getCustomUtmFromQuery=function(e,t,a,r){if(!_.isObject(e))return{};var s={};if(e.sa_utm)for(var i in e)"sa_utm"!==i?_.include(sa.para.source_channel,i)&&(s[a+i]=e[i]):s[r+i]=e[i];else for(var i in e)-1===(" "+source_channel_standard+" ").indexOf(" "+i+" ")?_.include(sa.para.source_channel,i)&&(s[a+i]=e[i]):s[t+i]=e[i];return s},_.getObjFromQuery=function(e){var t=e.split("?"),a=[],r={};return t&&t[1]?(_.each(t[1].split("&"),function(e){(a=e.split("="))[0]&&a[1]&&(r[a[0]]=a[1])}),r):{}},_.setStorageSync=function(e,t){var a=function(){wx.setStorageSync(e,t)};try{a()}catch(e){logger.info("set Storage fail --",e);try{a()}catch(e){logger.info("set Storage fail again --",e)}}},_.getStorageSync=function(e){var t="";try{t=wx.getStorageSync(e)}catch(a){try{t=wx.getStorageSync(e)}catch(e){logger.info("getStorage fail")}}return t},_.getMPScene=function(e){return"number"==typeof e||"string"==typeof e&&""!==e?e="wx-"+String(e):"\u672a\u53d6\u5230\u503c"},_.objToParam=function(e,t){if("[object Object]"!==Object.prototype.toString.call(e))return logger.info("\u8bf7\u4f20\u5165\u6709\u6548\u5bf9\u8c61"),"";var a=[];for(var r in e)if(e.hasOwnProperty(r)){var s=e[r];void 0===s?a.push(r+"="):(s=t?encodeURIComponent(s):s,a.push(r+"="+s))}return a.join("&")},_.delObjectKey=function(e){if("[object Object]"===Object.prototype.toString.call(e))for(var t=0;t=2?(page_route_map.shift(),page_route_map.push(e)):page_route_map.push(e)}}catch(e){logger.info(e)}},_.getRefPage=function(){var e={route:"\u76f4\u63a5\u6253\u5f00",title:""};return page_route_map.length>1&&(e.title=page_route_map[0].title,e.route=page_route_map[0].route),e},_.getCurrentPageInfo=function(){var e=_.getCurrentPage(),t={title:"",url:"",path:"\u672a\u53d6\u5230"};if(e&&e.route){var a=e.sensors_mp_url_query?"?"+e.sensors_mp_url_query:"";t.title=_.getPageTitle(e.route),t.url=e.route+a,t.path=e.route}return t},_.setPageRefData=function(e,t,a){var r=_.getRefPage();_.isObject(e)&&(t?page_route_map.length>0&&t?(a=a?"?"+a:"",e.$referrer=_.getPath(t)+a,e.$referrer_title=_.getPageTitle(t)):(e.$referrer="\u76f4\u63a5\u6253\u5f00",e.$referrer_title=""):(e.$referrer=r.route,e.$referrer_title=r.title))},_.getPageTitle=function(e){if("\u672a\u53d6\u5230"===e||!e)return"";var t="";try{if(__wxConfig){var a=__wxConfig,r=__wxConfig.page||{},s=r[e]||r[e+".html"],i={},n={};if(a.global&&a.global.window&&a.global.window.navigationBarTitleText&&(i.titleVal=a.global.window.navigationBarTitleText),s&&s.window&&s.window.navigationBarTitleText&&(n.titleVal=s.window.navigationBarTitleText),!n.titleVal&&__wxAppCode__){var o=__wxAppCode__[e+".json"];o&&o.navigationBarTitleText&&(n.titleVal=o.navigationBarTitleText)}if(_.each(globalTitle,function(a,r){if(r===e)return t=a}),0===t.length){var c=_.extend(i,n);t=c.titleVal||""}}}catch(e){logger.info(e)}return t},_.wxrequest=function(e){if(_.compareSDKVersion(wxSDKVersion,"2.10.0")>=0)e.timeout=sa.para.datasend_timeout,wx.request(e);else{var t=wx.request(e);setTimeout(function(){_.isObject(t)&&_.isFunction(t.abort)&&t.abort()},sa.para.datasend_timeout)}},_.getAppInfoSync=function(){if(wx.getAccountInfoSync){var e=wx.getAccountInfoSync(),t=e&&e.miniProgram?e.miniProgram:{};return{appId:t.appId,appEnv:t.envVersion,appVersion:t.version}}return{}},_.getAppId=function(){var e=_.getAppInfoSync();return e&&e.appId?e.appId:""},_.validId=function(e){return"string"!=typeof e&&"number"!=typeof e||""===e?(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1):"number"!=typeof e||(e=String(e),/^\d+$/.test(e))?!!_.check.ckeckIdLength(e)&&e:(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1)},_.compareSDKVersion=function(e,t){e=e.split("."),t=t.split(".");for(var a=Math.max(e.length,t.length);e.lengthi)return 1;if(s-1?t.system.split(" ")[1]:t.system,wxSDKVersion=t.SDKVersion,e.$mp_client_app_version=t.version,e.$mp_client_basic_library_version=wxSDKVersion},complete:function(){var t=(new Date).getTimezoneOffset(),a=_.getAppInfoSync();_.isNumber(t)&&(e.$timezone_offset=t),a.appId&&(e.$app_id=a.appId),a.appVersion&&(e.$app_version=a.appVersion),sa.initialState.systemIsComplete=!0,sa.initialState.checkIsComplete()}})}wx.getNetworkType({success:function(t){e.$network_type=_.setUpperCase(t.networkType)},complete:t})}},sa._=_,_.eventEmitter=function(){this.sub=[]},_.eventEmitter.prototype={add:function(e){this.sub.push(e)},emit:function(e,t){this.sub.forEach(function(a){a.on(e,t)})}},_.eventSub=function(e){sa.events.add(this),this._events=[],this.handle=e,this.ready=!1},_.eventSub.prototype={on:function(e,t){if(this.ready){if(_.isFunction(this.handle))try{this.handle(e,t)}catch(e){logger.info(e)}}else this._events.push({event:e,data:t})},isReady:function(){var e=this;e.ready=!0,e._events.forEach(function(t){if(_.isFunction(e.handle))try{e.handle(t.event,t.data)}catch(e){logger.info(e)}})}},sa.eventSub=_.eventSub,sa.events=new _.eventEmitter,sa.usePlugin=function(e,t){"function"==typeof e.init&&e.init(sa,t)},sa.store={storageInfo:null,getUUID:function(){return Date.now()+"-"+Math.floor(1e7*getRandom())+"-"+getRandom().toString(16).replace(".","")+"-"+String(31242*getRandom()).replace(".","").slice(0,8)},getStorage:function(){return this.storageInfo?this.storageInfo:(this.storageInfo=sa._.getStorageSync(sa.para.storage_store_key)||"",this.storageInfo)},_state:{},mem:{mdata:[],getLength:function(){return this.mdata.length},add:function(e){this.mdata.push(e)},clear:function(e){this.mdata.splice(0,e)}},toState:function(e){var t=null;_.isJSONString(e)?(t=JSON.parse(e)).distinct_id?this._state=t:this.set("distinct_id",this.getUUID()):_.isObject(e)&&(t=e).distinct_id?this._state=t:this.set("distinct_id",this.getUUID());var a=this._state._first_id||this._state.first_id,r=this._state._distinct_id||this._state.distinct_id,s=this._state.openid,i=(this._state.history_login_id?this._state.history_login_id:{}).name;if(this._state.identities&&_.isString(this._state.identities)){var n=JSON.parse(_.rot13defs(this._state.identities));this._state.identities=n}var o,c,u=_.getOpenidNameByAppid();if(this._state.identities&&_.isObject(this._state.identities)&&!_.isEmptyObject(this._state.identities)){var p=(o=_.getAppId(),c="$mp_openid",o&&(c="$mp_"+o+"_openid"),c);this._state.identities.hasOwnProperty("$mp_id")&&(this._state.identities.$identity_mp_id=this._state.identities.$mp_id,delete this._state.identities.$mp_id),this._state.identities.hasOwnProperty("$mp_unionid")&&(this._state.identities.$identity_mp_unionid=this._state.identities.$mp_unionid,delete this._state.identities.$mp_unionid),this._state.identities.hasOwnProperty(p)&&(this._state.identities[u]=this._state.identities[p],delete this._state.identities[p]),this._state.identities.hasOwnProperty("$identity_anonymous_id")&&(this._state.identities.$identity_anonymous_id=a||r)}else this._state.identities={},this._state.identities.$identity_mp_id=this.getUUID(),this._state.identities.$identity_anonymous_id=a||r;if(s&&(this._state.identities[u]=s),a)if(i&&this._state.identities.hasOwnProperty(i)){if(this._state.identities[i]!==r){for(var d in this._state.identities[i]=r,this._state.identities)this._state.identities.hasOwnProperty(d)&&"$identity_mp_id"!==d&&d!==i&&delete this._state.identities[d];this._state.history_login_id.value=r}}else{for(var d in this._state.identities[sa.para.login_id_key]=r,this._state.identities)this._state.identities.hasOwnProperty(d)&&"$identity_mp_id"!==d&&d!==sa.para.login_id_key&&delete this._state.identities[d];this._state.history_login_id={name:sa.para.login_id_key,value:r}}else{if(this._state.identities.hasOwnProperty("$identity_login_id")||this._state.identities.hasOwnProperty(i))for(var d in this._state.identities)this._state.identities.hasOwnProperty(d)&&"$identity_mp_id"!==d&&"$identity_anonymous_id"!==d&&delete this._state.identities[d];this._state.history_login_id={name:"",value:""}}this.save()},getFirstId:function(){return this._state._first_id||this._state.first_id},getDistinctId:function(){return this._state._distinct_id||this._state.distinct_id},getUnionId:function(){var e={},t=this._state._first_id||this._state.first_id,a=this._state._distinct_id||this._state.distinct_id;return t&&a?(e.login_id=a,e.anonymous_id=t):e.anonymous_id=a,e},getProps:function(){return this._state.props||{}},setProps:function(e,t){var a=this._state.props||{};t?this.set("props",e):(_.extend(a,e),this.set("props",a))},set:function(e,t){var a={};for(var r in"string"==typeof e?a[e]=t:"object"==typeof e&&(a=e),this._state=this._state||{},a)this._state[r]=a[r],"first_id"===r?delete this._state._first_id:"distinct_id"===r&&(delete this._state._distinct_id,sa.events.emit("changeDistinctId"));this.save()},identitiesSet:function(e,t){var a={};switch(e){case"login":a.$identity_mp_id=sa.store._state.identities.$identity_mp_id,a[sa.para.login_id_key]=t;break;case"logout":a.$identity_mp_id=sa.store._state.identities.$identity_mp_id;break;case"identify":(a=_.deepCopy(sa.store._state.identities)).$identity_anonymous_id=t}sa.store.set("identities",a)},change:function(e,t){this._state["_"+e]=t},encryptStorage:function(){var e=this.getStorage(),t="data:enc;";_.isObject(e)?e=t+_.rot13obfs(JSON.stringify(e)):_.isString(e)&&-1===e.indexOf(t)&&(e=t+_.rot13obfs(e)),sa._.setStorageSync(sa.para.storage_store_key,e)},save:function(){var e=_.deepCopy(this._state),t=_.rot13obfs(JSON.stringify(e.identities));if(e.identities=t,delete e._first_id,delete e._distinct_id,sa.para.encrypt_storage){e="data:enc;"+_.rot13obfs(JSON.stringify(e))}sa._.setStorageSync(sa.para.storage_store_key,e)},init:function(){var e=this.getStorage();if(e)_.isString(e)&&-1!==e.indexOf("data:enc;")&&(e=e.substring("data:enc;".length),e=JSON.parse(_.rot13defs(e))),this.toState(e);else{is_first_launch=!0;var t=new Date,a=t.getTime();t.setHours(23),t.setMinutes(59),t.setSeconds(60),sa.setOnceProfile({$first_visit_time:new Date}),this.set({distinct_id:this.getUUID(),first_visit_time:a,first_visit_day_time:t.getTime(),identities:{$identity_mp_id:this.getUUID()},history_login_id:{name:"",value:""}})}}},sa.setProfile=function(e,t){sa.saEvent.send({type:"profile_set",properties:e},t)},sa.setOnceProfile=function(e,t){sa.saEvent.send({type:"profile_set_once",properties:e},t)},sa.appendProfile=function(e,t){if(!_.isObject(e))return!1;_.each(e,function(t,a){_.isString(t)?e[a]=[t]:(delete e[a],logger.info("appendProfile\u5c5e\u6027\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32\u6216\u8005\u6570\u7ec4"))}),sa.saEvent.send({type:"profile_append",properties:e},t)},sa.incrementProfile=function(e,t){if(!_.isObject(e))return!1;var a=e;_.isString(e)&&((e={})[a]=1),sa.saEvent.send({type:"profile_increment",properties:e},t)},sa.track=function(e,t,a){this.saEvent.send({type:"track",event:e,properties:t},a)},sa.identify=function(e,t){if(e=_.validId(e)){var a=sa.store.getFirstId();!0===t?a?sa.store.set("first_id",e):sa.store.set("distinct_id",e):a?sa.store.change("first_id",e):sa.store.change("distinct_id",e),sa.store.identitiesSet("identify",e)}},sa.trackSignup=function(e,t,a,r){var s=sa.store.getFirstId()||sa.store.getDistinctId();sa.store.set("distinct_id",e),sa.saEvent.send({original_id:s,distinct_id:e,type:"track_signup",event:t,properties:a},r)},sa.registerApp=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&(_.info.currentProps=_.extend(_.info.currentProps,e))},sa.register=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&sa.store.setProps(e)},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.clearAllProps=function(e){var t=sa.store.getProps(),a={};_.isArray(e)&&(_.each(t,function(t,r){_.include(e,r)||(a[r]=t)}),sa.store.setProps(a,!0))},sa.clearAppRegister=function(e){_.isArray(e)&&_.each(_.info.currentProps,function(t,a){_.include(e,a)&&delete _.info.currentProps[a]})},_.setLatestChannel=function(e){_.isEmptyObject(e)||(function(e,t){var a=!1;for(var r in t)e[t[r]]&&(a=!0);return a}(e,latest_source_channel)&&(sa.clearAppRegister(latest_source_channel),sa.clearAllProps(latest_source_channel)),sa.para.is_persistent_save.utm?sa.register(e):sa.registerApp(e))},_.setLatestShare=function(e){(e.$latest_share_depth||e.$latest_share_distinct_id||e.$latest_share_url_path||e.$latest_share_method)&&(sa.clearAppRegister(latest_share_info),sa.clearAllProps(latest_share_info),sa.para.is_persistent_save.share?sa.register(e):sa.registerApp(e))},sa.login=function(e){if(e=_.validId(e)){var t=sa.store.getFirstId(),a=sa.store.getDistinctId();if(sa.store._state.identities.hasOwnProperty(sa.para.login_id_key)&&e===t)return!1;var r=!(sa.para.login_id_key===sa.store._state.history_login_id.name&&sa.store._state.history_login_id.value===e);r&&(sa.store._state.identities[sa.para.login_id_key]=e),r&&(t?sa.trackSignup(e,"$SignUp"):(sa.store.set("first_id",a),sa.trackSignup(e,"$SignUp"))),r&&(sa.store.identitiesSet("login",e),sa.store.set("history_login_id",{name:sa.para.login_id_key,value:e}))}},sa.getAnonymousID=function(){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")},sa.logout=function(e){var t=sa.store.getFirstId();t?(sa.store.set("first_id",""),!0===e?sa.store.set("distinct_id",sa.store.getUUID()):sa.store.set("distinct_id",t)):logger.info("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25"),sa.store.identitiesSet("logout"),sa.store.set("history_login_id",{name:"",value:""})},sa.getLocation=function(){wx.getSetting({success:function(e){if(!e.authSetting["scope.userLocation"])return!1;wx.getLocation({type:sa.para.preset_properties.location.type,success:function(e){sa.registerApp({$latitude:e.latitude*Math.pow(10,6),$longitude:e.longitude*Math.pow(10,6),$geo_coordinate_system:_.setUpperCase(sa.para.preset_properties.location.type)})},fail:function(e){logger.info("\u83b7\u53d6\u4f4d\u7f6e\u5931\u8d25",e)}})}})},sa.openid={getRequest:function(e){wx.login({success:function(t){t.code&&sa.para.appid&&sa.para.openid_url?_.wxrequest({url:sa.para.openid_url+"&code="+t.code+"&appid="+sa.para.appid,method:"GET",complete:function(t){_.isObject(t)&&_.isObject(t.data)&&t.data.openid?e(t.data.openid):e()}}):e()}})},getWXStorage:function(){var e=sa.store.getStorage();if(e&&_.isObject(e))return e.openid},getOpenid:function(e){if(!sa.para.appid)return e(),!1;var t=this.getWXStorage();t?e(t):this.getRequest(e)}},sa.initial=function(){this._.info.getSystem(),this.store.init()},sa.init=function(e){if(!0===this.hasInit)return!1;this.hasInit=!0,sa.setPara(e),sa.para.encrypt_storage&&this.store.encryptStorage(),sa.para.batch_send&&sendStrategy.init(),sa.initialState.storeIsComplete=!0,sa.initialState.checkIsComplete()},sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib){var e={};_.each(_.info.currentProps,function(t,a){0===a.indexOf("$")&&(e[a]=t)});var t={$url_path:_.getCurrentPath(),$is_first_day:_.getIsFirstDay(),$is_first_time:is_first_launch},a=_.extend(e,t,_.info.properties,sa.store.getProps());return delete a.$lib,a}return{}},sa.setOpenid=function(e,t){if(!(e=_.validId(e)))return!1;t&&console.log("%c \u5f53\u524d\u7248\u672c setOpenid \u63a5\u53e3 \u5df2\u4e0d\u652f\u6301\u4f20\u5165\u7b2c\u4e8c\u4e2a\u53c2\u6570","color:#F39C12;font-size: 14px;"),sa.store.set("openid",e),sa.identify(e,!0),sa.bind("$identity_mp_openid",e)},sa.unsetOpenid=function(e){var t=_.validId(e);if(!t)return!1;sa.store._state.openid===t&&sa.store.set("openid",""),sa.unbind("$identity_mp_openid",t)},sa.setUnionid=function(e){var t=_.validId(e);t&&sa.bind("$identity_mp_unionid",t)},sa.unsetUnionid=function(e){var t=_.validId(e);if(t){if(sa.store._state.identities.hasOwnProperty("$identity_mp_unionid")&&t===sa.store._state.identities.$identity_mp_unionid){var a=_.getOpenidNameByAppid();sa.store._state.identities.hasOwnProperty(a)&&(delete sa.store._state.identities[a],delete sa.store._state.openid,sa.store.save())}sa.unbind("$identity_mp_unionid",t)}},sa.initWithOpenid=function(e,t){(e=e||{}).appid&&(sa.para.appid=e.appid),sa.openid.getOpenid(function(a){a&&sa.setOpenid(a,e.isCoverLogin),t&&_.isFunction(t)&&t(a),sa.init(e)})},sa.bind=function(e,t){if(_.isNumber(t)){if(_.isInteger(t)&&!1===_.isSafeInteger(t))return logger.info("Value must be String"),!1;t=String(t)}if(!_.isString(e))return logger.info("Key must be String"),!1;if(!_.check.checkKeyword(e)||"$identity_anonymous_id"===e||"$mp_id"===e||"$identity_mp_id"===e||"$identity_login_id"===e||e===sa.para.login_id_key){var a="Key ["+e+"] is invalid";return logger.info(a),!1}if(!t||""===t)return logger.info("Value is empty or null"),!1;if(!_.isString(t))return logger.info("Value must be String"),!1;if(!_.check.ckeckIdLength(t)){a="Value ["+t+"] is beyond the maximum length 255";return logger.info(a),!1}var r=sa.store._state.identities;"$identity_mp_openid"===e&&(e=_.getOpenidNameByAppid()),r[e]=t,sa.store.save(),sa.saEvent.send({type:"track_id_bind",event:"$BindID"})},sa.unbind=function(e,t){if(_.isNumber(t)){if(_.isInteger(t)&&!1===_.isSafeInteger(t))return logger.info("Value must be String"),!1;t=String(t)}if(!_.isString(e))return logger.info("Key must be String"),!1;if(!_.check.checkKeyword(e)||"$identity_anonymous_id"===e||"$mp_id"===e||"$identity_mp_id"===e||"$identity_login_id"===e||e===sa.para.login_id_key){var a="Key ["+e+"] is invalid";return logger.info(a),!1}if(!t||""===t)return logger.info("Value is empty or null"),!1;if(!_.isString(t))return logger.info("Value must be String"),!1;if(!_.check.ckeckIdLength(t)){a="Value ["+t+"] is beyond the maximum length 255";return logger.info(a),!1}"$identity_mp_openid"===e&&(e=_.getOpenidNameByAppid()),sa.store._state.identities.hasOwnProperty(e)&&t===sa.store._state.identities[e]&&(delete sa.store._state.identities[e],sa.store.save());var r={};r[e]=t,sa.saEvent.send({type:"track_id_unbind",event:"$UnbindID",unbind_value:r})},sa.setWebViewUrl=function(e,t){if(!_.isString(e)||""===e)return logger.info("error:\u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;if(!/^http(s)?:\/\//.test(e))return logger.info("warning: \u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;var a=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e);if(!a)return!1;var r,s=a[1]||"",i=a[2]||"",n=a[3]||"",o="",c=sa.store.getDistinctId()||"",u=sa.store.getFirstId()||"";_.urlSafeBase64&&_.urlSafeBase64.encode?c=c?_.urlSafeBase64.trim(_.urlSafeBase64.encode(_.urlBase64Encode(c))):"":this._.rot13obfs&&(c=c?_.rot13obfs(c):""),c=encodeURIComponent(c);var p=u?"f"+c:"d"+c;t?(r=n.indexOf("_sasdk"),o=n.indexOf("?")>-1?r>-1?s+i+"#"+n.substring(1,r)+"_sasdk="+p:s+i+"#"+n.substring(1)+"&_sasdk="+p:s+i+"#"+n.substring(1)+"?_sasdk="+p):(r=i.indexOf("_sasdk"),o=/^\?(\w)+/.test(i)?r>-1?s+i.replace(/(_sasdk=)([^&]*)/gi,"_sasdk="+p)+n:s+"?"+i.substring(1)+"&_sasdk="+p+n:s+"?"+i.substring(1)+"_sasdk="+p+n);return o},_.each(["setProfile","setOnceProfile","track","quick","incrementProfile","appendProfile","login","logout","registerApp","register","clearAllRegister","clearAllProps","clearAppRegister","bind","unbind","unsetOpenid","setUnionid","unsetUnionid"],function(e){var t=sa[e];sa[e]=function(){sa.initialState.isComplete?t.apply(sa,arguments):sa.initialState.queue.push([e,arguments])}}),_.setQuery=function(e,t){if(e&&_.isObject(e)&&!_.isEmptyObject(e)){var a=[];return _.each(e,function(e,r){"q"===r&&_.isString(e)&&0===e.indexOf("http")||(t?a.push(r+"="+e):a.push(r+"="+_.decodeURIComponent(e)))}),a.join("&")}return""},_.getUtmFromPage=function(){var e={};try{var t=_.getCurrentPage(),a=_.deepCopy(t.options);for(var r in a)a[r]=_.decodeURIComponent(a[r]);e=_.getCustomUtmFromQuery(a,"$","_","$")}catch(e){logger.info(e)}return e},_.sendPageLeave=function(){var e={},t="";try{t=(e=_.getCurrentPage())?e.route:""}catch(e){logger.info(e)}if(page_show_time>=0&&""!==t){var a={},r=_.getPageTitle(t),s=(Date.now()-page_show_time)/1e3;a.$url_query=e.sensors_mp_url_query?e.sensors_mp_url_query:"",a.$url_path=t,a.$title=r,a.event_duration=s,sa.track("$MPPageLeave",a),page_show_time=-1}};{var mp_proxy=function(e,t,a){var r=sa.autoTrackCustom[a];if(e[t]){var s=e[t];e[t]=function(){"onLaunch"===t&&(this[sa.para.name]=sa),!sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&!sa.para.autoTrackIsFirst[a]?(s.apply(this,arguments),r.apply(this,arguments)):(!0===sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&sa.para.autoTrackIsFirst[a])&&(r.apply(this,arguments),s.apply(this,arguments))}}else e[t]=function(){"onLaunch"===t&&(this[sa.para.name]=sa),r.apply(this,arguments)}};function clickTrack(e){var t,a={},r={},s=e.currentTarget||{},i=e.target||{};if(_.isObject(sa.para.framework)&&_.isObject(sa.para.framework.taro)&&!sa.para.framework.taro.createApp&&i.id&&s.id&&i.id!==s.id)return!1;var n=s.dataset||{};if(t=e.type,a.$element_id=s.id,a.$element_type=n.type,a.$element_content=n.content,a.$element_name=n.name,_.isObject(e.event_prop)&&(r=e.event_prop),t&&_.isClick(t)){if(sa.para.preset_events&&sa.para.preset_events.collect_element&&!1===sa.para.preset_events.collect_element(arguments[0]))return!1;a.$url_path=_.getCurrentPath(),_.setPageRefData(a),a=_.extend(a,r),sa.track("$MPClick",a)}}var click_proxy=function(e,t){var a=e[t];e[t]=function(){var e=a.apply(this,arguments),t=arguments[0];return _.isObject(t)&&(sa.para.preset_events.defer_track?setTimeout(function(){clickTrack(t)},0):clickTrack(t)),e}},tabProxy=function(e){var t=e.onTabItemTap;e.onTabItemTap=function(e){t&&t.apply(this,arguments);var a={};e&&(a.$element_content=e.text),a.$element_type="tabBar",a.$url_path=_.getCurrentPath(),_.setPageRefData(a),sa.track("$MPClick",a)}},pageLeaveProxy=function(e){var t=e.onHide;e.onHide=function(){t&&t.apply(this,arguments),_.sendPageLeave()};var a=e.onUnload;e.onUnload=function(){a&&a.apply(this,arguments),_.sendPageLeave()}}}if(sa.autoTrackCustom={trackCustom:function(e,t,a){var r=sa.para.autoTrack[e],s="";sa.para.autoTrack&&r&&("function"==typeof r?(s=r(),_.isObject(s)&&_.extend(t,s)):_.isObject(r)&&(_.extend(t,r),sa.para.autoTrack[e]=!0),sa.track(a,t))},appLaunch:function(e,t){"object"!=typeof this||this.trackCustom||(this[sa.para.name]=sa);var a={};if(e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(a.$url_path=_.getPath(e.path),a.$title=_.getPageTitle(e.path),e.query&&_.isObject(e.query))){var r=_.setQuery(e.query);r=r?"?"+r:"",a.$url=a.$url_path+r}_.setShareInfo(e,a);var s=_.setUtm(e,a);is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(s.pre1)||sa.setOnceProfile(s.pre1)):a.$is_first_time=!1,_.setLatestChannel(s.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),_.setPageRefData(a),t?(a=_.extend(a,t),sa.track("$MPLaunch",a)):sa.para.autoTrack&&sa.para.autoTrack.appLaunch&&sa.autoTrackCustom.trackCustom("appLaunch",a,"$MPLaunch")},appShow:function(e,t){var a={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(a.$url_path=_.getPath(e.path),a.$title=_.getPageTitle(e.path)),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,a);var r=_.setUtm(e,a);_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),_.setPageRefData(a,e.path,a.$url_query),e&&e.path&&(a.$url=e.path+(a.$url_query?"?"+a.$url_query:"")),t?(a=_.extend(a,t),sa.track("$MPShow",a)):sa.para.autoTrack&&sa.para.autoTrack.appShow&&sa.autoTrackCustom.trackCustom("appShow",a,"$MPShow")},appHide:function(e){var t=(new Date).getTime(),a={};a.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(a.event_duration=(t-mpshow_time)/1e3),_.setPageRefData(a),e?(a=_.extend(a,e),sa.track("$MPHide",a)):sa.para.autoTrack&&sa.para.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",a,"$MPHide"),sendStrategy.onAppHide()},pageLoad:function(e){current_scene&&1010===current_scene&&e&&(e.sampshare&&delete e.sampshare,_.delObjectKey(e)),e&&_.isObject(e)&&(this.sensors_mp_url_query=_.setQuery(e),this.sensors_mp_encode_url_query=_.setQuery(e,!0))},pageShow:function(){page_show_time=Date.now();var e={},t=_.getCurrentPath(),a=_.getPageTitle(t);_.setRefPage(),e.$url_path=t,e.$url_query=this.sensors_mp_url_query?this.sensors_mp_url_query:"",e=_.extend(e,_.getUtmFromPage()),_.setPageRefData(e),_.setPageSfSource(e),a&&(e.$title=a),sa.para.onshow?sa.para.onshow(sa,t,this):_.isObject(sa.para.autotrack_exclude_page)&&_.isArray(sa.para.autotrack_exclude_page.pageShow)&&-1!==sa.para.autotrack_exclude_page.pageShow.indexOf(t)||sa.autoTrackCustom.trackCustom("pageShow",e,"$MPViewScreen")},pageShare:function(e){var t=e.onShareAppMessage;e.onShareAppMessage=function(){share_method="\u8f6c\u53d1\u6d88\u606f\u5361\u7247";var e=t.apply(this,arguments);if(sa.para.autoTrack&&sa.para.autoTrack.pageShare){var a={$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method};_.setPageRefData(a),sa.autoTrackCustom.trackCustom("pageShare",a,"$MPShare")}return sa.para.allow_amend_share_path&&("object"!=typeof e&&((e={}).path=_.getCurrentUrl(this)),"object"!=typeof e||void 0!==e.path&&""!==e.path||(e.path=_.getCurrentUrl(this)),"object"==typeof e&&"string"==typeof e.path&&(-1===e.path.indexOf("?")?e.path=e.path+"?":"&"!==e.path.slice(-1)&&(e.path=e.path+"&")),e.path=e.path+_.getShareInfo()),e}},pageShareTimeline:function(e){var t=e.onShareTimeline;e.onShareTimeline=function(){share_method="\u670b\u53cb\u5708\u5206\u4eab";var e=t.apply(this,arguments);if(sa.para.autoTrack&&sa.para.autoTrack.pageShare){var a={$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method};_.setPageRefData(a),sa.autoTrackCustom.trackCustom("pageShare",a,"$MPShare")}return sa.para.allow_amend_share_path&&("object"!=typeof e&&(e={}),"object"==typeof e&&void 0===e.query&&(e.query=""),"object"==typeof e&&"string"==typeof e.query&&""!==e.query&&"&"!==e.query.slice(-1)&&(e.query=e.query+"&"),e.query=e.query+_.getShareInfo()),e}},pageAddFavorites:function(){var e={};e.$url_path=_.getCurrentPath(),sa.para.autoTrack&&sa.para.autoTrack.mpFavorite&&sa.autoTrackCustom.trackCustom("mpFavorite",e,"$MPAddFavorites")}},sa.quick=function(){var e=arguments[0],t=arguments[1],a=arguments[2],r=_.isObject(a)?a:{};if("getAnonymousID"===e){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===e||"appShow"===e?t?sa.autoTrackCustom[e](t,r):logger.info("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(r=_.isObject(t)?t:{},sa.autoTrackCustom[e](r))},sa.appLaunch=function(e,t){var a={};e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(a.$url_path=_.getPath(e.path),a.$title=_.getPageTitle(e.path)),_.setShareInfo(e,a);var r=_.setUtm(e,a);is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):a.$is_first_time=!1,_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),a.$url=e.path+(a.$url_query?"?"+a.$url_query:""),_.setPageRefData(t),_.isObject(t)&&(a=_.extend(a,t)),sa.track("$MPLaunch",a)},sa.appShow=function(e,t){var a={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(a.$url_path=_.getPath(e.path),a.$title=_.getPageTitle(e.path)),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,a);var r=_.setUtm(e,a);_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),e&&e.path&&(a.$url=e.path+(a.$url_query?"?"+a.$url_query:"")),_.setPageRefData(a,e.path,a.$url_query),_.isObject(t)&&(a=_.extend(a,t)),sa.track("$MPShow",a)},sa.appHide=function(e){var t=(new Date).getTime(),a={};a.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(a.event_duration=(t-mpshow_time)/1e3),_.setPageRefData(a),_.isObject(e)&&(a=_.extend(a,e)),sa.track("$MPHide",a),sendStrategy.onAppHide()},sa.pageShow=function(e){var t={},a=_.getCurrentPath(),r=_.getPageTitle(a),s=_.getCurrentPage();_.setRefPage(),r&&(t.$title=r),t.$url_path=a,t.$url_query=s.sensors_mp_url_query?s.sensors_mp_url_query:"",t=_.extend(t,_.getUtmFromPage()),_.setPageSfSource(t),_.setPageRefData(t),_.isObject(e)&&(t=_.extend(t,e)),sa.track("$MPViewScreen",t)},sa.App=function(e){(e=e||{})[sa.para.name]=sa,App.apply(this,arguments)},wx.onAppShow(function(e){if(!deploy_para.launched){var t=wx.getLaunchOptionsSync()||{};sa.autoTrackCustom.appLaunch(t),deploy_para.launched=!0}sa.autoTrackCustom.appShow(e)}),wx.onAppHide(function(){sa.autoTrackCustom.appHide()}),sa.Page=function(e){e||(e={});var t=sa.para.autoTrack&&sa.para.autoTrack.mpClick&&_.getMethods(e);if(t)for(var a=0,r=t.length;a0){for(var r=0;r=500&&(sa._.logger.info("\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38"),sa.store.mem.mdata.shift());var t=Date.now();e._flush_time=t,(e=kit.processData(e))&&sa.store.mem.add(e),sa.store.mem.getLength()>=sa.para.batch_send.max_length&&this.batchSend()},wxrequest:function(e){if(sa._.isArray(e.data)&&e.data.length>0){var t=kit.batchTrackData(e.data);sa._.wxrequest({url:sa.para.server_url,method:"POST",dataType:"text",data:t,success:function(){e.success(e.len)},fail:function(){e.fail()}})}else e.success(e.len)},batchSend:function(){if(this.dataHasSend){var e,t,a=sa.store.mem.mdata;(t=(e=a.length>=100?a.slice(0,100):a).length)>0&&(this.dataHasSend=!1,this.wxrequest({data:e,len:t,success:this.batchRemove.bind(this),fail:this.sendFail.bind(this)}))}},sendFail:function(){this.dataHasSend=!0,this.failTime++},batchRemove:function(e){sa.store.mem.clear(e),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite(),this.failTime=0},is_first_batch_write:!0,batchWrite:function(){var e=this;this.dataHasChange&&(this.is_first_batch_write&&(this.is_first_batch_write=!1,setTimeout(function(){e.batchSend()},1e3)),this.dataHasChange=!1,this.syncStorage&&sa._.setStorageSync(sa.para.storage_prepare_data_key,sa.store.mem.mdata))},batchInterval:function(){var e=this;!function t(){setTimeout(function(){e.batchWrite(),t()},500)}(),function t(){setTimeout(function(){e.batchSend(),t()},sa.para.batch_send.send_timeout*Math.pow(2,e.failTime))}()}};function getSendUrl(e,t){var a=kit.onceTrackData(t);return-1!==e.indexOf("?")?e+"&"+a:e+"?"+a}function onceSend(e){e._flush_time=Date.now();var t=getSendUrl(sa.para.server_url,e);sa._.wxrequest({url:t,method:"GET"})}var saEvent={send:function(e,t){if(!sa.para.server_url)return sa._.logger.info("error: server_url \u4e0d\u80fd\u4e3a\u7a7a"),!1;if(sa.current_scene&&1154===sa.current_scene&&!sa.para.preset_events.moments_page)return!1;var a=sa.kit.buildData(e);a?(saEvent.debug(a),sa.events.emit("send",a),sa.para.batch_send?sendStrategy.send(a):onceSend(a)):sa._.logger.info("error: \u6570\u636e\u5f02\u5e38 "+a)},debug:function(e){sa._.logger.info(e)}},_={};sa.kit=kit,sa.mergeStorageData=mergeStorageData,sa.saEvent=saEvent,sa.sendStrategy=sendStrategy,sa.IDENTITY_KEY={EMAIL:"$identity_email",MOBILE:"$identity_mobile"},sa.para={name:"sensors",server_url:"",send_timeout:1e3,show_log:!1,login_id_key:"$identity_login_id",allow_amend_share_path:!0,max_string_length:500,datasend_timeout:3e3,source_channel:[],autoTrack:{appLaunch:!0,appShow:!0,appHide:!0,pageShow:!0,pageShare:!0,mpClick:!1,mpFavorite:!0,pageLeave:!1},autotrack_exclude_page:{pageShow:[]},is_persistent_save:{share:!1,utm:!1},preset_properties:{url_path:!0},preset_events:{moments_page:!1,defer_track:!1,share_info_use_string:!1},batch_send:!0,storage_store_key:"sensorsdata2015_wechat",storage_prepare_data_key:"sensors_mp_prepare_data"};var deploy_para={launched:!1},mpHook={data:1,onLoad:1,onShow:1,onReady:1,onPullDownRefresh:1,onShareAppMessage:1,onShareTimeline:1,onReachBottom:1,onPageScroll:1,onResize:1,onTabItemTap:1,onHide:1,onUnload:1},logger="object"==typeof logger?logger:{};logger.info=function(){if(sa.para.show_log&&"object"==typeof console&&console.log)try{if(3===arguments.length)return console.log(arguments[0],arguments[1],arguments[2]);if(2===arguments.length)return console.log(arguments[0],arguments[1]);if(1===arguments.length)return console.log(arguments[0])}catch(e){console.log(arguments[0])}},sa.setPara=function(e){sa.para=_.extend2Lev(sa.para,e);var t=[];if(_.isArray(sa.para.source_channel))for(var a=sa.para.source_channel.length,r=0;rsa.para.max_string_length?(logger.info("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,sa.para.max_string_length)):e},_.searchObjString=function(e){_.isObject(e)&&_.each(e,function(t,a){_.isObject(t)?_.searchObjString(e[a]):_.isString(t)&&(e[a]=_.formatString(t))})},_.parseSuperProperties=function(e){_.isObject(e)&&(_.each(e,function(t,a){if(_.isFunction(t))try{e[a]=t(),_.isFunction(e[a])&&(logger.info("\u60a8\u7684\u5c5e\u6027- "+a+" \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}catch(t){delete e[a],logger.info("\u60a8\u7684\u5c5e\u6027- "+a+" \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}}),_.strip_sa_properties(e))},_.unique=function(e){for(var t,a=[],r={},s=0;s255)||(logger.info("id \u957f\u5ea6\u8d85\u8fc7 255 \u4e2a\u5b57\u7b26\uff01"),!1)}},_.strip_sa_properties=function(e){return _.isObject(e)?(_.each(e,function(t,a){if(_.isArray(t)){var r=[];_.each(t,function(e){_.isString(e)?r.push(e):logger.info("\u60a8\u7684\u6570\u636e-",t,"\u7684\u6570\u7ec4\u91cc\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32,\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}),e[a]=r}_.isString(t)||_.isNumber(t)||_.isDate(t)||_.isBoolean(t)||_.isArray(t)||(logger.info("\u60a8\u7684\u6570\u636e-",t,"-\u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}),e):e},_.strip_empty_properties=function(e){var t={};return _.each(e,function(e,a){null!=e&&(t[a]=e)}),t},_.utf8Encode=function(e){var t,a,r,s,i="";for(t=a=0,r=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,s=0;s127&&n<2048?String.fromCharCode(n>>6|192,63&n|128):String.fromCharCode(n>>12|224,n>>6&63|128,63&n|128),null!==o&&(a>t&&(i+=e.substring(t,a)),i+=o,t=a=s+1)}return a>t&&(i+=e.substring(t,e.length)),i},_.base64Encode=function(e){var t,a,r,s,i,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,c=0,u="",p=[];if(!e)return e;e=_.utf8Encode(e);do{t=(i=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,a=i>>12&63,r=i>>6&63,s=63&i,p[c++]=n.charAt(t)+n.charAt(a)+n.charAt(r)+n.charAt(s)}while(o255||(r=e.charCodeAt(o++))>255||(s=e.charCodeAt(o++))>255)&&logger.info("Failed to execute 'btoa' : The string to be encoded contains characters outside of the Latin1 range."),n+=i.charAt((t=a<<16|r<<8|s)>>18&63)+i.charAt(t>>12&63)+i.charAt(t>>6&63)+i.charAt(63&t);return _?n.slice(0,_-3)+"===".substring(_):n},_.urlBase64Encode=function(e){return _.btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))},_.rot13obfs=function(e,t){t="number"==typeof t?t:13;for(var a=(e=String(e)).split(""),r=0,s=a.length;r(new Date).getTime()},_.getCurrentUrl=function(e){var t=_.getCurrentPath(),a="";return _.isObject(e)&&e.sensors_mp_encode_url_query&&(a=e.sensors_mp_encode_url_query),t?a?t+"?"+a:t:"\u672a\u53d6\u5230"},_.getPath=function(e){return e="string"==typeof e?e.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"},_.getMethods=function(e){var t=[];for(var a in e)"function"!=typeof e[a]||mpHook[a]||t.push(a);return t},_.isClick=function(e){return!!{tap:1,longpress:1,longtap:1}[e]},sa.initialState={queue:[],isComplete:!1,systemIsComplete:!1,storeIsComplete:!1,checkIsComplete:function(){this.systemIsComplete&&this.storeIsComplete&&(this.isComplete=!0,this.queue.length>0&&(_.each(this.queue,function(e){sa[e[0]].apply(sa,slice.call(e[1]))}),this.queue=[]))}},_.getCustomUtmFromQuery=function(e,t,a,r){if(!_.isObject(e))return{};var s={};if(e.sa_utm)for(var i in e)"sa_utm"!==i?_.include(sa.para.source_channel,i)&&(s[a+i]=e[i]):s[r+i]=e[i];else for(var i in e)-1===(" "+source_channel_standard+" ").indexOf(" "+i+" ")?_.include(sa.para.source_channel,i)&&(s[a+i]=e[i]):s[t+i]=e[i];return s},_.getObjFromQuery=function(e){var t=e.split("?"),a=[],r={};return t&&t[1]?(_.each(t[1].split("&"),function(e){(a=e.split("="))[0]&&a[1]&&(r[a[0]]=a[1])}),r):{}},_.setStorageSync=function(e,t){var a=function(){wx.setStorageSync(e,t)};try{a()}catch(e){logger.info("set Storage fail --",e);try{a()}catch(e){logger.info("set Storage fail again --",e)}}},_.getStorageSync=function(e){var t="";try{t=wx.getStorageSync(e)}catch(a){try{t=wx.getStorageSync(e)}catch(e){logger.info("getStorage fail")}}return t},_.getMPScene=function(e){return"number"==typeof e||"string"==typeof e&&""!==e?e="wx-"+String(e):"\u672a\u53d6\u5230\u503c"},_.objToParam=function(e,t){if("[object Object]"!==Object.prototype.toString.call(e))return logger.info("\u8bf7\u4f20\u5165\u6709\u6548\u5bf9\u8c61"),"";var a=[];for(var r in e)if(e.hasOwnProperty(r)){var s=e[r];void 0===s?a.push(r+"="):(s=t?encodeURIComponent(s):s,a.push(r+"="+s))}return a.join("&")},_.delObjectKey=function(e){if("[object Object]"===Object.prototype.toString.call(e))for(var t=0;t=2?(page_route_map.shift(),page_route_map.push(e)):page_route_map.push(e)}}catch(e){logger.info(e)}},_.getRefPage=function(){var e={route:"\u76f4\u63a5\u6253\u5f00",title:""};return page_route_map.length>1&&(e.title=page_route_map[0].title,e.route=page_route_map[0].route),e},_.getCurrentPageInfo=function(){var e=_.getCurrentPage(),t={title:"",url:""};if(e&&e.route){var a=e.sensors_mp_url_query?"?"+e.sensors_mp_url_query:"";t.title=_.getPageTitle(e.route),t.url=e.route+a}return t},_.setPageRefData=function(e,t,a){var r=_.getRefPage();_.isObject(e)&&(t?page_route_map.length>0&&t?(a=a?"?"+a:"",e.$referrer=_.getPath(t)+a,e.$referrer_title=_.getPageTitle(t)):(e.$referrer="\u76f4\u63a5\u6253\u5f00",e.$referrer_title=""):(e.$referrer=r.route,e.$referrer_title=r.title))},_.getPageTitle=function(e){if("\u672a\u53d6\u5230"===e||!e)return"";var t="";try{if(__wxConfig){var a=__wxConfig,r=__wxConfig.page||{},s=r[e]||r[e+".html"],i={},n={};if(a.global&&a.global.window&&a.global.window.navigationBarTitleText&&(i.titleVal=a.global.window.navigationBarTitleText),s&&s.window&&s.window.navigationBarTitleText&&(n.titleVal=s.window.navigationBarTitleText),!n.titleVal&&__wxAppCode__){var o=__wxAppCode__[e+".json"];o&&o.navigationBarTitleText&&(n.titleVal=o.navigationBarTitleText)}if(_.each(globalTitle,function(a,r){if(r===e)return t=a}),0===t.length){var c=_.extend(i,n);t=c.titleVal||""}}}catch(e){logger.info(e)}return t},_.wxrequest=function(e){if(_.compareSDKVersion(wxSDKVersion,"2.10.0")>=0)e.timeout=sa.para.datasend_timeout,wx.request(e);else{var t=wx.request(e);setTimeout(function(){_.isObject(t)&&_.isFunction(t.abort)&&t.abort()},sa.para.datasend_timeout)}},_.getAppInfoSync=function(){if(wx.getAccountInfoSync){var e=wx.getAccountInfoSync(),t=e&&e.miniProgram?e.miniProgram:{};return{appId:t.appId,appEnv:t.envVersion,appVersion:t.version}}return{}},_.getAppId=function(){var e=_.getAppInfoSync();return e&&e.appId?e.appId:""},_.validId=function(e){return"string"!=typeof e&&"number"!=typeof e||""===e?(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1):"number"!=typeof e||(e=String(e),/^\d+$/.test(e))?!!_.check.ckeckIdLength(e)&&e:(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1)},_.compareSDKVersion=function(e,t){e=e.split("."),t=t.split(".");for(var a=Math.max(e.length,t.length);e.lengthi)return 1;if(s-1?t.system.split(" ")[1]:t.system,wxSDKVersion=t.SDKVersion,e.$mp_client_app_version=t.version,e.$mp_client_basic_library_version=wxSDKVersion},complete:function(){var t=(new Date).getTimezoneOffset(),a=_.getAppInfoSync();_.isNumber(t)&&(e.$timezone_offset=t),a.appId&&(e.$app_id=a.appId),a.appVersion&&(e.$app_version=a.appVersion),sa.initialState.systemIsComplete=!0,sa.initialState.checkIsComplete()}})}wx.getNetworkType({success:function(t){e.$network_type=_.setUpperCase(t.networkType)},complete:t})}},sa._=_,_.eventEmitter=function(){this.sub=[]},_.eventEmitter.prototype={add:function(e){this.sub.push(e)},emit:function(e,t){this.sub.forEach(function(a){a.on(e,t)})}},_.eventSub=function(e){sa.events.add(this),this._events=[],this.handle=e,this.ready=!1},_.eventSub.prototype={on:function(e,t){if(this.ready){if(_.isFunction(this.handle))try{this.handle(e,t)}catch(e){logger.info(e)}}else this._events.push({event:e,data:t})},isReady:function(){var e=this;e.ready=!0,e._events.forEach(function(t){if(_.isFunction(e.handle))try{e.handle(t.event,t.data)}catch(e){logger.info(e)}})}},sa.eventSub=_.eventSub,sa.events=new _.eventEmitter,sa.usePlugin=function(e,t){"function"==typeof e.init&&e.init(sa,t)},sa.store={storageInfo:null,getUUID:function(){return Date.now()+"-"+Math.floor(1e7*getRandom())+"-"+getRandom().toString(16).replace(".","")+"-"+String(31242*getRandom()).replace(".","").slice(0,8)},getStorage:function(){return this.storageInfo?this.storageInfo:(this.storageInfo=sa._.getStorageSync(sa.para.storage_store_key)||"",this.storageInfo)},_state:{},mem:{mdata:[],getLength:function(){return this.mdata.length},add:function(e){this.mdata.push(e)},clear:function(e){this.mdata.splice(0,e)}},toState:function(e){var t=null;_.isJSONString(e)?(t=JSON.parse(e)).distinct_id?this._state=t:this.set("distinct_id",this.getUUID()):_.isObject(e)&&(t=e).distinct_id?this._state=t:this.set("distinct_id",this.getUUID());var a=this._state._first_id||this._state.first_id,r=this._state._distinct_id||this._state.distinct_id,s=this._state.openid,i=(this._state.history_login_id?this._state.history_login_id:{}).name;if(this._state.identities&&_.isString(this._state.identities)){var n=JSON.parse(_.rot13defs(this._state.identities));this._state.identities=n}if(this._state.identities&&_.isObject(this._state.identities)&&!_.isEmptyObject(this._state.identities)?this._state.identities.hasOwnProperty("$identity_anonymous_id")&&(this._state.identities.$identity_anonymous_id=a||r):(this._state.identities={},this._state.identities.$mp_id=this.getUUID(),this._state.identities.$identity_anonymous_id=a||r),s){var o=_.getOpenidNameByAppid();this._state.identities[o]=s}if(a)if(i&&this._state.identities.hasOwnProperty(i)){if(this._state.identities[i]!==r){for(var c in this._state.identities[i]=r,this._state.identities)this._state.identities.hasOwnProperty(c)&&"$mp_id"!==c&&c!==i&&delete this._state.identities[c];this._state.history_login_id.value=r}}else{for(var c in this._state.identities[sa.para.login_id_key]=r,this._state.identities)this._state.identities.hasOwnProperty(c)&&"$mp_id"!==c&&c!==sa.para.login_id_key&&delete this._state.identities[c];this._state.history_login_id={name:sa.para.login_id_key,value:r}}else{if(this._state.identities.hasOwnProperty("$identity_login_id")||this._state.identities.hasOwnProperty(i))for(var c in this._state.identities)this._state.identities.hasOwnProperty(c)&&"$mp_id"!==c&&"$identity_anonymous_id"!==c&&delete this._state.identities[c];this._state.history_login_id={name:"",value:""}}this.save()},getFirstId:function(){return this._state._first_id||this._state.first_id},getDistinctId:function(){return this._state._distinct_id||this._state.distinct_id},getUnionId:function(){var e={},t=this._state._first_id||this._state.first_id,a=this._state._distinct_id||this._state.distinct_id;return t&&a?(e.login_id=a,e.anonymous_id=t):e.anonymous_id=a,e},getProps:function(){return this._state.props||{}},setProps:function(e,t){var a=this._state.props||{};t?this.set("props",e):(_.extend(a,e),this.set("props",a))},set:function(e,t){var a={};for(var r in"string"==typeof e?a[e]=t:"object"==typeof e&&(a=e),this._state=this._state||{},a)this._state[r]=a[r],"first_id"===r?delete this._state._first_id:"distinct_id"===r&&(delete this._state._distinct_id,sa.events.emit("changeDistinctId"));this.save()},identitiesSet:function(e,t){var a={};switch(e){case"login":a.$mp_id=sa.store._state.identities.$mp_id,a[sa.para.login_id_key]=t;break;case"logout":a.$mp_id=sa.store._state.identities.$mp_id;break;case"identify":(a=_.deepCopy(sa.store._state.identities)).$identity_anonymous_id=t}sa.store.set("identities",a)},change:function(e,t){this._state["_"+e]=t},encryptStorage:function(){var e=this.getStorage(),t="data:enc;";_.isObject(e)?e=t+_.rot13obfs(JSON.stringify(e)):_.isString(e)&&-1===e.indexOf(t)&&(e=t+_.rot13obfs(e)),sa._.setStorageSync(sa.para.storage_store_key,e)},save:function(){var e=_.deepCopy(this._state),t=_.rot13obfs(JSON.stringify(e.identities));if(e.identities=t,delete e._first_id,delete e._distinct_id,sa.para.encrypt_storage){e="data:enc;"+_.rot13obfs(JSON.stringify(e))}sa._.setStorageSync(sa.para.storage_store_key,e)},init:function(){var e=this.getStorage();if(e)_.isString(e)&&-1!==e.indexOf("data:enc;")&&(e=e.substring("data:enc;".length),e=JSON.parse(_.rot13defs(e))),this.toState(e);else{is_first_launch=!0;var t=new Date,a=t.getTime();t.setHours(23),t.setMinutes(59),t.setSeconds(60),sa.setOnceProfile({$first_visit_time:new Date}),this.set({distinct_id:this.getUUID(),first_visit_time:a,first_visit_day_time:t.getTime(),identities:{$mp_id:this.getUUID()},history_login_id:{name:"",value:""}})}}},sa.setProfile=function(e,t){sa.saEvent.send({type:"profile_set",properties:e},t)},sa.setOnceProfile=function(e,t){sa.saEvent.send({type:"profile_set_once",properties:e},t)},sa.appendProfile=function(e,t){if(!_.isObject(e))return!1;_.each(e,function(t,a){_.isString(t)?e[a]=[t]:(delete e[a],logger.info("appendProfile\u5c5e\u6027\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32\u6216\u8005\u6570\u7ec4"))}),sa.saEvent.send({type:"profile_append",properties:e},t)},sa.incrementProfile=function(e,t){if(!_.isObject(e))return!1;var a=e;_.isString(e)&&((e={})[a]=1),sa.saEvent.send({type:"profile_increment",properties:e},t)},sa.track=function(e,t,a){this.saEvent.send({type:"track",event:e,properties:t},a)},sa.identify=function(e,t){if(e=_.validId(e)){var a=sa.store.getFirstId();!0===t?a?sa.store.set("first_id",e):sa.store.set("distinct_id",e):a?sa.store.change("first_id",e):sa.store.change("distinct_id",e),sa.store.identitiesSet("identify",e)}},sa.trackSignup=function(e,t,a,r){var s=sa.store.getFirstId()||sa.store.getDistinctId();sa.store.set("distinct_id",e),sa.saEvent.send({original_id:s,distinct_id:e,type:"track_signup",event:t,properties:a},r)},sa.registerApp=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&(_.info.currentProps=_.extend(_.info.currentProps,e))},sa.register=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&sa.store.setProps(e)},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.clearAllProps=function(e){var t=sa.store.getProps(),a={};_.isArray(e)&&(_.each(t,function(t,r){_.include(e,r)||(a[r]=t)}),sa.store.setProps(a,!0))},sa.clearAppRegister=function(e){_.isArray(e)&&_.each(_.info.currentProps,function(t,a){_.include(e,a)&&delete _.info.currentProps[a]})},_.setLatestChannel=function(e){_.isEmptyObject(e)||(function(e,t){var a=!1;for(var r in t)e[t[r]]&&(a=!0);return a}(e,latest_source_channel)&&(sa.clearAppRegister(latest_source_channel),sa.clearAllProps(latest_source_channel)),sa.para.is_persistent_save.utm?sa.register(e):sa.registerApp(e))},_.setLatestShare=function(e){(e.$latest_share_depth||e.$latest_share_distinct_id||e.$latest_share_url_path||e.$latest_share_method)&&(sa.clearAppRegister(latest_share_info),sa.clearAllProps(latest_share_info),sa.para.is_persistent_save.share?sa.register(e):sa.registerApp(e))},sa.login=function(e){if(e=_.validId(e)){var t=sa.store.getFirstId(),a=sa.store.getDistinctId();if(sa.store._state.identities.hasOwnProperty(sa.para.login_id_key)&&e===t)return!1;var r=!(sa.para.login_id_key===sa.store._state.history_login_id.name&&sa.store._state.history_login_id.value===e);r&&(sa.store._state.identities[sa.para.login_id_key]=e),r&&(t?sa.trackSignup(e,"$SignUp"):(sa.store.set("first_id",a),sa.trackSignup(e,"$SignUp"))),r&&(sa.store.identitiesSet("login",e),sa.store.set("history_login_id",{name:sa.para.login_id_key,value:e}))}},sa.getAnonymousID=function(){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")},sa.logout=function(e){var t=sa.store.getFirstId();t?(sa.store.set("first_id",""),!0===e?sa.store.set("distinct_id",sa.store.getUUID()):sa.store.set("distinct_id",t)):logger.info("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25"),sa.store.identitiesSet("logout"),sa.store.set("history_login_id",{name:"",value:""})},sa.getLocation=function(){wx.getSetting({success:function(e){if(!e.authSetting["scope.userLocation"])return!1;wx.getLocation({type:sa.para.preset_properties.location.type,success:function(e){sa.registerApp({$latitude:e.latitude*Math.pow(10,6),$longitude:e.longitude*Math.pow(10,6),$geo_coordinate_system:_.setUpperCase(sa.para.preset_properties.location.type)})},fail:function(e){logger.info("\u83b7\u53d6\u4f4d\u7f6e\u5931\u8d25",e)}})}})},sa.openid={getRequest:function(e){wx.login({success:function(t){t.code&&sa.para.appid&&sa.para.openid_url?_.wxrequest({url:sa.para.openid_url+"&code="+t.code+"&appid="+sa.para.appid,method:"GET",complete:function(t){_.isObject(t)&&_.isObject(t.data)&&t.data.openid?e(t.data.openid):e()}}):e()}})},getWXStorage:function(){var e=sa.store.getStorage();if(e&&_.isObject(e))return e.openid},getOpenid:function(e){if(!sa.para.appid)return e(),!1;var t=this.getWXStorage();t?e(t):this.getRequest(e)}},sa.initial=function(){this._.info.getSystem(),this.store.init()},sa.init=function(e){if(!0===this.hasInit)return!1;this.hasInit=!0,sa.setPara(e),sa.para.encrypt_storage&&this.store.encryptStorage(),sa.para.batch_send&&sendStrategy.init(),sa.initialState.storeIsComplete=!0,sa.initialState.checkIsComplete()},sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib){var e={};_.each(_.info.currentProps,function(t,a){0===a.indexOf("$")&&(e[a]=t)});var t=_.extend(e,{$url_path:_.getCurrentPath(),$is_first_day:_.getIsFirstDay()},_.info.properties,sa.store.getProps());return delete t.$lib,t}return{}},sa.setOpenid=function(e,t){if(!(e=_.validId(e)))return!1;var a=sa.store.getFirstId();sa.store.set("openid",e),t?sa.store.set("distinct_id",e):(sa.identify(e,!0),a?sa.store.set("first_id",e):sa.store.set("distinct_id",e)),sa.bind("$mp_openid",e)},sa.unsetOpenid=function(e){var t=_.validId(e);if(!t)return!1;sa.store._state.openid===t&&sa.store.set("openid",""),sa.unbind("$mp_openid",t)},sa.setUnionid=function(e){var t=_.validId(e);t&&sa.bind("$mp_unionid",t)},sa.unsetUnionid=function(e){var t=_.validId(e);if(t){if(sa.store._state.identities.hasOwnProperty("$mp_unionid")&&t===sa.store._state.identities.$mp_unionid){var a=_.getOpenidNameByAppid();sa.store._state.identities.hasOwnProperty(a)&&(delete sa.store._state.identities[a],sa.store.save())}sa.unbind("$mp_unionid",t)}},sa.initWithOpenid=function(e,t){(e=e||{}).appid&&(sa.para.appid=e.appid),sa.openid.getOpenid(function(a){a&&sa.setOpenid(a,e.isCoverLogin),t&&_.isFunction(t)&&t(a),sa.init(e)})},sa.bind=function(e,t){if(_.isNumber(t)){if(_.isInteger(t)&&!1===_.isSafeInteger(t))return logger.info("Value must be String"),!1;t=String(t)}if(!_.isString(e))return logger.info("Key must be String"),!1;if(!_.check.checkKeyword(e)||"$identity_anonymous_id"===e||"$mp_id"===e||"$identity_login_id"===e||e===sa.para.login_id_key){var a="Key ["+e+"] is invalid";return logger.info(a),!1}if(!t||""===t)return logger.info("Value is empty or null"),!1;if(!_.isString(t))return logger.info("Value must be String"),!1;if(!_.check.ckeckIdLength(t)){a="Value ["+t+"] is beyond the maximum length 255";return logger.info(a),!1}var r=sa.store._state.identities;"$mp_openid"===e&&(e=_.getOpenidNameByAppid()),r[e]=t,sa.store.save(),sa.saEvent.send({type:"track_id_bind",event:"$BindID"})},sa.unbind=function(e,t){if(_.isNumber(t)){if(_.isInteger(t)&&!1===_.isSafeInteger(t))return logger.info("Value must be String"),!1;t=String(t)}if(!_.isString(e))return logger.info("Key must be String"),!1;if(!_.check.checkKeyword(e)||"$identity_anonymous_id"===e||"$mp_id"===e||"$identity_login_id"===e||e===sa.para.login_id_key){var a="Key ["+e+"] is invalid";return logger.info(a),!1}if(!t||""===t)return logger.info("Value is empty or null"),!1;if(!_.isString(t))return logger.info("Value must be String"),!1;if(!_.check.ckeckIdLength(t)){a="Value ["+t+"] is beyond the maximum length 255";return logger.info(a),!1}"$mp_openid"===e&&(e=_.getOpenidNameByAppid()),sa.store._state.identities.hasOwnProperty(e)&&t===sa.store._state.identities[e]&&(delete sa.store._state.identities[e],sa.store.save());var r={};r[e]=t,sa.saEvent.send({type:"track_id_unbind",event:"$UnbindID",unbind_value:r})},sa.setWebViewUrl=function(e,t){if(!_.isString(e)||""===e)return logger.info("error:\u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;if(!/^http(s)?:\/\//.test(e))return logger.info("warning: \u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;var a=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e);if(!a)return!1;var r,s=a[1]||"",i=a[2]||"",n=a[3]||"",o="",c=sa.store.getDistinctId()||"",u=sa.store.getFirstId()||"";_.urlSafeBase64&&_.urlSafeBase64.encode?c=c?_.urlSafeBase64.trim(_.urlSafeBase64.encode(_.urlBase64Encode(c))):"":this._.rot13obfs&&(c=c?_.rot13obfs(c):""),c=encodeURIComponent(c);var p=u?"f"+c:"d"+c;t?(r=n.indexOf("_sasdk"),o=n.indexOf("?")>-1?r>-1?s+i+"#"+n.substring(1,r)+"_sasdk="+p:s+i+"#"+n.substring(1)+"&_sasdk="+p:s+i+"#"+n.substring(1)+"?_sasdk="+p):(r=i.indexOf("_sasdk"),o=/^\?(\w)+/.test(i)?r>-1?s+i.replace(/(_sasdk=)([^&]*)/gi,"_sasdk="+p)+n:s+"?"+i.substring(1)+"&_sasdk="+p+n:s+"?"+i.substring(1)+"_sasdk="+p+n);return o},_.each(["setProfile","setOnceProfile","track","quick","incrementProfile","appendProfile","login","logout","registerApp","register","clearAllRegister","clearAllProps","clearAppRegister","bind","unbind"],function(e){var t=sa[e];sa[e]=function(){sa.initialState.isComplete?t.apply(sa,arguments):sa.initialState.queue.push([e,arguments])}}),_.setQuery=function(e,t){if(e&&_.isObject(e)&&!_.isEmptyObject(e)){var a=[];return _.each(e,function(e,r){"q"===r&&_.isString(e)&&0===e.indexOf("http")||(t?a.push(r+"="+e):a.push(r+"="+_.decodeURIComponent(e)))}),a.join("&")}return""},_.getUtmFromPage=function(){var e={};try{var t=_.getCurrentPage(),a=_.deepCopy(t.options);for(var r in a)a[r]=_.decodeURIComponent(a[r]);e=_.getCustomUtmFromQuery(a,"$","_","$")}catch(e){logger.info(e)}return e},_.sendPageLeave=function(){var e={},t="";try{t=(e=_.getCurrentPage())?e.route:""}catch(e){logger.info(e)}if(page_show_time>=0&&""!==t){var a={},r=_.getPageTitle(t),s=(Date.now()-page_show_time)/1e3;a.$url_query=e.sensors_mp_url_query?e.sensors_mp_url_query:"",a.$url_path=t,a.$title=r,a.event_duration=s,sa.track("$MPPageLeave",a),page_show_time=-1}};{var mp_proxy=function(e,t,a){var r=sa.autoTrackCustom[a];if(e[t]){var s=e[t];e[t]=function(){"onLaunch"===t&&(this[sa.para.name]=sa),!sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&!sa.para.autoTrackIsFirst[a]?(s.apply(this,arguments),r.apply(this,arguments)):(!0===sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&sa.para.autoTrackIsFirst[a])&&(r.apply(this,arguments),s.apply(this,arguments))}}else e[t]=function(){"onLaunch"===t&&(this[sa.para.name]=sa),r.apply(this,arguments)}};function clickTrack(e){var t,a={},r={},s=e.currentTarget||{},i=e.target||{};if(_.isObject(sa.para.framework)&&_.isObject(sa.para.framework.taro)&&!sa.para.framework.taro.createApp&&i.id&&s.id&&i.id!==s.id)return!1;var n=s.dataset||{};if(t=e.type,a.$element_id=s.id,a.$element_type=n.type,a.$element_content=n.content,a.$element_name=n.name,_.isObject(e.event_prop)&&(r=e.event_prop),t&&_.isClick(t)){if(sa.para.preset_events&&sa.para.preset_events.collect_element&&!1===sa.para.preset_events.collect_element(arguments[0]))return!1;a.$url_path=_.getCurrentPath(),_.setPageRefData(a),a=_.extend(a,r),sa.track("$MPClick",a)}}var click_proxy=function(e,t){var a=e[t];e[t]=function(){var e=a.apply(this,arguments),t=arguments[0];return _.isObject(t)&&(sa.para.preset_events.defer_track?setTimeout(function(){clickTrack(t)},0):clickTrack(t)),e}},tabProxy=function(e){var t=e.onTabItemTap;e.onTabItemTap=function(e){t&&t.apply(this,arguments);var a={};e&&(a.$element_content=e.text),a.$element_type="tabBar",a.$url_path=_.getCurrentPath(),_.setPageRefData(a),sa.track("$MPClick",a)}},pageLeaveProxy=function(e){var t=e.onHide;e.onHide=function(){t&&t.apply(this,arguments),_.sendPageLeave()};var a=e.onUnload;e.onUnload=function(){a&&a.apply(this,arguments),_.sendPageLeave()}}}if(sa.autoTrackCustom={trackCustom:function(e,t,a){var r=sa.para.autoTrack[e],s="";sa.para.autoTrack&&r&&("function"==typeof r?(s=r(),_.isObject(s)&&_.extend(t,s)):_.isObject(r)&&(_.extend(t,r),sa.para.autoTrack[e]=!0),sa.track(a,t))},appLaunch:function(e,t){"object"!=typeof this||this.trackCustom||(this[sa.para.name]=sa);var a={};if(e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path){if(a.$url_path=_.getPath(e.path),a.$title=_.getPageTitle(e.path),e.query&&_.isObject(e.query)){var r=_.setQuery(e.query);r=r?"?"+r:"",a.$url=a.$url_path+r}!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})}_.setShareInfo(e,a);var s=_.setUtm(e,a);is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(s.pre1)||sa.setOnceProfile(s.pre1)):a.$is_first_time=!1,_.setLatestChannel(s.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),_.setPageRefData(a),t?(a=_.extend(a,t),sa.track("$MPLaunch",a)):sa.para.autoTrack&&sa.para.autoTrack.appLaunch&&sa.autoTrackCustom.trackCustom("appLaunch",a,"$MPLaunch")},appShow:function(e,t){var a={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(a.$url_path=_.getPath(e.path),a.$title=_.getPageTitle(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,a);var r=_.setUtm(e,a);_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),_.setPageRefData(a,e.path,a.$url_query),e&&e.path&&(a.$url=e.path+(a.$url_query?"?"+a.$url_query:"")),t?(a=_.extend(a,t),sa.track("$MPShow",a)):sa.para.autoTrack&&sa.para.autoTrack.appShow&&sa.autoTrackCustom.trackCustom("appShow",a,"$MPShow")},appHide:function(e){var t=(new Date).getTime(),a={};a.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(a.event_duration=(t-mpshow_time)/1e3),_.setPageRefData(a),e?(a=_.extend(a,e),sa.track("$MPHide",a)):sa.para.autoTrack&&sa.para.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",a,"$MPHide"),sendStrategy.onAppHide()},pageLoad:function(e){current_scene&&1010===current_scene&&e&&(e.sampshare&&delete e.sampshare,_.delObjectKey(e)),e&&_.isObject(e)&&(this.sensors_mp_url_query=_.setQuery(e),this.sensors_mp_encode_url_query=_.setQuery(e,!0))},pageShow:function(){page_show_time=Date.now();var e={},t=_.getCurrentPath(),a=_.getPageTitle(t);_.setRefPage(),e.$url_path=t,e.$url_query=this.sensors_mp_url_query?this.sensors_mp_url_query:"",e=_.extend(e,_.getUtmFromPage()),_.setPageRefData(e),_.setPageSfSource(e),a&&(e.$title=a),sa.para.onshow?sa.para.onshow(sa,t,this):_.isObject(sa.para.autotrack_exclude_page)&&_.isArray(sa.para.autotrack_exclude_page.pageShow)&&-1!==sa.para.autotrack_exclude_page.pageShow.indexOf(t)||sa.autoTrackCustom.trackCustom("pageShow",e,"$MPViewScreen"),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:t})},pageShare:function(e){var t=e.onShareAppMessage;e.onShareAppMessage=function(){share_method="\u8f6c\u53d1\u6d88\u606f\u5361\u7247";var e=t.apply(this,arguments);if(sa.para.autoTrack&&sa.para.autoTrack.pageShare){var a={$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method};_.setPageRefData(a),sa.autoTrackCustom.trackCustom("pageShare",a,"$MPShare")}return sa.para.allow_amend_share_path&&("object"!=typeof e&&((e={}).path=_.getCurrentUrl(this)),"object"!=typeof e||void 0!==e.path&&""!==e.path||(e.path=_.getCurrentUrl(this)),"object"==typeof e&&"string"==typeof e.path&&(-1===e.path.indexOf("?")?e.path=e.path+"?":"&"!==e.path.slice(-1)&&(e.path=e.path+"&")),e.path=e.path+_.getShareInfo()),e}},pageShareTimeline:function(e){var t=e.onShareTimeline;e.onShareTimeline=function(){share_method="\u670b\u53cb\u5708\u5206\u4eab";var e=t.apply(this,arguments);if(sa.para.autoTrack&&sa.para.autoTrack.pageShare){var a={$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method};_.setPageRefData(a),sa.autoTrackCustom.trackCustom("pageShare",a,"$MPShare")}return sa.para.allow_amend_share_path&&("object"!=typeof e&&(e={}),"object"==typeof e&&void 0===e.query&&(e.query=""),"object"==typeof e&&"string"==typeof e.query&&""!==e.query&&"&"!==e.query.slice(-1)&&(e.query=e.query+"&"),e.query=e.query+_.getShareInfo()),e}},pageAddFavorites:function(){var e={};e.$url_path=_.getCurrentPath(),sa.para.autoTrack&&sa.para.autoTrack.mpFavorite&&sa.autoTrackCustom.trackCustom("mpFavorite",e,"$MPAddFavorites")}},sa.quick=function(){var e=arguments[0],t=arguments[1],a=arguments[2],r=_.isObject(a)?a:{};if("getAnonymousID"===e){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===e||"appShow"===e?t?sa.autoTrackCustom[e](t,r):logger.info("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(r=_.isObject(t)?t:{},sa.autoTrackCustom[e](r))},sa.appLaunch=function(e,t){var a={};e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(a.$url_path=_.getPath(e.path),a.$title=_.getPageTitle(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),_.setShareInfo(e,a);var r=_.setUtm(e,a);is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):a.$is_first_time=!1,_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),a.$url=e.path+(a.$url_query?"?"+a.$url_query:""),_.setPageRefData(t),_.isObject(t)&&(a=_.extend(a,t)),sa.track("$MPLaunch",a)},sa.appShow=function(e,t){var a={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(a.$url_path=_.getPath(e.path),a.$title=_.getPageTitle(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,a);var r=_.setUtm(e,a);_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),e&&e.path&&(a.$url=e.path+(a.$url_query?"?"+a.$url_query:"")),_.setPageRefData(a,e.path,a.$url_query),_.isObject(t)&&(a=_.extend(a,t)),sa.track("$MPShow",a)},sa.appHide=function(e){var t=(new Date).getTime(),a={};a.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(a.event_duration=(t-mpshow_time)/1e3),_.setPageRefData(a),_.isObject(e)&&(a=_.extend(a,e)),sa.track("$MPHide",a),sendStrategy.onAppHide()},sa.pageShow=function(e){var t={},a=_.getCurrentPath(),r=_.getPageTitle(a),s=_.getCurrentPage();_.setRefPage(),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a}),r&&(t.$title=r),t.$url_path=a,t.$url_query=s.sensors_mp_url_query?s.sensors_mp_url_query:"",t=_.extend(t,_.getUtmFromPage()),_.setPageSfSource(t),_.setPageRefData(t),_.isObject(e)&&(t=_.extend(t,e)),sa.track("$MPViewScreen",t)},sa.App=function(e){(e=e||{})[sa.para.name]=sa,App.apply(this,arguments)},wx.onAppShow(function(e){if(!deploy_para.launched){var t=wx.getLaunchOptionsSync()||{};sa.autoTrackCustom.appLaunch(t),deploy_para.launched=!0}sa.autoTrackCustom.appShow(e)}),wx.onAppHide(function(){sa.autoTrackCustom.appHide()}),sa.Page=function(e){var t=sa.para.autoTrack&&sa.para.autoTrack.mpClick&&_.getMethods(e);if(t)for(var a=0,r=t.length;a0){for(var r=0;r=500&&(sa._.logger.info("\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38"),sa.store.mem.mdata.shift()),(e=kit.processData(e))&&sa.store.mem.add(e),sa.store.mem.getLength()>=sa.para.batch_send.max_length&&this.batchSend()},wxrequest:function(e){if(sa._.isArray(e.data)&&e.data.length>0){var t=kit.batchTrackData(e.data);sa._.wxrequest({url:sa.para.server_url,method:"POST",dataType:"text",data:t,success:function(){e.success(e.len)},fail:function(){e.fail()}})}else e.success(e.len)},batchSend:function(){if(this.dataHasSend){var e,t,a=sa.store.mem.mdata;(t=(e=a.length>=100?a.slice(0,100):a).length)>0&&(this.dataHasSend=!1,this.wxrequest({data:e,len:t,success:this.batchRemove.bind(this),fail:this.sendFail.bind(this)}))}},sendFail:function(){this.dataHasSend=!0,this.failTime++},batchRemove:function(e){sa.store.mem.clear(e),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite(),this.failTime=0},is_first_batch_write:!0,batchWrite:function(){var e=this;this.dataHasChange&&(this.is_first_batch_write&&(this.is_first_batch_write=!1,setTimeout(function(){e.batchSend()},1e3)),this.dataHasChange=!1,this.syncStorage&&sa._.setStorageSync(sa.para.storage_prepare_data_key,sa.store.mem.mdata))},batchInterval:function(){var e=this;!function t(){setTimeout(function(){e.batchWrite(),t()},500)}(),function t(){setTimeout(function(){e.batchSend(),t()},sa.para.batch_send.send_timeout*Math.pow(2,e.failTime))}()}};function getSendUrl(e,t){var a=kit.onceTrackData(t);return-1!==e.indexOf("?")?e+"&"+a:e+"?"+a}function onceSend(e){e._flush_time=Date.now();var t=getSendUrl(sa.para.server_url,e);sa._.wxrequest({url:t,method:"GET"})}var saEvent={send:function(e,t){if(!sa.para.server_url)return sa._.logger.info("error: server_url \u4e0d\u80fd\u4e3a\u7a7a"),!1;if(sa.current_scene&&1154===sa.current_scene&&!sa.para.preset_events.moments_page)return!1;var a=sa.kit.buildData(e);a?(saEvent.debug(a),sa.events.emit("send",a),sa.para.batch_send?sendStrategy.send(a):onceSend(a)):sa._.logger.info("error: \u6570\u636e\u5f02\u5e38 "+a)},debug:function(e){sa._.logger.info(e)}},_={};sa.kit=kit,sa.mergeStorageData=mergeStorageData,sa.saEvent=saEvent,sa.sendStrategy=sendStrategy,sa.IDENTITY_KEY={EMAIL:"$identity_email",MOBILE:"$identity_mobile"},sa.para={name:"sensors",server_url:"",send_timeout:1e3,show_log:!1,login_id_key:"$identity_login_id",allow_amend_share_path:!0,max_string_length:500,datasend_timeout:3e3,source_channel:[],autoTrack:{appLaunch:!0,appShow:!0,appHide:!0,pageShow:!0,pageShare:!0,mpClick:!1,mpFavorite:!0,pageLeave:!1},autotrack_exclude_page:{pageShow:[]},is_persistent_save:{share:!1,utm:!1},preset_properties:{url_path:!0},preset_events:{moments_page:!1,defer_track:!1,share_info_use_string:!1},batch_send:!0,storage_store_key:"sensorsdata2015_wechat",storage_prepare_data_key:"sensors_mp_prepare_data"};var deploy_para={launched:!1},mpHook={data:1,onLoad:1,onShow:1,onReady:1,onPullDownRefresh:1,onShareAppMessage:1,onShareTimeline:1,onReachBottom:1,onPageScroll:1,onResize:1,onTabItemTap:1,onHide:1,onUnload:1},logger="object"==typeof logger?logger:{};logger.info=function(){if(sa.para.show_log&&"object"==typeof console&&console.log)try{if(3===arguments.length)return console.log(arguments[0],arguments[1],arguments[2]);if(2===arguments.length)return console.log(arguments[0],arguments[1]);if(1===arguments.length)return console.log(arguments[0])}catch(e){console.log(arguments[0])}},sa.setPara=function(e){sa.para=_.extend2Lev(sa.para,e);var t=[];if(_.isArray(sa.para.source_channel))for(var a=sa.para.source_channel.length,r=0;rsa.para.max_string_length?(logger.info("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,sa.para.max_string_length)):e},_.searchObjString=function(e){_.isObject(e)&&_.each(e,function(t,a){_.isObject(t)?_.searchObjString(e[a]):_.isString(t)&&(e[a]=_.formatString(t))})},_.parseSuperProperties=function(e){_.isObject(e)&&(_.each(e,function(t,a){if(_.isFunction(t))try{e[a]=t(),_.isFunction(e[a])&&(logger.info("\u60a8\u7684\u5c5e\u6027- "+a+" \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}catch(t){delete e[a],logger.info("\u60a8\u7684\u5c5e\u6027- "+a+" \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}}),_.strip_sa_properties(e))},_.unique=function(e){for(var t,a=[],r={},s=0;s255)||(logger.info("id \u957f\u5ea6\u8d85\u8fc7 255 \u4e2a\u5b57\u7b26\uff01"),!1)}},_.strip_sa_properties=function(e){return _.isObject(e)?(_.each(e,function(t,a){if(_.isArray(t)){var r=[];_.each(t,function(e){_.isString(e)?r.push(e):logger.info("\u60a8\u7684\u6570\u636e-",t,"\u7684\u6570\u7ec4\u91cc\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32,\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}),e[a]=r}_.isString(t)||_.isNumber(t)||_.isDate(t)||_.isBoolean(t)||_.isArray(t)||(logger.info("\u60a8\u7684\u6570\u636e-",t,"-\u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}),e):e},_.strip_empty_properties=function(e){var t={};return _.each(e,function(e,a){null!=e&&(t[a]=e)}),t},_.utf8Encode=function(e){var t,a,r,s,i="";for(t=a=0,r=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,s=0;s127&&n<2048?String.fromCharCode(n>>6|192,63&n|128):String.fromCharCode(n>>12|224,n>>6&63|128,63&n|128),null!==o&&(a>t&&(i+=e.substring(t,a)),i+=o,t=a=s+1)}return a>t&&(i+=e.substring(t,e.length)),i},_.base64Encode=function(e){var t,a,r,s,i,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,c=0,u="",p=[];if(!e)return e;e=_.utf8Encode(e);do{t=(i=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,a=i>>12&63,r=i>>6&63,s=63&i,p[c++]=n.charAt(t)+n.charAt(a)+n.charAt(r)+n.charAt(s)}while(o255||(r=e.charCodeAt(o++))>255||(s=e.charCodeAt(o++))>255)&&logger.info("Failed to execute 'btoa' : The string to be encoded contains characters outside of the Latin1 range."),n+=i.charAt((t=a<<16|r<<8|s)>>18&63)+i.charAt(t>>12&63)+i.charAt(t>>6&63)+i.charAt(63&t);return _?n.slice(0,_-3)+"===".substring(_):n},_.urlBase64Encode=function(e){return _.btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))},_.rot13obfs=function(e,t){t="number"==typeof t?t:13;for(var a=(e=String(e)).split(""),r=0,s=a.length;r(new Date).getTime()},_.getCurrentUrl=function(e){var t=_.getCurrentPath(),a="";return _.isObject(e)&&e.sensors_mp_encode_url_query&&(a=e.sensors_mp_encode_url_query),t?a?t+"?"+a:t:"\u672a\u53d6\u5230"},_.getPath=function(e){return e="string"==typeof e?e.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"},_.getMethods=function(e){var t=[];for(var a in e)"function"!=typeof e[a]||mpHook[a]||t.push(a);return t},_.isClick=function(e){return!!{tap:1,longpress:1,longtap:1}[e]},sa.initialState={queue:[],isComplete:!1,systemIsComplete:!1,storeIsComplete:!1,checkIsComplete:function(){this.systemIsComplete&&this.storeIsComplete&&(this.isComplete=!0,this.queue.length>0&&(_.each(this.queue,function(e){sa[e[0]].apply(sa,slice.call(e[1]))}),this.queue=[]))}},_.getCustomUtmFromQuery=function(e,t,a,r){if(!_.isObject(e))return{};var s={};if(e.sa_utm)for(var i in e)"sa_utm"!==i?_.include(sa.para.source_channel,i)&&(s[a+i]=e[i]):s[r+i]=e[i];else for(var i in e)-1===(" "+source_channel_standard+" ").indexOf(" "+i+" ")?_.include(sa.para.source_channel,i)&&(s[a+i]=e[i]):s[t+i]=e[i];return s},_.getObjFromQuery=function(e){var t=e.split("?"),a=[],r={};return t&&t[1]?(_.each(t[1].split("&"),function(e){(a=e.split("="))[0]&&a[1]&&(r[a[0]]=a[1])}),r):{}},_.setStorageSync=function(e,t){var a=function(){wx.setStorageSync(e,t)};try{a()}catch(e){logger.info("set Storage fail --",e);try{a()}catch(e){logger.info("set Storage fail again --",e)}}},_.getStorageSync=function(e){var t="";try{t=wx.getStorageSync(e)}catch(a){try{t=wx.getStorageSync(e)}catch(e){logger.info("getStorage fail")}}return t},_.getMPScene=function(e){return"number"==typeof e||"string"==typeof e&&""!==e?e="wx-"+String(e):"\u672a\u53d6\u5230\u503c"},_.objToParam=function(e,t){if("[object Object]"!==Object.prototype.toString.call(e))return logger.info("\u8bf7\u4f20\u5165\u6709\u6548\u5bf9\u8c61"),"";var a=[];for(var r in e)if(e.hasOwnProperty(r)){var s=e[r];void 0===s?a.push(r+"="):(s=t?encodeURIComponent(s):s,a.push(r+"="+s))}return a.join("&")},_.delObjectKey=function(e){if("[object Object]"===Object.prototype.toString.call(e))for(var t=0;t=2?(page_route_map.shift(),page_route_map.push(e)):page_route_map.push(e)}}catch(e){logger.info(e)}},_.getRefPage=function(){var e={route:"\u76f4\u63a5\u6253\u5f00",title:""};return page_route_map.length>1&&(e.title=page_route_map[0].title,e.route=page_route_map[0].route),e},_.getCurrentPageInfo=function(){var e=_.getCurrentPage(),t={title:"",url:"",path:"\u672a\u53d6\u5230"};if(e&&e.route){var a=e.sensors_mp_url_query?"?"+e.sensors_mp_url_query:"";t.title=_.getPageTitle(e.route),t.url=e.route+a,t.path=e.route}return t},_.setPageRefData=function(e,t,a){var r=_.getRefPage();_.isObject(e)&&(t?page_route_map.length>0&&t?(a=a?"?"+a:"",e.$referrer=_.getPath(t)+a,e.$referrer_title=_.getPageTitle(t)):(e.$referrer="\u76f4\u63a5\u6253\u5f00",e.$referrer_title=""):(e.$referrer=r.route,e.$referrer_title=r.title))},_.getPageTitle=function(e){if("\u672a\u53d6\u5230"===e||!e)return"";var t="";try{if(__wxConfig){var a=__wxConfig,r=__wxConfig.page||{},s=r[e]||r[e+".html"],i={},n={};if(a.global&&a.global.window&&a.global.window.navigationBarTitleText&&(i.titleVal=a.global.window.navigationBarTitleText),s&&s.window&&s.window.navigationBarTitleText&&(n.titleVal=s.window.navigationBarTitleText),!n.titleVal&&__wxAppCode__){var o=__wxAppCode__[e+".json"];o&&o.navigationBarTitleText&&(n.titleVal=o.navigationBarTitleText)}if(_.each(globalTitle,function(a,r){if(r===e)return t=a}),0===t.length){var c=_.extend(i,n);t=c.titleVal||""}}}catch(e){logger.info(e)}return t},_.wxrequest=function(e){if(_.compareSDKVersion(wxSDKVersion,"2.10.0")>=0)e.timeout=sa.para.datasend_timeout,wx.request(e);else{var t=wx.request(e);setTimeout(function(){_.isObject(t)&&_.isFunction(t.abort)&&t.abort()},sa.para.datasend_timeout)}},_.getAppInfoSync=function(){if(wx.getAccountInfoSync){var e=wx.getAccountInfoSync(),t=e&&e.miniProgram?e.miniProgram:{};return{appId:t.appId,appEnv:t.envVersion,appVersion:t.version}}return{}},_.getAppId=function(){var e=_.getAppInfoSync();return e&&e.appId?e.appId:""},_.validId=function(e){return"string"!=typeof e&&"number"!=typeof e||""===e?(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1):"number"!=typeof e||(e=String(e),/^\d+$/.test(e))?!!_.check.ckeckIdLength(e)&&e:(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1)},_.compareSDKVersion=function(e,t){e=e.split("."),t=t.split(".");for(var a=Math.max(e.length,t.length);e.lengthi)return 1;if(s-1?t.system.split(" ")[1]:t.system,wxSDKVersion=t.SDKVersion,e.$mp_client_app_version=t.version,e.$mp_client_basic_library_version=wxSDKVersion},complete:function(){var t=(new Date).getTimezoneOffset(),a=_.getAppInfoSync();_.isNumber(t)&&(e.$timezone_offset=t),a.appId&&(e.$app_id=a.appId),a.appVersion&&(e.$app_version=a.appVersion),sa.initialState.systemIsComplete=!0,sa.initialState.checkIsComplete()}})}wx.getNetworkType({success:function(t){e.$network_type=_.setUpperCase(t.networkType)},complete:t})}},sa._=_,_.eventEmitter=function(){this.sub=[]},_.eventEmitter.prototype={add:function(e){this.sub.push(e)},emit:function(e,t){this.sub.forEach(function(a){a.on(e,t)})}},_.eventSub=function(e){sa.events.add(this),this._events=[],this.handle=e,this.ready=!1},_.eventSub.prototype={on:function(e,t){if(this.ready){if(_.isFunction(this.handle))try{this.handle(e,t)}catch(e){logger.info(e)}}else this._events.push({event:e,data:t})},isReady:function(){var e=this;e.ready=!0,e._events.forEach(function(t){if(_.isFunction(e.handle))try{e.handle(t.event,t.data)}catch(e){logger.info(e)}})}},sa.eventSub=_.eventSub,sa.events=new _.eventEmitter,sa.usePlugin=function(e,t){"function"==typeof e.init&&e.init(sa,t)},sa.store={storageInfo:null,getUUID:function(){return Date.now()+"-"+Math.floor(1e7*getRandom())+"-"+getRandom().toString(16).replace(".","")+"-"+String(31242*getRandom()).replace(".","").slice(0,8)},getStorage:function(){return this.storageInfo?this.storageInfo:(this.storageInfo=sa._.getStorageSync(sa.para.storage_store_key)||"",this.storageInfo)},_state:{},mem:{mdata:[],getLength:function(){return this.mdata.length},add:function(e){this.mdata.push(e)},clear:function(e){this.mdata.splice(0,e)}},toState:function(e){var t=null;_.isJSONString(e)?(t=JSON.parse(e)).distinct_id?this._state=t:this.set("distinct_id",this.getUUID()):_.isObject(e)&&(t=e).distinct_id?this._state=t:this.set("distinct_id",this.getUUID());var a=this._state._first_id||this._state.first_id,r=this._state._distinct_id||this._state.distinct_id,s=this._state.openid,i=(this._state.history_login_id?this._state.history_login_id:{}).name;if(this._state.identities&&_.isString(this._state.identities)){var n=JSON.parse(_.rot13defs(this._state.identities));this._state.identities=n}var o,c,u=_.getOpenidNameByAppid();if(this._state.identities&&_.isObject(this._state.identities)&&!_.isEmptyObject(this._state.identities)){var p=(o=_.getAppId(),c="$mp_openid",o&&(c="$mp_"+o+"_openid"),c);this._state.identities.hasOwnProperty("$mp_id")&&(this._state.identities.$identity_mp_id=this._state.identities.$mp_id,delete this._state.identities.$mp_id),this._state.identities.hasOwnProperty("$mp_unionid")&&(this._state.identities.$identity_mp_unionid=this._state.identities.$mp_unionid,delete this._state.identities.$mp_unionid),this._state.identities.hasOwnProperty(p)&&(this._state.identities[u]=this._state.identities[p],delete this._state.identities[p]),this._state.identities.hasOwnProperty("$identity_anonymous_id")&&(this._state.identities.$identity_anonymous_id=a||r)}else this._state.identities={},this._state.identities.$identity_mp_id=this.getUUID(),this._state.identities.$identity_anonymous_id=a||r;if(s&&(this._state.identities[u]=s),a)if(i&&this._state.identities.hasOwnProperty(i)){if(this._state.identities[i]!==r){for(var d in this._state.identities[i]=r,this._state.identities)this._state.identities.hasOwnProperty(d)&&"$identity_mp_id"!==d&&d!==i&&delete this._state.identities[d];this._state.history_login_id.value=r}}else{for(var d in this._state.identities[sa.para.login_id_key]=r,this._state.identities)this._state.identities.hasOwnProperty(d)&&"$identity_mp_id"!==d&&d!==sa.para.login_id_key&&delete this._state.identities[d];this._state.history_login_id={name:sa.para.login_id_key,value:r}}else{if(this._state.identities.hasOwnProperty("$identity_login_id")||this._state.identities.hasOwnProperty(i))for(var d in this._state.identities)this._state.identities.hasOwnProperty(d)&&"$identity_mp_id"!==d&&"$identity_anonymous_id"!==d&&delete this._state.identities[d];this._state.history_login_id={name:"",value:""}}this.save()},getFirstId:function(){return this._state._first_id||this._state.first_id},getDistinctId:function(){return this._state._distinct_id||this._state.distinct_id},getUnionId:function(){var e={},t=this._state._first_id||this._state.first_id,a=this._state._distinct_id||this._state.distinct_id;return t&&a?(e.login_id=a,e.anonymous_id=t):e.anonymous_id=a,e},getProps:function(){return this._state.props||{}},setProps:function(e,t){var a=this._state.props||{};t?this.set("props",e):(_.extend(a,e),this.set("props",a))},set:function(e,t){var a={};for(var r in"string"==typeof e?a[e]=t:"object"==typeof e&&(a=e),this._state=this._state||{},a)this._state[r]=a[r],"first_id"===r?delete this._state._first_id:"distinct_id"===r&&(delete this._state._distinct_id,sa.events.emit("changeDistinctId"));this.save()},identitiesSet:function(e,t){var a={};switch(e){case"login":a.$identity_mp_id=sa.store._state.identities.$identity_mp_id,a[sa.para.login_id_key]=t;break;case"logout":a.$identity_mp_id=sa.store._state.identities.$identity_mp_id;break;case"identify":(a=_.deepCopy(sa.store._state.identities)).$identity_anonymous_id=t}sa.store.set("identities",a)},change:function(e,t){this._state["_"+e]=t},encryptStorage:function(){var e=this.getStorage(),t="data:enc;";_.isObject(e)?e=t+_.rot13obfs(JSON.stringify(e)):_.isString(e)&&-1===e.indexOf(t)&&(e=t+_.rot13obfs(e)),sa._.setStorageSync(sa.para.storage_store_key,e)},save:function(){var e=_.deepCopy(this._state),t=_.rot13obfs(JSON.stringify(e.identities));if(e.identities=t,delete e._first_id,delete e._distinct_id,sa.para.encrypt_storage){e="data:enc;"+_.rot13obfs(JSON.stringify(e))}sa._.setStorageSync(sa.para.storage_store_key,e)},init:function(){var e=this.getStorage();if(e)_.isString(e)&&-1!==e.indexOf("data:enc;")&&(e=e.substring("data:enc;".length),e=JSON.parse(_.rot13defs(e))),this.toState(e);else{is_first_launch=!0;var t=new Date,a=t.getTime();t.setHours(23),t.setMinutes(59),t.setSeconds(60),sa.setOnceProfile({$first_visit_time:new Date}),this.set({distinct_id:this.getUUID(),first_visit_time:a,first_visit_day_time:t.getTime(),identities:{$identity_mp_id:this.getUUID()},history_login_id:{name:"",value:""}})}}},sa.setProfile=function(e,t){sa.saEvent.send({type:"profile_set",properties:e},t)},sa.setOnceProfile=function(e,t){sa.saEvent.send({type:"profile_set_once",properties:e},t)},sa.appendProfile=function(e,t){if(!_.isObject(e))return!1;_.each(e,function(t,a){_.isString(t)?e[a]=[t]:(delete e[a],logger.info("appendProfile\u5c5e\u6027\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32\u6216\u8005\u6570\u7ec4"))}),sa.saEvent.send({type:"profile_append",properties:e},t)},sa.incrementProfile=function(e,t){if(!_.isObject(e))return!1;var a=e;_.isString(e)&&((e={})[a]=1),sa.saEvent.send({type:"profile_increment",properties:e},t)},sa.track=function(e,t,a){this.saEvent.send({type:"track",event:e,properties:t},a)},sa.identify=function(e,t){if(e=_.validId(e)){var a=sa.store.getFirstId();!0===t?a?sa.store.set("first_id",e):sa.store.set("distinct_id",e):a?sa.store.change("first_id",e):sa.store.change("distinct_id",e),sa.store.identitiesSet("identify",e)}},sa.trackSignup=function(e,t,a,r){var s=sa.store.getFirstId()||sa.store.getDistinctId();sa.store.set("distinct_id",e),sa.saEvent.send({original_id:s,distinct_id:e,type:"track_signup",event:t,properties:a},r)},sa.registerApp=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&(_.info.currentProps=_.extend(_.info.currentProps,e))},sa.register=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&sa.store.setProps(e)},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.clearAllProps=function(e){var t=sa.store.getProps(),a={};_.isArray(e)&&(_.each(t,function(t,r){_.include(e,r)||(a[r]=t)}),sa.store.setProps(a,!0))},sa.clearAppRegister=function(e){_.isArray(e)&&_.each(_.info.currentProps,function(t,a){_.include(e,a)&&delete _.info.currentProps[a]})},_.setLatestChannel=function(e){_.isEmptyObject(e)||(function(e,t){var a=!1;for(var r in t)e[t[r]]&&(a=!0);return a}(e,latest_source_channel)&&(sa.clearAppRegister(latest_source_channel),sa.clearAllProps(latest_source_channel)),sa.para.is_persistent_save.utm?sa.register(e):sa.registerApp(e))},_.setLatestShare=function(e){(e.$latest_share_depth||e.$latest_share_distinct_id||e.$latest_share_url_path||e.$latest_share_method)&&(sa.clearAppRegister(latest_share_info),sa.clearAllProps(latest_share_info),sa.para.is_persistent_save.share?sa.register(e):sa.registerApp(e))},sa.login=function(e){if(e=_.validId(e)){var t=sa.store.getFirstId(),a=sa.store.getDistinctId();if(sa.store._state.identities.hasOwnProperty(sa.para.login_id_key)&&e===t)return!1;var r=!(sa.para.login_id_key===sa.store._state.history_login_id.name&&sa.store._state.history_login_id.value===e);r&&(sa.store._state.identities[sa.para.login_id_key]=e),r&&(t?sa.trackSignup(e,"$SignUp"):(sa.store.set("first_id",a),sa.trackSignup(e,"$SignUp"))),r&&(sa.store.identitiesSet("login",e),sa.store.set("history_login_id",{name:sa.para.login_id_key,value:e}))}},sa.getAnonymousID=function(){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")},sa.logout=function(e){var t=sa.store.getFirstId();t?(sa.store.set("first_id",""),!0===e?sa.store.set("distinct_id",sa.store.getUUID()):sa.store.set("distinct_id",t)):logger.info("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25"),sa.store.identitiesSet("logout"),sa.store.set("history_login_id",{name:"",value:""})},sa.getLocation=function(){wx.getSetting({success:function(e){if(!e.authSetting["scope.userLocation"])return!1;wx.getLocation({type:sa.para.preset_properties.location.type,success:function(e){sa.registerApp({$latitude:e.latitude*Math.pow(10,6),$longitude:e.longitude*Math.pow(10,6),$geo_coordinate_system:_.setUpperCase(sa.para.preset_properties.location.type)})},fail:function(e){logger.info("\u83b7\u53d6\u4f4d\u7f6e\u5931\u8d25",e)}})}})},sa.openid={getRequest:function(e){wx.login({success:function(t){t.code&&sa.para.appid&&sa.para.openid_url?_.wxrequest({url:sa.para.openid_url+"&code="+t.code+"&appid="+sa.para.appid,method:"GET",complete:function(t){_.isObject(t)&&_.isObject(t.data)&&t.data.openid?e(t.data.openid):e()}}):e()}})},getWXStorage:function(){var e=sa.store.getStorage();if(e&&_.isObject(e))return e.openid},getOpenid:function(e){if(!sa.para.appid)return e(),!1;var t=this.getWXStorage();t?e(t):this.getRequest(e)}},sa.initial=function(){this._.info.getSystem(),this.store.init()},sa.init=function(e){if(!0===this.hasInit)return!1;this.hasInit=!0,sa.setPara(e),sa.para.encrypt_storage&&this.store.encryptStorage(),sa.para.batch_send&&sendStrategy.init(),sa.initialState.storeIsComplete=!0,sa.initialState.checkIsComplete()},sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib){var e={};_.each(_.info.currentProps,function(t,a){0===a.indexOf("$")&&(e[a]=t)});var t={$url_path:_.getCurrentPath(),$is_first_day:_.getIsFirstDay(),$is_first_time:is_first_launch},a=_.extend(e,t,_.info.properties,sa.store.getProps());return delete a.$lib,a}return{}},sa.setOpenid=function(e,t){if(!(e=_.validId(e)))return!1;t&&console.log("%c \u5f53\u524d\u7248\u672c setOpenid \u63a5\u53e3 \u5df2\u4e0d\u652f\u6301\u4f20\u5165\u7b2c\u4e8c\u4e2a\u53c2\u6570","color:#F39C12;font-size: 14px;"),sa.store.set("openid",e),sa.identify(e,!0),sa.bind("$identity_mp_openid",e)},sa.unsetOpenid=function(e){var t=_.validId(e);if(!t)return!1;sa.store._state.openid===t&&sa.store.set("openid",""),sa.unbind("$identity_mp_openid",t)},sa.setUnionid=function(e){var t=_.validId(e);t&&sa.bind("$identity_mp_unionid",t)},sa.unsetUnionid=function(e){var t=_.validId(e);if(t){if(sa.store._state.identities.hasOwnProperty("$identity_mp_unionid")&&t===sa.store._state.identities.$identity_mp_unionid){var a=_.getOpenidNameByAppid();sa.store._state.identities.hasOwnProperty(a)&&(delete sa.store._state.identities[a],delete sa.store._state.openid,sa.store.save())}sa.unbind("$identity_mp_unionid",t)}},sa.initWithOpenid=function(e,t){(e=e||{}).appid&&(sa.para.appid=e.appid),sa.openid.getOpenid(function(a){a&&sa.setOpenid(a,e.isCoverLogin),t&&_.isFunction(t)&&t(a),sa.init(e)})},sa.bind=function(e,t){if(_.isNumber(t)){if(_.isInteger(t)&&!1===_.isSafeInteger(t))return logger.info("Value must be String"),!1;t=String(t)}if(!_.isString(e))return logger.info("Key must be String"),!1;if(!_.check.checkKeyword(e)||"$identity_anonymous_id"===e||"$mp_id"===e||"$identity_mp_id"===e||"$identity_login_id"===e||e===sa.para.login_id_key){var a="Key ["+e+"] is invalid";return logger.info(a),!1}if(!t||""===t)return logger.info("Value is empty or null"),!1;if(!_.isString(t))return logger.info("Value must be String"),!1;if(!_.check.ckeckIdLength(t)){a="Value ["+t+"] is beyond the maximum length 255";return logger.info(a),!1}var r=sa.store._state.identities;"$identity_mp_openid"===e&&(e=_.getOpenidNameByAppid()),r[e]=t,sa.store.save(),sa.saEvent.send({type:"track_id_bind",event:"$BindID"})},sa.unbind=function(e,t){if(_.isNumber(t)){if(_.isInteger(t)&&!1===_.isSafeInteger(t))return logger.info("Value must be String"),!1;t=String(t)}if(!_.isString(e))return logger.info("Key must be String"),!1;if(!_.check.checkKeyword(e)||"$identity_anonymous_id"===e||"$mp_id"===e||"$identity_mp_id"===e||"$identity_login_id"===e||e===sa.para.login_id_key){var a="Key ["+e+"] is invalid";return logger.info(a),!1}if(!t||""===t)return logger.info("Value is empty or null"),!1;if(!_.isString(t))return logger.info("Value must be String"),!1;if(!_.check.ckeckIdLength(t)){a="Value ["+t+"] is beyond the maximum length 255";return logger.info(a),!1}"$identity_mp_openid"===e&&(e=_.getOpenidNameByAppid()),sa.store._state.identities.hasOwnProperty(e)&&t===sa.store._state.identities[e]&&(delete sa.store._state.identities[e],sa.store.save());var r={};r[e]=t,sa.saEvent.send({type:"track_id_unbind",event:"$UnbindID",unbind_value:r})},sa.setWebViewUrl=function(e,t){if(!_.isString(e)||""===e)return logger.info("error:\u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;if(!/^http(s)?:\/\//.test(e))return logger.info("warning: \u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;var a=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e);if(!a)return!1;var r,s=a[1]||"",i=a[2]||"",n=a[3]||"",o="",c=sa.store.getDistinctId()||"",u=sa.store.getFirstId()||"";_.urlSafeBase64&&_.urlSafeBase64.encode?c=c?_.urlSafeBase64.trim(_.urlSafeBase64.encode(_.urlBase64Encode(c))):"":this._.rot13obfs&&(c=c?_.rot13obfs(c):""),c=encodeURIComponent(c);var p=u?"f"+c:"d"+c;t?(r=n.indexOf("_sasdk"),o=n.indexOf("?")>-1?r>-1?s+i+"#"+n.substring(1,r)+"_sasdk="+p:s+i+"#"+n.substring(1)+"&_sasdk="+p:s+i+"#"+n.substring(1)+"?_sasdk="+p):(r=i.indexOf("_sasdk"),o=/^\?(\w)+/.test(i)?r>-1?s+i.replace(/(_sasdk=)([^&]*)/gi,"_sasdk="+p)+n:s+"?"+i.substring(1)+"&_sasdk="+p+n:s+"?"+i.substring(1)+"_sasdk="+p+n);return o},_.each(["setProfile","setOnceProfile","track","quick","incrementProfile","appendProfile","login","logout","registerApp","register","clearAllRegister","clearAllProps","clearAppRegister","bind","unbind","unsetOpenid","setUnionid","unsetUnionid"],function(e){var t=sa[e];sa[e]=function(){sa.initialState.isComplete?t.apply(sa,arguments):sa.initialState.queue.push([e,arguments])}}),_.setQuery=function(e,t){if(e&&_.isObject(e)&&!_.isEmptyObject(e)){var a=[];return _.each(e,function(e,r){"q"===r&&_.isString(e)&&0===e.indexOf("http")||(t?a.push(r+"="+e):a.push(r+"="+_.decodeURIComponent(e)))}),a.join("&")}return""},_.getUtmFromPage=function(){var e={};try{var t=_.getCurrentPage(),a=_.deepCopy(t.options);for(var r in a)a[r]=_.decodeURIComponent(a[r]);e=_.getCustomUtmFromQuery(a,"$","_","$")}catch(e){logger.info(e)}return e},_.sendPageLeave=function(){var e={},t="";try{t=(e=_.getCurrentPage())?e.route:""}catch(e){logger.info(e)}if(page_show_time>=0&&""!==t){var a={},r=_.getPageTitle(t),s=(Date.now()-page_show_time)/1e3;a.$url_query=e.sensors_mp_url_query?e.sensors_mp_url_query:"",a.$url_path=t,a.$title=r,a.event_duration=s,sa.track("$MPPageLeave",a),page_show_time=-1}};{var mp_proxy=function(e,t,a){var r=sa.autoTrackCustom[a];if(e[t]){var s=e[t];e[t]=function(){"onLaunch"===t&&(this[sa.para.name]=sa),!sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&!sa.para.autoTrackIsFirst[a]?(s.apply(this,arguments),r.apply(this,arguments)):(!0===sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&sa.para.autoTrackIsFirst[a])&&(r.apply(this,arguments),s.apply(this,arguments))}}else e[t]=function(){"onLaunch"===t&&(this[sa.para.name]=sa),r.apply(this,arguments)}};function clickTrack(e){var t,a={},r={},s=e.currentTarget||{},i=e.target||{};if(_.isObject(sa.para.framework)&&_.isObject(sa.para.framework.taro)&&!sa.para.framework.taro.createApp&&i.id&&s.id&&i.id!==s.id)return!1;var n=s.dataset||{};if(t=e.type,a.$element_id=s.id,a.$element_type=n.type,a.$element_content=n.content,a.$element_name=n.name,_.isObject(e.event_prop)&&(r=e.event_prop),t&&_.isClick(t)){if(sa.para.preset_events&&sa.para.preset_events.collect_element&&!1===sa.para.preset_events.collect_element(arguments[0]))return!1;a.$url_path=_.getCurrentPath(),_.setPageRefData(a),a=_.extend(a,r),sa.track("$MPClick",a)}}var click_proxy=function(e,t){var a=e[t];e[t]=function(){var e=a.apply(this,arguments),t=arguments[0];return _.isObject(t)&&(sa.para.preset_events.defer_track?setTimeout(function(){clickTrack(t)},0):clickTrack(t)),e}},tabProxy=function(e){var t=e.onTabItemTap;e.onTabItemTap=function(e){t&&t.apply(this,arguments);var a={};e&&(a.$element_content=e.text),a.$element_type="tabBar",a.$url_path=_.getCurrentPath(),_.setPageRefData(a),sa.track("$MPClick",a)}},pageLeaveProxy=function(e){var t=e.onHide;e.onHide=function(){t&&t.apply(this,arguments),_.sendPageLeave()};var a=e.onUnload;e.onUnload=function(){a&&a.apply(this,arguments),_.sendPageLeave()}}}if(sa.autoTrackCustom={trackCustom:function(e,t,a){var r=sa.para.autoTrack[e],s="";sa.para.autoTrack&&r&&("function"==typeof r?(s=r(),_.isObject(s)&&_.extend(t,s)):_.isObject(r)&&(_.extend(t,r),sa.para.autoTrack[e]=!0),sa.track(a,t))},appLaunch:function(e,t){"object"!=typeof this||this.trackCustom||(this[sa.para.name]=sa);var a={};if(e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(a.$url_path=_.getPath(e.path),a.$title=_.getPageTitle(e.path),e.query&&_.isObject(e.query))){var r=_.setQuery(e.query);r=r?"?"+r:"",a.$url=a.$url_path+r}_.setShareInfo(e,a);var s=_.setUtm(e,a);is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(s.pre1)||sa.setOnceProfile(s.pre1)):a.$is_first_time=!1,_.setLatestChannel(s.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),_.setPageRefData(a),t?(a=_.extend(a,t),sa.track("$MPLaunch",a)):sa.para.autoTrack&&sa.para.autoTrack.appLaunch&&sa.autoTrackCustom.trackCustom("appLaunch",a,"$MPLaunch")},appShow:function(e,t){var a={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(a.$url_path=_.getPath(e.path),a.$title=_.getPageTitle(e.path)),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,a);var r=_.setUtm(e,a);_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),_.setPageRefData(a,e.path,a.$url_query),e&&e.path&&(a.$url=e.path+(a.$url_query?"?"+a.$url_query:"")),t?(a=_.extend(a,t),sa.track("$MPShow",a)):sa.para.autoTrack&&sa.para.autoTrack.appShow&&sa.autoTrackCustom.trackCustom("appShow",a,"$MPShow")},appHide:function(e){var t=(new Date).getTime(),a={};a.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(a.event_duration=(t-mpshow_time)/1e3),_.setPageRefData(a),e?(a=_.extend(a,e),sa.track("$MPHide",a)):sa.para.autoTrack&&sa.para.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",a,"$MPHide"),sendStrategy.onAppHide()},pageLoad:function(e){current_scene&&1010===current_scene&&e&&(e.sampshare&&delete e.sampshare,_.delObjectKey(e)),e&&_.isObject(e)&&(this.sensors_mp_url_query=_.setQuery(e),this.sensors_mp_encode_url_query=_.setQuery(e,!0))},pageShow:function(){page_show_time=Date.now();var e={},t=_.getCurrentPath(),a=_.getPageTitle(t);_.setRefPage(),e.$url_path=t,e.$url_query=this.sensors_mp_url_query?this.sensors_mp_url_query:"",e=_.extend(e,_.getUtmFromPage()),_.setPageRefData(e),_.setPageSfSource(e),a&&(e.$title=a),sa.para.onshow?sa.para.onshow(sa,t,this):_.isObject(sa.para.autotrack_exclude_page)&&_.isArray(sa.para.autotrack_exclude_page.pageShow)&&-1!==sa.para.autotrack_exclude_page.pageShow.indexOf(t)||sa.autoTrackCustom.trackCustom("pageShow",e,"$MPViewScreen")},pageShare:function(e){var t=e.onShareAppMessage;e.onShareAppMessage=function(){share_method="\u8f6c\u53d1\u6d88\u606f\u5361\u7247";var e=t.apply(this,arguments);if(sa.para.autoTrack&&sa.para.autoTrack.pageShare){var a={$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method};_.setPageRefData(a),sa.autoTrackCustom.trackCustom("pageShare",a,"$MPShare")}return sa.para.allow_amend_share_path&&("object"!=typeof e&&((e={}).path=_.getCurrentUrl(this)),"object"!=typeof e||void 0!==e.path&&""!==e.path||(e.path=_.getCurrentUrl(this)),"object"==typeof e&&"string"==typeof e.path&&(-1===e.path.indexOf("?")?e.path=e.path+"?":"&"!==e.path.slice(-1)&&(e.path=e.path+"&")),e.path=e.path+_.getShareInfo()),e}},pageShareTimeline:function(e){var t=e.onShareTimeline;e.onShareTimeline=function(){share_method="\u670b\u53cb\u5708\u5206\u4eab";var e=t.apply(this,arguments);if(sa.para.autoTrack&&sa.para.autoTrack.pageShare){var a={$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method};_.setPageRefData(a),sa.autoTrackCustom.trackCustom("pageShare",a,"$MPShare")}return sa.para.allow_amend_share_path&&("object"!=typeof e&&(e={}),"object"==typeof e&&void 0===e.query&&(e.query=""),"object"==typeof e&&"string"==typeof e.query&&""!==e.query&&"&"!==e.query.slice(-1)&&(e.query=e.query+"&"),e.query=e.query+_.getShareInfo()),e}},pageAddFavorites:function(){var e={};e.$url_path=_.getCurrentPath(),sa.para.autoTrack&&sa.para.autoTrack.mpFavorite&&sa.autoTrackCustom.trackCustom("mpFavorite",e,"$MPAddFavorites")}},sa.quick=function(){var e=arguments[0],t=arguments[1],a=arguments[2],r=_.isObject(a)?a:{};if("getAnonymousID"===e){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===e||"appShow"===e?t?sa.autoTrackCustom[e](t,r):logger.info("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(r=_.isObject(t)?t:{},sa.autoTrackCustom[e](r))},sa.appLaunch=function(e,t){var a={};e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(a.$url_path=_.getPath(e.path),a.$title=_.getPageTitle(e.path)),_.setShareInfo(e,a);var r=_.setUtm(e,a);is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):a.$is_first_time=!1,_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),a.$url=e.path+(a.$url_query?"?"+a.$url_query:""),_.setPageRefData(t),_.isObject(t)&&(a=_.extend(a,t)),sa.track("$MPLaunch",a)},sa.appShow=function(e,t){var a={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,sa.current_scene=current_scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&(e.query.sampshare&&delete e.query.sampshare,_.delObjectKey(e.query)),e&&e.path&&(a.$url_path=_.getPath(e.path),a.$title=_.getPageTitle(e.path)),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,a);var r=_.setUtm(e,a);_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),e&&e.path&&(a.$url=e.path+(a.$url_query?"?"+a.$url_query:"")),_.setPageRefData(a,e.path,a.$url_query),_.isObject(t)&&(a=_.extend(a,t)),sa.track("$MPShow",a)},sa.appHide=function(e){var t=(new Date).getTime(),a={};a.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(a.event_duration=(t-mpshow_time)/1e3),_.setPageRefData(a),_.isObject(e)&&(a=_.extend(a,e)),sa.track("$MPHide",a),sendStrategy.onAppHide()},sa.pageShow=function(e){var t={},a=_.getCurrentPath(),r=_.getPageTitle(a),s=_.getCurrentPage();_.setRefPage(),r&&(t.$title=r),t.$url_path=a,t.$url_query=s.sensors_mp_url_query?s.sensors_mp_url_query:"",t=_.extend(t,_.getUtmFromPage()),_.setPageSfSource(t),_.setPageRefData(t),_.isObject(e)&&(t=_.extend(t,e)),sa.track("$MPViewScreen",t)},sa.App=function(e){(e=e||{})[sa.para.name]=sa,App.apply(this,arguments)},wx.onAppShow(function(e){if(!deploy_para.launched){var t=wx.getLaunchOptionsSync()||{};sa.autoTrackCustom.appLaunch(t),deploy_para.launched=!0}sa.autoTrackCustom.appShow(e)}),wx.onAppHide(function(){sa.autoTrackCustom.appHide()}),sa.Page=function(e){e||(e={});var t=sa.para.autoTrack&&sa.para.autoTrack.mpClick&&_.getMethods(e);if(t)for(var a=0,r=t.length;a