diff --git a/CHANGELOG.md b/CHANGELOG.md index 7349b11..4f9f528 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.13.5 (2024-2-26) +1. 优化 + - 淘宝云函数 getApp() 生命周期问题优化 + ## 0.13.4 (2024-1-0) 1. 新增 - 新增 mp-wechat-mini-extrem 精简版微信小程序 SDK,新增全埋点,压缩后 37.5K diff --git a/dist/mp-taobao/index.cjs.js b/dist/mp-taobao/index.cjs.js index dd877c7..7839569 100644 --- a/dist/mp-taobao/index.cjs.js +++ b/dist/mp-taobao/index.cjs.js @@ -1 +1 @@ -var sa={is_first_launch:!1,launched:!1,_queue:[],mpshow_time:null,sa_referrer:'\u76f4\u63a5\u6253\u5f00',query_share_depth:0,share_distinct_id:'',share_method:'',current_scene:'',inited:!1,para:{server_url:'',send_timeout:1e3,show_log:!1,allow_amend_share_path:!0,max_string_length:500,datasend_timeout:3e3,source_channel:[],batch_send:{send_timeout:6e3,max_length:6},preset_properties:{}},platform:'',lib:{version:'0.13.2',name:'MiniGame',method:'code'},properties:{$lib:'MiniGame',$lib_version:'0.13.2'},currentProps:{}};const _toString=Object.prototype.toString,_hasOwnProperty=Object.prototype.hasOwnProperty,indexOf=Array.prototype.indexOf,slice=Array.prototype.slice,_isArray=Array.prototype.isArray,forEach=Array.prototype.forEach,bind=Function.prototype.bind;function isUndefined(e){return void 0===e}function isString(e){return'[object String]'==_toString.call(e)}function isDate(e){return'[object Date]'==_toString.call(e)}function isBoolean(e){return'[object Boolean]'==_toString.call(e)}function isNumber(e){return'[object Number]'==_toString.call(e)&&/[\d\\.]+/.test(String(e))}function isJSONString(e){try{JSON.parse(e)}catch(e){return!1}return!0}function isObject(e){return null!=e&&'[object Object]'===_toString.call(e)}function isPlainObject(e){return'[object Object]'===_toString.call(e)}function isArray(e){return _isArray||'[object Array]'===_toString.call(e)}function isFuction(e){try{return/^\s*\bfunction\b/.test(e)}catch(e){return!1}}function isArguments(e){return!(!e||!_hasOwnProperty.call(e,'callee'))}function toString(e){return null==e?'':isArray(e)||isPlainObject(e)&&e.toString===_toString?JSON.stringify(e,null,2):String(e)}function each(e,t,n){if(null==e)return!1;if(forEach&&e.forEach===forEach)e.forEach(t,n);else if(e.length===+e.length){for(var s=0,r=e.length;ssa.para.max_string_length?(sa.log('\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}function searchObjString(e){isObject(e)&&each(e,function(t,n){isObject(t)?searchObjString(e[n]):isString(t)&&(e[n]=formatString(t))})}function encodeDates(e){return each(e,function(t,n){isDate(t)?e[n]=formatDate(t):isObject(t)&&(e[n]=encodeDates(t))}),e}function utf8Encode(e){var t,n,s,r,a='';for(t=n=0,s=(e=(e+'').replace(/\r\n/g,'\n').replace(/\r/g,'\n')).length,r=0;r127&&i<2048?String.fromCharCode(i>>6|192,63&i|128):String.fromCharCode(i>>12|224,i>>6&63|128,63&i|128),null!==o&&(n>t&&(a+=e.substring(t,n)),a+=o,t=n=r+1)}return n>t&&(a+=e.substring(t,e.length)),a}function base64Encode(e){var t,n,s,r,a,i='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',o=0,c=0,u='',l=[];if(!e)return e;e=utf8Encode(e);do{t=(a=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,n=a>>12&63,s=a>>6&63,r=63&a,l[c++]=i.charAt(t)+i.charAt(n)+i.charAt(s)+i.charAt(r)}while(o255)||(sa.log('id \u957f\u5ea6\u8d85\u8fc7 255 \u4e2a\u5b57\u7b26\uff01'),!1)}};function getOpenidNameByAppid(e){if(''==e||!isString(e))return sa.log('error: \u53c2\u6570\u5fc5\u987b\u662f\u6709\u6548\u503c'),!1;var t=getAppId(),n="$identity_"+e+"_openid";return t&&(n="$identity_"+e+'_'+t+"_openid"),n}function validId(e){return!isString(e)&&!isNumber(e)||''===e?(sa.log('\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef'),!1):isNumber(e)&&(e=String(e),!/^\d+$/.test(e))?(sa.log('\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef'),!1):!!check.checkIdLength(e)&&e}function isNewLoginId(e,t){return e!==sa.store._state.history_login_id.name||sa.store._state.history_login_id.value!==t}function isSameAndAnonymousID(e){var t=sa.store.getFirstId(),n=sa.store.getDistinctId();return t?e===t:e===n}function setUpperCase(e){return isString(e)?e.toLocaleUpperCase():e}function getIsFirstDay(){return!!('object'==typeof sa.store._state&&isNumber(sa.store._state.first_visit_day_time)&&sa.store._state.first_visit_day_time>(new Date).getTime())}function joinUrl(e,t){return!!e&&('\u672a\u53d6\u5230'===e?'\u672a\u53d6\u5230':t?e+'?'+t:e)}function getPath(e){return e=isString(e)?e.replace(/^\//,''):'\u53d6\u503c\u5f02\u5e38'}function getAppProps(e){var t={};return e&&e.path&&(t.$url_path=getPath(e.path),t.$url_query=setQuery(e.query),t.$url=joinUrl(t.$url_path,t.$url_query)),t}function getPageProps(){var e=getCurrentPage(),t=getCurrentPath(),n=e.sensors_mp_url_query||'';return{$url_path:t,$url:joinUrl(t,n),$url_query:n}}function rot13defs(e){return rot13obfs(e=String(e),113)}function rot13obfs(e,t){t='number'==typeof t?t:13;for(var n=(e=String(e)).split(''),s=0,r=n.length;s{sa.system_api.getSystemInfo({success(e){var t=sa.properties;if(isObject(e)){t.$manufacturer=e.brand,t.$model=e.model,t.$brand=setUpperCase(e.brand)||'',t.$screen_width=Number(e.screenWidth),t.$screen_height=Number(e.screenHeight),t.$os=formatSystem(e.platform),t.$os_version=e.system.indexOf(' ')>-1?e.system.split(' ')[1]:e.system,t.$mp_client_app_version=e.version||'';var n=e.SDKVersion||'';n&&(t.$mp_client_basic_library_version=n)}},fail(e){sa.log('\u83b7\u53d6\u7cfb\u7edf\u4fe1\u606f\u5931\u8d25: ',e)},complete(){e()}})})}var system={inited:!1,init:function(){var e=(new Date).getTimezoneOffset();isNumber(e)&&(sa.properties.$timezone_offset=e);var t=getAppId()||sa.para.app_id||sa.para.appid;t&&(sa.properties.$app_id=t),getNetwork(),getSystemInfo$1()}},identity_id='$identity_taobao_uuid';function stripProperties(e){return isObject(e)?(each(e,function(t,n){if(isArray(t)){var s=[];each(t,function(e){if(isString(e))s.push(e);else if(isUndefined(e))s.push('null');else try{s.push(JSON.stringify(e))}catch(e){sa.log('\u60a8\u7684\u6570\u636e - '+n+':'+t+' - \u7684\u6570\u7ec4\u91cc\u7684\u503c\u6709\u9519\u8bef,\u5df2\u7ecf\u5c06\u5176\u5220\u9664')}}),e[n]=s}if(isObject(t))try{e[n]=JSON.stringify(t)}catch(s){delete e[n],sa.log('\u60a8\u7684\u6570\u636e - '+n+':'+t+' - \u7684\u6570\u636e\u503c\u6709\u9519\u8bef,\u5df2\u7ecf\u5c06\u5176\u5220\u9664')}else isString(t)||isNumber(t)||isDate(t)||isBoolean(t)||isArray(t)||(sa.log('\u60a8\u7684\u6570\u636e - ',t,'-\u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664'),delete e[n])}),e):e}function parseSuperProperties(e){isObject(e)&&each(e,function(t,n){if(isFunction(t))try{e[n]=t(),isFunction(e[n])&&(sa.log('\u60a8\u7684\u5c5e\u6027 - '+n+' \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664'),delete e[n])}catch(t){delete e[n],sa.log('\u60a8\u7684\u5c5e\u6027 - '+n+' \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664')}})}function batchRequest(e){if(isArray(e.data)&&e.data.length>0){var t=Date.now(),n=sa.para.datasend_timeout;e.data.forEach(function(e){e._flush_time=t}),e.data=JSON.stringify(e.data);let s={url:sa.para.server_url,method:'POST',dataType:'text',data:'data_list='+encodeURIComponent(base64Encode(e.data)),timeout:n,success:function(){e.success(e.len)},fail:function(){e.fail()}};sa.system_api.request(s)}else e.success(e.len)}function onceSend(e){e._flush_time=Date.now();var t='',n=JSON.stringify(e);t=-1!==sa.para.server_url.indexOf('?')?sa.para.server_url+'&data='+encodeURIComponent(base64Encode(n)):sa.para.server_url+'?data='+encodeURIComponent(base64Encode(n));var s=sa.para.datasend_timeout;sa.system_api.request({url:t,dataType:'text',method:'GET',timeout:s})}IDENTITIES.identity_unionid='',IDENTITIES.identity_id=identity_id,IDENTITIES.openid_name='taobao',IDENTITIES.bind_preset_id=[identity_id],IDENTITIES.unbind_without_check=[identity_id],IDENTITIES.login_preset_id=[identity_id];var kit={batchRequest:batchRequest,onceSend:onceSend};function onAppHide(){isFunction(sa.platform_obj.onAppHide)&&sa.platform_obj.onAppHide(function(){sa.para.batch_send&&batchSend()})}function batchSend(){if(sa.batch_state.sended){var e,t,n=sa.batch_state.mem;(t=(e=n.length>=100?n.slice(0,100):n).length)>0&&(sa.batch_state.sended=!1,kit.batchRequest({data:e,len:t,success:batchRemove,fail:sendFail}))}}function sendFail(){sa.batch_state.sended=!0,sa.batch_state.failTime++}function batchRemove(e){sa.batch_state.clear(e),sa.batch_state.sended=!0,sa.batch_state.changed=!0,batchWrite(),sa.batch_state.failTime=0}function batchWrite(){sa.batch_state.changed&&(sa.batch_state.is_first_batch_write&&(sa.batch_state.is_first_batch_write=!1,setTimeout(function(){batchSend()},1e3)),sa.batch_state.syncStorage&&(sa.system_api.setStorageSync('sensors_prepare_data',sa.batch_state.mem),sa.batch_state.changed=!1))}function batchInterval(){!function e(){setTimeout(function(){batchWrite(),e()},1e3)}(),function e(){setTimeout(function(){batchSend(),e()},sa.para.batch_send.send_timeout*Math.pow(2,sa.batch_state.failTime))}()}function reportEvent(e){var t='';e._flush_time=Date.now(),t=e.event?"sensors_"+e.event:"sensors_"+e.type,e.dataSource='sensors',sa.log('report_event, name: ',t,'-- key: ',e),__mp_private_api__.reportEvent(t,e)}sa.batch_state={mem:[],changed:!1,sended:!0,is_first_batch_write:!0,sync_storage:!1,failTime:0,getLength:function(){return this.mem.length},add:function(e){this.mem.push(e)},clear:function(e){this.mem.splice(0,e)}},sa.batchWrite=batchWrite,sa.prepareData=function(e){var t={distinct_id:sa.store.getDistinctId(),lib:{$lib:sa.lib.name,$lib_method:sa.lib.method,$lib_version:String(sa.lib.version)},properties:{}};if(isObject(sa.store._state.identities)&&(t.identities=sa.store._state.identities),'track_id_unbind'===e.type&&'$UnbindID'===e.event&&(t.identities=deepCopy(e.unbind_value),delete e.unbind_value),t=extend(t,sa.store.getUnionId(),e),isObject(e.properties)&&!isEmptyObject(e.properties)&&(t.properties=extend(t.properties,e.properties)),e.type&&'profile'===e.type.slice(0,7)||(t._track_id=Number(String(getRandom()).slice(2,5)+String(getRandom()).slice(2,4)+String(Date.now()).slice(-4)),t.properties=extend({},sa.properties,sa.store.getProps(),sa.currentProps,t.properties),'track'===e.type&&(t.properties.$is_first_day=getIsFirstDay())),t.properties.$time&&isDate(t.properties.$time)?(t.time=1*t.properties.$time,delete t.properties.$time):t.time=1*new Date,sa.ee.data.emit('beforeBuildCheck',t),parseSuperProperties(t.properties),searchObjDate(t),stripProperties(t.properties),searchObjString(t),sa.ee.data.emit('finalAdjustData',t),!sa.para.server_url)return!1;sa.log(t),sa.send(t)},sa.send=function(e){if(e._nocache=(String(getRandom())+String(getRandom())+String(getRandom())).slice(2,15),'sensorsdata2015_binance'===sa.storageName&&'native'===sa.para.data_report_type)return reportEvent(e),!1;sa.para.batch_send?(sa.batch_state.getLength()>=500&&(sa.log('\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38'),sa.batch_state.mem.shift()),sa.batch_state.add(e),sa.batch_state.changed=!0,sa.batch_state.getLength()>=sa.para.batch_send.max_length&&batchSend()):kit.onceSend(e)},sa.log=function(){if(sa.para.show_log&&'object'==typeof console&&console.log)try{var e=Array.prototype.slice.call(arguments);return console.log.apply(console,e)}catch(e){console.log(arguments[0])}},sa.track=function(e,t,n){sa.prepareData({type:'track',event:e,properties:t},n)},sa.setProfile=function(e){sa.prepareData({type:'profile_set',properties:e})},sa.setOnceProfile=function(e,t){sa.prepareData({type:'profile_set_once',properties:e},t)},sa.login=function(e){var t=sa.store.getFirstId(),n=sa.store.getDistinctId();e!==n&&(t?sa.trackSignup(e,'$SignUp'):(sa.store.set('first_id',n),sa.trackSignup(e,'$SignUp')))},sa.logout=function(e){var t=sa.store.getFirstId();t?(sa.store.set('first_id',''),!0===e?sa.store.set('distinct_id',getUUID()):sa.store.set('distinct_id',t)):sa.log('\u6ca1\u6709first_id\uff0clogout\u5931\u8d25')},sa.identify=function(e){if('number'==typeof e)e=String(e);else if('string'!=typeof e)return!1;sa.store.getFirstId()?sa.store.set('first_id',e):sa.store.set('distinct_id',e)},sa.trackSignup=function(e,t,n){var s,r,a,i,o;isObject(e)?(s=e.id,r=e.event_name,a=e.id_name):(s=e,r=t),sa.store.set('distinct_id',s),i=a&&a!==IDENTITY_KEY.LOGIN?a+'+'+s:s,o=sa.store.getFirstId()||sa.store.getDistinctId(),sa.prepareData({original_id:o,distinct_id:i,type:'track_signup',event:r,properties:n})},sa.registerApp=function(e){isObject(e)&&!isEmptyObject(e)&&(sa.currentProps=extend(sa.currentProps,e))},sa.clearAppRegister=function(e){isArray(e)&&each(sa.currentProps,function(t,n){include(e,n)&&delete sa.currentProps[n]})},sa.register=function(e){isObject(e)&&!isEmptyObject(e)&&sa.store.setProps(e)},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.use=function(e){const t=toArray(arguments,1);return t.unshift(this),isObject(e)&&isFunction(e.init)&&e.init.apply(e,t),e},sa.usePlugin=sa.use,sa.getServerUrl=function(){return sa.para.server_url},sa.registerPropertyPlugin=function(e){isFunction(e.properties)?!e.isMatchedWithFilter||isFunction(e.isMatchedWithFilter)?sa.ee.data.on('finalAdjustData',function(t){try{isFunction(e.isMatchedWithFilter)?e.isMatchedWithFilter(t)&&e.properties(t):e.properties(t)}catch(e){sa.log('execute registerPropertyPlugin callback error:'+e)}}):sa.log('registerPropertyPlugin arguments error, isMatchedWithFilter must be function'):sa.log('registerPropertyPlugin arguments error, properties must be function')};var hasOwnProperty$1=Object.prototype.hasOwnProperty,store={inited:!0,storageInfo:null,store_queue:[],getStorage:function(){return this.storageInfo?this.storageInfo:(this.storageInfo=sa.system_api.getStorageSync(sa.storageName)||'',this.storageInfo)},_state:{},toState:function(e){var t=null,n=this;function s(){t.distinct_id?n._state=t:n.set('distinct_id',getUUID())}isJSONString(e)?(t=JSON.parse(e),s()):isObject(e)?(t=e,s()):this.set('distinct_id',getUUID());var r=this._state._first_id||this._state.first_id,a=this._state._distinct_id||this._state.distinct_id,i=(this._state.history_login_id?this._state.history_login_id:{}).name;if(this._state.identities&&isString(this._state.identities)){var o=JSON.parse(rot13defs(this._state.identities));this._state.identities=o}function c(e){for(var t in store._state.identities)hasOwnProperty$1.call(store._state.identities,t)&&t!==IDENTITIES.identity_id&&t!==e&&delete store._state.identities[t]}this._state.identities&&isObject(this._state.identities)&&!isEmptyObject(this._state.identities)||(this._state.identities={},this._state.identities[IDENTITIES.identity_id]=getUUID()),r?i&&hasOwnProperty$1.call(this._state.identities,i)?this._state.identities[i]!==a&&(this._state.identities[i]=a,c(i),this._state.history_login_id.value=a):(this._state.identities[IDENTITY_KEY.LOGIN]=a,c(IDENTITY_KEY.LOGIN),this._state.history_login_id={name:IDENTITY_KEY.LOGIN,value:a}):this._state.history_login_id={name:'',value:''},this.save()},getFirstId:function(){return this._state._first_id||this._state.first_id},getDistinctId:function(){var e=this.getLoginDistinctId();return e||(this._state._distinct_id||this._state.distinct_id)},getUnionId:function(){var e={},t=this._state._first_id||this._state.first_id,n=this.getDistinctId();return t&&n?(e.login_id=n,e.anonymous_id=t):e.anonymous_id=n,e},getHistoryLoginId:function(){return isObject(this._state.history_login_id)?this._state.history_login_id:null},getLoginDistinctId:function(){var e=this.getHistoryLoginId();return isObject(e)&&e.value?e.name!==IDENTITY_KEY.LOGIN?e.name+'+'+e.value:e.value:null},getProps:function(){return this._state.props||{}},setProps:function(e,t){var n=this._state.props||{};t?this.set('props',e):(extend(n,e),this.set('props',n))},set:function(e,t){var n={};for(var s in'string'==typeof e?n[e]=t:'object'==typeof e&&(n=e),this._state=this._state||{},n)this._state[s]=n[s],'first_id'===s?delete this._state._first_id:'distinct_id'===s&&(delete this._state._distinct_id,sa.events.emit('changeDistinctId'));this.save()},identitiesSet:function(e){var t={};switch(e.type){case'login':t[IDENTITIES.identity_id]=this._state.identities[IDENTITIES.identity_id],t[e.id_name]=e.id;break;case'logout':t[IDENTITIES.identity_id]=this._state.identities[IDENTITIES.identity_id]}this.set('identities',t)},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.system_api.setStorageSync(sa.storageName,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.system_api.setStorageSync(sa.storageName,e)},init:function(){var e=this.getStorage(),t=getUUID();if(e)isString(e)&&-1!==e.indexOf("data:enc;")&&(e=e.substring("data:enc;".length),e=JSON.parse(rot13defs(e))),this.toState(e);else{meta.is_first_launch=!0;var n=new Date,s=n.getTime();n.setHours(23),n.setMinutes(59),n.setSeconds(60),this.set({distinct_id:t,first_visit_time:s,first_visit_day_time:n.getTime(),identities:{[IDENTITIES.identity_id]:t},history_login_id:{name:'',value:''}}),sa.setOnceProfile({$first_visit_time:n})}this.checkStoreInit&&this.checkStoreInit()}};function identify(e,t){if(e=_.validId(e)){var n=store.getFirstId();!0===t?n?store.set('first_id',e):store.set('distinct_id',e):n?store.change('first_id',e):store.change('distinct_id',e)}}function trackSignup(e,t,n){var s,r,a,i;_.isObject(e)?(s=e.id,r=e.event_name,a=e.id_name):(s=e,r=t),store.set('distinct_id',s),i=a&&a!==IDENTITY_KEY.LOGIN?a+'+'+s:s;var o=store.getFirstId()||store.getDistinctId();sa.prepareData({original_id:o,distinct_id:i,type:'track_signup',event:r,properties:n})}function bindWithoutCheck(e,t){store._state.identities[e]=t,store.save(),sa.prepareData({type:'track_id_bind',event:'$BindID'})}function bind$1(e,t){var n='';if(_.isNumber(t)){if(_.isInteger(t)&&!1===_.isSafeInteger(t))return sa.log('Value must be String'),!1;t=String(t)}if(!_.isString(e))return sa.log('Key must be String'),!1;var s=store.getHistoryLoginId(),r=s?s.name:'',a=[IDENTITY_KEY.LOGIN,r];return _.isArray(IDENTITIES.bind_preset_id)&&(a=[IDENTITY_KEY.LOGIN,r].concat(IDENTITIES.bind_preset_id)),!_.check.checkKeyword(e)||_.isPresetIdKeys(e,a)?(n='Key ['+e+'] is invalid',sa.log(n),!1):t&&''!==t?_.isString(t)?!!_.check.checkIdLength(t)&&void bindWithoutCheck(e,t):(sa.log('Value must be String'),!1):(sa.log('Value is empty or null'),!1)}function unbindWithoutCheck(e,t){hasOwnProperty.call(store._state.identities,e)&&t===store._state.identities[e]&&(IDENTITIES.unbind_without_check&&IDENTITIES.unbind_without_check.indexOf(e)<0&&delete store._state.identities[e],store.save());var n=store.getDistinctId(),s=store.getFirstId();n===e+'+'+t&&(store.set('first_id',''),store.set('distinct_id',s),store.set('history_login_id',{name:'',value:''}));var r={};r[e]=t,sa.prepareData({type:'track_id_unbind',event:'$UnbindID',unbind_value:r})}function unbind(e,t){var n='';if(_.isNumber(t)){if(_.isInteger(t)&&!1===_.isSafeInteger(t))return sa.log('Value must be String'),!1;t=String(t)}return _.isString(e)?!_.check.checkKeyword(e)||_.isPresetIdKeys(e,[IDENTITY_KEY.LOGIN])?(n='Key ['+e+'] is invalid',sa.log(n),!1):t&&''!==t?_.isString(t)?!!_.check.checkIdLength(t)&&void unbindWithoutCheck(e,t):(sa.log('Value must be String'),!1):(sa.log('Value is empty or null'),!1):(sa.log('Key must be String'),!1)}function loginWithKey(e,t){if(!_.isString(e))return sa.log('Key must be String'),!1;var n='';if(!_.check.checkKeyword(e)&&e.length>100)n='Key ['+e+'] is invalid',sa.log(n);else if(!_.check.checkKeyword(e))return n='Key ['+e+'] is invalid',sa.log(n),!1;if(_.isPresetIdKeys(e,IDENTITIES.login_preset_id))return n='Key ['+e+'] is invalid',sa.log(n),!1;if(!(t=_.validId(t)))return!1;if(_.isSameAndAnonymousID(t))return!1;var s=store.getFirstId(),r=store.getDistinctId();_.isNewLoginId(e,t)&&(store._state.identities[e]=t,store.set('history_login_id',{name:e,value:t}),s||store.set('first_id',r),sa.trackSignup({id:t,event_name:'$SignUp',id_name:e}),store.identitiesSet({type:'login',id:t,id_name:e}))}function login(e){if(!(e=_.validId(e)))return!1;if(_.isSameAndAnonymousID(e))return!1;var t=store.getFirstId(),n=store.getDistinctId(),s=IDENTITY_KEY.LOGIN;_.isNewLoginId(s,e)&&(store._state.identities&&(store._state.identities[s]=e),store.set('history_login_id',{name:s,value:e}),t||store.set('first_id',n),sa.trackSignup({id:e,event_name:'$SignUp'}),store.identitiesSet({type:'login',id:e,id_name:s}))}function logout(){var e=store.getFirstId();store.identitiesSet({type:'logout'}),store.set('history_login_id',{name:'',value:''}),e?(store.set('first_id',''),store.set('distinct_id',e)):sa.log('\u6ca1\u6709first_id\uff0clogout\u5931\u8d25')}function bindOpenid(e){if(!(e=_.validId(e)))return!1;bind$1(_.getOpenidNameByAppid(IDENTITIES.openid_name),e)}function unbindOpenid(e){if(!_.validId(e))return!1;unbind(_.getOpenidNameByAppid(IDENTITIES.openid_name),e)}sa.store=store;var functions=Object.freeze({__proto__:null,identify:identify,trackSignup:trackSignup,bindWithoutCheck:bindWithoutCheck,bind:bind$1,unbindWithoutCheck:unbindWithoutCheck,unbind:unbind,loginWithKey:loginWithKey,login:login,logout:logout,bindOpenid:bindOpenid,unbindOpenid:unbindOpenid});for(var f in functions)sa[f]=functions[f];function buildPara(e){return!(!e||!isObject(e))&&(sa.setPara(e),!!e.server_url||(sa.log('error: server_url is empty'),!1))}function isValidListener(e){return'function'==typeof e||!(!e||'object'!=typeof e)&&isValidListener(e.listener)}sa.identify=function(){},sa.unsetOpenid=function(e){if(!_.validId(e))return!1;var t=_.getOpenidNameByAppid('taobao');sa.unbind(t,e)},sa.setOpenid=function(e){if(!(e=_.validId(e)))return!1;var t=_.getOpenidNameByAppid('taobao');sa.bind(t,e)},sa.setPara=function(e){sa.para=extend2Lev(sa.para,e);var t=[];if(isArray(sa.para.source_channel))for(var n=sa.para.source_channel.length,s=0;s0&&this.cacheEvents.forEach(function(n){n.type===e&&t.call(null,n.data)})}emit(e,t){super.emit.apply(this,arguments),this.cacheEvents.push({type:e,data:t}),this.cacheEvents.length>this.maxLen&&this.cacheEvents.shift()}}var ee={};ee.sdk=new EventEmitterEx,ee.data=new EventEmitterEx;var eventEmitter=function(){this.sub=[]};eventEmitter.prototype={add:function(e){this.sub.push(e)},emit:function(e,t){this.sub.forEach(function(n){n.on(e,t)})}};var 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){sa.log(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){sa.log(e)}})}},sa.ee=ee,sa.eventSub=eventSub,sa.events=new eventEmitter,sa.meta=meta,sa.kit=kit,sa.modules={},sa.init=function(e){if(!0===meta.hasExeInit)return!1;meta.hasExeInit=!0,ee.sdk.emit('beforeInit'),buildPara(e),ee.sdk.emit('initPara'),ee.sdk.emit('afterInitPara'),sa.store.init(),sa.system.init(),ee.sdk.emit('initAPI'),ee.sdk.emit('afterInitAPI'),ee.sdk.emit('afterInit'),ee.sdk.emit('ready'),sa.para.batch_send&&(sa.system_api.getStorage('sensors_prepare_data',function(e){var t=[];e&&e.data&&isArray(e.data)&&(t=e.data,sa.batch_state.mem=t.concat(sa.batch_state.mem)),sa.batch_state.syncStorage=!0,onAppHide()}),batchInterval())};const forEach$1=Array.prototype.forEach,slice$1=Array.prototype.slice,_hasOwnProperty$1=Object.prototype.hasOwnProperty,_toString$1=Object.prototype.toString;function extend$1(e){return each$1(slice$1.call(arguments,1),function(t){for(var n in t)void 0!==t[n]&&(e[n]=t[n])}),e}function isObject$1(e){return null!==e&&'object'==typeof e}function isFunction$1(e){if(!e)return!1;var t=Object.prototype.toString.call(e);return'[object Function]'==t||'[object AsyncFunction]'==t||'[object GeneratorFunction]'==t}function isString$1(e){return'[object String]'==_toString$1.call(e)}function each$1(e,t,n){if(null==e)return!1;if(forEach$1&&e.forEach===forEach$1)e.forEach(t,n);else if(e.length===+e.length){for(var s=0,r=e.length;s0&&(t-s)/36e5<24&&(n.event_duration=(t-s)/1e3),global.sensors.para&&global.sensors.para.autoTrack&&global.sensors.para.autoTrack.appHide&&global.sensors.track('$MPHide',n)}lifeCycleHook.forEach(function(e){miniLifeCycleAPI[e]=function(){throw new Error(`\u9700\u8981\u5148\u5b9a\u4e49 '${e}' \u624d\u80fd\u4f7f\u7528`)}});var presetEvents={appLaunch:!0,appShow:!0,appHide:!0},AutoTrackApp={name:'AutoTrackApp'};function getMixedQuery$1(e){var t={};if(e&&global.sensors._.isObject(e.query)&&(t=global.sensors._.extend({},e.query),e.query.qrCode&&global.sensors._.extend(t,global.sensors._.getObjFromQuery(global.sensors._.decodeURIComponent(e.query.qrCode)))),e&&global.sensors._.isObject(e.referrerInfo)&&e.referrerInfo.extraData){var n={};global.sensors._.isObject(e.referrerInfo.extraData)&&!global.sensors._.isEmptyObject(e.referrerInfo.extraData)?n=e.referrerInfo.extraData:global.sensors._.isJSONString(e.referrerInfo.extraData)&&(n=JSON.parse(e.referrerInfo.extraData)),global.sensors._.extend(t,n)}return t}function setUtm$1(e,t){var n={},s=getMixedQuery$1(e),r=global.sensors._.getCustomUtmFromQuery(s,'$','_','$'),a=global.sensors._.getCustomUtmFromQuery(s,'$latest_','_latest_','$latest_');return n.pre1=r,n.pre2=a,global.sensors._.extend(t,r),n}function appOnLaunch$1(e,t){if(isObject$1(e)){var n={};if(e&&e.path&&extend$1(n,global.sensors._.getAppProps(e)),e&&e.scene){var s=getScene(e.scene,global.sensors);s&&(n.$scene=s,global.sensors.meta.current_scene=s,global.sensors.registerApp({$latest_scene:s}))}else n.$scene='\u672a\u53d6\u5230\u503c';var r=global.sensors.para&&global.sensors.para.autoTrack&&global.sensors.para.autoTrack.appLaunch,a=setUtm$1(e,n);global.sensors.meta.is_first_launch?(n.$is_first_time=!0,global.sensors._.isEmptyObject(a.pre1)||r&&global.sensors.setOnceProfile(a.pre1)):n.$is_first_time=!1,global.sensors._.isEmptyObject(a.pre2)||global.sensors._.setLatestChannel(a.pre2),n.$url_query=global.sensors._.setQuery(e.query),isObject$1(t)&&(n=extend$1(n,t)),r&&global.sensors.track('$MPLaunch',n)}else global.sensors.log('appOnLaunch:\u8bf7\u4f20\u5165\u6b63\u786e\u7684\u53c2\u6570')}function appOnShow$1(e,t){var n={};global.sensors.meta.mp_show_time=(new Date).getTime(),e&&e.path&&extend$1(n,global.sensors._.getAppProps(e));var s=setUtm$1(e,n);if(global.sensors._.isEmptyObject(s.pre2)||global.sensors._.setLatestChannel(s.pre2),e&&e.scene){var r=getScene(e.scene,global.sensors);r&&(n.$scene=r,global.sensors.registerApp({$latest_scene:r}))}isObject$1(t)&&(n=extend$1(n,t)),global.sensors.para&&global.sensors.para.autoTrack&&global.sensors.para.autoTrack.appShow&&global.sensors.track('$MPShow',n)}AutoTrackApp.init=function(e,t){if(!e)return console.log('\u8bf7\u6b63\u786e\u521d\u59cb\u5316 sensorsdata\uff0c\u624d\u80fd\u4f7f\u7528\u63d2\u4ef6'),!1;global.sensors=e,global.sensors.para.autoTrack=extend$1(presetEvents,t),AutoTrackApp.lifeCycleAPI(),AutoTrackApp.proxyFrameworkInterface()},AutoTrackApp.lifeCycleAPI=function(){var e={};e.appOnLaunch=appOnLaunch,e.appOnShow=appOnShow,e.appOnHide=appOnHide,registerLifeCycleHook(e)},AutoTrackApp.proxyFrameworkInterface=function(){proxyApp(hookAppFunc,global.sensors)},AutoTrackApp.lifeCycleAPI=function(){var e={};e.appOnLaunch=appOnLaunch$1,e.appOnShow=appOnShow$1,e.appOnHide=appOnHide,registerLifeCycleHook(e)};var global$1={};function getCurrentPath$1(e){var t='\u672a\u53d6\u5230',n=getCurrentPage$1(e);return n&&n.route&&(t=n.route),t}function getCurrentPage$1(e){var t,n={};if(e)try{n=(t=isFunction$1(e.platform_obj.getCurrentPages)?e.platform_obj.getCurrentPages():getCurrentPages())[t.length-1]}catch(t){e.log(t)}else console.log('getCurrentPage:\u8bf7\u4f20\u5165 sa \u5bf9\u8c61');return n}function isClick(e){return!!{tap:1,longtap:1,longpress:1}[e]}function createClickData(e){var t={},n={},s=e.currentTarget||{},r=s.dataset||{};return t.$element_id=s.id,t.$element_type=r.type,t.$element_content=r.content,t.$element_name=r.name,isObject$1(e.event_prop)&&(n=e.event_prop),t.$url_path=getCurrentPath$1(global$1.sensors),t.$url=global$1.sensors._.getPageProps().$url,t=extend$1(t,n)}var ClickTrack={track:function(e){var t=createClickData(e),n=e.currentTarget||{},s=e.target||{},r=e.type,a=global$1.sensors.para;if(isObject$1(a.framework)&&isObject$1(a.framework.taro)&&!a.framework.taro.createApp&&s.id&&n.id&&s.id!==n.id)return!1;if(isObject$1(t)&&r&&isClick(r)){if(a.preset_events&&a.preset_events.collect_element&&!1===a.preset_events.collect_element(arguments[0]))return!1;global$1.sensors.track('$MPClick',t)}}},MP_HOOKS={data:1,onLoad:1,onShow:1,onReady:1,onPullDownRefresh:1,onReachBottom:1,onShareAppMessage:1,onPageScroll:1,onResize:1,onTabItemTap:1,onHide:1,onUnload:1};function clickProxy(e,t){var n=e[t];e[t]=function(){var e=n.apply(this,arguments),t=arguments[0];return isObject$1(t)&&ClickTrack.track(t),e}}function monitorClick(e){var t=[],n=global$1.sensors.para.autoTrack;if(n&&n.mpClick){t=getMethods(e),tabProxy(e);for(var s=t.length,r=0;r=0&&''!==t){var n={},s=(Date.now()-global$1.sensors.meta.page_show_time)/1e3;(isNaN(s)||s<0)&&(s=0),extend$1(n,global$1.sensors._.getPageProps()),n.event_duration=s,global$1.sensors.track('$MPPageLeave',n),global$1.sensors.meta.page_show_time=-1}}};function pageOnLoad(e){var t=this;if(global$1.sensors._.isObject(e)){try{t=getCurrentPage$1(global$1.sensors)}catch(e){global$1.sensors.log('pageOnLoad:'+e)}t.sensors_mp_url_query=global$1.sensors._.setQuery(e),t.sensors_mp_encode_url_query=global$1.sensors._.setQuery(e,!0)}}function pageOnShow(){global$1.sensors.meta.page_show_time=Date.now();var e={},t='';try{var n=getCurrentPage$1(global$1.sensors);t=n?n.route:''}catch(e){global$1.sensors.log('pageOnShow:'+e)}extend$1(e,global$1.sensors._.getPageProps()),e.$referrer=global$1.sensors.meta.sa_referrer,global$1.sensors.para&&global$1.sensors.para.autoTrack&&global$1.sensors.para.autoTrack.pageShow&&global$1.sensors.track('$MPViewScreen',e),global$1.sensors.meta.sa_referrer=t}function pageOnUnload(){pageLeave()}function pageOnHide(){pageLeave()}var presetEvents$1={pageShow:!0,mpClick:!0,pageLeave:!1},AutoTrackPage={name:'AutoTrackPage',init:function(e,t){if(!e)return console.log('\u8bf7\u6b63\u786e\u521d\u59cb\u5316 sensorsdata\uff0c\u624d\u80fd\u4f7f\u7528\u63d2\u4ef6'),!1;global$1.sensors=e,global$1.sensors.para.autoTrack=extend$1(presetEvents$1,t),AutoTrackPage.lifeCycleAPI(),AutoTrackPage.proxyFrameworkInterface()},lifeCycleAPI:function(){var e={};e.pageOnShow=pageOnShow,e.pageOnLoad=pageOnLoad,e.pageOnUnload=pageOnUnload,e.pageOnHide=pageOnHide,registerLifeCycleHook(e)},proxyFrameworkInterface:function(){proxyPage(hookPageFunc,monitorClick)}},presetEvents$2={appLaunch:!0,appShow:!0,appHide:!0,pageShow:!0,mpClick:!0,pageLeave:!1},AutoTrack={name:'AutoTrack',init:function(e,t){if(!e)return console.log('\u8bf7\u6b63\u786e\u521d\u59cb\u5316 sensorsdata\uff0c\u624d\u80fd\u4f7f\u7528\u63d2\u4ef6'),!1;e.ee.sdk.on('afterInitPara',function(){var n=extend$1(presetEvents$2,e.para.autoTrack,t);e.use(AutoTrackApp,n),e.use(AutoTrackPage,n)})}};sa.platform_obj=my,sa._=_,sa.system=system,sa.system_api=Object.assign(compose,compose$1),sa.lib.name='TaobaoMini',sa.properties.$lib='TaobaoMini',sa.storageName='sensorsdata2015_tb',sa.meta.scene_prefix='tb-',sa.properties.$data_ingestion_source=['TaobaoMini'],sa.properties.$mp_client_basic_library_version=my.SDKVersion||'',sa.use(AutoTrack);export default sa; \ No newline at end of file +var sa={is_first_launch:!1,launched:!1,_queue:[],mpshow_time:null,sa_referrer:'\u76f4\u63a5\u6253\u5f00',query_share_depth:0,share_distinct_id:'',share_method:'',current_scene:'',inited:!1,para:{server_url:'',send_timeout:1e3,show_log:!1,allow_amend_share_path:!0,max_string_length:500,datasend_timeout:3e3,source_channel:[],batch_send:{send_timeout:6e3,max_length:6},preset_properties:{}},platform:'',lib:{version:'0.13.5',name:'MiniGame',method:'code'},properties:{$lib:'MiniGame',$lib_version:'0.13.5'},currentProps:{}};const _toString=Object.prototype.toString,_hasOwnProperty=Object.prototype.hasOwnProperty,indexOf=Array.prototype.indexOf,slice=Array.prototype.slice,_isArray=Array.prototype.isArray,forEach=Array.prototype.forEach,bind=Function.prototype.bind;function isUndefined(e){return void 0===e}function isString(e){return'[object String]'==_toString.call(e)}function isDate(e){return'[object Date]'==_toString.call(e)}function isBoolean(e){return'[object Boolean]'==_toString.call(e)}function isNumber(e){return'[object Number]'==_toString.call(e)&&/[\d\\.]+/.test(String(e))}function isJSONString(e){try{JSON.parse(e)}catch(e){return!1}return!0}function isObject(e){return null!=e&&'[object Object]'===_toString.call(e)}function isPlainObject(e){return'[object Object]'===_toString.call(e)}function isArray(e){return _isArray||'[object Array]'===_toString.call(e)}function isFuction(e){try{return/^\s*\bfunction\b/.test(e)}catch(e){return!1}}function isArguments(e){return!(!e||!_hasOwnProperty.call(e,'callee'))}function toString(e){return null==e?'':isArray(e)||isPlainObject(e)&&e.toString===_toString?JSON.stringify(e,null,2):String(e)}function each(e,t,n){if(null==e)return!1;if(forEach&&e.forEach===forEach)e.forEach(t,n);else if(e.length===+e.length){for(var s=0,r=e.length;ssa.para.max_string_length?(sa.log('\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}function searchObjString(e){isObject(e)&&each(e,function(t,n){isObject(t)?searchObjString(e[n]):isString(t)&&(e[n]=formatString(t))})}function encodeDates(e){return each(e,function(t,n){isDate(t)?e[n]=formatDate(t):isObject(t)&&(e[n]=encodeDates(t))}),e}function utf8Encode(e){var t,n,s,r,a='';for(t=n=0,s=(e=(e+'').replace(/\r\n/g,'\n').replace(/\r/g,'\n')).length,r=0;r127&&i<2048?String.fromCharCode(i>>6|192,63&i|128):String.fromCharCode(i>>12|224,i>>6&63|128,63&i|128),null!==o&&(n>t&&(a+=e.substring(t,n)),a+=o,t=n=r+1)}return n>t&&(a+=e.substring(t,e.length)),a}function base64Encode(e){var t,n,s,r,a,i='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',o=0,c=0,u='',l=[];if(!e)return e;e=utf8Encode(e);do{t=(a=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,n=a>>12&63,s=a>>6&63,r=63&a,l[c++]=i.charAt(t)+i.charAt(n)+i.charAt(s)+i.charAt(r)}while(o255)||(sa.log('id \u957f\u5ea6\u8d85\u8fc7 255 \u4e2a\u5b57\u7b26\uff01'),!1)}};function getOpenidNameByAppid(e){if(''==e||!isString(e))return sa.log('error: \u53c2\u6570\u5fc5\u987b\u662f\u6709\u6548\u503c'),!1;var t=getAppId(),n="$identity_"+e+"_openid";return t&&(n="$identity_"+e+'_'+t+"_openid"),n}function validId(e){return!isString(e)&&!isNumber(e)||''===e?(sa.log('\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef'),!1):isNumber(e)&&(e=String(e),!/^\d+$/.test(e))?(sa.log('\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef'),!1):!!check.checkIdLength(e)&&e}function isNewLoginId(e,t){return e!==sa.store._state.history_login_id.name||sa.store._state.history_login_id.value!==t}function isSameAndAnonymousID(e){var t=sa.store.getFirstId(),n=sa.store.getDistinctId();return t?e===t:e===n}function setUpperCase(e){return isString(e)?e.toLocaleUpperCase():e}function getIsFirstDay(){return!!('object'==typeof sa.store._state&&isNumber(sa.store._state.first_visit_day_time)&&sa.store._state.first_visit_day_time>(new Date).getTime())}function joinUrl(e,t){return!!e&&('\u672a\u53d6\u5230'===e?'\u672a\u53d6\u5230':t?e+'?'+t:e)}function getPath(e){return e=isString(e)?e.replace(/^\//,''):'\u53d6\u503c\u5f02\u5e38'}function getAppProps(e){var t={};return e&&e.path&&(t.$url_path=getPath(e.path),t.$url_query=setQuery(e.query),t.$url=joinUrl(t.$url_path,t.$url_query)),t}function getPageProps(){var e=getCurrentPage(),t=getCurrentPath(),n=e.sensors_mp_url_query||'';return{$url_path:t,$url:joinUrl(t,n),$url_query:n}}function rot13defs(e){return rot13obfs(e=String(e),113)}function rot13obfs(e,t){t='number'==typeof t?t:13;for(var n=(e=String(e)).split(''),s=0,r=n.length;s{sa.system_api.getSystemInfo({success(e){var t=sa.properties;if(isObject(e)){t.$manufacturer=e.brand,t.$model=e.model,t.$brand=setUpperCase(e.brand)||'',t.$screen_width=Number(e.screenWidth),t.$screen_height=Number(e.screenHeight),t.$os=formatSystem(e.platform),t.$os_version=e.system.indexOf(' ')>-1?e.system.split(' ')[1]:e.system,t.$mp_client_app_version=e.version||'';var n=e.SDKVersion||'';n&&(t.$mp_client_basic_library_version=n)}},fail(e){sa.log('\u83b7\u53d6\u7cfb\u7edf\u4fe1\u606f\u5931\u8d25: ',e)},complete(){e()}})})}var system={inited:!1,init:function(){var e=(new Date).getTimezoneOffset();isNumber(e)&&(sa.properties.$timezone_offset=e);var t=getAppId()||sa.para.app_id||sa.para.appid;t&&(sa.properties.$app_id=t),getNetwork(),getSystemInfo$1()}},identity_id='$identity_taobao_uuid';function stripProperties(e){return isObject(e)?(each(e,function(t,n){if(isArray(t)){var s=[];each(t,function(e){if(isString(e))s.push(e);else if(isUndefined(e))s.push('null');else try{s.push(JSON.stringify(e))}catch(e){sa.log('\u60a8\u7684\u6570\u636e - '+n+':'+t+' - \u7684\u6570\u7ec4\u91cc\u7684\u503c\u6709\u9519\u8bef,\u5df2\u7ecf\u5c06\u5176\u5220\u9664')}}),e[n]=s}if(isObject(t))try{e[n]=JSON.stringify(t)}catch(s){delete e[n],sa.log('\u60a8\u7684\u6570\u636e - '+n+':'+t+' - \u7684\u6570\u636e\u503c\u6709\u9519\u8bef,\u5df2\u7ecf\u5c06\u5176\u5220\u9664')}else isString(t)||isNumber(t)||isDate(t)||isBoolean(t)||isArray(t)||(sa.log('\u60a8\u7684\u6570\u636e - ',t,'-\u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664'),delete e[n])}),e):e}function parseSuperProperties(e){isObject(e)&&each(e,function(t,n){if(isFunction(t))try{e[n]=t(),isFunction(e[n])&&(sa.log('\u60a8\u7684\u5c5e\u6027 - '+n+' \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664'),delete e[n])}catch(t){delete e[n],sa.log('\u60a8\u7684\u5c5e\u6027 - '+n+' \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664')}})}function batchRequest(e){if(isArray(e.data)&&e.data.length>0){var t=Date.now(),n=sa.para.datasend_timeout;e.data.forEach(function(e){e._flush_time=t}),e.data=JSON.stringify(e.data);let s={url:sa.para.server_url,method:'POST',dataType:'text',data:'data_list='+encodeURIComponent(base64Encode(e.data)),timeout:n,success:function(){e.success(e.len)},fail:function(){e.fail()}};sa.system_api.request(s)}else e.success(e.len)}function onceSend(e){e._flush_time=Date.now();var t='',n=JSON.stringify(e);t=-1!==sa.para.server_url.indexOf('?')?sa.para.server_url+'&data='+encodeURIComponent(base64Encode(n)):sa.para.server_url+'?data='+encodeURIComponent(base64Encode(n));var s=sa.para.datasend_timeout;sa.system_api.request({url:t,dataType:'text',method:'GET',timeout:s})}IDENTITIES.identity_unionid='',IDENTITIES.identity_id=identity_id,IDENTITIES.openid_name='taobao',IDENTITIES.bind_preset_id=[identity_id],IDENTITIES.unbind_without_check=[identity_id],IDENTITIES.login_preset_id=[identity_id];var kit={batchRequest:batchRequest,onceSend:onceSend};function onAppHide(){isFunction(sa.platform_obj.onAppHide)&&sa.platform_obj.onAppHide(function(){sa.para.batch_send&&batchSend()})}function batchSend(){if(sa.batch_state.sended){var e,t,n=sa.batch_state.mem;(t=(e=n.length>=100?n.slice(0,100):n).length)>0&&(sa.batch_state.sended=!1,kit.batchRequest({data:e,len:t,success:batchRemove,fail:sendFail}))}}function sendFail(){sa.batch_state.sended=!0,sa.batch_state.failTime++}function batchRemove(e){sa.batch_state.clear(e),sa.batch_state.sended=!0,sa.batch_state.changed=!0,batchWrite(),sa.batch_state.failTime=0}function batchWrite(){sa.batch_state.changed&&(sa.batch_state.is_first_batch_write&&(sa.batch_state.is_first_batch_write=!1,setTimeout(function(){batchSend()},1e3)),sa.batch_state.syncStorage&&(sa.system_api.setStorageSync('sensors_prepare_data',sa.batch_state.mem),sa.batch_state.changed=!1))}function batchInterval(){!function e(){setTimeout(function(){batchWrite(),e()},1e3)}(),function e(){setTimeout(function(){batchSend(),e()},sa.para.batch_send.send_timeout*Math.pow(2,sa.batch_state.failTime))}()}function reportEvent(e){var t='';e._flush_time=Date.now(),t=e.event?"sensors_"+e.event:"sensors_"+e.type,e.dataSource='sensors',sa.log('report_event, name: ',t,'-- key: ',e),__mp_private_api__.reportEvent(t,e)}sa.batch_state={mem:[],changed:!1,sended:!0,is_first_batch_write:!0,sync_storage:!1,failTime:0,getLength:function(){return this.mem.length},add:function(e){this.mem.push(e)},clear:function(e){this.mem.splice(0,e)}},sa.batchWrite=batchWrite,sa.prepareData=function(e){var t={distinct_id:sa.store.getDistinctId(),lib:{$lib:sa.lib.name,$lib_method:sa.lib.method,$lib_version:String(sa.lib.version)},properties:{}};if(isObject(sa.store._state.identities)&&(t.identities=extend({},sa.store._state.identities)),'track_id_unbind'===e.type&&'$UnbindID'===e.event&&(t.identities=deepCopy(e.unbind_value),delete e.unbind_value),t=extend(t,sa.store.getUnionId(),e),isObject(e.properties)&&!isEmptyObject(e.properties)&&(t.properties=extend(t.properties,e.properties)),e.type&&'profile'===e.type.slice(0,7)||(t._track_id=Number(String(getRandom()).slice(2,5)+String(getRandom()).slice(2,4)+String(Date.now()).slice(-4)),t.properties=extend({},sa.properties,sa.store.getProps(),sa.currentProps,t.properties),'track'===e.type&&(t.properties.$is_first_day=getIsFirstDay())),t.properties.$time&&isDate(t.properties.$time)?(t.time=1*t.properties.$time,delete t.properties.$time):t.time=1*new Date,sa.ee.data.emit('beforeBuildCheck',t),parseSuperProperties(t.properties),searchObjDate(t),stripProperties(t.properties),searchObjString(t),sa.ee.data.emit('finalAdjustData',t),!sa.para.server_url)return!1;sa.log(t),sa.send(t)},sa.send=function(e){if('sensorsdata2015_binance'===sa.storageName&&'native'===sa.para.data_report_type)return reportEvent(e),!1;sa.para.batch_send?(sa.batch_state.getLength()>=500&&(sa.log('\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38'),sa.batch_state.mem.shift()),sa.batch_state.add(e),sa.batch_state.changed=!0,sa.batch_state.getLength()>=sa.para.batch_send.max_length&&batchSend()):kit.onceSend(e)},sa.log=function(){if(sa.para.show_log&&'object'==typeof console&&console.log)try{var e=Array.prototype.slice.call(arguments);return console.log.apply(console,e)}catch(e){console.log(arguments[0])}},sa.track=function(e,t,n){sa.prepareData({type:'track',event:e,properties:t},n)},sa.setProfile=function(e){sa.prepareData({type:'profile_set',properties:e})},sa.setOnceProfile=function(e,t){sa.prepareData({type:'profile_set_once',properties:e},t)},sa.login=function(e){var t=sa.store.getFirstId(),n=sa.store.getDistinctId();e!==n&&(t?sa.trackSignup(e,'$SignUp'):(sa.store.set('first_id',n),sa.trackSignup(e,'$SignUp')))},sa.logout=function(e){var t=sa.store.getFirstId();t?(sa.store.set('first_id',''),!0===e?sa.store.set('distinct_id',getUUID()):sa.store.set('distinct_id',t)):sa.log('\u6ca1\u6709first_id\uff0clogout\u5931\u8d25')},sa.identify=function(e){if('number'==typeof e)e=String(e);else if('string'!=typeof e)return!1;sa.store.getFirstId()?sa.store.set('first_id',e):sa.store.set('distinct_id',e)},sa.trackSignup=function(e,t,n){var s,r,a,i,o;isObject(e)?(s=e.id,r=e.event_name,a=e.id_name):(s=e,r=t),sa.store.set('distinct_id',s),i=a&&a!==IDENTITY_KEY.LOGIN?a+'+'+s:s,o=sa.store.getFirstId()||sa.store.getDistinctId(),sa.prepareData({original_id:o,distinct_id:i,type:'track_signup',event:r,properties:n})},sa.registerApp=function(e){isObject(e)&&!isEmptyObject(e)&&(sa.currentProps=extend(sa.currentProps,e))},sa.clearAppRegister=function(e){isArray(e)&&each(sa.currentProps,function(t,n){include(e,n)&&delete sa.currentProps[n]})},sa.register=function(e){isObject(e)&&!isEmptyObject(e)&&sa.store.setProps(e)},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.use=function(e){const t=toArray(arguments,1);return t.unshift(this),isObject(e)&&isFunction(e.init)&&e.init.apply(e,t),e},sa.usePlugin=sa.use,sa.getServerUrl=function(){return sa.para.server_url},sa.registerPropertyPlugin=function(e){isFunction(e.properties)?!e.isMatchedWithFilter||isFunction(e.isMatchedWithFilter)?sa.ee.data.on('finalAdjustData',function(t){try{isFunction(e.isMatchedWithFilter)?e.isMatchedWithFilter(t)&&e.properties(t):e.properties(t)}catch(e){sa.log('execute registerPropertyPlugin callback error:'+e)}}):sa.log('registerPropertyPlugin arguments error, isMatchedWithFilter must be function'):sa.log('registerPropertyPlugin arguments error, properties must be function')};var hasOwnProperty$1=Object.prototype.hasOwnProperty,store={inited:!0,storageInfo:null,store_queue:[],getStorage:function(){return this.storageInfo?this.storageInfo:(this.storageInfo=sa.system_api.getStorageSync(sa.storageName)||'',this.storageInfo)},_state:{},toState:function(e){var t=null,n=this;function s(){t.distinct_id?n._state=t:n.set('distinct_id',getUUID())}isJSONString(e)?(t=JSON.parse(e),s()):isObject(e)?(t=e,s()):this.set('distinct_id',getUUID());var r=this._state._first_id||this._state.first_id,a=this._state._distinct_id||this._state.distinct_id,i=(this._state.history_login_id?this._state.history_login_id:{}).name;if(this._state.identities&&isString(this._state.identities)){var o=JSON.parse(rot13defs(this._state.identities));this._state.identities=o}function c(e){for(var t in store._state.identities)hasOwnProperty$1.call(store._state.identities,t)&&t!==IDENTITIES.identity_id&&t!==e&&delete store._state.identities[t]}this._state.identities&&isObject(this._state.identities)&&!isEmptyObject(this._state.identities)||(this._state.identities={},this._state.identities[IDENTITIES.identity_id]=getUUID()),r?i&&hasOwnProperty$1.call(this._state.identities,i)?this._state.identities[i]!==a&&(this._state.identities[i]=a,c(i),this._state.history_login_id.value=a):(this._state.identities[IDENTITY_KEY.LOGIN]=a,c(IDENTITY_KEY.LOGIN),this._state.history_login_id={name:IDENTITY_KEY.LOGIN,value:a}):this._state.history_login_id={name:'',value:''},this.save()},getFirstId:function(){return this._state._first_id||this._state.first_id},getDistinctId:function(){var e=this.getLoginDistinctId();return e||(this._state._distinct_id||this._state.distinct_id)},getUnionId:function(){var e={},t=this._state._first_id||this._state.first_id,n=this.getDistinctId();return t&&n?(e.login_id=n,e.anonymous_id=t):e.anonymous_id=n,e},getHistoryLoginId:function(){return isObject(this._state.history_login_id)?this._state.history_login_id:null},getLoginDistinctId:function(){var e=this.getHistoryLoginId();return isObject(e)&&e.value?e.name!==IDENTITY_KEY.LOGIN?e.name+'+'+e.value:e.value:null},getProps:function(){return this._state.props||{}},setProps:function(e,t){var n=this._state.props||{};t?this.set('props',e):(extend(n,e),this.set('props',n))},set:function(e,t){var n={};for(var s in'string'==typeof e?n[e]=t:'object'==typeof e&&(n=e),this._state=this._state||{},n)this._state[s]=n[s],'first_id'===s?delete this._state._first_id:'distinct_id'===s&&(delete this._state._distinct_id,sa.events.emit('changeDistinctId'));this.save()},identitiesSet:function(e){var t={};switch(e.type){case'login':t[IDENTITIES.identity_id]=this._state.identities[IDENTITIES.identity_id],t[e.id_name]=e.id;break;case'logout':t[IDENTITIES.identity_id]=this._state.identities[IDENTITIES.identity_id]}this.set('identities',t)},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.system_api.setStorageSync(sa.storageName,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.system_api.setStorageSync(sa.storageName,e)},init:function(){var e=this.getStorage(),t=getUUID();if(e)isString(e)&&-1!==e.indexOf("data:enc;")&&(e=e.substring("data:enc;".length),e=JSON.parse(rot13defs(e))),this.toState(e);else{meta.is_first_launch=!0;var n=new Date,s=n.getTime();n.setHours(23),n.setMinutes(59),n.setSeconds(60),this.set({distinct_id:t,first_visit_time:s,first_visit_day_time:n.getTime(),identities:{[IDENTITIES.identity_id]:t},history_login_id:{name:'',value:''}}),sa.setOnceProfile({$first_visit_time:n})}this.checkStoreInit&&this.checkStoreInit()}};function identify(e,t){if(e=_.validId(e)){var n=store.getFirstId();!0===t?n?store.set('first_id',e):store.set('distinct_id',e):n?store.change('first_id',e):store.change('distinct_id',e)}}function trackSignup(e,t,n){var s,r,a,i;_.isObject(e)?(s=e.id,r=e.event_name,a=e.id_name):(s=e,r=t),store.set('distinct_id',s),i=a&&a!==IDENTITY_KEY.LOGIN?a+'+'+s:s;var o=store.getFirstId()||store.getDistinctId();sa.prepareData({original_id:o,distinct_id:i,type:'track_signup',event:r,properties:n})}function bindWithoutCheck(e,t){store._state.identities[e]=t,store.save(),sa.prepareData({type:'track_id_bind',event:'$BindID'})}function bind$1(e,t){var n='';if(_.isNumber(t)){if(_.isInteger(t)&&!1===_.isSafeInteger(t))return sa.log('Value must be String'),!1;t=String(t)}if(!_.isString(e))return sa.log('Key must be String'),!1;var s=store.getHistoryLoginId(),r=s?s.name:'',a=[IDENTITY_KEY.LOGIN,r];return _.isArray(IDENTITIES.bind_preset_id)&&(a=[IDENTITY_KEY.LOGIN,r].concat(IDENTITIES.bind_preset_id)),!_.check.checkKeyword(e)||_.isPresetIdKeys(e,a)?(n='Key ['+e+'] is invalid',sa.log(n),!1):t&&''!==t?_.isString(t)?!!_.check.checkIdLength(t)&&void bindWithoutCheck(e,t):(sa.log('Value must be String'),!1):(sa.log('Value is empty or null'),!1)}function unbindWithoutCheck(e,t){hasOwnProperty.call(store._state.identities,e)&&t===store._state.identities[e]&&(IDENTITIES.unbind_without_check&&IDENTITIES.unbind_without_check.indexOf(e)<0&&delete store._state.identities[e],store.save());var n=store.getDistinctId(),s=store.getFirstId();n===e+'+'+t&&(store.set('first_id',''),store.set('distinct_id',s),store.set('history_login_id',{name:'',value:''}));var r={};r[e]=t,sa.prepareData({type:'track_id_unbind',event:'$UnbindID',unbind_value:r})}function unbind(e,t){var n='';if(_.isNumber(t)){if(_.isInteger(t)&&!1===_.isSafeInteger(t))return sa.log('Value must be String'),!1;t=String(t)}return _.isString(e)?!_.check.checkKeyword(e)||_.isPresetIdKeys(e,[IDENTITY_KEY.LOGIN])?(n='Key ['+e+'] is invalid',sa.log(n),!1):t&&''!==t?_.isString(t)?!!_.check.checkIdLength(t)&&void unbindWithoutCheck(e,t):(sa.log('Value must be String'),!1):(sa.log('Value is empty or null'),!1):(sa.log('Key must be String'),!1)}function loginWithKey(e,t){if(!_.isString(e))return sa.log('Key must be String'),!1;var n='';if(!_.check.checkKeyword(e)&&e.length>100)n='Key ['+e+'] is invalid',sa.log(n);else if(!_.check.checkKeyword(e))return n='Key ['+e+'] is invalid',sa.log(n),!1;if(_.isPresetIdKeys(e,IDENTITIES.login_preset_id))return n='Key ['+e+'] is invalid',sa.log(n),!1;if(!(t=_.validId(t)))return!1;if(_.isSameAndAnonymousID(t))return!1;var s=store.getFirstId(),r=store.getDistinctId();_.isNewLoginId(e,t)&&(store._state.identities[e]=t,store.set('history_login_id',{name:e,value:t}),s||store.set('first_id',r),sa.trackSignup({id:t,event_name:'$SignUp',id_name:e}),store.identitiesSet({type:'login',id:t,id_name:e}))}function login(e){if(!(e=_.validId(e)))return!1;if(_.isSameAndAnonymousID(e))return!1;var t=store.getFirstId(),n=store.getDistinctId(),s=IDENTITY_KEY.LOGIN;_.isNewLoginId(s,e)&&(store._state.identities&&(store._state.identities[s]=e),store.set('history_login_id',{name:s,value:e}),t||store.set('first_id',n),sa.trackSignup({id:e,event_name:'$SignUp'}),store.identitiesSet({type:'login',id:e,id_name:s}))}function logout(){var e=store.getFirstId();store.identitiesSet({type:'logout'}),store.set('history_login_id',{name:'',value:''}),e?(store.set('first_id',''),store.set('distinct_id',e)):sa.log('\u6ca1\u6709first_id\uff0clogout\u5931\u8d25')}function bindOpenid(e){if(!(e=_.validId(e)))return!1;bind$1(_.getOpenidNameByAppid(IDENTITIES.openid_name),e)}function unbindOpenid(e){if(!_.validId(e))return!1;unbind(_.getOpenidNameByAppid(IDENTITIES.openid_name),e)}sa.store=store;var functions=Object.freeze({__proto__:null,identify:identify,trackSignup:trackSignup,bindWithoutCheck:bindWithoutCheck,bind:bind$1,unbindWithoutCheck:unbindWithoutCheck,unbind:unbind,loginWithKey:loginWithKey,login:login,logout:logout,bindOpenid:bindOpenid,unbindOpenid:unbindOpenid});for(var f in functions)sa[f]=functions[f];function buildPara(e){return!(!e||!isObject(e))&&(sa.setPara(e),!!e.server_url||(sa.log('error: server_url is empty'),!1))}function isValidListener(e){return'function'==typeof e||!(!e||'object'!=typeof e)&&isValidListener(e.listener)}sa.identify=function(){},sa.unsetOpenid=function(e){if(!_.validId(e))return!1;var t=_.getOpenidNameByAppid('taobao');sa.unbind(t,e)},sa.setOpenid=function(e){if(!(e=_.validId(e)))return!1;var t=_.getOpenidNameByAppid('taobao');sa.bind(t,e)},sa.setPara=function(e){sa.para=extend2Lev(sa.para,e);var t=[];if(isArray(sa.para.source_channel))for(var n=sa.para.source_channel.length,s=0;s0&&this.cacheEvents.forEach(function(n){n.type===e&&t.call(null,n.data)})}emit(e,t){super.emit.apply(this,arguments),this.cacheEvents.push({type:e,data:t}),this.cacheEvents.length>this.maxLen&&this.cacheEvents.shift()}}var ee={};ee.sdk=new EventEmitterEx,ee.data=new EventEmitterEx;var eventEmitter=function(){this.sub=[]};eventEmitter.prototype={add:function(e){this.sub.push(e)},emit:function(e,t){this.sub.forEach(function(n){n.on(e,t)})}};var 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){sa.log(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){sa.log(e)}})}},sa.ee=ee,sa.eventSub=eventSub,sa.events=new eventEmitter,sa.meta=meta,sa.kit=kit,sa.modules={},sa.init=function(e){if(!0===meta.hasExeInit)return!1;meta.hasExeInit=!0,ee.sdk.emit('beforeInit'),buildPara(e),ee.sdk.emit('initPara'),ee.sdk.emit('afterInitPara'),sa.store.init(),sa.system.init(),ee.sdk.emit('initAPI'),ee.sdk.emit('afterInitAPI'),ee.sdk.emit('afterInit'),ee.sdk.emit('ready'),sa.para.batch_send&&(sa.system_api.getStorage('sensors_prepare_data',function(e){var t=[];e&&e.data&&isArray(e.data)&&(t=e.data,sa.batch_state.mem=t.concat(sa.batch_state.mem)),sa.batch_state.syncStorage=!0,onAppHide()}),batchInterval())};const forEach$1=Array.prototype.forEach,slice$1=Array.prototype.slice,_hasOwnProperty$1=Object.prototype.hasOwnProperty,_toString$1=Object.prototype.toString;function extend$1(e){return each$1(slice$1.call(arguments,1),function(t){for(var n in t)void 0!==t[n]&&(e[n]=t[n])}),e}function isObject$1(e){return null!==e&&'object'==typeof e}function isFunction$1(e){if(!e)return!1;var t=Object.prototype.toString.call(e);return'[object Function]'==t||'[object AsyncFunction]'==t||'[object GeneratorFunction]'==t}function isString$1(e){return'[object String]'==_toString$1.call(e)}function each$1(e,t,n){if(null==e)return!1;if(forEach$1&&e.forEach===forEach$1)e.forEach(t,n);else if(e.length===+e.length){for(var s=0,r=e.length;s0&&(t-s)/36e5<24&&(n.event_duration=(t-s)/1e3),global.sensors.para&&global.sensors.para.autoTrack&&global.sensors.para.autoTrack.appHide&&global.sensors.track('$MPHide',n)}lifeCycleHook.forEach(function(e){miniLifeCycleAPI[e]=function(){throw new Error(`\u9700\u8981\u5148\u5b9a\u4e49 '${e}' \u624d\u80fd\u4f7f\u7528`)}});var presetEvents={appLaunch:!0,appShow:!0,appHide:!0},AutoTrackApp={name:'AutoTrackApp'};function getMixedQuery$1(e){var t={};if(e&&global.sensors._.isObject(e.query)&&(t=global.sensors._.extend({},e.query),e.query.qrCode&&global.sensors._.extend(t,global.sensors._.getObjFromQuery(global.sensors._.decodeURIComponent(e.query.qrCode)))),e&&global.sensors._.isObject(e.referrerInfo)&&e.referrerInfo.extraData){var n={};global.sensors._.isObject(e.referrerInfo.extraData)&&!global.sensors._.isEmptyObject(e.referrerInfo.extraData)?n=e.referrerInfo.extraData:global.sensors._.isJSONString(e.referrerInfo.extraData)&&(n=JSON.parse(e.referrerInfo.extraData)),global.sensors._.extend(t,n)}return t}function setUtm$1(e,t){var n={},s=getMixedQuery$1(e),r=global.sensors._.getCustomUtmFromQuery(s,'$','_','$'),a=global.sensors._.getCustomUtmFromQuery(s,'$latest_','_latest_','$latest_');return n.pre1=r,n.pre2=a,global.sensors._.extend(t,r),n}function appOnLaunch$1(e,t){if(isObject$1(e)){var n={};if(e&&e.path&&extend$1(n,global.sensors._.getAppProps(e)),e&&e.scene){var s=getScene(e.scene,global.sensors);s&&(n.$scene=s,global.sensors.meta.current_scene=s,global.sensors.registerApp({$latest_scene:s}))}else n.$scene='\u672a\u53d6\u5230\u503c';var r=global.sensors.para&&global.sensors.para.autoTrack&&global.sensors.para.autoTrack.appLaunch,a=setUtm$1(e,n);global.sensors.meta.is_first_launch?(n.$is_first_time=!0,global.sensors._.isEmptyObject(a.pre1)||r&&global.sensors.setOnceProfile(a.pre1)):n.$is_first_time=!1,global.sensors._.isEmptyObject(a.pre2)||global.sensors._.setLatestChannel(a.pre2),n.$url_query=global.sensors._.setQuery(e.query),isObject$1(t)&&(n=extend$1(n,t)),r&&global.sensors.track('$MPLaunch',n)}else global.sensors.log('appOnLaunch:\u8bf7\u4f20\u5165\u6b63\u786e\u7684\u53c2\u6570')}function appOnShow$1(e,t){var n={};global.sensors.meta.mp_show_time=(new Date).getTime(),e&&e.path&&extend$1(n,global.sensors._.getAppProps(e));var s=setUtm$1(e,n);if(global.sensors._.isEmptyObject(s.pre2)||global.sensors._.setLatestChannel(s.pre2),e&&e.scene){var r=getScene(e.scene,global.sensors);r&&(n.$scene=r,global.sensors.registerApp({$latest_scene:r}))}isObject$1(t)&&(n=extend$1(n,t)),global.sensors.para&&global.sensors.para.autoTrack&&global.sensors.para.autoTrack.appShow&&global.sensors.track('$MPShow',n)}AutoTrackApp.init=function(e,t){if(!e)return console.log('\u8bf7\u6b63\u786e\u521d\u59cb\u5316 sensorsdata\uff0c\u624d\u80fd\u4f7f\u7528\u63d2\u4ef6'),!1;global.sensors=e,global.sensors.para.autoTrack=extend$1(presetEvents,t),AutoTrackApp.lifeCycleAPI(),AutoTrackApp.proxyFrameworkInterface()},AutoTrackApp.lifeCycleAPI=function(){var e={};e.appOnLaunch=appOnLaunch,e.appOnShow=appOnShow,e.appOnHide=appOnHide,registerLifeCycleHook(e)},AutoTrackApp.proxyFrameworkInterface=function(){proxyApp(hookAppFunc,global.sensors)},AutoTrackApp.lifeCycleAPI=function(){var e={};e.appOnLaunch=appOnLaunch$1,e.appOnShow=appOnShow$1,e.appOnHide=appOnHide,registerLifeCycleHook(e)};var global$1={};function getCurrentPath$1(e){var t='\u672a\u53d6\u5230',n=getCurrentPage$1(e);return n&&n.route&&(t=n.route),t}function getCurrentPage$1(e){var t,n={};if(e)try{n=(t=isFunction$1(e.platform_obj.getCurrentPages)?e.platform_obj.getCurrentPages():getCurrentPages())[t.length-1]}catch(t){e.log(t)}else console.log('getCurrentPage:\u8bf7\u4f20\u5165 sa \u5bf9\u8c61');return n}function isClick(e){return!!{tap:1,longtap:1,longpress:1}[e]}function createClickData(e){var t={},n={},s=e.currentTarget||{},r=s.dataset||{};return t.$element_id=s.id,t.$element_type=r.type,t.$element_content=r.content,t.$element_name=r.name,isObject$1(e.event_prop)&&(n=e.event_prop),t.$url_path=getCurrentPath$1(global$1.sensors),t.$url=global$1.sensors._.getPageProps().$url,t=extend$1(t,n)}var ClickTrack={track:function(e){var t=createClickData(e),n=e.currentTarget||{},s=e.target||{},r=e.type,a=global$1.sensors.para;if(isObject$1(a.framework)&&isObject$1(a.framework.taro)&&!a.framework.taro.createApp&&s.id&&n.id&&s.id!==n.id)return!1;if(isObject$1(t)&&r&&isClick(r)){if(a.preset_events&&a.preset_events.collect_element&&!1===a.preset_events.collect_element(arguments[0]))return!1;global$1.sensors.track('$MPClick',t)}}},MP_HOOKS={data:1,onLoad:1,onShow:1,onReady:1,onPullDownRefresh:1,onReachBottom:1,onShareAppMessage:1,onPageScroll:1,onResize:1,onTabItemTap:1,onHide:1,onUnload:1};function clickProxy(e,t){var n=e[t];e[t]=function(){var e=n.apply(this,arguments),t=arguments[0];return isObject$1(t)&&ClickTrack.track(t),e}}function monitorClick(e){var t=[],n=global$1.sensors.para.autoTrack;if(n&&n.mpClick){t=getMethods(e),tabProxy(e);for(var s=t.length,r=0;r=0&&''!==t){var n={},s=(Date.now()-global$1.sensors.meta.page_show_time)/1e3;(isNaN(s)||s<0)&&(s=0),extend$1(n,global$1.sensors._.getPageProps()),n.event_duration=s,global$1.sensors.track('$MPPageLeave',n),global$1.sensors.meta.page_show_time=-1}}};function pageOnLoad(e){var t=this;if(global$1.sensors._.isObject(e)){try{t=getCurrentPage$1(global$1.sensors)}catch(e){global$1.sensors.log('pageOnLoad:'+e)}t.sensors_mp_url_query=global$1.sensors._.setQuery(e),t.sensors_mp_encode_url_query=global$1.sensors._.setQuery(e,!0)}}function pageOnShow(){global$1.sensors.meta.page_show_time=Date.now();var e={},t='';try{var n=getCurrentPage$1(global$1.sensors);t=n?n.route:''}catch(e){global$1.sensors.log('pageOnShow:'+e)}extend$1(e,global$1.sensors._.getPageProps()),e.$referrer=global$1.sensors.meta.sa_referrer,global$1.sensors.para&&global$1.sensors.para.autoTrack&&global$1.sensors.para.autoTrack.pageShow&&global$1.sensors.track('$MPViewScreen',e),global$1.sensors.meta.sa_referrer=t}function pageOnUnload(){pageLeave()}function pageOnHide(){pageLeave()}var presetEvents$1={pageShow:!0,mpClick:!0,pageLeave:!1},AutoTrackPage={name:'AutoTrackPage',init:function(e,t){if(!e)return console.log('\u8bf7\u6b63\u786e\u521d\u59cb\u5316 sensorsdata\uff0c\u624d\u80fd\u4f7f\u7528\u63d2\u4ef6'),!1;global$1.sensors=e,global$1.sensors.para.autoTrack=extend$1(presetEvents$1,t),AutoTrackPage.lifeCycleAPI(),AutoTrackPage.proxyFrameworkInterface()},lifeCycleAPI:function(){var e={};e.pageOnShow=pageOnShow,e.pageOnLoad=pageOnLoad,e.pageOnUnload=pageOnUnload,e.pageOnHide=pageOnHide,registerLifeCycleHook(e)},proxyFrameworkInterface:function(){proxyPage(hookPageFunc,monitorClick)}},presetEvents$2={appLaunch:!0,appShow:!0,appHide:!0,pageShow:!0,mpClick:!0,pageLeave:!1},AutoTrack={name:'AutoTrack',init:function(e,t){if(!e)return console.log('\u8bf7\u6b63\u786e\u521d\u59cb\u5316 sensorsdata\uff0c\u624d\u80fd\u4f7f\u7528\u63d2\u4ef6'),!1;e.ee.sdk.on('afterInitPara',function(){var n=extend$1(presetEvents$2,e.para.autoTrack,t);e.use(AutoTrackApp,n),e.use(AutoTrackPage,n)})}};sa.platform_obj=my,sa._=_,sa.system=system,sa.system_api=Object.assign(compose,compose$1),sa.lib.name='TaobaoMini',sa.properties.$lib='TaobaoMini',sa.storageName='sensorsdata2015_tb',sa.meta.scene_prefix='tb-',sa.properties.$data_ingestion_source=['TaobaoMini'],sa.properties.$mp_client_basic_library_version=my.SDKVersion||'',sa.use(AutoTrack);export default sa; \ No newline at end of file diff --git a/dist/mp-taobao/index.esm.js b/dist/mp-taobao/index.esm.js index dd877c7..7839569 100644 --- a/dist/mp-taobao/index.esm.js +++ b/dist/mp-taobao/index.esm.js @@ -1 +1 @@ -var sa={is_first_launch:!1,launched:!1,_queue:[],mpshow_time:null,sa_referrer:'\u76f4\u63a5\u6253\u5f00',query_share_depth:0,share_distinct_id:'',share_method:'',current_scene:'',inited:!1,para:{server_url:'',send_timeout:1e3,show_log:!1,allow_amend_share_path:!0,max_string_length:500,datasend_timeout:3e3,source_channel:[],batch_send:{send_timeout:6e3,max_length:6},preset_properties:{}},platform:'',lib:{version:'0.13.2',name:'MiniGame',method:'code'},properties:{$lib:'MiniGame',$lib_version:'0.13.2'},currentProps:{}};const _toString=Object.prototype.toString,_hasOwnProperty=Object.prototype.hasOwnProperty,indexOf=Array.prototype.indexOf,slice=Array.prototype.slice,_isArray=Array.prototype.isArray,forEach=Array.prototype.forEach,bind=Function.prototype.bind;function isUndefined(e){return void 0===e}function isString(e){return'[object String]'==_toString.call(e)}function isDate(e){return'[object Date]'==_toString.call(e)}function isBoolean(e){return'[object Boolean]'==_toString.call(e)}function isNumber(e){return'[object Number]'==_toString.call(e)&&/[\d\\.]+/.test(String(e))}function isJSONString(e){try{JSON.parse(e)}catch(e){return!1}return!0}function isObject(e){return null!=e&&'[object Object]'===_toString.call(e)}function isPlainObject(e){return'[object Object]'===_toString.call(e)}function isArray(e){return _isArray||'[object Array]'===_toString.call(e)}function isFuction(e){try{return/^\s*\bfunction\b/.test(e)}catch(e){return!1}}function isArguments(e){return!(!e||!_hasOwnProperty.call(e,'callee'))}function toString(e){return null==e?'':isArray(e)||isPlainObject(e)&&e.toString===_toString?JSON.stringify(e,null,2):String(e)}function each(e,t,n){if(null==e)return!1;if(forEach&&e.forEach===forEach)e.forEach(t,n);else if(e.length===+e.length){for(var s=0,r=e.length;ssa.para.max_string_length?(sa.log('\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}function searchObjString(e){isObject(e)&&each(e,function(t,n){isObject(t)?searchObjString(e[n]):isString(t)&&(e[n]=formatString(t))})}function encodeDates(e){return each(e,function(t,n){isDate(t)?e[n]=formatDate(t):isObject(t)&&(e[n]=encodeDates(t))}),e}function utf8Encode(e){var t,n,s,r,a='';for(t=n=0,s=(e=(e+'').replace(/\r\n/g,'\n').replace(/\r/g,'\n')).length,r=0;r127&&i<2048?String.fromCharCode(i>>6|192,63&i|128):String.fromCharCode(i>>12|224,i>>6&63|128,63&i|128),null!==o&&(n>t&&(a+=e.substring(t,n)),a+=o,t=n=r+1)}return n>t&&(a+=e.substring(t,e.length)),a}function base64Encode(e){var t,n,s,r,a,i='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',o=0,c=0,u='',l=[];if(!e)return e;e=utf8Encode(e);do{t=(a=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,n=a>>12&63,s=a>>6&63,r=63&a,l[c++]=i.charAt(t)+i.charAt(n)+i.charAt(s)+i.charAt(r)}while(o255)||(sa.log('id \u957f\u5ea6\u8d85\u8fc7 255 \u4e2a\u5b57\u7b26\uff01'),!1)}};function getOpenidNameByAppid(e){if(''==e||!isString(e))return sa.log('error: \u53c2\u6570\u5fc5\u987b\u662f\u6709\u6548\u503c'),!1;var t=getAppId(),n="$identity_"+e+"_openid";return t&&(n="$identity_"+e+'_'+t+"_openid"),n}function validId(e){return!isString(e)&&!isNumber(e)||''===e?(sa.log('\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef'),!1):isNumber(e)&&(e=String(e),!/^\d+$/.test(e))?(sa.log('\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef'),!1):!!check.checkIdLength(e)&&e}function isNewLoginId(e,t){return e!==sa.store._state.history_login_id.name||sa.store._state.history_login_id.value!==t}function isSameAndAnonymousID(e){var t=sa.store.getFirstId(),n=sa.store.getDistinctId();return t?e===t:e===n}function setUpperCase(e){return isString(e)?e.toLocaleUpperCase():e}function getIsFirstDay(){return!!('object'==typeof sa.store._state&&isNumber(sa.store._state.first_visit_day_time)&&sa.store._state.first_visit_day_time>(new Date).getTime())}function joinUrl(e,t){return!!e&&('\u672a\u53d6\u5230'===e?'\u672a\u53d6\u5230':t?e+'?'+t:e)}function getPath(e){return e=isString(e)?e.replace(/^\//,''):'\u53d6\u503c\u5f02\u5e38'}function getAppProps(e){var t={};return e&&e.path&&(t.$url_path=getPath(e.path),t.$url_query=setQuery(e.query),t.$url=joinUrl(t.$url_path,t.$url_query)),t}function getPageProps(){var e=getCurrentPage(),t=getCurrentPath(),n=e.sensors_mp_url_query||'';return{$url_path:t,$url:joinUrl(t,n),$url_query:n}}function rot13defs(e){return rot13obfs(e=String(e),113)}function rot13obfs(e,t){t='number'==typeof t?t:13;for(var n=(e=String(e)).split(''),s=0,r=n.length;s{sa.system_api.getSystemInfo({success(e){var t=sa.properties;if(isObject(e)){t.$manufacturer=e.brand,t.$model=e.model,t.$brand=setUpperCase(e.brand)||'',t.$screen_width=Number(e.screenWidth),t.$screen_height=Number(e.screenHeight),t.$os=formatSystem(e.platform),t.$os_version=e.system.indexOf(' ')>-1?e.system.split(' ')[1]:e.system,t.$mp_client_app_version=e.version||'';var n=e.SDKVersion||'';n&&(t.$mp_client_basic_library_version=n)}},fail(e){sa.log('\u83b7\u53d6\u7cfb\u7edf\u4fe1\u606f\u5931\u8d25: ',e)},complete(){e()}})})}var system={inited:!1,init:function(){var e=(new Date).getTimezoneOffset();isNumber(e)&&(sa.properties.$timezone_offset=e);var t=getAppId()||sa.para.app_id||sa.para.appid;t&&(sa.properties.$app_id=t),getNetwork(),getSystemInfo$1()}},identity_id='$identity_taobao_uuid';function stripProperties(e){return isObject(e)?(each(e,function(t,n){if(isArray(t)){var s=[];each(t,function(e){if(isString(e))s.push(e);else if(isUndefined(e))s.push('null');else try{s.push(JSON.stringify(e))}catch(e){sa.log('\u60a8\u7684\u6570\u636e - '+n+':'+t+' - \u7684\u6570\u7ec4\u91cc\u7684\u503c\u6709\u9519\u8bef,\u5df2\u7ecf\u5c06\u5176\u5220\u9664')}}),e[n]=s}if(isObject(t))try{e[n]=JSON.stringify(t)}catch(s){delete e[n],sa.log('\u60a8\u7684\u6570\u636e - '+n+':'+t+' - \u7684\u6570\u636e\u503c\u6709\u9519\u8bef,\u5df2\u7ecf\u5c06\u5176\u5220\u9664')}else isString(t)||isNumber(t)||isDate(t)||isBoolean(t)||isArray(t)||(sa.log('\u60a8\u7684\u6570\u636e - ',t,'-\u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664'),delete e[n])}),e):e}function parseSuperProperties(e){isObject(e)&&each(e,function(t,n){if(isFunction(t))try{e[n]=t(),isFunction(e[n])&&(sa.log('\u60a8\u7684\u5c5e\u6027 - '+n+' \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664'),delete e[n])}catch(t){delete e[n],sa.log('\u60a8\u7684\u5c5e\u6027 - '+n+' \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664')}})}function batchRequest(e){if(isArray(e.data)&&e.data.length>0){var t=Date.now(),n=sa.para.datasend_timeout;e.data.forEach(function(e){e._flush_time=t}),e.data=JSON.stringify(e.data);let s={url:sa.para.server_url,method:'POST',dataType:'text',data:'data_list='+encodeURIComponent(base64Encode(e.data)),timeout:n,success:function(){e.success(e.len)},fail:function(){e.fail()}};sa.system_api.request(s)}else e.success(e.len)}function onceSend(e){e._flush_time=Date.now();var t='',n=JSON.stringify(e);t=-1!==sa.para.server_url.indexOf('?')?sa.para.server_url+'&data='+encodeURIComponent(base64Encode(n)):sa.para.server_url+'?data='+encodeURIComponent(base64Encode(n));var s=sa.para.datasend_timeout;sa.system_api.request({url:t,dataType:'text',method:'GET',timeout:s})}IDENTITIES.identity_unionid='',IDENTITIES.identity_id=identity_id,IDENTITIES.openid_name='taobao',IDENTITIES.bind_preset_id=[identity_id],IDENTITIES.unbind_without_check=[identity_id],IDENTITIES.login_preset_id=[identity_id];var kit={batchRequest:batchRequest,onceSend:onceSend};function onAppHide(){isFunction(sa.platform_obj.onAppHide)&&sa.platform_obj.onAppHide(function(){sa.para.batch_send&&batchSend()})}function batchSend(){if(sa.batch_state.sended){var e,t,n=sa.batch_state.mem;(t=(e=n.length>=100?n.slice(0,100):n).length)>0&&(sa.batch_state.sended=!1,kit.batchRequest({data:e,len:t,success:batchRemove,fail:sendFail}))}}function sendFail(){sa.batch_state.sended=!0,sa.batch_state.failTime++}function batchRemove(e){sa.batch_state.clear(e),sa.batch_state.sended=!0,sa.batch_state.changed=!0,batchWrite(),sa.batch_state.failTime=0}function batchWrite(){sa.batch_state.changed&&(sa.batch_state.is_first_batch_write&&(sa.batch_state.is_first_batch_write=!1,setTimeout(function(){batchSend()},1e3)),sa.batch_state.syncStorage&&(sa.system_api.setStorageSync('sensors_prepare_data',sa.batch_state.mem),sa.batch_state.changed=!1))}function batchInterval(){!function e(){setTimeout(function(){batchWrite(),e()},1e3)}(),function e(){setTimeout(function(){batchSend(),e()},sa.para.batch_send.send_timeout*Math.pow(2,sa.batch_state.failTime))}()}function reportEvent(e){var t='';e._flush_time=Date.now(),t=e.event?"sensors_"+e.event:"sensors_"+e.type,e.dataSource='sensors',sa.log('report_event, name: ',t,'-- key: ',e),__mp_private_api__.reportEvent(t,e)}sa.batch_state={mem:[],changed:!1,sended:!0,is_first_batch_write:!0,sync_storage:!1,failTime:0,getLength:function(){return this.mem.length},add:function(e){this.mem.push(e)},clear:function(e){this.mem.splice(0,e)}},sa.batchWrite=batchWrite,sa.prepareData=function(e){var t={distinct_id:sa.store.getDistinctId(),lib:{$lib:sa.lib.name,$lib_method:sa.lib.method,$lib_version:String(sa.lib.version)},properties:{}};if(isObject(sa.store._state.identities)&&(t.identities=sa.store._state.identities),'track_id_unbind'===e.type&&'$UnbindID'===e.event&&(t.identities=deepCopy(e.unbind_value),delete e.unbind_value),t=extend(t,sa.store.getUnionId(),e),isObject(e.properties)&&!isEmptyObject(e.properties)&&(t.properties=extend(t.properties,e.properties)),e.type&&'profile'===e.type.slice(0,7)||(t._track_id=Number(String(getRandom()).slice(2,5)+String(getRandom()).slice(2,4)+String(Date.now()).slice(-4)),t.properties=extend({},sa.properties,sa.store.getProps(),sa.currentProps,t.properties),'track'===e.type&&(t.properties.$is_first_day=getIsFirstDay())),t.properties.$time&&isDate(t.properties.$time)?(t.time=1*t.properties.$time,delete t.properties.$time):t.time=1*new Date,sa.ee.data.emit('beforeBuildCheck',t),parseSuperProperties(t.properties),searchObjDate(t),stripProperties(t.properties),searchObjString(t),sa.ee.data.emit('finalAdjustData',t),!sa.para.server_url)return!1;sa.log(t),sa.send(t)},sa.send=function(e){if(e._nocache=(String(getRandom())+String(getRandom())+String(getRandom())).slice(2,15),'sensorsdata2015_binance'===sa.storageName&&'native'===sa.para.data_report_type)return reportEvent(e),!1;sa.para.batch_send?(sa.batch_state.getLength()>=500&&(sa.log('\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38'),sa.batch_state.mem.shift()),sa.batch_state.add(e),sa.batch_state.changed=!0,sa.batch_state.getLength()>=sa.para.batch_send.max_length&&batchSend()):kit.onceSend(e)},sa.log=function(){if(sa.para.show_log&&'object'==typeof console&&console.log)try{var e=Array.prototype.slice.call(arguments);return console.log.apply(console,e)}catch(e){console.log(arguments[0])}},sa.track=function(e,t,n){sa.prepareData({type:'track',event:e,properties:t},n)},sa.setProfile=function(e){sa.prepareData({type:'profile_set',properties:e})},sa.setOnceProfile=function(e,t){sa.prepareData({type:'profile_set_once',properties:e},t)},sa.login=function(e){var t=sa.store.getFirstId(),n=sa.store.getDistinctId();e!==n&&(t?sa.trackSignup(e,'$SignUp'):(sa.store.set('first_id',n),sa.trackSignup(e,'$SignUp')))},sa.logout=function(e){var t=sa.store.getFirstId();t?(sa.store.set('first_id',''),!0===e?sa.store.set('distinct_id',getUUID()):sa.store.set('distinct_id',t)):sa.log('\u6ca1\u6709first_id\uff0clogout\u5931\u8d25')},sa.identify=function(e){if('number'==typeof e)e=String(e);else if('string'!=typeof e)return!1;sa.store.getFirstId()?sa.store.set('first_id',e):sa.store.set('distinct_id',e)},sa.trackSignup=function(e,t,n){var s,r,a,i,o;isObject(e)?(s=e.id,r=e.event_name,a=e.id_name):(s=e,r=t),sa.store.set('distinct_id',s),i=a&&a!==IDENTITY_KEY.LOGIN?a+'+'+s:s,o=sa.store.getFirstId()||sa.store.getDistinctId(),sa.prepareData({original_id:o,distinct_id:i,type:'track_signup',event:r,properties:n})},sa.registerApp=function(e){isObject(e)&&!isEmptyObject(e)&&(sa.currentProps=extend(sa.currentProps,e))},sa.clearAppRegister=function(e){isArray(e)&&each(sa.currentProps,function(t,n){include(e,n)&&delete sa.currentProps[n]})},sa.register=function(e){isObject(e)&&!isEmptyObject(e)&&sa.store.setProps(e)},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.use=function(e){const t=toArray(arguments,1);return t.unshift(this),isObject(e)&&isFunction(e.init)&&e.init.apply(e,t),e},sa.usePlugin=sa.use,sa.getServerUrl=function(){return sa.para.server_url},sa.registerPropertyPlugin=function(e){isFunction(e.properties)?!e.isMatchedWithFilter||isFunction(e.isMatchedWithFilter)?sa.ee.data.on('finalAdjustData',function(t){try{isFunction(e.isMatchedWithFilter)?e.isMatchedWithFilter(t)&&e.properties(t):e.properties(t)}catch(e){sa.log('execute registerPropertyPlugin callback error:'+e)}}):sa.log('registerPropertyPlugin arguments error, isMatchedWithFilter must be function'):sa.log('registerPropertyPlugin arguments error, properties must be function')};var hasOwnProperty$1=Object.prototype.hasOwnProperty,store={inited:!0,storageInfo:null,store_queue:[],getStorage:function(){return this.storageInfo?this.storageInfo:(this.storageInfo=sa.system_api.getStorageSync(sa.storageName)||'',this.storageInfo)},_state:{},toState:function(e){var t=null,n=this;function s(){t.distinct_id?n._state=t:n.set('distinct_id',getUUID())}isJSONString(e)?(t=JSON.parse(e),s()):isObject(e)?(t=e,s()):this.set('distinct_id',getUUID());var r=this._state._first_id||this._state.first_id,a=this._state._distinct_id||this._state.distinct_id,i=(this._state.history_login_id?this._state.history_login_id:{}).name;if(this._state.identities&&isString(this._state.identities)){var o=JSON.parse(rot13defs(this._state.identities));this._state.identities=o}function c(e){for(var t in store._state.identities)hasOwnProperty$1.call(store._state.identities,t)&&t!==IDENTITIES.identity_id&&t!==e&&delete store._state.identities[t]}this._state.identities&&isObject(this._state.identities)&&!isEmptyObject(this._state.identities)||(this._state.identities={},this._state.identities[IDENTITIES.identity_id]=getUUID()),r?i&&hasOwnProperty$1.call(this._state.identities,i)?this._state.identities[i]!==a&&(this._state.identities[i]=a,c(i),this._state.history_login_id.value=a):(this._state.identities[IDENTITY_KEY.LOGIN]=a,c(IDENTITY_KEY.LOGIN),this._state.history_login_id={name:IDENTITY_KEY.LOGIN,value:a}):this._state.history_login_id={name:'',value:''},this.save()},getFirstId:function(){return this._state._first_id||this._state.first_id},getDistinctId:function(){var e=this.getLoginDistinctId();return e||(this._state._distinct_id||this._state.distinct_id)},getUnionId:function(){var e={},t=this._state._first_id||this._state.first_id,n=this.getDistinctId();return t&&n?(e.login_id=n,e.anonymous_id=t):e.anonymous_id=n,e},getHistoryLoginId:function(){return isObject(this._state.history_login_id)?this._state.history_login_id:null},getLoginDistinctId:function(){var e=this.getHistoryLoginId();return isObject(e)&&e.value?e.name!==IDENTITY_KEY.LOGIN?e.name+'+'+e.value:e.value:null},getProps:function(){return this._state.props||{}},setProps:function(e,t){var n=this._state.props||{};t?this.set('props',e):(extend(n,e),this.set('props',n))},set:function(e,t){var n={};for(var s in'string'==typeof e?n[e]=t:'object'==typeof e&&(n=e),this._state=this._state||{},n)this._state[s]=n[s],'first_id'===s?delete this._state._first_id:'distinct_id'===s&&(delete this._state._distinct_id,sa.events.emit('changeDistinctId'));this.save()},identitiesSet:function(e){var t={};switch(e.type){case'login':t[IDENTITIES.identity_id]=this._state.identities[IDENTITIES.identity_id],t[e.id_name]=e.id;break;case'logout':t[IDENTITIES.identity_id]=this._state.identities[IDENTITIES.identity_id]}this.set('identities',t)},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.system_api.setStorageSync(sa.storageName,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.system_api.setStorageSync(sa.storageName,e)},init:function(){var e=this.getStorage(),t=getUUID();if(e)isString(e)&&-1!==e.indexOf("data:enc;")&&(e=e.substring("data:enc;".length),e=JSON.parse(rot13defs(e))),this.toState(e);else{meta.is_first_launch=!0;var n=new Date,s=n.getTime();n.setHours(23),n.setMinutes(59),n.setSeconds(60),this.set({distinct_id:t,first_visit_time:s,first_visit_day_time:n.getTime(),identities:{[IDENTITIES.identity_id]:t},history_login_id:{name:'',value:''}}),sa.setOnceProfile({$first_visit_time:n})}this.checkStoreInit&&this.checkStoreInit()}};function identify(e,t){if(e=_.validId(e)){var n=store.getFirstId();!0===t?n?store.set('first_id',e):store.set('distinct_id',e):n?store.change('first_id',e):store.change('distinct_id',e)}}function trackSignup(e,t,n){var s,r,a,i;_.isObject(e)?(s=e.id,r=e.event_name,a=e.id_name):(s=e,r=t),store.set('distinct_id',s),i=a&&a!==IDENTITY_KEY.LOGIN?a+'+'+s:s;var o=store.getFirstId()||store.getDistinctId();sa.prepareData({original_id:o,distinct_id:i,type:'track_signup',event:r,properties:n})}function bindWithoutCheck(e,t){store._state.identities[e]=t,store.save(),sa.prepareData({type:'track_id_bind',event:'$BindID'})}function bind$1(e,t){var n='';if(_.isNumber(t)){if(_.isInteger(t)&&!1===_.isSafeInteger(t))return sa.log('Value must be String'),!1;t=String(t)}if(!_.isString(e))return sa.log('Key must be String'),!1;var s=store.getHistoryLoginId(),r=s?s.name:'',a=[IDENTITY_KEY.LOGIN,r];return _.isArray(IDENTITIES.bind_preset_id)&&(a=[IDENTITY_KEY.LOGIN,r].concat(IDENTITIES.bind_preset_id)),!_.check.checkKeyword(e)||_.isPresetIdKeys(e,a)?(n='Key ['+e+'] is invalid',sa.log(n),!1):t&&''!==t?_.isString(t)?!!_.check.checkIdLength(t)&&void bindWithoutCheck(e,t):(sa.log('Value must be String'),!1):(sa.log('Value is empty or null'),!1)}function unbindWithoutCheck(e,t){hasOwnProperty.call(store._state.identities,e)&&t===store._state.identities[e]&&(IDENTITIES.unbind_without_check&&IDENTITIES.unbind_without_check.indexOf(e)<0&&delete store._state.identities[e],store.save());var n=store.getDistinctId(),s=store.getFirstId();n===e+'+'+t&&(store.set('first_id',''),store.set('distinct_id',s),store.set('history_login_id',{name:'',value:''}));var r={};r[e]=t,sa.prepareData({type:'track_id_unbind',event:'$UnbindID',unbind_value:r})}function unbind(e,t){var n='';if(_.isNumber(t)){if(_.isInteger(t)&&!1===_.isSafeInteger(t))return sa.log('Value must be String'),!1;t=String(t)}return _.isString(e)?!_.check.checkKeyword(e)||_.isPresetIdKeys(e,[IDENTITY_KEY.LOGIN])?(n='Key ['+e+'] is invalid',sa.log(n),!1):t&&''!==t?_.isString(t)?!!_.check.checkIdLength(t)&&void unbindWithoutCheck(e,t):(sa.log('Value must be String'),!1):(sa.log('Value is empty or null'),!1):(sa.log('Key must be String'),!1)}function loginWithKey(e,t){if(!_.isString(e))return sa.log('Key must be String'),!1;var n='';if(!_.check.checkKeyword(e)&&e.length>100)n='Key ['+e+'] is invalid',sa.log(n);else if(!_.check.checkKeyword(e))return n='Key ['+e+'] is invalid',sa.log(n),!1;if(_.isPresetIdKeys(e,IDENTITIES.login_preset_id))return n='Key ['+e+'] is invalid',sa.log(n),!1;if(!(t=_.validId(t)))return!1;if(_.isSameAndAnonymousID(t))return!1;var s=store.getFirstId(),r=store.getDistinctId();_.isNewLoginId(e,t)&&(store._state.identities[e]=t,store.set('history_login_id',{name:e,value:t}),s||store.set('first_id',r),sa.trackSignup({id:t,event_name:'$SignUp',id_name:e}),store.identitiesSet({type:'login',id:t,id_name:e}))}function login(e){if(!(e=_.validId(e)))return!1;if(_.isSameAndAnonymousID(e))return!1;var t=store.getFirstId(),n=store.getDistinctId(),s=IDENTITY_KEY.LOGIN;_.isNewLoginId(s,e)&&(store._state.identities&&(store._state.identities[s]=e),store.set('history_login_id',{name:s,value:e}),t||store.set('first_id',n),sa.trackSignup({id:e,event_name:'$SignUp'}),store.identitiesSet({type:'login',id:e,id_name:s}))}function logout(){var e=store.getFirstId();store.identitiesSet({type:'logout'}),store.set('history_login_id',{name:'',value:''}),e?(store.set('first_id',''),store.set('distinct_id',e)):sa.log('\u6ca1\u6709first_id\uff0clogout\u5931\u8d25')}function bindOpenid(e){if(!(e=_.validId(e)))return!1;bind$1(_.getOpenidNameByAppid(IDENTITIES.openid_name),e)}function unbindOpenid(e){if(!_.validId(e))return!1;unbind(_.getOpenidNameByAppid(IDENTITIES.openid_name),e)}sa.store=store;var functions=Object.freeze({__proto__:null,identify:identify,trackSignup:trackSignup,bindWithoutCheck:bindWithoutCheck,bind:bind$1,unbindWithoutCheck:unbindWithoutCheck,unbind:unbind,loginWithKey:loginWithKey,login:login,logout:logout,bindOpenid:bindOpenid,unbindOpenid:unbindOpenid});for(var f in functions)sa[f]=functions[f];function buildPara(e){return!(!e||!isObject(e))&&(sa.setPara(e),!!e.server_url||(sa.log('error: server_url is empty'),!1))}function isValidListener(e){return'function'==typeof e||!(!e||'object'!=typeof e)&&isValidListener(e.listener)}sa.identify=function(){},sa.unsetOpenid=function(e){if(!_.validId(e))return!1;var t=_.getOpenidNameByAppid('taobao');sa.unbind(t,e)},sa.setOpenid=function(e){if(!(e=_.validId(e)))return!1;var t=_.getOpenidNameByAppid('taobao');sa.bind(t,e)},sa.setPara=function(e){sa.para=extend2Lev(sa.para,e);var t=[];if(isArray(sa.para.source_channel))for(var n=sa.para.source_channel.length,s=0;s0&&this.cacheEvents.forEach(function(n){n.type===e&&t.call(null,n.data)})}emit(e,t){super.emit.apply(this,arguments),this.cacheEvents.push({type:e,data:t}),this.cacheEvents.length>this.maxLen&&this.cacheEvents.shift()}}var ee={};ee.sdk=new EventEmitterEx,ee.data=new EventEmitterEx;var eventEmitter=function(){this.sub=[]};eventEmitter.prototype={add:function(e){this.sub.push(e)},emit:function(e,t){this.sub.forEach(function(n){n.on(e,t)})}};var 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){sa.log(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){sa.log(e)}})}},sa.ee=ee,sa.eventSub=eventSub,sa.events=new eventEmitter,sa.meta=meta,sa.kit=kit,sa.modules={},sa.init=function(e){if(!0===meta.hasExeInit)return!1;meta.hasExeInit=!0,ee.sdk.emit('beforeInit'),buildPara(e),ee.sdk.emit('initPara'),ee.sdk.emit('afterInitPara'),sa.store.init(),sa.system.init(),ee.sdk.emit('initAPI'),ee.sdk.emit('afterInitAPI'),ee.sdk.emit('afterInit'),ee.sdk.emit('ready'),sa.para.batch_send&&(sa.system_api.getStorage('sensors_prepare_data',function(e){var t=[];e&&e.data&&isArray(e.data)&&(t=e.data,sa.batch_state.mem=t.concat(sa.batch_state.mem)),sa.batch_state.syncStorage=!0,onAppHide()}),batchInterval())};const forEach$1=Array.prototype.forEach,slice$1=Array.prototype.slice,_hasOwnProperty$1=Object.prototype.hasOwnProperty,_toString$1=Object.prototype.toString;function extend$1(e){return each$1(slice$1.call(arguments,1),function(t){for(var n in t)void 0!==t[n]&&(e[n]=t[n])}),e}function isObject$1(e){return null!==e&&'object'==typeof e}function isFunction$1(e){if(!e)return!1;var t=Object.prototype.toString.call(e);return'[object Function]'==t||'[object AsyncFunction]'==t||'[object GeneratorFunction]'==t}function isString$1(e){return'[object String]'==_toString$1.call(e)}function each$1(e,t,n){if(null==e)return!1;if(forEach$1&&e.forEach===forEach$1)e.forEach(t,n);else if(e.length===+e.length){for(var s=0,r=e.length;s0&&(t-s)/36e5<24&&(n.event_duration=(t-s)/1e3),global.sensors.para&&global.sensors.para.autoTrack&&global.sensors.para.autoTrack.appHide&&global.sensors.track('$MPHide',n)}lifeCycleHook.forEach(function(e){miniLifeCycleAPI[e]=function(){throw new Error(`\u9700\u8981\u5148\u5b9a\u4e49 '${e}' \u624d\u80fd\u4f7f\u7528`)}});var presetEvents={appLaunch:!0,appShow:!0,appHide:!0},AutoTrackApp={name:'AutoTrackApp'};function getMixedQuery$1(e){var t={};if(e&&global.sensors._.isObject(e.query)&&(t=global.sensors._.extend({},e.query),e.query.qrCode&&global.sensors._.extend(t,global.sensors._.getObjFromQuery(global.sensors._.decodeURIComponent(e.query.qrCode)))),e&&global.sensors._.isObject(e.referrerInfo)&&e.referrerInfo.extraData){var n={};global.sensors._.isObject(e.referrerInfo.extraData)&&!global.sensors._.isEmptyObject(e.referrerInfo.extraData)?n=e.referrerInfo.extraData:global.sensors._.isJSONString(e.referrerInfo.extraData)&&(n=JSON.parse(e.referrerInfo.extraData)),global.sensors._.extend(t,n)}return t}function setUtm$1(e,t){var n={},s=getMixedQuery$1(e),r=global.sensors._.getCustomUtmFromQuery(s,'$','_','$'),a=global.sensors._.getCustomUtmFromQuery(s,'$latest_','_latest_','$latest_');return n.pre1=r,n.pre2=a,global.sensors._.extend(t,r),n}function appOnLaunch$1(e,t){if(isObject$1(e)){var n={};if(e&&e.path&&extend$1(n,global.sensors._.getAppProps(e)),e&&e.scene){var s=getScene(e.scene,global.sensors);s&&(n.$scene=s,global.sensors.meta.current_scene=s,global.sensors.registerApp({$latest_scene:s}))}else n.$scene='\u672a\u53d6\u5230\u503c';var r=global.sensors.para&&global.sensors.para.autoTrack&&global.sensors.para.autoTrack.appLaunch,a=setUtm$1(e,n);global.sensors.meta.is_first_launch?(n.$is_first_time=!0,global.sensors._.isEmptyObject(a.pre1)||r&&global.sensors.setOnceProfile(a.pre1)):n.$is_first_time=!1,global.sensors._.isEmptyObject(a.pre2)||global.sensors._.setLatestChannel(a.pre2),n.$url_query=global.sensors._.setQuery(e.query),isObject$1(t)&&(n=extend$1(n,t)),r&&global.sensors.track('$MPLaunch',n)}else global.sensors.log('appOnLaunch:\u8bf7\u4f20\u5165\u6b63\u786e\u7684\u53c2\u6570')}function appOnShow$1(e,t){var n={};global.sensors.meta.mp_show_time=(new Date).getTime(),e&&e.path&&extend$1(n,global.sensors._.getAppProps(e));var s=setUtm$1(e,n);if(global.sensors._.isEmptyObject(s.pre2)||global.sensors._.setLatestChannel(s.pre2),e&&e.scene){var r=getScene(e.scene,global.sensors);r&&(n.$scene=r,global.sensors.registerApp({$latest_scene:r}))}isObject$1(t)&&(n=extend$1(n,t)),global.sensors.para&&global.sensors.para.autoTrack&&global.sensors.para.autoTrack.appShow&&global.sensors.track('$MPShow',n)}AutoTrackApp.init=function(e,t){if(!e)return console.log('\u8bf7\u6b63\u786e\u521d\u59cb\u5316 sensorsdata\uff0c\u624d\u80fd\u4f7f\u7528\u63d2\u4ef6'),!1;global.sensors=e,global.sensors.para.autoTrack=extend$1(presetEvents,t),AutoTrackApp.lifeCycleAPI(),AutoTrackApp.proxyFrameworkInterface()},AutoTrackApp.lifeCycleAPI=function(){var e={};e.appOnLaunch=appOnLaunch,e.appOnShow=appOnShow,e.appOnHide=appOnHide,registerLifeCycleHook(e)},AutoTrackApp.proxyFrameworkInterface=function(){proxyApp(hookAppFunc,global.sensors)},AutoTrackApp.lifeCycleAPI=function(){var e={};e.appOnLaunch=appOnLaunch$1,e.appOnShow=appOnShow$1,e.appOnHide=appOnHide,registerLifeCycleHook(e)};var global$1={};function getCurrentPath$1(e){var t='\u672a\u53d6\u5230',n=getCurrentPage$1(e);return n&&n.route&&(t=n.route),t}function getCurrentPage$1(e){var t,n={};if(e)try{n=(t=isFunction$1(e.platform_obj.getCurrentPages)?e.platform_obj.getCurrentPages():getCurrentPages())[t.length-1]}catch(t){e.log(t)}else console.log('getCurrentPage:\u8bf7\u4f20\u5165 sa \u5bf9\u8c61');return n}function isClick(e){return!!{tap:1,longtap:1,longpress:1}[e]}function createClickData(e){var t={},n={},s=e.currentTarget||{},r=s.dataset||{};return t.$element_id=s.id,t.$element_type=r.type,t.$element_content=r.content,t.$element_name=r.name,isObject$1(e.event_prop)&&(n=e.event_prop),t.$url_path=getCurrentPath$1(global$1.sensors),t.$url=global$1.sensors._.getPageProps().$url,t=extend$1(t,n)}var ClickTrack={track:function(e){var t=createClickData(e),n=e.currentTarget||{},s=e.target||{},r=e.type,a=global$1.sensors.para;if(isObject$1(a.framework)&&isObject$1(a.framework.taro)&&!a.framework.taro.createApp&&s.id&&n.id&&s.id!==n.id)return!1;if(isObject$1(t)&&r&&isClick(r)){if(a.preset_events&&a.preset_events.collect_element&&!1===a.preset_events.collect_element(arguments[0]))return!1;global$1.sensors.track('$MPClick',t)}}},MP_HOOKS={data:1,onLoad:1,onShow:1,onReady:1,onPullDownRefresh:1,onReachBottom:1,onShareAppMessage:1,onPageScroll:1,onResize:1,onTabItemTap:1,onHide:1,onUnload:1};function clickProxy(e,t){var n=e[t];e[t]=function(){var e=n.apply(this,arguments),t=arguments[0];return isObject$1(t)&&ClickTrack.track(t),e}}function monitorClick(e){var t=[],n=global$1.sensors.para.autoTrack;if(n&&n.mpClick){t=getMethods(e),tabProxy(e);for(var s=t.length,r=0;r=0&&''!==t){var n={},s=(Date.now()-global$1.sensors.meta.page_show_time)/1e3;(isNaN(s)||s<0)&&(s=0),extend$1(n,global$1.sensors._.getPageProps()),n.event_duration=s,global$1.sensors.track('$MPPageLeave',n),global$1.sensors.meta.page_show_time=-1}}};function pageOnLoad(e){var t=this;if(global$1.sensors._.isObject(e)){try{t=getCurrentPage$1(global$1.sensors)}catch(e){global$1.sensors.log('pageOnLoad:'+e)}t.sensors_mp_url_query=global$1.sensors._.setQuery(e),t.sensors_mp_encode_url_query=global$1.sensors._.setQuery(e,!0)}}function pageOnShow(){global$1.sensors.meta.page_show_time=Date.now();var e={},t='';try{var n=getCurrentPage$1(global$1.sensors);t=n?n.route:''}catch(e){global$1.sensors.log('pageOnShow:'+e)}extend$1(e,global$1.sensors._.getPageProps()),e.$referrer=global$1.sensors.meta.sa_referrer,global$1.sensors.para&&global$1.sensors.para.autoTrack&&global$1.sensors.para.autoTrack.pageShow&&global$1.sensors.track('$MPViewScreen',e),global$1.sensors.meta.sa_referrer=t}function pageOnUnload(){pageLeave()}function pageOnHide(){pageLeave()}var presetEvents$1={pageShow:!0,mpClick:!0,pageLeave:!1},AutoTrackPage={name:'AutoTrackPage',init:function(e,t){if(!e)return console.log('\u8bf7\u6b63\u786e\u521d\u59cb\u5316 sensorsdata\uff0c\u624d\u80fd\u4f7f\u7528\u63d2\u4ef6'),!1;global$1.sensors=e,global$1.sensors.para.autoTrack=extend$1(presetEvents$1,t),AutoTrackPage.lifeCycleAPI(),AutoTrackPage.proxyFrameworkInterface()},lifeCycleAPI:function(){var e={};e.pageOnShow=pageOnShow,e.pageOnLoad=pageOnLoad,e.pageOnUnload=pageOnUnload,e.pageOnHide=pageOnHide,registerLifeCycleHook(e)},proxyFrameworkInterface:function(){proxyPage(hookPageFunc,monitorClick)}},presetEvents$2={appLaunch:!0,appShow:!0,appHide:!0,pageShow:!0,mpClick:!0,pageLeave:!1},AutoTrack={name:'AutoTrack',init:function(e,t){if(!e)return console.log('\u8bf7\u6b63\u786e\u521d\u59cb\u5316 sensorsdata\uff0c\u624d\u80fd\u4f7f\u7528\u63d2\u4ef6'),!1;e.ee.sdk.on('afterInitPara',function(){var n=extend$1(presetEvents$2,e.para.autoTrack,t);e.use(AutoTrackApp,n),e.use(AutoTrackPage,n)})}};sa.platform_obj=my,sa._=_,sa.system=system,sa.system_api=Object.assign(compose,compose$1),sa.lib.name='TaobaoMini',sa.properties.$lib='TaobaoMini',sa.storageName='sensorsdata2015_tb',sa.meta.scene_prefix='tb-',sa.properties.$data_ingestion_source=['TaobaoMini'],sa.properties.$mp_client_basic_library_version=my.SDKVersion||'',sa.use(AutoTrack);export default sa; \ No newline at end of file +var sa={is_first_launch:!1,launched:!1,_queue:[],mpshow_time:null,sa_referrer:'\u76f4\u63a5\u6253\u5f00',query_share_depth:0,share_distinct_id:'',share_method:'',current_scene:'',inited:!1,para:{server_url:'',send_timeout:1e3,show_log:!1,allow_amend_share_path:!0,max_string_length:500,datasend_timeout:3e3,source_channel:[],batch_send:{send_timeout:6e3,max_length:6},preset_properties:{}},platform:'',lib:{version:'0.13.5',name:'MiniGame',method:'code'},properties:{$lib:'MiniGame',$lib_version:'0.13.5'},currentProps:{}};const _toString=Object.prototype.toString,_hasOwnProperty=Object.prototype.hasOwnProperty,indexOf=Array.prototype.indexOf,slice=Array.prototype.slice,_isArray=Array.prototype.isArray,forEach=Array.prototype.forEach,bind=Function.prototype.bind;function isUndefined(e){return void 0===e}function isString(e){return'[object String]'==_toString.call(e)}function isDate(e){return'[object Date]'==_toString.call(e)}function isBoolean(e){return'[object Boolean]'==_toString.call(e)}function isNumber(e){return'[object Number]'==_toString.call(e)&&/[\d\\.]+/.test(String(e))}function isJSONString(e){try{JSON.parse(e)}catch(e){return!1}return!0}function isObject(e){return null!=e&&'[object Object]'===_toString.call(e)}function isPlainObject(e){return'[object Object]'===_toString.call(e)}function isArray(e){return _isArray||'[object Array]'===_toString.call(e)}function isFuction(e){try{return/^\s*\bfunction\b/.test(e)}catch(e){return!1}}function isArguments(e){return!(!e||!_hasOwnProperty.call(e,'callee'))}function toString(e){return null==e?'':isArray(e)||isPlainObject(e)&&e.toString===_toString?JSON.stringify(e,null,2):String(e)}function each(e,t,n){if(null==e)return!1;if(forEach&&e.forEach===forEach)e.forEach(t,n);else if(e.length===+e.length){for(var s=0,r=e.length;ssa.para.max_string_length?(sa.log('\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}function searchObjString(e){isObject(e)&&each(e,function(t,n){isObject(t)?searchObjString(e[n]):isString(t)&&(e[n]=formatString(t))})}function encodeDates(e){return each(e,function(t,n){isDate(t)?e[n]=formatDate(t):isObject(t)&&(e[n]=encodeDates(t))}),e}function utf8Encode(e){var t,n,s,r,a='';for(t=n=0,s=(e=(e+'').replace(/\r\n/g,'\n').replace(/\r/g,'\n')).length,r=0;r127&&i<2048?String.fromCharCode(i>>6|192,63&i|128):String.fromCharCode(i>>12|224,i>>6&63|128,63&i|128),null!==o&&(n>t&&(a+=e.substring(t,n)),a+=o,t=n=r+1)}return n>t&&(a+=e.substring(t,e.length)),a}function base64Encode(e){var t,n,s,r,a,i='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',o=0,c=0,u='',l=[];if(!e)return e;e=utf8Encode(e);do{t=(a=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,n=a>>12&63,s=a>>6&63,r=63&a,l[c++]=i.charAt(t)+i.charAt(n)+i.charAt(s)+i.charAt(r)}while(o255)||(sa.log('id \u957f\u5ea6\u8d85\u8fc7 255 \u4e2a\u5b57\u7b26\uff01'),!1)}};function getOpenidNameByAppid(e){if(''==e||!isString(e))return sa.log('error: \u53c2\u6570\u5fc5\u987b\u662f\u6709\u6548\u503c'),!1;var t=getAppId(),n="$identity_"+e+"_openid";return t&&(n="$identity_"+e+'_'+t+"_openid"),n}function validId(e){return!isString(e)&&!isNumber(e)||''===e?(sa.log('\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef'),!1):isNumber(e)&&(e=String(e),!/^\d+$/.test(e))?(sa.log('\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef'),!1):!!check.checkIdLength(e)&&e}function isNewLoginId(e,t){return e!==sa.store._state.history_login_id.name||sa.store._state.history_login_id.value!==t}function isSameAndAnonymousID(e){var t=sa.store.getFirstId(),n=sa.store.getDistinctId();return t?e===t:e===n}function setUpperCase(e){return isString(e)?e.toLocaleUpperCase():e}function getIsFirstDay(){return!!('object'==typeof sa.store._state&&isNumber(sa.store._state.first_visit_day_time)&&sa.store._state.first_visit_day_time>(new Date).getTime())}function joinUrl(e,t){return!!e&&('\u672a\u53d6\u5230'===e?'\u672a\u53d6\u5230':t?e+'?'+t:e)}function getPath(e){return e=isString(e)?e.replace(/^\//,''):'\u53d6\u503c\u5f02\u5e38'}function getAppProps(e){var t={};return e&&e.path&&(t.$url_path=getPath(e.path),t.$url_query=setQuery(e.query),t.$url=joinUrl(t.$url_path,t.$url_query)),t}function getPageProps(){var e=getCurrentPage(),t=getCurrentPath(),n=e.sensors_mp_url_query||'';return{$url_path:t,$url:joinUrl(t,n),$url_query:n}}function rot13defs(e){return rot13obfs(e=String(e),113)}function rot13obfs(e,t){t='number'==typeof t?t:13;for(var n=(e=String(e)).split(''),s=0,r=n.length;s{sa.system_api.getSystemInfo({success(e){var t=sa.properties;if(isObject(e)){t.$manufacturer=e.brand,t.$model=e.model,t.$brand=setUpperCase(e.brand)||'',t.$screen_width=Number(e.screenWidth),t.$screen_height=Number(e.screenHeight),t.$os=formatSystem(e.platform),t.$os_version=e.system.indexOf(' ')>-1?e.system.split(' ')[1]:e.system,t.$mp_client_app_version=e.version||'';var n=e.SDKVersion||'';n&&(t.$mp_client_basic_library_version=n)}},fail(e){sa.log('\u83b7\u53d6\u7cfb\u7edf\u4fe1\u606f\u5931\u8d25: ',e)},complete(){e()}})})}var system={inited:!1,init:function(){var e=(new Date).getTimezoneOffset();isNumber(e)&&(sa.properties.$timezone_offset=e);var t=getAppId()||sa.para.app_id||sa.para.appid;t&&(sa.properties.$app_id=t),getNetwork(),getSystemInfo$1()}},identity_id='$identity_taobao_uuid';function stripProperties(e){return isObject(e)?(each(e,function(t,n){if(isArray(t)){var s=[];each(t,function(e){if(isString(e))s.push(e);else if(isUndefined(e))s.push('null');else try{s.push(JSON.stringify(e))}catch(e){sa.log('\u60a8\u7684\u6570\u636e - '+n+':'+t+' - \u7684\u6570\u7ec4\u91cc\u7684\u503c\u6709\u9519\u8bef,\u5df2\u7ecf\u5c06\u5176\u5220\u9664')}}),e[n]=s}if(isObject(t))try{e[n]=JSON.stringify(t)}catch(s){delete e[n],sa.log('\u60a8\u7684\u6570\u636e - '+n+':'+t+' - \u7684\u6570\u636e\u503c\u6709\u9519\u8bef,\u5df2\u7ecf\u5c06\u5176\u5220\u9664')}else isString(t)||isNumber(t)||isDate(t)||isBoolean(t)||isArray(t)||(sa.log('\u60a8\u7684\u6570\u636e - ',t,'-\u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664'),delete e[n])}),e):e}function parseSuperProperties(e){isObject(e)&&each(e,function(t,n){if(isFunction(t))try{e[n]=t(),isFunction(e[n])&&(sa.log('\u60a8\u7684\u5c5e\u6027 - '+n+' \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664'),delete e[n])}catch(t){delete e[n],sa.log('\u60a8\u7684\u5c5e\u6027 - '+n+' \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664')}})}function batchRequest(e){if(isArray(e.data)&&e.data.length>0){var t=Date.now(),n=sa.para.datasend_timeout;e.data.forEach(function(e){e._flush_time=t}),e.data=JSON.stringify(e.data);let s={url:sa.para.server_url,method:'POST',dataType:'text',data:'data_list='+encodeURIComponent(base64Encode(e.data)),timeout:n,success:function(){e.success(e.len)},fail:function(){e.fail()}};sa.system_api.request(s)}else e.success(e.len)}function onceSend(e){e._flush_time=Date.now();var t='',n=JSON.stringify(e);t=-1!==sa.para.server_url.indexOf('?')?sa.para.server_url+'&data='+encodeURIComponent(base64Encode(n)):sa.para.server_url+'?data='+encodeURIComponent(base64Encode(n));var s=sa.para.datasend_timeout;sa.system_api.request({url:t,dataType:'text',method:'GET',timeout:s})}IDENTITIES.identity_unionid='',IDENTITIES.identity_id=identity_id,IDENTITIES.openid_name='taobao',IDENTITIES.bind_preset_id=[identity_id],IDENTITIES.unbind_without_check=[identity_id],IDENTITIES.login_preset_id=[identity_id];var kit={batchRequest:batchRequest,onceSend:onceSend};function onAppHide(){isFunction(sa.platform_obj.onAppHide)&&sa.platform_obj.onAppHide(function(){sa.para.batch_send&&batchSend()})}function batchSend(){if(sa.batch_state.sended){var e,t,n=sa.batch_state.mem;(t=(e=n.length>=100?n.slice(0,100):n).length)>0&&(sa.batch_state.sended=!1,kit.batchRequest({data:e,len:t,success:batchRemove,fail:sendFail}))}}function sendFail(){sa.batch_state.sended=!0,sa.batch_state.failTime++}function batchRemove(e){sa.batch_state.clear(e),sa.batch_state.sended=!0,sa.batch_state.changed=!0,batchWrite(),sa.batch_state.failTime=0}function batchWrite(){sa.batch_state.changed&&(sa.batch_state.is_first_batch_write&&(sa.batch_state.is_first_batch_write=!1,setTimeout(function(){batchSend()},1e3)),sa.batch_state.syncStorage&&(sa.system_api.setStorageSync('sensors_prepare_data',sa.batch_state.mem),sa.batch_state.changed=!1))}function batchInterval(){!function e(){setTimeout(function(){batchWrite(),e()},1e3)}(),function e(){setTimeout(function(){batchSend(),e()},sa.para.batch_send.send_timeout*Math.pow(2,sa.batch_state.failTime))}()}function reportEvent(e){var t='';e._flush_time=Date.now(),t=e.event?"sensors_"+e.event:"sensors_"+e.type,e.dataSource='sensors',sa.log('report_event, name: ',t,'-- key: ',e),__mp_private_api__.reportEvent(t,e)}sa.batch_state={mem:[],changed:!1,sended:!0,is_first_batch_write:!0,sync_storage:!1,failTime:0,getLength:function(){return this.mem.length},add:function(e){this.mem.push(e)},clear:function(e){this.mem.splice(0,e)}},sa.batchWrite=batchWrite,sa.prepareData=function(e){var t={distinct_id:sa.store.getDistinctId(),lib:{$lib:sa.lib.name,$lib_method:sa.lib.method,$lib_version:String(sa.lib.version)},properties:{}};if(isObject(sa.store._state.identities)&&(t.identities=extend({},sa.store._state.identities)),'track_id_unbind'===e.type&&'$UnbindID'===e.event&&(t.identities=deepCopy(e.unbind_value),delete e.unbind_value),t=extend(t,sa.store.getUnionId(),e),isObject(e.properties)&&!isEmptyObject(e.properties)&&(t.properties=extend(t.properties,e.properties)),e.type&&'profile'===e.type.slice(0,7)||(t._track_id=Number(String(getRandom()).slice(2,5)+String(getRandom()).slice(2,4)+String(Date.now()).slice(-4)),t.properties=extend({},sa.properties,sa.store.getProps(),sa.currentProps,t.properties),'track'===e.type&&(t.properties.$is_first_day=getIsFirstDay())),t.properties.$time&&isDate(t.properties.$time)?(t.time=1*t.properties.$time,delete t.properties.$time):t.time=1*new Date,sa.ee.data.emit('beforeBuildCheck',t),parseSuperProperties(t.properties),searchObjDate(t),stripProperties(t.properties),searchObjString(t),sa.ee.data.emit('finalAdjustData',t),!sa.para.server_url)return!1;sa.log(t),sa.send(t)},sa.send=function(e){if('sensorsdata2015_binance'===sa.storageName&&'native'===sa.para.data_report_type)return reportEvent(e),!1;sa.para.batch_send?(sa.batch_state.getLength()>=500&&(sa.log('\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38'),sa.batch_state.mem.shift()),sa.batch_state.add(e),sa.batch_state.changed=!0,sa.batch_state.getLength()>=sa.para.batch_send.max_length&&batchSend()):kit.onceSend(e)},sa.log=function(){if(sa.para.show_log&&'object'==typeof console&&console.log)try{var e=Array.prototype.slice.call(arguments);return console.log.apply(console,e)}catch(e){console.log(arguments[0])}},sa.track=function(e,t,n){sa.prepareData({type:'track',event:e,properties:t},n)},sa.setProfile=function(e){sa.prepareData({type:'profile_set',properties:e})},sa.setOnceProfile=function(e,t){sa.prepareData({type:'profile_set_once',properties:e},t)},sa.login=function(e){var t=sa.store.getFirstId(),n=sa.store.getDistinctId();e!==n&&(t?sa.trackSignup(e,'$SignUp'):(sa.store.set('first_id',n),sa.trackSignup(e,'$SignUp')))},sa.logout=function(e){var t=sa.store.getFirstId();t?(sa.store.set('first_id',''),!0===e?sa.store.set('distinct_id',getUUID()):sa.store.set('distinct_id',t)):sa.log('\u6ca1\u6709first_id\uff0clogout\u5931\u8d25')},sa.identify=function(e){if('number'==typeof e)e=String(e);else if('string'!=typeof e)return!1;sa.store.getFirstId()?sa.store.set('first_id',e):sa.store.set('distinct_id',e)},sa.trackSignup=function(e,t,n){var s,r,a,i,o;isObject(e)?(s=e.id,r=e.event_name,a=e.id_name):(s=e,r=t),sa.store.set('distinct_id',s),i=a&&a!==IDENTITY_KEY.LOGIN?a+'+'+s:s,o=sa.store.getFirstId()||sa.store.getDistinctId(),sa.prepareData({original_id:o,distinct_id:i,type:'track_signup',event:r,properties:n})},sa.registerApp=function(e){isObject(e)&&!isEmptyObject(e)&&(sa.currentProps=extend(sa.currentProps,e))},sa.clearAppRegister=function(e){isArray(e)&&each(sa.currentProps,function(t,n){include(e,n)&&delete sa.currentProps[n]})},sa.register=function(e){isObject(e)&&!isEmptyObject(e)&&sa.store.setProps(e)},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.use=function(e){const t=toArray(arguments,1);return t.unshift(this),isObject(e)&&isFunction(e.init)&&e.init.apply(e,t),e},sa.usePlugin=sa.use,sa.getServerUrl=function(){return sa.para.server_url},sa.registerPropertyPlugin=function(e){isFunction(e.properties)?!e.isMatchedWithFilter||isFunction(e.isMatchedWithFilter)?sa.ee.data.on('finalAdjustData',function(t){try{isFunction(e.isMatchedWithFilter)?e.isMatchedWithFilter(t)&&e.properties(t):e.properties(t)}catch(e){sa.log('execute registerPropertyPlugin callback error:'+e)}}):sa.log('registerPropertyPlugin arguments error, isMatchedWithFilter must be function'):sa.log('registerPropertyPlugin arguments error, properties must be function')};var hasOwnProperty$1=Object.prototype.hasOwnProperty,store={inited:!0,storageInfo:null,store_queue:[],getStorage:function(){return this.storageInfo?this.storageInfo:(this.storageInfo=sa.system_api.getStorageSync(sa.storageName)||'',this.storageInfo)},_state:{},toState:function(e){var t=null,n=this;function s(){t.distinct_id?n._state=t:n.set('distinct_id',getUUID())}isJSONString(e)?(t=JSON.parse(e),s()):isObject(e)?(t=e,s()):this.set('distinct_id',getUUID());var r=this._state._first_id||this._state.first_id,a=this._state._distinct_id||this._state.distinct_id,i=(this._state.history_login_id?this._state.history_login_id:{}).name;if(this._state.identities&&isString(this._state.identities)){var o=JSON.parse(rot13defs(this._state.identities));this._state.identities=o}function c(e){for(var t in store._state.identities)hasOwnProperty$1.call(store._state.identities,t)&&t!==IDENTITIES.identity_id&&t!==e&&delete store._state.identities[t]}this._state.identities&&isObject(this._state.identities)&&!isEmptyObject(this._state.identities)||(this._state.identities={},this._state.identities[IDENTITIES.identity_id]=getUUID()),r?i&&hasOwnProperty$1.call(this._state.identities,i)?this._state.identities[i]!==a&&(this._state.identities[i]=a,c(i),this._state.history_login_id.value=a):(this._state.identities[IDENTITY_KEY.LOGIN]=a,c(IDENTITY_KEY.LOGIN),this._state.history_login_id={name:IDENTITY_KEY.LOGIN,value:a}):this._state.history_login_id={name:'',value:''},this.save()},getFirstId:function(){return this._state._first_id||this._state.first_id},getDistinctId:function(){var e=this.getLoginDistinctId();return e||(this._state._distinct_id||this._state.distinct_id)},getUnionId:function(){var e={},t=this._state._first_id||this._state.first_id,n=this.getDistinctId();return t&&n?(e.login_id=n,e.anonymous_id=t):e.anonymous_id=n,e},getHistoryLoginId:function(){return isObject(this._state.history_login_id)?this._state.history_login_id:null},getLoginDistinctId:function(){var e=this.getHistoryLoginId();return isObject(e)&&e.value?e.name!==IDENTITY_KEY.LOGIN?e.name+'+'+e.value:e.value:null},getProps:function(){return this._state.props||{}},setProps:function(e,t){var n=this._state.props||{};t?this.set('props',e):(extend(n,e),this.set('props',n))},set:function(e,t){var n={};for(var s in'string'==typeof e?n[e]=t:'object'==typeof e&&(n=e),this._state=this._state||{},n)this._state[s]=n[s],'first_id'===s?delete this._state._first_id:'distinct_id'===s&&(delete this._state._distinct_id,sa.events.emit('changeDistinctId'));this.save()},identitiesSet:function(e){var t={};switch(e.type){case'login':t[IDENTITIES.identity_id]=this._state.identities[IDENTITIES.identity_id],t[e.id_name]=e.id;break;case'logout':t[IDENTITIES.identity_id]=this._state.identities[IDENTITIES.identity_id]}this.set('identities',t)},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.system_api.setStorageSync(sa.storageName,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.system_api.setStorageSync(sa.storageName,e)},init:function(){var e=this.getStorage(),t=getUUID();if(e)isString(e)&&-1!==e.indexOf("data:enc;")&&(e=e.substring("data:enc;".length),e=JSON.parse(rot13defs(e))),this.toState(e);else{meta.is_first_launch=!0;var n=new Date,s=n.getTime();n.setHours(23),n.setMinutes(59),n.setSeconds(60),this.set({distinct_id:t,first_visit_time:s,first_visit_day_time:n.getTime(),identities:{[IDENTITIES.identity_id]:t},history_login_id:{name:'',value:''}}),sa.setOnceProfile({$first_visit_time:n})}this.checkStoreInit&&this.checkStoreInit()}};function identify(e,t){if(e=_.validId(e)){var n=store.getFirstId();!0===t?n?store.set('first_id',e):store.set('distinct_id',e):n?store.change('first_id',e):store.change('distinct_id',e)}}function trackSignup(e,t,n){var s,r,a,i;_.isObject(e)?(s=e.id,r=e.event_name,a=e.id_name):(s=e,r=t),store.set('distinct_id',s),i=a&&a!==IDENTITY_KEY.LOGIN?a+'+'+s:s;var o=store.getFirstId()||store.getDistinctId();sa.prepareData({original_id:o,distinct_id:i,type:'track_signup',event:r,properties:n})}function bindWithoutCheck(e,t){store._state.identities[e]=t,store.save(),sa.prepareData({type:'track_id_bind',event:'$BindID'})}function bind$1(e,t){var n='';if(_.isNumber(t)){if(_.isInteger(t)&&!1===_.isSafeInteger(t))return sa.log('Value must be String'),!1;t=String(t)}if(!_.isString(e))return sa.log('Key must be String'),!1;var s=store.getHistoryLoginId(),r=s?s.name:'',a=[IDENTITY_KEY.LOGIN,r];return _.isArray(IDENTITIES.bind_preset_id)&&(a=[IDENTITY_KEY.LOGIN,r].concat(IDENTITIES.bind_preset_id)),!_.check.checkKeyword(e)||_.isPresetIdKeys(e,a)?(n='Key ['+e+'] is invalid',sa.log(n),!1):t&&''!==t?_.isString(t)?!!_.check.checkIdLength(t)&&void bindWithoutCheck(e,t):(sa.log('Value must be String'),!1):(sa.log('Value is empty or null'),!1)}function unbindWithoutCheck(e,t){hasOwnProperty.call(store._state.identities,e)&&t===store._state.identities[e]&&(IDENTITIES.unbind_without_check&&IDENTITIES.unbind_without_check.indexOf(e)<0&&delete store._state.identities[e],store.save());var n=store.getDistinctId(),s=store.getFirstId();n===e+'+'+t&&(store.set('first_id',''),store.set('distinct_id',s),store.set('history_login_id',{name:'',value:''}));var r={};r[e]=t,sa.prepareData({type:'track_id_unbind',event:'$UnbindID',unbind_value:r})}function unbind(e,t){var n='';if(_.isNumber(t)){if(_.isInteger(t)&&!1===_.isSafeInteger(t))return sa.log('Value must be String'),!1;t=String(t)}return _.isString(e)?!_.check.checkKeyword(e)||_.isPresetIdKeys(e,[IDENTITY_KEY.LOGIN])?(n='Key ['+e+'] is invalid',sa.log(n),!1):t&&''!==t?_.isString(t)?!!_.check.checkIdLength(t)&&void unbindWithoutCheck(e,t):(sa.log('Value must be String'),!1):(sa.log('Value is empty or null'),!1):(sa.log('Key must be String'),!1)}function loginWithKey(e,t){if(!_.isString(e))return sa.log('Key must be String'),!1;var n='';if(!_.check.checkKeyword(e)&&e.length>100)n='Key ['+e+'] is invalid',sa.log(n);else if(!_.check.checkKeyword(e))return n='Key ['+e+'] is invalid',sa.log(n),!1;if(_.isPresetIdKeys(e,IDENTITIES.login_preset_id))return n='Key ['+e+'] is invalid',sa.log(n),!1;if(!(t=_.validId(t)))return!1;if(_.isSameAndAnonymousID(t))return!1;var s=store.getFirstId(),r=store.getDistinctId();_.isNewLoginId(e,t)&&(store._state.identities[e]=t,store.set('history_login_id',{name:e,value:t}),s||store.set('first_id',r),sa.trackSignup({id:t,event_name:'$SignUp',id_name:e}),store.identitiesSet({type:'login',id:t,id_name:e}))}function login(e){if(!(e=_.validId(e)))return!1;if(_.isSameAndAnonymousID(e))return!1;var t=store.getFirstId(),n=store.getDistinctId(),s=IDENTITY_KEY.LOGIN;_.isNewLoginId(s,e)&&(store._state.identities&&(store._state.identities[s]=e),store.set('history_login_id',{name:s,value:e}),t||store.set('first_id',n),sa.trackSignup({id:e,event_name:'$SignUp'}),store.identitiesSet({type:'login',id:e,id_name:s}))}function logout(){var e=store.getFirstId();store.identitiesSet({type:'logout'}),store.set('history_login_id',{name:'',value:''}),e?(store.set('first_id',''),store.set('distinct_id',e)):sa.log('\u6ca1\u6709first_id\uff0clogout\u5931\u8d25')}function bindOpenid(e){if(!(e=_.validId(e)))return!1;bind$1(_.getOpenidNameByAppid(IDENTITIES.openid_name),e)}function unbindOpenid(e){if(!_.validId(e))return!1;unbind(_.getOpenidNameByAppid(IDENTITIES.openid_name),e)}sa.store=store;var functions=Object.freeze({__proto__:null,identify:identify,trackSignup:trackSignup,bindWithoutCheck:bindWithoutCheck,bind:bind$1,unbindWithoutCheck:unbindWithoutCheck,unbind:unbind,loginWithKey:loginWithKey,login:login,logout:logout,bindOpenid:bindOpenid,unbindOpenid:unbindOpenid});for(var f in functions)sa[f]=functions[f];function buildPara(e){return!(!e||!isObject(e))&&(sa.setPara(e),!!e.server_url||(sa.log('error: server_url is empty'),!1))}function isValidListener(e){return'function'==typeof e||!(!e||'object'!=typeof e)&&isValidListener(e.listener)}sa.identify=function(){},sa.unsetOpenid=function(e){if(!_.validId(e))return!1;var t=_.getOpenidNameByAppid('taobao');sa.unbind(t,e)},sa.setOpenid=function(e){if(!(e=_.validId(e)))return!1;var t=_.getOpenidNameByAppid('taobao');sa.bind(t,e)},sa.setPara=function(e){sa.para=extend2Lev(sa.para,e);var t=[];if(isArray(sa.para.source_channel))for(var n=sa.para.source_channel.length,s=0;s0&&this.cacheEvents.forEach(function(n){n.type===e&&t.call(null,n.data)})}emit(e,t){super.emit.apply(this,arguments),this.cacheEvents.push({type:e,data:t}),this.cacheEvents.length>this.maxLen&&this.cacheEvents.shift()}}var ee={};ee.sdk=new EventEmitterEx,ee.data=new EventEmitterEx;var eventEmitter=function(){this.sub=[]};eventEmitter.prototype={add:function(e){this.sub.push(e)},emit:function(e,t){this.sub.forEach(function(n){n.on(e,t)})}};var 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){sa.log(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){sa.log(e)}})}},sa.ee=ee,sa.eventSub=eventSub,sa.events=new eventEmitter,sa.meta=meta,sa.kit=kit,sa.modules={},sa.init=function(e){if(!0===meta.hasExeInit)return!1;meta.hasExeInit=!0,ee.sdk.emit('beforeInit'),buildPara(e),ee.sdk.emit('initPara'),ee.sdk.emit('afterInitPara'),sa.store.init(),sa.system.init(),ee.sdk.emit('initAPI'),ee.sdk.emit('afterInitAPI'),ee.sdk.emit('afterInit'),ee.sdk.emit('ready'),sa.para.batch_send&&(sa.system_api.getStorage('sensors_prepare_data',function(e){var t=[];e&&e.data&&isArray(e.data)&&(t=e.data,sa.batch_state.mem=t.concat(sa.batch_state.mem)),sa.batch_state.syncStorage=!0,onAppHide()}),batchInterval())};const forEach$1=Array.prototype.forEach,slice$1=Array.prototype.slice,_hasOwnProperty$1=Object.prototype.hasOwnProperty,_toString$1=Object.prototype.toString;function extend$1(e){return each$1(slice$1.call(arguments,1),function(t){for(var n in t)void 0!==t[n]&&(e[n]=t[n])}),e}function isObject$1(e){return null!==e&&'object'==typeof e}function isFunction$1(e){if(!e)return!1;var t=Object.prototype.toString.call(e);return'[object Function]'==t||'[object AsyncFunction]'==t||'[object GeneratorFunction]'==t}function isString$1(e){return'[object String]'==_toString$1.call(e)}function each$1(e,t,n){if(null==e)return!1;if(forEach$1&&e.forEach===forEach$1)e.forEach(t,n);else if(e.length===+e.length){for(var s=0,r=e.length;s0&&(t-s)/36e5<24&&(n.event_duration=(t-s)/1e3),global.sensors.para&&global.sensors.para.autoTrack&&global.sensors.para.autoTrack.appHide&&global.sensors.track('$MPHide',n)}lifeCycleHook.forEach(function(e){miniLifeCycleAPI[e]=function(){throw new Error(`\u9700\u8981\u5148\u5b9a\u4e49 '${e}' \u624d\u80fd\u4f7f\u7528`)}});var presetEvents={appLaunch:!0,appShow:!0,appHide:!0},AutoTrackApp={name:'AutoTrackApp'};function getMixedQuery$1(e){var t={};if(e&&global.sensors._.isObject(e.query)&&(t=global.sensors._.extend({},e.query),e.query.qrCode&&global.sensors._.extend(t,global.sensors._.getObjFromQuery(global.sensors._.decodeURIComponent(e.query.qrCode)))),e&&global.sensors._.isObject(e.referrerInfo)&&e.referrerInfo.extraData){var n={};global.sensors._.isObject(e.referrerInfo.extraData)&&!global.sensors._.isEmptyObject(e.referrerInfo.extraData)?n=e.referrerInfo.extraData:global.sensors._.isJSONString(e.referrerInfo.extraData)&&(n=JSON.parse(e.referrerInfo.extraData)),global.sensors._.extend(t,n)}return t}function setUtm$1(e,t){var n={},s=getMixedQuery$1(e),r=global.sensors._.getCustomUtmFromQuery(s,'$','_','$'),a=global.sensors._.getCustomUtmFromQuery(s,'$latest_','_latest_','$latest_');return n.pre1=r,n.pre2=a,global.sensors._.extend(t,r),n}function appOnLaunch$1(e,t){if(isObject$1(e)){var n={};if(e&&e.path&&extend$1(n,global.sensors._.getAppProps(e)),e&&e.scene){var s=getScene(e.scene,global.sensors);s&&(n.$scene=s,global.sensors.meta.current_scene=s,global.sensors.registerApp({$latest_scene:s}))}else n.$scene='\u672a\u53d6\u5230\u503c';var r=global.sensors.para&&global.sensors.para.autoTrack&&global.sensors.para.autoTrack.appLaunch,a=setUtm$1(e,n);global.sensors.meta.is_first_launch?(n.$is_first_time=!0,global.sensors._.isEmptyObject(a.pre1)||r&&global.sensors.setOnceProfile(a.pre1)):n.$is_first_time=!1,global.sensors._.isEmptyObject(a.pre2)||global.sensors._.setLatestChannel(a.pre2),n.$url_query=global.sensors._.setQuery(e.query),isObject$1(t)&&(n=extend$1(n,t)),r&&global.sensors.track('$MPLaunch',n)}else global.sensors.log('appOnLaunch:\u8bf7\u4f20\u5165\u6b63\u786e\u7684\u53c2\u6570')}function appOnShow$1(e,t){var n={};global.sensors.meta.mp_show_time=(new Date).getTime(),e&&e.path&&extend$1(n,global.sensors._.getAppProps(e));var s=setUtm$1(e,n);if(global.sensors._.isEmptyObject(s.pre2)||global.sensors._.setLatestChannel(s.pre2),e&&e.scene){var r=getScene(e.scene,global.sensors);r&&(n.$scene=r,global.sensors.registerApp({$latest_scene:r}))}isObject$1(t)&&(n=extend$1(n,t)),global.sensors.para&&global.sensors.para.autoTrack&&global.sensors.para.autoTrack.appShow&&global.sensors.track('$MPShow',n)}AutoTrackApp.init=function(e,t){if(!e)return console.log('\u8bf7\u6b63\u786e\u521d\u59cb\u5316 sensorsdata\uff0c\u624d\u80fd\u4f7f\u7528\u63d2\u4ef6'),!1;global.sensors=e,global.sensors.para.autoTrack=extend$1(presetEvents,t),AutoTrackApp.lifeCycleAPI(),AutoTrackApp.proxyFrameworkInterface()},AutoTrackApp.lifeCycleAPI=function(){var e={};e.appOnLaunch=appOnLaunch,e.appOnShow=appOnShow,e.appOnHide=appOnHide,registerLifeCycleHook(e)},AutoTrackApp.proxyFrameworkInterface=function(){proxyApp(hookAppFunc,global.sensors)},AutoTrackApp.lifeCycleAPI=function(){var e={};e.appOnLaunch=appOnLaunch$1,e.appOnShow=appOnShow$1,e.appOnHide=appOnHide,registerLifeCycleHook(e)};var global$1={};function getCurrentPath$1(e){var t='\u672a\u53d6\u5230',n=getCurrentPage$1(e);return n&&n.route&&(t=n.route),t}function getCurrentPage$1(e){var t,n={};if(e)try{n=(t=isFunction$1(e.platform_obj.getCurrentPages)?e.platform_obj.getCurrentPages():getCurrentPages())[t.length-1]}catch(t){e.log(t)}else console.log('getCurrentPage:\u8bf7\u4f20\u5165 sa \u5bf9\u8c61');return n}function isClick(e){return!!{tap:1,longtap:1,longpress:1}[e]}function createClickData(e){var t={},n={},s=e.currentTarget||{},r=s.dataset||{};return t.$element_id=s.id,t.$element_type=r.type,t.$element_content=r.content,t.$element_name=r.name,isObject$1(e.event_prop)&&(n=e.event_prop),t.$url_path=getCurrentPath$1(global$1.sensors),t.$url=global$1.sensors._.getPageProps().$url,t=extend$1(t,n)}var ClickTrack={track:function(e){var t=createClickData(e),n=e.currentTarget||{},s=e.target||{},r=e.type,a=global$1.sensors.para;if(isObject$1(a.framework)&&isObject$1(a.framework.taro)&&!a.framework.taro.createApp&&s.id&&n.id&&s.id!==n.id)return!1;if(isObject$1(t)&&r&&isClick(r)){if(a.preset_events&&a.preset_events.collect_element&&!1===a.preset_events.collect_element(arguments[0]))return!1;global$1.sensors.track('$MPClick',t)}}},MP_HOOKS={data:1,onLoad:1,onShow:1,onReady:1,onPullDownRefresh:1,onReachBottom:1,onShareAppMessage:1,onPageScroll:1,onResize:1,onTabItemTap:1,onHide:1,onUnload:1};function clickProxy(e,t){var n=e[t];e[t]=function(){var e=n.apply(this,arguments),t=arguments[0];return isObject$1(t)&&ClickTrack.track(t),e}}function monitorClick(e){var t=[],n=global$1.sensors.para.autoTrack;if(n&&n.mpClick){t=getMethods(e),tabProxy(e);for(var s=t.length,r=0;r=0&&''!==t){var n={},s=(Date.now()-global$1.sensors.meta.page_show_time)/1e3;(isNaN(s)||s<0)&&(s=0),extend$1(n,global$1.sensors._.getPageProps()),n.event_duration=s,global$1.sensors.track('$MPPageLeave',n),global$1.sensors.meta.page_show_time=-1}}};function pageOnLoad(e){var t=this;if(global$1.sensors._.isObject(e)){try{t=getCurrentPage$1(global$1.sensors)}catch(e){global$1.sensors.log('pageOnLoad:'+e)}t.sensors_mp_url_query=global$1.sensors._.setQuery(e),t.sensors_mp_encode_url_query=global$1.sensors._.setQuery(e,!0)}}function pageOnShow(){global$1.sensors.meta.page_show_time=Date.now();var e={},t='';try{var n=getCurrentPage$1(global$1.sensors);t=n?n.route:''}catch(e){global$1.sensors.log('pageOnShow:'+e)}extend$1(e,global$1.sensors._.getPageProps()),e.$referrer=global$1.sensors.meta.sa_referrer,global$1.sensors.para&&global$1.sensors.para.autoTrack&&global$1.sensors.para.autoTrack.pageShow&&global$1.sensors.track('$MPViewScreen',e),global$1.sensors.meta.sa_referrer=t}function pageOnUnload(){pageLeave()}function pageOnHide(){pageLeave()}var presetEvents$1={pageShow:!0,mpClick:!0,pageLeave:!1},AutoTrackPage={name:'AutoTrackPage',init:function(e,t){if(!e)return console.log('\u8bf7\u6b63\u786e\u521d\u59cb\u5316 sensorsdata\uff0c\u624d\u80fd\u4f7f\u7528\u63d2\u4ef6'),!1;global$1.sensors=e,global$1.sensors.para.autoTrack=extend$1(presetEvents$1,t),AutoTrackPage.lifeCycleAPI(),AutoTrackPage.proxyFrameworkInterface()},lifeCycleAPI:function(){var e={};e.pageOnShow=pageOnShow,e.pageOnLoad=pageOnLoad,e.pageOnUnload=pageOnUnload,e.pageOnHide=pageOnHide,registerLifeCycleHook(e)},proxyFrameworkInterface:function(){proxyPage(hookPageFunc,monitorClick)}},presetEvents$2={appLaunch:!0,appShow:!0,appHide:!0,pageShow:!0,mpClick:!0,pageLeave:!1},AutoTrack={name:'AutoTrack',init:function(e,t){if(!e)return console.log('\u8bf7\u6b63\u786e\u521d\u59cb\u5316 sensorsdata\uff0c\u624d\u80fd\u4f7f\u7528\u63d2\u4ef6'),!1;e.ee.sdk.on('afterInitPara',function(){var n=extend$1(presetEvents$2,e.para.autoTrack,t);e.use(AutoTrackApp,n),e.use(AutoTrackPage,n)})}};sa.platform_obj=my,sa._=_,sa.system=system,sa.system_api=Object.assign(compose,compose$1),sa.lib.name='TaobaoMini',sa.properties.$lib='TaobaoMini',sa.storageName='sensorsdata2015_tb',sa.meta.scene_prefix='tb-',sa.properties.$data_ingestion_source=['TaobaoMini'],sa.properties.$mp_client_basic_library_version=my.SDKVersion||'',sa.use(AutoTrack);export default sa; \ No newline at end of file diff --git a/dist/mp-taobao/plugin/taobao-send-adapter/index.esm.js b/dist/mp-taobao/plugin/taobao-send-adapter/index.esm.js index 8e05d6d..10114f2 100644 --- a/dist/mp-taobao/plugin/taobao-send-adapter/index.esm.js +++ b/dist/mp-taobao/plugin/taobao-send-adapter/index.esm.js @@ -1 +1 @@ -const _toString=Object.prototype.toString,_isArray=Array.prototype.isArray;function isArray(a){return _isArray||'[object Array]'===_toString.call(a)}function utf8Encode(a){var t,n,e,o,c='';for(t=n=0,e=(a=(a+'').replace(/\r\n/g,'\n').replace(/\r/g,'\n')).length,o=0;o127&&s<2048?String.fromCharCode(s>>6|192,63&s|128):String.fromCharCode(s>>12|224,s>>6&63|128,63&s|128),null!==i&&(n>t&&(c+=a.substring(t,n)),c+=i,t=n=o+1)}return n>t&&(c+=a.substring(t,a.length)),c}function base64Encode(a){var t,n,e,o,c,s='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',i=0,r=0,d='',u=[];if(!a)return a;a=utf8Encode(a);do{t=(c=a.charCodeAt(i++)<<16|a.charCodeAt(i++)<<8|a.charCodeAt(i++))>>18&63,n=c>>12&63,e=c>>6&63,o=63&c,u[r++]=s.charAt(t)+s.charAt(n)+s.charAt(e)+s.charAt(o)}while(i{t&&t.success?a.success&&a.success():a.fail&&a.fail()}).catch(t=>{sa.log('\u6570\u636e\u53d1\u9001\u5931\u8d25!'+JSON.stringify(t)),a.fail&&a.fail()}):sa.log('\u8bf7\u6c42\u5931\u8d25!\u5f53\u524d\u5e94\u7528\u4e0d\u652f\u6301\u6dd8\u5b9d\u4e91\u51fd\u6570!')},cloudAppInvoke=function(a){var t;try{t=getApp()}catch(a){console.log(a)}if(t&&t.cloud&&t.cloud.application&&t.cloud.application.httpRequest){var n={path:tbConfig.path,headers:{'Content-Type':'application/json;charset=UTF-8'},exts:sa._.extend({},{cloudAppId:tbConfig.cloudAppId},tbConfig.exts)};if(sa&&sa.para&&sa.para.batch_send)n.method='POST',n.body={data_list:a.data};else{n.method='GET';var e=tbConfig.path,o=e+"?data="+a.data;-1!==e.indexOf('?')&&(o=e+"&data="+a.data),n.path=o}t.cloud.application.httpRequest(n).then(t=>{t&&t.success?a.success&&a.success():a.fail&&a.fail()}).catch(t=>{sa.log('\u6570\u636e\u53d1\u9001\u5931\u8d25!'+JSON.stringify(t)),a.fail&&a.fail()})}else sa.log('\u8bf7\u6c42\u5931\u8d25!\u5f53\u524d\u5e94\u7528\u4e0d\u652f\u6301\u6dd8\u5b9d\u4e91\u5e94\u7528!')},onceSend=function(a){var t=cloudAppInvoke;tbConfig.cloudFuncSend&&(t=cloudFuncInvoke),a._flush_time=Date.now();var n=JSON.stringify(a);t({data:encodeURIComponent(base64Encode(n))})},batchRequest=function(a){var t=cloudAppInvoke;if(tbConfig.cloudFuncSend&&(t=cloudFuncInvoke),isArray(a.data)&&a.data.length>0){var n=Date.now();a.data.forEach(function(a){a._flush_time=n}),a.data=JSON.stringify(a.data),t({data:encodeURIComponent(base64Encode(a.data)),success:function(){a.success(a.len)},fail:function(){a.fail()}})}else a.success(a.len)},TaobaoSendAdapter={name:'TaobaoSendAdapter',init:function(a,t={}){if(!(sa=a))return console.log('\u5f53\u524d\u4e3bsdk \u521d\u59cb\u5316\u5931\u8d25\uff0c\u8bf7\u4f20\u5165\u6b63\u786e\u7684 sensors \u5bf9\u8c61\uff01'),!1;tbConfig=Object.assign(tbConfig,t),sa.kit&&(sa.kit.batchRequest=batchRequest,sa.kit.onceSend=onceSend,sa.para.show_log&&sa.log('[sensorsData]\uff1aTaobaoSendAdapter \u63d2\u4ef6\u521d\u59cb\u5316\u5b8c\u6210\uff01'))}};export default TaobaoSendAdapter; \ No newline at end of file +const _toString=Object.prototype.toString,_isArray=Array.prototype.isArray;function isArray(a){return _isArray||'[object Array]'===_toString.call(a)}function utf8Encode(a){var t,e,n,o,c='';for(t=e=0,n=(a=(a+'').replace(/\r\n/g,'\n').replace(/\r/g,'\n')).length,o=0;o127&&s<2048?String.fromCharCode(s>>6|192,63&s|128):String.fromCharCode(s>>12|224,s>>6&63|128,63&s|128),null!==i&&(e>t&&(c+=a.substring(t,e)),c+=i,t=e=o+1)}return e>t&&(c+=a.substring(t,a.length)),c}function base64Encode(a){var t,e,n,o,c,s='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',i=0,r=0,d='',u=[];if(!a)return a;a=utf8Encode(a);do{t=(c=a.charCodeAt(i++)<<16|a.charCodeAt(i++)<<8|a.charCodeAt(i++))>>18&63,e=c>>12&63,n=c>>6&63,o=63&c,u[r++]=s.charAt(t)+s.charAt(e)+s.charAt(n)+s.charAt(o)}while(i{t&&t.success?a.success&&a.success():a.fail&&a.fail()}).catch(t=>{sa.log('\u6570\u636e\u53d1\u9001\u5931\u8d25!'+JSON.stringify(t)),a.fail&&a.fail()}):sa.log('\u8bf7\u6c42\u5931\u8d25!\u5f53\u524d\u5e94\u7528\u4e0d\u652f\u6301\u6dd8\u5b9d\u4e91\u51fd\u6570!')},cloudAppInvoke=function(a){if(getApp()&&getApp().cloud&&getApp().cloud.application&&getApp().cloud.application.httpRequest){var t={path:tbConfig.path,headers:{'Content-Type':'application/json;charset=UTF-8'},exts:sa._.extend({},{cloudAppId:tbConfig.cloudAppId},tbConfig.exts)};if(sa&&sa.para&&sa.para.batch_send)t.method='POST',t.body={data_list:a.data};else{t.method='GET';var e=tbConfig.path,n=e+"?data="+a.data;-1!==e.indexOf('?')&&(n=e+"&data="+a.data),t.path=n}getApp().cloud.application.httpRequest(t).then(t=>{t&&t.success?a.success&&a.success():a.fail&&a.fail()}).catch(t=>{sa.log('\u6570\u636e\u53d1\u9001\u5931\u8d25!'+JSON.stringify(t)),a.fail&&a.fail()})}else sa.log('\u8bf7\u6c42\u5931\u8d25!\u5f53\u524d\u5e94\u7528\u4e0d\u652f\u6301\u6dd8\u5b9d\u4e91\u5e94\u7528!')},onceSend=function(a){var t=cloudAppInvoke;tbConfig.cloudFuncSend&&(t=cloudFuncInvoke),a._flush_time=Date.now();var e=JSON.stringify(a);t({data:encodeURIComponent(base64Encode(e))})},batchRequest=function(a){var t=cloudAppInvoke;if(tbConfig.cloudFuncSend&&(t=cloudFuncInvoke),isArray(a.data)&&a.data.length>0){var e=Date.now();a.data.forEach(function(a){a._flush_time=e}),a.data=JSON.stringify(a.data),t({data:encodeURIComponent(base64Encode(a.data)),success:function(){a.success(a.len)},fail:function(){a.fail()}})}else a.success(a.len)},TaobaoSendAdapter={name:'TaobaoSendAdapter',init:function(a,t={}){if(!(sa=a))return console.log('\u5f53\u524d\u4e3bsdk \u521d\u59cb\u5316\u5931\u8d25\uff0c\u8bf7\u4f20\u5165\u6b63\u786e\u7684 sensors \u5bf9\u8c61\uff01'),!1;tbConfig=Object.assign(tbConfig,t),sa.kit&&(sa.kit.batchRequest=batchRequest,sa.kit.onceSend=onceSend,sa.para.show_log&&sa.log('[sensorsData]\uff1aTaobaoSendAdapter \u63d2\u4ef6\u521d\u59cb\u5316\u5b8c\u6210\uff01'))}};export default TaobaoSendAdapter; \ No newline at end of file diff --git a/dist/mp-taobao/plugin/taobao-send-adapter/src/index.esm.js b/dist/mp-taobao/plugin/taobao-send-adapter/src/index.esm.js index 8e05d6d..10114f2 100644 --- a/dist/mp-taobao/plugin/taobao-send-adapter/src/index.esm.js +++ b/dist/mp-taobao/plugin/taobao-send-adapter/src/index.esm.js @@ -1 +1 @@ -const _toString=Object.prototype.toString,_isArray=Array.prototype.isArray;function isArray(a){return _isArray||'[object Array]'===_toString.call(a)}function utf8Encode(a){var t,n,e,o,c='';for(t=n=0,e=(a=(a+'').replace(/\r\n/g,'\n').replace(/\r/g,'\n')).length,o=0;o127&&s<2048?String.fromCharCode(s>>6|192,63&s|128):String.fromCharCode(s>>12|224,s>>6&63|128,63&s|128),null!==i&&(n>t&&(c+=a.substring(t,n)),c+=i,t=n=o+1)}return n>t&&(c+=a.substring(t,a.length)),c}function base64Encode(a){var t,n,e,o,c,s='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',i=0,r=0,d='',u=[];if(!a)return a;a=utf8Encode(a);do{t=(c=a.charCodeAt(i++)<<16|a.charCodeAt(i++)<<8|a.charCodeAt(i++))>>18&63,n=c>>12&63,e=c>>6&63,o=63&c,u[r++]=s.charAt(t)+s.charAt(n)+s.charAt(e)+s.charAt(o)}while(i{t&&t.success?a.success&&a.success():a.fail&&a.fail()}).catch(t=>{sa.log('\u6570\u636e\u53d1\u9001\u5931\u8d25!'+JSON.stringify(t)),a.fail&&a.fail()}):sa.log('\u8bf7\u6c42\u5931\u8d25!\u5f53\u524d\u5e94\u7528\u4e0d\u652f\u6301\u6dd8\u5b9d\u4e91\u51fd\u6570!')},cloudAppInvoke=function(a){var t;try{t=getApp()}catch(a){console.log(a)}if(t&&t.cloud&&t.cloud.application&&t.cloud.application.httpRequest){var n={path:tbConfig.path,headers:{'Content-Type':'application/json;charset=UTF-8'},exts:sa._.extend({},{cloudAppId:tbConfig.cloudAppId},tbConfig.exts)};if(sa&&sa.para&&sa.para.batch_send)n.method='POST',n.body={data_list:a.data};else{n.method='GET';var e=tbConfig.path,o=e+"?data="+a.data;-1!==e.indexOf('?')&&(o=e+"&data="+a.data),n.path=o}t.cloud.application.httpRequest(n).then(t=>{t&&t.success?a.success&&a.success():a.fail&&a.fail()}).catch(t=>{sa.log('\u6570\u636e\u53d1\u9001\u5931\u8d25!'+JSON.stringify(t)),a.fail&&a.fail()})}else sa.log('\u8bf7\u6c42\u5931\u8d25!\u5f53\u524d\u5e94\u7528\u4e0d\u652f\u6301\u6dd8\u5b9d\u4e91\u5e94\u7528!')},onceSend=function(a){var t=cloudAppInvoke;tbConfig.cloudFuncSend&&(t=cloudFuncInvoke),a._flush_time=Date.now();var n=JSON.stringify(a);t({data:encodeURIComponent(base64Encode(n))})},batchRequest=function(a){var t=cloudAppInvoke;if(tbConfig.cloudFuncSend&&(t=cloudFuncInvoke),isArray(a.data)&&a.data.length>0){var n=Date.now();a.data.forEach(function(a){a._flush_time=n}),a.data=JSON.stringify(a.data),t({data:encodeURIComponent(base64Encode(a.data)),success:function(){a.success(a.len)},fail:function(){a.fail()}})}else a.success(a.len)},TaobaoSendAdapter={name:'TaobaoSendAdapter',init:function(a,t={}){if(!(sa=a))return console.log('\u5f53\u524d\u4e3bsdk \u521d\u59cb\u5316\u5931\u8d25\uff0c\u8bf7\u4f20\u5165\u6b63\u786e\u7684 sensors \u5bf9\u8c61\uff01'),!1;tbConfig=Object.assign(tbConfig,t),sa.kit&&(sa.kit.batchRequest=batchRequest,sa.kit.onceSend=onceSend,sa.para.show_log&&sa.log('[sensorsData]\uff1aTaobaoSendAdapter \u63d2\u4ef6\u521d\u59cb\u5316\u5b8c\u6210\uff01'))}};export default TaobaoSendAdapter; \ No newline at end of file +const _toString=Object.prototype.toString,_isArray=Array.prototype.isArray;function isArray(a){return _isArray||'[object Array]'===_toString.call(a)}function utf8Encode(a){var t,e,n,o,c='';for(t=e=0,n=(a=(a+'').replace(/\r\n/g,'\n').replace(/\r/g,'\n')).length,o=0;o127&&s<2048?String.fromCharCode(s>>6|192,63&s|128):String.fromCharCode(s>>12|224,s>>6&63|128,63&s|128),null!==i&&(e>t&&(c+=a.substring(t,e)),c+=i,t=e=o+1)}return e>t&&(c+=a.substring(t,a.length)),c}function base64Encode(a){var t,e,n,o,c,s='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=',i=0,r=0,d='',u=[];if(!a)return a;a=utf8Encode(a);do{t=(c=a.charCodeAt(i++)<<16|a.charCodeAt(i++)<<8|a.charCodeAt(i++))>>18&63,e=c>>12&63,n=c>>6&63,o=63&c,u[r++]=s.charAt(t)+s.charAt(e)+s.charAt(n)+s.charAt(o)}while(i{t&&t.success?a.success&&a.success():a.fail&&a.fail()}).catch(t=>{sa.log('\u6570\u636e\u53d1\u9001\u5931\u8d25!'+JSON.stringify(t)),a.fail&&a.fail()}):sa.log('\u8bf7\u6c42\u5931\u8d25!\u5f53\u524d\u5e94\u7528\u4e0d\u652f\u6301\u6dd8\u5b9d\u4e91\u51fd\u6570!')},cloudAppInvoke=function(a){if(getApp()&&getApp().cloud&&getApp().cloud.application&&getApp().cloud.application.httpRequest){var t={path:tbConfig.path,headers:{'Content-Type':'application/json;charset=UTF-8'},exts:sa._.extend({},{cloudAppId:tbConfig.cloudAppId},tbConfig.exts)};if(sa&&sa.para&&sa.para.batch_send)t.method='POST',t.body={data_list:a.data};else{t.method='GET';var e=tbConfig.path,n=e+"?data="+a.data;-1!==e.indexOf('?')&&(n=e+"&data="+a.data),t.path=n}getApp().cloud.application.httpRequest(t).then(t=>{t&&t.success?a.success&&a.success():a.fail&&a.fail()}).catch(t=>{sa.log('\u6570\u636e\u53d1\u9001\u5931\u8d25!'+JSON.stringify(t)),a.fail&&a.fail()})}else sa.log('\u8bf7\u6c42\u5931\u8d25!\u5f53\u524d\u5e94\u7528\u4e0d\u652f\u6301\u6dd8\u5b9d\u4e91\u5e94\u7528!')},onceSend=function(a){var t=cloudAppInvoke;tbConfig.cloudFuncSend&&(t=cloudFuncInvoke),a._flush_time=Date.now();var e=JSON.stringify(a);t({data:encodeURIComponent(base64Encode(e))})},batchRequest=function(a){var t=cloudAppInvoke;if(tbConfig.cloudFuncSend&&(t=cloudFuncInvoke),isArray(a.data)&&a.data.length>0){var e=Date.now();a.data.forEach(function(a){a._flush_time=e}),a.data=JSON.stringify(a.data),t({data:encodeURIComponent(base64Encode(a.data)),success:function(){a.success(a.len)},fail:function(){a.fail()}})}else a.success(a.len)},TaobaoSendAdapter={name:'TaobaoSendAdapter',init:function(a,t={}){if(!(sa=a))return console.log('\u5f53\u524d\u4e3bsdk \u521d\u59cb\u5316\u5931\u8d25\uff0c\u8bf7\u4f20\u5165\u6b63\u786e\u7684 sensors \u5bf9\u8c61\uff01'),!1;tbConfig=Object.assign(tbConfig,t),sa.kit&&(sa.kit.batchRequest=batchRequest,sa.kit.onceSend=onceSend,sa.para.show_log&&sa.log('[sensorsData]\uff1aTaobaoSendAdapter \u63d2\u4ef6\u521d\u59cb\u5316\u5b8c\u6210\uff01'))}};export default TaobaoSendAdapter; \ No newline at end of file diff --git a/package.json b/package.json index dd1d4c8..a2bfe3c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sa-sdk-mini", - "version": "0.13.4", + "version": "0.13.5", "description": "神策小游戏 SDK", "main": "/build/", "scripts": {