diff --git a/CHANGELOG.md b/CHANGELOG.md index b8e0a88..15d4d13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.14.15(2021-07-29) +1. 优化 + - 优化批量发送 300 条限制逻辑 + ## 1.14.14(2021-07-19) 1. 修复 - 修复自定义属性被预置属性覆盖问题 diff --git a/demo/kbone/src/App.vue b/demo/kbone/src/App.vue index 9013049..38cc182 100644 --- a/demo/kbone/src/App.vue +++ b/demo/kbone/src/App.vue @@ -8,7 +8,7 @@ // import sensors from './utils/sensorsdata.es6.full' // sensors.setPara({ // name: 'sensors', -// server_url: 'https://jssdkdata.debugbox.sensorsdata.cn/sa?project=beiyong3', +// server_url: '您的数据接收地址', // // 全埋点控制开关 // autoTrack: { // appLaunch: true, // 默认为 true,false 则关闭 $MPLaunch 事件采集 diff --git a/demo/kbone/src/app.js b/demo/kbone/src/app.js index ba70689..1cc6e2e 100644 --- a/demo/kbone/src/app.js +++ b/demo/kbone/src/app.js @@ -2,7 +2,7 @@ import sensors from 'sa-sdk-miniprogram'; sensors.setPara({ name: 'sensors', - server_url: 'https://jssdkdata.debugbox.sensorsdata.cn/sa?project=beiyong3', + server_url: '您的数据接收地址', // 全埋点控制开关 autoTrack: { appLaunch: true, // 默认为 true,false 则关闭 $MPLaunch 事件采集 diff --git a/demo/mpvue/src/main.js b/demo/mpvue/src/main.js index 7b22138..a17b6e5 100644 --- a/demo/mpvue/src/main.js +++ b/demo/mpvue/src/main.js @@ -5,7 +5,7 @@ import App from './App' sensors.setPara({ name: 'sensors', - server_url: 'https://jssdkdata.debugbox.sensorsdata.cn/sa?project=beiyong3', + server_url: '您的数据接收地址', autoTrack: { mpClick: true }, diff --git a/demo/remax/src/app.js b/demo/remax/src/app.js index a786a57..ba1446c 100644 --- a/demo/remax/src/app.js +++ b/demo/remax/src/app.js @@ -3,7 +3,7 @@ import './app.css'; import sensors from './utils/sensorsdata.min.es6' sensors.setPara({ name: 'sensors', - server_url: 'https://jssdkdata.debugbox.sensorsdata.cn/sa?project=beiyong3', + server_url: '您的数据接收地址', // 全埋点控制开关 autoTrack: { mpClick: true diff --git a/demo/taro/src/app.js b/demo/taro/src/app.js index b606ee1..69413cc 100644 --- a/demo/taro/src/app.js +++ b/demo/taro/src/app.js @@ -5,7 +5,7 @@ import sensors from 'sa-sdk-miniprogram' // SDK初始化配置 sensors.setPara({ name: 'sensors', - server_url: 'https://jssdkdata.debugbox.sensorsdata.cn/sa?project=beiyong3', + server_url: '您的数据接收地址', // 全埋点控制开关 autoTrack: { mpClick: true diff --git a/demo/uni-app/App.vue b/demo/uni-app/App.vue index a291aec..b1a499b 100644 --- a/demo/uni-app/App.vue +++ b/demo/uni-app/App.vue @@ -4,7 +4,7 @@ import sensors from 'sa-sdk-miniprogram' sensors.setPara({ name: 'sensors', - server_url: 'https://jssdkdata.debugbox.sensorsdata.cn/sa?project=beiyong3', + server_url: '您的数据接收地址', // 全埋点控制开关 autoTrack: { mpClick: true, // 默认为 false,true 则开启 $MPClick 事件采集 diff --git a/demo/uni-app/main.js b/demo/uni-app/main.js index 228a946..2bb375c 100644 --- a/demo/uni-app/main.js +++ b/demo/uni-app/main.js @@ -4,7 +4,7 @@ import Vue from 'vue' import sensors from 'sa-sdk-miniprogram' sensors.setPara({ name: 'sensors', - server_url: 'https://jssdkdata.debugbox.sensorsdata.cn/sa?project=beiyong3', + server_url: '您的数据接收地址', // 全埋点控制开关 autoTrack: { mpClick: true, // 默认为 false,true 则开启 $MPClick 事件采集 diff --git a/demo/wepy/src/app.wpy b/demo/wepy/src/app.wpy index fb29167..fa9c668 100644 --- a/demo/wepy/src/app.wpy +++ b/demo/wepy/src/app.wpy @@ -12,7 +12,7 @@ wepy.use(vuex); // SDK 初始化配置 sensors.setPara({ name: 'sensors', - server_url: 'https://jssdkdata.debugbox.sensorsdata.cn/sa?project=beiyong3', + server_url: '您的数据接收地址', autoTrack: { mpClick: true }, diff --git a/package.json b/package.json index 7d4846d..712320c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sa-sdk-miniprogram", - "version": "1.14.14", + "version": "1.14.15", "description": "sensorsdata miniprogram sdk", "main": "sensorsdata.min.js", "scripts": { diff --git a/product/sensorsdata.custom.es6.full.js b/product/sensorsdata.custom.es6.full.js index b8bc5dd..d9949cb 100755 --- a/product/sensorsdata.custom.es6.full.js +++ b/product/sensorsdata.custom.es6.full.js @@ -156,7 +156,7 @@ var ArrayProto = Array.prototype, slice = ArrayProto.slice, toString = ObjProto.toString, hasOwnProperty = ObjProto.hasOwnProperty, - LIB_VERSION = '1.14.14', + LIB_VERSION = '1.14.15', LIB_NAME = 'MiniProgram'; var source_channel_standard = 'utm_source utm_medium utm_campaign utm_content utm_term'; @@ -1834,9 +1834,9 @@ sa.sendStrategy = { } if (sa.para.batch_send) { this.dataHasChange = true; - if (sa.store.mem.getLength() >= 300) { + if (sa.store.mem.getLength() >= 500) { logger.info('数据量存储过大,有异常'); - return false; + sa.store.mem.mdata.shift(); } sa.store.mem.add(data); if (sa.store.mem.getLength() >= sa.para.batch_send.max_length) { @@ -1888,8 +1888,15 @@ sa.sendStrategy = { }, batchSend: function() { if (this.dataHasSend) { - var data = sa.store.mem.mdata; - var len = data.length; + var data, + len, + mdata = sa.store.mem.mdata; + if (mdata.length >= 100) { + data = mdata.slice(0, 100); + } else { + data = mdata; + } + len = data.length; if (len > 0) { this.dataHasSend = false; this.wxrequest({ diff --git a/product/sensorsdata.custom.full.js b/product/sensorsdata.custom.full.js index cc99e98..2d91a4b 100755 --- a/product/sensorsdata.custom.full.js +++ b/product/sensorsdata.custom.full.js @@ -156,7 +156,7 @@ var ArrayProto = Array.prototype, slice = ArrayProto.slice, toString = ObjProto.toString, hasOwnProperty = ObjProto.hasOwnProperty, - LIB_VERSION = '1.14.14', + LIB_VERSION = '1.14.15', LIB_NAME = 'MiniProgram'; var source_channel_standard = 'utm_source utm_medium utm_campaign utm_content utm_term'; @@ -1834,9 +1834,9 @@ sa.sendStrategy = { } if (sa.para.batch_send) { this.dataHasChange = true; - if (sa.store.mem.getLength() >= 300) { + if (sa.store.mem.getLength() >= 500) { logger.info('数据量存储过大,有异常'); - return false; + sa.store.mem.mdata.shift(); } sa.store.mem.add(data); if (sa.store.mem.getLength() >= sa.para.batch_send.max_length) { @@ -1888,8 +1888,15 @@ sa.sendStrategy = { }, batchSend: function() { if (this.dataHasSend) { - var data = sa.store.mem.mdata; - var len = data.length; + var data, + len, + mdata = sa.store.mem.mdata; + if (mdata.length >= 100) { + data = mdata.slice(0, 100); + } else { + data = mdata; + } + len = data.length; if (len > 0) { this.dataHasSend = false; this.wxrequest({ diff --git a/product/sensorsdata.es6.full.js b/product/sensorsdata.es6.full.js index 85d1122..d25b638 100755 --- a/product/sensorsdata.es6.full.js +++ b/product/sensorsdata.es6.full.js @@ -156,7 +156,7 @@ var ArrayProto = Array.prototype, slice = ArrayProto.slice, toString = ObjProto.toString, hasOwnProperty = ObjProto.hasOwnProperty, - LIB_VERSION = '1.14.14', + LIB_VERSION = '1.14.15', LIB_NAME = 'MiniProgram'; var source_channel_standard = 'utm_source utm_medium utm_campaign utm_content utm_term'; @@ -1834,9 +1834,9 @@ sa.sendStrategy = { } if (sa.para.batch_send) { this.dataHasChange = true; - if (sa.store.mem.getLength() >= 300) { + if (sa.store.mem.getLength() >= 500) { logger.info('数据量存储过大,有异常'); - return false; + sa.store.mem.mdata.shift(); } sa.store.mem.add(data); if (sa.store.mem.getLength() >= sa.para.batch_send.max_length) { @@ -1888,8 +1888,15 @@ sa.sendStrategy = { }, batchSend: function() { if (this.dataHasSend) { - var data = sa.store.mem.mdata; - var len = data.length; + var data, + len, + mdata = sa.store.mem.mdata; + if (mdata.length >= 100) { + data = mdata.slice(0, 100); + } else { + data = mdata; + } + len = data.length; if (len > 0) { this.dataHasSend = false; this.wxrequest({ diff --git a/product/sensorsdata.full.js b/product/sensorsdata.full.js index 5b3caa0..3b00aca 100755 --- a/product/sensorsdata.full.js +++ b/product/sensorsdata.full.js @@ -156,7 +156,7 @@ var ArrayProto = Array.prototype, slice = ArrayProto.slice, toString = ObjProto.toString, hasOwnProperty = ObjProto.hasOwnProperty, - LIB_VERSION = '1.14.14', + LIB_VERSION = '1.14.15', LIB_NAME = 'MiniProgram'; var source_channel_standard = 'utm_source utm_medium utm_campaign utm_content utm_term'; @@ -1834,9 +1834,9 @@ sa.sendStrategy = { } if (sa.para.batch_send) { this.dataHasChange = true; - if (sa.store.mem.getLength() >= 300) { + if (sa.store.mem.getLength() >= 500) { logger.info('数据量存储过大,有异常'); - return false; + sa.store.mem.mdata.shift(); } sa.store.mem.add(data); if (sa.store.mem.getLength() >= sa.para.batch_send.max_length) { @@ -1888,8 +1888,15 @@ sa.sendStrategy = { }, batchSend: function() { if (this.dataHasSend) { - var data = sa.store.mem.mdata; - var len = data.length; + var data, + len, + mdata = sa.store.mem.mdata; + if (mdata.length >= 100) { + data = mdata.slice(0, 100); + } else { + data = mdata; + } + len = data.length; if (len > 0) { this.dataHasSend = false; this.wxrequest({ diff --git a/product/sensorsdata.plugin.es6.full.js b/product/sensorsdata.plugin.es6.full.js index 844c60b..29b9f7e 100755 --- a/product/sensorsdata.plugin.es6.full.js +++ b/product/sensorsdata.plugin.es6.full.js @@ -156,7 +156,7 @@ var ArrayProto = Array.prototype, slice = ArrayProto.slice, toString = ObjProto.toString, hasOwnProperty = ObjProto.hasOwnProperty, - LIB_VERSION = '1.14.14', + LIB_VERSION = '1.14.15', LIB_NAME = 'MiniProgram'; var source_channel_standard = 'utm_source utm_medium utm_campaign utm_content utm_term'; @@ -1834,9 +1834,9 @@ sa.sendStrategy = { } if (sa.para.batch_send) { this.dataHasChange = true; - if (sa.store.mem.getLength() >= 300) { + if (sa.store.mem.getLength() >= 500) { logger.info('数据量存储过大,有异常'); - return false; + sa.store.mem.mdata.shift(); } sa.store.mem.add(data); if (sa.store.mem.getLength() >= sa.para.batch_send.max_length) { @@ -1888,8 +1888,15 @@ sa.sendStrategy = { }, batchSend: function() { if (this.dataHasSend) { - var data = sa.store.mem.mdata; - var len = data.length; + var data, + len, + mdata = sa.store.mem.mdata; + if (mdata.length >= 100) { + data = mdata.slice(0, 100); + } else { + data = mdata; + } + len = data.length; if (len > 0) { this.dataHasSend = false; this.wxrequest({ diff --git a/product/sensorsdata.plugin.full.js b/product/sensorsdata.plugin.full.js index 54f1d45..6961401 100755 --- a/product/sensorsdata.plugin.full.js +++ b/product/sensorsdata.plugin.full.js @@ -156,7 +156,7 @@ var ArrayProto = Array.prototype, slice = ArrayProto.slice, toString = ObjProto.toString, hasOwnProperty = ObjProto.hasOwnProperty, - LIB_VERSION = '1.14.14', + LIB_VERSION = '1.14.15', LIB_NAME = 'MiniProgram'; var source_channel_standard = 'utm_source utm_medium utm_campaign utm_content utm_term'; @@ -1834,9 +1834,9 @@ sa.sendStrategy = { } if (sa.para.batch_send) { this.dataHasChange = true; - if (sa.store.mem.getLength() >= 300) { + if (sa.store.mem.getLength() >= 500) { logger.info('数据量存储过大,有异常'); - return false; + sa.store.mem.mdata.shift(); } sa.store.mem.add(data); if (sa.store.mem.getLength() >= sa.para.batch_send.max_length) { @@ -1888,8 +1888,15 @@ sa.sendStrategy = { }, batchSend: function() { if (this.dataHasSend) { - var data = sa.store.mem.mdata; - var len = data.length; + var data, + len, + mdata = sa.store.mem.mdata; + if (mdata.length >= 100) { + data = mdata.slice(0, 100); + } else { + data = mdata; + } + len = data.length; if (len > 0) { this.dataHasSend = false; this.wxrequest({ diff --git a/sensorsdata.custom.es6.min.js b/sensorsdata.custom.es6.min.js index 1cf7091..152a891 100755 --- a/sensorsdata.custom.es6.min.js +++ b/sensorsdata.custom.es6.min.js @@ -1 +1 @@ -var _={},sa={para:{name:"sensors",server_url:"",send_timeout:1e3,show_log:!0,launched:!1,allow_amend_share_path:!0,max_string_length:300,datasend_timeout:3e3,source_channel:[],autoTrack:{appLaunch:!0,appShow:!0,appHide:!0,pageShow:!0,pageShare:!0,mpClick:!1,mpFavorite:!0},autotrack_exclude_page:{pageShow:[]},is_persistent_save:{share:!1,utm:!1},preset_properties:{url_path:!0},preset_events:{moments_page:!1,defer_track:!1},batch_send:!0}},mpHook={data:1,onLoad:1,onShow:1,onReady:1,onPullDownRefresh:1,onReachBottom:1,onShareAppMessage:1,onShareTimeline:1,onPullDownRefresh:1,onReachBottom:1,onPageScroll:1,onResize:1,onTabItemTap:1,onHide:1,onUnload:1},logger="object"==typeof logger?logger:{};logger.info=function(){if(sa.para.show_log&&"object"==typeof console&&console.log)try{if(3===arguments.length)return console.log(arguments[0],arguments[1],arguments[2]);if(2===arguments.length)return console.log(arguments[0],arguments[1]);if(1===arguments.length)return console.log(arguments[0])}catch(e){console.log(arguments[0])}},sa.setPara=function(e){sa.para=_.extend2Lev(sa.para,e);var t=[];if(_.isArray(sa.para.source_channel))for(var r=sa.para.source_channel.length,s=0;ssa.para.max_string_length?(logger.info("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,sa.para.max_string_length)):e},_.searchObjString=function(e){_.isObject(e)&&_.each(e,function(t,r){_.isObject(t)?_.searchObjString(e[r]):_.isString(t)&&(e[r]=_.formatString(t))})},_.parseSuperProperties=function(e){_.isObject(e)&&(_.each(e,function(t,r){if(_.isFunction(t))try{e[r]=t(),_.isFunction(e[r])&&(logger.info("\u60a8\u7684\u5c5e\u6027- "+r+" \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[r])}catch(t){delete e[r],logger.info("\u60a8\u7684\u5c5e\u6027- "+r+" \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}}),_.strip_sa_properties(e))},_.unique=function(e){for(var t,r=[],s={},a=0;a127&&i<2048?String.fromCharCode(i>>6|192,63&i|128):String.fromCharCode(i>>12|224,i>>6&63|128,63&i|128),null!==o&&(r>t&&(n+=e.substring(t,r)),n+=o,t=r=a+1)}return r>t&&(n+=e.substring(t,e.length)),n},_.base64Encode=function(e){var t,r,s,a,n,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,c=0,u="",p=[];if(!e)return e;e=_.utf8Encode(e);do{t=(n=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,r=n>>12&63,s=n>>6&63,a=63&n,p[c++]=i.charAt(t)+i.charAt(r)+i.charAt(s)+i.charAt(a)}while(o255||(s=e.charCodeAt(o++))>255||(a=e.charCodeAt(o++))>255)&&logger.info("Failed to execute 'btoa' : The string to be encoded contains characters outside of the Latin1 range."),i+=n.charAt((t=r<<16|s<<8|a)>>18&63)+n.charAt(t>>12&63)+n.charAt(t>>6&63)+n.charAt(63&t);return c?i.slice(0,c-3)+"===".substring(c):i},_.urlBase64Encode=function(e){return _.btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))},_.rot13obfs=function(e,t){t="number"==typeof t?t:13;for(var r=(e=String(e)).split(""),s=0,a=r.length;s(new Date).getTime()},_.getCurrentUrl=function(e){var t=_.getCurrentPath(),r="";return _.isObject(e)&&e.sensors_mp_encode_url_query&&(r=e.sensors_mp_encode_url_query),t?r?t+"?"+r:t:"\u672a\u53d6\u5230"},_.getPath=function(e){return e="string"==typeof e?e.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"},_.getMethods=function(e){var t=[];for(var r in e)"function"!=typeof e[r]||mpHook[r]||t.push(r);return t},_.isClick=function(e){return!!{tap:1,longpress:1,longtap:1}[e]},sa.initialState={queue:[],isComplete:!1,systemIsComplete:!1,storeIsComplete:!1,checkIsComplete:function(){this.systemIsComplete&&this.storeIsComplete&&(this.isComplete=!0,this.queue.length>0&&(_.each(this.queue,function(e){sa[e[0]].apply(sa,slice.call(e[1]))}),this.queue=[]))}},_.getCustomUtmFromQuery=function(e,t,r,s){if(!_.isObject(e))return{};var a={};if(e.sa_utm)for(var n in e)"sa_utm"!==n?_.include(sa.para.source_channel,n)&&(a[r+n]=e[n]):a[s+n]=e[n];else for(var n in e)-1===(" "+source_channel_standard+" ").indexOf(" "+n+" ")?_.include(sa.para.source_channel,n)&&(a[r+n]=e[n]):a[t+n]=e[n];return a},_.getObjFromQuery=function(e){var t=e.split("?"),r=[],s={};return t&&t[1]?(_.each(t[1].split("&"),function(e){(r=e.split("="))[0]&&r[1]&&(s[r[0]]=r[1])}),s):{}},_.setStorageSync=function(e,t){var r=function(){wx.setStorageSync(e,t)};try{r()}catch(e){logger.info("set Storage fail --",e);try{r()}catch(e){logger.info("set Storage fail again --",e)}}},_.getStorageSync=function(e){var t="";try{t=wx.getStorageSync(e)}catch(r){try{t=wx.getStorageSync(e)}catch(e){logger.info("getStorage fail")}}return t},_.getMPScene=function(e){return"number"==typeof e||"string"==typeof e&&""!==e?e="wx-"+String(e):"\u672a\u53d6\u5230\u503c"},_.setShareInfo=function(e,t){var r={},s={},a=sa.store.getDistinctId(),n=sa.store.getFirstId();if(!(e&&_.isObject(e.query)&&e.query.sampshare))return{};if(r=_.decodeURIComponent(e.query.sampshare),!_.isJSONString(r))return{};var i=(r=JSON.parse(r)).d,o=r.p,c=r.i,u=r.m;"string"==typeof c?(t.$share_distinct_id=c,share_distinct_id=c,s.$latest_share_distinct_id=c):t.$share_distinct_id="\u53d6\u503c\u5f02\u5e38","number"==typeof i?!share_distinct_id||share_distinct_id!==a&&share_distinct_id!==n?!share_distinct_id||share_distinct_id===a&&share_distinct_id===n?t.$share_depth="-1":(t.$share_depth=i+1,query_share_depth=i+1,s.$latest_share_depth=i+1):(t.$share_depth=i,query_share_depth=i,s.$latest_share_depth=i):t.$share_depth="-1","string"==typeof o?(t.$share_url_path=o,s.$latest_share_url_path=o):t.$share_url_path="\u53d6\u503c\u5f02\u5e38","string"==typeof u?(t.$share_method=u,s.$latest_share_method=u):t.$share_method="\u53d6\u503c\u5f02\u5e38",_.setLatestShare(s)},_.getShareInfo=function(){return JSON.stringify({i:sa.store.getDistinctId()||"\u53d6\u503c\u5f02\u5e38",p:_.getCurrentPath(),d:query_share_depth,m:share_method})},_.detectOptionQuery=function(e){if(!e||!_.isObject(e.query))return{};var t,r,s,a,n={};return n.query=_.extend({},e.query),"string"==typeof n.query.scene&&(t=n.query,r=["utm_source","utm_content","utm_medium","utm_campaign","utm_term","sa_utm"].concat(sa.para.source_channel),s=new RegExp("("+r.join("|")+")%3D","i"),1===(a=Object.keys(t)).length&&"scene"===a[0]&&s.test(t.scene))&&(n.scene=n.query.scene,delete n.query.scene),e.query.q&&e.query.scancode_time&&"101"===String(e.scene).slice(0,3)&&(n.q=String(n.query.q),delete n.query.q,delete n.query.scancode_time),n},_.getMixedQuery=function(e){var t=_.detectOptionQuery(e),r=t.scene,s=t.q,a=t.query;for(var n in a)a[n]=_.decodeURIComponent(a[n]);return r&&(r=-1!==(r=_.decodeURIComponent(r)).indexOf("?")?"?"+r.replace(/\?/g,""):"?"+r,_.extend(a,_.getObjFromQuery(r))),s&&_.extend(a,_.getObjFromQuery(_.decodeURIComponent(s))),a},_.setUtm=function(e,t){var r={},s=_.getMixedQuery(e),a=_.getCustomUtmFromQuery(s,"$","_","$"),n=_.getCustomUtmFromQuery(s,"$latest_","_latest_","$latest_");return r.pre1=a,r.pre2=n,_.extend(t,a),r},_.setSfSource=function(e,t){!_.isEmptyObject(e.query)&&e.query._sfs&&(t.$sf_source=e.query._sfs,sa.registerApp({$latest_sf_source:t.$sf_source}))},_.setPageSfSource=function(e){try{var t=getCurrentPages(),r=JSON.parse(JSON.stringify(t[t.length-1].options));for(var s in r)r[s]=_.decodeURIComponent(r[s]);!_.isEmptyObject(r)&&r._sfs&&(e.$sf_source=r._sfs)}catch(e){logger.info(e)}};try{var oldSetNavigationBarTitle=wx.setNavigationBarTitle;Object.defineProperty(wx,"setNavigationBarTitle",{get:function(){return function(e){var t=getCurrentPages(),r=t[t.length-1].route||"";e=_.isObject(e)?e:{},globalTitle[r]=e.title,oldSetNavigationBarTitle.call(this,e)}}})}catch(e){logger.info(e)}_.getPageTitle=function(e){if("\u672a\u53d6\u5230"===e||!e)return!1;var t="";try{if(__wxConfig){var r=__wxConfig,s=r.page[e]||r.page[e+".html"],a={},n={};if(r.global&&r.global.window&&r.global.window.navigationBarTitleText&&(a.titleVal=r.global.window.navigationBarTitleText),s&&s.window&&s.window.navigationBarTitleText&&(n.titleVal=s.window.navigationBarTitleText),_.each(globalTitle,function(r,s){if(s===e)return t=r}),0===t.length){var i=_.extend(a,n);t=i.titleVal}}}catch(e){logger.info(e)}return t},_.wxrequest=function(e){if(_.compareSDKVersion(wxSDKVersion,"2.10.0")>=0)e.timeout=sa.para.datasend_timeout,wx.request(e);else{var t=wx.request(e);setTimeout(function(){_.isObject(t)&&_.isFunction(t.abort)&&t.abort()},sa.para.datasend_timeout)}},_.getAppId=function(){var e;if(wx.getAccountInfoSync&&(e=wx.getAccountInfoSync()),_.isObject(e)&&_.isObject(e.miniProgram))return e.miniProgram.appId},_.validId=function(e){return"string"!=typeof e&&"number"!=typeof e||""===e?(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1):"number"!=typeof e||(e=String(e),/^\d+$/.test(e))?e:(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1)},_.compareSDKVersion=function(e,t){e=e.split("."),t=t.split(".");for(var r=Math.max(e.length,t.length);e.lengthn)return 1;if(a-1?t.system.split(" ")[1]:t.system,wxSDKVersion=t.SDKVersion},complete:function(){var t=(new Date).getTimezoneOffset(),r=_.getAppId();_.isNumber(t)&&(e.$timezone_offset=t),r&&(e.$app_id=r),sa.initialState.systemIsComplete=!0,sa.initialState.checkIsComplete()}})}wx.getNetworkType({success:function(t){e.$network_type=_.setUpperCase(t.networkType)},complete:t})}},sa._=_,_.eventEmitter=function(){this.sub=[]},_.eventEmitter.prototype={add:function(e){this.sub.push(e)},emit:function(e,t){this.sub.forEach(function(r){r.on(e,t)})}},_.eventSub=function(e){sa.events.add(this),this._events=[],this.handle=e,this.ready=!1},_.eventSub.prototype={on:function(e,t){if(this.ready){if(_.isFunction(this.handle))try{this.handle(e,t)}catch(e){logger.info(e)}}else this._events.push({event:e,data:t})},isReady:function(){var e=this;e.ready=!0,e._events.forEach(function(t){if(_.isFunction(e.handle))try{e.handle(t.event,t.data)}catch(e){logger.info(e)}})}},sa.eventSub=_.eventSub,sa.events=new _.eventEmitter,sa.usePlugin=function(e,t){"function"==typeof e.init&&e.init(sa,t)},sa.prepareData=function(e,t){if(current_scene&&1154===current_scene&&!sa.para.preset_events.moments_page)return!1;var r={distinct_id:this.store.getDistinctId(),lib:{$lib:LIB_NAME,$lib_method:"code",$lib_version:String(LIB_VERSION)},properties:{}};_.extend(r,this.store.getUnionId(),e),_.isObject(e.properties)&&!_.isEmptyObject(e.properties)&&_.extend(r.properties,e.properties),e.type&&"profile"===e.type.slice(0,7)||(r._track_id=Number(String(Math.random()).slice(2,5)+String(Math.random()).slice(2,4)+String(Date.now()).slice(-4)),r.properties=_.extend({},_.info.properties,sa.store.getProps(),_.info.currentProps,r.properties),r.properties.$is_first_day=_.getIsFirstDay()),r.properties.$time&&_.isDate(r.properties.$time)?(r.time=1*r.properties.$time,delete r.properties.$time):r.time=1*new Date,_.parseSuperProperties(r.properties),_.searchObjDate(r),_.searchObjString(r),logger.info(r),sa.events.emit("send",r),sa.sendStrategy.send(r)},sa.store={storageInfo:null,getUUID:function(){return Date.now()+"-"+Math.floor(1e7*Math.random())+"-"+Math.random().toString(16).replace(".","")+"-"+String(31242*Math.random()).replace(".","").slice(0,8)},getStorage:function(){return this.storageInfo?this.storageInfo:(this.storageInfo=sa._.getStorageSync("sensorsdata2015_wechat")||"",this.storageInfo)},_state:{},mem:{mdata:[],getLength:function(){return this.mdata.length},add:function(e){this.mdata.push(e)},clear:function(e){this.mdata.splice(0,e)}},toState:function(e){var t=null;_.isJSONString(e)?(t=JSON.parse(e)).distinct_id?this._state=t:this.set("distinct_id",this.getUUID()):_.isObject(e)&&(t=e).distinct_id?this._state=t:this.set("distinct_id",this.getUUID())},getFirstId:function(){return this._state._first_id||this._state.first_id},getDistinctId:function(){return this._state._distinct_id||this._state.distinct_id},getUnionId:function(){var e={},t=this._state._first_id||this._state.first_id,r=this._state._distinct_id||this._state.distinct_id;return t&&r?(e.login_id=r,e.anonymous_id=t):e.anonymous_id=r,e},getProps:function(){return this._state.props||{}},setProps:function(e,t){var r=this._state.props||{};t?this.set("props",e):(_.extend(r,e),this.set("props",r))},set:function(e,t){var r={};for(var s in"string"==typeof e?r[e]=t:"object"==typeof e&&(r=e),this._state=this._state||{},r)this._state[s]=r[s],"first_id"===s?delete this._state._first_id:"distinct_id"===s&&(delete this._state._distinct_id,sa.events.emit("changeDistinctId"));this.save()},change:function(e,t){this._state["_"+e]=t},encryptStorage:function(){var e=this.getStorage(),t="data:enc;";_.isObject(e)?e=t+_.rot13obfs(JSON.stringify(e)):_.isString(e)&&-1===e.indexOf(t)&&(e=t+_.rot13obfs(e)),sa._.setStorageSync("sensorsdata2015_wechat",e)},save:function(){var e=JSON.parse(JSON.stringify(this._state));if(delete e._first_id,delete e._distinct_id,sa.para.encrypt_storage){e="data:enc;"+_.rot13obfs(JSON.stringify(e))}sa._.setStorageSync("sensorsdata2015_wechat",e)},init:function(){var e=this.getStorage();if(e)_.isString(e)&&-1!==e.indexOf("data:enc;")&&(e=e.substring("data:enc;".length),e=JSON.parse(_.rot13defs(e))),this.toState(e);else{is_first_launch=!0;var t=new Date,r=t.getTime();t.setHours(23),t.setMinutes(59),t.setSeconds(60),sa.setOnceProfile({$first_visit_time:new Date}),this.set({distinct_id:this.getUUID(),first_visit_time:r,first_visit_day_time:t.getTime()})}}},sa.setProfile=function(e,t){sa.prepareData({type:"profile_set",properties:e},t)},sa.setOnceProfile=function(e,t){sa.prepareData({type:"profile_set_once",properties:e},t)},sa.appendProfile=function(e,t){if(!_.isObject(e))return!1;_.each(e,function(t,r){_.isString(t)?e[r]=[t]:_.isArray(t)||(delete e[r],logger.info("appendProfile\u5c5e\u6027\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32\u6216\u8005\u6570\u7ec4"))}),sa.prepareData({type:"profile_append",properties:e},t)},sa.incrementProfile=function(e,t){if(!_.isObject(e))return!1;var r=e;_.isString(e)&&((e={})[r]=1),sa.prepareData({type:"profile_increment",properties:e},t)},sa.track=function(e,t,r){this.prepareData({type:"track",event:e,properties:t},r)},sa.identify=function(e,t){if(e=_.validId(e)){var r=sa.store.getFirstId();!0===t?r?sa.store.set("first_id",e):sa.store.set("distinct_id",e):r?sa.store.change("first_id",e):sa.store.change("distinct_id",e)}},sa.trackSignup=function(e,t,r,s){var a=sa.store.getFirstId()||sa.store.getDistinctId();sa.store.set("distinct_id",e),sa.prepareData({original_id:a,distinct_id:e,type:"track_signup",event:t,properties:r},s)},sa.registerApp=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&(_.info.currentProps=_.extend(_.info.currentProps,e))},sa.register=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&sa.store.setProps(e)},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.clearAllProps=function(e){var t=sa.store.getProps(),r={};_.isArray(e)&&(_.each(t,function(t,s){_.include(e,s)||(r[s]=t)}),sa.store.setProps(r,!0))},sa.clearAppRegister=function(e){_.isArray(e)&&_.each(_.info.currentProps,function(t,r){_.include(e,r)&&delete _.info.currentProps[r]})},_.setLatestChannel=function(e){_.isEmptyObject(e)||(function(e,t){var r=!1;for(var s in t)e[t[s]]&&(r=!0);return r}(e,latest_source_channel)&&(sa.clearAppRegister(latest_source_channel),sa.clearAllProps(latest_source_channel)),sa.para.is_persistent_save.utm?sa.register(e):sa.registerApp(e))},_.setLatestShare=function(e){(e.$latest_share_depth||e.$latest_share_distinct_id||e.$latest_share_url_path||e.$latest_share_method)&&(sa.clearAppRegister(latest_share_info),sa.clearAllProps(latest_share_info),sa.para.is_persistent_save.share?sa.register(e):sa.registerApp(e))},sa.login=function(e){if(e=_.validId(e)){var t=sa.store.getFirstId(),r=sa.store.getDistinctId();e!==r&&(t?sa.trackSignup(e,"$SignUp"):(sa.store.set("first_id",r),sa.trackSignup(e,"$SignUp")))}},sa.getAnonymousID=function(){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")},sa.logout=function(e){var t=sa.store.getFirstId();t?(sa.store.set("first_id",""),!0===e?sa.store.set("distinct_id",sa.store.getUUID()):sa.store.set("distinct_id",t)):logger.info("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25")},sa.getLocation=function(){wx.getSetting({success:function(e){if(!e.authSetting["scope.userLocation"])return!1;wx.getLocation({type:sa.para.preset_properties.location.type,success:function(e){sa.registerApp({$latitude:e.latitude*Math.pow(10,6),$longitude:e.longitude*Math.pow(10,6),$geo_coordinate_system:_.setUpperCase(sa.para.preset_properties.location.type)})},fail:function(e){console.log("\u83b7\u53d6\u4f4d\u7f6e\u5931\u8d25",e)}})}})},sa.openid={getRequest:function(e){wx.login({success:function(t){t.code&&sa.para.appid&&sa.para.openid_url?_.wxrequest({url:sa.para.openid_url+"&code="+t.code+"&appid="+sa.para.appid,method:"GET",complete:function(t){_.isObject(t)&&_.isObject(t.data)&&t.data.openid?e(t.data.openid):e()}}):e()}})},getWXStorage:function(){var e=sa.store.getStorage();if(e&&_.isObject(e))return e.openid},getOpenid:function(e){if(!sa.para.appid)return e(),!1;var t=this.getWXStorage();t?e(t):this.getRequest(e)}},sa.initial=function(){this._.info.getSystem(),this.store.init()},sa.init=function(e){if(!0===this.hasInit)return!1;this.hasInit=!0,sa.setPara(e),sa.para.encrypt_storage&&this.store.encryptStorage(),sa.para.batch_send&&(wx.getStorage({key:"sensors_mp_prepare_data",complete:function(e){var t=e.data&&_.isArray(e.data)?e.data:[];sa.store.mem.mdata=t.concat(sa.store.mem.mdata),sa.sendStrategy.syncStorage=!0}}),sa.sendStrategy.batchInterval()),sa.initialState.storeIsComplete=!0,sa.initialState.checkIsComplete()},sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib){var e={};_.each(_.info.currentProps,function(t,r){0===r.indexOf("$")&&(e[r]=t)});var t=_.extend(e,{$url_path:_.getCurrentPath(),$is_first_day:_.getIsFirstDay()},_.info.properties,sa.store.getProps());return delete t.$lib,t}return{}},_.autoExeQueue=function(){return{items:[],enqueue:function(e){this.items.push(e),this.start()},dequeue:function(){return this.items.shift()},getCurrentItem:function(){return this.items[0]},isRun:!1,start:function(){this.items.length>0&&!this.isRun&&(this.isRun=!0,this.getCurrentItem().start())},close:function(){this.dequeue(),this.isRun=!1,this.start()}}},sa.requestQueue=function(e){this.url=e.url},sa.requestQueue.prototype.isEnd=function(){this.received||(this.received=!0,this.close())},sa.requestQueue.prototype.start=function(){var e=this;_.wxrequest({url:this.url,method:"GET",complete:function(){e.isEnd()}})},sa.dataQueue=_.autoExeQueue(),sa.sendStrategy={dataHasSend:!0,dataHasChange:!1,syncStorage:!1,failTime:0,onAppHide:function(){sa.para.batch_send&&this.batchSend()},send:function(e){if(!sa.para.server_url)return!1;if(sa.para.batch_send){if(this.dataHasChange=!0,sa.store.mem.getLength()>=300)return logger.info("\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38"),!1;sa.store.mem.add(e),sa.store.mem.getLength()>=sa.para.batch_send.max_length&&this.batchSend()}else this.queueSend(e)},queueSend:function(e){e._flush_time=Date.now(),e=JSON.stringify(e),e=-1!==sa.para.server_url.indexOf("?")?sa.para.server_url+"&data="+encodeURIComponent(_.base64Encode(e)):sa.para.server_url+"?data="+encodeURIComponent(_.base64Encode(e));var t=new sa.requestQueue({url:e});t.close=function(){sa.dataQueue.close()},sa.dataQueue.enqueue(t)},wxrequest:function(e){if(_.isArray(e.data)&&e.data.length>0){var t=Date.now();e.data.forEach(function(e){e._flush_time=t}),e.data=JSON.stringify(e.data),_.wxrequest({url:sa.para.server_url,method:"POST",dataType:"text",data:"data_list="+encodeURIComponent(_.base64Encode(e.data)),success:function(){e.success(e.len)},fail:function(){e.fail()}})}else e.success(e.len)},batchSend:function(){if(this.dataHasSend){var e=sa.store.mem.mdata,t=e.length;t>0&&(this.dataHasSend=!1,this.wxrequest({data:e,len:t,success:this.batchRemove.bind(this),fail:this.sendFail.bind(this)}))}},sendFail:function(){this.dataHasSend=!0,this.failTime++},batchRemove:function(e){sa.store.mem.clear(e),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite(),this.failTime=0},is_first_batch_write:!0,batchWrite:function(){var e=this;this.dataHasChange&&(this.is_first_batch_write&&(this.is_first_batch_write=!1,setTimeout(function(){e.batchSend()},1e3)),this.dataHasChange=!1,this.syncStorage&&sa._.setStorageSync("sensors_mp_prepare_data",sa.store.mem.mdata))},batchInterval:function(){var e=this;!function t(){setTimeout(function(){e.batchWrite(),t()},500)}(),function t(){setTimeout(function(){e.batchSend(),t()},sa.para.batch_send.send_timeout*Math.pow(2,e.failTime))}()}},sa.setOpenid=function(e,t){sa.store.set("openid",e),t?sa.store.set("distinct_id",e):sa.identify(e,!0)},sa.initWithOpenid=function(e,t){(e=e||{}).appid&&(sa.para.appid=e.appid),sa.openid.getOpenid(function(r){r&&sa.setOpenid(r,e.isCoverLogin),t&&_.isFunction(t)&&t(r),sa.init(e)})},sa.setWebViewUrl=function(e,t){if(!_.isString(e)||""===e)return logger.info("error:\u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;e=decodeURIComponent(e);var r,s=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e),a=s[1]||"",n=s[2]||"",i=s[3]||"",o="",c=sa.store.getDistinctId()||"",u=sa.store.getFirstId()||"";_.urlSafeBase64&&_.urlSafeBase64.encode?c=c?_.urlSafeBase64.trim(_.urlSafeBase64.encode(_.urlBase64Encode(c))):"":this._.rot13obfs&&(c=c?_.rot13obfs(c):""),c=encodeURIComponent(c);var p=u?"f"+c:"d"+c;t?(r=i.indexOf("_sasdk"),o=i.indexOf("?")>-1?r>-1?a+n+"#"+i.substring(1,r)+"_sasdk="+p:a+n+"#"+i.substring(1)+"&_sasdk="+p:a+n+"#"+i.substring(1)+"?_sasdk="+p):(r=n.indexOf("_sasdk"),o=/^\?(\w)+/.test(n)?r>-1?a+"?"+n.substring(1,r)+"_sasdk="+p+i:a+"?"+n.substring(1)+"&_sasdk="+p+i:a+"?"+n.substring(1)+"_sasdk="+p+i);return o},_.each(["setProfile","setOnceProfile","track","quick","incrementProfile","appendProfile","login","logout","registerApp","register","clearAllRegister","clearAllProps","clearAppRegister"],function(e){var t=sa[e];sa[e]=function(){sa.initialState.isComplete?t.apply(sa,arguments):sa.initialState.queue.push([e,arguments])}}),_.setQuery=function(e,t){if(e&&_.isObject(e)&&!_.isEmptyObject(e)){var r=[];return _.each(e,function(e,s){"q"===s&&_.isString(e)&&0===e.indexOf("http")||(t?r.push(s+"="+e):r.push(s+"="+_.decodeURIComponent(e)))}),r.join("&")}return""},_.getUtmFromPage=function(){var e={};try{var t=getCurrentPages(),r=JSON.parse(JSON.stringify(t[t.length-1].options));for(var s in r)r[s]=_.decodeURIComponent(r[s]);e=_.getCustomUtmFromQuery(r,"$","_","$")}catch(e){logger.info(e)}return e},sa.autoTrackCustom={trackCustom:function(e,t,r){var s=sa.para.autoTrack[e],a="";sa.para.autoTrack&&s&&("function"==typeof s?(a=s(),_.isObject(a)&&_.extend(t,a)):_.isObject(s)&&(_.extend(t,s),sa.para.autoTrack[e]=!0),sa.track(r,t))},appLaunch:function(e,t){"object"!=typeof this||this.trackCustom||(this[sa.para.name]=sa);var r={};e&&e.scene?(current_scene=e.scene,r.$scene=_.getMPScene(e.scene)):r.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(r.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:r.$url_path})),_.setShareInfo(e,r);var s=_.setUtm(e,r);is_first_launch?(r.$is_first_time=!0,_.isEmptyObject(s.pre1)||sa.setOnceProfile(s.pre1)):r.$is_first_time=!1,_.setLatestChannel(s.pre2),_.setSfSource(e,r),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(e.query),t?(r=_.extend(r,t),sa.track("$MPLaunch",r)):sa.para.autoTrack&&sa.para.autoTrack.appLaunch&&sa.autoTrackCustom.trackCustom("appLaunch",r,"$MPLaunch")},appShow:function(e,t){var r={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,r.$scene=_.getMPScene(e.scene)):r.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(r.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:r.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,r);var s=_.setUtm(e,r);_.setLatestChannel(s.pre2),_.setSfSource(e,r),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(e.query),t?(r=_.extend(r,t),sa.track("$MPShow",r)):sa.para.autoTrack&&sa.para.autoTrack.appShow&&sa.autoTrackCustom.trackCustom("appShow",r,"$MPShow")},appHide:function(e){var t=(new Date).getTime(),r={};r.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(r.event_duration=(t-mpshow_time)/1e3),e?(r=_.extend(r,e),sa.track("$MPHide",r)):sa.para.autoTrack&&sa.para.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",r,"$MPHide"),sa.sendStrategy.onAppHide()}},sa.quick=function(){var e=arguments[0],t=arguments[1],r=arguments[2],s=_.isObject(r)?r:{};if("getAnonymousID"===e){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===e||"appShow"===e?t?sa.autoTrackCustom[e](t,s):logger.info("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(s=_.isObject(t)?t:{},sa.autoTrackCustom[e](s))},sa.appLaunch=function(e,t){var r={};e&&e.scene?(current_scene=e.scene,r.$scene=_.getMPScene(e.scene)):r.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(r.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:r.$url_path})),_.setShareInfo(e,r);var s=_.setUtm(e,r);is_first_launch?(r.$is_first_time=!0,_.isEmptyObject(s.pre1)||sa.setOnceProfile(s.pre1)):r.$is_first_time=!1,_.setLatestChannel(s.pre2),_.setSfSource(e,r),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(e.query),_.isObject(t)&&(r=_.extend(r,t)),sa.track("$MPLaunch",r)},sa.appShow=function(e,t){var r={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,r.$scene=_.getMPScene(e.scene)):r.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(r.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:r.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,r);var s=_.setUtm(e,r);_.setLatestChannel(s.pre2),_.setSfSource(e,r),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(e.query),_.isObject(t)&&(r=_.extend(r,t)),sa.track("$MPShow",r)},sa.appHide=function(e){var t=(new Date).getTime(),r={};r.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(r.event_duration=(t-mpshow_time)/1e3),_.isObject(e)&&(r=_.extend(r,e)),sa.track("$MPHide",r),sa.sendStrategy.onAppHide()},sa.pageShow=function(e){var t={},r=_.getCurrentPath(),s=_.getPageTitle(r),a={};try{var n=getCurrentPages();a=n[n.length-1]}catch(e){logger.info(e)}!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:r}),s&&(t.$title=s),t.$referrer=sa_referrer,t.$url_path=r,sa.status.last_referrer=sa_referrer,t.$url_query=a.sensors_mp_url_query?a.sensors_mp_url_query:"",t=_.extend(t,_.getUtmFromPage()),_.setPageSfSource(t),_.isObject(e)&&(t=_.extend(t,e)),sa.track("$MPViewScreen",t),sa_referrer=r,sa.status.referrer=r},sa.initial();export default sa; \ No newline at end of file +var _={},sa={para:{name:"sensors",server_url:"",send_timeout:1e3,show_log:!0,launched:!1,allow_amend_share_path:!0,max_string_length:300,datasend_timeout:3e3,source_channel:[],autoTrack:{appLaunch:!0,appShow:!0,appHide:!0,pageShow:!0,pageShare:!0,mpClick:!1,mpFavorite:!0},autotrack_exclude_page:{pageShow:[]},is_persistent_save:{share:!1,utm:!1},preset_properties:{url_path:!0},preset_events:{moments_page:!1,defer_track:!1},batch_send:!0}},mpHook={data:1,onLoad:1,onShow:1,onReady:1,onPullDownRefresh:1,onReachBottom:1,onShareAppMessage:1,onShareTimeline:1,onPullDownRefresh:1,onReachBottom:1,onPageScroll:1,onResize:1,onTabItemTap:1,onHide:1,onUnload:1},logger="object"==typeof logger?logger:{};logger.info=function(){if(sa.para.show_log&&"object"==typeof console&&console.log)try{if(3===arguments.length)return console.log(arguments[0],arguments[1],arguments[2]);if(2===arguments.length)return console.log(arguments[0],arguments[1]);if(1===arguments.length)return console.log(arguments[0])}catch(e){console.log(arguments[0])}},sa.setPara=function(e){sa.para=_.extend2Lev(sa.para,e);var t=[];if(_.isArray(sa.para.source_channel))for(var r=sa.para.source_channel.length,s=0;ssa.para.max_string_length?(logger.info("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,sa.para.max_string_length)):e},_.searchObjString=function(e){_.isObject(e)&&_.each(e,function(t,r){_.isObject(t)?_.searchObjString(e[r]):_.isString(t)&&(e[r]=_.formatString(t))})},_.parseSuperProperties=function(e){_.isObject(e)&&(_.each(e,function(t,r){if(_.isFunction(t))try{e[r]=t(),_.isFunction(e[r])&&(logger.info("\u60a8\u7684\u5c5e\u6027- "+r+" \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[r])}catch(t){delete e[r],logger.info("\u60a8\u7684\u5c5e\u6027- "+r+" \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}}),_.strip_sa_properties(e))},_.unique=function(e){for(var t,r=[],s={},a=0;a127&&i<2048?String.fromCharCode(i>>6|192,63&i|128):String.fromCharCode(i>>12|224,i>>6&63|128,63&i|128),null!==o&&(r>t&&(n+=e.substring(t,r)),n+=o,t=r=a+1)}return r>t&&(n+=e.substring(t,e.length)),n},_.base64Encode=function(e){var t,r,s,a,n,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,c=0,u="",p=[];if(!e)return e;e=_.utf8Encode(e);do{t=(n=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,r=n>>12&63,s=n>>6&63,a=63&n,p[c++]=i.charAt(t)+i.charAt(r)+i.charAt(s)+i.charAt(a)}while(o255||(s=e.charCodeAt(o++))>255||(a=e.charCodeAt(o++))>255)&&logger.info("Failed to execute 'btoa' : The string to be encoded contains characters outside of the Latin1 range."),i+=n.charAt((t=r<<16|s<<8|a)>>18&63)+n.charAt(t>>12&63)+n.charAt(t>>6&63)+n.charAt(63&t);return c?i.slice(0,c-3)+"===".substring(c):i},_.urlBase64Encode=function(e){return _.btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))},_.rot13obfs=function(e,t){t="number"==typeof t?t:13;for(var r=(e=String(e)).split(""),s=0,a=r.length;s(new Date).getTime()},_.getCurrentUrl=function(e){var t=_.getCurrentPath(),r="";return _.isObject(e)&&e.sensors_mp_encode_url_query&&(r=e.sensors_mp_encode_url_query),t?r?t+"?"+r:t:"\u672a\u53d6\u5230"},_.getPath=function(e){return e="string"==typeof e?e.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"},_.getMethods=function(e){var t=[];for(var r in e)"function"!=typeof e[r]||mpHook[r]||t.push(r);return t},_.isClick=function(e){return!!{tap:1,longpress:1,longtap:1}[e]},sa.initialState={queue:[],isComplete:!1,systemIsComplete:!1,storeIsComplete:!1,checkIsComplete:function(){this.systemIsComplete&&this.storeIsComplete&&(this.isComplete=!0,this.queue.length>0&&(_.each(this.queue,function(e){sa[e[0]].apply(sa,slice.call(e[1]))}),this.queue=[]))}},_.getCustomUtmFromQuery=function(e,t,r,s){if(!_.isObject(e))return{};var a={};if(e.sa_utm)for(var n in e)"sa_utm"!==n?_.include(sa.para.source_channel,n)&&(a[r+n]=e[n]):a[s+n]=e[n];else for(var n in e)-1===(" "+source_channel_standard+" ").indexOf(" "+n+" ")?_.include(sa.para.source_channel,n)&&(a[r+n]=e[n]):a[t+n]=e[n];return a},_.getObjFromQuery=function(e){var t=e.split("?"),r=[],s={};return t&&t[1]?(_.each(t[1].split("&"),function(e){(r=e.split("="))[0]&&r[1]&&(s[r[0]]=r[1])}),s):{}},_.setStorageSync=function(e,t){var r=function(){wx.setStorageSync(e,t)};try{r()}catch(e){logger.info("set Storage fail --",e);try{r()}catch(e){logger.info("set Storage fail again --",e)}}},_.getStorageSync=function(e){var t="";try{t=wx.getStorageSync(e)}catch(r){try{t=wx.getStorageSync(e)}catch(e){logger.info("getStorage fail")}}return t},_.getMPScene=function(e){return"number"==typeof e||"string"==typeof e&&""!==e?e="wx-"+String(e):"\u672a\u53d6\u5230\u503c"},_.setShareInfo=function(e,t){var r={},s={},a=sa.store.getDistinctId(),n=sa.store.getFirstId();if(!(e&&_.isObject(e.query)&&e.query.sampshare))return{};if(r=_.decodeURIComponent(e.query.sampshare),!_.isJSONString(r))return{};var i=(r=JSON.parse(r)).d,o=r.p,c=r.i,u=r.m;"string"==typeof c?(t.$share_distinct_id=c,share_distinct_id=c,s.$latest_share_distinct_id=c):t.$share_distinct_id="\u53d6\u503c\u5f02\u5e38","number"==typeof i?!share_distinct_id||share_distinct_id!==a&&share_distinct_id!==n?!share_distinct_id||share_distinct_id===a&&share_distinct_id===n?t.$share_depth="-1":(t.$share_depth=i+1,query_share_depth=i+1,s.$latest_share_depth=i+1):(t.$share_depth=i,query_share_depth=i,s.$latest_share_depth=i):t.$share_depth="-1","string"==typeof o?(t.$share_url_path=o,s.$latest_share_url_path=o):t.$share_url_path="\u53d6\u503c\u5f02\u5e38","string"==typeof u?(t.$share_method=u,s.$latest_share_method=u):t.$share_method="\u53d6\u503c\u5f02\u5e38",_.setLatestShare(s)},_.getShareInfo=function(){return JSON.stringify({i:sa.store.getDistinctId()||"\u53d6\u503c\u5f02\u5e38",p:_.getCurrentPath(),d:query_share_depth,m:share_method})},_.detectOptionQuery=function(e){if(!e||!_.isObject(e.query))return{};var t,r,s,a,n={};return n.query=_.extend({},e.query),"string"==typeof n.query.scene&&(t=n.query,r=["utm_source","utm_content","utm_medium","utm_campaign","utm_term","sa_utm"].concat(sa.para.source_channel),s=new RegExp("("+r.join("|")+")%3D","i"),1===(a=Object.keys(t)).length&&"scene"===a[0]&&s.test(t.scene))&&(n.scene=n.query.scene,delete n.query.scene),e.query.q&&e.query.scancode_time&&"101"===String(e.scene).slice(0,3)&&(n.q=String(n.query.q),delete n.query.q,delete n.query.scancode_time),n},_.getMixedQuery=function(e){var t=_.detectOptionQuery(e),r=t.scene,s=t.q,a=t.query;for(var n in a)a[n]=_.decodeURIComponent(a[n]);return r&&(r=-1!==(r=_.decodeURIComponent(r)).indexOf("?")?"?"+r.replace(/\?/g,""):"?"+r,_.extend(a,_.getObjFromQuery(r))),s&&_.extend(a,_.getObjFromQuery(_.decodeURIComponent(s))),a},_.setUtm=function(e,t){var r={},s=_.getMixedQuery(e),a=_.getCustomUtmFromQuery(s,"$","_","$"),n=_.getCustomUtmFromQuery(s,"$latest_","_latest_","$latest_");return r.pre1=a,r.pre2=n,_.extend(t,a),r},_.setSfSource=function(e,t){!_.isEmptyObject(e.query)&&e.query._sfs&&(t.$sf_source=e.query._sfs,sa.registerApp({$latest_sf_source:t.$sf_source}))},_.setPageSfSource=function(e){try{var t=getCurrentPages(),r=JSON.parse(JSON.stringify(t[t.length-1].options));for(var s in r)r[s]=_.decodeURIComponent(r[s]);!_.isEmptyObject(r)&&r._sfs&&(e.$sf_source=r._sfs)}catch(e){logger.info(e)}};try{var oldSetNavigationBarTitle=wx.setNavigationBarTitle;Object.defineProperty(wx,"setNavigationBarTitle",{get:function(){return function(e){var t=getCurrentPages(),r=t[t.length-1].route||"";e=_.isObject(e)?e:{},globalTitle[r]=e.title,oldSetNavigationBarTitle.call(this,e)}}})}catch(e){logger.info(e)}_.getPageTitle=function(e){if("\u672a\u53d6\u5230"===e||!e)return!1;var t="";try{if(__wxConfig){var r=__wxConfig,s=r.page[e]||r.page[e+".html"],a={},n={};if(r.global&&r.global.window&&r.global.window.navigationBarTitleText&&(a.titleVal=r.global.window.navigationBarTitleText),s&&s.window&&s.window.navigationBarTitleText&&(n.titleVal=s.window.navigationBarTitleText),_.each(globalTitle,function(r,s){if(s===e)return t=r}),0===t.length){var i=_.extend(a,n);t=i.titleVal}}}catch(e){logger.info(e)}return t},_.wxrequest=function(e){if(_.compareSDKVersion(wxSDKVersion,"2.10.0")>=0)e.timeout=sa.para.datasend_timeout,wx.request(e);else{var t=wx.request(e);setTimeout(function(){_.isObject(t)&&_.isFunction(t.abort)&&t.abort()},sa.para.datasend_timeout)}},_.getAppId=function(){var e;if(wx.getAccountInfoSync&&(e=wx.getAccountInfoSync()),_.isObject(e)&&_.isObject(e.miniProgram))return e.miniProgram.appId},_.validId=function(e){return"string"!=typeof e&&"number"!=typeof e||""===e?(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1):"number"!=typeof e||(e=String(e),/^\d+$/.test(e))?e:(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1)},_.compareSDKVersion=function(e,t){e=e.split("."),t=t.split(".");for(var r=Math.max(e.length,t.length);e.lengthn)return 1;if(a-1?t.system.split(" ")[1]:t.system,wxSDKVersion=t.SDKVersion},complete:function(){var t=(new Date).getTimezoneOffset(),r=_.getAppId();_.isNumber(t)&&(e.$timezone_offset=t),r&&(e.$app_id=r),sa.initialState.systemIsComplete=!0,sa.initialState.checkIsComplete()}})}wx.getNetworkType({success:function(t){e.$network_type=_.setUpperCase(t.networkType)},complete:t})}},sa._=_,_.eventEmitter=function(){this.sub=[]},_.eventEmitter.prototype={add:function(e){this.sub.push(e)},emit:function(e,t){this.sub.forEach(function(r){r.on(e,t)})}},_.eventSub=function(e){sa.events.add(this),this._events=[],this.handle=e,this.ready=!1},_.eventSub.prototype={on:function(e,t){if(this.ready){if(_.isFunction(this.handle))try{this.handle(e,t)}catch(e){logger.info(e)}}else this._events.push({event:e,data:t})},isReady:function(){var e=this;e.ready=!0,e._events.forEach(function(t){if(_.isFunction(e.handle))try{e.handle(t.event,t.data)}catch(e){logger.info(e)}})}},sa.eventSub=_.eventSub,sa.events=new _.eventEmitter,sa.usePlugin=function(e,t){"function"==typeof e.init&&e.init(sa,t)},sa.prepareData=function(e,t){if(current_scene&&1154===current_scene&&!sa.para.preset_events.moments_page)return!1;var r={distinct_id:this.store.getDistinctId(),lib:{$lib:LIB_NAME,$lib_method:"code",$lib_version:String(LIB_VERSION)},properties:{}};_.extend(r,this.store.getUnionId(),e),_.isObject(e.properties)&&!_.isEmptyObject(e.properties)&&_.extend(r.properties,e.properties),e.type&&"profile"===e.type.slice(0,7)||(r._track_id=Number(String(Math.random()).slice(2,5)+String(Math.random()).slice(2,4)+String(Date.now()).slice(-4)),r.properties=_.extend({},_.info.properties,sa.store.getProps(),_.info.currentProps,r.properties),r.properties.$is_first_day=_.getIsFirstDay()),r.properties.$time&&_.isDate(r.properties.$time)?(r.time=1*r.properties.$time,delete r.properties.$time):r.time=1*new Date,_.parseSuperProperties(r.properties),_.searchObjDate(r),_.searchObjString(r),logger.info(r),sa.events.emit("send",r),sa.sendStrategy.send(r)},sa.store={storageInfo:null,getUUID:function(){return Date.now()+"-"+Math.floor(1e7*Math.random())+"-"+Math.random().toString(16).replace(".","")+"-"+String(31242*Math.random()).replace(".","").slice(0,8)},getStorage:function(){return this.storageInfo?this.storageInfo:(this.storageInfo=sa._.getStorageSync("sensorsdata2015_wechat")||"",this.storageInfo)},_state:{},mem:{mdata:[],getLength:function(){return this.mdata.length},add:function(e){this.mdata.push(e)},clear:function(e){this.mdata.splice(0,e)}},toState:function(e){var t=null;_.isJSONString(e)?(t=JSON.parse(e)).distinct_id?this._state=t:this.set("distinct_id",this.getUUID()):_.isObject(e)&&(t=e).distinct_id?this._state=t:this.set("distinct_id",this.getUUID())},getFirstId:function(){return this._state._first_id||this._state.first_id},getDistinctId:function(){return this._state._distinct_id||this._state.distinct_id},getUnionId:function(){var e={},t=this._state._first_id||this._state.first_id,r=this._state._distinct_id||this._state.distinct_id;return t&&r?(e.login_id=r,e.anonymous_id=t):e.anonymous_id=r,e},getProps:function(){return this._state.props||{}},setProps:function(e,t){var r=this._state.props||{};t?this.set("props",e):(_.extend(r,e),this.set("props",r))},set:function(e,t){var r={};for(var s in"string"==typeof e?r[e]=t:"object"==typeof e&&(r=e),this._state=this._state||{},r)this._state[s]=r[s],"first_id"===s?delete this._state._first_id:"distinct_id"===s&&(delete this._state._distinct_id,sa.events.emit("changeDistinctId"));this.save()},change:function(e,t){this._state["_"+e]=t},encryptStorage:function(){var e=this.getStorage(),t="data:enc;";_.isObject(e)?e=t+_.rot13obfs(JSON.stringify(e)):_.isString(e)&&-1===e.indexOf(t)&&(e=t+_.rot13obfs(e)),sa._.setStorageSync("sensorsdata2015_wechat",e)},save:function(){var e=JSON.parse(JSON.stringify(this._state));if(delete e._first_id,delete e._distinct_id,sa.para.encrypt_storage){e="data:enc;"+_.rot13obfs(JSON.stringify(e))}sa._.setStorageSync("sensorsdata2015_wechat",e)},init:function(){var e=this.getStorage();if(e)_.isString(e)&&-1!==e.indexOf("data:enc;")&&(e=e.substring("data:enc;".length),e=JSON.parse(_.rot13defs(e))),this.toState(e);else{is_first_launch=!0;var t=new Date,r=t.getTime();t.setHours(23),t.setMinutes(59),t.setSeconds(60),sa.setOnceProfile({$first_visit_time:new Date}),this.set({distinct_id:this.getUUID(),first_visit_time:r,first_visit_day_time:t.getTime()})}}},sa.setProfile=function(e,t){sa.prepareData({type:"profile_set",properties:e},t)},sa.setOnceProfile=function(e,t){sa.prepareData({type:"profile_set_once",properties:e},t)},sa.appendProfile=function(e,t){if(!_.isObject(e))return!1;_.each(e,function(t,r){_.isString(t)?e[r]=[t]:_.isArray(t)||(delete e[r],logger.info("appendProfile\u5c5e\u6027\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32\u6216\u8005\u6570\u7ec4"))}),sa.prepareData({type:"profile_append",properties:e},t)},sa.incrementProfile=function(e,t){if(!_.isObject(e))return!1;var r=e;_.isString(e)&&((e={})[r]=1),sa.prepareData({type:"profile_increment",properties:e},t)},sa.track=function(e,t,r){this.prepareData({type:"track",event:e,properties:t},r)},sa.identify=function(e,t){if(e=_.validId(e)){var r=sa.store.getFirstId();!0===t?r?sa.store.set("first_id",e):sa.store.set("distinct_id",e):r?sa.store.change("first_id",e):sa.store.change("distinct_id",e)}},sa.trackSignup=function(e,t,r,s){var a=sa.store.getFirstId()||sa.store.getDistinctId();sa.store.set("distinct_id",e),sa.prepareData({original_id:a,distinct_id:e,type:"track_signup",event:t,properties:r},s)},sa.registerApp=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&(_.info.currentProps=_.extend(_.info.currentProps,e))},sa.register=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&sa.store.setProps(e)},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.clearAllProps=function(e){var t=sa.store.getProps(),r={};_.isArray(e)&&(_.each(t,function(t,s){_.include(e,s)||(r[s]=t)}),sa.store.setProps(r,!0))},sa.clearAppRegister=function(e){_.isArray(e)&&_.each(_.info.currentProps,function(t,r){_.include(e,r)&&delete _.info.currentProps[r]})},_.setLatestChannel=function(e){_.isEmptyObject(e)||(function(e,t){var r=!1;for(var s in t)e[t[s]]&&(r=!0);return r}(e,latest_source_channel)&&(sa.clearAppRegister(latest_source_channel),sa.clearAllProps(latest_source_channel)),sa.para.is_persistent_save.utm?sa.register(e):sa.registerApp(e))},_.setLatestShare=function(e){(e.$latest_share_depth||e.$latest_share_distinct_id||e.$latest_share_url_path||e.$latest_share_method)&&(sa.clearAppRegister(latest_share_info),sa.clearAllProps(latest_share_info),sa.para.is_persistent_save.share?sa.register(e):sa.registerApp(e))},sa.login=function(e){if(e=_.validId(e)){var t=sa.store.getFirstId(),r=sa.store.getDistinctId();e!==r&&(t?sa.trackSignup(e,"$SignUp"):(sa.store.set("first_id",r),sa.trackSignup(e,"$SignUp")))}},sa.getAnonymousID=function(){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")},sa.logout=function(e){var t=sa.store.getFirstId();t?(sa.store.set("first_id",""),!0===e?sa.store.set("distinct_id",sa.store.getUUID()):sa.store.set("distinct_id",t)):logger.info("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25")},sa.getLocation=function(){wx.getSetting({success:function(e){if(!e.authSetting["scope.userLocation"])return!1;wx.getLocation({type:sa.para.preset_properties.location.type,success:function(e){sa.registerApp({$latitude:e.latitude*Math.pow(10,6),$longitude:e.longitude*Math.pow(10,6),$geo_coordinate_system:_.setUpperCase(sa.para.preset_properties.location.type)})},fail:function(e){console.log("\u83b7\u53d6\u4f4d\u7f6e\u5931\u8d25",e)}})}})},sa.openid={getRequest:function(e){wx.login({success:function(t){t.code&&sa.para.appid&&sa.para.openid_url?_.wxrequest({url:sa.para.openid_url+"&code="+t.code+"&appid="+sa.para.appid,method:"GET",complete:function(t){_.isObject(t)&&_.isObject(t.data)&&t.data.openid?e(t.data.openid):e()}}):e()}})},getWXStorage:function(){var e=sa.store.getStorage();if(e&&_.isObject(e))return e.openid},getOpenid:function(e){if(!sa.para.appid)return e(),!1;var t=this.getWXStorage();t?e(t):this.getRequest(e)}},sa.initial=function(){this._.info.getSystem(),this.store.init()},sa.init=function(e){if(!0===this.hasInit)return!1;this.hasInit=!0,sa.setPara(e),sa.para.encrypt_storage&&this.store.encryptStorage(),sa.para.batch_send&&(wx.getStorage({key:"sensors_mp_prepare_data",complete:function(e){var t=e.data&&_.isArray(e.data)?e.data:[];sa.store.mem.mdata=t.concat(sa.store.mem.mdata),sa.sendStrategy.syncStorage=!0}}),sa.sendStrategy.batchInterval()),sa.initialState.storeIsComplete=!0,sa.initialState.checkIsComplete()},sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib){var e={};_.each(_.info.currentProps,function(t,r){0===r.indexOf("$")&&(e[r]=t)});var t=_.extend(e,{$url_path:_.getCurrentPath(),$is_first_day:_.getIsFirstDay()},_.info.properties,sa.store.getProps());return delete t.$lib,t}return{}},_.autoExeQueue=function(){return{items:[],enqueue:function(e){this.items.push(e),this.start()},dequeue:function(){return this.items.shift()},getCurrentItem:function(){return this.items[0]},isRun:!1,start:function(){this.items.length>0&&!this.isRun&&(this.isRun=!0,this.getCurrentItem().start())},close:function(){this.dequeue(),this.isRun=!1,this.start()}}},sa.requestQueue=function(e){this.url=e.url},sa.requestQueue.prototype.isEnd=function(){this.received||(this.received=!0,this.close())},sa.requestQueue.prototype.start=function(){var e=this;_.wxrequest({url:this.url,method:"GET",complete:function(){e.isEnd()}})},sa.dataQueue=_.autoExeQueue(),sa.sendStrategy={dataHasSend:!0,dataHasChange:!1,syncStorage:!1,failTime:0,onAppHide:function(){sa.para.batch_send&&this.batchSend()},send:function(e){if(!sa.para.server_url)return!1;sa.para.batch_send?(this.dataHasChange=!0,sa.store.mem.getLength()>=500&&(logger.info("\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38"),sa.store.mem.mdata.shift()),sa.store.mem.add(e),sa.store.mem.getLength()>=sa.para.batch_send.max_length&&this.batchSend()):this.queueSend(e)},queueSend:function(e){e._flush_time=Date.now(),e=JSON.stringify(e),e=-1!==sa.para.server_url.indexOf("?")?sa.para.server_url+"&data="+encodeURIComponent(_.base64Encode(e)):sa.para.server_url+"?data="+encodeURIComponent(_.base64Encode(e));var t=new sa.requestQueue({url:e});t.close=function(){sa.dataQueue.close()},sa.dataQueue.enqueue(t)},wxrequest:function(e){if(_.isArray(e.data)&&e.data.length>0){var t=Date.now();e.data.forEach(function(e){e._flush_time=t}),e.data=JSON.stringify(e.data),_.wxrequest({url:sa.para.server_url,method:"POST",dataType:"text",data:"data_list="+encodeURIComponent(_.base64Encode(e.data)),success:function(){e.success(e.len)},fail:function(){e.fail()}})}else e.success(e.len)},batchSend:function(){if(this.dataHasSend){var e,t,r=sa.store.mem.mdata;(t=(e=r.length>=100?r.slice(0,100):r).length)>0&&(this.dataHasSend=!1,this.wxrequest({data:e,len:t,success:this.batchRemove.bind(this),fail:this.sendFail.bind(this)}))}},sendFail:function(){this.dataHasSend=!0,this.failTime++},batchRemove:function(e){sa.store.mem.clear(e),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite(),this.failTime=0},is_first_batch_write:!0,batchWrite:function(){var e=this;this.dataHasChange&&(this.is_first_batch_write&&(this.is_first_batch_write=!1,setTimeout(function(){e.batchSend()},1e3)),this.dataHasChange=!1,this.syncStorage&&sa._.setStorageSync("sensors_mp_prepare_data",sa.store.mem.mdata))},batchInterval:function(){var e=this;!function t(){setTimeout(function(){e.batchWrite(),t()},500)}(),function t(){setTimeout(function(){e.batchSend(),t()},sa.para.batch_send.send_timeout*Math.pow(2,e.failTime))}()}},sa.setOpenid=function(e,t){sa.store.set("openid",e),t?sa.store.set("distinct_id",e):sa.identify(e,!0)},sa.initWithOpenid=function(e,t){(e=e||{}).appid&&(sa.para.appid=e.appid),sa.openid.getOpenid(function(r){r&&sa.setOpenid(r,e.isCoverLogin),t&&_.isFunction(t)&&t(r),sa.init(e)})},sa.setWebViewUrl=function(e,t){if(!_.isString(e)||""===e)return logger.info("error:\u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;e=decodeURIComponent(e);var r,s=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e),a=s[1]||"",n=s[2]||"",i=s[3]||"",o="",c=sa.store.getDistinctId()||"",u=sa.store.getFirstId()||"";_.urlSafeBase64&&_.urlSafeBase64.encode?c=c?_.urlSafeBase64.trim(_.urlSafeBase64.encode(_.urlBase64Encode(c))):"":this._.rot13obfs&&(c=c?_.rot13obfs(c):""),c=encodeURIComponent(c);var p=u?"f"+c:"d"+c;t?(r=i.indexOf("_sasdk"),o=i.indexOf("?")>-1?r>-1?a+n+"#"+i.substring(1,r)+"_sasdk="+p:a+n+"#"+i.substring(1)+"&_sasdk="+p:a+n+"#"+i.substring(1)+"?_sasdk="+p):(r=n.indexOf("_sasdk"),o=/^\?(\w)+/.test(n)?r>-1?a+"?"+n.substring(1,r)+"_sasdk="+p+i:a+"?"+n.substring(1)+"&_sasdk="+p+i:a+"?"+n.substring(1)+"_sasdk="+p+i);return o},_.each(["setProfile","setOnceProfile","track","quick","incrementProfile","appendProfile","login","logout","registerApp","register","clearAllRegister","clearAllProps","clearAppRegister"],function(e){var t=sa[e];sa[e]=function(){sa.initialState.isComplete?t.apply(sa,arguments):sa.initialState.queue.push([e,arguments])}}),_.setQuery=function(e,t){if(e&&_.isObject(e)&&!_.isEmptyObject(e)){var r=[];return _.each(e,function(e,s){"q"===s&&_.isString(e)&&0===e.indexOf("http")||(t?r.push(s+"="+e):r.push(s+"="+_.decodeURIComponent(e)))}),r.join("&")}return""},_.getUtmFromPage=function(){var e={};try{var t=getCurrentPages(),r=JSON.parse(JSON.stringify(t[t.length-1].options));for(var s in r)r[s]=_.decodeURIComponent(r[s]);e=_.getCustomUtmFromQuery(r,"$","_","$")}catch(e){logger.info(e)}return e},sa.autoTrackCustom={trackCustom:function(e,t,r){var s=sa.para.autoTrack[e],a="";sa.para.autoTrack&&s&&("function"==typeof s?(a=s(),_.isObject(a)&&_.extend(t,a)):_.isObject(s)&&(_.extend(t,s),sa.para.autoTrack[e]=!0),sa.track(r,t))},appLaunch:function(e,t){"object"!=typeof this||this.trackCustom||(this[sa.para.name]=sa);var r={};e&&e.scene?(current_scene=e.scene,r.$scene=_.getMPScene(e.scene)):r.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(r.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:r.$url_path})),_.setShareInfo(e,r);var s=_.setUtm(e,r);is_first_launch?(r.$is_first_time=!0,_.isEmptyObject(s.pre1)||sa.setOnceProfile(s.pre1)):r.$is_first_time=!1,_.setLatestChannel(s.pre2),_.setSfSource(e,r),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(e.query),t?(r=_.extend(r,t),sa.track("$MPLaunch",r)):sa.para.autoTrack&&sa.para.autoTrack.appLaunch&&sa.autoTrackCustom.trackCustom("appLaunch",r,"$MPLaunch")},appShow:function(e,t){var r={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,r.$scene=_.getMPScene(e.scene)):r.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(r.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:r.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,r);var s=_.setUtm(e,r);_.setLatestChannel(s.pre2),_.setSfSource(e,r),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(e.query),t?(r=_.extend(r,t),sa.track("$MPShow",r)):sa.para.autoTrack&&sa.para.autoTrack.appShow&&sa.autoTrackCustom.trackCustom("appShow",r,"$MPShow")},appHide:function(e){var t=(new Date).getTime(),r={};r.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(r.event_duration=(t-mpshow_time)/1e3),e?(r=_.extend(r,e),sa.track("$MPHide",r)):sa.para.autoTrack&&sa.para.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",r,"$MPHide"),sa.sendStrategy.onAppHide()}},sa.quick=function(){var e=arguments[0],t=arguments[1],r=arguments[2],s=_.isObject(r)?r:{};if("getAnonymousID"===e){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===e||"appShow"===e?t?sa.autoTrackCustom[e](t,s):logger.info("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(s=_.isObject(t)?t:{},sa.autoTrackCustom[e](s))},sa.appLaunch=function(e,t){var r={};e&&e.scene?(current_scene=e.scene,r.$scene=_.getMPScene(e.scene)):r.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(r.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:r.$url_path})),_.setShareInfo(e,r);var s=_.setUtm(e,r);is_first_launch?(r.$is_first_time=!0,_.isEmptyObject(s.pre1)||sa.setOnceProfile(s.pre1)):r.$is_first_time=!1,_.setLatestChannel(s.pre2),_.setSfSource(e,r),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(e.query),_.isObject(t)&&(r=_.extend(r,t)),sa.track("$MPLaunch",r)},sa.appShow=function(e,t){var r={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,r.$scene=_.getMPScene(e.scene)):r.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(r.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:r.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,r);var s=_.setUtm(e,r);_.setLatestChannel(s.pre2),_.setSfSource(e,r),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(e.query),_.isObject(t)&&(r=_.extend(r,t)),sa.track("$MPShow",r)},sa.appHide=function(e){var t=(new Date).getTime(),r={};r.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(r.event_duration=(t-mpshow_time)/1e3),_.isObject(e)&&(r=_.extend(r,e)),sa.track("$MPHide",r),sa.sendStrategy.onAppHide()},sa.pageShow=function(e){var t={},r=_.getCurrentPath(),s=_.getPageTitle(r),a={};try{var n=getCurrentPages();a=n[n.length-1]}catch(e){logger.info(e)}!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:r}),s&&(t.$title=s),t.$referrer=sa_referrer,t.$url_path=r,sa.status.last_referrer=sa_referrer,t.$url_query=a.sensors_mp_url_query?a.sensors_mp_url_query:"",t=_.extend(t,_.getUtmFromPage()),_.setPageSfSource(t),_.isObject(e)&&(t=_.extend(t,e)),sa.track("$MPViewScreen",t),sa_referrer=r,sa.status.referrer=r},sa.initial();export default sa; \ No newline at end of file diff --git a/sensorsdata.custom.min.js b/sensorsdata.custom.min.js index 3551cf3..58e6d75 100755 --- a/sensorsdata.custom.min.js +++ b/sensorsdata.custom.min.js @@ -1 +1 @@ -var _={},sa={para:{name:"sensors",server_url:"",send_timeout:1e3,show_log:!0,launched:!1,allow_amend_share_path:!0,max_string_length:300,datasend_timeout:3e3,source_channel:[],autoTrack:{appLaunch:!0,appShow:!0,appHide:!0,pageShow:!0,pageShare:!0,mpClick:!1,mpFavorite:!0},autotrack_exclude_page:{pageShow:[]},is_persistent_save:{share:!1,utm:!1},preset_properties:{url_path:!0},preset_events:{moments_page:!1,defer_track:!1},batch_send:!0}},mpHook={data:1,onLoad:1,onShow:1,onReady:1,onPullDownRefresh:1,onReachBottom:1,onShareAppMessage:1,onShareTimeline:1,onPullDownRefresh:1,onReachBottom:1,onPageScroll:1,onResize:1,onTabItemTap:1,onHide:1,onUnload:1},logger="object"==typeof logger?logger:{};logger.info=function(){if(sa.para.show_log&&"object"==typeof console&&console.log)try{if(3===arguments.length)return console.log(arguments[0],arguments[1],arguments[2]);if(2===arguments.length)return console.log(arguments[0],arguments[1]);if(1===arguments.length)return console.log(arguments[0])}catch(e){console.log(arguments[0])}},sa.setPara=function(e){sa.para=_.extend2Lev(sa.para,e);var t=[];if(_.isArray(sa.para.source_channel))for(var r=sa.para.source_channel.length,s=0;ssa.para.max_string_length?(logger.info("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,sa.para.max_string_length)):e},_.searchObjString=function(e){_.isObject(e)&&_.each(e,function(t,r){_.isObject(t)?_.searchObjString(e[r]):_.isString(t)&&(e[r]=_.formatString(t))})},_.parseSuperProperties=function(e){_.isObject(e)&&(_.each(e,function(t,r){if(_.isFunction(t))try{e[r]=t(),_.isFunction(e[r])&&(logger.info("\u60a8\u7684\u5c5e\u6027- "+r+" \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[r])}catch(t){delete e[r],logger.info("\u60a8\u7684\u5c5e\u6027- "+r+" \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}}),_.strip_sa_properties(e))},_.unique=function(e){for(var t,r=[],s={},a=0;a127&&i<2048?String.fromCharCode(i>>6|192,63&i|128):String.fromCharCode(i>>12|224,i>>6&63|128,63&i|128),null!==o&&(r>t&&(n+=e.substring(t,r)),n+=o,t=r=a+1)}return r>t&&(n+=e.substring(t,e.length)),n},_.base64Encode=function(e){var t,r,s,a,n,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,c=0,u="",p=[];if(!e)return e;e=_.utf8Encode(e);do{t=(n=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,r=n>>12&63,s=n>>6&63,a=63&n,p[c++]=i.charAt(t)+i.charAt(r)+i.charAt(s)+i.charAt(a)}while(o255||(s=e.charCodeAt(o++))>255||(a=e.charCodeAt(o++))>255)&&logger.info("Failed to execute 'btoa' : The string to be encoded contains characters outside of the Latin1 range."),i+=n.charAt((t=r<<16|s<<8|a)>>18&63)+n.charAt(t>>12&63)+n.charAt(t>>6&63)+n.charAt(63&t);return c?i.slice(0,c-3)+"===".substring(c):i},_.urlBase64Encode=function(e){return _.btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))},_.rot13obfs=function(e,t){t="number"==typeof t?t:13;for(var r=(e=String(e)).split(""),s=0,a=r.length;s(new Date).getTime()},_.getCurrentUrl=function(e){var t=_.getCurrentPath(),r="";return _.isObject(e)&&e.sensors_mp_encode_url_query&&(r=e.sensors_mp_encode_url_query),t?r?t+"?"+r:t:"\u672a\u53d6\u5230"},_.getPath=function(e){return e="string"==typeof e?e.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"},_.getMethods=function(e){var t=[];for(var r in e)"function"!=typeof e[r]||mpHook[r]||t.push(r);return t},_.isClick=function(e){return!!{tap:1,longpress:1,longtap:1}[e]},sa.initialState={queue:[],isComplete:!1,systemIsComplete:!1,storeIsComplete:!1,checkIsComplete:function(){this.systemIsComplete&&this.storeIsComplete&&(this.isComplete=!0,this.queue.length>0&&(_.each(this.queue,function(e){sa[e[0]].apply(sa,slice.call(e[1]))}),this.queue=[]))}},_.getCustomUtmFromQuery=function(e,t,r,s){if(!_.isObject(e))return{};var a={};if(e.sa_utm)for(var n in e)"sa_utm"!==n?_.include(sa.para.source_channel,n)&&(a[r+n]=e[n]):a[s+n]=e[n];else for(var n in e)-1===(" "+source_channel_standard+" ").indexOf(" "+n+" ")?_.include(sa.para.source_channel,n)&&(a[r+n]=e[n]):a[t+n]=e[n];return a},_.getObjFromQuery=function(e){var t=e.split("?"),r=[],s={};return t&&t[1]?(_.each(t[1].split("&"),function(e){(r=e.split("="))[0]&&r[1]&&(s[r[0]]=r[1])}),s):{}},_.setStorageSync=function(e,t){var r=function(){wx.setStorageSync(e,t)};try{r()}catch(e){logger.info("set Storage fail --",e);try{r()}catch(e){logger.info("set Storage fail again --",e)}}},_.getStorageSync=function(e){var t="";try{t=wx.getStorageSync(e)}catch(r){try{t=wx.getStorageSync(e)}catch(e){logger.info("getStorage fail")}}return t},_.getMPScene=function(e){return"number"==typeof e||"string"==typeof e&&""!==e?e="wx-"+String(e):"\u672a\u53d6\u5230\u503c"},_.setShareInfo=function(e,t){var r={},s={},a=sa.store.getDistinctId(),n=sa.store.getFirstId();if(!(e&&_.isObject(e.query)&&e.query.sampshare))return{};if(r=_.decodeURIComponent(e.query.sampshare),!_.isJSONString(r))return{};var i=(r=JSON.parse(r)).d,o=r.p,c=r.i,u=r.m;"string"==typeof c?(t.$share_distinct_id=c,share_distinct_id=c,s.$latest_share_distinct_id=c):t.$share_distinct_id="\u53d6\u503c\u5f02\u5e38","number"==typeof i?!share_distinct_id||share_distinct_id!==a&&share_distinct_id!==n?!share_distinct_id||share_distinct_id===a&&share_distinct_id===n?t.$share_depth="-1":(t.$share_depth=i+1,query_share_depth=i+1,s.$latest_share_depth=i+1):(t.$share_depth=i,query_share_depth=i,s.$latest_share_depth=i):t.$share_depth="-1","string"==typeof o?(t.$share_url_path=o,s.$latest_share_url_path=o):t.$share_url_path="\u53d6\u503c\u5f02\u5e38","string"==typeof u?(t.$share_method=u,s.$latest_share_method=u):t.$share_method="\u53d6\u503c\u5f02\u5e38",_.setLatestShare(s)},_.getShareInfo=function(){return JSON.stringify({i:sa.store.getDistinctId()||"\u53d6\u503c\u5f02\u5e38",p:_.getCurrentPath(),d:query_share_depth,m:share_method})},_.detectOptionQuery=function(e){if(!e||!_.isObject(e.query))return{};var t,r,s,a,n={};return n.query=_.extend({},e.query),"string"==typeof n.query.scene&&(t=n.query,r=["utm_source","utm_content","utm_medium","utm_campaign","utm_term","sa_utm"].concat(sa.para.source_channel),s=new RegExp("("+r.join("|")+")%3D","i"),1===(a=Object.keys(t)).length&&"scene"===a[0]&&s.test(t.scene))&&(n.scene=n.query.scene,delete n.query.scene),e.query.q&&e.query.scancode_time&&"101"===String(e.scene).slice(0,3)&&(n.q=String(n.query.q),delete n.query.q,delete n.query.scancode_time),n},_.getMixedQuery=function(e){var t=_.detectOptionQuery(e),r=t.scene,s=t.q,a=t.query;for(var n in a)a[n]=_.decodeURIComponent(a[n]);return r&&(r=-1!==(r=_.decodeURIComponent(r)).indexOf("?")?"?"+r.replace(/\?/g,""):"?"+r,_.extend(a,_.getObjFromQuery(r))),s&&_.extend(a,_.getObjFromQuery(_.decodeURIComponent(s))),a},_.setUtm=function(e,t){var r={},s=_.getMixedQuery(e),a=_.getCustomUtmFromQuery(s,"$","_","$"),n=_.getCustomUtmFromQuery(s,"$latest_","_latest_","$latest_");return r.pre1=a,r.pre2=n,_.extend(t,a),r},_.setSfSource=function(e,t){!_.isEmptyObject(e.query)&&e.query._sfs&&(t.$sf_source=e.query._sfs,sa.registerApp({$latest_sf_source:t.$sf_source}))},_.setPageSfSource=function(e){try{var t=getCurrentPages(),r=JSON.parse(JSON.stringify(t[t.length-1].options));for(var s in r)r[s]=_.decodeURIComponent(r[s]);!_.isEmptyObject(r)&&r._sfs&&(e.$sf_source=r._sfs)}catch(e){logger.info(e)}};try{var oldSetNavigationBarTitle=wx.setNavigationBarTitle;Object.defineProperty(wx,"setNavigationBarTitle",{get:function(){return function(e){var t=getCurrentPages(),r=t[t.length-1].route||"";e=_.isObject(e)?e:{},globalTitle[r]=e.title,oldSetNavigationBarTitle.call(this,e)}}})}catch(e){logger.info(e)}_.getPageTitle=function(e){if("\u672a\u53d6\u5230"===e||!e)return!1;var t="";try{if(__wxConfig){var r=__wxConfig,s=r.page[e]||r.page[e+".html"],a={},n={};if(r.global&&r.global.window&&r.global.window.navigationBarTitleText&&(a.titleVal=r.global.window.navigationBarTitleText),s&&s.window&&s.window.navigationBarTitleText&&(n.titleVal=s.window.navigationBarTitleText),_.each(globalTitle,function(r,s){if(s===e)return t=r}),0===t.length){var i=_.extend(a,n);t=i.titleVal}}}catch(e){logger.info(e)}return t},_.wxrequest=function(e){if(_.compareSDKVersion(wxSDKVersion,"2.10.0")>=0)e.timeout=sa.para.datasend_timeout,wx.request(e);else{var t=wx.request(e);setTimeout(function(){_.isObject(t)&&_.isFunction(t.abort)&&t.abort()},sa.para.datasend_timeout)}},_.getAppId=function(){var e;if(wx.getAccountInfoSync&&(e=wx.getAccountInfoSync()),_.isObject(e)&&_.isObject(e.miniProgram))return e.miniProgram.appId},_.validId=function(e){return"string"!=typeof e&&"number"!=typeof e||""===e?(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1):"number"!=typeof e||(e=String(e),/^\d+$/.test(e))?e:(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1)},_.compareSDKVersion=function(e,t){e=e.split("."),t=t.split(".");for(var r=Math.max(e.length,t.length);e.lengthn)return 1;if(a-1?t.system.split(" ")[1]:t.system,wxSDKVersion=t.SDKVersion},complete:function(){var t=(new Date).getTimezoneOffset(),r=_.getAppId();_.isNumber(t)&&(e.$timezone_offset=t),r&&(e.$app_id=r),sa.initialState.systemIsComplete=!0,sa.initialState.checkIsComplete()}})}wx.getNetworkType({success:function(t){e.$network_type=_.setUpperCase(t.networkType)},complete:t})}},sa._=_,_.eventEmitter=function(){this.sub=[]},_.eventEmitter.prototype={add:function(e){this.sub.push(e)},emit:function(e,t){this.sub.forEach(function(r){r.on(e,t)})}},_.eventSub=function(e){sa.events.add(this),this._events=[],this.handle=e,this.ready=!1},_.eventSub.prototype={on:function(e,t){if(this.ready){if(_.isFunction(this.handle))try{this.handle(e,t)}catch(e){logger.info(e)}}else this._events.push({event:e,data:t})},isReady:function(){var e=this;e.ready=!0,e._events.forEach(function(t){if(_.isFunction(e.handle))try{e.handle(t.event,t.data)}catch(e){logger.info(e)}})}},sa.eventSub=_.eventSub,sa.events=new _.eventEmitter,sa.usePlugin=function(e,t){"function"==typeof e.init&&e.init(sa,t)},sa.prepareData=function(e,t){if(current_scene&&1154===current_scene&&!sa.para.preset_events.moments_page)return!1;var r={distinct_id:this.store.getDistinctId(),lib:{$lib:LIB_NAME,$lib_method:"code",$lib_version:String(LIB_VERSION)},properties:{}};_.extend(r,this.store.getUnionId(),e),_.isObject(e.properties)&&!_.isEmptyObject(e.properties)&&_.extend(r.properties,e.properties),e.type&&"profile"===e.type.slice(0,7)||(r._track_id=Number(String(Math.random()).slice(2,5)+String(Math.random()).slice(2,4)+String(Date.now()).slice(-4)),r.properties=_.extend({},_.info.properties,sa.store.getProps(),_.info.currentProps,r.properties),r.properties.$is_first_day=_.getIsFirstDay()),r.properties.$time&&_.isDate(r.properties.$time)?(r.time=1*r.properties.$time,delete r.properties.$time):r.time=1*new Date,_.parseSuperProperties(r.properties),_.searchObjDate(r),_.searchObjString(r),logger.info(r),sa.events.emit("send",r),sa.sendStrategy.send(r)},sa.store={storageInfo:null,getUUID:function(){return Date.now()+"-"+Math.floor(1e7*Math.random())+"-"+Math.random().toString(16).replace(".","")+"-"+String(31242*Math.random()).replace(".","").slice(0,8)},getStorage:function(){return this.storageInfo?this.storageInfo:(this.storageInfo=sa._.getStorageSync("sensorsdata2015_wechat")||"",this.storageInfo)},_state:{},mem:{mdata:[],getLength:function(){return this.mdata.length},add:function(e){this.mdata.push(e)},clear:function(e){this.mdata.splice(0,e)}},toState:function(e){var t=null;_.isJSONString(e)?(t=JSON.parse(e)).distinct_id?this._state=t:this.set("distinct_id",this.getUUID()):_.isObject(e)&&(t=e).distinct_id?this._state=t:this.set("distinct_id",this.getUUID())},getFirstId:function(){return this._state._first_id||this._state.first_id},getDistinctId:function(){return this._state._distinct_id||this._state.distinct_id},getUnionId:function(){var e={},t=this._state._first_id||this._state.first_id,r=this._state._distinct_id||this._state.distinct_id;return t&&r?(e.login_id=r,e.anonymous_id=t):e.anonymous_id=r,e},getProps:function(){return this._state.props||{}},setProps:function(e,t){var r=this._state.props||{};t?this.set("props",e):(_.extend(r,e),this.set("props",r))},set:function(e,t){var r={};for(var s in"string"==typeof e?r[e]=t:"object"==typeof e&&(r=e),this._state=this._state||{},r)this._state[s]=r[s],"first_id"===s?delete this._state._first_id:"distinct_id"===s&&(delete this._state._distinct_id,sa.events.emit("changeDistinctId"));this.save()},change:function(e,t){this._state["_"+e]=t},encryptStorage:function(){var e=this.getStorage(),t="data:enc;";_.isObject(e)?e=t+_.rot13obfs(JSON.stringify(e)):_.isString(e)&&-1===e.indexOf(t)&&(e=t+_.rot13obfs(e)),sa._.setStorageSync("sensorsdata2015_wechat",e)},save:function(){var e=JSON.parse(JSON.stringify(this._state));if(delete e._first_id,delete e._distinct_id,sa.para.encrypt_storage){e="data:enc;"+_.rot13obfs(JSON.stringify(e))}sa._.setStorageSync("sensorsdata2015_wechat",e)},init:function(){var e=this.getStorage();if(e)_.isString(e)&&-1!==e.indexOf("data:enc;")&&(e=e.substring("data:enc;".length),e=JSON.parse(_.rot13defs(e))),this.toState(e);else{is_first_launch=!0;var t=new Date,r=t.getTime();t.setHours(23),t.setMinutes(59),t.setSeconds(60),sa.setOnceProfile({$first_visit_time:new Date}),this.set({distinct_id:this.getUUID(),first_visit_time:r,first_visit_day_time:t.getTime()})}}},sa.setProfile=function(e,t){sa.prepareData({type:"profile_set",properties:e},t)},sa.setOnceProfile=function(e,t){sa.prepareData({type:"profile_set_once",properties:e},t)},sa.appendProfile=function(e,t){if(!_.isObject(e))return!1;_.each(e,function(t,r){_.isString(t)?e[r]=[t]:_.isArray(t)||(delete e[r],logger.info("appendProfile\u5c5e\u6027\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32\u6216\u8005\u6570\u7ec4"))}),sa.prepareData({type:"profile_append",properties:e},t)},sa.incrementProfile=function(e,t){if(!_.isObject(e))return!1;var r=e;_.isString(e)&&((e={})[r]=1),sa.prepareData({type:"profile_increment",properties:e},t)},sa.track=function(e,t,r){this.prepareData({type:"track",event:e,properties:t},r)},sa.identify=function(e,t){if(e=_.validId(e)){var r=sa.store.getFirstId();!0===t?r?sa.store.set("first_id",e):sa.store.set("distinct_id",e):r?sa.store.change("first_id",e):sa.store.change("distinct_id",e)}},sa.trackSignup=function(e,t,r,s){var a=sa.store.getFirstId()||sa.store.getDistinctId();sa.store.set("distinct_id",e),sa.prepareData({original_id:a,distinct_id:e,type:"track_signup",event:t,properties:r},s)},sa.registerApp=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&(_.info.currentProps=_.extend(_.info.currentProps,e))},sa.register=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&sa.store.setProps(e)},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.clearAllProps=function(e){var t=sa.store.getProps(),r={};_.isArray(e)&&(_.each(t,function(t,s){_.include(e,s)||(r[s]=t)}),sa.store.setProps(r,!0))},sa.clearAppRegister=function(e){_.isArray(e)&&_.each(_.info.currentProps,function(t,r){_.include(e,r)&&delete _.info.currentProps[r]})},_.setLatestChannel=function(e){_.isEmptyObject(e)||(function(e,t){var r=!1;for(var s in t)e[t[s]]&&(r=!0);return r}(e,latest_source_channel)&&(sa.clearAppRegister(latest_source_channel),sa.clearAllProps(latest_source_channel)),sa.para.is_persistent_save.utm?sa.register(e):sa.registerApp(e))},_.setLatestShare=function(e){(e.$latest_share_depth||e.$latest_share_distinct_id||e.$latest_share_url_path||e.$latest_share_method)&&(sa.clearAppRegister(latest_share_info),sa.clearAllProps(latest_share_info),sa.para.is_persistent_save.share?sa.register(e):sa.registerApp(e))},sa.login=function(e){if(e=_.validId(e)){var t=sa.store.getFirstId(),r=sa.store.getDistinctId();e!==r&&(t?sa.trackSignup(e,"$SignUp"):(sa.store.set("first_id",r),sa.trackSignup(e,"$SignUp")))}},sa.getAnonymousID=function(){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")},sa.logout=function(e){var t=sa.store.getFirstId();t?(sa.store.set("first_id",""),!0===e?sa.store.set("distinct_id",sa.store.getUUID()):sa.store.set("distinct_id",t)):logger.info("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25")},sa.getLocation=function(){wx.getSetting({success:function(e){if(!e.authSetting["scope.userLocation"])return!1;wx.getLocation({type:sa.para.preset_properties.location.type,success:function(e){sa.registerApp({$latitude:e.latitude*Math.pow(10,6),$longitude:e.longitude*Math.pow(10,6),$geo_coordinate_system:_.setUpperCase(sa.para.preset_properties.location.type)})},fail:function(e){console.log("\u83b7\u53d6\u4f4d\u7f6e\u5931\u8d25",e)}})}})},sa.openid={getRequest:function(e){wx.login({success:function(t){t.code&&sa.para.appid&&sa.para.openid_url?_.wxrequest({url:sa.para.openid_url+"&code="+t.code+"&appid="+sa.para.appid,method:"GET",complete:function(t){_.isObject(t)&&_.isObject(t.data)&&t.data.openid?e(t.data.openid):e()}}):e()}})},getWXStorage:function(){var e=sa.store.getStorage();if(e&&_.isObject(e))return e.openid},getOpenid:function(e){if(!sa.para.appid)return e(),!1;var t=this.getWXStorage();t?e(t):this.getRequest(e)}},sa.initial=function(){this._.info.getSystem(),this.store.init()},sa.init=function(e){if(!0===this.hasInit)return!1;this.hasInit=!0,sa.setPara(e),sa.para.encrypt_storage&&this.store.encryptStorage(),sa.para.batch_send&&(wx.getStorage({key:"sensors_mp_prepare_data",complete:function(e){var t=e.data&&_.isArray(e.data)?e.data:[];sa.store.mem.mdata=t.concat(sa.store.mem.mdata),sa.sendStrategy.syncStorage=!0}}),sa.sendStrategy.batchInterval()),sa.initialState.storeIsComplete=!0,sa.initialState.checkIsComplete()},sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib){var e={};_.each(_.info.currentProps,function(t,r){0===r.indexOf("$")&&(e[r]=t)});var t=_.extend(e,{$url_path:_.getCurrentPath(),$is_first_day:_.getIsFirstDay()},_.info.properties,sa.store.getProps());return delete t.$lib,t}return{}},_.autoExeQueue=function(){return{items:[],enqueue:function(e){this.items.push(e),this.start()},dequeue:function(){return this.items.shift()},getCurrentItem:function(){return this.items[0]},isRun:!1,start:function(){this.items.length>0&&!this.isRun&&(this.isRun=!0,this.getCurrentItem().start())},close:function(){this.dequeue(),this.isRun=!1,this.start()}}},sa.requestQueue=function(e){this.url=e.url},sa.requestQueue.prototype.isEnd=function(){this.received||(this.received=!0,this.close())},sa.requestQueue.prototype.start=function(){var e=this;_.wxrequest({url:this.url,method:"GET",complete:function(){e.isEnd()}})},sa.dataQueue=_.autoExeQueue(),sa.sendStrategy={dataHasSend:!0,dataHasChange:!1,syncStorage:!1,failTime:0,onAppHide:function(){sa.para.batch_send&&this.batchSend()},send:function(e){if(!sa.para.server_url)return!1;if(sa.para.batch_send){if(this.dataHasChange=!0,sa.store.mem.getLength()>=300)return logger.info("\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38"),!1;sa.store.mem.add(e),sa.store.mem.getLength()>=sa.para.batch_send.max_length&&this.batchSend()}else this.queueSend(e)},queueSend:function(e){e._flush_time=Date.now(),e=JSON.stringify(e),e=-1!==sa.para.server_url.indexOf("?")?sa.para.server_url+"&data="+encodeURIComponent(_.base64Encode(e)):sa.para.server_url+"?data="+encodeURIComponent(_.base64Encode(e));var t=new sa.requestQueue({url:e});t.close=function(){sa.dataQueue.close()},sa.dataQueue.enqueue(t)},wxrequest:function(e){if(_.isArray(e.data)&&e.data.length>0){var t=Date.now();e.data.forEach(function(e){e._flush_time=t}),e.data=JSON.stringify(e.data),_.wxrequest({url:sa.para.server_url,method:"POST",dataType:"text",data:"data_list="+encodeURIComponent(_.base64Encode(e.data)),success:function(){e.success(e.len)},fail:function(){e.fail()}})}else e.success(e.len)},batchSend:function(){if(this.dataHasSend){var e=sa.store.mem.mdata,t=e.length;t>0&&(this.dataHasSend=!1,this.wxrequest({data:e,len:t,success:this.batchRemove.bind(this),fail:this.sendFail.bind(this)}))}},sendFail:function(){this.dataHasSend=!0,this.failTime++},batchRemove:function(e){sa.store.mem.clear(e),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite(),this.failTime=0},is_first_batch_write:!0,batchWrite:function(){var e=this;this.dataHasChange&&(this.is_first_batch_write&&(this.is_first_batch_write=!1,setTimeout(function(){e.batchSend()},1e3)),this.dataHasChange=!1,this.syncStorage&&sa._.setStorageSync("sensors_mp_prepare_data",sa.store.mem.mdata))},batchInterval:function(){var e=this;!function t(){setTimeout(function(){e.batchWrite(),t()},500)}(),function t(){setTimeout(function(){e.batchSend(),t()},sa.para.batch_send.send_timeout*Math.pow(2,e.failTime))}()}},sa.setOpenid=function(e,t){sa.store.set("openid",e),t?sa.store.set("distinct_id",e):sa.identify(e,!0)},sa.initWithOpenid=function(e,t){(e=e||{}).appid&&(sa.para.appid=e.appid),sa.openid.getOpenid(function(r){r&&sa.setOpenid(r,e.isCoverLogin),t&&_.isFunction(t)&&t(r),sa.init(e)})},sa.setWebViewUrl=function(e,t){if(!_.isString(e)||""===e)return logger.info("error:\u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;e=decodeURIComponent(e);var r,s=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e),a=s[1]||"",n=s[2]||"",i=s[3]||"",o="",c=sa.store.getDistinctId()||"",u=sa.store.getFirstId()||"";_.urlSafeBase64&&_.urlSafeBase64.encode?c=c?_.urlSafeBase64.trim(_.urlSafeBase64.encode(_.urlBase64Encode(c))):"":this._.rot13obfs&&(c=c?_.rot13obfs(c):""),c=encodeURIComponent(c);var p=u?"f"+c:"d"+c;t?(r=i.indexOf("_sasdk"),o=i.indexOf("?")>-1?r>-1?a+n+"#"+i.substring(1,r)+"_sasdk="+p:a+n+"#"+i.substring(1)+"&_sasdk="+p:a+n+"#"+i.substring(1)+"?_sasdk="+p):(r=n.indexOf("_sasdk"),o=/^\?(\w)+/.test(n)?r>-1?a+"?"+n.substring(1,r)+"_sasdk="+p+i:a+"?"+n.substring(1)+"&_sasdk="+p+i:a+"?"+n.substring(1)+"_sasdk="+p+i);return o},_.each(["setProfile","setOnceProfile","track","quick","incrementProfile","appendProfile","login","logout","registerApp","register","clearAllRegister","clearAllProps","clearAppRegister"],function(e){var t=sa[e];sa[e]=function(){sa.initialState.isComplete?t.apply(sa,arguments):sa.initialState.queue.push([e,arguments])}}),_.setQuery=function(e,t){if(e&&_.isObject(e)&&!_.isEmptyObject(e)){var r=[];return _.each(e,function(e,s){"q"===s&&_.isString(e)&&0===e.indexOf("http")||(t?r.push(s+"="+e):r.push(s+"="+_.decodeURIComponent(e)))}),r.join("&")}return""},_.getUtmFromPage=function(){var e={};try{var t=getCurrentPages(),r=JSON.parse(JSON.stringify(t[t.length-1].options));for(var s in r)r[s]=_.decodeURIComponent(r[s]);e=_.getCustomUtmFromQuery(r,"$","_","$")}catch(e){logger.info(e)}return e},sa.autoTrackCustom={trackCustom:function(e,t,r){var s=sa.para.autoTrack[e],a="";sa.para.autoTrack&&s&&("function"==typeof s?(a=s(),_.isObject(a)&&_.extend(t,a)):_.isObject(s)&&(_.extend(t,s),sa.para.autoTrack[e]=!0),sa.track(r,t))},appLaunch:function(e,t){"object"!=typeof this||this.trackCustom||(this[sa.para.name]=sa);var r={};e&&e.scene?(current_scene=e.scene,r.$scene=_.getMPScene(e.scene)):r.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(r.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:r.$url_path})),_.setShareInfo(e,r);var s=_.setUtm(e,r);is_first_launch?(r.$is_first_time=!0,_.isEmptyObject(s.pre1)||sa.setOnceProfile(s.pre1)):r.$is_first_time=!1,_.setLatestChannel(s.pre2),_.setSfSource(e,r),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(e.query),t?(r=_.extend(r,t),sa.track("$MPLaunch",r)):sa.para.autoTrack&&sa.para.autoTrack.appLaunch&&sa.autoTrackCustom.trackCustom("appLaunch",r,"$MPLaunch")},appShow:function(e,t){var r={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,r.$scene=_.getMPScene(e.scene)):r.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(r.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:r.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,r);var s=_.setUtm(e,r);_.setLatestChannel(s.pre2),_.setSfSource(e,r),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(e.query),t?(r=_.extend(r,t),sa.track("$MPShow",r)):sa.para.autoTrack&&sa.para.autoTrack.appShow&&sa.autoTrackCustom.trackCustom("appShow",r,"$MPShow")},appHide:function(e){var t=(new Date).getTime(),r={};r.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(r.event_duration=(t-mpshow_time)/1e3),e?(r=_.extend(r,e),sa.track("$MPHide",r)):sa.para.autoTrack&&sa.para.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",r,"$MPHide"),sa.sendStrategy.onAppHide()}},sa.quick=function(){var e=arguments[0],t=arguments[1],r=arguments[2],s=_.isObject(r)?r:{};if("getAnonymousID"===e){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===e||"appShow"===e?t?sa.autoTrackCustom[e](t,s):logger.info("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(s=_.isObject(t)?t:{},sa.autoTrackCustom[e](s))},sa.appLaunch=function(e,t){var r={};e&&e.scene?(current_scene=e.scene,r.$scene=_.getMPScene(e.scene)):r.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(r.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:r.$url_path})),_.setShareInfo(e,r);var s=_.setUtm(e,r);is_first_launch?(r.$is_first_time=!0,_.isEmptyObject(s.pre1)||sa.setOnceProfile(s.pre1)):r.$is_first_time=!1,_.setLatestChannel(s.pre2),_.setSfSource(e,r),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(e.query),_.isObject(t)&&(r=_.extend(r,t)),sa.track("$MPLaunch",r)},sa.appShow=function(e,t){var r={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,r.$scene=_.getMPScene(e.scene)):r.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(r.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:r.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,r);var s=_.setUtm(e,r);_.setLatestChannel(s.pre2),_.setSfSource(e,r),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(e.query),_.isObject(t)&&(r=_.extend(r,t)),sa.track("$MPShow",r)},sa.appHide=function(e){var t=(new Date).getTime(),r={};r.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(r.event_duration=(t-mpshow_time)/1e3),_.isObject(e)&&(r=_.extend(r,e)),sa.track("$MPHide",r),sa.sendStrategy.onAppHide()},sa.pageShow=function(e){var t={},r=_.getCurrentPath(),s=_.getPageTitle(r),a={};try{var n=getCurrentPages();a=n[n.length-1]}catch(e){logger.info(e)}!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:r}),s&&(t.$title=s),t.$referrer=sa_referrer,t.$url_path=r,sa.status.last_referrer=sa_referrer,t.$url_query=a.sensors_mp_url_query?a.sensors_mp_url_query:"",t=_.extend(t,_.getUtmFromPage()),_.setPageSfSource(t),_.isObject(e)&&(t=_.extend(t,e)),sa.track("$MPViewScreen",t),sa_referrer=r,sa.status.referrer=r},sa.initial(),module.exports=sa; \ No newline at end of file +var _={},sa={para:{name:"sensors",server_url:"",send_timeout:1e3,show_log:!0,launched:!1,allow_amend_share_path:!0,max_string_length:300,datasend_timeout:3e3,source_channel:[],autoTrack:{appLaunch:!0,appShow:!0,appHide:!0,pageShow:!0,pageShare:!0,mpClick:!1,mpFavorite:!0},autotrack_exclude_page:{pageShow:[]},is_persistent_save:{share:!1,utm:!1},preset_properties:{url_path:!0},preset_events:{moments_page:!1,defer_track:!1},batch_send:!0}},mpHook={data:1,onLoad:1,onShow:1,onReady:1,onPullDownRefresh:1,onReachBottom:1,onShareAppMessage:1,onShareTimeline:1,onPullDownRefresh:1,onReachBottom:1,onPageScroll:1,onResize:1,onTabItemTap:1,onHide:1,onUnload:1},logger="object"==typeof logger?logger:{};logger.info=function(){if(sa.para.show_log&&"object"==typeof console&&console.log)try{if(3===arguments.length)return console.log(arguments[0],arguments[1],arguments[2]);if(2===arguments.length)return console.log(arguments[0],arguments[1]);if(1===arguments.length)return console.log(arguments[0])}catch(e){console.log(arguments[0])}},sa.setPara=function(e){sa.para=_.extend2Lev(sa.para,e);var t=[];if(_.isArray(sa.para.source_channel))for(var r=sa.para.source_channel.length,s=0;ssa.para.max_string_length?(logger.info("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,sa.para.max_string_length)):e},_.searchObjString=function(e){_.isObject(e)&&_.each(e,function(t,r){_.isObject(t)?_.searchObjString(e[r]):_.isString(t)&&(e[r]=_.formatString(t))})},_.parseSuperProperties=function(e){_.isObject(e)&&(_.each(e,function(t,r){if(_.isFunction(t))try{e[r]=t(),_.isFunction(e[r])&&(logger.info("\u60a8\u7684\u5c5e\u6027- "+r+" \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[r])}catch(t){delete e[r],logger.info("\u60a8\u7684\u5c5e\u6027- "+r+" \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}}),_.strip_sa_properties(e))},_.unique=function(e){for(var t,r=[],s={},a=0;a127&&i<2048?String.fromCharCode(i>>6|192,63&i|128):String.fromCharCode(i>>12|224,i>>6&63|128,63&i|128),null!==o&&(r>t&&(n+=e.substring(t,r)),n+=o,t=r=a+1)}return r>t&&(n+=e.substring(t,e.length)),n},_.base64Encode=function(e){var t,r,s,a,n,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,c=0,u="",p=[];if(!e)return e;e=_.utf8Encode(e);do{t=(n=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,r=n>>12&63,s=n>>6&63,a=63&n,p[c++]=i.charAt(t)+i.charAt(r)+i.charAt(s)+i.charAt(a)}while(o255||(s=e.charCodeAt(o++))>255||(a=e.charCodeAt(o++))>255)&&logger.info("Failed to execute 'btoa' : The string to be encoded contains characters outside of the Latin1 range."),i+=n.charAt((t=r<<16|s<<8|a)>>18&63)+n.charAt(t>>12&63)+n.charAt(t>>6&63)+n.charAt(63&t);return c?i.slice(0,c-3)+"===".substring(c):i},_.urlBase64Encode=function(e){return _.btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))},_.rot13obfs=function(e,t){t="number"==typeof t?t:13;for(var r=(e=String(e)).split(""),s=0,a=r.length;s(new Date).getTime()},_.getCurrentUrl=function(e){var t=_.getCurrentPath(),r="";return _.isObject(e)&&e.sensors_mp_encode_url_query&&(r=e.sensors_mp_encode_url_query),t?r?t+"?"+r:t:"\u672a\u53d6\u5230"},_.getPath=function(e){return e="string"==typeof e?e.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"},_.getMethods=function(e){var t=[];for(var r in e)"function"!=typeof e[r]||mpHook[r]||t.push(r);return t},_.isClick=function(e){return!!{tap:1,longpress:1,longtap:1}[e]},sa.initialState={queue:[],isComplete:!1,systemIsComplete:!1,storeIsComplete:!1,checkIsComplete:function(){this.systemIsComplete&&this.storeIsComplete&&(this.isComplete=!0,this.queue.length>0&&(_.each(this.queue,function(e){sa[e[0]].apply(sa,slice.call(e[1]))}),this.queue=[]))}},_.getCustomUtmFromQuery=function(e,t,r,s){if(!_.isObject(e))return{};var a={};if(e.sa_utm)for(var n in e)"sa_utm"!==n?_.include(sa.para.source_channel,n)&&(a[r+n]=e[n]):a[s+n]=e[n];else for(var n in e)-1===(" "+source_channel_standard+" ").indexOf(" "+n+" ")?_.include(sa.para.source_channel,n)&&(a[r+n]=e[n]):a[t+n]=e[n];return a},_.getObjFromQuery=function(e){var t=e.split("?"),r=[],s={};return t&&t[1]?(_.each(t[1].split("&"),function(e){(r=e.split("="))[0]&&r[1]&&(s[r[0]]=r[1])}),s):{}},_.setStorageSync=function(e,t){var r=function(){wx.setStorageSync(e,t)};try{r()}catch(e){logger.info("set Storage fail --",e);try{r()}catch(e){logger.info("set Storage fail again --",e)}}},_.getStorageSync=function(e){var t="";try{t=wx.getStorageSync(e)}catch(r){try{t=wx.getStorageSync(e)}catch(e){logger.info("getStorage fail")}}return t},_.getMPScene=function(e){return"number"==typeof e||"string"==typeof e&&""!==e?e="wx-"+String(e):"\u672a\u53d6\u5230\u503c"},_.setShareInfo=function(e,t){var r={},s={},a=sa.store.getDistinctId(),n=sa.store.getFirstId();if(!(e&&_.isObject(e.query)&&e.query.sampshare))return{};if(r=_.decodeURIComponent(e.query.sampshare),!_.isJSONString(r))return{};var i=(r=JSON.parse(r)).d,o=r.p,c=r.i,u=r.m;"string"==typeof c?(t.$share_distinct_id=c,share_distinct_id=c,s.$latest_share_distinct_id=c):t.$share_distinct_id="\u53d6\u503c\u5f02\u5e38","number"==typeof i?!share_distinct_id||share_distinct_id!==a&&share_distinct_id!==n?!share_distinct_id||share_distinct_id===a&&share_distinct_id===n?t.$share_depth="-1":(t.$share_depth=i+1,query_share_depth=i+1,s.$latest_share_depth=i+1):(t.$share_depth=i,query_share_depth=i,s.$latest_share_depth=i):t.$share_depth="-1","string"==typeof o?(t.$share_url_path=o,s.$latest_share_url_path=o):t.$share_url_path="\u53d6\u503c\u5f02\u5e38","string"==typeof u?(t.$share_method=u,s.$latest_share_method=u):t.$share_method="\u53d6\u503c\u5f02\u5e38",_.setLatestShare(s)},_.getShareInfo=function(){return JSON.stringify({i:sa.store.getDistinctId()||"\u53d6\u503c\u5f02\u5e38",p:_.getCurrentPath(),d:query_share_depth,m:share_method})},_.detectOptionQuery=function(e){if(!e||!_.isObject(e.query))return{};var t,r,s,a,n={};return n.query=_.extend({},e.query),"string"==typeof n.query.scene&&(t=n.query,r=["utm_source","utm_content","utm_medium","utm_campaign","utm_term","sa_utm"].concat(sa.para.source_channel),s=new RegExp("("+r.join("|")+")%3D","i"),1===(a=Object.keys(t)).length&&"scene"===a[0]&&s.test(t.scene))&&(n.scene=n.query.scene,delete n.query.scene),e.query.q&&e.query.scancode_time&&"101"===String(e.scene).slice(0,3)&&(n.q=String(n.query.q),delete n.query.q,delete n.query.scancode_time),n},_.getMixedQuery=function(e){var t=_.detectOptionQuery(e),r=t.scene,s=t.q,a=t.query;for(var n in a)a[n]=_.decodeURIComponent(a[n]);return r&&(r=-1!==(r=_.decodeURIComponent(r)).indexOf("?")?"?"+r.replace(/\?/g,""):"?"+r,_.extend(a,_.getObjFromQuery(r))),s&&_.extend(a,_.getObjFromQuery(_.decodeURIComponent(s))),a},_.setUtm=function(e,t){var r={},s=_.getMixedQuery(e),a=_.getCustomUtmFromQuery(s,"$","_","$"),n=_.getCustomUtmFromQuery(s,"$latest_","_latest_","$latest_");return r.pre1=a,r.pre2=n,_.extend(t,a),r},_.setSfSource=function(e,t){!_.isEmptyObject(e.query)&&e.query._sfs&&(t.$sf_source=e.query._sfs,sa.registerApp({$latest_sf_source:t.$sf_source}))},_.setPageSfSource=function(e){try{var t=getCurrentPages(),r=JSON.parse(JSON.stringify(t[t.length-1].options));for(var s in r)r[s]=_.decodeURIComponent(r[s]);!_.isEmptyObject(r)&&r._sfs&&(e.$sf_source=r._sfs)}catch(e){logger.info(e)}};try{var oldSetNavigationBarTitle=wx.setNavigationBarTitle;Object.defineProperty(wx,"setNavigationBarTitle",{get:function(){return function(e){var t=getCurrentPages(),r=t[t.length-1].route||"";e=_.isObject(e)?e:{},globalTitle[r]=e.title,oldSetNavigationBarTitle.call(this,e)}}})}catch(e){logger.info(e)}_.getPageTitle=function(e){if("\u672a\u53d6\u5230"===e||!e)return!1;var t="";try{if(__wxConfig){var r=__wxConfig,s=r.page[e]||r.page[e+".html"],a={},n={};if(r.global&&r.global.window&&r.global.window.navigationBarTitleText&&(a.titleVal=r.global.window.navigationBarTitleText),s&&s.window&&s.window.navigationBarTitleText&&(n.titleVal=s.window.navigationBarTitleText),_.each(globalTitle,function(r,s){if(s===e)return t=r}),0===t.length){var i=_.extend(a,n);t=i.titleVal}}}catch(e){logger.info(e)}return t},_.wxrequest=function(e){if(_.compareSDKVersion(wxSDKVersion,"2.10.0")>=0)e.timeout=sa.para.datasend_timeout,wx.request(e);else{var t=wx.request(e);setTimeout(function(){_.isObject(t)&&_.isFunction(t.abort)&&t.abort()},sa.para.datasend_timeout)}},_.getAppId=function(){var e;if(wx.getAccountInfoSync&&(e=wx.getAccountInfoSync()),_.isObject(e)&&_.isObject(e.miniProgram))return e.miniProgram.appId},_.validId=function(e){return"string"!=typeof e&&"number"!=typeof e||""===e?(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1):"number"!=typeof e||(e=String(e),/^\d+$/.test(e))?e:(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1)},_.compareSDKVersion=function(e,t){e=e.split("."),t=t.split(".");for(var r=Math.max(e.length,t.length);e.lengthn)return 1;if(a-1?t.system.split(" ")[1]:t.system,wxSDKVersion=t.SDKVersion},complete:function(){var t=(new Date).getTimezoneOffset(),r=_.getAppId();_.isNumber(t)&&(e.$timezone_offset=t),r&&(e.$app_id=r),sa.initialState.systemIsComplete=!0,sa.initialState.checkIsComplete()}})}wx.getNetworkType({success:function(t){e.$network_type=_.setUpperCase(t.networkType)},complete:t})}},sa._=_,_.eventEmitter=function(){this.sub=[]},_.eventEmitter.prototype={add:function(e){this.sub.push(e)},emit:function(e,t){this.sub.forEach(function(r){r.on(e,t)})}},_.eventSub=function(e){sa.events.add(this),this._events=[],this.handle=e,this.ready=!1},_.eventSub.prototype={on:function(e,t){if(this.ready){if(_.isFunction(this.handle))try{this.handle(e,t)}catch(e){logger.info(e)}}else this._events.push({event:e,data:t})},isReady:function(){var e=this;e.ready=!0,e._events.forEach(function(t){if(_.isFunction(e.handle))try{e.handle(t.event,t.data)}catch(e){logger.info(e)}})}},sa.eventSub=_.eventSub,sa.events=new _.eventEmitter,sa.usePlugin=function(e,t){"function"==typeof e.init&&e.init(sa,t)},sa.prepareData=function(e,t){if(current_scene&&1154===current_scene&&!sa.para.preset_events.moments_page)return!1;var r={distinct_id:this.store.getDistinctId(),lib:{$lib:LIB_NAME,$lib_method:"code",$lib_version:String(LIB_VERSION)},properties:{}};_.extend(r,this.store.getUnionId(),e),_.isObject(e.properties)&&!_.isEmptyObject(e.properties)&&_.extend(r.properties,e.properties),e.type&&"profile"===e.type.slice(0,7)||(r._track_id=Number(String(Math.random()).slice(2,5)+String(Math.random()).slice(2,4)+String(Date.now()).slice(-4)),r.properties=_.extend({},_.info.properties,sa.store.getProps(),_.info.currentProps,r.properties),r.properties.$is_first_day=_.getIsFirstDay()),r.properties.$time&&_.isDate(r.properties.$time)?(r.time=1*r.properties.$time,delete r.properties.$time):r.time=1*new Date,_.parseSuperProperties(r.properties),_.searchObjDate(r),_.searchObjString(r),logger.info(r),sa.events.emit("send",r),sa.sendStrategy.send(r)},sa.store={storageInfo:null,getUUID:function(){return Date.now()+"-"+Math.floor(1e7*Math.random())+"-"+Math.random().toString(16).replace(".","")+"-"+String(31242*Math.random()).replace(".","").slice(0,8)},getStorage:function(){return this.storageInfo?this.storageInfo:(this.storageInfo=sa._.getStorageSync("sensorsdata2015_wechat")||"",this.storageInfo)},_state:{},mem:{mdata:[],getLength:function(){return this.mdata.length},add:function(e){this.mdata.push(e)},clear:function(e){this.mdata.splice(0,e)}},toState:function(e){var t=null;_.isJSONString(e)?(t=JSON.parse(e)).distinct_id?this._state=t:this.set("distinct_id",this.getUUID()):_.isObject(e)&&(t=e).distinct_id?this._state=t:this.set("distinct_id",this.getUUID())},getFirstId:function(){return this._state._first_id||this._state.first_id},getDistinctId:function(){return this._state._distinct_id||this._state.distinct_id},getUnionId:function(){var e={},t=this._state._first_id||this._state.first_id,r=this._state._distinct_id||this._state.distinct_id;return t&&r?(e.login_id=r,e.anonymous_id=t):e.anonymous_id=r,e},getProps:function(){return this._state.props||{}},setProps:function(e,t){var r=this._state.props||{};t?this.set("props",e):(_.extend(r,e),this.set("props",r))},set:function(e,t){var r={};for(var s in"string"==typeof e?r[e]=t:"object"==typeof e&&(r=e),this._state=this._state||{},r)this._state[s]=r[s],"first_id"===s?delete this._state._first_id:"distinct_id"===s&&(delete this._state._distinct_id,sa.events.emit("changeDistinctId"));this.save()},change:function(e,t){this._state["_"+e]=t},encryptStorage:function(){var e=this.getStorage(),t="data:enc;";_.isObject(e)?e=t+_.rot13obfs(JSON.stringify(e)):_.isString(e)&&-1===e.indexOf(t)&&(e=t+_.rot13obfs(e)),sa._.setStorageSync("sensorsdata2015_wechat",e)},save:function(){var e=JSON.parse(JSON.stringify(this._state));if(delete e._first_id,delete e._distinct_id,sa.para.encrypt_storage){e="data:enc;"+_.rot13obfs(JSON.stringify(e))}sa._.setStorageSync("sensorsdata2015_wechat",e)},init:function(){var e=this.getStorage();if(e)_.isString(e)&&-1!==e.indexOf("data:enc;")&&(e=e.substring("data:enc;".length),e=JSON.parse(_.rot13defs(e))),this.toState(e);else{is_first_launch=!0;var t=new Date,r=t.getTime();t.setHours(23),t.setMinutes(59),t.setSeconds(60),sa.setOnceProfile({$first_visit_time:new Date}),this.set({distinct_id:this.getUUID(),first_visit_time:r,first_visit_day_time:t.getTime()})}}},sa.setProfile=function(e,t){sa.prepareData({type:"profile_set",properties:e},t)},sa.setOnceProfile=function(e,t){sa.prepareData({type:"profile_set_once",properties:e},t)},sa.appendProfile=function(e,t){if(!_.isObject(e))return!1;_.each(e,function(t,r){_.isString(t)?e[r]=[t]:_.isArray(t)||(delete e[r],logger.info("appendProfile\u5c5e\u6027\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32\u6216\u8005\u6570\u7ec4"))}),sa.prepareData({type:"profile_append",properties:e},t)},sa.incrementProfile=function(e,t){if(!_.isObject(e))return!1;var r=e;_.isString(e)&&((e={})[r]=1),sa.prepareData({type:"profile_increment",properties:e},t)},sa.track=function(e,t,r){this.prepareData({type:"track",event:e,properties:t},r)},sa.identify=function(e,t){if(e=_.validId(e)){var r=sa.store.getFirstId();!0===t?r?sa.store.set("first_id",e):sa.store.set("distinct_id",e):r?sa.store.change("first_id",e):sa.store.change("distinct_id",e)}},sa.trackSignup=function(e,t,r,s){var a=sa.store.getFirstId()||sa.store.getDistinctId();sa.store.set("distinct_id",e),sa.prepareData({original_id:a,distinct_id:e,type:"track_signup",event:t,properties:r},s)},sa.registerApp=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&(_.info.currentProps=_.extend(_.info.currentProps,e))},sa.register=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&sa.store.setProps(e)},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.clearAllProps=function(e){var t=sa.store.getProps(),r={};_.isArray(e)&&(_.each(t,function(t,s){_.include(e,s)||(r[s]=t)}),sa.store.setProps(r,!0))},sa.clearAppRegister=function(e){_.isArray(e)&&_.each(_.info.currentProps,function(t,r){_.include(e,r)&&delete _.info.currentProps[r]})},_.setLatestChannel=function(e){_.isEmptyObject(e)||(function(e,t){var r=!1;for(var s in t)e[t[s]]&&(r=!0);return r}(e,latest_source_channel)&&(sa.clearAppRegister(latest_source_channel),sa.clearAllProps(latest_source_channel)),sa.para.is_persistent_save.utm?sa.register(e):sa.registerApp(e))},_.setLatestShare=function(e){(e.$latest_share_depth||e.$latest_share_distinct_id||e.$latest_share_url_path||e.$latest_share_method)&&(sa.clearAppRegister(latest_share_info),sa.clearAllProps(latest_share_info),sa.para.is_persistent_save.share?sa.register(e):sa.registerApp(e))},sa.login=function(e){if(e=_.validId(e)){var t=sa.store.getFirstId(),r=sa.store.getDistinctId();e!==r&&(t?sa.trackSignup(e,"$SignUp"):(sa.store.set("first_id",r),sa.trackSignup(e,"$SignUp")))}},sa.getAnonymousID=function(){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")},sa.logout=function(e){var t=sa.store.getFirstId();t?(sa.store.set("first_id",""),!0===e?sa.store.set("distinct_id",sa.store.getUUID()):sa.store.set("distinct_id",t)):logger.info("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25")},sa.getLocation=function(){wx.getSetting({success:function(e){if(!e.authSetting["scope.userLocation"])return!1;wx.getLocation({type:sa.para.preset_properties.location.type,success:function(e){sa.registerApp({$latitude:e.latitude*Math.pow(10,6),$longitude:e.longitude*Math.pow(10,6),$geo_coordinate_system:_.setUpperCase(sa.para.preset_properties.location.type)})},fail:function(e){console.log("\u83b7\u53d6\u4f4d\u7f6e\u5931\u8d25",e)}})}})},sa.openid={getRequest:function(e){wx.login({success:function(t){t.code&&sa.para.appid&&sa.para.openid_url?_.wxrequest({url:sa.para.openid_url+"&code="+t.code+"&appid="+sa.para.appid,method:"GET",complete:function(t){_.isObject(t)&&_.isObject(t.data)&&t.data.openid?e(t.data.openid):e()}}):e()}})},getWXStorage:function(){var e=sa.store.getStorage();if(e&&_.isObject(e))return e.openid},getOpenid:function(e){if(!sa.para.appid)return e(),!1;var t=this.getWXStorage();t?e(t):this.getRequest(e)}},sa.initial=function(){this._.info.getSystem(),this.store.init()},sa.init=function(e){if(!0===this.hasInit)return!1;this.hasInit=!0,sa.setPara(e),sa.para.encrypt_storage&&this.store.encryptStorage(),sa.para.batch_send&&(wx.getStorage({key:"sensors_mp_prepare_data",complete:function(e){var t=e.data&&_.isArray(e.data)?e.data:[];sa.store.mem.mdata=t.concat(sa.store.mem.mdata),sa.sendStrategy.syncStorage=!0}}),sa.sendStrategy.batchInterval()),sa.initialState.storeIsComplete=!0,sa.initialState.checkIsComplete()},sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib){var e={};_.each(_.info.currentProps,function(t,r){0===r.indexOf("$")&&(e[r]=t)});var t=_.extend(e,{$url_path:_.getCurrentPath(),$is_first_day:_.getIsFirstDay()},_.info.properties,sa.store.getProps());return delete t.$lib,t}return{}},_.autoExeQueue=function(){return{items:[],enqueue:function(e){this.items.push(e),this.start()},dequeue:function(){return this.items.shift()},getCurrentItem:function(){return this.items[0]},isRun:!1,start:function(){this.items.length>0&&!this.isRun&&(this.isRun=!0,this.getCurrentItem().start())},close:function(){this.dequeue(),this.isRun=!1,this.start()}}},sa.requestQueue=function(e){this.url=e.url},sa.requestQueue.prototype.isEnd=function(){this.received||(this.received=!0,this.close())},sa.requestQueue.prototype.start=function(){var e=this;_.wxrequest({url:this.url,method:"GET",complete:function(){e.isEnd()}})},sa.dataQueue=_.autoExeQueue(),sa.sendStrategy={dataHasSend:!0,dataHasChange:!1,syncStorage:!1,failTime:0,onAppHide:function(){sa.para.batch_send&&this.batchSend()},send:function(e){if(!sa.para.server_url)return!1;sa.para.batch_send?(this.dataHasChange=!0,sa.store.mem.getLength()>=500&&(logger.info("\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38"),sa.store.mem.mdata.shift()),sa.store.mem.add(e),sa.store.mem.getLength()>=sa.para.batch_send.max_length&&this.batchSend()):this.queueSend(e)},queueSend:function(e){e._flush_time=Date.now(),e=JSON.stringify(e),e=-1!==sa.para.server_url.indexOf("?")?sa.para.server_url+"&data="+encodeURIComponent(_.base64Encode(e)):sa.para.server_url+"?data="+encodeURIComponent(_.base64Encode(e));var t=new sa.requestQueue({url:e});t.close=function(){sa.dataQueue.close()},sa.dataQueue.enqueue(t)},wxrequest:function(e){if(_.isArray(e.data)&&e.data.length>0){var t=Date.now();e.data.forEach(function(e){e._flush_time=t}),e.data=JSON.stringify(e.data),_.wxrequest({url:sa.para.server_url,method:"POST",dataType:"text",data:"data_list="+encodeURIComponent(_.base64Encode(e.data)),success:function(){e.success(e.len)},fail:function(){e.fail()}})}else e.success(e.len)},batchSend:function(){if(this.dataHasSend){var e,t,r=sa.store.mem.mdata;(t=(e=r.length>=100?r.slice(0,100):r).length)>0&&(this.dataHasSend=!1,this.wxrequest({data:e,len:t,success:this.batchRemove.bind(this),fail:this.sendFail.bind(this)}))}},sendFail:function(){this.dataHasSend=!0,this.failTime++},batchRemove:function(e){sa.store.mem.clear(e),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite(),this.failTime=0},is_first_batch_write:!0,batchWrite:function(){var e=this;this.dataHasChange&&(this.is_first_batch_write&&(this.is_first_batch_write=!1,setTimeout(function(){e.batchSend()},1e3)),this.dataHasChange=!1,this.syncStorage&&sa._.setStorageSync("sensors_mp_prepare_data",sa.store.mem.mdata))},batchInterval:function(){var e=this;!function t(){setTimeout(function(){e.batchWrite(),t()},500)}(),function t(){setTimeout(function(){e.batchSend(),t()},sa.para.batch_send.send_timeout*Math.pow(2,e.failTime))}()}},sa.setOpenid=function(e,t){sa.store.set("openid",e),t?sa.store.set("distinct_id",e):sa.identify(e,!0)},sa.initWithOpenid=function(e,t){(e=e||{}).appid&&(sa.para.appid=e.appid),sa.openid.getOpenid(function(r){r&&sa.setOpenid(r,e.isCoverLogin),t&&_.isFunction(t)&&t(r),sa.init(e)})},sa.setWebViewUrl=function(e,t){if(!_.isString(e)||""===e)return logger.info("error:\u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;e=decodeURIComponent(e);var r,s=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e),a=s[1]||"",n=s[2]||"",i=s[3]||"",o="",c=sa.store.getDistinctId()||"",u=sa.store.getFirstId()||"";_.urlSafeBase64&&_.urlSafeBase64.encode?c=c?_.urlSafeBase64.trim(_.urlSafeBase64.encode(_.urlBase64Encode(c))):"":this._.rot13obfs&&(c=c?_.rot13obfs(c):""),c=encodeURIComponent(c);var p=u?"f"+c:"d"+c;t?(r=i.indexOf("_sasdk"),o=i.indexOf("?")>-1?r>-1?a+n+"#"+i.substring(1,r)+"_sasdk="+p:a+n+"#"+i.substring(1)+"&_sasdk="+p:a+n+"#"+i.substring(1)+"?_sasdk="+p):(r=n.indexOf("_sasdk"),o=/^\?(\w)+/.test(n)?r>-1?a+"?"+n.substring(1,r)+"_sasdk="+p+i:a+"?"+n.substring(1)+"&_sasdk="+p+i:a+"?"+n.substring(1)+"_sasdk="+p+i);return o},_.each(["setProfile","setOnceProfile","track","quick","incrementProfile","appendProfile","login","logout","registerApp","register","clearAllRegister","clearAllProps","clearAppRegister"],function(e){var t=sa[e];sa[e]=function(){sa.initialState.isComplete?t.apply(sa,arguments):sa.initialState.queue.push([e,arguments])}}),_.setQuery=function(e,t){if(e&&_.isObject(e)&&!_.isEmptyObject(e)){var r=[];return _.each(e,function(e,s){"q"===s&&_.isString(e)&&0===e.indexOf("http")||(t?r.push(s+"="+e):r.push(s+"="+_.decodeURIComponent(e)))}),r.join("&")}return""},_.getUtmFromPage=function(){var e={};try{var t=getCurrentPages(),r=JSON.parse(JSON.stringify(t[t.length-1].options));for(var s in r)r[s]=_.decodeURIComponent(r[s]);e=_.getCustomUtmFromQuery(r,"$","_","$")}catch(e){logger.info(e)}return e},sa.autoTrackCustom={trackCustom:function(e,t,r){var s=sa.para.autoTrack[e],a="";sa.para.autoTrack&&s&&("function"==typeof s?(a=s(),_.isObject(a)&&_.extend(t,a)):_.isObject(s)&&(_.extend(t,s),sa.para.autoTrack[e]=!0),sa.track(r,t))},appLaunch:function(e,t){"object"!=typeof this||this.trackCustom||(this[sa.para.name]=sa);var r={};e&&e.scene?(current_scene=e.scene,r.$scene=_.getMPScene(e.scene)):r.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(r.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:r.$url_path})),_.setShareInfo(e,r);var s=_.setUtm(e,r);is_first_launch?(r.$is_first_time=!0,_.isEmptyObject(s.pre1)||sa.setOnceProfile(s.pre1)):r.$is_first_time=!1,_.setLatestChannel(s.pre2),_.setSfSource(e,r),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(e.query),t?(r=_.extend(r,t),sa.track("$MPLaunch",r)):sa.para.autoTrack&&sa.para.autoTrack.appLaunch&&sa.autoTrackCustom.trackCustom("appLaunch",r,"$MPLaunch")},appShow:function(e,t){var r={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,r.$scene=_.getMPScene(e.scene)):r.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(r.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:r.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,r);var s=_.setUtm(e,r);_.setLatestChannel(s.pre2),_.setSfSource(e,r),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(e.query),t?(r=_.extend(r,t),sa.track("$MPShow",r)):sa.para.autoTrack&&sa.para.autoTrack.appShow&&sa.autoTrackCustom.trackCustom("appShow",r,"$MPShow")},appHide:function(e){var t=(new Date).getTime(),r={};r.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(r.event_duration=(t-mpshow_time)/1e3),e?(r=_.extend(r,e),sa.track("$MPHide",r)):sa.para.autoTrack&&sa.para.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",r,"$MPHide"),sa.sendStrategy.onAppHide()}},sa.quick=function(){var e=arguments[0],t=arguments[1],r=arguments[2],s=_.isObject(r)?r:{};if("getAnonymousID"===e){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===e||"appShow"===e?t?sa.autoTrackCustom[e](t,s):logger.info("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(s=_.isObject(t)?t:{},sa.autoTrackCustom[e](s))},sa.appLaunch=function(e,t){var r={};e&&e.scene?(current_scene=e.scene,r.$scene=_.getMPScene(e.scene)):r.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(r.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:r.$url_path})),_.setShareInfo(e,r);var s=_.setUtm(e,r);is_first_launch?(r.$is_first_time=!0,_.isEmptyObject(s.pre1)||sa.setOnceProfile(s.pre1)):r.$is_first_time=!1,_.setLatestChannel(s.pre2),_.setSfSource(e,r),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(e.query),_.isObject(t)&&(r=_.extend(r,t)),sa.track("$MPLaunch",r)},sa.appShow=function(e,t){var r={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,r.$scene=_.getMPScene(e.scene)):r.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(r.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:r.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,r);var s=_.setUtm(e,r);_.setLatestChannel(s.pre2),_.setSfSource(e,r),sa.registerApp({$latest_scene:r.$scene}),r.$url_query=_.setQuery(e.query),_.isObject(t)&&(r=_.extend(r,t)),sa.track("$MPShow",r)},sa.appHide=function(e){var t=(new Date).getTime(),r={};r.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(r.event_duration=(t-mpshow_time)/1e3),_.isObject(e)&&(r=_.extend(r,e)),sa.track("$MPHide",r),sa.sendStrategy.onAppHide()},sa.pageShow=function(e){var t={},r=_.getCurrentPath(),s=_.getPageTitle(r),a={};try{var n=getCurrentPages();a=n[n.length-1]}catch(e){logger.info(e)}!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:r}),s&&(t.$title=s),t.$referrer=sa_referrer,t.$url_path=r,sa.status.last_referrer=sa_referrer,t.$url_query=a.sensors_mp_url_query?a.sensors_mp_url_query:"",t=_.extend(t,_.getUtmFromPage()),_.setPageSfSource(t),_.isObject(e)&&(t=_.extend(t,e)),sa.track("$MPViewScreen",t),sa_referrer=r,sa.status.referrer=r},sa.initial(),module.exports=sa; \ No newline at end of file diff --git a/sensorsdata.min.es6.js b/sensorsdata.min.es6.js index 1898685..a8a105a 100755 --- a/sensorsdata.min.es6.js +++ b/sensorsdata.min.es6.js @@ -1 +1 @@ -var _={},sa={para:{name:"sensors",server_url:"",send_timeout:1e3,show_log:!0,launched:!1,allow_amend_share_path:!0,max_string_length:300,datasend_timeout:3e3,source_channel:[],autoTrack:{appLaunch:!0,appShow:!0,appHide:!0,pageShow:!0,pageShare:!0,mpClick:!1,mpFavorite:!0},autotrack_exclude_page:{pageShow:[]},is_persistent_save:{share:!1,utm:!1},preset_properties:{url_path:!0},preset_events:{moments_page:!1,defer_track:!1},batch_send:!0}},mpHook={data:1,onLoad:1,onShow:1,onReady:1,onPullDownRefresh:1,onReachBottom:1,onShareAppMessage:1,onShareTimeline:1,onPullDownRefresh:1,onReachBottom:1,onPageScroll:1,onResize:1,onTabItemTap:1,onHide:1,onUnload:1},logger="object"==typeof logger?logger:{};logger.info=function(){if(sa.para.show_log&&"object"==typeof console&&console.log)try{if(3===arguments.length)return console.log(arguments[0],arguments[1],arguments[2]);if(2===arguments.length)return console.log(arguments[0],arguments[1]);if(1===arguments.length)return console.log(arguments[0])}catch(e){console.log(arguments[0])}},sa.setPara=function(e){sa.para=_.extend2Lev(sa.para,e);var t=[];if(_.isArray(sa.para.source_channel))for(var a=sa.para.source_channel.length,r=0;rsa.para.max_string_length?(logger.info("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,sa.para.max_string_length)):e},_.searchObjString=function(e){_.isObject(e)&&_.each(e,function(t,a){_.isObject(t)?_.searchObjString(e[a]):_.isString(t)&&(e[a]=_.formatString(t))})},_.parseSuperProperties=function(e){_.isObject(e)&&(_.each(e,function(t,a){if(_.isFunction(t))try{e[a]=t(),_.isFunction(e[a])&&(logger.info("\u60a8\u7684\u5c5e\u6027- "+a+" \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}catch(t){delete e[a],logger.info("\u60a8\u7684\u5c5e\u6027- "+a+" \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}}),_.strip_sa_properties(e))},_.unique=function(e){for(var t,a=[],r={},s=0;s127&&i<2048?String.fromCharCode(i>>6|192,63&i|128):String.fromCharCode(i>>12|224,i>>6&63|128,63&i|128),null!==o&&(a>t&&(n+=e.substring(t,a)),n+=o,t=a=s+1)}return a>t&&(n+=e.substring(t,e.length)),n},_.base64Encode=function(e){var t,a,r,s,n,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,c=0,u="",p=[];if(!e)return e;e=_.utf8Encode(e);do{t=(n=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,a=n>>12&63,r=n>>6&63,s=63&n,p[c++]=i.charAt(t)+i.charAt(a)+i.charAt(r)+i.charAt(s)}while(o255||(r=e.charCodeAt(o++))>255||(s=e.charCodeAt(o++))>255)&&logger.info("Failed to execute 'btoa' : The string to be encoded contains characters outside of the Latin1 range."),i+=n.charAt((t=a<<16|r<<8|s)>>18&63)+n.charAt(t>>12&63)+n.charAt(t>>6&63)+n.charAt(63&t);return c?i.slice(0,c-3)+"===".substring(c):i},_.urlBase64Encode=function(e){return _.btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))},_.rot13obfs=function(e,t){t="number"==typeof t?t:13;for(var a=(e=String(e)).split(""),r=0,s=a.length;r(new Date).getTime()},_.getCurrentUrl=function(e){var t=_.getCurrentPath(),a="";return _.isObject(e)&&e.sensors_mp_encode_url_query&&(a=e.sensors_mp_encode_url_query),t?a?t+"?"+a:t:"\u672a\u53d6\u5230"},_.getPath=function(e){return e="string"==typeof e?e.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"},_.getMethods=function(e){var t=[];for(var a in e)"function"!=typeof e[a]||mpHook[a]||t.push(a);return t},_.isClick=function(e){return!!{tap:1,longpress:1,longtap:1}[e]},sa.initialState={queue:[],isComplete:!1,systemIsComplete:!1,storeIsComplete:!1,checkIsComplete:function(){this.systemIsComplete&&this.storeIsComplete&&(this.isComplete=!0,this.queue.length>0&&(_.each(this.queue,function(e){sa[e[0]].apply(sa,slice.call(e[1]))}),this.queue=[]))}},_.getCustomUtmFromQuery=function(e,t,a,r){if(!_.isObject(e))return{};var s={};if(e.sa_utm)for(var n in e)"sa_utm"!==n?_.include(sa.para.source_channel,n)&&(s[a+n]=e[n]):s[r+n]=e[n];else for(var n in e)-1===(" "+source_channel_standard+" ").indexOf(" "+n+" ")?_.include(sa.para.source_channel,n)&&(s[a+n]=e[n]):s[t+n]=e[n];return s},_.getObjFromQuery=function(e){var t=e.split("?"),a=[],r={};return t&&t[1]?(_.each(t[1].split("&"),function(e){(a=e.split("="))[0]&&a[1]&&(r[a[0]]=a[1])}),r):{}},_.setStorageSync=function(e,t){var a=function(){wx.setStorageSync(e,t)};try{a()}catch(e){logger.info("set Storage fail --",e);try{a()}catch(e){logger.info("set Storage fail again --",e)}}},_.getStorageSync=function(e){var t="";try{t=wx.getStorageSync(e)}catch(a){try{t=wx.getStorageSync(e)}catch(e){logger.info("getStorage fail")}}return t},_.getMPScene=function(e){return"number"==typeof e||"string"==typeof e&&""!==e?e="wx-"+String(e):"\u672a\u53d6\u5230\u503c"},_.setShareInfo=function(e,t){var a={},r={},s=sa.store.getDistinctId(),n=sa.store.getFirstId();if(!(e&&_.isObject(e.query)&&e.query.sampshare))return{};if(a=_.decodeURIComponent(e.query.sampshare),!_.isJSONString(a))return{};var i=(a=JSON.parse(a)).d,o=a.p,c=a.i,u=a.m;"string"==typeof c?(t.$share_distinct_id=c,share_distinct_id=c,r.$latest_share_distinct_id=c):t.$share_distinct_id="\u53d6\u503c\u5f02\u5e38","number"==typeof i?!share_distinct_id||share_distinct_id!==s&&share_distinct_id!==n?!share_distinct_id||share_distinct_id===s&&share_distinct_id===n?t.$share_depth="-1":(t.$share_depth=i+1,query_share_depth=i+1,r.$latest_share_depth=i+1):(t.$share_depth=i,query_share_depth=i,r.$latest_share_depth=i):t.$share_depth="-1","string"==typeof o?(t.$share_url_path=o,r.$latest_share_url_path=o):t.$share_url_path="\u53d6\u503c\u5f02\u5e38","string"==typeof u?(t.$share_method=u,r.$latest_share_method=u):t.$share_method="\u53d6\u503c\u5f02\u5e38",_.setLatestShare(r)},_.getShareInfo=function(){return JSON.stringify({i:sa.store.getDistinctId()||"\u53d6\u503c\u5f02\u5e38",p:_.getCurrentPath(),d:query_share_depth,m:share_method})},_.detectOptionQuery=function(e){if(!e||!_.isObject(e.query))return{};var t,a,r,s,n={};return n.query=_.extend({},e.query),"string"==typeof n.query.scene&&(t=n.query,a=["utm_source","utm_content","utm_medium","utm_campaign","utm_term","sa_utm"].concat(sa.para.source_channel),r=new RegExp("("+a.join("|")+")%3D","i"),1===(s=Object.keys(t)).length&&"scene"===s[0]&&r.test(t.scene))&&(n.scene=n.query.scene,delete n.query.scene),e.query.q&&e.query.scancode_time&&"101"===String(e.scene).slice(0,3)&&(n.q=String(n.query.q),delete n.query.q,delete n.query.scancode_time),n},_.getMixedQuery=function(e){var t=_.detectOptionQuery(e),a=t.scene,r=t.q,s=t.query;for(var n in s)s[n]=_.decodeURIComponent(s[n]);return a&&(a=-1!==(a=_.decodeURIComponent(a)).indexOf("?")?"?"+a.replace(/\?/g,""):"?"+a,_.extend(s,_.getObjFromQuery(a))),r&&_.extend(s,_.getObjFromQuery(_.decodeURIComponent(r))),s},_.setUtm=function(e,t){var a={},r=_.getMixedQuery(e),s=_.getCustomUtmFromQuery(r,"$","_","$"),n=_.getCustomUtmFromQuery(r,"$latest_","_latest_","$latest_");return a.pre1=s,a.pre2=n,_.extend(t,s),a},_.setSfSource=function(e,t){!_.isEmptyObject(e.query)&&e.query._sfs&&(t.$sf_source=e.query._sfs,sa.registerApp({$latest_sf_source:t.$sf_source}))},_.setPageSfSource=function(e){try{var t=getCurrentPages(),a=JSON.parse(JSON.stringify(t[t.length-1].options));for(var r in a)a[r]=_.decodeURIComponent(a[r]);!_.isEmptyObject(a)&&a._sfs&&(e.$sf_source=a._sfs)}catch(e){logger.info(e)}};try{var oldSetNavigationBarTitle=wx.setNavigationBarTitle;Object.defineProperty(wx,"setNavigationBarTitle",{get:function(){return function(e){var t=getCurrentPages(),a=t[t.length-1].route||"";e=_.isObject(e)?e:{},globalTitle[a]=e.title,oldSetNavigationBarTitle.call(this,e)}}})}catch(e){logger.info(e)}function mp_proxy(e,t,a){var r=sa.autoTrackCustom[a];if(e[t]){var s=e[t];e[t]=function(){"onLaunch"===t&&(this[sa.para.name]=sa),!sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&!sa.para.autoTrackIsFirst[a]?(s.apply(this,arguments),r.apply(this,arguments)):(!0===sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&sa.para.autoTrackIsFirst[a])&&(r.apply(this,arguments),s.apply(this,arguments))}}else e[t]=function(){"onLaunch"===t&&(this[sa.para.name]=sa),r.apply(this,arguments)}}function clickTrack(e){var t,a={},r={},s=e.currentTarget||{},n=e.target||{};if(_.isObject(sa.para.framework)&&_.isObject(sa.para.framework.taro)&&!sa.para.framework.taro.createApp&&n.id&&s.id&&n.id!==s.id)return!1;var i=s.dataset||{};if(t=e.type,a.$element_id=s.id,a.$element_type=i.type,a.$element_content=i.content,a.$element_name=i.name,_.isObject(e.event_prop)&&(r=e.event_prop),t&&_.isClick(t)){if(sa.para.preset_events&&sa.para.preset_events.collect_element&&!1===sa.para.preset_events.collect_element(arguments[0]))return!1;a.$url_path=_.getCurrentPath(),a=_.extend(a,r),sa.track("$MPClick",a)}}function click_proxy(e,t){var a=e[t];e[t]=function(){var e=a.apply(this,arguments),t=arguments[0];return _.isObject(t)&&(sa.para.preset_events.defer_track?setTimeout(function(){clickTrack(t)},0):clickTrack(t)),e}}function tabProxy(e){var t=e.onTabItemTap;e.onTabItemTap=function(e){t&&t.apply(this,arguments);var a={};e&&(a.$element_content=e.text),a.$element_type="tabBar",a.$url_path=_.getCurrentPath(),sa.track("$MPClick",a)}}_.getPageTitle=function(e){if("\u672a\u53d6\u5230"===e||!e)return!1;var t="";try{if(__wxConfig){var a=__wxConfig,r=a.page[e]||a.page[e+".html"],s={},n={};if(a.global&&a.global.window&&a.global.window.navigationBarTitleText&&(s.titleVal=a.global.window.navigationBarTitleText),r&&r.window&&r.window.navigationBarTitleText&&(n.titleVal=r.window.navigationBarTitleText),_.each(globalTitle,function(a,r){if(r===e)return t=a}),0===t.length){var i=_.extend(s,n);t=i.titleVal}}}catch(e){logger.info(e)}return t},_.wxrequest=function(e){if(_.compareSDKVersion(wxSDKVersion,"2.10.0")>=0)e.timeout=sa.para.datasend_timeout,wx.request(e);else{var t=wx.request(e);setTimeout(function(){_.isObject(t)&&_.isFunction(t.abort)&&t.abort()},sa.para.datasend_timeout)}},_.getAppId=function(){var e;if(wx.getAccountInfoSync&&(e=wx.getAccountInfoSync()),_.isObject(e)&&_.isObject(e.miniProgram))return e.miniProgram.appId},_.validId=function(e){return"string"!=typeof e&&"number"!=typeof e||""===e?(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1):"number"!=typeof e||(e=String(e),/^\d+$/.test(e))?e:(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1)},_.compareSDKVersion=function(e,t){e=e.split("."),t=t.split(".");for(var a=Math.max(e.length,t.length);e.lengthn)return 1;if(s-1?t.system.split(" ")[1]:t.system,wxSDKVersion=t.SDKVersion},complete:function(){var t=(new Date).getTimezoneOffset(),a=_.getAppId();_.isNumber(t)&&(e.$timezone_offset=t),a&&(e.$app_id=a),sa.initialState.systemIsComplete=!0,sa.initialState.checkIsComplete()}})}wx.getNetworkType({success:function(t){e.$network_type=_.setUpperCase(t.networkType)},complete:t})}},sa._=_,_.eventEmitter=function(){this.sub=[]},_.eventEmitter.prototype={add:function(e){this.sub.push(e)},emit:function(e,t){this.sub.forEach(function(a){a.on(e,t)})}},_.eventSub=function(e){sa.events.add(this),this._events=[],this.handle=e,this.ready=!1},_.eventSub.prototype={on:function(e,t){if(this.ready){if(_.isFunction(this.handle))try{this.handle(e,t)}catch(e){logger.info(e)}}else this._events.push({event:e,data:t})},isReady:function(){var e=this;e.ready=!0,e._events.forEach(function(t){if(_.isFunction(e.handle))try{e.handle(t.event,t.data)}catch(e){logger.info(e)}})}},sa.eventSub=_.eventSub,sa.events=new _.eventEmitter,sa.usePlugin=function(e,t){"function"==typeof e.init&&e.init(sa,t)},sa.prepareData=function(e,t){if(current_scene&&1154===current_scene&&!sa.para.preset_events.moments_page)return!1;var a={distinct_id:this.store.getDistinctId(),lib:{$lib:LIB_NAME,$lib_method:"code",$lib_version:String(LIB_VERSION)},properties:{}};_.extend(a,this.store.getUnionId(),e),_.isObject(e.properties)&&!_.isEmptyObject(e.properties)&&_.extend(a.properties,e.properties),e.type&&"profile"===e.type.slice(0,7)||(a._track_id=Number(String(Math.random()).slice(2,5)+String(Math.random()).slice(2,4)+String(Date.now()).slice(-4)),a.properties=_.extend({},_.info.properties,sa.store.getProps(),_.info.currentProps,a.properties),a.properties.$is_first_day=_.getIsFirstDay()),a.properties.$time&&_.isDate(a.properties.$time)?(a.time=1*a.properties.$time,delete a.properties.$time):a.time=1*new Date,_.parseSuperProperties(a.properties),_.searchObjDate(a),_.searchObjString(a),logger.info(a),sa.events.emit("send",a),sa.sendStrategy.send(a)},sa.store={storageInfo:null,getUUID:function(){return Date.now()+"-"+Math.floor(1e7*Math.random())+"-"+Math.random().toString(16).replace(".","")+"-"+String(31242*Math.random()).replace(".","").slice(0,8)},getStorage:function(){return this.storageInfo?this.storageInfo:(this.storageInfo=sa._.getStorageSync("sensorsdata2015_wechat")||"",this.storageInfo)},_state:{},mem:{mdata:[],getLength:function(){return this.mdata.length},add:function(e){this.mdata.push(e)},clear:function(e){this.mdata.splice(0,e)}},toState:function(e){var t=null;_.isJSONString(e)?(t=JSON.parse(e)).distinct_id?this._state=t:this.set("distinct_id",this.getUUID()):_.isObject(e)&&(t=e).distinct_id?this._state=t:this.set("distinct_id",this.getUUID())},getFirstId:function(){return this._state._first_id||this._state.first_id},getDistinctId:function(){return this._state._distinct_id||this._state.distinct_id},getUnionId:function(){var e={},t=this._state._first_id||this._state.first_id,a=this._state._distinct_id||this._state.distinct_id;return t&&a?(e.login_id=a,e.anonymous_id=t):e.anonymous_id=a,e},getProps:function(){return this._state.props||{}},setProps:function(e,t){var a=this._state.props||{};t?this.set("props",e):(_.extend(a,e),this.set("props",a))},set:function(e,t){var a={};for(var r in"string"==typeof e?a[e]=t:"object"==typeof e&&(a=e),this._state=this._state||{},a)this._state[r]=a[r],"first_id"===r?delete this._state._first_id:"distinct_id"===r&&(delete this._state._distinct_id,sa.events.emit("changeDistinctId"));this.save()},change:function(e,t){this._state["_"+e]=t},encryptStorage:function(){var e=this.getStorage(),t="data:enc;";_.isObject(e)?e=t+_.rot13obfs(JSON.stringify(e)):_.isString(e)&&-1===e.indexOf(t)&&(e=t+_.rot13obfs(e)),sa._.setStorageSync("sensorsdata2015_wechat",e)},save:function(){var e=JSON.parse(JSON.stringify(this._state));if(delete e._first_id,delete e._distinct_id,sa.para.encrypt_storage){e="data:enc;"+_.rot13obfs(JSON.stringify(e))}sa._.setStorageSync("sensorsdata2015_wechat",e)},init:function(){var e=this.getStorage();if(e)_.isString(e)&&-1!==e.indexOf("data:enc;")&&(e=e.substring("data:enc;".length),e=JSON.parse(_.rot13defs(e))),this.toState(e);else{is_first_launch=!0;var t=new Date,a=t.getTime();t.setHours(23),t.setMinutes(59),t.setSeconds(60),sa.setOnceProfile({$first_visit_time:new Date}),this.set({distinct_id:this.getUUID(),first_visit_time:a,first_visit_day_time:t.getTime()})}}},sa.setProfile=function(e,t){sa.prepareData({type:"profile_set",properties:e},t)},sa.setOnceProfile=function(e,t){sa.prepareData({type:"profile_set_once",properties:e},t)},sa.appendProfile=function(e,t){if(!_.isObject(e))return!1;_.each(e,function(t,a){_.isString(t)?e[a]=[t]:_.isArray(t)||(delete e[a],logger.info("appendProfile\u5c5e\u6027\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32\u6216\u8005\u6570\u7ec4"))}),sa.prepareData({type:"profile_append",properties:e},t)},sa.incrementProfile=function(e,t){if(!_.isObject(e))return!1;var a=e;_.isString(e)&&((e={})[a]=1),sa.prepareData({type:"profile_increment",properties:e},t)},sa.track=function(e,t,a){this.prepareData({type:"track",event:e,properties:t},a)},sa.identify=function(e,t){if(e=_.validId(e)){var a=sa.store.getFirstId();!0===t?a?sa.store.set("first_id",e):sa.store.set("distinct_id",e):a?sa.store.change("first_id",e):sa.store.change("distinct_id",e)}},sa.trackSignup=function(e,t,a,r){var s=sa.store.getFirstId()||sa.store.getDistinctId();sa.store.set("distinct_id",e),sa.prepareData({original_id:s,distinct_id:e,type:"track_signup",event:t,properties:a},r)},sa.registerApp=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&(_.info.currentProps=_.extend(_.info.currentProps,e))},sa.register=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&sa.store.setProps(e)},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.clearAllProps=function(e){var t=sa.store.getProps(),a={};_.isArray(e)&&(_.each(t,function(t,r){_.include(e,r)||(a[r]=t)}),sa.store.setProps(a,!0))},sa.clearAppRegister=function(e){_.isArray(e)&&_.each(_.info.currentProps,function(t,a){_.include(e,a)&&delete _.info.currentProps[a]})},_.setLatestChannel=function(e){_.isEmptyObject(e)||(function(e,t){var a=!1;for(var r in t)e[t[r]]&&(a=!0);return a}(e,latest_source_channel)&&(sa.clearAppRegister(latest_source_channel),sa.clearAllProps(latest_source_channel)),sa.para.is_persistent_save.utm?sa.register(e):sa.registerApp(e))},_.setLatestShare=function(e){(e.$latest_share_depth||e.$latest_share_distinct_id||e.$latest_share_url_path||e.$latest_share_method)&&(sa.clearAppRegister(latest_share_info),sa.clearAllProps(latest_share_info),sa.para.is_persistent_save.share?sa.register(e):sa.registerApp(e))},sa.login=function(e){if(e=_.validId(e)){var t=sa.store.getFirstId(),a=sa.store.getDistinctId();e!==a&&(t?sa.trackSignup(e,"$SignUp"):(sa.store.set("first_id",a),sa.trackSignup(e,"$SignUp")))}},sa.getAnonymousID=function(){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")},sa.logout=function(e){var t=sa.store.getFirstId();t?(sa.store.set("first_id",""),!0===e?sa.store.set("distinct_id",sa.store.getUUID()):sa.store.set("distinct_id",t)):logger.info("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25")},sa.getLocation=function(){wx.getSetting({success:function(e){if(!e.authSetting["scope.userLocation"])return!1;wx.getLocation({type:sa.para.preset_properties.location.type,success:function(e){sa.registerApp({$latitude:e.latitude*Math.pow(10,6),$longitude:e.longitude*Math.pow(10,6),$geo_coordinate_system:_.setUpperCase(sa.para.preset_properties.location.type)})},fail:function(e){console.log("\u83b7\u53d6\u4f4d\u7f6e\u5931\u8d25",e)}})}})},sa.openid={getRequest:function(e){wx.login({success:function(t){t.code&&sa.para.appid&&sa.para.openid_url?_.wxrequest({url:sa.para.openid_url+"&code="+t.code+"&appid="+sa.para.appid,method:"GET",complete:function(t){_.isObject(t)&&_.isObject(t.data)&&t.data.openid?e(t.data.openid):e()}}):e()}})},getWXStorage:function(){var e=sa.store.getStorage();if(e&&_.isObject(e))return e.openid},getOpenid:function(e){if(!sa.para.appid)return e(),!1;var t=this.getWXStorage();t?e(t):this.getRequest(e)}},sa.initial=function(){this._.info.getSystem(),this.store.init()},sa.init=function(e){if(!0===this.hasInit)return!1;this.hasInit=!0,sa.setPara(e),sa.para.encrypt_storage&&this.store.encryptStorage(),sa.para.batch_send&&(wx.getStorage({key:"sensors_mp_prepare_data",complete:function(e){var t=e.data&&_.isArray(e.data)?e.data:[];sa.store.mem.mdata=t.concat(sa.store.mem.mdata),sa.sendStrategy.syncStorage=!0}}),sa.sendStrategy.batchInterval()),sa.initialState.storeIsComplete=!0,sa.initialState.checkIsComplete()},sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib){var e={};_.each(_.info.currentProps,function(t,a){0===a.indexOf("$")&&(e[a]=t)});var t=_.extend(e,{$url_path:_.getCurrentPath(),$is_first_day:_.getIsFirstDay()},_.info.properties,sa.store.getProps());return delete t.$lib,t}return{}},_.autoExeQueue=function(){return{items:[],enqueue:function(e){this.items.push(e),this.start()},dequeue:function(){return this.items.shift()},getCurrentItem:function(){return this.items[0]},isRun:!1,start:function(){this.items.length>0&&!this.isRun&&(this.isRun=!0,this.getCurrentItem().start())},close:function(){this.dequeue(),this.isRun=!1,this.start()}}},sa.requestQueue=function(e){this.url=e.url},sa.requestQueue.prototype.isEnd=function(){this.received||(this.received=!0,this.close())},sa.requestQueue.prototype.start=function(){var e=this;_.wxrequest({url:this.url,method:"GET",complete:function(){e.isEnd()}})},sa.dataQueue=_.autoExeQueue(),sa.sendStrategy={dataHasSend:!0,dataHasChange:!1,syncStorage:!1,failTime:0,onAppHide:function(){sa.para.batch_send&&this.batchSend()},send:function(e){if(!sa.para.server_url)return!1;if(sa.para.batch_send){if(this.dataHasChange=!0,sa.store.mem.getLength()>=300)return logger.info("\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38"),!1;sa.store.mem.add(e),sa.store.mem.getLength()>=sa.para.batch_send.max_length&&this.batchSend()}else this.queueSend(e)},queueSend:function(e){e._flush_time=Date.now(),e=JSON.stringify(e),e=-1!==sa.para.server_url.indexOf("?")?sa.para.server_url+"&data="+encodeURIComponent(_.base64Encode(e)):sa.para.server_url+"?data="+encodeURIComponent(_.base64Encode(e));var t=new sa.requestQueue({url:e});t.close=function(){sa.dataQueue.close()},sa.dataQueue.enqueue(t)},wxrequest:function(e){if(_.isArray(e.data)&&e.data.length>0){var t=Date.now();e.data.forEach(function(e){e._flush_time=t}),e.data=JSON.stringify(e.data),_.wxrequest({url:sa.para.server_url,method:"POST",dataType:"text",data:"data_list="+encodeURIComponent(_.base64Encode(e.data)),success:function(){e.success(e.len)},fail:function(){e.fail()}})}else e.success(e.len)},batchSend:function(){if(this.dataHasSend){var e=sa.store.mem.mdata,t=e.length;t>0&&(this.dataHasSend=!1,this.wxrequest({data:e,len:t,success:this.batchRemove.bind(this),fail:this.sendFail.bind(this)}))}},sendFail:function(){this.dataHasSend=!0,this.failTime++},batchRemove:function(e){sa.store.mem.clear(e),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite(),this.failTime=0},is_first_batch_write:!0,batchWrite:function(){var e=this;this.dataHasChange&&(this.is_first_batch_write&&(this.is_first_batch_write=!1,setTimeout(function(){e.batchSend()},1e3)),this.dataHasChange=!1,this.syncStorage&&sa._.setStorageSync("sensors_mp_prepare_data",sa.store.mem.mdata))},batchInterval:function(){var e=this;!function t(){setTimeout(function(){e.batchWrite(),t()},500)}(),function t(){setTimeout(function(){e.batchSend(),t()},sa.para.batch_send.send_timeout*Math.pow(2,e.failTime))}()}},sa.setOpenid=function(e,t){sa.store.set("openid",e),t?sa.store.set("distinct_id",e):sa.identify(e,!0)},sa.initWithOpenid=function(e,t){(e=e||{}).appid&&(sa.para.appid=e.appid),sa.openid.getOpenid(function(a){a&&sa.setOpenid(a,e.isCoverLogin),t&&_.isFunction(t)&&t(a),sa.init(e)})},sa.setWebViewUrl=function(e,t){if(!_.isString(e)||""===e)return logger.info("error:\u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;e=decodeURIComponent(e);var a,r=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e),s=r[1]||"",n=r[2]||"",i=r[3]||"",o="",c=sa.store.getDistinctId()||"",u=sa.store.getFirstId()||"";_.urlSafeBase64&&_.urlSafeBase64.encode?c=c?_.urlSafeBase64.trim(_.urlSafeBase64.encode(_.urlBase64Encode(c))):"":this._.rot13obfs&&(c=c?_.rot13obfs(c):""),c=encodeURIComponent(c);var p=u?"f"+c:"d"+c;t?(a=i.indexOf("_sasdk"),o=i.indexOf("?")>-1?a>-1?s+n+"#"+i.substring(1,a)+"_sasdk="+p:s+n+"#"+i.substring(1)+"&_sasdk="+p:s+n+"#"+i.substring(1)+"?_sasdk="+p):(a=n.indexOf("_sasdk"),o=/^\?(\w)+/.test(n)?a>-1?s+"?"+n.substring(1,a)+"_sasdk="+p+i:s+"?"+n.substring(1)+"&_sasdk="+p+i:s+"?"+n.substring(1)+"_sasdk="+p+i);return o},_.each(["setProfile","setOnceProfile","track","quick","incrementProfile","appendProfile","login","logout","registerApp","register","clearAllRegister","clearAllProps","clearAppRegister"],function(e){var t=sa[e];sa[e]=function(){sa.initialState.isComplete?t.apply(sa,arguments):sa.initialState.queue.push([e,arguments])}}),_.setQuery=function(e,t){if(e&&_.isObject(e)&&!_.isEmptyObject(e)){var a=[];return _.each(e,function(e,r){"q"===r&&_.isString(e)&&0===e.indexOf("http")||(t?a.push(r+"="+e):a.push(r+"="+_.decodeURIComponent(e)))}),a.join("&")}return""},_.getUtmFromPage=function(){var e={};try{var t=getCurrentPages(),a=JSON.parse(JSON.stringify(t[t.length-1].options));for(var r in a)a[r]=_.decodeURIComponent(a[r]);e=_.getCustomUtmFromQuery(a,"$","_","$")}catch(e){logger.info(e)}return e},sa.autoTrackCustom={trackCustom:function(e,t,a){var r=sa.para.autoTrack[e],s="";sa.para.autoTrack&&r&&("function"==typeof r?(s=r(),_.isObject(s)&&_.extend(t,s)):_.isObject(r)&&(_.extend(t,r),sa.para.autoTrack[e]=!0),sa.track(a,t))},appLaunch:function(e,t){"object"!=typeof this||this.trackCustom||(this[sa.para.name]=sa);var a={};e&&e.scene?(current_scene=e.scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(a.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),_.setShareInfo(e,a);var r=_.setUtm(e,a);is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):a.$is_first_time=!1,_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),t?(a=_.extend(a,t),sa.track("$MPLaunch",a)):sa.para.autoTrack&&sa.para.autoTrack.appLaunch&&sa.autoTrackCustom.trackCustom("appLaunch",a,"$MPLaunch")},appShow:function(e,t){var a={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(a.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,a);var r=_.setUtm(e,a);_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),t?(a=_.extend(a,t),sa.track("$MPShow",a)):sa.para.autoTrack&&sa.para.autoTrack.appShow&&sa.autoTrackCustom.trackCustom("appShow",a,"$MPShow")},appHide:function(e){var t=(new Date).getTime(),a={};a.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(a.event_duration=(t-mpshow_time)/1e3),e?(a=_.extend(a,e),sa.track("$MPHide",a)):sa.para.autoTrack&&sa.para.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",a,"$MPHide"),sa.sendStrategy.onAppHide()},pageLoad:function(e){current_scene&&1010===current_scene&&e&&e.sampshare&&delete e.sampshare,e&&_.isObject(e)&&(this.sensors_mp_url_query=_.setQuery(e),this.sensors_mp_encode_url_query=_.setQuery(e,!0))},pageShow:function(){var e={},t=_.getCurrentPath(),a=_.getPageTitle(t);e.$referrer=sa_referrer,e.$url_path=t,sa.status.last_referrer=sa_referrer,e.$url_query=this.sensors_mp_url_query?this.sensors_mp_url_query:"",e=_.extend(e,_.getUtmFromPage()),_.setPageSfSource(e),a&&(e.$title=a),sa.para.onshow?sa.para.onshow(sa,t,this):_.isObject(sa.para.autotrack_exclude_page)&&_.isArray(sa.para.autotrack_exclude_page.pageShow)&&-1!==sa.para.autotrack_exclude_page.pageShow.indexOf(t)||sa.autoTrackCustom.trackCustom("pageShow",e,"$MPViewScreen"),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:t}),sa_referrer=t,sa.status.referrer=t},pageShare:function(e){var t=e.onShareAppMessage;e.onShareAppMessage=function(){share_method="\u8f6c\u53d1\u6d88\u606f\u5361\u7247";var e=t.apply(this,arguments);return sa.para.autoTrack&&sa.para.autoTrack.pageShare&&sa.autoTrackCustom.trackCustom("pageShare",{$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method},"$MPShare"),sa.para.allow_amend_share_path&&("object"!=typeof e&&((e={}).path=_.getCurrentUrl(this)),"object"!=typeof e||void 0!==e.path&&""!==e.path||(e.path=_.getCurrentUrl(this)),"object"==typeof e&&"string"==typeof e.path&&(-1===e.path.indexOf("?")?e.path=e.path+"?":"&"!==e.path.slice(-1)&&(e.path=e.path+"&")),e.path=e.path+"sampshare="+encodeURIComponent(_.getShareInfo())),e}},pageShareTimeline:function(e){var t=e.onShareTimeline;e.onShareTimeline=function(){share_method="\u670b\u53cb\u5708\u5206\u4eab";var e=t.apply(this,arguments);return sa.para.autoTrack&&sa.para.autoTrack.pageShare&&sa.autoTrackCustom.trackCustom("pageShare",{$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method},"$MPShare"),sa.para.allow_amend_share_path&&("object"!=typeof e&&(e={}),"object"==typeof e&&void 0===e.query&&(e.query=""),"object"==typeof e&&"string"==typeof e.query&&""!==e.query&&"&"!==e.query.slice(-1)&&(e.query=e.query+"&"),e.query=e.query+"sampshare="+encodeURIComponent(_.getShareInfo())),e}},pageAddFavorites:function(){var e={};e.$url_path=_.getCurrentPath(),sa.para.autoTrack&&sa.para.autoTrack.mpFavorite&&sa.autoTrackCustom.trackCustom("mpFavorite",e,"$MPAddFavorites")}},sa.quick=function(){var e=arguments[0],t=arguments[1],a=arguments[2],r=_.isObject(a)?a:{};if("getAnonymousID"===e){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===e||"appShow"===e?t?sa.autoTrackCustom[e](t,r):logger.info("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(r=_.isObject(t)?t:{},sa.autoTrackCustom[e](r))},sa.appLaunch=function(e,t){var a={};e&&e.scene?(current_scene=e.scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(a.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),_.setShareInfo(e,a);var r=_.setUtm(e,a);is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):a.$is_first_time=!1,_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),_.isObject(t)&&(a=_.extend(a,t)),sa.track("$MPLaunch",a)},sa.appShow=function(e,t){var a={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(a.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,a);var r=_.setUtm(e,a);_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),_.isObject(t)&&(a=_.extend(a,t)),sa.track("$MPShow",a)},sa.appHide=function(e){var t=(new Date).getTime(),a={};a.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(a.event_duration=(t-mpshow_time)/1e3),_.isObject(e)&&(a=_.extend(a,e)),sa.track("$MPHide",a),sa.sendStrategy.onAppHide()},sa.pageShow=function(e){var t={},a=_.getCurrentPath(),r=_.getPageTitle(a),s={};try{var n=getCurrentPages();s=n[n.length-1]}catch(e){logger.info(e)}!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a}),r&&(t.$title=r),t.$referrer=sa_referrer,t.$url_path=a,sa.status.last_referrer=sa_referrer,t.$url_query=s.sensors_mp_url_query?s.sensors_mp_url_query:"",t=_.extend(t,_.getUtmFromPage()),_.setPageSfSource(t),_.isObject(e)&&(t=_.extend(t,e)),sa.track("$MPViewScreen",t),sa_referrer=a,sa.status.referrer=a};var oldApp=App;App=function(e){e[sa.para.name]=sa,oldApp.apply(this,arguments)},wx.onAppShow(function(e){if(!sa.para.launched){var t=wx.getLaunchOptionsSync()||{};sa.autoTrackCustom.appLaunch(t),sa.para.launched=!0}sa.autoTrackCustom.appShow(e)}),wx.onAppHide(function(){sa.autoTrackCustom.appHide()});var oldPage=Page;Page=function(e){var t=sa.para.autoTrack&&sa.para.autoTrack.mpClick&&_.getMethods(e);if(t)for(var a=0,r=t.length;asa.para.max_string_length?(logger.info("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,sa.para.max_string_length)):e},_.searchObjString=function(e){_.isObject(e)&&_.each(e,function(t,a){_.isObject(t)?_.searchObjString(e[a]):_.isString(t)&&(e[a]=_.formatString(t))})},_.parseSuperProperties=function(e){_.isObject(e)&&(_.each(e,function(t,a){if(_.isFunction(t))try{e[a]=t(),_.isFunction(e[a])&&(logger.info("\u60a8\u7684\u5c5e\u6027- "+a+" \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}catch(t){delete e[a],logger.info("\u60a8\u7684\u5c5e\u6027- "+a+" \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}}),_.strip_sa_properties(e))},_.unique=function(e){for(var t,a=[],r={},s=0;s127&&i<2048?String.fromCharCode(i>>6|192,63&i|128):String.fromCharCode(i>>12|224,i>>6&63|128,63&i|128),null!==o&&(a>t&&(n+=e.substring(t,a)),n+=o,t=a=s+1)}return a>t&&(n+=e.substring(t,e.length)),n},_.base64Encode=function(e){var t,a,r,s,n,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,c=0,u="",p=[];if(!e)return e;e=_.utf8Encode(e);do{t=(n=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,a=n>>12&63,r=n>>6&63,s=63&n,p[c++]=i.charAt(t)+i.charAt(a)+i.charAt(r)+i.charAt(s)}while(o255||(r=e.charCodeAt(o++))>255||(s=e.charCodeAt(o++))>255)&&logger.info("Failed to execute 'btoa' : The string to be encoded contains characters outside of the Latin1 range."),i+=n.charAt((t=a<<16|r<<8|s)>>18&63)+n.charAt(t>>12&63)+n.charAt(t>>6&63)+n.charAt(63&t);return c?i.slice(0,c-3)+"===".substring(c):i},_.urlBase64Encode=function(e){return _.btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))},_.rot13obfs=function(e,t){t="number"==typeof t?t:13;for(var a=(e=String(e)).split(""),r=0,s=a.length;r(new Date).getTime()},_.getCurrentUrl=function(e){var t=_.getCurrentPath(),a="";return _.isObject(e)&&e.sensors_mp_encode_url_query&&(a=e.sensors_mp_encode_url_query),t?a?t+"?"+a:t:"\u672a\u53d6\u5230"},_.getPath=function(e){return e="string"==typeof e?e.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"},_.getMethods=function(e){var t=[];for(var a in e)"function"!=typeof e[a]||mpHook[a]||t.push(a);return t},_.isClick=function(e){return!!{tap:1,longpress:1,longtap:1}[e]},sa.initialState={queue:[],isComplete:!1,systemIsComplete:!1,storeIsComplete:!1,checkIsComplete:function(){this.systemIsComplete&&this.storeIsComplete&&(this.isComplete=!0,this.queue.length>0&&(_.each(this.queue,function(e){sa[e[0]].apply(sa,slice.call(e[1]))}),this.queue=[]))}},_.getCustomUtmFromQuery=function(e,t,a,r){if(!_.isObject(e))return{};var s={};if(e.sa_utm)for(var n in e)"sa_utm"!==n?_.include(sa.para.source_channel,n)&&(s[a+n]=e[n]):s[r+n]=e[n];else for(var n in e)-1===(" "+source_channel_standard+" ").indexOf(" "+n+" ")?_.include(sa.para.source_channel,n)&&(s[a+n]=e[n]):s[t+n]=e[n];return s},_.getObjFromQuery=function(e){var t=e.split("?"),a=[],r={};return t&&t[1]?(_.each(t[1].split("&"),function(e){(a=e.split("="))[0]&&a[1]&&(r[a[0]]=a[1])}),r):{}},_.setStorageSync=function(e,t){var a=function(){wx.setStorageSync(e,t)};try{a()}catch(e){logger.info("set Storage fail --",e);try{a()}catch(e){logger.info("set Storage fail again --",e)}}},_.getStorageSync=function(e){var t="";try{t=wx.getStorageSync(e)}catch(a){try{t=wx.getStorageSync(e)}catch(e){logger.info("getStorage fail")}}return t},_.getMPScene=function(e){return"number"==typeof e||"string"==typeof e&&""!==e?e="wx-"+String(e):"\u672a\u53d6\u5230\u503c"},_.setShareInfo=function(e,t){var a={},r={},s=sa.store.getDistinctId(),n=sa.store.getFirstId();if(!(e&&_.isObject(e.query)&&e.query.sampshare))return{};if(a=_.decodeURIComponent(e.query.sampshare),!_.isJSONString(a))return{};var i=(a=JSON.parse(a)).d,o=a.p,c=a.i,u=a.m;"string"==typeof c?(t.$share_distinct_id=c,share_distinct_id=c,r.$latest_share_distinct_id=c):t.$share_distinct_id="\u53d6\u503c\u5f02\u5e38","number"==typeof i?!share_distinct_id||share_distinct_id!==s&&share_distinct_id!==n?!share_distinct_id||share_distinct_id===s&&share_distinct_id===n?t.$share_depth="-1":(t.$share_depth=i+1,query_share_depth=i+1,r.$latest_share_depth=i+1):(t.$share_depth=i,query_share_depth=i,r.$latest_share_depth=i):t.$share_depth="-1","string"==typeof o?(t.$share_url_path=o,r.$latest_share_url_path=o):t.$share_url_path="\u53d6\u503c\u5f02\u5e38","string"==typeof u?(t.$share_method=u,r.$latest_share_method=u):t.$share_method="\u53d6\u503c\u5f02\u5e38",_.setLatestShare(r)},_.getShareInfo=function(){return JSON.stringify({i:sa.store.getDistinctId()||"\u53d6\u503c\u5f02\u5e38",p:_.getCurrentPath(),d:query_share_depth,m:share_method})},_.detectOptionQuery=function(e){if(!e||!_.isObject(e.query))return{};var t,a,r,s,n={};return n.query=_.extend({},e.query),"string"==typeof n.query.scene&&(t=n.query,a=["utm_source","utm_content","utm_medium","utm_campaign","utm_term","sa_utm"].concat(sa.para.source_channel),r=new RegExp("("+a.join("|")+")%3D","i"),1===(s=Object.keys(t)).length&&"scene"===s[0]&&r.test(t.scene))&&(n.scene=n.query.scene,delete n.query.scene),e.query.q&&e.query.scancode_time&&"101"===String(e.scene).slice(0,3)&&(n.q=String(n.query.q),delete n.query.q,delete n.query.scancode_time),n},_.getMixedQuery=function(e){var t=_.detectOptionQuery(e),a=t.scene,r=t.q,s=t.query;for(var n in s)s[n]=_.decodeURIComponent(s[n]);return a&&(a=-1!==(a=_.decodeURIComponent(a)).indexOf("?")?"?"+a.replace(/\?/g,""):"?"+a,_.extend(s,_.getObjFromQuery(a))),r&&_.extend(s,_.getObjFromQuery(_.decodeURIComponent(r))),s},_.setUtm=function(e,t){var a={},r=_.getMixedQuery(e),s=_.getCustomUtmFromQuery(r,"$","_","$"),n=_.getCustomUtmFromQuery(r,"$latest_","_latest_","$latest_");return a.pre1=s,a.pre2=n,_.extend(t,s),a},_.setSfSource=function(e,t){!_.isEmptyObject(e.query)&&e.query._sfs&&(t.$sf_source=e.query._sfs,sa.registerApp({$latest_sf_source:t.$sf_source}))},_.setPageSfSource=function(e){try{var t=getCurrentPages(),a=JSON.parse(JSON.stringify(t[t.length-1].options));for(var r in a)a[r]=_.decodeURIComponent(a[r]);!_.isEmptyObject(a)&&a._sfs&&(e.$sf_source=a._sfs)}catch(e){logger.info(e)}};try{var oldSetNavigationBarTitle=wx.setNavigationBarTitle;Object.defineProperty(wx,"setNavigationBarTitle",{get:function(){return function(e){var t=getCurrentPages(),a=t[t.length-1].route||"";e=_.isObject(e)?e:{},globalTitle[a]=e.title,oldSetNavigationBarTitle.call(this,e)}}})}catch(e){logger.info(e)}function mp_proxy(e,t,a){var r=sa.autoTrackCustom[a];if(e[t]){var s=e[t];e[t]=function(){"onLaunch"===t&&(this[sa.para.name]=sa),!sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&!sa.para.autoTrackIsFirst[a]?(s.apply(this,arguments),r.apply(this,arguments)):(!0===sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&sa.para.autoTrackIsFirst[a])&&(r.apply(this,arguments),s.apply(this,arguments))}}else e[t]=function(){"onLaunch"===t&&(this[sa.para.name]=sa),r.apply(this,arguments)}}function clickTrack(e){var t,a={},r={},s=e.currentTarget||{},n=e.target||{};if(_.isObject(sa.para.framework)&&_.isObject(sa.para.framework.taro)&&!sa.para.framework.taro.createApp&&n.id&&s.id&&n.id!==s.id)return!1;var i=s.dataset||{};if(t=e.type,a.$element_id=s.id,a.$element_type=i.type,a.$element_content=i.content,a.$element_name=i.name,_.isObject(e.event_prop)&&(r=e.event_prop),t&&_.isClick(t)){if(sa.para.preset_events&&sa.para.preset_events.collect_element&&!1===sa.para.preset_events.collect_element(arguments[0]))return!1;a.$url_path=_.getCurrentPath(),a=_.extend(a,r),sa.track("$MPClick",a)}}function click_proxy(e,t){var a=e[t];e[t]=function(){var e=a.apply(this,arguments),t=arguments[0];return _.isObject(t)&&(sa.para.preset_events.defer_track?setTimeout(function(){clickTrack(t)},0):clickTrack(t)),e}}function tabProxy(e){var t=e.onTabItemTap;e.onTabItemTap=function(e){t&&t.apply(this,arguments);var a={};e&&(a.$element_content=e.text),a.$element_type="tabBar",a.$url_path=_.getCurrentPath(),sa.track("$MPClick",a)}}_.getPageTitle=function(e){if("\u672a\u53d6\u5230"===e||!e)return!1;var t="";try{if(__wxConfig){var a=__wxConfig,r=a.page[e]||a.page[e+".html"],s={},n={};if(a.global&&a.global.window&&a.global.window.navigationBarTitleText&&(s.titleVal=a.global.window.navigationBarTitleText),r&&r.window&&r.window.navigationBarTitleText&&(n.titleVal=r.window.navigationBarTitleText),_.each(globalTitle,function(a,r){if(r===e)return t=a}),0===t.length){var i=_.extend(s,n);t=i.titleVal}}}catch(e){logger.info(e)}return t},_.wxrequest=function(e){if(_.compareSDKVersion(wxSDKVersion,"2.10.0")>=0)e.timeout=sa.para.datasend_timeout,wx.request(e);else{var t=wx.request(e);setTimeout(function(){_.isObject(t)&&_.isFunction(t.abort)&&t.abort()},sa.para.datasend_timeout)}},_.getAppId=function(){var e;if(wx.getAccountInfoSync&&(e=wx.getAccountInfoSync()),_.isObject(e)&&_.isObject(e.miniProgram))return e.miniProgram.appId},_.validId=function(e){return"string"!=typeof e&&"number"!=typeof e||""===e?(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1):"number"!=typeof e||(e=String(e),/^\d+$/.test(e))?e:(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1)},_.compareSDKVersion=function(e,t){e=e.split("."),t=t.split(".");for(var a=Math.max(e.length,t.length);e.lengthn)return 1;if(s-1?t.system.split(" ")[1]:t.system,wxSDKVersion=t.SDKVersion},complete:function(){var t=(new Date).getTimezoneOffset(),a=_.getAppId();_.isNumber(t)&&(e.$timezone_offset=t),a&&(e.$app_id=a),sa.initialState.systemIsComplete=!0,sa.initialState.checkIsComplete()}})}wx.getNetworkType({success:function(t){e.$network_type=_.setUpperCase(t.networkType)},complete:t})}},sa._=_,_.eventEmitter=function(){this.sub=[]},_.eventEmitter.prototype={add:function(e){this.sub.push(e)},emit:function(e,t){this.sub.forEach(function(a){a.on(e,t)})}},_.eventSub=function(e){sa.events.add(this),this._events=[],this.handle=e,this.ready=!1},_.eventSub.prototype={on:function(e,t){if(this.ready){if(_.isFunction(this.handle))try{this.handle(e,t)}catch(e){logger.info(e)}}else this._events.push({event:e,data:t})},isReady:function(){var e=this;e.ready=!0,e._events.forEach(function(t){if(_.isFunction(e.handle))try{e.handle(t.event,t.data)}catch(e){logger.info(e)}})}},sa.eventSub=_.eventSub,sa.events=new _.eventEmitter,sa.usePlugin=function(e,t){"function"==typeof e.init&&e.init(sa,t)},sa.prepareData=function(e,t){if(current_scene&&1154===current_scene&&!sa.para.preset_events.moments_page)return!1;var a={distinct_id:this.store.getDistinctId(),lib:{$lib:LIB_NAME,$lib_method:"code",$lib_version:String(LIB_VERSION)},properties:{}};_.extend(a,this.store.getUnionId(),e),_.isObject(e.properties)&&!_.isEmptyObject(e.properties)&&_.extend(a.properties,e.properties),e.type&&"profile"===e.type.slice(0,7)||(a._track_id=Number(String(Math.random()).slice(2,5)+String(Math.random()).slice(2,4)+String(Date.now()).slice(-4)),a.properties=_.extend({},_.info.properties,sa.store.getProps(),_.info.currentProps,a.properties),a.properties.$is_first_day=_.getIsFirstDay()),a.properties.$time&&_.isDate(a.properties.$time)?(a.time=1*a.properties.$time,delete a.properties.$time):a.time=1*new Date,_.parseSuperProperties(a.properties),_.searchObjDate(a),_.searchObjString(a),logger.info(a),sa.events.emit("send",a),sa.sendStrategy.send(a)},sa.store={storageInfo:null,getUUID:function(){return Date.now()+"-"+Math.floor(1e7*Math.random())+"-"+Math.random().toString(16).replace(".","")+"-"+String(31242*Math.random()).replace(".","").slice(0,8)},getStorage:function(){return this.storageInfo?this.storageInfo:(this.storageInfo=sa._.getStorageSync("sensorsdata2015_wechat")||"",this.storageInfo)},_state:{},mem:{mdata:[],getLength:function(){return this.mdata.length},add:function(e){this.mdata.push(e)},clear:function(e){this.mdata.splice(0,e)}},toState:function(e){var t=null;_.isJSONString(e)?(t=JSON.parse(e)).distinct_id?this._state=t:this.set("distinct_id",this.getUUID()):_.isObject(e)&&(t=e).distinct_id?this._state=t:this.set("distinct_id",this.getUUID())},getFirstId:function(){return this._state._first_id||this._state.first_id},getDistinctId:function(){return this._state._distinct_id||this._state.distinct_id},getUnionId:function(){var e={},t=this._state._first_id||this._state.first_id,a=this._state._distinct_id||this._state.distinct_id;return t&&a?(e.login_id=a,e.anonymous_id=t):e.anonymous_id=a,e},getProps:function(){return this._state.props||{}},setProps:function(e,t){var a=this._state.props||{};t?this.set("props",e):(_.extend(a,e),this.set("props",a))},set:function(e,t){var a={};for(var r in"string"==typeof e?a[e]=t:"object"==typeof e&&(a=e),this._state=this._state||{},a)this._state[r]=a[r],"first_id"===r?delete this._state._first_id:"distinct_id"===r&&(delete this._state._distinct_id,sa.events.emit("changeDistinctId"));this.save()},change:function(e,t){this._state["_"+e]=t},encryptStorage:function(){var e=this.getStorage(),t="data:enc;";_.isObject(e)?e=t+_.rot13obfs(JSON.stringify(e)):_.isString(e)&&-1===e.indexOf(t)&&(e=t+_.rot13obfs(e)),sa._.setStorageSync("sensorsdata2015_wechat",e)},save:function(){var e=JSON.parse(JSON.stringify(this._state));if(delete e._first_id,delete e._distinct_id,sa.para.encrypt_storage){e="data:enc;"+_.rot13obfs(JSON.stringify(e))}sa._.setStorageSync("sensorsdata2015_wechat",e)},init:function(){var e=this.getStorage();if(e)_.isString(e)&&-1!==e.indexOf("data:enc;")&&(e=e.substring("data:enc;".length),e=JSON.parse(_.rot13defs(e))),this.toState(e);else{is_first_launch=!0;var t=new Date,a=t.getTime();t.setHours(23),t.setMinutes(59),t.setSeconds(60),sa.setOnceProfile({$first_visit_time:new Date}),this.set({distinct_id:this.getUUID(),first_visit_time:a,first_visit_day_time:t.getTime()})}}},sa.setProfile=function(e,t){sa.prepareData({type:"profile_set",properties:e},t)},sa.setOnceProfile=function(e,t){sa.prepareData({type:"profile_set_once",properties:e},t)},sa.appendProfile=function(e,t){if(!_.isObject(e))return!1;_.each(e,function(t,a){_.isString(t)?e[a]=[t]:_.isArray(t)||(delete e[a],logger.info("appendProfile\u5c5e\u6027\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32\u6216\u8005\u6570\u7ec4"))}),sa.prepareData({type:"profile_append",properties:e},t)},sa.incrementProfile=function(e,t){if(!_.isObject(e))return!1;var a=e;_.isString(e)&&((e={})[a]=1),sa.prepareData({type:"profile_increment",properties:e},t)},sa.track=function(e,t,a){this.prepareData({type:"track",event:e,properties:t},a)},sa.identify=function(e,t){if(e=_.validId(e)){var a=sa.store.getFirstId();!0===t?a?sa.store.set("first_id",e):sa.store.set("distinct_id",e):a?sa.store.change("first_id",e):sa.store.change("distinct_id",e)}},sa.trackSignup=function(e,t,a,r){var s=sa.store.getFirstId()||sa.store.getDistinctId();sa.store.set("distinct_id",e),sa.prepareData({original_id:s,distinct_id:e,type:"track_signup",event:t,properties:a},r)},sa.registerApp=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&(_.info.currentProps=_.extend(_.info.currentProps,e))},sa.register=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&sa.store.setProps(e)},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.clearAllProps=function(e){var t=sa.store.getProps(),a={};_.isArray(e)&&(_.each(t,function(t,r){_.include(e,r)||(a[r]=t)}),sa.store.setProps(a,!0))},sa.clearAppRegister=function(e){_.isArray(e)&&_.each(_.info.currentProps,function(t,a){_.include(e,a)&&delete _.info.currentProps[a]})},_.setLatestChannel=function(e){_.isEmptyObject(e)||(function(e,t){var a=!1;for(var r in t)e[t[r]]&&(a=!0);return a}(e,latest_source_channel)&&(sa.clearAppRegister(latest_source_channel),sa.clearAllProps(latest_source_channel)),sa.para.is_persistent_save.utm?sa.register(e):sa.registerApp(e))},_.setLatestShare=function(e){(e.$latest_share_depth||e.$latest_share_distinct_id||e.$latest_share_url_path||e.$latest_share_method)&&(sa.clearAppRegister(latest_share_info),sa.clearAllProps(latest_share_info),sa.para.is_persistent_save.share?sa.register(e):sa.registerApp(e))},sa.login=function(e){if(e=_.validId(e)){var t=sa.store.getFirstId(),a=sa.store.getDistinctId();e!==a&&(t?sa.trackSignup(e,"$SignUp"):(sa.store.set("first_id",a),sa.trackSignup(e,"$SignUp")))}},sa.getAnonymousID=function(){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")},sa.logout=function(e){var t=sa.store.getFirstId();t?(sa.store.set("first_id",""),!0===e?sa.store.set("distinct_id",sa.store.getUUID()):sa.store.set("distinct_id",t)):logger.info("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25")},sa.getLocation=function(){wx.getSetting({success:function(e){if(!e.authSetting["scope.userLocation"])return!1;wx.getLocation({type:sa.para.preset_properties.location.type,success:function(e){sa.registerApp({$latitude:e.latitude*Math.pow(10,6),$longitude:e.longitude*Math.pow(10,6),$geo_coordinate_system:_.setUpperCase(sa.para.preset_properties.location.type)})},fail:function(e){console.log("\u83b7\u53d6\u4f4d\u7f6e\u5931\u8d25",e)}})}})},sa.openid={getRequest:function(e){wx.login({success:function(t){t.code&&sa.para.appid&&sa.para.openid_url?_.wxrequest({url:sa.para.openid_url+"&code="+t.code+"&appid="+sa.para.appid,method:"GET",complete:function(t){_.isObject(t)&&_.isObject(t.data)&&t.data.openid?e(t.data.openid):e()}}):e()}})},getWXStorage:function(){var e=sa.store.getStorage();if(e&&_.isObject(e))return e.openid},getOpenid:function(e){if(!sa.para.appid)return e(),!1;var t=this.getWXStorage();t?e(t):this.getRequest(e)}},sa.initial=function(){this._.info.getSystem(),this.store.init()},sa.init=function(e){if(!0===this.hasInit)return!1;this.hasInit=!0,sa.setPara(e),sa.para.encrypt_storage&&this.store.encryptStorage(),sa.para.batch_send&&(wx.getStorage({key:"sensors_mp_prepare_data",complete:function(e){var t=e.data&&_.isArray(e.data)?e.data:[];sa.store.mem.mdata=t.concat(sa.store.mem.mdata),sa.sendStrategy.syncStorage=!0}}),sa.sendStrategy.batchInterval()),sa.initialState.storeIsComplete=!0,sa.initialState.checkIsComplete()},sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib){var e={};_.each(_.info.currentProps,function(t,a){0===a.indexOf("$")&&(e[a]=t)});var t=_.extend(e,{$url_path:_.getCurrentPath(),$is_first_day:_.getIsFirstDay()},_.info.properties,sa.store.getProps());return delete t.$lib,t}return{}},_.autoExeQueue=function(){return{items:[],enqueue:function(e){this.items.push(e),this.start()},dequeue:function(){return this.items.shift()},getCurrentItem:function(){return this.items[0]},isRun:!1,start:function(){this.items.length>0&&!this.isRun&&(this.isRun=!0,this.getCurrentItem().start())},close:function(){this.dequeue(),this.isRun=!1,this.start()}}},sa.requestQueue=function(e){this.url=e.url},sa.requestQueue.prototype.isEnd=function(){this.received||(this.received=!0,this.close())},sa.requestQueue.prototype.start=function(){var e=this;_.wxrequest({url:this.url,method:"GET",complete:function(){e.isEnd()}})},sa.dataQueue=_.autoExeQueue(),sa.sendStrategy={dataHasSend:!0,dataHasChange:!1,syncStorage:!1,failTime:0,onAppHide:function(){sa.para.batch_send&&this.batchSend()},send:function(e){if(!sa.para.server_url)return!1;sa.para.batch_send?(this.dataHasChange=!0,sa.store.mem.getLength()>=500&&(logger.info("\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38"),sa.store.mem.mdata.shift()),sa.store.mem.add(e),sa.store.mem.getLength()>=sa.para.batch_send.max_length&&this.batchSend()):this.queueSend(e)},queueSend:function(e){e._flush_time=Date.now(),e=JSON.stringify(e),e=-1!==sa.para.server_url.indexOf("?")?sa.para.server_url+"&data="+encodeURIComponent(_.base64Encode(e)):sa.para.server_url+"?data="+encodeURIComponent(_.base64Encode(e));var t=new sa.requestQueue({url:e});t.close=function(){sa.dataQueue.close()},sa.dataQueue.enqueue(t)},wxrequest:function(e){if(_.isArray(e.data)&&e.data.length>0){var t=Date.now();e.data.forEach(function(e){e._flush_time=t}),e.data=JSON.stringify(e.data),_.wxrequest({url:sa.para.server_url,method:"POST",dataType:"text",data:"data_list="+encodeURIComponent(_.base64Encode(e.data)),success:function(){e.success(e.len)},fail:function(){e.fail()}})}else e.success(e.len)},batchSend:function(){if(this.dataHasSend){var e,t,a=sa.store.mem.mdata;(t=(e=a.length>=100?a.slice(0,100):a).length)>0&&(this.dataHasSend=!1,this.wxrequest({data:e,len:t,success:this.batchRemove.bind(this),fail:this.sendFail.bind(this)}))}},sendFail:function(){this.dataHasSend=!0,this.failTime++},batchRemove:function(e){sa.store.mem.clear(e),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite(),this.failTime=0},is_first_batch_write:!0,batchWrite:function(){var e=this;this.dataHasChange&&(this.is_first_batch_write&&(this.is_first_batch_write=!1,setTimeout(function(){e.batchSend()},1e3)),this.dataHasChange=!1,this.syncStorage&&sa._.setStorageSync("sensors_mp_prepare_data",sa.store.mem.mdata))},batchInterval:function(){var e=this;!function t(){setTimeout(function(){e.batchWrite(),t()},500)}(),function t(){setTimeout(function(){e.batchSend(),t()},sa.para.batch_send.send_timeout*Math.pow(2,e.failTime))}()}},sa.setOpenid=function(e,t){sa.store.set("openid",e),t?sa.store.set("distinct_id",e):sa.identify(e,!0)},sa.initWithOpenid=function(e,t){(e=e||{}).appid&&(sa.para.appid=e.appid),sa.openid.getOpenid(function(a){a&&sa.setOpenid(a,e.isCoverLogin),t&&_.isFunction(t)&&t(a),sa.init(e)})},sa.setWebViewUrl=function(e,t){if(!_.isString(e)||""===e)return logger.info("error:\u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;e=decodeURIComponent(e);var a,r=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e),s=r[1]||"",n=r[2]||"",i=r[3]||"",o="",c=sa.store.getDistinctId()||"",u=sa.store.getFirstId()||"";_.urlSafeBase64&&_.urlSafeBase64.encode?c=c?_.urlSafeBase64.trim(_.urlSafeBase64.encode(_.urlBase64Encode(c))):"":this._.rot13obfs&&(c=c?_.rot13obfs(c):""),c=encodeURIComponent(c);var p=u?"f"+c:"d"+c;t?(a=i.indexOf("_sasdk"),o=i.indexOf("?")>-1?a>-1?s+n+"#"+i.substring(1,a)+"_sasdk="+p:s+n+"#"+i.substring(1)+"&_sasdk="+p:s+n+"#"+i.substring(1)+"?_sasdk="+p):(a=n.indexOf("_sasdk"),o=/^\?(\w)+/.test(n)?a>-1?s+"?"+n.substring(1,a)+"_sasdk="+p+i:s+"?"+n.substring(1)+"&_sasdk="+p+i:s+"?"+n.substring(1)+"_sasdk="+p+i);return o},_.each(["setProfile","setOnceProfile","track","quick","incrementProfile","appendProfile","login","logout","registerApp","register","clearAllRegister","clearAllProps","clearAppRegister"],function(e){var t=sa[e];sa[e]=function(){sa.initialState.isComplete?t.apply(sa,arguments):sa.initialState.queue.push([e,arguments])}}),_.setQuery=function(e,t){if(e&&_.isObject(e)&&!_.isEmptyObject(e)){var a=[];return _.each(e,function(e,r){"q"===r&&_.isString(e)&&0===e.indexOf("http")||(t?a.push(r+"="+e):a.push(r+"="+_.decodeURIComponent(e)))}),a.join("&")}return""},_.getUtmFromPage=function(){var e={};try{var t=getCurrentPages(),a=JSON.parse(JSON.stringify(t[t.length-1].options));for(var r in a)a[r]=_.decodeURIComponent(a[r]);e=_.getCustomUtmFromQuery(a,"$","_","$")}catch(e){logger.info(e)}return e},sa.autoTrackCustom={trackCustom:function(e,t,a){var r=sa.para.autoTrack[e],s="";sa.para.autoTrack&&r&&("function"==typeof r?(s=r(),_.isObject(s)&&_.extend(t,s)):_.isObject(r)&&(_.extend(t,r),sa.para.autoTrack[e]=!0),sa.track(a,t))},appLaunch:function(e,t){"object"!=typeof this||this.trackCustom||(this[sa.para.name]=sa);var a={};e&&e.scene?(current_scene=e.scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(a.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),_.setShareInfo(e,a);var r=_.setUtm(e,a);is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):a.$is_first_time=!1,_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),t?(a=_.extend(a,t),sa.track("$MPLaunch",a)):sa.para.autoTrack&&sa.para.autoTrack.appLaunch&&sa.autoTrackCustom.trackCustom("appLaunch",a,"$MPLaunch")},appShow:function(e,t){var a={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(a.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,a);var r=_.setUtm(e,a);_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),t?(a=_.extend(a,t),sa.track("$MPShow",a)):sa.para.autoTrack&&sa.para.autoTrack.appShow&&sa.autoTrackCustom.trackCustom("appShow",a,"$MPShow")},appHide:function(e){var t=(new Date).getTime(),a={};a.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(a.event_duration=(t-mpshow_time)/1e3),e?(a=_.extend(a,e),sa.track("$MPHide",a)):sa.para.autoTrack&&sa.para.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",a,"$MPHide"),sa.sendStrategy.onAppHide()},pageLoad:function(e){current_scene&&1010===current_scene&&e&&e.sampshare&&delete e.sampshare,e&&_.isObject(e)&&(this.sensors_mp_url_query=_.setQuery(e),this.sensors_mp_encode_url_query=_.setQuery(e,!0))},pageShow:function(){var e={},t=_.getCurrentPath(),a=_.getPageTitle(t);e.$referrer=sa_referrer,e.$url_path=t,sa.status.last_referrer=sa_referrer,e.$url_query=this.sensors_mp_url_query?this.sensors_mp_url_query:"",e=_.extend(e,_.getUtmFromPage()),_.setPageSfSource(e),a&&(e.$title=a),sa.para.onshow?sa.para.onshow(sa,t,this):_.isObject(sa.para.autotrack_exclude_page)&&_.isArray(sa.para.autotrack_exclude_page.pageShow)&&-1!==sa.para.autotrack_exclude_page.pageShow.indexOf(t)||sa.autoTrackCustom.trackCustom("pageShow",e,"$MPViewScreen"),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:t}),sa_referrer=t,sa.status.referrer=t},pageShare:function(e){var t=e.onShareAppMessage;e.onShareAppMessage=function(){share_method="\u8f6c\u53d1\u6d88\u606f\u5361\u7247";var e=t.apply(this,arguments);return sa.para.autoTrack&&sa.para.autoTrack.pageShare&&sa.autoTrackCustom.trackCustom("pageShare",{$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method},"$MPShare"),sa.para.allow_amend_share_path&&("object"!=typeof e&&((e={}).path=_.getCurrentUrl(this)),"object"!=typeof e||void 0!==e.path&&""!==e.path||(e.path=_.getCurrentUrl(this)),"object"==typeof e&&"string"==typeof e.path&&(-1===e.path.indexOf("?")?e.path=e.path+"?":"&"!==e.path.slice(-1)&&(e.path=e.path+"&")),e.path=e.path+"sampshare="+encodeURIComponent(_.getShareInfo())),e}},pageShareTimeline:function(e){var t=e.onShareTimeline;e.onShareTimeline=function(){share_method="\u670b\u53cb\u5708\u5206\u4eab";var e=t.apply(this,arguments);return sa.para.autoTrack&&sa.para.autoTrack.pageShare&&sa.autoTrackCustom.trackCustom("pageShare",{$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method},"$MPShare"),sa.para.allow_amend_share_path&&("object"!=typeof e&&(e={}),"object"==typeof e&&void 0===e.query&&(e.query=""),"object"==typeof e&&"string"==typeof e.query&&""!==e.query&&"&"!==e.query.slice(-1)&&(e.query=e.query+"&"),e.query=e.query+"sampshare="+encodeURIComponent(_.getShareInfo())),e}},pageAddFavorites:function(){var e={};e.$url_path=_.getCurrentPath(),sa.para.autoTrack&&sa.para.autoTrack.mpFavorite&&sa.autoTrackCustom.trackCustom("mpFavorite",e,"$MPAddFavorites")}},sa.quick=function(){var e=arguments[0],t=arguments[1],a=arguments[2],r=_.isObject(a)?a:{};if("getAnonymousID"===e){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===e||"appShow"===e?t?sa.autoTrackCustom[e](t,r):logger.info("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(r=_.isObject(t)?t:{},sa.autoTrackCustom[e](r))},sa.appLaunch=function(e,t){var a={};e&&e.scene?(current_scene=e.scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(a.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),_.setShareInfo(e,a);var r=_.setUtm(e,a);is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):a.$is_first_time=!1,_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),_.isObject(t)&&(a=_.extend(a,t)),sa.track("$MPLaunch",a)},sa.appShow=function(e,t){var a={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(a.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,a);var r=_.setUtm(e,a);_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),_.isObject(t)&&(a=_.extend(a,t)),sa.track("$MPShow",a)},sa.appHide=function(e){var t=(new Date).getTime(),a={};a.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(a.event_duration=(t-mpshow_time)/1e3),_.isObject(e)&&(a=_.extend(a,e)),sa.track("$MPHide",a),sa.sendStrategy.onAppHide()},sa.pageShow=function(e){var t={},a=_.getCurrentPath(),r=_.getPageTitle(a),s={};try{var n=getCurrentPages();s=n[n.length-1]}catch(e){logger.info(e)}!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a}),r&&(t.$title=r),t.$referrer=sa_referrer,t.$url_path=a,sa.status.last_referrer=sa_referrer,t.$url_query=s.sensors_mp_url_query?s.sensors_mp_url_query:"",t=_.extend(t,_.getUtmFromPage()),_.setPageSfSource(t),_.isObject(e)&&(t=_.extend(t,e)),sa.track("$MPViewScreen",t),sa_referrer=a,sa.status.referrer=a};var oldApp=App;App=function(e){e[sa.para.name]=sa,oldApp.apply(this,arguments)},wx.onAppShow(function(e){if(!sa.para.launched){var t=wx.getLaunchOptionsSync()||{};sa.autoTrackCustom.appLaunch(t),sa.para.launched=!0}sa.autoTrackCustom.appShow(e)}),wx.onAppHide(function(){sa.autoTrackCustom.appHide()});var oldPage=Page;Page=function(e){var t=sa.para.autoTrack&&sa.para.autoTrack.mpClick&&_.getMethods(e);if(t)for(var a=0,r=t.length;asa.para.max_string_length?(logger.info("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,sa.para.max_string_length)):e},_.searchObjString=function(e){_.isObject(e)&&_.each(e,function(t,a){_.isObject(t)?_.searchObjString(e[a]):_.isString(t)&&(e[a]=_.formatString(t))})},_.parseSuperProperties=function(e){_.isObject(e)&&(_.each(e,function(t,a){if(_.isFunction(t))try{e[a]=t(),_.isFunction(e[a])&&(logger.info("\u60a8\u7684\u5c5e\u6027- "+a+" \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}catch(t){delete e[a],logger.info("\u60a8\u7684\u5c5e\u6027- "+a+" \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}}),_.strip_sa_properties(e))},_.unique=function(e){for(var t,a=[],r={},s=0;s127&&i<2048?String.fromCharCode(i>>6|192,63&i|128):String.fromCharCode(i>>12|224,i>>6&63|128,63&i|128),null!==o&&(a>t&&(n+=e.substring(t,a)),n+=o,t=a=s+1)}return a>t&&(n+=e.substring(t,e.length)),n},_.base64Encode=function(e){var t,a,r,s,n,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,c=0,u="",p=[];if(!e)return e;e=_.utf8Encode(e);do{t=(n=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,a=n>>12&63,r=n>>6&63,s=63&n,p[c++]=i.charAt(t)+i.charAt(a)+i.charAt(r)+i.charAt(s)}while(o255||(r=e.charCodeAt(o++))>255||(s=e.charCodeAt(o++))>255)&&logger.info("Failed to execute 'btoa' : The string to be encoded contains characters outside of the Latin1 range."),i+=n.charAt((t=a<<16|r<<8|s)>>18&63)+n.charAt(t>>12&63)+n.charAt(t>>6&63)+n.charAt(63&t);return c?i.slice(0,c-3)+"===".substring(c):i},_.urlBase64Encode=function(e){return _.btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))},_.rot13obfs=function(e,t){t="number"==typeof t?t:13;for(var a=(e=String(e)).split(""),r=0,s=a.length;r(new Date).getTime()},_.getCurrentUrl=function(e){var t=_.getCurrentPath(),a="";return _.isObject(e)&&e.sensors_mp_encode_url_query&&(a=e.sensors_mp_encode_url_query),t?a?t+"?"+a:t:"\u672a\u53d6\u5230"},_.getPath=function(e){return e="string"==typeof e?e.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"},_.getMethods=function(e){var t=[];for(var a in e)"function"!=typeof e[a]||mpHook[a]||t.push(a);return t},_.isClick=function(e){return!!{tap:1,longpress:1,longtap:1}[e]},sa.initialState={queue:[],isComplete:!1,systemIsComplete:!1,storeIsComplete:!1,checkIsComplete:function(){this.systemIsComplete&&this.storeIsComplete&&(this.isComplete=!0,this.queue.length>0&&(_.each(this.queue,function(e){sa[e[0]].apply(sa,slice.call(e[1]))}),this.queue=[]))}},_.getCustomUtmFromQuery=function(e,t,a,r){if(!_.isObject(e))return{};var s={};if(e.sa_utm)for(var n in e)"sa_utm"!==n?_.include(sa.para.source_channel,n)&&(s[a+n]=e[n]):s[r+n]=e[n];else for(var n in e)-1===(" "+source_channel_standard+" ").indexOf(" "+n+" ")?_.include(sa.para.source_channel,n)&&(s[a+n]=e[n]):s[t+n]=e[n];return s},_.getObjFromQuery=function(e){var t=e.split("?"),a=[],r={};return t&&t[1]?(_.each(t[1].split("&"),function(e){(a=e.split("="))[0]&&a[1]&&(r[a[0]]=a[1])}),r):{}},_.setStorageSync=function(e,t){var a=function(){wx.setStorageSync(e,t)};try{a()}catch(e){logger.info("set Storage fail --",e);try{a()}catch(e){logger.info("set Storage fail again --",e)}}},_.getStorageSync=function(e){var t="";try{t=wx.getStorageSync(e)}catch(a){try{t=wx.getStorageSync(e)}catch(e){logger.info("getStorage fail")}}return t},_.getMPScene=function(e){return"number"==typeof e||"string"==typeof e&&""!==e?e="wx-"+String(e):"\u672a\u53d6\u5230\u503c"},_.setShareInfo=function(e,t){var a={},r={},s=sa.store.getDistinctId(),n=sa.store.getFirstId();if(!(e&&_.isObject(e.query)&&e.query.sampshare))return{};if(a=_.decodeURIComponent(e.query.sampshare),!_.isJSONString(a))return{};var i=(a=JSON.parse(a)).d,o=a.p,c=a.i,u=a.m;"string"==typeof c?(t.$share_distinct_id=c,share_distinct_id=c,r.$latest_share_distinct_id=c):t.$share_distinct_id="\u53d6\u503c\u5f02\u5e38","number"==typeof i?!share_distinct_id||share_distinct_id!==s&&share_distinct_id!==n?!share_distinct_id||share_distinct_id===s&&share_distinct_id===n?t.$share_depth="-1":(t.$share_depth=i+1,query_share_depth=i+1,r.$latest_share_depth=i+1):(t.$share_depth=i,query_share_depth=i,r.$latest_share_depth=i):t.$share_depth="-1","string"==typeof o?(t.$share_url_path=o,r.$latest_share_url_path=o):t.$share_url_path="\u53d6\u503c\u5f02\u5e38","string"==typeof u?(t.$share_method=u,r.$latest_share_method=u):t.$share_method="\u53d6\u503c\u5f02\u5e38",_.setLatestShare(r)},_.getShareInfo=function(){return JSON.stringify({i:sa.store.getDistinctId()||"\u53d6\u503c\u5f02\u5e38",p:_.getCurrentPath(),d:query_share_depth,m:share_method})},_.detectOptionQuery=function(e){if(!e||!_.isObject(e.query))return{};var t,a,r,s,n={};return n.query=_.extend({},e.query),"string"==typeof n.query.scene&&(t=n.query,a=["utm_source","utm_content","utm_medium","utm_campaign","utm_term","sa_utm"].concat(sa.para.source_channel),r=new RegExp("("+a.join("|")+")%3D","i"),1===(s=Object.keys(t)).length&&"scene"===s[0]&&r.test(t.scene))&&(n.scene=n.query.scene,delete n.query.scene),e.query.q&&e.query.scancode_time&&"101"===String(e.scene).slice(0,3)&&(n.q=String(n.query.q),delete n.query.q,delete n.query.scancode_time),n},_.getMixedQuery=function(e){var t=_.detectOptionQuery(e),a=t.scene,r=t.q,s=t.query;for(var n in s)s[n]=_.decodeURIComponent(s[n]);return a&&(a=-1!==(a=_.decodeURIComponent(a)).indexOf("?")?"?"+a.replace(/\?/g,""):"?"+a,_.extend(s,_.getObjFromQuery(a))),r&&_.extend(s,_.getObjFromQuery(_.decodeURIComponent(r))),s},_.setUtm=function(e,t){var a={},r=_.getMixedQuery(e),s=_.getCustomUtmFromQuery(r,"$","_","$"),n=_.getCustomUtmFromQuery(r,"$latest_","_latest_","$latest_");return a.pre1=s,a.pre2=n,_.extend(t,s),a},_.setSfSource=function(e,t){!_.isEmptyObject(e.query)&&e.query._sfs&&(t.$sf_source=e.query._sfs,sa.registerApp({$latest_sf_source:t.$sf_source}))},_.setPageSfSource=function(e){try{var t=getCurrentPages(),a=JSON.parse(JSON.stringify(t[t.length-1].options));for(var r in a)a[r]=_.decodeURIComponent(a[r]);!_.isEmptyObject(a)&&a._sfs&&(e.$sf_source=a._sfs)}catch(e){logger.info(e)}};try{var oldSetNavigationBarTitle=wx.setNavigationBarTitle;Object.defineProperty(wx,"setNavigationBarTitle",{get:function(){return function(e){var t=getCurrentPages(),a=t[t.length-1].route||"";e=_.isObject(e)?e:{},globalTitle[a]=e.title,oldSetNavigationBarTitle.call(this,e)}}})}catch(e){logger.info(e)}function mp_proxy(e,t,a){var r=sa.autoTrackCustom[a];if(e[t]){var s=e[t];e[t]=function(){"onLaunch"===t&&(this[sa.para.name]=sa),!sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&!sa.para.autoTrackIsFirst[a]?(s.apply(this,arguments),r.apply(this,arguments)):(!0===sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&sa.para.autoTrackIsFirst[a])&&(r.apply(this,arguments),s.apply(this,arguments))}}else e[t]=function(){"onLaunch"===t&&(this[sa.para.name]=sa),r.apply(this,arguments)}}function clickTrack(e){var t,a={},r={},s=e.currentTarget||{},n=e.target||{};if(_.isObject(sa.para.framework)&&_.isObject(sa.para.framework.taro)&&!sa.para.framework.taro.createApp&&n.id&&s.id&&n.id!==s.id)return!1;var i=s.dataset||{};if(t=e.type,a.$element_id=s.id,a.$element_type=i.type,a.$element_content=i.content,a.$element_name=i.name,_.isObject(e.event_prop)&&(r=e.event_prop),t&&_.isClick(t)){if(sa.para.preset_events&&sa.para.preset_events.collect_element&&!1===sa.para.preset_events.collect_element(arguments[0]))return!1;a.$url_path=_.getCurrentPath(),a=_.extend(a,r),sa.track("$MPClick",a)}}function click_proxy(e,t){var a=e[t];e[t]=function(){var e=a.apply(this,arguments),t=arguments[0];return _.isObject(t)&&(sa.para.preset_events.defer_track?setTimeout(function(){clickTrack(t)},0):clickTrack(t)),e}}function tabProxy(e){var t=e.onTabItemTap;e.onTabItemTap=function(e){t&&t.apply(this,arguments);var a={};e&&(a.$element_content=e.text),a.$element_type="tabBar",a.$url_path=_.getCurrentPath(),sa.track("$MPClick",a)}}_.getPageTitle=function(e){if("\u672a\u53d6\u5230"===e||!e)return!1;var t="";try{if(__wxConfig){var a=__wxConfig,r=a.page[e]||a.page[e+".html"],s={},n={};if(a.global&&a.global.window&&a.global.window.navigationBarTitleText&&(s.titleVal=a.global.window.navigationBarTitleText),r&&r.window&&r.window.navigationBarTitleText&&(n.titleVal=r.window.navigationBarTitleText),_.each(globalTitle,function(a,r){if(r===e)return t=a}),0===t.length){var i=_.extend(s,n);t=i.titleVal}}}catch(e){logger.info(e)}return t},_.wxrequest=function(e){if(_.compareSDKVersion(wxSDKVersion,"2.10.0")>=0)e.timeout=sa.para.datasend_timeout,wx.request(e);else{var t=wx.request(e);setTimeout(function(){_.isObject(t)&&_.isFunction(t.abort)&&t.abort()},sa.para.datasend_timeout)}},_.getAppId=function(){var e;if(wx.getAccountInfoSync&&(e=wx.getAccountInfoSync()),_.isObject(e)&&_.isObject(e.miniProgram))return e.miniProgram.appId},_.validId=function(e){return"string"!=typeof e&&"number"!=typeof e||""===e?(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1):"number"!=typeof e||(e=String(e),/^\d+$/.test(e))?e:(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1)},_.compareSDKVersion=function(e,t){e=e.split("."),t=t.split(".");for(var a=Math.max(e.length,t.length);e.lengthn)return 1;if(s-1?t.system.split(" ")[1]:t.system,wxSDKVersion=t.SDKVersion},complete:function(){var t=(new Date).getTimezoneOffset(),a=_.getAppId();_.isNumber(t)&&(e.$timezone_offset=t),a&&(e.$app_id=a),sa.initialState.systemIsComplete=!0,sa.initialState.checkIsComplete()}})}wx.getNetworkType({success:function(t){e.$network_type=_.setUpperCase(t.networkType)},complete:t})}},sa._=_,_.eventEmitter=function(){this.sub=[]},_.eventEmitter.prototype={add:function(e){this.sub.push(e)},emit:function(e,t){this.sub.forEach(function(a){a.on(e,t)})}},_.eventSub=function(e){sa.events.add(this),this._events=[],this.handle=e,this.ready=!1},_.eventSub.prototype={on:function(e,t){if(this.ready){if(_.isFunction(this.handle))try{this.handle(e,t)}catch(e){logger.info(e)}}else this._events.push({event:e,data:t})},isReady:function(){var e=this;e.ready=!0,e._events.forEach(function(t){if(_.isFunction(e.handle))try{e.handle(t.event,t.data)}catch(e){logger.info(e)}})}},sa.eventSub=_.eventSub,sa.events=new _.eventEmitter,sa.usePlugin=function(e,t){"function"==typeof e.init&&e.init(sa,t)},sa.prepareData=function(e,t){if(current_scene&&1154===current_scene&&!sa.para.preset_events.moments_page)return!1;var a={distinct_id:this.store.getDistinctId(),lib:{$lib:LIB_NAME,$lib_method:"code",$lib_version:String(LIB_VERSION)},properties:{}};_.extend(a,this.store.getUnionId(),e),_.isObject(e.properties)&&!_.isEmptyObject(e.properties)&&_.extend(a.properties,e.properties),e.type&&"profile"===e.type.slice(0,7)||(a._track_id=Number(String(Math.random()).slice(2,5)+String(Math.random()).slice(2,4)+String(Date.now()).slice(-4)),a.properties=_.extend({},_.info.properties,sa.store.getProps(),_.info.currentProps,a.properties),a.properties.$is_first_day=_.getIsFirstDay()),a.properties.$time&&_.isDate(a.properties.$time)?(a.time=1*a.properties.$time,delete a.properties.$time):a.time=1*new Date,_.parseSuperProperties(a.properties),_.searchObjDate(a),_.searchObjString(a),logger.info(a),sa.events.emit("send",a),sa.sendStrategy.send(a)},sa.store={storageInfo:null,getUUID:function(){return Date.now()+"-"+Math.floor(1e7*Math.random())+"-"+Math.random().toString(16).replace(".","")+"-"+String(31242*Math.random()).replace(".","").slice(0,8)},getStorage:function(){return this.storageInfo?this.storageInfo:(this.storageInfo=sa._.getStorageSync("sensorsdata2015_wechat")||"",this.storageInfo)},_state:{},mem:{mdata:[],getLength:function(){return this.mdata.length},add:function(e){this.mdata.push(e)},clear:function(e){this.mdata.splice(0,e)}},toState:function(e){var t=null;_.isJSONString(e)?(t=JSON.parse(e)).distinct_id?this._state=t:this.set("distinct_id",this.getUUID()):_.isObject(e)&&(t=e).distinct_id?this._state=t:this.set("distinct_id",this.getUUID())},getFirstId:function(){return this._state._first_id||this._state.first_id},getDistinctId:function(){return this._state._distinct_id||this._state.distinct_id},getUnionId:function(){var e={},t=this._state._first_id||this._state.first_id,a=this._state._distinct_id||this._state.distinct_id;return t&&a?(e.login_id=a,e.anonymous_id=t):e.anonymous_id=a,e},getProps:function(){return this._state.props||{}},setProps:function(e,t){var a=this._state.props||{};t?this.set("props",e):(_.extend(a,e),this.set("props",a))},set:function(e,t){var a={};for(var r in"string"==typeof e?a[e]=t:"object"==typeof e&&(a=e),this._state=this._state||{},a)this._state[r]=a[r],"first_id"===r?delete this._state._first_id:"distinct_id"===r&&(delete this._state._distinct_id,sa.events.emit("changeDistinctId"));this.save()},change:function(e,t){this._state["_"+e]=t},encryptStorage:function(){var e=this.getStorage(),t="data:enc;";_.isObject(e)?e=t+_.rot13obfs(JSON.stringify(e)):_.isString(e)&&-1===e.indexOf(t)&&(e=t+_.rot13obfs(e)),sa._.setStorageSync("sensorsdata2015_wechat",e)},save:function(){var e=JSON.parse(JSON.stringify(this._state));if(delete e._first_id,delete e._distinct_id,sa.para.encrypt_storage){e="data:enc;"+_.rot13obfs(JSON.stringify(e))}sa._.setStorageSync("sensorsdata2015_wechat",e)},init:function(){var e=this.getStorage();if(e)_.isString(e)&&-1!==e.indexOf("data:enc;")&&(e=e.substring("data:enc;".length),e=JSON.parse(_.rot13defs(e))),this.toState(e);else{is_first_launch=!0;var t=new Date,a=t.getTime();t.setHours(23),t.setMinutes(59),t.setSeconds(60),sa.setOnceProfile({$first_visit_time:new Date}),this.set({distinct_id:this.getUUID(),first_visit_time:a,first_visit_day_time:t.getTime()})}}},sa.setProfile=function(e,t){sa.prepareData({type:"profile_set",properties:e},t)},sa.setOnceProfile=function(e,t){sa.prepareData({type:"profile_set_once",properties:e},t)},sa.appendProfile=function(e,t){if(!_.isObject(e))return!1;_.each(e,function(t,a){_.isString(t)?e[a]=[t]:_.isArray(t)||(delete e[a],logger.info("appendProfile\u5c5e\u6027\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32\u6216\u8005\u6570\u7ec4"))}),sa.prepareData({type:"profile_append",properties:e},t)},sa.incrementProfile=function(e,t){if(!_.isObject(e))return!1;var a=e;_.isString(e)&&((e={})[a]=1),sa.prepareData({type:"profile_increment",properties:e},t)},sa.track=function(e,t,a){this.prepareData({type:"track",event:e,properties:t},a)},sa.identify=function(e,t){if(e=_.validId(e)){var a=sa.store.getFirstId();!0===t?a?sa.store.set("first_id",e):sa.store.set("distinct_id",e):a?sa.store.change("first_id",e):sa.store.change("distinct_id",e)}},sa.trackSignup=function(e,t,a,r){var s=sa.store.getFirstId()||sa.store.getDistinctId();sa.store.set("distinct_id",e),sa.prepareData({original_id:s,distinct_id:e,type:"track_signup",event:t,properties:a},r)},sa.registerApp=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&(_.info.currentProps=_.extend(_.info.currentProps,e))},sa.register=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&sa.store.setProps(e)},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.clearAllProps=function(e){var t=sa.store.getProps(),a={};_.isArray(e)&&(_.each(t,function(t,r){_.include(e,r)||(a[r]=t)}),sa.store.setProps(a,!0))},sa.clearAppRegister=function(e){_.isArray(e)&&_.each(_.info.currentProps,function(t,a){_.include(e,a)&&delete _.info.currentProps[a]})},_.setLatestChannel=function(e){_.isEmptyObject(e)||(function(e,t){var a=!1;for(var r in t)e[t[r]]&&(a=!0);return a}(e,latest_source_channel)&&(sa.clearAppRegister(latest_source_channel),sa.clearAllProps(latest_source_channel)),sa.para.is_persistent_save.utm?sa.register(e):sa.registerApp(e))},_.setLatestShare=function(e){(e.$latest_share_depth||e.$latest_share_distinct_id||e.$latest_share_url_path||e.$latest_share_method)&&(sa.clearAppRegister(latest_share_info),sa.clearAllProps(latest_share_info),sa.para.is_persistent_save.share?sa.register(e):sa.registerApp(e))},sa.login=function(e){if(e=_.validId(e)){var t=sa.store.getFirstId(),a=sa.store.getDistinctId();e!==a&&(t?sa.trackSignup(e,"$SignUp"):(sa.store.set("first_id",a),sa.trackSignup(e,"$SignUp")))}},sa.getAnonymousID=function(){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")},sa.logout=function(e){var t=sa.store.getFirstId();t?(sa.store.set("first_id",""),!0===e?sa.store.set("distinct_id",sa.store.getUUID()):sa.store.set("distinct_id",t)):logger.info("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25")},sa.getLocation=function(){wx.getSetting({success:function(e){if(!e.authSetting["scope.userLocation"])return!1;wx.getLocation({type:sa.para.preset_properties.location.type,success:function(e){sa.registerApp({$latitude:e.latitude*Math.pow(10,6),$longitude:e.longitude*Math.pow(10,6),$geo_coordinate_system:_.setUpperCase(sa.para.preset_properties.location.type)})},fail:function(e){console.log("\u83b7\u53d6\u4f4d\u7f6e\u5931\u8d25",e)}})}})},sa.openid={getRequest:function(e){wx.login({success:function(t){t.code&&sa.para.appid&&sa.para.openid_url?_.wxrequest({url:sa.para.openid_url+"&code="+t.code+"&appid="+sa.para.appid,method:"GET",complete:function(t){_.isObject(t)&&_.isObject(t.data)&&t.data.openid?e(t.data.openid):e()}}):e()}})},getWXStorage:function(){var e=sa.store.getStorage();if(e&&_.isObject(e))return e.openid},getOpenid:function(e){if(!sa.para.appid)return e(),!1;var t=this.getWXStorage();t?e(t):this.getRequest(e)}},sa.initial=function(){this._.info.getSystem(),this.store.init()},sa.init=function(e){if(!0===this.hasInit)return!1;this.hasInit=!0,sa.setPara(e),sa.para.encrypt_storage&&this.store.encryptStorage(),sa.para.batch_send&&(wx.getStorage({key:"sensors_mp_prepare_data",complete:function(e){var t=e.data&&_.isArray(e.data)?e.data:[];sa.store.mem.mdata=t.concat(sa.store.mem.mdata),sa.sendStrategy.syncStorage=!0}}),sa.sendStrategy.batchInterval()),sa.initialState.storeIsComplete=!0,sa.initialState.checkIsComplete()},sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib){var e={};_.each(_.info.currentProps,function(t,a){0===a.indexOf("$")&&(e[a]=t)});var t=_.extend(e,{$url_path:_.getCurrentPath(),$is_first_day:_.getIsFirstDay()},_.info.properties,sa.store.getProps());return delete t.$lib,t}return{}},_.autoExeQueue=function(){return{items:[],enqueue:function(e){this.items.push(e),this.start()},dequeue:function(){return this.items.shift()},getCurrentItem:function(){return this.items[0]},isRun:!1,start:function(){this.items.length>0&&!this.isRun&&(this.isRun=!0,this.getCurrentItem().start())},close:function(){this.dequeue(),this.isRun=!1,this.start()}}},sa.requestQueue=function(e){this.url=e.url},sa.requestQueue.prototype.isEnd=function(){this.received||(this.received=!0,this.close())},sa.requestQueue.prototype.start=function(){var e=this;_.wxrequest({url:this.url,method:"GET",complete:function(){e.isEnd()}})},sa.dataQueue=_.autoExeQueue(),sa.sendStrategy={dataHasSend:!0,dataHasChange:!1,syncStorage:!1,failTime:0,onAppHide:function(){sa.para.batch_send&&this.batchSend()},send:function(e){if(!sa.para.server_url)return!1;if(sa.para.batch_send){if(this.dataHasChange=!0,sa.store.mem.getLength()>=300)return logger.info("\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38"),!1;sa.store.mem.add(e),sa.store.mem.getLength()>=sa.para.batch_send.max_length&&this.batchSend()}else this.queueSend(e)},queueSend:function(e){e._flush_time=Date.now(),e=JSON.stringify(e),e=-1!==sa.para.server_url.indexOf("?")?sa.para.server_url+"&data="+encodeURIComponent(_.base64Encode(e)):sa.para.server_url+"?data="+encodeURIComponent(_.base64Encode(e));var t=new sa.requestQueue({url:e});t.close=function(){sa.dataQueue.close()},sa.dataQueue.enqueue(t)},wxrequest:function(e){if(_.isArray(e.data)&&e.data.length>0){var t=Date.now();e.data.forEach(function(e){e._flush_time=t}),e.data=JSON.stringify(e.data),_.wxrequest({url:sa.para.server_url,method:"POST",dataType:"text",data:"data_list="+encodeURIComponent(_.base64Encode(e.data)),success:function(){e.success(e.len)},fail:function(){e.fail()}})}else e.success(e.len)},batchSend:function(){if(this.dataHasSend){var e=sa.store.mem.mdata,t=e.length;t>0&&(this.dataHasSend=!1,this.wxrequest({data:e,len:t,success:this.batchRemove.bind(this),fail:this.sendFail.bind(this)}))}},sendFail:function(){this.dataHasSend=!0,this.failTime++},batchRemove:function(e){sa.store.mem.clear(e),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite(),this.failTime=0},is_first_batch_write:!0,batchWrite:function(){var e=this;this.dataHasChange&&(this.is_first_batch_write&&(this.is_first_batch_write=!1,setTimeout(function(){e.batchSend()},1e3)),this.dataHasChange=!1,this.syncStorage&&sa._.setStorageSync("sensors_mp_prepare_data",sa.store.mem.mdata))},batchInterval:function(){var e=this;!function t(){setTimeout(function(){e.batchWrite(),t()},500)}(),function t(){setTimeout(function(){e.batchSend(),t()},sa.para.batch_send.send_timeout*Math.pow(2,e.failTime))}()}},sa.setOpenid=function(e,t){sa.store.set("openid",e),t?sa.store.set("distinct_id",e):sa.identify(e,!0)},sa.initWithOpenid=function(e,t){(e=e||{}).appid&&(sa.para.appid=e.appid),sa.openid.getOpenid(function(a){a&&sa.setOpenid(a,e.isCoverLogin),t&&_.isFunction(t)&&t(a),sa.init(e)})},sa.setWebViewUrl=function(e,t){if(!_.isString(e)||""===e)return logger.info("error:\u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;e=decodeURIComponent(e);var a,r=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e),s=r[1]||"",n=r[2]||"",i=r[3]||"",o="",c=sa.store.getDistinctId()||"",u=sa.store.getFirstId()||"";_.urlSafeBase64&&_.urlSafeBase64.encode?c=c?_.urlSafeBase64.trim(_.urlSafeBase64.encode(_.urlBase64Encode(c))):"":this._.rot13obfs&&(c=c?_.rot13obfs(c):""),c=encodeURIComponent(c);var p=u?"f"+c:"d"+c;t?(a=i.indexOf("_sasdk"),o=i.indexOf("?")>-1?a>-1?s+n+"#"+i.substring(1,a)+"_sasdk="+p:s+n+"#"+i.substring(1)+"&_sasdk="+p:s+n+"#"+i.substring(1)+"?_sasdk="+p):(a=n.indexOf("_sasdk"),o=/^\?(\w)+/.test(n)?a>-1?s+"?"+n.substring(1,a)+"_sasdk="+p+i:s+"?"+n.substring(1)+"&_sasdk="+p+i:s+"?"+n.substring(1)+"_sasdk="+p+i);return o},_.each(["setProfile","setOnceProfile","track","quick","incrementProfile","appendProfile","login","logout","registerApp","register","clearAllRegister","clearAllProps","clearAppRegister"],function(e){var t=sa[e];sa[e]=function(){sa.initialState.isComplete?t.apply(sa,arguments):sa.initialState.queue.push([e,arguments])}}),_.setQuery=function(e,t){if(e&&_.isObject(e)&&!_.isEmptyObject(e)){var a=[];return _.each(e,function(e,r){"q"===r&&_.isString(e)&&0===e.indexOf("http")||(t?a.push(r+"="+e):a.push(r+"="+_.decodeURIComponent(e)))}),a.join("&")}return""},_.getUtmFromPage=function(){var e={};try{var t=getCurrentPages(),a=JSON.parse(JSON.stringify(t[t.length-1].options));for(var r in a)a[r]=_.decodeURIComponent(a[r]);e=_.getCustomUtmFromQuery(a,"$","_","$")}catch(e){logger.info(e)}return e},sa.autoTrackCustom={trackCustom:function(e,t,a){var r=sa.para.autoTrack[e],s="";sa.para.autoTrack&&r&&("function"==typeof r?(s=r(),_.isObject(s)&&_.extend(t,s)):_.isObject(r)&&(_.extend(t,r),sa.para.autoTrack[e]=!0),sa.track(a,t))},appLaunch:function(e,t){"object"!=typeof this||this.trackCustom||(this[sa.para.name]=sa);var a={};e&&e.scene?(current_scene=e.scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(a.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),_.setShareInfo(e,a);var r=_.setUtm(e,a);is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):a.$is_first_time=!1,_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),t?(a=_.extend(a,t),sa.track("$MPLaunch",a)):sa.para.autoTrack&&sa.para.autoTrack.appLaunch&&sa.autoTrackCustom.trackCustom("appLaunch",a,"$MPLaunch")},appShow:function(e,t){var a={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(a.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,a);var r=_.setUtm(e,a);_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),t?(a=_.extend(a,t),sa.track("$MPShow",a)):sa.para.autoTrack&&sa.para.autoTrack.appShow&&sa.autoTrackCustom.trackCustom("appShow",a,"$MPShow")},appHide:function(e){var t=(new Date).getTime(),a={};a.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(a.event_duration=(t-mpshow_time)/1e3),e?(a=_.extend(a,e),sa.track("$MPHide",a)):sa.para.autoTrack&&sa.para.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",a,"$MPHide"),sa.sendStrategy.onAppHide()},pageLoad:function(e){current_scene&&1010===current_scene&&e&&e.sampshare&&delete e.sampshare,e&&_.isObject(e)&&(this.sensors_mp_url_query=_.setQuery(e),this.sensors_mp_encode_url_query=_.setQuery(e,!0))},pageShow:function(){var e={},t=_.getCurrentPath(),a=_.getPageTitle(t);e.$referrer=sa_referrer,e.$url_path=t,sa.status.last_referrer=sa_referrer,e.$url_query=this.sensors_mp_url_query?this.sensors_mp_url_query:"",e=_.extend(e,_.getUtmFromPage()),_.setPageSfSource(e),a&&(e.$title=a),sa.para.onshow?sa.para.onshow(sa,t,this):_.isObject(sa.para.autotrack_exclude_page)&&_.isArray(sa.para.autotrack_exclude_page.pageShow)&&-1!==sa.para.autotrack_exclude_page.pageShow.indexOf(t)||sa.autoTrackCustom.trackCustom("pageShow",e,"$MPViewScreen"),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:t}),sa_referrer=t,sa.status.referrer=t},pageShare:function(e){var t=e.onShareAppMessage;e.onShareAppMessage=function(){share_method="\u8f6c\u53d1\u6d88\u606f\u5361\u7247";var e=t.apply(this,arguments);return sa.para.autoTrack&&sa.para.autoTrack.pageShare&&sa.autoTrackCustom.trackCustom("pageShare",{$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method},"$MPShare"),sa.para.allow_amend_share_path&&("object"!=typeof e&&((e={}).path=_.getCurrentUrl(this)),"object"!=typeof e||void 0!==e.path&&""!==e.path||(e.path=_.getCurrentUrl(this)),"object"==typeof e&&"string"==typeof e.path&&(-1===e.path.indexOf("?")?e.path=e.path+"?":"&"!==e.path.slice(-1)&&(e.path=e.path+"&")),e.path=e.path+"sampshare="+encodeURIComponent(_.getShareInfo())),e}},pageShareTimeline:function(e){var t=e.onShareTimeline;e.onShareTimeline=function(){share_method="\u670b\u53cb\u5708\u5206\u4eab";var e=t.apply(this,arguments);return sa.para.autoTrack&&sa.para.autoTrack.pageShare&&sa.autoTrackCustom.trackCustom("pageShare",{$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method},"$MPShare"),sa.para.allow_amend_share_path&&("object"!=typeof e&&(e={}),"object"==typeof e&&void 0===e.query&&(e.query=""),"object"==typeof e&&"string"==typeof e.query&&""!==e.query&&"&"!==e.query.slice(-1)&&(e.query=e.query+"&"),e.query=e.query+"sampshare="+encodeURIComponent(_.getShareInfo())),e}},pageAddFavorites:function(){var e={};e.$url_path=_.getCurrentPath(),sa.para.autoTrack&&sa.para.autoTrack.mpFavorite&&sa.autoTrackCustom.trackCustom("mpFavorite",e,"$MPAddFavorites")}},sa.quick=function(){var e=arguments[0],t=arguments[1],a=arguments[2],r=_.isObject(a)?a:{};if("getAnonymousID"===e){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===e||"appShow"===e?t?sa.autoTrackCustom[e](t,r):logger.info("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(r=_.isObject(t)?t:{},sa.autoTrackCustom[e](r))},sa.appLaunch=function(e,t){var a={};e&&e.scene?(current_scene=e.scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(a.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),_.setShareInfo(e,a);var r=_.setUtm(e,a);is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):a.$is_first_time=!1,_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),_.isObject(t)&&(a=_.extend(a,t)),sa.track("$MPLaunch",a)},sa.appShow=function(e,t){var a={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(a.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,a);var r=_.setUtm(e,a);_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),_.isObject(t)&&(a=_.extend(a,t)),sa.track("$MPShow",a)},sa.appHide=function(e){var t=(new Date).getTime(),a={};a.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(a.event_duration=(t-mpshow_time)/1e3),_.isObject(e)&&(a=_.extend(a,e)),sa.track("$MPHide",a),sa.sendStrategy.onAppHide()},sa.pageShow=function(e){var t={},a=_.getCurrentPath(),r=_.getPageTitle(a),s={};try{var n=getCurrentPages();s=n[n.length-1]}catch(e){logger.info(e)}!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a}),r&&(t.$title=r),t.$referrer=sa_referrer,t.$url_path=a,sa.status.last_referrer=sa_referrer,t.$url_query=s.sensors_mp_url_query?s.sensors_mp_url_query:"",t=_.extend(t,_.getUtmFromPage()),_.setPageSfSource(t),_.isObject(e)&&(t=_.extend(t,e)),sa.track("$MPViewScreen",t),sa_referrer=a,sa.status.referrer=a};var oldApp=App;App=function(e){e[sa.para.name]=sa,oldApp.apply(this,arguments)},wx.onAppShow(function(e){if(!sa.para.launched){var t=wx.getLaunchOptionsSync()||{};sa.autoTrackCustom.appLaunch(t),sa.para.launched=!0}sa.autoTrackCustom.appShow(e)}),wx.onAppHide(function(){sa.autoTrackCustom.appHide()});var oldPage=Page;Page=function(e){var t=sa.para.autoTrack&&sa.para.autoTrack.mpClick&&_.getMethods(e);if(t)for(var a=0,r=t.length;asa.para.max_string_length?(logger.info("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,sa.para.max_string_length)):e},_.searchObjString=function(e){_.isObject(e)&&_.each(e,function(t,a){_.isObject(t)?_.searchObjString(e[a]):_.isString(t)&&(e[a]=_.formatString(t))})},_.parseSuperProperties=function(e){_.isObject(e)&&(_.each(e,function(t,a){if(_.isFunction(t))try{e[a]=t(),_.isFunction(e[a])&&(logger.info("\u60a8\u7684\u5c5e\u6027- "+a+" \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}catch(t){delete e[a],logger.info("\u60a8\u7684\u5c5e\u6027- "+a+" \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}}),_.strip_sa_properties(e))},_.unique=function(e){for(var t,a=[],r={},s=0;s127&&i<2048?String.fromCharCode(i>>6|192,63&i|128):String.fromCharCode(i>>12|224,i>>6&63|128,63&i|128),null!==o&&(a>t&&(n+=e.substring(t,a)),n+=o,t=a=s+1)}return a>t&&(n+=e.substring(t,e.length)),n},_.base64Encode=function(e){var t,a,r,s,n,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,c=0,u="",p=[];if(!e)return e;e=_.utf8Encode(e);do{t=(n=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,a=n>>12&63,r=n>>6&63,s=63&n,p[c++]=i.charAt(t)+i.charAt(a)+i.charAt(r)+i.charAt(s)}while(o255||(r=e.charCodeAt(o++))>255||(s=e.charCodeAt(o++))>255)&&logger.info("Failed to execute 'btoa' : The string to be encoded contains characters outside of the Latin1 range."),i+=n.charAt((t=a<<16|r<<8|s)>>18&63)+n.charAt(t>>12&63)+n.charAt(t>>6&63)+n.charAt(63&t);return c?i.slice(0,c-3)+"===".substring(c):i},_.urlBase64Encode=function(e){return _.btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))},_.rot13obfs=function(e,t){t="number"==typeof t?t:13;for(var a=(e=String(e)).split(""),r=0,s=a.length;r(new Date).getTime()},_.getCurrentUrl=function(e){var t=_.getCurrentPath(),a="";return _.isObject(e)&&e.sensors_mp_encode_url_query&&(a=e.sensors_mp_encode_url_query),t?a?t+"?"+a:t:"\u672a\u53d6\u5230"},_.getPath=function(e){return e="string"==typeof e?e.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"},_.getMethods=function(e){var t=[];for(var a in e)"function"!=typeof e[a]||mpHook[a]||t.push(a);return t},_.isClick=function(e){return!!{tap:1,longpress:1,longtap:1}[e]},sa.initialState={queue:[],isComplete:!1,systemIsComplete:!1,storeIsComplete:!1,checkIsComplete:function(){this.systemIsComplete&&this.storeIsComplete&&(this.isComplete=!0,this.queue.length>0&&(_.each(this.queue,function(e){sa[e[0]].apply(sa,slice.call(e[1]))}),this.queue=[]))}},_.getCustomUtmFromQuery=function(e,t,a,r){if(!_.isObject(e))return{};var s={};if(e.sa_utm)for(var n in e)"sa_utm"!==n?_.include(sa.para.source_channel,n)&&(s[a+n]=e[n]):s[r+n]=e[n];else for(var n in e)-1===(" "+source_channel_standard+" ").indexOf(" "+n+" ")?_.include(sa.para.source_channel,n)&&(s[a+n]=e[n]):s[t+n]=e[n];return s},_.getObjFromQuery=function(e){var t=e.split("?"),a=[],r={};return t&&t[1]?(_.each(t[1].split("&"),function(e){(a=e.split("="))[0]&&a[1]&&(r[a[0]]=a[1])}),r):{}},_.setStorageSync=function(e,t){var a=function(){wx.setStorageSync(e,t)};try{a()}catch(e){logger.info("set Storage fail --",e);try{a()}catch(e){logger.info("set Storage fail again --",e)}}},_.getStorageSync=function(e){var t="";try{t=wx.getStorageSync(e)}catch(a){try{t=wx.getStorageSync(e)}catch(e){logger.info("getStorage fail")}}return t},_.getMPScene=function(e){return"number"==typeof e||"string"==typeof e&&""!==e?e="wx-"+String(e):"\u672a\u53d6\u5230\u503c"},_.setShareInfo=function(e,t){var a={},r={},s=sa.store.getDistinctId(),n=sa.store.getFirstId();if(!(e&&_.isObject(e.query)&&e.query.sampshare))return{};if(a=_.decodeURIComponent(e.query.sampshare),!_.isJSONString(a))return{};var i=(a=JSON.parse(a)).d,o=a.p,c=a.i,u=a.m;"string"==typeof c?(t.$share_distinct_id=c,share_distinct_id=c,r.$latest_share_distinct_id=c):t.$share_distinct_id="\u53d6\u503c\u5f02\u5e38","number"==typeof i?!share_distinct_id||share_distinct_id!==s&&share_distinct_id!==n?!share_distinct_id||share_distinct_id===s&&share_distinct_id===n?t.$share_depth="-1":(t.$share_depth=i+1,query_share_depth=i+1,r.$latest_share_depth=i+1):(t.$share_depth=i,query_share_depth=i,r.$latest_share_depth=i):t.$share_depth="-1","string"==typeof o?(t.$share_url_path=o,r.$latest_share_url_path=o):t.$share_url_path="\u53d6\u503c\u5f02\u5e38","string"==typeof u?(t.$share_method=u,r.$latest_share_method=u):t.$share_method="\u53d6\u503c\u5f02\u5e38",_.setLatestShare(r)},_.getShareInfo=function(){return JSON.stringify({i:sa.store.getDistinctId()||"\u53d6\u503c\u5f02\u5e38",p:_.getCurrentPath(),d:query_share_depth,m:share_method})},_.detectOptionQuery=function(e){if(!e||!_.isObject(e.query))return{};var t,a,r,s,n={};return n.query=_.extend({},e.query),"string"==typeof n.query.scene&&(t=n.query,a=["utm_source","utm_content","utm_medium","utm_campaign","utm_term","sa_utm"].concat(sa.para.source_channel),r=new RegExp("("+a.join("|")+")%3D","i"),1===(s=Object.keys(t)).length&&"scene"===s[0]&&r.test(t.scene))&&(n.scene=n.query.scene,delete n.query.scene),e.query.q&&e.query.scancode_time&&"101"===String(e.scene).slice(0,3)&&(n.q=String(n.query.q),delete n.query.q,delete n.query.scancode_time),n},_.getMixedQuery=function(e){var t=_.detectOptionQuery(e),a=t.scene,r=t.q,s=t.query;for(var n in s)s[n]=_.decodeURIComponent(s[n]);return a&&(a=-1!==(a=_.decodeURIComponent(a)).indexOf("?")?"?"+a.replace(/\?/g,""):"?"+a,_.extend(s,_.getObjFromQuery(a))),r&&_.extend(s,_.getObjFromQuery(_.decodeURIComponent(r))),s},_.setUtm=function(e,t){var a={},r=_.getMixedQuery(e),s=_.getCustomUtmFromQuery(r,"$","_","$"),n=_.getCustomUtmFromQuery(r,"$latest_","_latest_","$latest_");return a.pre1=s,a.pre2=n,_.extend(t,s),a},_.setSfSource=function(e,t){!_.isEmptyObject(e.query)&&e.query._sfs&&(t.$sf_source=e.query._sfs,sa.registerApp({$latest_sf_source:t.$sf_source}))},_.setPageSfSource=function(e){try{var t=getCurrentPages(),a=JSON.parse(JSON.stringify(t[t.length-1].options));for(var r in a)a[r]=_.decodeURIComponent(a[r]);!_.isEmptyObject(a)&&a._sfs&&(e.$sf_source=a._sfs)}catch(e){logger.info(e)}};try{var oldSetNavigationBarTitle=wx.setNavigationBarTitle;Object.defineProperty(wx,"setNavigationBarTitle",{get:function(){return function(e){var t=getCurrentPages(),a=t[t.length-1].route||"";e=_.isObject(e)?e:{},globalTitle[a]=e.title,oldSetNavigationBarTitle.call(this,e)}}})}catch(e){logger.info(e)}function mp_proxy(e,t,a){var r=sa.autoTrackCustom[a];if(e[t]){var s=e[t];e[t]=function(){"onLaunch"===t&&(this[sa.para.name]=sa),!sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&!sa.para.autoTrackIsFirst[a]?(s.apply(this,arguments),r.apply(this,arguments)):(!0===sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&sa.para.autoTrackIsFirst[a])&&(r.apply(this,arguments),s.apply(this,arguments))}}else e[t]=function(){"onLaunch"===t&&(this[sa.para.name]=sa),r.apply(this,arguments)}}function clickTrack(e){var t,a={},r={},s=e.currentTarget||{},n=e.target||{};if(_.isObject(sa.para.framework)&&_.isObject(sa.para.framework.taro)&&!sa.para.framework.taro.createApp&&n.id&&s.id&&n.id!==s.id)return!1;var i=s.dataset||{};if(t=e.type,a.$element_id=s.id,a.$element_type=i.type,a.$element_content=i.content,a.$element_name=i.name,_.isObject(e.event_prop)&&(r=e.event_prop),t&&_.isClick(t)){if(sa.para.preset_events&&sa.para.preset_events.collect_element&&!1===sa.para.preset_events.collect_element(arguments[0]))return!1;a.$url_path=_.getCurrentPath(),a=_.extend(a,r),sa.track("$MPClick",a)}}function click_proxy(e,t){var a=e[t];e[t]=function(){var e=a.apply(this,arguments),t=arguments[0];return _.isObject(t)&&(sa.para.preset_events.defer_track?setTimeout(function(){clickTrack(t)},0):clickTrack(t)),e}}function tabProxy(e){var t=e.onTabItemTap;e.onTabItemTap=function(e){t&&t.apply(this,arguments);var a={};e&&(a.$element_content=e.text),a.$element_type="tabBar",a.$url_path=_.getCurrentPath(),sa.track("$MPClick",a)}}_.getPageTitle=function(e){if("\u672a\u53d6\u5230"===e||!e)return!1;var t="";try{if(__wxConfig){var a=__wxConfig,r=a.page[e]||a.page[e+".html"],s={},n={};if(a.global&&a.global.window&&a.global.window.navigationBarTitleText&&(s.titleVal=a.global.window.navigationBarTitleText),r&&r.window&&r.window.navigationBarTitleText&&(n.titleVal=r.window.navigationBarTitleText),_.each(globalTitle,function(a,r){if(r===e)return t=a}),0===t.length){var i=_.extend(s,n);t=i.titleVal}}}catch(e){logger.info(e)}return t},_.wxrequest=function(e){if(_.compareSDKVersion(wxSDKVersion,"2.10.0")>=0)e.timeout=sa.para.datasend_timeout,wx.request(e);else{var t=wx.request(e);setTimeout(function(){_.isObject(t)&&_.isFunction(t.abort)&&t.abort()},sa.para.datasend_timeout)}},_.getAppId=function(){var e;if(wx.getAccountInfoSync&&(e=wx.getAccountInfoSync()),_.isObject(e)&&_.isObject(e.miniProgram))return e.miniProgram.appId},_.validId=function(e){return"string"!=typeof e&&"number"!=typeof e||""===e?(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1):"number"!=typeof e||(e=String(e),/^\d+$/.test(e))?e:(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1)},_.compareSDKVersion=function(e,t){e=e.split("."),t=t.split(".");for(var a=Math.max(e.length,t.length);e.lengthn)return 1;if(s-1?t.system.split(" ")[1]:t.system,wxSDKVersion=t.SDKVersion},complete:function(){var t=(new Date).getTimezoneOffset(),a=_.getAppId();_.isNumber(t)&&(e.$timezone_offset=t),a&&(e.$app_id=a),sa.initialState.systemIsComplete=!0,sa.initialState.checkIsComplete()}})}wx.getNetworkType({success:function(t){e.$network_type=_.setUpperCase(t.networkType)},complete:t})}},sa._=_,_.eventEmitter=function(){this.sub=[]},_.eventEmitter.prototype={add:function(e){this.sub.push(e)},emit:function(e,t){this.sub.forEach(function(a){a.on(e,t)})}},_.eventSub=function(e){sa.events.add(this),this._events=[],this.handle=e,this.ready=!1},_.eventSub.prototype={on:function(e,t){if(this.ready){if(_.isFunction(this.handle))try{this.handle(e,t)}catch(e){logger.info(e)}}else this._events.push({event:e,data:t})},isReady:function(){var e=this;e.ready=!0,e._events.forEach(function(t){if(_.isFunction(e.handle))try{e.handle(t.event,t.data)}catch(e){logger.info(e)}})}},sa.eventSub=_.eventSub,sa.events=new _.eventEmitter,sa.usePlugin=function(e,t){"function"==typeof e.init&&e.init(sa,t)},sa.prepareData=function(e,t){if(current_scene&&1154===current_scene&&!sa.para.preset_events.moments_page)return!1;var a={distinct_id:this.store.getDistinctId(),lib:{$lib:LIB_NAME,$lib_method:"code",$lib_version:String(LIB_VERSION)},properties:{}};_.extend(a,this.store.getUnionId(),e),_.isObject(e.properties)&&!_.isEmptyObject(e.properties)&&_.extend(a.properties,e.properties),e.type&&"profile"===e.type.slice(0,7)||(a._track_id=Number(String(Math.random()).slice(2,5)+String(Math.random()).slice(2,4)+String(Date.now()).slice(-4)),a.properties=_.extend({},_.info.properties,sa.store.getProps(),_.info.currentProps,a.properties),a.properties.$is_first_day=_.getIsFirstDay()),a.properties.$time&&_.isDate(a.properties.$time)?(a.time=1*a.properties.$time,delete a.properties.$time):a.time=1*new Date,_.parseSuperProperties(a.properties),_.searchObjDate(a),_.searchObjString(a),logger.info(a),sa.events.emit("send",a),sa.sendStrategy.send(a)},sa.store={storageInfo:null,getUUID:function(){return Date.now()+"-"+Math.floor(1e7*Math.random())+"-"+Math.random().toString(16).replace(".","")+"-"+String(31242*Math.random()).replace(".","").slice(0,8)},getStorage:function(){return this.storageInfo?this.storageInfo:(this.storageInfo=sa._.getStorageSync("sensorsdata2015_wechat")||"",this.storageInfo)},_state:{},mem:{mdata:[],getLength:function(){return this.mdata.length},add:function(e){this.mdata.push(e)},clear:function(e){this.mdata.splice(0,e)}},toState:function(e){var t=null;_.isJSONString(e)?(t=JSON.parse(e)).distinct_id?this._state=t:this.set("distinct_id",this.getUUID()):_.isObject(e)&&(t=e).distinct_id?this._state=t:this.set("distinct_id",this.getUUID())},getFirstId:function(){return this._state._first_id||this._state.first_id},getDistinctId:function(){return this._state._distinct_id||this._state.distinct_id},getUnionId:function(){var e={},t=this._state._first_id||this._state.first_id,a=this._state._distinct_id||this._state.distinct_id;return t&&a?(e.login_id=a,e.anonymous_id=t):e.anonymous_id=a,e},getProps:function(){return this._state.props||{}},setProps:function(e,t){var a=this._state.props||{};t?this.set("props",e):(_.extend(a,e),this.set("props",a))},set:function(e,t){var a={};for(var r in"string"==typeof e?a[e]=t:"object"==typeof e&&(a=e),this._state=this._state||{},a)this._state[r]=a[r],"first_id"===r?delete this._state._first_id:"distinct_id"===r&&(delete this._state._distinct_id,sa.events.emit("changeDistinctId"));this.save()},change:function(e,t){this._state["_"+e]=t},encryptStorage:function(){var e=this.getStorage(),t="data:enc;";_.isObject(e)?e=t+_.rot13obfs(JSON.stringify(e)):_.isString(e)&&-1===e.indexOf(t)&&(e=t+_.rot13obfs(e)),sa._.setStorageSync("sensorsdata2015_wechat",e)},save:function(){var e=JSON.parse(JSON.stringify(this._state));if(delete e._first_id,delete e._distinct_id,sa.para.encrypt_storage){e="data:enc;"+_.rot13obfs(JSON.stringify(e))}sa._.setStorageSync("sensorsdata2015_wechat",e)},init:function(){var e=this.getStorage();if(e)_.isString(e)&&-1!==e.indexOf("data:enc;")&&(e=e.substring("data:enc;".length),e=JSON.parse(_.rot13defs(e))),this.toState(e);else{is_first_launch=!0;var t=new Date,a=t.getTime();t.setHours(23),t.setMinutes(59),t.setSeconds(60),sa.setOnceProfile({$first_visit_time:new Date}),this.set({distinct_id:this.getUUID(),first_visit_time:a,first_visit_day_time:t.getTime()})}}},sa.setProfile=function(e,t){sa.prepareData({type:"profile_set",properties:e},t)},sa.setOnceProfile=function(e,t){sa.prepareData({type:"profile_set_once",properties:e},t)},sa.appendProfile=function(e,t){if(!_.isObject(e))return!1;_.each(e,function(t,a){_.isString(t)?e[a]=[t]:_.isArray(t)||(delete e[a],logger.info("appendProfile\u5c5e\u6027\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32\u6216\u8005\u6570\u7ec4"))}),sa.prepareData({type:"profile_append",properties:e},t)},sa.incrementProfile=function(e,t){if(!_.isObject(e))return!1;var a=e;_.isString(e)&&((e={})[a]=1),sa.prepareData({type:"profile_increment",properties:e},t)},sa.track=function(e,t,a){this.prepareData({type:"track",event:e,properties:t},a)},sa.identify=function(e,t){if(e=_.validId(e)){var a=sa.store.getFirstId();!0===t?a?sa.store.set("first_id",e):sa.store.set("distinct_id",e):a?sa.store.change("first_id",e):sa.store.change("distinct_id",e)}},sa.trackSignup=function(e,t,a,r){var s=sa.store.getFirstId()||sa.store.getDistinctId();sa.store.set("distinct_id",e),sa.prepareData({original_id:s,distinct_id:e,type:"track_signup",event:t,properties:a},r)},sa.registerApp=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&(_.info.currentProps=_.extend(_.info.currentProps,e))},sa.register=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&sa.store.setProps(e)},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.clearAllProps=function(e){var t=sa.store.getProps(),a={};_.isArray(e)&&(_.each(t,function(t,r){_.include(e,r)||(a[r]=t)}),sa.store.setProps(a,!0))},sa.clearAppRegister=function(e){_.isArray(e)&&_.each(_.info.currentProps,function(t,a){_.include(e,a)&&delete _.info.currentProps[a]})},_.setLatestChannel=function(e){_.isEmptyObject(e)||(function(e,t){var a=!1;for(var r in t)e[t[r]]&&(a=!0);return a}(e,latest_source_channel)&&(sa.clearAppRegister(latest_source_channel),sa.clearAllProps(latest_source_channel)),sa.para.is_persistent_save.utm?sa.register(e):sa.registerApp(e))},_.setLatestShare=function(e){(e.$latest_share_depth||e.$latest_share_distinct_id||e.$latest_share_url_path||e.$latest_share_method)&&(sa.clearAppRegister(latest_share_info),sa.clearAllProps(latest_share_info),sa.para.is_persistent_save.share?sa.register(e):sa.registerApp(e))},sa.login=function(e){if(e=_.validId(e)){var t=sa.store.getFirstId(),a=sa.store.getDistinctId();e!==a&&(t?sa.trackSignup(e,"$SignUp"):(sa.store.set("first_id",a),sa.trackSignup(e,"$SignUp")))}},sa.getAnonymousID=function(){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")},sa.logout=function(e){var t=sa.store.getFirstId();t?(sa.store.set("first_id",""),!0===e?sa.store.set("distinct_id",sa.store.getUUID()):sa.store.set("distinct_id",t)):logger.info("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25")},sa.getLocation=function(){wx.getSetting({success:function(e){if(!e.authSetting["scope.userLocation"])return!1;wx.getLocation({type:sa.para.preset_properties.location.type,success:function(e){sa.registerApp({$latitude:e.latitude*Math.pow(10,6),$longitude:e.longitude*Math.pow(10,6),$geo_coordinate_system:_.setUpperCase(sa.para.preset_properties.location.type)})},fail:function(e){console.log("\u83b7\u53d6\u4f4d\u7f6e\u5931\u8d25",e)}})}})},sa.openid={getRequest:function(e){wx.login({success:function(t){t.code&&sa.para.appid&&sa.para.openid_url?_.wxrequest({url:sa.para.openid_url+"&code="+t.code+"&appid="+sa.para.appid,method:"GET",complete:function(t){_.isObject(t)&&_.isObject(t.data)&&t.data.openid?e(t.data.openid):e()}}):e()}})},getWXStorage:function(){var e=sa.store.getStorage();if(e&&_.isObject(e))return e.openid},getOpenid:function(e){if(!sa.para.appid)return e(),!1;var t=this.getWXStorage();t?e(t):this.getRequest(e)}},sa.initial=function(){this._.info.getSystem(),this.store.init()},sa.init=function(e){if(!0===this.hasInit)return!1;this.hasInit=!0,sa.setPara(e),sa.para.encrypt_storage&&this.store.encryptStorage(),sa.para.batch_send&&(wx.getStorage({key:"sensors_mp_prepare_data",complete:function(e){var t=e.data&&_.isArray(e.data)?e.data:[];sa.store.mem.mdata=t.concat(sa.store.mem.mdata),sa.sendStrategy.syncStorage=!0}}),sa.sendStrategy.batchInterval()),sa.initialState.storeIsComplete=!0,sa.initialState.checkIsComplete()},sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib){var e={};_.each(_.info.currentProps,function(t,a){0===a.indexOf("$")&&(e[a]=t)});var t=_.extend(e,{$url_path:_.getCurrentPath(),$is_first_day:_.getIsFirstDay()},_.info.properties,sa.store.getProps());return delete t.$lib,t}return{}},_.autoExeQueue=function(){return{items:[],enqueue:function(e){this.items.push(e),this.start()},dequeue:function(){return this.items.shift()},getCurrentItem:function(){return this.items[0]},isRun:!1,start:function(){this.items.length>0&&!this.isRun&&(this.isRun=!0,this.getCurrentItem().start())},close:function(){this.dequeue(),this.isRun=!1,this.start()}}},sa.requestQueue=function(e){this.url=e.url},sa.requestQueue.prototype.isEnd=function(){this.received||(this.received=!0,this.close())},sa.requestQueue.prototype.start=function(){var e=this;_.wxrequest({url:this.url,method:"GET",complete:function(){e.isEnd()}})},sa.dataQueue=_.autoExeQueue(),sa.sendStrategy={dataHasSend:!0,dataHasChange:!1,syncStorage:!1,failTime:0,onAppHide:function(){sa.para.batch_send&&this.batchSend()},send:function(e){if(!sa.para.server_url)return!1;sa.para.batch_send?(this.dataHasChange=!0,sa.store.mem.getLength()>=500&&(logger.info("\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38"),sa.store.mem.mdata.shift()),sa.store.mem.add(e),sa.store.mem.getLength()>=sa.para.batch_send.max_length&&this.batchSend()):this.queueSend(e)},queueSend:function(e){e._flush_time=Date.now(),e=JSON.stringify(e),e=-1!==sa.para.server_url.indexOf("?")?sa.para.server_url+"&data="+encodeURIComponent(_.base64Encode(e)):sa.para.server_url+"?data="+encodeURIComponent(_.base64Encode(e));var t=new sa.requestQueue({url:e});t.close=function(){sa.dataQueue.close()},sa.dataQueue.enqueue(t)},wxrequest:function(e){if(_.isArray(e.data)&&e.data.length>0){var t=Date.now();e.data.forEach(function(e){e._flush_time=t}),e.data=JSON.stringify(e.data),_.wxrequest({url:sa.para.server_url,method:"POST",dataType:"text",data:"data_list="+encodeURIComponent(_.base64Encode(e.data)),success:function(){e.success(e.len)},fail:function(){e.fail()}})}else e.success(e.len)},batchSend:function(){if(this.dataHasSend){var e,t,a=sa.store.mem.mdata;(t=(e=a.length>=100?a.slice(0,100):a).length)>0&&(this.dataHasSend=!1,this.wxrequest({data:e,len:t,success:this.batchRemove.bind(this),fail:this.sendFail.bind(this)}))}},sendFail:function(){this.dataHasSend=!0,this.failTime++},batchRemove:function(e){sa.store.mem.clear(e),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite(),this.failTime=0},is_first_batch_write:!0,batchWrite:function(){var e=this;this.dataHasChange&&(this.is_first_batch_write&&(this.is_first_batch_write=!1,setTimeout(function(){e.batchSend()},1e3)),this.dataHasChange=!1,this.syncStorage&&sa._.setStorageSync("sensors_mp_prepare_data",sa.store.mem.mdata))},batchInterval:function(){var e=this;!function t(){setTimeout(function(){e.batchWrite(),t()},500)}(),function t(){setTimeout(function(){e.batchSend(),t()},sa.para.batch_send.send_timeout*Math.pow(2,e.failTime))}()}},sa.setOpenid=function(e,t){sa.store.set("openid",e),t?sa.store.set("distinct_id",e):sa.identify(e,!0)},sa.initWithOpenid=function(e,t){(e=e||{}).appid&&(sa.para.appid=e.appid),sa.openid.getOpenid(function(a){a&&sa.setOpenid(a,e.isCoverLogin),t&&_.isFunction(t)&&t(a),sa.init(e)})},sa.setWebViewUrl=function(e,t){if(!_.isString(e)||""===e)return logger.info("error:\u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;e=decodeURIComponent(e);var a,r=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e),s=r[1]||"",n=r[2]||"",i=r[3]||"",o="",c=sa.store.getDistinctId()||"",u=sa.store.getFirstId()||"";_.urlSafeBase64&&_.urlSafeBase64.encode?c=c?_.urlSafeBase64.trim(_.urlSafeBase64.encode(_.urlBase64Encode(c))):"":this._.rot13obfs&&(c=c?_.rot13obfs(c):""),c=encodeURIComponent(c);var p=u?"f"+c:"d"+c;t?(a=i.indexOf("_sasdk"),o=i.indexOf("?")>-1?a>-1?s+n+"#"+i.substring(1,a)+"_sasdk="+p:s+n+"#"+i.substring(1)+"&_sasdk="+p:s+n+"#"+i.substring(1)+"?_sasdk="+p):(a=n.indexOf("_sasdk"),o=/^\?(\w)+/.test(n)?a>-1?s+"?"+n.substring(1,a)+"_sasdk="+p+i:s+"?"+n.substring(1)+"&_sasdk="+p+i:s+"?"+n.substring(1)+"_sasdk="+p+i);return o},_.each(["setProfile","setOnceProfile","track","quick","incrementProfile","appendProfile","login","logout","registerApp","register","clearAllRegister","clearAllProps","clearAppRegister"],function(e){var t=sa[e];sa[e]=function(){sa.initialState.isComplete?t.apply(sa,arguments):sa.initialState.queue.push([e,arguments])}}),_.setQuery=function(e,t){if(e&&_.isObject(e)&&!_.isEmptyObject(e)){var a=[];return _.each(e,function(e,r){"q"===r&&_.isString(e)&&0===e.indexOf("http")||(t?a.push(r+"="+e):a.push(r+"="+_.decodeURIComponent(e)))}),a.join("&")}return""},_.getUtmFromPage=function(){var e={};try{var t=getCurrentPages(),a=JSON.parse(JSON.stringify(t[t.length-1].options));for(var r in a)a[r]=_.decodeURIComponent(a[r]);e=_.getCustomUtmFromQuery(a,"$","_","$")}catch(e){logger.info(e)}return e},sa.autoTrackCustom={trackCustom:function(e,t,a){var r=sa.para.autoTrack[e],s="";sa.para.autoTrack&&r&&("function"==typeof r?(s=r(),_.isObject(s)&&_.extend(t,s)):_.isObject(r)&&(_.extend(t,r),sa.para.autoTrack[e]=!0),sa.track(a,t))},appLaunch:function(e,t){"object"!=typeof this||this.trackCustom||(this[sa.para.name]=sa);var a={};e&&e.scene?(current_scene=e.scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(a.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),_.setShareInfo(e,a);var r=_.setUtm(e,a);is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):a.$is_first_time=!1,_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),t?(a=_.extend(a,t),sa.track("$MPLaunch",a)):sa.para.autoTrack&&sa.para.autoTrack.appLaunch&&sa.autoTrackCustom.trackCustom("appLaunch",a,"$MPLaunch")},appShow:function(e,t){var a={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(a.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,a);var r=_.setUtm(e,a);_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),t?(a=_.extend(a,t),sa.track("$MPShow",a)):sa.para.autoTrack&&sa.para.autoTrack.appShow&&sa.autoTrackCustom.trackCustom("appShow",a,"$MPShow")},appHide:function(e){var t=(new Date).getTime(),a={};a.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(a.event_duration=(t-mpshow_time)/1e3),e?(a=_.extend(a,e),sa.track("$MPHide",a)):sa.para.autoTrack&&sa.para.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",a,"$MPHide"),sa.sendStrategy.onAppHide()},pageLoad:function(e){current_scene&&1010===current_scene&&e&&e.sampshare&&delete e.sampshare,e&&_.isObject(e)&&(this.sensors_mp_url_query=_.setQuery(e),this.sensors_mp_encode_url_query=_.setQuery(e,!0))},pageShow:function(){var e={},t=_.getCurrentPath(),a=_.getPageTitle(t);e.$referrer=sa_referrer,e.$url_path=t,sa.status.last_referrer=sa_referrer,e.$url_query=this.sensors_mp_url_query?this.sensors_mp_url_query:"",e=_.extend(e,_.getUtmFromPage()),_.setPageSfSource(e),a&&(e.$title=a),sa.para.onshow?sa.para.onshow(sa,t,this):_.isObject(sa.para.autotrack_exclude_page)&&_.isArray(sa.para.autotrack_exclude_page.pageShow)&&-1!==sa.para.autotrack_exclude_page.pageShow.indexOf(t)||sa.autoTrackCustom.trackCustom("pageShow",e,"$MPViewScreen"),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:t}),sa_referrer=t,sa.status.referrer=t},pageShare:function(e){var t=e.onShareAppMessage;e.onShareAppMessage=function(){share_method="\u8f6c\u53d1\u6d88\u606f\u5361\u7247";var e=t.apply(this,arguments);return sa.para.autoTrack&&sa.para.autoTrack.pageShare&&sa.autoTrackCustom.trackCustom("pageShare",{$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method},"$MPShare"),sa.para.allow_amend_share_path&&("object"!=typeof e&&((e={}).path=_.getCurrentUrl(this)),"object"!=typeof e||void 0!==e.path&&""!==e.path||(e.path=_.getCurrentUrl(this)),"object"==typeof e&&"string"==typeof e.path&&(-1===e.path.indexOf("?")?e.path=e.path+"?":"&"!==e.path.slice(-1)&&(e.path=e.path+"&")),e.path=e.path+"sampshare="+encodeURIComponent(_.getShareInfo())),e}},pageShareTimeline:function(e){var t=e.onShareTimeline;e.onShareTimeline=function(){share_method="\u670b\u53cb\u5708\u5206\u4eab";var e=t.apply(this,arguments);return sa.para.autoTrack&&sa.para.autoTrack.pageShare&&sa.autoTrackCustom.trackCustom("pageShare",{$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method},"$MPShare"),sa.para.allow_amend_share_path&&("object"!=typeof e&&(e={}),"object"==typeof e&&void 0===e.query&&(e.query=""),"object"==typeof e&&"string"==typeof e.query&&""!==e.query&&"&"!==e.query.slice(-1)&&(e.query=e.query+"&"),e.query=e.query+"sampshare="+encodeURIComponent(_.getShareInfo())),e}},pageAddFavorites:function(){var e={};e.$url_path=_.getCurrentPath(),sa.para.autoTrack&&sa.para.autoTrack.mpFavorite&&sa.autoTrackCustom.trackCustom("mpFavorite",e,"$MPAddFavorites")}},sa.quick=function(){var e=arguments[0],t=arguments[1],a=arguments[2],r=_.isObject(a)?a:{};if("getAnonymousID"===e){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===e||"appShow"===e?t?sa.autoTrackCustom[e](t,r):logger.info("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(r=_.isObject(t)?t:{},sa.autoTrackCustom[e](r))},sa.appLaunch=function(e,t){var a={};e&&e.scene?(current_scene=e.scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(a.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),_.setShareInfo(e,a);var r=_.setUtm(e,a);is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):a.$is_first_time=!1,_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),_.isObject(t)&&(a=_.extend(a,t)),sa.track("$MPLaunch",a)},sa.appShow=function(e,t){var a={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(a.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,a);var r=_.setUtm(e,a);_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),_.isObject(t)&&(a=_.extend(a,t)),sa.track("$MPShow",a)},sa.appHide=function(e){var t=(new Date).getTime(),a={};a.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(a.event_duration=(t-mpshow_time)/1e3),_.isObject(e)&&(a=_.extend(a,e)),sa.track("$MPHide",a),sa.sendStrategy.onAppHide()},sa.pageShow=function(e){var t={},a=_.getCurrentPath(),r=_.getPageTitle(a),s={};try{var n=getCurrentPages();s=n[n.length-1]}catch(e){logger.info(e)}!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a}),r&&(t.$title=r),t.$referrer=sa_referrer,t.$url_path=a,sa.status.last_referrer=sa_referrer,t.$url_query=s.sensors_mp_url_query?s.sensors_mp_url_query:"",t=_.extend(t,_.getUtmFromPage()),_.setPageSfSource(t),_.isObject(e)&&(t=_.extend(t,e)),sa.track("$MPViewScreen",t),sa_referrer=a,sa.status.referrer=a};var oldApp=App;App=function(e){e[sa.para.name]=sa,oldApp.apply(this,arguments)},wx.onAppShow(function(e){if(!sa.para.launched){var t=wx.getLaunchOptionsSync()||{};sa.autoTrackCustom.appLaunch(t),sa.para.launched=!0}sa.autoTrackCustom.appShow(e)}),wx.onAppHide(function(){sa.autoTrackCustom.appHide()});var oldPage=Page;Page=function(e){var t=sa.para.autoTrack&&sa.para.autoTrack.mpClick&&_.getMethods(e);if(t)for(var a=0,r=t.length;asa.para.max_string_length?(logger.info("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,sa.para.max_string_length)):e},_.searchObjString=function(e){_.isObject(e)&&_.each(e,function(t,a){_.isObject(t)?_.searchObjString(e[a]):_.isString(t)&&(e[a]=_.formatString(t))})},_.parseSuperProperties=function(e){_.isObject(e)&&(_.each(e,function(t,a){if(_.isFunction(t))try{e[a]=t(),_.isFunction(e[a])&&(logger.info("\u60a8\u7684\u5c5e\u6027- "+a+" \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}catch(t){delete e[a],logger.info("\u60a8\u7684\u5c5e\u6027- "+a+" \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}}),_.strip_sa_properties(e))},_.unique=function(e){for(var t,a=[],r={},s=0;s127&&i<2048?String.fromCharCode(i>>6|192,63&i|128):String.fromCharCode(i>>12|224,i>>6&63|128,63&i|128),null!==o&&(a>t&&(n+=e.substring(t,a)),n+=o,t=a=s+1)}return a>t&&(n+=e.substring(t,e.length)),n},_.base64Encode=function(e){var t,a,r,s,n,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,c=0,u="",p=[];if(!e)return e;e=_.utf8Encode(e);do{t=(n=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,a=n>>12&63,r=n>>6&63,s=63&n,p[c++]=i.charAt(t)+i.charAt(a)+i.charAt(r)+i.charAt(s)}while(o255||(r=e.charCodeAt(o++))>255||(s=e.charCodeAt(o++))>255)&&logger.info("Failed to execute 'btoa' : The string to be encoded contains characters outside of the Latin1 range."),i+=n.charAt((t=a<<16|r<<8|s)>>18&63)+n.charAt(t>>12&63)+n.charAt(t>>6&63)+n.charAt(63&t);return c?i.slice(0,c-3)+"===".substring(c):i},_.urlBase64Encode=function(e){return _.btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))},_.rot13obfs=function(e,t){t="number"==typeof t?t:13;for(var a=(e=String(e)).split(""),r=0,s=a.length;r(new Date).getTime()},_.getCurrentUrl=function(e){var t=_.getCurrentPath(),a="";return _.isObject(e)&&e.sensors_mp_encode_url_query&&(a=e.sensors_mp_encode_url_query),t?a?t+"?"+a:t:"\u672a\u53d6\u5230"},_.getPath=function(e){return e="string"==typeof e?e.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"},_.getMethods=function(e){var t=[];for(var a in e)"function"!=typeof e[a]||mpHook[a]||t.push(a);return t},_.isClick=function(e){return!!{tap:1,longpress:1,longtap:1}[e]},sa.initialState={queue:[],isComplete:!1,systemIsComplete:!1,storeIsComplete:!1,checkIsComplete:function(){this.systemIsComplete&&this.storeIsComplete&&(this.isComplete=!0,this.queue.length>0&&(_.each(this.queue,function(e){sa[e[0]].apply(sa,slice.call(e[1]))}),this.queue=[]))}},_.getCustomUtmFromQuery=function(e,t,a,r){if(!_.isObject(e))return{};var s={};if(e.sa_utm)for(var n in e)"sa_utm"!==n?_.include(sa.para.source_channel,n)&&(s[a+n]=e[n]):s[r+n]=e[n];else for(var n in e)-1===(" "+source_channel_standard+" ").indexOf(" "+n+" ")?_.include(sa.para.source_channel,n)&&(s[a+n]=e[n]):s[t+n]=e[n];return s},_.getObjFromQuery=function(e){var t=e.split("?"),a=[],r={};return t&&t[1]?(_.each(t[1].split("&"),function(e){(a=e.split("="))[0]&&a[1]&&(r[a[0]]=a[1])}),r):{}},_.setStorageSync=function(e,t){var a=function(){wx.setStorageSync(e,t)};try{a()}catch(e){logger.info("set Storage fail --",e);try{a()}catch(e){logger.info("set Storage fail again --",e)}}},_.getStorageSync=function(e){var t="";try{t=wx.getStorageSync(e)}catch(a){try{t=wx.getStorageSync(e)}catch(e){logger.info("getStorage fail")}}return t},_.getMPScene=function(e){return"number"==typeof e||"string"==typeof e&&""!==e?e="wx-"+String(e):"\u672a\u53d6\u5230\u503c"},_.setShareInfo=function(e,t){var a={},r={},s=sa.store.getDistinctId(),n=sa.store.getFirstId();if(!(e&&_.isObject(e.query)&&e.query.sampshare))return{};if(a=_.decodeURIComponent(e.query.sampshare),!_.isJSONString(a))return{};var i=(a=JSON.parse(a)).d,o=a.p,c=a.i,u=a.m;"string"==typeof c?(t.$share_distinct_id=c,share_distinct_id=c,r.$latest_share_distinct_id=c):t.$share_distinct_id="\u53d6\u503c\u5f02\u5e38","number"==typeof i?!share_distinct_id||share_distinct_id!==s&&share_distinct_id!==n?!share_distinct_id||share_distinct_id===s&&share_distinct_id===n?t.$share_depth="-1":(t.$share_depth=i+1,query_share_depth=i+1,r.$latest_share_depth=i+1):(t.$share_depth=i,query_share_depth=i,r.$latest_share_depth=i):t.$share_depth="-1","string"==typeof o?(t.$share_url_path=o,r.$latest_share_url_path=o):t.$share_url_path="\u53d6\u503c\u5f02\u5e38","string"==typeof u?(t.$share_method=u,r.$latest_share_method=u):t.$share_method="\u53d6\u503c\u5f02\u5e38",_.setLatestShare(r)},_.getShareInfo=function(){return JSON.stringify({i:sa.store.getDistinctId()||"\u53d6\u503c\u5f02\u5e38",p:_.getCurrentPath(),d:query_share_depth,m:share_method})},_.detectOptionQuery=function(e){if(!e||!_.isObject(e.query))return{};var t,a,r,s,n={};return n.query=_.extend({},e.query),"string"==typeof n.query.scene&&(t=n.query,a=["utm_source","utm_content","utm_medium","utm_campaign","utm_term","sa_utm"].concat(sa.para.source_channel),r=new RegExp("("+a.join("|")+")%3D","i"),1===(s=Object.keys(t)).length&&"scene"===s[0]&&r.test(t.scene))&&(n.scene=n.query.scene,delete n.query.scene),e.query.q&&e.query.scancode_time&&"101"===String(e.scene).slice(0,3)&&(n.q=String(n.query.q),delete n.query.q,delete n.query.scancode_time),n},_.getMixedQuery=function(e){var t=_.detectOptionQuery(e),a=t.scene,r=t.q,s=t.query;for(var n in s)s[n]=_.decodeURIComponent(s[n]);return a&&(a=-1!==(a=_.decodeURIComponent(a)).indexOf("?")?"?"+a.replace(/\?/g,""):"?"+a,_.extend(s,_.getObjFromQuery(a))),r&&_.extend(s,_.getObjFromQuery(_.decodeURIComponent(r))),s},_.setUtm=function(e,t){var a={},r=_.getMixedQuery(e),s=_.getCustomUtmFromQuery(r,"$","_","$"),n=_.getCustomUtmFromQuery(r,"$latest_","_latest_","$latest_");return a.pre1=s,a.pre2=n,_.extend(t,s),a},_.setSfSource=function(e,t){!_.isEmptyObject(e.query)&&e.query._sfs&&(t.$sf_source=e.query._sfs,sa.registerApp({$latest_sf_source:t.$sf_source}))},_.setPageSfSource=function(e){try{var t=getCurrentPages(),a=JSON.parse(JSON.stringify(t[t.length-1].options));for(var r in a)a[r]=_.decodeURIComponent(a[r]);!_.isEmptyObject(a)&&a._sfs&&(e.$sf_source=a._sfs)}catch(e){logger.info(e)}};try{var oldSetNavigationBarTitle=wx.setNavigationBarTitle;Object.defineProperty(wx,"setNavigationBarTitle",{get:function(){return function(e){var t=getCurrentPages(),a=t[t.length-1].route||"";e=_.isObject(e)?e:{},globalTitle[a]=e.title,oldSetNavigationBarTitle.call(this,e)}}})}catch(e){logger.info(e)}function mp_proxy(e,t,a){var r=sa.autoTrackCustom[a];if(e[t]){var s=e[t];e[t]=function(){"onLaunch"===t&&(this[sa.para.name]=sa),!sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&!sa.para.autoTrackIsFirst[a]?(s.apply(this,arguments),r.apply(this,arguments)):(!0===sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&sa.para.autoTrackIsFirst[a])&&(r.apply(this,arguments),s.apply(this,arguments))}}else e[t]=function(){"onLaunch"===t&&(this[sa.para.name]=sa),r.apply(this,arguments)}}function clickTrack(e){var t,a={},r={},s=e.currentTarget||{},n=e.target||{};if(_.isObject(sa.para.framework)&&_.isObject(sa.para.framework.taro)&&!sa.para.framework.taro.createApp&&n.id&&s.id&&n.id!==s.id)return!1;var i=s.dataset||{};if(t=e.type,a.$element_id=s.id,a.$element_type=i.type,a.$element_content=i.content,a.$element_name=i.name,_.isObject(e.event_prop)&&(r=e.event_prop),t&&_.isClick(t)){if(sa.para.preset_events&&sa.para.preset_events.collect_element&&!1===sa.para.preset_events.collect_element(arguments[0]))return!1;a.$url_path=_.getCurrentPath(),a=_.extend(a,r),sa.track("$MPClick",a)}}function click_proxy(e,t){var a=e[t];e[t]=function(){var e=a.apply(this,arguments),t=arguments[0];return _.isObject(t)&&(sa.para.preset_events.defer_track?setTimeout(function(){clickTrack(t)},0):clickTrack(t)),e}}function tabProxy(e){var t=e.onTabItemTap;e.onTabItemTap=function(e){t&&t.apply(this,arguments);var a={};e&&(a.$element_content=e.text),a.$element_type="tabBar",a.$url_path=_.getCurrentPath(),sa.track("$MPClick",a)}}_.getPageTitle=function(e){if("\u672a\u53d6\u5230"===e||!e)return!1;var t="";try{if(__wxConfig){var a=__wxConfig,r=a.page[e]||a.page[e+".html"],s={},n={};if(a.global&&a.global.window&&a.global.window.navigationBarTitleText&&(s.titleVal=a.global.window.navigationBarTitleText),r&&r.window&&r.window.navigationBarTitleText&&(n.titleVal=r.window.navigationBarTitleText),_.each(globalTitle,function(a,r){if(r===e)return t=a}),0===t.length){var i=_.extend(s,n);t=i.titleVal}}}catch(e){logger.info(e)}return t},_.wxrequest=function(e){if(_.compareSDKVersion(wxSDKVersion,"2.10.0")>=0)e.timeout=sa.para.datasend_timeout,wx.request(e);else{var t=wx.request(e);setTimeout(function(){_.isObject(t)&&_.isFunction(t.abort)&&t.abort()},sa.para.datasend_timeout)}},_.getAppId=function(){var e;if(wx.getAccountInfoSync&&(e=wx.getAccountInfoSync()),_.isObject(e)&&_.isObject(e.miniProgram))return e.miniProgram.appId},_.validId=function(e){return"string"!=typeof e&&"number"!=typeof e||""===e?(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1):"number"!=typeof e||(e=String(e),/^\d+$/.test(e))?e:(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1)},_.compareSDKVersion=function(e,t){e=e.split("."),t=t.split(".");for(var a=Math.max(e.length,t.length);e.lengthn)return 1;if(s-1?t.system.split(" ")[1]:t.system,wxSDKVersion=t.SDKVersion},complete:function(){var t=(new Date).getTimezoneOffset(),a=_.getAppId();_.isNumber(t)&&(e.$timezone_offset=t),a&&(e.$app_id=a),sa.initialState.systemIsComplete=!0,sa.initialState.checkIsComplete()}})}wx.getNetworkType({success:function(t){e.$network_type=_.setUpperCase(t.networkType)},complete:t})}},sa._=_,_.eventEmitter=function(){this.sub=[]},_.eventEmitter.prototype={add:function(e){this.sub.push(e)},emit:function(e,t){this.sub.forEach(function(a){a.on(e,t)})}},_.eventSub=function(e){sa.events.add(this),this._events=[],this.handle=e,this.ready=!1},_.eventSub.prototype={on:function(e,t){if(this.ready){if(_.isFunction(this.handle))try{this.handle(e,t)}catch(e){logger.info(e)}}else this._events.push({event:e,data:t})},isReady:function(){var e=this;e.ready=!0,e._events.forEach(function(t){if(_.isFunction(e.handle))try{e.handle(t.event,t.data)}catch(e){logger.info(e)}})}},sa.eventSub=_.eventSub,sa.events=new _.eventEmitter,sa.usePlugin=function(e,t){"function"==typeof e.init&&e.init(sa,t)},sa.prepareData=function(e,t){if(current_scene&&1154===current_scene&&!sa.para.preset_events.moments_page)return!1;var a={distinct_id:this.store.getDistinctId(),lib:{$lib:LIB_NAME,$lib_method:"code",$lib_version:String(LIB_VERSION)},properties:{}};_.extend(a,this.store.getUnionId(),e),_.isObject(e.properties)&&!_.isEmptyObject(e.properties)&&_.extend(a.properties,e.properties),e.type&&"profile"===e.type.slice(0,7)||(a._track_id=Number(String(Math.random()).slice(2,5)+String(Math.random()).slice(2,4)+String(Date.now()).slice(-4)),a.properties=_.extend({},_.info.properties,sa.store.getProps(),_.info.currentProps,a.properties),a.properties.$is_first_day=_.getIsFirstDay()),a.properties.$time&&_.isDate(a.properties.$time)?(a.time=1*a.properties.$time,delete a.properties.$time):a.time=1*new Date,_.parseSuperProperties(a.properties),_.searchObjDate(a),_.searchObjString(a),logger.info(a),sa.events.emit("send",a),sa.sendStrategy.send(a)},sa.store={storageInfo:null,getUUID:function(){return Date.now()+"-"+Math.floor(1e7*Math.random())+"-"+Math.random().toString(16).replace(".","")+"-"+String(31242*Math.random()).replace(".","").slice(0,8)},getStorage:function(){return this.storageInfo?this.storageInfo:(this.storageInfo=sa._.getStorageSync("sensorsdata2015_wechat")||"",this.storageInfo)},_state:{},mem:{mdata:[],getLength:function(){return this.mdata.length},add:function(e){this.mdata.push(e)},clear:function(e){this.mdata.splice(0,e)}},toState:function(e){var t=null;_.isJSONString(e)?(t=JSON.parse(e)).distinct_id?this._state=t:this.set("distinct_id",this.getUUID()):_.isObject(e)&&(t=e).distinct_id?this._state=t:this.set("distinct_id",this.getUUID())},getFirstId:function(){return this._state._first_id||this._state.first_id},getDistinctId:function(){return this._state._distinct_id||this._state.distinct_id},getUnionId:function(){var e={},t=this._state._first_id||this._state.first_id,a=this._state._distinct_id||this._state.distinct_id;return t&&a?(e.login_id=a,e.anonymous_id=t):e.anonymous_id=a,e},getProps:function(){return this._state.props||{}},setProps:function(e,t){var a=this._state.props||{};t?this.set("props",e):(_.extend(a,e),this.set("props",a))},set:function(e,t){var a={};for(var r in"string"==typeof e?a[e]=t:"object"==typeof e&&(a=e),this._state=this._state||{},a)this._state[r]=a[r],"first_id"===r?delete this._state._first_id:"distinct_id"===r&&(delete this._state._distinct_id,sa.events.emit("changeDistinctId"));this.save()},change:function(e,t){this._state["_"+e]=t},encryptStorage:function(){var e=this.getStorage(),t="data:enc;";_.isObject(e)?e=t+_.rot13obfs(JSON.stringify(e)):_.isString(e)&&-1===e.indexOf(t)&&(e=t+_.rot13obfs(e)),sa._.setStorageSync("sensorsdata2015_wechat",e)},save:function(){var e=JSON.parse(JSON.stringify(this._state));if(delete e._first_id,delete e._distinct_id,sa.para.encrypt_storage){e="data:enc;"+_.rot13obfs(JSON.stringify(e))}sa._.setStorageSync("sensorsdata2015_wechat",e)},init:function(){var e=this.getStorage();if(e)_.isString(e)&&-1!==e.indexOf("data:enc;")&&(e=e.substring("data:enc;".length),e=JSON.parse(_.rot13defs(e))),this.toState(e);else{is_first_launch=!0;var t=new Date,a=t.getTime();t.setHours(23),t.setMinutes(59),t.setSeconds(60),sa.setOnceProfile({$first_visit_time:new Date}),this.set({distinct_id:this.getUUID(),first_visit_time:a,first_visit_day_time:t.getTime()})}}},sa.setProfile=function(e,t){sa.prepareData({type:"profile_set",properties:e},t)},sa.setOnceProfile=function(e,t){sa.prepareData({type:"profile_set_once",properties:e},t)},sa.appendProfile=function(e,t){if(!_.isObject(e))return!1;_.each(e,function(t,a){_.isString(t)?e[a]=[t]:_.isArray(t)||(delete e[a],logger.info("appendProfile\u5c5e\u6027\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32\u6216\u8005\u6570\u7ec4"))}),sa.prepareData({type:"profile_append",properties:e},t)},sa.incrementProfile=function(e,t){if(!_.isObject(e))return!1;var a=e;_.isString(e)&&((e={})[a]=1),sa.prepareData({type:"profile_increment",properties:e},t)},sa.track=function(e,t,a){this.prepareData({type:"track",event:e,properties:t},a)},sa.identify=function(e,t){if(e=_.validId(e)){var a=sa.store.getFirstId();!0===t?a?sa.store.set("first_id",e):sa.store.set("distinct_id",e):a?sa.store.change("first_id",e):sa.store.change("distinct_id",e)}},sa.trackSignup=function(e,t,a,r){var s=sa.store.getFirstId()||sa.store.getDistinctId();sa.store.set("distinct_id",e),sa.prepareData({original_id:s,distinct_id:e,type:"track_signup",event:t,properties:a},r)},sa.registerApp=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&(_.info.currentProps=_.extend(_.info.currentProps,e))},sa.register=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&sa.store.setProps(e)},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.clearAllProps=function(e){var t=sa.store.getProps(),a={};_.isArray(e)&&(_.each(t,function(t,r){_.include(e,r)||(a[r]=t)}),sa.store.setProps(a,!0))},sa.clearAppRegister=function(e){_.isArray(e)&&_.each(_.info.currentProps,function(t,a){_.include(e,a)&&delete _.info.currentProps[a]})},_.setLatestChannel=function(e){_.isEmptyObject(e)||(function(e,t){var a=!1;for(var r in t)e[t[r]]&&(a=!0);return a}(e,latest_source_channel)&&(sa.clearAppRegister(latest_source_channel),sa.clearAllProps(latest_source_channel)),sa.para.is_persistent_save.utm?sa.register(e):sa.registerApp(e))},_.setLatestShare=function(e){(e.$latest_share_depth||e.$latest_share_distinct_id||e.$latest_share_url_path||e.$latest_share_method)&&(sa.clearAppRegister(latest_share_info),sa.clearAllProps(latest_share_info),sa.para.is_persistent_save.share?sa.register(e):sa.registerApp(e))},sa.login=function(e){if(e=_.validId(e)){var t=sa.store.getFirstId(),a=sa.store.getDistinctId();e!==a&&(t?sa.trackSignup(e,"$SignUp"):(sa.store.set("first_id",a),sa.trackSignup(e,"$SignUp")))}},sa.getAnonymousID=function(){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")},sa.logout=function(e){var t=sa.store.getFirstId();t?(sa.store.set("first_id",""),!0===e?sa.store.set("distinct_id",sa.store.getUUID()):sa.store.set("distinct_id",t)):logger.info("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25")},sa.getLocation=function(){wx.getSetting({success:function(e){if(!e.authSetting["scope.userLocation"])return!1;wx.getLocation({type:sa.para.preset_properties.location.type,success:function(e){sa.registerApp({$latitude:e.latitude*Math.pow(10,6),$longitude:e.longitude*Math.pow(10,6),$geo_coordinate_system:_.setUpperCase(sa.para.preset_properties.location.type)})},fail:function(e){console.log("\u83b7\u53d6\u4f4d\u7f6e\u5931\u8d25",e)}})}})},sa.openid={getRequest:function(e){wx.login({success:function(t){t.code&&sa.para.appid&&sa.para.openid_url?_.wxrequest({url:sa.para.openid_url+"&code="+t.code+"&appid="+sa.para.appid,method:"GET",complete:function(t){_.isObject(t)&&_.isObject(t.data)&&t.data.openid?e(t.data.openid):e()}}):e()}})},getWXStorage:function(){var e=sa.store.getStorage();if(e&&_.isObject(e))return e.openid},getOpenid:function(e){if(!sa.para.appid)return e(),!1;var t=this.getWXStorage();t?e(t):this.getRequest(e)}},sa.initial=function(){this._.info.getSystem(),this.store.init()},sa.init=function(e){if(!0===this.hasInit)return!1;this.hasInit=!0,sa.setPara(e),sa.para.encrypt_storage&&this.store.encryptStorage(),sa.para.batch_send&&(wx.getStorage({key:"sensors_mp_prepare_data",complete:function(e){var t=e.data&&_.isArray(e.data)?e.data:[];sa.store.mem.mdata=t.concat(sa.store.mem.mdata),sa.sendStrategy.syncStorage=!0}}),sa.sendStrategy.batchInterval()),sa.initialState.storeIsComplete=!0,sa.initialState.checkIsComplete()},sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib){var e={};_.each(_.info.currentProps,function(t,a){0===a.indexOf("$")&&(e[a]=t)});var t=_.extend(e,{$url_path:_.getCurrentPath(),$is_first_day:_.getIsFirstDay()},_.info.properties,sa.store.getProps());return delete t.$lib,t}return{}},_.autoExeQueue=function(){return{items:[],enqueue:function(e){this.items.push(e),this.start()},dequeue:function(){return this.items.shift()},getCurrentItem:function(){return this.items[0]},isRun:!1,start:function(){this.items.length>0&&!this.isRun&&(this.isRun=!0,this.getCurrentItem().start())},close:function(){this.dequeue(),this.isRun=!1,this.start()}}},sa.requestQueue=function(e){this.url=e.url},sa.requestQueue.prototype.isEnd=function(){this.received||(this.received=!0,this.close())},sa.requestQueue.prototype.start=function(){var e=this;_.wxrequest({url:this.url,method:"GET",complete:function(){e.isEnd()}})},sa.dataQueue=_.autoExeQueue(),sa.sendStrategy={dataHasSend:!0,dataHasChange:!1,syncStorage:!1,failTime:0,onAppHide:function(){sa.para.batch_send&&this.batchSend()},send:function(e){if(!sa.para.server_url)return!1;if(sa.para.batch_send){if(this.dataHasChange=!0,sa.store.mem.getLength()>=300)return logger.info("\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38"),!1;sa.store.mem.add(e),sa.store.mem.getLength()>=sa.para.batch_send.max_length&&this.batchSend()}else this.queueSend(e)},queueSend:function(e){e._flush_time=Date.now(),e=JSON.stringify(e),e=-1!==sa.para.server_url.indexOf("?")?sa.para.server_url+"&data="+encodeURIComponent(_.base64Encode(e)):sa.para.server_url+"?data="+encodeURIComponent(_.base64Encode(e));var t=new sa.requestQueue({url:e});t.close=function(){sa.dataQueue.close()},sa.dataQueue.enqueue(t)},wxrequest:function(e){if(_.isArray(e.data)&&e.data.length>0){var t=Date.now();e.data.forEach(function(e){e._flush_time=t}),e.data=JSON.stringify(e.data),_.wxrequest({url:sa.para.server_url,method:"POST",dataType:"text",data:"data_list="+encodeURIComponent(_.base64Encode(e.data)),success:function(){e.success(e.len)},fail:function(){e.fail()}})}else e.success(e.len)},batchSend:function(){if(this.dataHasSend){var e=sa.store.mem.mdata,t=e.length;t>0&&(this.dataHasSend=!1,this.wxrequest({data:e,len:t,success:this.batchRemove.bind(this),fail:this.sendFail.bind(this)}))}},sendFail:function(){this.dataHasSend=!0,this.failTime++},batchRemove:function(e){sa.store.mem.clear(e),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite(),this.failTime=0},is_first_batch_write:!0,batchWrite:function(){var e=this;this.dataHasChange&&(this.is_first_batch_write&&(this.is_first_batch_write=!1,setTimeout(function(){e.batchSend()},1e3)),this.dataHasChange=!1,this.syncStorage&&sa._.setStorageSync("sensors_mp_prepare_data",sa.store.mem.mdata))},batchInterval:function(){var e=this;!function t(){setTimeout(function(){e.batchWrite(),t()},500)}(),function t(){setTimeout(function(){e.batchSend(),t()},sa.para.batch_send.send_timeout*Math.pow(2,e.failTime))}()}},sa.setOpenid=function(e,t){sa.store.set("openid",e),t?sa.store.set("distinct_id",e):sa.identify(e,!0)},sa.initWithOpenid=function(e,t){(e=e||{}).appid&&(sa.para.appid=e.appid),sa.openid.getOpenid(function(a){a&&sa.setOpenid(a,e.isCoverLogin),t&&_.isFunction(t)&&t(a),sa.init(e)})},sa.setWebViewUrl=function(e,t){if(!_.isString(e)||""===e)return logger.info("error:\u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;e=decodeURIComponent(e);var a,r=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e),s=r[1]||"",n=r[2]||"",i=r[3]||"",o="",c=sa.store.getDistinctId()||"",u=sa.store.getFirstId()||"";_.urlSafeBase64&&_.urlSafeBase64.encode?c=c?_.urlSafeBase64.trim(_.urlSafeBase64.encode(_.urlBase64Encode(c))):"":this._.rot13obfs&&(c=c?_.rot13obfs(c):""),c=encodeURIComponent(c);var p=u?"f"+c:"d"+c;t?(a=i.indexOf("_sasdk"),o=i.indexOf("?")>-1?a>-1?s+n+"#"+i.substring(1,a)+"_sasdk="+p:s+n+"#"+i.substring(1)+"&_sasdk="+p:s+n+"#"+i.substring(1)+"?_sasdk="+p):(a=n.indexOf("_sasdk"),o=/^\?(\w)+/.test(n)?a>-1?s+"?"+n.substring(1,a)+"_sasdk="+p+i:s+"?"+n.substring(1)+"&_sasdk="+p+i:s+"?"+n.substring(1)+"_sasdk="+p+i);return o},_.each(["setProfile","setOnceProfile","track","quick","incrementProfile","appendProfile","login","logout","registerApp","register","clearAllRegister","clearAllProps","clearAppRegister"],function(e){var t=sa[e];sa[e]=function(){sa.initialState.isComplete?t.apply(sa,arguments):sa.initialState.queue.push([e,arguments])}}),_.setQuery=function(e,t){if(e&&_.isObject(e)&&!_.isEmptyObject(e)){var a=[];return _.each(e,function(e,r){"q"===r&&_.isString(e)&&0===e.indexOf("http")||(t?a.push(r+"="+e):a.push(r+"="+_.decodeURIComponent(e)))}),a.join("&")}return""},_.getUtmFromPage=function(){var e={};try{var t=getCurrentPages(),a=JSON.parse(JSON.stringify(t[t.length-1].options));for(var r in a)a[r]=_.decodeURIComponent(a[r]);e=_.getCustomUtmFromQuery(a,"$","_","$")}catch(e){logger.info(e)}return e},sa.autoTrackCustom={trackCustom:function(e,t,a){var r=sa.para.autoTrack[e],s="";sa.para.autoTrack&&r&&("function"==typeof r?(s=r(),_.isObject(s)&&_.extend(t,s)):_.isObject(r)&&(_.extend(t,r),sa.para.autoTrack[e]=!0),sa.track(a,t))},appLaunch:function(e,t){"object"!=typeof this||this.trackCustom||(this[sa.para.name]=sa);var a={};e&&e.scene?(current_scene=e.scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(a.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),_.setShareInfo(e,a);var r=_.setUtm(e,a);is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):a.$is_first_time=!1,_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),t?(a=_.extend(a,t),sa.track("$MPLaunch",a)):sa.para.autoTrack&&sa.para.autoTrack.appLaunch&&sa.autoTrackCustom.trackCustom("appLaunch",a,"$MPLaunch")},appShow:function(e,t){var a={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(a.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,a);var r=_.setUtm(e,a);_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),t?(a=_.extend(a,t),sa.track("$MPShow",a)):sa.para.autoTrack&&sa.para.autoTrack.appShow&&sa.autoTrackCustom.trackCustom("appShow",a,"$MPShow")},appHide:function(e){var t=(new Date).getTime(),a={};a.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(a.event_duration=(t-mpshow_time)/1e3),e?(a=_.extend(a,e),sa.track("$MPHide",a)):sa.para.autoTrack&&sa.para.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",a,"$MPHide"),sa.sendStrategy.onAppHide()},pageLoad:function(e){current_scene&&1010===current_scene&&e&&e.sampshare&&delete e.sampshare,e&&_.isObject(e)&&(this.sensors_mp_url_query=_.setQuery(e),this.sensors_mp_encode_url_query=_.setQuery(e,!0))},pageShow:function(){var e={},t=_.getCurrentPath(),a=_.getPageTitle(t);e.$referrer=sa_referrer,e.$url_path=t,sa.status.last_referrer=sa_referrer,e.$url_query=this.sensors_mp_url_query?this.sensors_mp_url_query:"",e=_.extend(e,_.getUtmFromPage()),_.setPageSfSource(e),a&&(e.$title=a),sa.para.onshow?sa.para.onshow(sa,t,this):_.isObject(sa.para.autotrack_exclude_page)&&_.isArray(sa.para.autotrack_exclude_page.pageShow)&&-1!==sa.para.autotrack_exclude_page.pageShow.indexOf(t)||sa.autoTrackCustom.trackCustom("pageShow",e,"$MPViewScreen"),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:t}),sa_referrer=t,sa.status.referrer=t},pageShare:function(e){var t=e.onShareAppMessage;e.onShareAppMessage=function(){share_method="\u8f6c\u53d1\u6d88\u606f\u5361\u7247";var e=t.apply(this,arguments);return sa.para.autoTrack&&sa.para.autoTrack.pageShare&&sa.autoTrackCustom.trackCustom("pageShare",{$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method},"$MPShare"),sa.para.allow_amend_share_path&&("object"!=typeof e&&((e={}).path=_.getCurrentUrl(this)),"object"!=typeof e||void 0!==e.path&&""!==e.path||(e.path=_.getCurrentUrl(this)),"object"==typeof e&&"string"==typeof e.path&&(-1===e.path.indexOf("?")?e.path=e.path+"?":"&"!==e.path.slice(-1)&&(e.path=e.path+"&")),e.path=e.path+"sampshare="+encodeURIComponent(_.getShareInfo())),e}},pageShareTimeline:function(e){var t=e.onShareTimeline;e.onShareTimeline=function(){share_method="\u670b\u53cb\u5708\u5206\u4eab";var e=t.apply(this,arguments);return sa.para.autoTrack&&sa.para.autoTrack.pageShare&&sa.autoTrackCustom.trackCustom("pageShare",{$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method},"$MPShare"),sa.para.allow_amend_share_path&&("object"!=typeof e&&(e={}),"object"==typeof e&&void 0===e.query&&(e.query=""),"object"==typeof e&&"string"==typeof e.query&&""!==e.query&&"&"!==e.query.slice(-1)&&(e.query=e.query+"&"),e.query=e.query+"sampshare="+encodeURIComponent(_.getShareInfo())),e}},pageAddFavorites:function(){var e={};e.$url_path=_.getCurrentPath(),sa.para.autoTrack&&sa.para.autoTrack.mpFavorite&&sa.autoTrackCustom.trackCustom("mpFavorite",e,"$MPAddFavorites")}},sa.quick=function(){var e=arguments[0],t=arguments[1],a=arguments[2],r=_.isObject(a)?a:{};if("getAnonymousID"===e){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===e||"appShow"===e?t?sa.autoTrackCustom[e](t,r):logger.info("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(r=_.isObject(t)?t:{},sa.autoTrackCustom[e](r))},sa.appLaunch=function(e,t){var a={};e&&e.scene?(current_scene=e.scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(a.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),_.setShareInfo(e,a);var r=_.setUtm(e,a);is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):a.$is_first_time=!1,_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),_.isObject(t)&&(a=_.extend(a,t)),sa.track("$MPLaunch",a)},sa.appShow=function(e,t){var a={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(a.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,a);var r=_.setUtm(e,a);_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),_.isObject(t)&&(a=_.extend(a,t)),sa.track("$MPShow",a)},sa.appHide=function(e){var t=(new Date).getTime(),a={};a.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(a.event_duration=(t-mpshow_time)/1e3),_.isObject(e)&&(a=_.extend(a,e)),sa.track("$MPHide",a),sa.sendStrategy.onAppHide()},sa.pageShow=function(e){var t={},a=_.getCurrentPath(),r=_.getPageTitle(a),s={};try{var n=getCurrentPages();s=n[n.length-1]}catch(e){logger.info(e)}!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a}),r&&(t.$title=r),t.$referrer=sa_referrer,t.$url_path=a,sa.status.last_referrer=sa_referrer,t.$url_query=s.sensors_mp_url_query?s.sensors_mp_url_query:"",t=_.extend(t,_.getUtmFromPage()),_.setPageSfSource(t),_.isObject(e)&&(t=_.extend(t,e)),sa.track("$MPViewScreen",t),sa_referrer=a,sa.status.referrer=a},sa.App=function(e){(e=e||{})[sa.para.name]=sa,App.apply(this,arguments)},wx.onAppShow(function(e){if(!sa.para.launched){var t=wx.getLaunchOptionsSync()||{};sa.autoTrackCustom.appLaunch(t),sa.para.launched=!0}sa.autoTrackCustom.appShow(e)}),wx.onAppHide(function(){sa.autoTrackCustom.appHide()}),sa.Page=function(e){var t=sa.para.autoTrack&&sa.para.autoTrack.mpClick&&_.getMethods(e);if(t)for(var a=0,r=t.length;asa.para.max_string_length?(logger.info("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,sa.para.max_string_length)):e},_.searchObjString=function(e){_.isObject(e)&&_.each(e,function(t,a){_.isObject(t)?_.searchObjString(e[a]):_.isString(t)&&(e[a]=_.formatString(t))})},_.parseSuperProperties=function(e){_.isObject(e)&&(_.each(e,function(t,a){if(_.isFunction(t))try{e[a]=t(),_.isFunction(e[a])&&(logger.info("\u60a8\u7684\u5c5e\u6027- "+a+" \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}catch(t){delete e[a],logger.info("\u60a8\u7684\u5c5e\u6027- "+a+" \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}}),_.strip_sa_properties(e))},_.unique=function(e){for(var t,a=[],r={},s=0;s127&&i<2048?String.fromCharCode(i>>6|192,63&i|128):String.fromCharCode(i>>12|224,i>>6&63|128,63&i|128),null!==o&&(a>t&&(n+=e.substring(t,a)),n+=o,t=a=s+1)}return a>t&&(n+=e.substring(t,e.length)),n},_.base64Encode=function(e){var t,a,r,s,n,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,c=0,u="",p=[];if(!e)return e;e=_.utf8Encode(e);do{t=(n=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,a=n>>12&63,r=n>>6&63,s=63&n,p[c++]=i.charAt(t)+i.charAt(a)+i.charAt(r)+i.charAt(s)}while(o255||(r=e.charCodeAt(o++))>255||(s=e.charCodeAt(o++))>255)&&logger.info("Failed to execute 'btoa' : The string to be encoded contains characters outside of the Latin1 range."),i+=n.charAt((t=a<<16|r<<8|s)>>18&63)+n.charAt(t>>12&63)+n.charAt(t>>6&63)+n.charAt(63&t);return c?i.slice(0,c-3)+"===".substring(c):i},_.urlBase64Encode=function(e){return _.btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))},_.rot13obfs=function(e,t){t="number"==typeof t?t:13;for(var a=(e=String(e)).split(""),r=0,s=a.length;r(new Date).getTime()},_.getCurrentUrl=function(e){var t=_.getCurrentPath(),a="";return _.isObject(e)&&e.sensors_mp_encode_url_query&&(a=e.sensors_mp_encode_url_query),t?a?t+"?"+a:t:"\u672a\u53d6\u5230"},_.getPath=function(e){return e="string"==typeof e?e.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"},_.getMethods=function(e){var t=[];for(var a in e)"function"!=typeof e[a]||mpHook[a]||t.push(a);return t},_.isClick=function(e){return!!{tap:1,longpress:1,longtap:1}[e]},sa.initialState={queue:[],isComplete:!1,systemIsComplete:!1,storeIsComplete:!1,checkIsComplete:function(){this.systemIsComplete&&this.storeIsComplete&&(this.isComplete=!0,this.queue.length>0&&(_.each(this.queue,function(e){sa[e[0]].apply(sa,slice.call(e[1]))}),this.queue=[]))}},_.getCustomUtmFromQuery=function(e,t,a,r){if(!_.isObject(e))return{};var s={};if(e.sa_utm)for(var n in e)"sa_utm"!==n?_.include(sa.para.source_channel,n)&&(s[a+n]=e[n]):s[r+n]=e[n];else for(var n in e)-1===(" "+source_channel_standard+" ").indexOf(" "+n+" ")?_.include(sa.para.source_channel,n)&&(s[a+n]=e[n]):s[t+n]=e[n];return s},_.getObjFromQuery=function(e){var t=e.split("?"),a=[],r={};return t&&t[1]?(_.each(t[1].split("&"),function(e){(a=e.split("="))[0]&&a[1]&&(r[a[0]]=a[1])}),r):{}},_.setStorageSync=function(e,t){var a=function(){wx.setStorageSync(e,t)};try{a()}catch(e){logger.info("set Storage fail --",e);try{a()}catch(e){logger.info("set Storage fail again --",e)}}},_.getStorageSync=function(e){var t="";try{t=wx.getStorageSync(e)}catch(a){try{t=wx.getStorageSync(e)}catch(e){logger.info("getStorage fail")}}return t},_.getMPScene=function(e){return"number"==typeof e||"string"==typeof e&&""!==e?e="wx-"+String(e):"\u672a\u53d6\u5230\u503c"},_.setShareInfo=function(e,t){var a={},r={},s=sa.store.getDistinctId(),n=sa.store.getFirstId();if(!(e&&_.isObject(e.query)&&e.query.sampshare))return{};if(a=_.decodeURIComponent(e.query.sampshare),!_.isJSONString(a))return{};var i=(a=JSON.parse(a)).d,o=a.p,c=a.i,u=a.m;"string"==typeof c?(t.$share_distinct_id=c,share_distinct_id=c,r.$latest_share_distinct_id=c):t.$share_distinct_id="\u53d6\u503c\u5f02\u5e38","number"==typeof i?!share_distinct_id||share_distinct_id!==s&&share_distinct_id!==n?!share_distinct_id||share_distinct_id===s&&share_distinct_id===n?t.$share_depth="-1":(t.$share_depth=i+1,query_share_depth=i+1,r.$latest_share_depth=i+1):(t.$share_depth=i,query_share_depth=i,r.$latest_share_depth=i):t.$share_depth="-1","string"==typeof o?(t.$share_url_path=o,r.$latest_share_url_path=o):t.$share_url_path="\u53d6\u503c\u5f02\u5e38","string"==typeof u?(t.$share_method=u,r.$latest_share_method=u):t.$share_method="\u53d6\u503c\u5f02\u5e38",_.setLatestShare(r)},_.getShareInfo=function(){return JSON.stringify({i:sa.store.getDistinctId()||"\u53d6\u503c\u5f02\u5e38",p:_.getCurrentPath(),d:query_share_depth,m:share_method})},_.detectOptionQuery=function(e){if(!e||!_.isObject(e.query))return{};var t,a,r,s,n={};return n.query=_.extend({},e.query),"string"==typeof n.query.scene&&(t=n.query,a=["utm_source","utm_content","utm_medium","utm_campaign","utm_term","sa_utm"].concat(sa.para.source_channel),r=new RegExp("("+a.join("|")+")%3D","i"),1===(s=Object.keys(t)).length&&"scene"===s[0]&&r.test(t.scene))&&(n.scene=n.query.scene,delete n.query.scene),e.query.q&&e.query.scancode_time&&"101"===String(e.scene).slice(0,3)&&(n.q=String(n.query.q),delete n.query.q,delete n.query.scancode_time),n},_.getMixedQuery=function(e){var t=_.detectOptionQuery(e),a=t.scene,r=t.q,s=t.query;for(var n in s)s[n]=_.decodeURIComponent(s[n]);return a&&(a=-1!==(a=_.decodeURIComponent(a)).indexOf("?")?"?"+a.replace(/\?/g,""):"?"+a,_.extend(s,_.getObjFromQuery(a))),r&&_.extend(s,_.getObjFromQuery(_.decodeURIComponent(r))),s},_.setUtm=function(e,t){var a={},r=_.getMixedQuery(e),s=_.getCustomUtmFromQuery(r,"$","_","$"),n=_.getCustomUtmFromQuery(r,"$latest_","_latest_","$latest_");return a.pre1=s,a.pre2=n,_.extend(t,s),a},_.setSfSource=function(e,t){!_.isEmptyObject(e.query)&&e.query._sfs&&(t.$sf_source=e.query._sfs,sa.registerApp({$latest_sf_source:t.$sf_source}))},_.setPageSfSource=function(e){try{var t=getCurrentPages(),a=JSON.parse(JSON.stringify(t[t.length-1].options));for(var r in a)a[r]=_.decodeURIComponent(a[r]);!_.isEmptyObject(a)&&a._sfs&&(e.$sf_source=a._sfs)}catch(e){logger.info(e)}};try{var oldSetNavigationBarTitle=wx.setNavigationBarTitle;Object.defineProperty(wx,"setNavigationBarTitle",{get:function(){return function(e){var t=getCurrentPages(),a=t[t.length-1].route||"";e=_.isObject(e)?e:{},globalTitle[a]=e.title,oldSetNavigationBarTitle.call(this,e)}}})}catch(e){logger.info(e)}function mp_proxy(e,t,a){var r=sa.autoTrackCustom[a];if(e[t]){var s=e[t];e[t]=function(){"onLaunch"===t&&(this[sa.para.name]=sa),!sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&!sa.para.autoTrackIsFirst[a]?(s.apply(this,arguments),r.apply(this,arguments)):(!0===sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&sa.para.autoTrackIsFirst[a])&&(r.apply(this,arguments),s.apply(this,arguments))}}else e[t]=function(){"onLaunch"===t&&(this[sa.para.name]=sa),r.apply(this,arguments)}}function clickTrack(e){var t,a={},r={},s=e.currentTarget||{},n=e.target||{};if(_.isObject(sa.para.framework)&&_.isObject(sa.para.framework.taro)&&!sa.para.framework.taro.createApp&&n.id&&s.id&&n.id!==s.id)return!1;var i=s.dataset||{};if(t=e.type,a.$element_id=s.id,a.$element_type=i.type,a.$element_content=i.content,a.$element_name=i.name,_.isObject(e.event_prop)&&(r=e.event_prop),t&&_.isClick(t)){if(sa.para.preset_events&&sa.para.preset_events.collect_element&&!1===sa.para.preset_events.collect_element(arguments[0]))return!1;a.$url_path=_.getCurrentPath(),a=_.extend(a,r),sa.track("$MPClick",a)}}function click_proxy(e,t){var a=e[t];e[t]=function(){var e=a.apply(this,arguments),t=arguments[0];return _.isObject(t)&&(sa.para.preset_events.defer_track?setTimeout(function(){clickTrack(t)},0):clickTrack(t)),e}}function tabProxy(e){var t=e.onTabItemTap;e.onTabItemTap=function(e){t&&t.apply(this,arguments);var a={};e&&(a.$element_content=e.text),a.$element_type="tabBar",a.$url_path=_.getCurrentPath(),sa.track("$MPClick",a)}}_.getPageTitle=function(e){if("\u672a\u53d6\u5230"===e||!e)return!1;var t="";try{if(__wxConfig){var a=__wxConfig,r=a.page[e]||a.page[e+".html"],s={},n={};if(a.global&&a.global.window&&a.global.window.navigationBarTitleText&&(s.titleVal=a.global.window.navigationBarTitleText),r&&r.window&&r.window.navigationBarTitleText&&(n.titleVal=r.window.navigationBarTitleText),_.each(globalTitle,function(a,r){if(r===e)return t=a}),0===t.length){var i=_.extend(s,n);t=i.titleVal}}}catch(e){logger.info(e)}return t},_.wxrequest=function(e){if(_.compareSDKVersion(wxSDKVersion,"2.10.0")>=0)e.timeout=sa.para.datasend_timeout,wx.request(e);else{var t=wx.request(e);setTimeout(function(){_.isObject(t)&&_.isFunction(t.abort)&&t.abort()},sa.para.datasend_timeout)}},_.getAppId=function(){var e;if(wx.getAccountInfoSync&&(e=wx.getAccountInfoSync()),_.isObject(e)&&_.isObject(e.miniProgram))return e.miniProgram.appId},_.validId=function(e){return"string"!=typeof e&&"number"!=typeof e||""===e?(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1):"number"!=typeof e||(e=String(e),/^\d+$/.test(e))?e:(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1)},_.compareSDKVersion=function(e,t){e=e.split("."),t=t.split(".");for(var a=Math.max(e.length,t.length);e.lengthn)return 1;if(s-1?t.system.split(" ")[1]:t.system,wxSDKVersion=t.SDKVersion},complete:function(){var t=(new Date).getTimezoneOffset(),a=_.getAppId();_.isNumber(t)&&(e.$timezone_offset=t),a&&(e.$app_id=a),sa.initialState.systemIsComplete=!0,sa.initialState.checkIsComplete()}})}wx.getNetworkType({success:function(t){e.$network_type=_.setUpperCase(t.networkType)},complete:t})}},sa._=_,_.eventEmitter=function(){this.sub=[]},_.eventEmitter.prototype={add:function(e){this.sub.push(e)},emit:function(e,t){this.sub.forEach(function(a){a.on(e,t)})}},_.eventSub=function(e){sa.events.add(this),this._events=[],this.handle=e,this.ready=!1},_.eventSub.prototype={on:function(e,t){if(this.ready){if(_.isFunction(this.handle))try{this.handle(e,t)}catch(e){logger.info(e)}}else this._events.push({event:e,data:t})},isReady:function(){var e=this;e.ready=!0,e._events.forEach(function(t){if(_.isFunction(e.handle))try{e.handle(t.event,t.data)}catch(e){logger.info(e)}})}},sa.eventSub=_.eventSub,sa.events=new _.eventEmitter,sa.usePlugin=function(e,t){"function"==typeof e.init&&e.init(sa,t)},sa.prepareData=function(e,t){if(current_scene&&1154===current_scene&&!sa.para.preset_events.moments_page)return!1;var a={distinct_id:this.store.getDistinctId(),lib:{$lib:LIB_NAME,$lib_method:"code",$lib_version:String(LIB_VERSION)},properties:{}};_.extend(a,this.store.getUnionId(),e),_.isObject(e.properties)&&!_.isEmptyObject(e.properties)&&_.extend(a.properties,e.properties),e.type&&"profile"===e.type.slice(0,7)||(a._track_id=Number(String(Math.random()).slice(2,5)+String(Math.random()).slice(2,4)+String(Date.now()).slice(-4)),a.properties=_.extend({},_.info.properties,sa.store.getProps(),_.info.currentProps,a.properties),a.properties.$is_first_day=_.getIsFirstDay()),a.properties.$time&&_.isDate(a.properties.$time)?(a.time=1*a.properties.$time,delete a.properties.$time):a.time=1*new Date,_.parseSuperProperties(a.properties),_.searchObjDate(a),_.searchObjString(a),logger.info(a),sa.events.emit("send",a),sa.sendStrategy.send(a)},sa.store={storageInfo:null,getUUID:function(){return Date.now()+"-"+Math.floor(1e7*Math.random())+"-"+Math.random().toString(16).replace(".","")+"-"+String(31242*Math.random()).replace(".","").slice(0,8)},getStorage:function(){return this.storageInfo?this.storageInfo:(this.storageInfo=sa._.getStorageSync("sensorsdata2015_wechat")||"",this.storageInfo)},_state:{},mem:{mdata:[],getLength:function(){return this.mdata.length},add:function(e){this.mdata.push(e)},clear:function(e){this.mdata.splice(0,e)}},toState:function(e){var t=null;_.isJSONString(e)?(t=JSON.parse(e)).distinct_id?this._state=t:this.set("distinct_id",this.getUUID()):_.isObject(e)&&(t=e).distinct_id?this._state=t:this.set("distinct_id",this.getUUID())},getFirstId:function(){return this._state._first_id||this._state.first_id},getDistinctId:function(){return this._state._distinct_id||this._state.distinct_id},getUnionId:function(){var e={},t=this._state._first_id||this._state.first_id,a=this._state._distinct_id||this._state.distinct_id;return t&&a?(e.login_id=a,e.anonymous_id=t):e.anonymous_id=a,e},getProps:function(){return this._state.props||{}},setProps:function(e,t){var a=this._state.props||{};t?this.set("props",e):(_.extend(a,e),this.set("props",a))},set:function(e,t){var a={};for(var r in"string"==typeof e?a[e]=t:"object"==typeof e&&(a=e),this._state=this._state||{},a)this._state[r]=a[r],"first_id"===r?delete this._state._first_id:"distinct_id"===r&&(delete this._state._distinct_id,sa.events.emit("changeDistinctId"));this.save()},change:function(e,t){this._state["_"+e]=t},encryptStorage:function(){var e=this.getStorage(),t="data:enc;";_.isObject(e)?e=t+_.rot13obfs(JSON.stringify(e)):_.isString(e)&&-1===e.indexOf(t)&&(e=t+_.rot13obfs(e)),sa._.setStorageSync("sensorsdata2015_wechat",e)},save:function(){var e=JSON.parse(JSON.stringify(this._state));if(delete e._first_id,delete e._distinct_id,sa.para.encrypt_storage){e="data:enc;"+_.rot13obfs(JSON.stringify(e))}sa._.setStorageSync("sensorsdata2015_wechat",e)},init:function(){var e=this.getStorage();if(e)_.isString(e)&&-1!==e.indexOf("data:enc;")&&(e=e.substring("data:enc;".length),e=JSON.parse(_.rot13defs(e))),this.toState(e);else{is_first_launch=!0;var t=new Date,a=t.getTime();t.setHours(23),t.setMinutes(59),t.setSeconds(60),sa.setOnceProfile({$first_visit_time:new Date}),this.set({distinct_id:this.getUUID(),first_visit_time:a,first_visit_day_time:t.getTime()})}}},sa.setProfile=function(e,t){sa.prepareData({type:"profile_set",properties:e},t)},sa.setOnceProfile=function(e,t){sa.prepareData({type:"profile_set_once",properties:e},t)},sa.appendProfile=function(e,t){if(!_.isObject(e))return!1;_.each(e,function(t,a){_.isString(t)?e[a]=[t]:_.isArray(t)||(delete e[a],logger.info("appendProfile\u5c5e\u6027\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32\u6216\u8005\u6570\u7ec4"))}),sa.prepareData({type:"profile_append",properties:e},t)},sa.incrementProfile=function(e,t){if(!_.isObject(e))return!1;var a=e;_.isString(e)&&((e={})[a]=1),sa.prepareData({type:"profile_increment",properties:e},t)},sa.track=function(e,t,a){this.prepareData({type:"track",event:e,properties:t},a)},sa.identify=function(e,t){if(e=_.validId(e)){var a=sa.store.getFirstId();!0===t?a?sa.store.set("first_id",e):sa.store.set("distinct_id",e):a?sa.store.change("first_id",e):sa.store.change("distinct_id",e)}},sa.trackSignup=function(e,t,a,r){var s=sa.store.getFirstId()||sa.store.getDistinctId();sa.store.set("distinct_id",e),sa.prepareData({original_id:s,distinct_id:e,type:"track_signup",event:t,properties:a},r)},sa.registerApp=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&(_.info.currentProps=_.extend(_.info.currentProps,e))},sa.register=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&sa.store.setProps(e)},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.clearAllProps=function(e){var t=sa.store.getProps(),a={};_.isArray(e)&&(_.each(t,function(t,r){_.include(e,r)||(a[r]=t)}),sa.store.setProps(a,!0))},sa.clearAppRegister=function(e){_.isArray(e)&&_.each(_.info.currentProps,function(t,a){_.include(e,a)&&delete _.info.currentProps[a]})},_.setLatestChannel=function(e){_.isEmptyObject(e)||(function(e,t){var a=!1;for(var r in t)e[t[r]]&&(a=!0);return a}(e,latest_source_channel)&&(sa.clearAppRegister(latest_source_channel),sa.clearAllProps(latest_source_channel)),sa.para.is_persistent_save.utm?sa.register(e):sa.registerApp(e))},_.setLatestShare=function(e){(e.$latest_share_depth||e.$latest_share_distinct_id||e.$latest_share_url_path||e.$latest_share_method)&&(sa.clearAppRegister(latest_share_info),sa.clearAllProps(latest_share_info),sa.para.is_persistent_save.share?sa.register(e):sa.registerApp(e))},sa.login=function(e){if(e=_.validId(e)){var t=sa.store.getFirstId(),a=sa.store.getDistinctId();e!==a&&(t?sa.trackSignup(e,"$SignUp"):(sa.store.set("first_id",a),sa.trackSignup(e,"$SignUp")))}},sa.getAnonymousID=function(){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")},sa.logout=function(e){var t=sa.store.getFirstId();t?(sa.store.set("first_id",""),!0===e?sa.store.set("distinct_id",sa.store.getUUID()):sa.store.set("distinct_id",t)):logger.info("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25")},sa.getLocation=function(){wx.getSetting({success:function(e){if(!e.authSetting["scope.userLocation"])return!1;wx.getLocation({type:sa.para.preset_properties.location.type,success:function(e){sa.registerApp({$latitude:e.latitude*Math.pow(10,6),$longitude:e.longitude*Math.pow(10,6),$geo_coordinate_system:_.setUpperCase(sa.para.preset_properties.location.type)})},fail:function(e){console.log("\u83b7\u53d6\u4f4d\u7f6e\u5931\u8d25",e)}})}})},sa.openid={getRequest:function(e){wx.login({success:function(t){t.code&&sa.para.appid&&sa.para.openid_url?_.wxrequest({url:sa.para.openid_url+"&code="+t.code+"&appid="+sa.para.appid,method:"GET",complete:function(t){_.isObject(t)&&_.isObject(t.data)&&t.data.openid?e(t.data.openid):e()}}):e()}})},getWXStorage:function(){var e=sa.store.getStorage();if(e&&_.isObject(e))return e.openid},getOpenid:function(e){if(!sa.para.appid)return e(),!1;var t=this.getWXStorage();t?e(t):this.getRequest(e)}},sa.initial=function(){this._.info.getSystem(),this.store.init()},sa.init=function(e){if(!0===this.hasInit)return!1;this.hasInit=!0,sa.setPara(e),sa.para.encrypt_storage&&this.store.encryptStorage(),sa.para.batch_send&&(wx.getStorage({key:"sensors_mp_prepare_data",complete:function(e){var t=e.data&&_.isArray(e.data)?e.data:[];sa.store.mem.mdata=t.concat(sa.store.mem.mdata),sa.sendStrategy.syncStorage=!0}}),sa.sendStrategy.batchInterval()),sa.initialState.storeIsComplete=!0,sa.initialState.checkIsComplete()},sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib){var e={};_.each(_.info.currentProps,function(t,a){0===a.indexOf("$")&&(e[a]=t)});var t=_.extend(e,{$url_path:_.getCurrentPath(),$is_first_day:_.getIsFirstDay()},_.info.properties,sa.store.getProps());return delete t.$lib,t}return{}},_.autoExeQueue=function(){return{items:[],enqueue:function(e){this.items.push(e),this.start()},dequeue:function(){return this.items.shift()},getCurrentItem:function(){return this.items[0]},isRun:!1,start:function(){this.items.length>0&&!this.isRun&&(this.isRun=!0,this.getCurrentItem().start())},close:function(){this.dequeue(),this.isRun=!1,this.start()}}},sa.requestQueue=function(e){this.url=e.url},sa.requestQueue.prototype.isEnd=function(){this.received||(this.received=!0,this.close())},sa.requestQueue.prototype.start=function(){var e=this;_.wxrequest({url:this.url,method:"GET",complete:function(){e.isEnd()}})},sa.dataQueue=_.autoExeQueue(),sa.sendStrategy={dataHasSend:!0,dataHasChange:!1,syncStorage:!1,failTime:0,onAppHide:function(){sa.para.batch_send&&this.batchSend()},send:function(e){if(!sa.para.server_url)return!1;sa.para.batch_send?(this.dataHasChange=!0,sa.store.mem.getLength()>=500&&(logger.info("\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38"),sa.store.mem.mdata.shift()),sa.store.mem.add(e),sa.store.mem.getLength()>=sa.para.batch_send.max_length&&this.batchSend()):this.queueSend(e)},queueSend:function(e){e._flush_time=Date.now(),e=JSON.stringify(e),e=-1!==sa.para.server_url.indexOf("?")?sa.para.server_url+"&data="+encodeURIComponent(_.base64Encode(e)):sa.para.server_url+"?data="+encodeURIComponent(_.base64Encode(e));var t=new sa.requestQueue({url:e});t.close=function(){sa.dataQueue.close()},sa.dataQueue.enqueue(t)},wxrequest:function(e){if(_.isArray(e.data)&&e.data.length>0){var t=Date.now();e.data.forEach(function(e){e._flush_time=t}),e.data=JSON.stringify(e.data),_.wxrequest({url:sa.para.server_url,method:"POST",dataType:"text",data:"data_list="+encodeURIComponent(_.base64Encode(e.data)),success:function(){e.success(e.len)},fail:function(){e.fail()}})}else e.success(e.len)},batchSend:function(){if(this.dataHasSend){var e,t,a=sa.store.mem.mdata;(t=(e=a.length>=100?a.slice(0,100):a).length)>0&&(this.dataHasSend=!1,this.wxrequest({data:e,len:t,success:this.batchRemove.bind(this),fail:this.sendFail.bind(this)}))}},sendFail:function(){this.dataHasSend=!0,this.failTime++},batchRemove:function(e){sa.store.mem.clear(e),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite(),this.failTime=0},is_first_batch_write:!0,batchWrite:function(){var e=this;this.dataHasChange&&(this.is_first_batch_write&&(this.is_first_batch_write=!1,setTimeout(function(){e.batchSend()},1e3)),this.dataHasChange=!1,this.syncStorage&&sa._.setStorageSync("sensors_mp_prepare_data",sa.store.mem.mdata))},batchInterval:function(){var e=this;!function t(){setTimeout(function(){e.batchWrite(),t()},500)}(),function t(){setTimeout(function(){e.batchSend(),t()},sa.para.batch_send.send_timeout*Math.pow(2,e.failTime))}()}},sa.setOpenid=function(e,t){sa.store.set("openid",e),t?sa.store.set("distinct_id",e):sa.identify(e,!0)},sa.initWithOpenid=function(e,t){(e=e||{}).appid&&(sa.para.appid=e.appid),sa.openid.getOpenid(function(a){a&&sa.setOpenid(a,e.isCoverLogin),t&&_.isFunction(t)&&t(a),sa.init(e)})},sa.setWebViewUrl=function(e,t){if(!_.isString(e)||""===e)return logger.info("error:\u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;e=decodeURIComponent(e);var a,r=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e),s=r[1]||"",n=r[2]||"",i=r[3]||"",o="",c=sa.store.getDistinctId()||"",u=sa.store.getFirstId()||"";_.urlSafeBase64&&_.urlSafeBase64.encode?c=c?_.urlSafeBase64.trim(_.urlSafeBase64.encode(_.urlBase64Encode(c))):"":this._.rot13obfs&&(c=c?_.rot13obfs(c):""),c=encodeURIComponent(c);var p=u?"f"+c:"d"+c;t?(a=i.indexOf("_sasdk"),o=i.indexOf("?")>-1?a>-1?s+n+"#"+i.substring(1,a)+"_sasdk="+p:s+n+"#"+i.substring(1)+"&_sasdk="+p:s+n+"#"+i.substring(1)+"?_sasdk="+p):(a=n.indexOf("_sasdk"),o=/^\?(\w)+/.test(n)?a>-1?s+"?"+n.substring(1,a)+"_sasdk="+p+i:s+"?"+n.substring(1)+"&_sasdk="+p+i:s+"?"+n.substring(1)+"_sasdk="+p+i);return o},_.each(["setProfile","setOnceProfile","track","quick","incrementProfile","appendProfile","login","logout","registerApp","register","clearAllRegister","clearAllProps","clearAppRegister"],function(e){var t=sa[e];sa[e]=function(){sa.initialState.isComplete?t.apply(sa,arguments):sa.initialState.queue.push([e,arguments])}}),_.setQuery=function(e,t){if(e&&_.isObject(e)&&!_.isEmptyObject(e)){var a=[];return _.each(e,function(e,r){"q"===r&&_.isString(e)&&0===e.indexOf("http")||(t?a.push(r+"="+e):a.push(r+"="+_.decodeURIComponent(e)))}),a.join("&")}return""},_.getUtmFromPage=function(){var e={};try{var t=getCurrentPages(),a=JSON.parse(JSON.stringify(t[t.length-1].options));for(var r in a)a[r]=_.decodeURIComponent(a[r]);e=_.getCustomUtmFromQuery(a,"$","_","$")}catch(e){logger.info(e)}return e},sa.autoTrackCustom={trackCustom:function(e,t,a){var r=sa.para.autoTrack[e],s="";sa.para.autoTrack&&r&&("function"==typeof r?(s=r(),_.isObject(s)&&_.extend(t,s)):_.isObject(r)&&(_.extend(t,r),sa.para.autoTrack[e]=!0),sa.track(a,t))},appLaunch:function(e,t){"object"!=typeof this||this.trackCustom||(this[sa.para.name]=sa);var a={};e&&e.scene?(current_scene=e.scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(a.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),_.setShareInfo(e,a);var r=_.setUtm(e,a);is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):a.$is_first_time=!1,_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),t?(a=_.extend(a,t),sa.track("$MPLaunch",a)):sa.para.autoTrack&&sa.para.autoTrack.appLaunch&&sa.autoTrackCustom.trackCustom("appLaunch",a,"$MPLaunch")},appShow:function(e,t){var a={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(a.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,a);var r=_.setUtm(e,a);_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),t?(a=_.extend(a,t),sa.track("$MPShow",a)):sa.para.autoTrack&&sa.para.autoTrack.appShow&&sa.autoTrackCustom.trackCustom("appShow",a,"$MPShow")},appHide:function(e){var t=(new Date).getTime(),a={};a.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(a.event_duration=(t-mpshow_time)/1e3),e?(a=_.extend(a,e),sa.track("$MPHide",a)):sa.para.autoTrack&&sa.para.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",a,"$MPHide"),sa.sendStrategy.onAppHide()},pageLoad:function(e){current_scene&&1010===current_scene&&e&&e.sampshare&&delete e.sampshare,e&&_.isObject(e)&&(this.sensors_mp_url_query=_.setQuery(e),this.sensors_mp_encode_url_query=_.setQuery(e,!0))},pageShow:function(){var e={},t=_.getCurrentPath(),a=_.getPageTitle(t);e.$referrer=sa_referrer,e.$url_path=t,sa.status.last_referrer=sa_referrer,e.$url_query=this.sensors_mp_url_query?this.sensors_mp_url_query:"",e=_.extend(e,_.getUtmFromPage()),_.setPageSfSource(e),a&&(e.$title=a),sa.para.onshow?sa.para.onshow(sa,t,this):_.isObject(sa.para.autotrack_exclude_page)&&_.isArray(sa.para.autotrack_exclude_page.pageShow)&&-1!==sa.para.autotrack_exclude_page.pageShow.indexOf(t)||sa.autoTrackCustom.trackCustom("pageShow",e,"$MPViewScreen"),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:t}),sa_referrer=t,sa.status.referrer=t},pageShare:function(e){var t=e.onShareAppMessage;e.onShareAppMessage=function(){share_method="\u8f6c\u53d1\u6d88\u606f\u5361\u7247";var e=t.apply(this,arguments);return sa.para.autoTrack&&sa.para.autoTrack.pageShare&&sa.autoTrackCustom.trackCustom("pageShare",{$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method},"$MPShare"),sa.para.allow_amend_share_path&&("object"!=typeof e&&((e={}).path=_.getCurrentUrl(this)),"object"!=typeof e||void 0!==e.path&&""!==e.path||(e.path=_.getCurrentUrl(this)),"object"==typeof e&&"string"==typeof e.path&&(-1===e.path.indexOf("?")?e.path=e.path+"?":"&"!==e.path.slice(-1)&&(e.path=e.path+"&")),e.path=e.path+"sampshare="+encodeURIComponent(_.getShareInfo())),e}},pageShareTimeline:function(e){var t=e.onShareTimeline;e.onShareTimeline=function(){share_method="\u670b\u53cb\u5708\u5206\u4eab";var e=t.apply(this,arguments);return sa.para.autoTrack&&sa.para.autoTrack.pageShare&&sa.autoTrackCustom.trackCustom("pageShare",{$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method},"$MPShare"),sa.para.allow_amend_share_path&&("object"!=typeof e&&(e={}),"object"==typeof e&&void 0===e.query&&(e.query=""),"object"==typeof e&&"string"==typeof e.query&&""!==e.query&&"&"!==e.query.slice(-1)&&(e.query=e.query+"&"),e.query=e.query+"sampshare="+encodeURIComponent(_.getShareInfo())),e}},pageAddFavorites:function(){var e={};e.$url_path=_.getCurrentPath(),sa.para.autoTrack&&sa.para.autoTrack.mpFavorite&&sa.autoTrackCustom.trackCustom("mpFavorite",e,"$MPAddFavorites")}},sa.quick=function(){var e=arguments[0],t=arguments[1],a=arguments[2],r=_.isObject(a)?a:{};if("getAnonymousID"===e){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===e||"appShow"===e?t?sa.autoTrackCustom[e](t,r):logger.info("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(r=_.isObject(t)?t:{},sa.autoTrackCustom[e](r))},sa.appLaunch=function(e,t){var a={};e&&e.scene?(current_scene=e.scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(a.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),_.setShareInfo(e,a);var r=_.setUtm(e,a);is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):a.$is_first_time=!1,_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),_.isObject(t)&&(a=_.extend(a,t)),sa.track("$MPLaunch",a)},sa.appShow=function(e,t){var a={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(a.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,a);var r=_.setUtm(e,a);_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),_.isObject(t)&&(a=_.extend(a,t)),sa.track("$MPShow",a)},sa.appHide=function(e){var t=(new Date).getTime(),a={};a.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(a.event_duration=(t-mpshow_time)/1e3),_.isObject(e)&&(a=_.extend(a,e)),sa.track("$MPHide",a),sa.sendStrategy.onAppHide()},sa.pageShow=function(e){var t={},a=_.getCurrentPath(),r=_.getPageTitle(a),s={};try{var n=getCurrentPages();s=n[n.length-1]}catch(e){logger.info(e)}!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a}),r&&(t.$title=r),t.$referrer=sa_referrer,t.$url_path=a,sa.status.last_referrer=sa_referrer,t.$url_query=s.sensors_mp_url_query?s.sensors_mp_url_query:"",t=_.extend(t,_.getUtmFromPage()),_.setPageSfSource(t),_.isObject(e)&&(t=_.extend(t,e)),sa.track("$MPViewScreen",t),sa_referrer=a,sa.status.referrer=a},sa.App=function(e){(e=e||{})[sa.para.name]=sa,App.apply(this,arguments)},wx.onAppShow(function(e){if(!sa.para.launched){var t=wx.getLaunchOptionsSync()||{};sa.autoTrackCustom.appLaunch(t),sa.para.launched=!0}sa.autoTrackCustom.appShow(e)}),wx.onAppHide(function(){sa.autoTrackCustom.appHide()}),sa.Page=function(e){var t=sa.para.autoTrack&&sa.para.autoTrack.mpClick&&_.getMethods(e);if(t)for(var a=0,r=t.length;asa.para.max_string_length?(logger.info("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,sa.para.max_string_length)):e},_.searchObjString=function(e){_.isObject(e)&&_.each(e,function(t,a){_.isObject(t)?_.searchObjString(e[a]):_.isString(t)&&(e[a]=_.formatString(t))})},_.parseSuperProperties=function(e){_.isObject(e)&&(_.each(e,function(t,a){if(_.isFunction(t))try{e[a]=t(),_.isFunction(e[a])&&(logger.info("\u60a8\u7684\u5c5e\u6027- "+a+" \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}catch(t){delete e[a],logger.info("\u60a8\u7684\u5c5e\u6027- "+a+" \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}}),_.strip_sa_properties(e))},_.unique=function(e){for(var t,a=[],r={},s=0;s127&&i<2048?String.fromCharCode(i>>6|192,63&i|128):String.fromCharCode(i>>12|224,i>>6&63|128,63&i|128),null!==o&&(a>t&&(n+=e.substring(t,a)),n+=o,t=a=s+1)}return a>t&&(n+=e.substring(t,e.length)),n},_.base64Encode=function(e){var t,a,r,s,n,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,c=0,u="",p=[];if(!e)return e;e=_.utf8Encode(e);do{t=(n=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,a=n>>12&63,r=n>>6&63,s=63&n,p[c++]=i.charAt(t)+i.charAt(a)+i.charAt(r)+i.charAt(s)}while(o255||(r=e.charCodeAt(o++))>255||(s=e.charCodeAt(o++))>255)&&logger.info("Failed to execute 'btoa' : The string to be encoded contains characters outside of the Latin1 range."),i+=n.charAt((t=a<<16|r<<8|s)>>18&63)+n.charAt(t>>12&63)+n.charAt(t>>6&63)+n.charAt(63&t);return c?i.slice(0,c-3)+"===".substring(c):i},_.urlBase64Encode=function(e){return _.btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))},_.rot13obfs=function(e,t){t="number"==typeof t?t:13;for(var a=(e=String(e)).split(""),r=0,s=a.length;r(new Date).getTime()},_.getCurrentUrl=function(e){var t=_.getCurrentPath(),a="";return _.isObject(e)&&e.sensors_mp_encode_url_query&&(a=e.sensors_mp_encode_url_query),t?a?t+"?"+a:t:"\u672a\u53d6\u5230"},_.getPath=function(e){return e="string"==typeof e?e.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"},_.getMethods=function(e){var t=[];for(var a in e)"function"!=typeof e[a]||mpHook[a]||t.push(a);return t},_.isClick=function(e){return!!{tap:1,longpress:1,longtap:1}[e]},sa.initialState={queue:[],isComplete:!1,systemIsComplete:!1,storeIsComplete:!1,checkIsComplete:function(){this.systemIsComplete&&this.storeIsComplete&&(this.isComplete=!0,this.queue.length>0&&(_.each(this.queue,function(e){sa[e[0]].apply(sa,slice.call(e[1]))}),this.queue=[]))}},_.getCustomUtmFromQuery=function(e,t,a,r){if(!_.isObject(e))return{};var s={};if(e.sa_utm)for(var n in e)"sa_utm"!==n?_.include(sa.para.source_channel,n)&&(s[a+n]=e[n]):s[r+n]=e[n];else for(var n in e)-1===(" "+source_channel_standard+" ").indexOf(" "+n+" ")?_.include(sa.para.source_channel,n)&&(s[a+n]=e[n]):s[t+n]=e[n];return s},_.getObjFromQuery=function(e){var t=e.split("?"),a=[],r={};return t&&t[1]?(_.each(t[1].split("&"),function(e){(a=e.split("="))[0]&&a[1]&&(r[a[0]]=a[1])}),r):{}},_.setStorageSync=function(e,t){var a=function(){wx.setStorageSync(e,t)};try{a()}catch(e){logger.info("set Storage fail --",e);try{a()}catch(e){logger.info("set Storage fail again --",e)}}},_.getStorageSync=function(e){var t="";try{t=wx.getStorageSync(e)}catch(a){try{t=wx.getStorageSync(e)}catch(e){logger.info("getStorage fail")}}return t},_.getMPScene=function(e){return"number"==typeof e||"string"==typeof e&&""!==e?e="wx-"+String(e):"\u672a\u53d6\u5230\u503c"},_.setShareInfo=function(e,t){var a={},r={},s=sa.store.getDistinctId(),n=sa.store.getFirstId();if(!(e&&_.isObject(e.query)&&e.query.sampshare))return{};if(a=_.decodeURIComponent(e.query.sampshare),!_.isJSONString(a))return{};var i=(a=JSON.parse(a)).d,o=a.p,c=a.i,u=a.m;"string"==typeof c?(t.$share_distinct_id=c,share_distinct_id=c,r.$latest_share_distinct_id=c):t.$share_distinct_id="\u53d6\u503c\u5f02\u5e38","number"==typeof i?!share_distinct_id||share_distinct_id!==s&&share_distinct_id!==n?!share_distinct_id||share_distinct_id===s&&share_distinct_id===n?t.$share_depth="-1":(t.$share_depth=i+1,query_share_depth=i+1,r.$latest_share_depth=i+1):(t.$share_depth=i,query_share_depth=i,r.$latest_share_depth=i):t.$share_depth="-1","string"==typeof o?(t.$share_url_path=o,r.$latest_share_url_path=o):t.$share_url_path="\u53d6\u503c\u5f02\u5e38","string"==typeof u?(t.$share_method=u,r.$latest_share_method=u):t.$share_method="\u53d6\u503c\u5f02\u5e38",_.setLatestShare(r)},_.getShareInfo=function(){return JSON.stringify({i:sa.store.getDistinctId()||"\u53d6\u503c\u5f02\u5e38",p:_.getCurrentPath(),d:query_share_depth,m:share_method})},_.detectOptionQuery=function(e){if(!e||!_.isObject(e.query))return{};var t,a,r,s,n={};return n.query=_.extend({},e.query),"string"==typeof n.query.scene&&(t=n.query,a=["utm_source","utm_content","utm_medium","utm_campaign","utm_term","sa_utm"].concat(sa.para.source_channel),r=new RegExp("("+a.join("|")+")%3D","i"),1===(s=Object.keys(t)).length&&"scene"===s[0]&&r.test(t.scene))&&(n.scene=n.query.scene,delete n.query.scene),e.query.q&&e.query.scancode_time&&"101"===String(e.scene).slice(0,3)&&(n.q=String(n.query.q),delete n.query.q,delete n.query.scancode_time),n},_.getMixedQuery=function(e){var t=_.detectOptionQuery(e),a=t.scene,r=t.q,s=t.query;for(var n in s)s[n]=_.decodeURIComponent(s[n]);return a&&(a=-1!==(a=_.decodeURIComponent(a)).indexOf("?")?"?"+a.replace(/\?/g,""):"?"+a,_.extend(s,_.getObjFromQuery(a))),r&&_.extend(s,_.getObjFromQuery(_.decodeURIComponent(r))),s},_.setUtm=function(e,t){var a={},r=_.getMixedQuery(e),s=_.getCustomUtmFromQuery(r,"$","_","$"),n=_.getCustomUtmFromQuery(r,"$latest_","_latest_","$latest_");return a.pre1=s,a.pre2=n,_.extend(t,s),a},_.setSfSource=function(e,t){!_.isEmptyObject(e.query)&&e.query._sfs&&(t.$sf_source=e.query._sfs,sa.registerApp({$latest_sf_source:t.$sf_source}))},_.setPageSfSource=function(e){try{var t=getCurrentPages(),a=JSON.parse(JSON.stringify(t[t.length-1].options));for(var r in a)a[r]=_.decodeURIComponent(a[r]);!_.isEmptyObject(a)&&a._sfs&&(e.$sf_source=a._sfs)}catch(e){logger.info(e)}};try{var oldSetNavigationBarTitle=wx.setNavigationBarTitle;Object.defineProperty(wx,"setNavigationBarTitle",{get:function(){return function(e){var t=getCurrentPages(),a=t[t.length-1].route||"";e=_.isObject(e)?e:{},globalTitle[a]=e.title,oldSetNavigationBarTitle.call(this,e)}}})}catch(e){logger.info(e)}function mp_proxy(e,t,a){var r=sa.autoTrackCustom[a];if(e[t]){var s=e[t];e[t]=function(){"onLaunch"===t&&(this[sa.para.name]=sa),!sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&!sa.para.autoTrackIsFirst[a]?(s.apply(this,arguments),r.apply(this,arguments)):(!0===sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&sa.para.autoTrackIsFirst[a])&&(r.apply(this,arguments),s.apply(this,arguments))}}else e[t]=function(){"onLaunch"===t&&(this[sa.para.name]=sa),r.apply(this,arguments)}}function clickTrack(e){var t,a={},r={},s=e.currentTarget||{},n=e.target||{};if(_.isObject(sa.para.framework)&&_.isObject(sa.para.framework.taro)&&!sa.para.framework.taro.createApp&&n.id&&s.id&&n.id!==s.id)return!1;var i=s.dataset||{};if(t=e.type,a.$element_id=s.id,a.$element_type=i.type,a.$element_content=i.content,a.$element_name=i.name,_.isObject(e.event_prop)&&(r=e.event_prop),t&&_.isClick(t)){if(sa.para.preset_events&&sa.para.preset_events.collect_element&&!1===sa.para.preset_events.collect_element(arguments[0]))return!1;a.$url_path=_.getCurrentPath(),a=_.extend(a,r),sa.track("$MPClick",a)}}function click_proxy(e,t){var a=e[t];e[t]=function(){var e=a.apply(this,arguments),t=arguments[0];return _.isObject(t)&&(sa.para.preset_events.defer_track?setTimeout(function(){clickTrack(t)},0):clickTrack(t)),e}}function tabProxy(e){var t=e.onTabItemTap;e.onTabItemTap=function(e){t&&t.apply(this,arguments);var a={};e&&(a.$element_content=e.text),a.$element_type="tabBar",a.$url_path=_.getCurrentPath(),sa.track("$MPClick",a)}}_.getPageTitle=function(e){if("\u672a\u53d6\u5230"===e||!e)return!1;var t="";try{if(__wxConfig){var a=__wxConfig,r=a.page[e]||a.page[e+".html"],s={},n={};if(a.global&&a.global.window&&a.global.window.navigationBarTitleText&&(s.titleVal=a.global.window.navigationBarTitleText),r&&r.window&&r.window.navigationBarTitleText&&(n.titleVal=r.window.navigationBarTitleText),_.each(globalTitle,function(a,r){if(r===e)return t=a}),0===t.length){var i=_.extend(s,n);t=i.titleVal}}}catch(e){logger.info(e)}return t},_.wxrequest=function(e){if(_.compareSDKVersion(wxSDKVersion,"2.10.0")>=0)e.timeout=sa.para.datasend_timeout,wx.request(e);else{var t=wx.request(e);setTimeout(function(){_.isObject(t)&&_.isFunction(t.abort)&&t.abort()},sa.para.datasend_timeout)}},_.getAppId=function(){var e;if(wx.getAccountInfoSync&&(e=wx.getAccountInfoSync()),_.isObject(e)&&_.isObject(e.miniProgram))return e.miniProgram.appId},_.validId=function(e){return"string"!=typeof e&&"number"!=typeof e||""===e?(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1):"number"!=typeof e||(e=String(e),/^\d+$/.test(e))?e:(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1)},_.compareSDKVersion=function(e,t){e=e.split("."),t=t.split(".");for(var a=Math.max(e.length,t.length);e.lengthn)return 1;if(s-1?t.system.split(" ")[1]:t.system,wxSDKVersion=t.SDKVersion},complete:function(){var t=(new Date).getTimezoneOffset(),a=_.getAppId();_.isNumber(t)&&(e.$timezone_offset=t),a&&(e.$app_id=a),sa.initialState.systemIsComplete=!0,sa.initialState.checkIsComplete()}})}wx.getNetworkType({success:function(t){e.$network_type=_.setUpperCase(t.networkType)},complete:t})}},sa._=_,_.eventEmitter=function(){this.sub=[]},_.eventEmitter.prototype={add:function(e){this.sub.push(e)},emit:function(e,t){this.sub.forEach(function(a){a.on(e,t)})}},_.eventSub=function(e){sa.events.add(this),this._events=[],this.handle=e,this.ready=!1},_.eventSub.prototype={on:function(e,t){if(this.ready){if(_.isFunction(this.handle))try{this.handle(e,t)}catch(e){logger.info(e)}}else this._events.push({event:e,data:t})},isReady:function(){var e=this;e.ready=!0,e._events.forEach(function(t){if(_.isFunction(e.handle))try{e.handle(t.event,t.data)}catch(e){logger.info(e)}})}},sa.eventSub=_.eventSub,sa.events=new _.eventEmitter,sa.usePlugin=function(e,t){"function"==typeof e.init&&e.init(sa,t)},sa.prepareData=function(e,t){if(current_scene&&1154===current_scene&&!sa.para.preset_events.moments_page)return!1;var a={distinct_id:this.store.getDistinctId(),lib:{$lib:LIB_NAME,$lib_method:"code",$lib_version:String(LIB_VERSION)},properties:{}};_.extend(a,this.store.getUnionId(),e),_.isObject(e.properties)&&!_.isEmptyObject(e.properties)&&_.extend(a.properties,e.properties),e.type&&"profile"===e.type.slice(0,7)||(a._track_id=Number(String(Math.random()).slice(2,5)+String(Math.random()).slice(2,4)+String(Date.now()).slice(-4)),a.properties=_.extend({},_.info.properties,sa.store.getProps(),_.info.currentProps,a.properties),a.properties.$is_first_day=_.getIsFirstDay()),a.properties.$time&&_.isDate(a.properties.$time)?(a.time=1*a.properties.$time,delete a.properties.$time):a.time=1*new Date,_.parseSuperProperties(a.properties),_.searchObjDate(a),_.searchObjString(a),logger.info(a),sa.events.emit("send",a),sa.sendStrategy.send(a)},sa.store={storageInfo:null,getUUID:function(){return Date.now()+"-"+Math.floor(1e7*Math.random())+"-"+Math.random().toString(16).replace(".","")+"-"+String(31242*Math.random()).replace(".","").slice(0,8)},getStorage:function(){return this.storageInfo?this.storageInfo:(this.storageInfo=sa._.getStorageSync("sensorsdata2015_wechat")||"",this.storageInfo)},_state:{},mem:{mdata:[],getLength:function(){return this.mdata.length},add:function(e){this.mdata.push(e)},clear:function(e){this.mdata.splice(0,e)}},toState:function(e){var t=null;_.isJSONString(e)?(t=JSON.parse(e)).distinct_id?this._state=t:this.set("distinct_id",this.getUUID()):_.isObject(e)&&(t=e).distinct_id?this._state=t:this.set("distinct_id",this.getUUID())},getFirstId:function(){return this._state._first_id||this._state.first_id},getDistinctId:function(){return this._state._distinct_id||this._state.distinct_id},getUnionId:function(){var e={},t=this._state._first_id||this._state.first_id,a=this._state._distinct_id||this._state.distinct_id;return t&&a?(e.login_id=a,e.anonymous_id=t):e.anonymous_id=a,e},getProps:function(){return this._state.props||{}},setProps:function(e,t){var a=this._state.props||{};t?this.set("props",e):(_.extend(a,e),this.set("props",a))},set:function(e,t){var a={};for(var r in"string"==typeof e?a[e]=t:"object"==typeof e&&(a=e),this._state=this._state||{},a)this._state[r]=a[r],"first_id"===r?delete this._state._first_id:"distinct_id"===r&&(delete this._state._distinct_id,sa.events.emit("changeDistinctId"));this.save()},change:function(e,t){this._state["_"+e]=t},encryptStorage:function(){var e=this.getStorage(),t="data:enc;";_.isObject(e)?e=t+_.rot13obfs(JSON.stringify(e)):_.isString(e)&&-1===e.indexOf(t)&&(e=t+_.rot13obfs(e)),sa._.setStorageSync("sensorsdata2015_wechat",e)},save:function(){var e=JSON.parse(JSON.stringify(this._state));if(delete e._first_id,delete e._distinct_id,sa.para.encrypt_storage){e="data:enc;"+_.rot13obfs(JSON.stringify(e))}sa._.setStorageSync("sensorsdata2015_wechat",e)},init:function(){var e=this.getStorage();if(e)_.isString(e)&&-1!==e.indexOf("data:enc;")&&(e=e.substring("data:enc;".length),e=JSON.parse(_.rot13defs(e))),this.toState(e);else{is_first_launch=!0;var t=new Date,a=t.getTime();t.setHours(23),t.setMinutes(59),t.setSeconds(60),sa.setOnceProfile({$first_visit_time:new Date}),this.set({distinct_id:this.getUUID(),first_visit_time:a,first_visit_day_time:t.getTime()})}}},sa.setProfile=function(e,t){sa.prepareData({type:"profile_set",properties:e},t)},sa.setOnceProfile=function(e,t){sa.prepareData({type:"profile_set_once",properties:e},t)},sa.appendProfile=function(e,t){if(!_.isObject(e))return!1;_.each(e,function(t,a){_.isString(t)?e[a]=[t]:_.isArray(t)||(delete e[a],logger.info("appendProfile\u5c5e\u6027\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32\u6216\u8005\u6570\u7ec4"))}),sa.prepareData({type:"profile_append",properties:e},t)},sa.incrementProfile=function(e,t){if(!_.isObject(e))return!1;var a=e;_.isString(e)&&((e={})[a]=1),sa.prepareData({type:"profile_increment",properties:e},t)},sa.track=function(e,t,a){this.prepareData({type:"track",event:e,properties:t},a)},sa.identify=function(e,t){if(e=_.validId(e)){var a=sa.store.getFirstId();!0===t?a?sa.store.set("first_id",e):sa.store.set("distinct_id",e):a?sa.store.change("first_id",e):sa.store.change("distinct_id",e)}},sa.trackSignup=function(e,t,a,r){var s=sa.store.getFirstId()||sa.store.getDistinctId();sa.store.set("distinct_id",e),sa.prepareData({original_id:s,distinct_id:e,type:"track_signup",event:t,properties:a},r)},sa.registerApp=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&(_.info.currentProps=_.extend(_.info.currentProps,e))},sa.register=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&sa.store.setProps(e)},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.clearAllProps=function(e){var t=sa.store.getProps(),a={};_.isArray(e)&&(_.each(t,function(t,r){_.include(e,r)||(a[r]=t)}),sa.store.setProps(a,!0))},sa.clearAppRegister=function(e){_.isArray(e)&&_.each(_.info.currentProps,function(t,a){_.include(e,a)&&delete _.info.currentProps[a]})},_.setLatestChannel=function(e){_.isEmptyObject(e)||(function(e,t){var a=!1;for(var r in t)e[t[r]]&&(a=!0);return a}(e,latest_source_channel)&&(sa.clearAppRegister(latest_source_channel),sa.clearAllProps(latest_source_channel)),sa.para.is_persistent_save.utm?sa.register(e):sa.registerApp(e))},_.setLatestShare=function(e){(e.$latest_share_depth||e.$latest_share_distinct_id||e.$latest_share_url_path||e.$latest_share_method)&&(sa.clearAppRegister(latest_share_info),sa.clearAllProps(latest_share_info),sa.para.is_persistent_save.share?sa.register(e):sa.registerApp(e))},sa.login=function(e){if(e=_.validId(e)){var t=sa.store.getFirstId(),a=sa.store.getDistinctId();e!==a&&(t?sa.trackSignup(e,"$SignUp"):(sa.store.set("first_id",a),sa.trackSignup(e,"$SignUp")))}},sa.getAnonymousID=function(){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")},sa.logout=function(e){var t=sa.store.getFirstId();t?(sa.store.set("first_id",""),!0===e?sa.store.set("distinct_id",sa.store.getUUID()):sa.store.set("distinct_id",t)):logger.info("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25")},sa.getLocation=function(){wx.getSetting({success:function(e){if(!e.authSetting["scope.userLocation"])return!1;wx.getLocation({type:sa.para.preset_properties.location.type,success:function(e){sa.registerApp({$latitude:e.latitude*Math.pow(10,6),$longitude:e.longitude*Math.pow(10,6),$geo_coordinate_system:_.setUpperCase(sa.para.preset_properties.location.type)})},fail:function(e){console.log("\u83b7\u53d6\u4f4d\u7f6e\u5931\u8d25",e)}})}})},sa.openid={getRequest:function(e){wx.login({success:function(t){t.code&&sa.para.appid&&sa.para.openid_url?_.wxrequest({url:sa.para.openid_url+"&code="+t.code+"&appid="+sa.para.appid,method:"GET",complete:function(t){_.isObject(t)&&_.isObject(t.data)&&t.data.openid?e(t.data.openid):e()}}):e()}})},getWXStorage:function(){var e=sa.store.getStorage();if(e&&_.isObject(e))return e.openid},getOpenid:function(e){if(!sa.para.appid)return e(),!1;var t=this.getWXStorage();t?e(t):this.getRequest(e)}},sa.initial=function(){this._.info.getSystem(),this.store.init()},sa.init=function(e){if(!0===this.hasInit)return!1;this.hasInit=!0,sa.setPara(e),sa.para.encrypt_storage&&this.store.encryptStorage(),sa.para.batch_send&&(wx.getStorage({key:"sensors_mp_prepare_data",complete:function(e){var t=e.data&&_.isArray(e.data)?e.data:[];sa.store.mem.mdata=t.concat(sa.store.mem.mdata),sa.sendStrategy.syncStorage=!0}}),sa.sendStrategy.batchInterval()),sa.initialState.storeIsComplete=!0,sa.initialState.checkIsComplete()},sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib){var e={};_.each(_.info.currentProps,function(t,a){0===a.indexOf("$")&&(e[a]=t)});var t=_.extend(e,{$url_path:_.getCurrentPath(),$is_first_day:_.getIsFirstDay()},_.info.properties,sa.store.getProps());return delete t.$lib,t}return{}},_.autoExeQueue=function(){return{items:[],enqueue:function(e){this.items.push(e),this.start()},dequeue:function(){return this.items.shift()},getCurrentItem:function(){return this.items[0]},isRun:!1,start:function(){this.items.length>0&&!this.isRun&&(this.isRun=!0,this.getCurrentItem().start())},close:function(){this.dequeue(),this.isRun=!1,this.start()}}},sa.requestQueue=function(e){this.url=e.url},sa.requestQueue.prototype.isEnd=function(){this.received||(this.received=!0,this.close())},sa.requestQueue.prototype.start=function(){var e=this;_.wxrequest({url:this.url,method:"GET",complete:function(){e.isEnd()}})},sa.dataQueue=_.autoExeQueue(),sa.sendStrategy={dataHasSend:!0,dataHasChange:!1,syncStorage:!1,failTime:0,onAppHide:function(){sa.para.batch_send&&this.batchSend()},send:function(e){if(!sa.para.server_url)return!1;if(sa.para.batch_send){if(this.dataHasChange=!0,sa.store.mem.getLength()>=300)return logger.info("\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38"),!1;sa.store.mem.add(e),sa.store.mem.getLength()>=sa.para.batch_send.max_length&&this.batchSend()}else this.queueSend(e)},queueSend:function(e){e._flush_time=Date.now(),e=JSON.stringify(e),e=-1!==sa.para.server_url.indexOf("?")?sa.para.server_url+"&data="+encodeURIComponent(_.base64Encode(e)):sa.para.server_url+"?data="+encodeURIComponent(_.base64Encode(e));var t=new sa.requestQueue({url:e});t.close=function(){sa.dataQueue.close()},sa.dataQueue.enqueue(t)},wxrequest:function(e){if(_.isArray(e.data)&&e.data.length>0){var t=Date.now();e.data.forEach(function(e){e._flush_time=t}),e.data=JSON.stringify(e.data),_.wxrequest({url:sa.para.server_url,method:"POST",dataType:"text",data:"data_list="+encodeURIComponent(_.base64Encode(e.data)),success:function(){e.success(e.len)},fail:function(){e.fail()}})}else e.success(e.len)},batchSend:function(){if(this.dataHasSend){var e=sa.store.mem.mdata,t=e.length;t>0&&(this.dataHasSend=!1,this.wxrequest({data:e,len:t,success:this.batchRemove.bind(this),fail:this.sendFail.bind(this)}))}},sendFail:function(){this.dataHasSend=!0,this.failTime++},batchRemove:function(e){sa.store.mem.clear(e),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite(),this.failTime=0},is_first_batch_write:!0,batchWrite:function(){var e=this;this.dataHasChange&&(this.is_first_batch_write&&(this.is_first_batch_write=!1,setTimeout(function(){e.batchSend()},1e3)),this.dataHasChange=!1,this.syncStorage&&sa._.setStorageSync("sensors_mp_prepare_data",sa.store.mem.mdata))},batchInterval:function(){var e=this;!function t(){setTimeout(function(){e.batchWrite(),t()},500)}(),function t(){setTimeout(function(){e.batchSend(),t()},sa.para.batch_send.send_timeout*Math.pow(2,e.failTime))}()}},sa.setOpenid=function(e,t){sa.store.set("openid",e),t?sa.store.set("distinct_id",e):sa.identify(e,!0)},sa.initWithOpenid=function(e,t){(e=e||{}).appid&&(sa.para.appid=e.appid),sa.openid.getOpenid(function(a){a&&sa.setOpenid(a,e.isCoverLogin),t&&_.isFunction(t)&&t(a),sa.init(e)})},sa.setWebViewUrl=function(e,t){if(!_.isString(e)||""===e)return logger.info("error:\u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;e=decodeURIComponent(e);var a,r=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e),s=r[1]||"",n=r[2]||"",i=r[3]||"",o="",c=sa.store.getDistinctId()||"",u=sa.store.getFirstId()||"";_.urlSafeBase64&&_.urlSafeBase64.encode?c=c?_.urlSafeBase64.trim(_.urlSafeBase64.encode(_.urlBase64Encode(c))):"":this._.rot13obfs&&(c=c?_.rot13obfs(c):""),c=encodeURIComponent(c);var p=u?"f"+c:"d"+c;t?(a=i.indexOf("_sasdk"),o=i.indexOf("?")>-1?a>-1?s+n+"#"+i.substring(1,a)+"_sasdk="+p:s+n+"#"+i.substring(1)+"&_sasdk="+p:s+n+"#"+i.substring(1)+"?_sasdk="+p):(a=n.indexOf("_sasdk"),o=/^\?(\w)+/.test(n)?a>-1?s+"?"+n.substring(1,a)+"_sasdk="+p+i:s+"?"+n.substring(1)+"&_sasdk="+p+i:s+"?"+n.substring(1)+"_sasdk="+p+i);return o},_.each(["setProfile","setOnceProfile","track","quick","incrementProfile","appendProfile","login","logout","registerApp","register","clearAllRegister","clearAllProps","clearAppRegister"],function(e){var t=sa[e];sa[e]=function(){sa.initialState.isComplete?t.apply(sa,arguments):sa.initialState.queue.push([e,arguments])}}),_.setQuery=function(e,t){if(e&&_.isObject(e)&&!_.isEmptyObject(e)){var a=[];return _.each(e,function(e,r){"q"===r&&_.isString(e)&&0===e.indexOf("http")||(t?a.push(r+"="+e):a.push(r+"="+_.decodeURIComponent(e)))}),a.join("&")}return""},_.getUtmFromPage=function(){var e={};try{var t=getCurrentPages(),a=JSON.parse(JSON.stringify(t[t.length-1].options));for(var r in a)a[r]=_.decodeURIComponent(a[r]);e=_.getCustomUtmFromQuery(a,"$","_","$")}catch(e){logger.info(e)}return e},sa.autoTrackCustom={trackCustom:function(e,t,a){var r=sa.para.autoTrack[e],s="";sa.para.autoTrack&&r&&("function"==typeof r?(s=r(),_.isObject(s)&&_.extend(t,s)):_.isObject(r)&&(_.extend(t,r),sa.para.autoTrack[e]=!0),sa.track(a,t))},appLaunch:function(e,t){"object"!=typeof this||this.trackCustom||(this[sa.para.name]=sa);var a={};e&&e.scene?(current_scene=e.scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(a.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),_.setShareInfo(e,a);var r=_.setUtm(e,a);is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):a.$is_first_time=!1,_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),t?(a=_.extend(a,t),sa.track("$MPLaunch",a)):sa.para.autoTrack&&sa.para.autoTrack.appLaunch&&sa.autoTrackCustom.trackCustom("appLaunch",a,"$MPLaunch")},appShow:function(e,t){var a={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(a.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,a);var r=_.setUtm(e,a);_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),t?(a=_.extend(a,t),sa.track("$MPShow",a)):sa.para.autoTrack&&sa.para.autoTrack.appShow&&sa.autoTrackCustom.trackCustom("appShow",a,"$MPShow")},appHide:function(e){var t=(new Date).getTime(),a={};a.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(a.event_duration=(t-mpshow_time)/1e3),e?(a=_.extend(a,e),sa.track("$MPHide",a)):sa.para.autoTrack&&sa.para.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",a,"$MPHide"),sa.sendStrategy.onAppHide()},pageLoad:function(e){current_scene&&1010===current_scene&&e&&e.sampshare&&delete e.sampshare,e&&_.isObject(e)&&(this.sensors_mp_url_query=_.setQuery(e),this.sensors_mp_encode_url_query=_.setQuery(e,!0))},pageShow:function(){var e={},t=_.getCurrentPath(),a=_.getPageTitle(t);e.$referrer=sa_referrer,e.$url_path=t,sa.status.last_referrer=sa_referrer,e.$url_query=this.sensors_mp_url_query?this.sensors_mp_url_query:"",e=_.extend(e,_.getUtmFromPage()),_.setPageSfSource(e),a&&(e.$title=a),sa.para.onshow?sa.para.onshow(sa,t,this):_.isObject(sa.para.autotrack_exclude_page)&&_.isArray(sa.para.autotrack_exclude_page.pageShow)&&-1!==sa.para.autotrack_exclude_page.pageShow.indexOf(t)||sa.autoTrackCustom.trackCustom("pageShow",e,"$MPViewScreen"),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:t}),sa_referrer=t,sa.status.referrer=t},pageShare:function(e){var t=e.onShareAppMessage;e.onShareAppMessage=function(){share_method="\u8f6c\u53d1\u6d88\u606f\u5361\u7247";var e=t.apply(this,arguments);return sa.para.autoTrack&&sa.para.autoTrack.pageShare&&sa.autoTrackCustom.trackCustom("pageShare",{$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method},"$MPShare"),sa.para.allow_amend_share_path&&("object"!=typeof e&&((e={}).path=_.getCurrentUrl(this)),"object"!=typeof e||void 0!==e.path&&""!==e.path||(e.path=_.getCurrentUrl(this)),"object"==typeof e&&"string"==typeof e.path&&(-1===e.path.indexOf("?")?e.path=e.path+"?":"&"!==e.path.slice(-1)&&(e.path=e.path+"&")),e.path=e.path+"sampshare="+encodeURIComponent(_.getShareInfo())),e}},pageShareTimeline:function(e){var t=e.onShareTimeline;e.onShareTimeline=function(){share_method="\u670b\u53cb\u5708\u5206\u4eab";var e=t.apply(this,arguments);return sa.para.autoTrack&&sa.para.autoTrack.pageShare&&sa.autoTrackCustom.trackCustom("pageShare",{$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method},"$MPShare"),sa.para.allow_amend_share_path&&("object"!=typeof e&&(e={}),"object"==typeof e&&void 0===e.query&&(e.query=""),"object"==typeof e&&"string"==typeof e.query&&""!==e.query&&"&"!==e.query.slice(-1)&&(e.query=e.query+"&"),e.query=e.query+"sampshare="+encodeURIComponent(_.getShareInfo())),e}},pageAddFavorites:function(){var e={};e.$url_path=_.getCurrentPath(),sa.para.autoTrack&&sa.para.autoTrack.mpFavorite&&sa.autoTrackCustom.trackCustom("mpFavorite",e,"$MPAddFavorites")}},sa.quick=function(){var e=arguments[0],t=arguments[1],a=arguments[2],r=_.isObject(a)?a:{};if("getAnonymousID"===e){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===e||"appShow"===e?t?sa.autoTrackCustom[e](t,r):logger.info("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(r=_.isObject(t)?t:{},sa.autoTrackCustom[e](r))},sa.appLaunch=function(e,t){var a={};e&&e.scene?(current_scene=e.scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(a.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),_.setShareInfo(e,a);var r=_.setUtm(e,a);is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):a.$is_first_time=!1,_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),_.isObject(t)&&(a=_.extend(a,t)),sa.track("$MPLaunch",a)},sa.appShow=function(e,t){var a={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(a.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,a);var r=_.setUtm(e,a);_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),_.isObject(t)&&(a=_.extend(a,t)),sa.track("$MPShow",a)},sa.appHide=function(e){var t=(new Date).getTime(),a={};a.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(a.event_duration=(t-mpshow_time)/1e3),_.isObject(e)&&(a=_.extend(a,e)),sa.track("$MPHide",a),sa.sendStrategy.onAppHide()},sa.pageShow=function(e){var t={},a=_.getCurrentPath(),r=_.getPageTitle(a),s={};try{var n=getCurrentPages();s=n[n.length-1]}catch(e){logger.info(e)}!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a}),r&&(t.$title=r),t.$referrer=sa_referrer,t.$url_path=a,sa.status.last_referrer=sa_referrer,t.$url_query=s.sensors_mp_url_query?s.sensors_mp_url_query:"",t=_.extend(t,_.getUtmFromPage()),_.setPageSfSource(t),_.isObject(e)&&(t=_.extend(t,e)),sa.track("$MPViewScreen",t),sa_referrer=a,sa.status.referrer=a},sa.App=function(e){(e=e||{})[sa.para.name]=sa,App.apply(this,arguments)},wx.onAppShow(function(e){if(!sa.para.launched){var t=wx.getLaunchOptionsSync()||{};sa.autoTrackCustom.appLaunch(t),sa.para.launched=!0}sa.autoTrackCustom.appShow(e)}),wx.onAppHide(function(){sa.autoTrackCustom.appHide()}),sa.Page=function(e){var t=sa.para.autoTrack&&sa.para.autoTrack.mpClick&&_.getMethods(e);if(t)for(var a=0,r=t.length;asa.para.max_string_length?(logger.info("\u5b57\u7b26\u4e32\u957f\u5ea6\u8d85\u8fc7\u9650\u5236\uff0c\u5df2\u7ecf\u505a\u622a\u53d6--"+e),e.slice(0,sa.para.max_string_length)):e},_.searchObjString=function(e){_.isObject(e)&&_.each(e,function(t,a){_.isObject(t)?_.searchObjString(e[a]):_.isString(t)&&(e[a]=_.formatString(t))})},_.parseSuperProperties=function(e){_.isObject(e)&&(_.each(e,function(t,a){if(_.isFunction(t))try{e[a]=t(),_.isFunction(e[a])&&(logger.info("\u60a8\u7684\u5c5e\u6027- "+a+" \u683c\u5f0f\u4e0d\u6ee1\u8db3\u8981\u6c42\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664"),delete e[a])}catch(t){delete e[a],logger.info("\u60a8\u7684\u5c5e\u6027- "+a+" \u629b\u51fa\u4e86\u5f02\u5e38\uff0c\u6211\u4eec\u5df2\u7ecf\u5c06\u5176\u5220\u9664")}}),_.strip_sa_properties(e))},_.unique=function(e){for(var t,a=[],r={},s=0;s127&&i<2048?String.fromCharCode(i>>6|192,63&i|128):String.fromCharCode(i>>12|224,i>>6&63|128,63&i|128),null!==o&&(a>t&&(n+=e.substring(t,a)),n+=o,t=a=s+1)}return a>t&&(n+=e.substring(t,e.length)),n},_.base64Encode=function(e){var t,a,r,s,n,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,c=0,u="",p=[];if(!e)return e;e=_.utf8Encode(e);do{t=(n=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,a=n>>12&63,r=n>>6&63,s=63&n,p[c++]=i.charAt(t)+i.charAt(a)+i.charAt(r)+i.charAt(s)}while(o255||(r=e.charCodeAt(o++))>255||(s=e.charCodeAt(o++))>255)&&logger.info("Failed to execute 'btoa' : The string to be encoded contains characters outside of the Latin1 range."),i+=n.charAt((t=a<<16|r<<8|s)>>18&63)+n.charAt(t>>12&63)+n.charAt(t>>6&63)+n.charAt(63&t);return c?i.slice(0,c-3)+"===".substring(c):i},_.urlBase64Encode=function(e){return _.btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(e,t){return String.fromCharCode("0x"+t)}))},_.rot13obfs=function(e,t){t="number"==typeof t?t:13;for(var a=(e=String(e)).split(""),r=0,s=a.length;r(new Date).getTime()},_.getCurrentUrl=function(e){var t=_.getCurrentPath(),a="";return _.isObject(e)&&e.sensors_mp_encode_url_query&&(a=e.sensors_mp_encode_url_query),t?a?t+"?"+a:t:"\u672a\u53d6\u5230"},_.getPath=function(e){return e="string"==typeof e?e.replace(/^\//,""):"\u53d6\u503c\u5f02\u5e38"},_.getMethods=function(e){var t=[];for(var a in e)"function"!=typeof e[a]||mpHook[a]||t.push(a);return t},_.isClick=function(e){return!!{tap:1,longpress:1,longtap:1}[e]},sa.initialState={queue:[],isComplete:!1,systemIsComplete:!1,storeIsComplete:!1,checkIsComplete:function(){this.systemIsComplete&&this.storeIsComplete&&(this.isComplete=!0,this.queue.length>0&&(_.each(this.queue,function(e){sa[e[0]].apply(sa,slice.call(e[1]))}),this.queue=[]))}},_.getCustomUtmFromQuery=function(e,t,a,r){if(!_.isObject(e))return{};var s={};if(e.sa_utm)for(var n in e)"sa_utm"!==n?_.include(sa.para.source_channel,n)&&(s[a+n]=e[n]):s[r+n]=e[n];else for(var n in e)-1===(" "+source_channel_standard+" ").indexOf(" "+n+" ")?_.include(sa.para.source_channel,n)&&(s[a+n]=e[n]):s[t+n]=e[n];return s},_.getObjFromQuery=function(e){var t=e.split("?"),a=[],r={};return t&&t[1]?(_.each(t[1].split("&"),function(e){(a=e.split("="))[0]&&a[1]&&(r[a[0]]=a[1])}),r):{}},_.setStorageSync=function(e,t){var a=function(){wx.setStorageSync(e,t)};try{a()}catch(e){logger.info("set Storage fail --",e);try{a()}catch(e){logger.info("set Storage fail again --",e)}}},_.getStorageSync=function(e){var t="";try{t=wx.getStorageSync(e)}catch(a){try{t=wx.getStorageSync(e)}catch(e){logger.info("getStorage fail")}}return t},_.getMPScene=function(e){return"number"==typeof e||"string"==typeof e&&""!==e?e="wx-"+String(e):"\u672a\u53d6\u5230\u503c"},_.setShareInfo=function(e,t){var a={},r={},s=sa.store.getDistinctId(),n=sa.store.getFirstId();if(!(e&&_.isObject(e.query)&&e.query.sampshare))return{};if(a=_.decodeURIComponent(e.query.sampshare),!_.isJSONString(a))return{};var i=(a=JSON.parse(a)).d,o=a.p,c=a.i,u=a.m;"string"==typeof c?(t.$share_distinct_id=c,share_distinct_id=c,r.$latest_share_distinct_id=c):t.$share_distinct_id="\u53d6\u503c\u5f02\u5e38","number"==typeof i?!share_distinct_id||share_distinct_id!==s&&share_distinct_id!==n?!share_distinct_id||share_distinct_id===s&&share_distinct_id===n?t.$share_depth="-1":(t.$share_depth=i+1,query_share_depth=i+1,r.$latest_share_depth=i+1):(t.$share_depth=i,query_share_depth=i,r.$latest_share_depth=i):t.$share_depth="-1","string"==typeof o?(t.$share_url_path=o,r.$latest_share_url_path=o):t.$share_url_path="\u53d6\u503c\u5f02\u5e38","string"==typeof u?(t.$share_method=u,r.$latest_share_method=u):t.$share_method="\u53d6\u503c\u5f02\u5e38",_.setLatestShare(r)},_.getShareInfo=function(){return JSON.stringify({i:sa.store.getDistinctId()||"\u53d6\u503c\u5f02\u5e38",p:_.getCurrentPath(),d:query_share_depth,m:share_method})},_.detectOptionQuery=function(e){if(!e||!_.isObject(e.query))return{};var t,a,r,s,n={};return n.query=_.extend({},e.query),"string"==typeof n.query.scene&&(t=n.query,a=["utm_source","utm_content","utm_medium","utm_campaign","utm_term","sa_utm"].concat(sa.para.source_channel),r=new RegExp("("+a.join("|")+")%3D","i"),1===(s=Object.keys(t)).length&&"scene"===s[0]&&r.test(t.scene))&&(n.scene=n.query.scene,delete n.query.scene),e.query.q&&e.query.scancode_time&&"101"===String(e.scene).slice(0,3)&&(n.q=String(n.query.q),delete n.query.q,delete n.query.scancode_time),n},_.getMixedQuery=function(e){var t=_.detectOptionQuery(e),a=t.scene,r=t.q,s=t.query;for(var n in s)s[n]=_.decodeURIComponent(s[n]);return a&&(a=-1!==(a=_.decodeURIComponent(a)).indexOf("?")?"?"+a.replace(/\?/g,""):"?"+a,_.extend(s,_.getObjFromQuery(a))),r&&_.extend(s,_.getObjFromQuery(_.decodeURIComponent(r))),s},_.setUtm=function(e,t){var a={},r=_.getMixedQuery(e),s=_.getCustomUtmFromQuery(r,"$","_","$"),n=_.getCustomUtmFromQuery(r,"$latest_","_latest_","$latest_");return a.pre1=s,a.pre2=n,_.extend(t,s),a},_.setSfSource=function(e,t){!_.isEmptyObject(e.query)&&e.query._sfs&&(t.$sf_source=e.query._sfs,sa.registerApp({$latest_sf_source:t.$sf_source}))},_.setPageSfSource=function(e){try{var t=getCurrentPages(),a=JSON.parse(JSON.stringify(t[t.length-1].options));for(var r in a)a[r]=_.decodeURIComponent(a[r]);!_.isEmptyObject(a)&&a._sfs&&(e.$sf_source=a._sfs)}catch(e){logger.info(e)}};try{var oldSetNavigationBarTitle=wx.setNavigationBarTitle;Object.defineProperty(wx,"setNavigationBarTitle",{get:function(){return function(e){var t=getCurrentPages(),a=t[t.length-1].route||"";e=_.isObject(e)?e:{},globalTitle[a]=e.title,oldSetNavigationBarTitle.call(this,e)}}})}catch(e){logger.info(e)}function mp_proxy(e,t,a){var r=sa.autoTrackCustom[a];if(e[t]){var s=e[t];e[t]=function(){"onLaunch"===t&&(this[sa.para.name]=sa),!sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&!sa.para.autoTrackIsFirst[a]?(s.apply(this,arguments),r.apply(this,arguments)):(!0===sa.para.autoTrackIsFirst||_.isObject(sa.para.autoTrackIsFirst)&&sa.para.autoTrackIsFirst[a])&&(r.apply(this,arguments),s.apply(this,arguments))}}else e[t]=function(){"onLaunch"===t&&(this[sa.para.name]=sa),r.apply(this,arguments)}}function clickTrack(e){var t,a={},r={},s=e.currentTarget||{},n=e.target||{};if(_.isObject(sa.para.framework)&&_.isObject(sa.para.framework.taro)&&!sa.para.framework.taro.createApp&&n.id&&s.id&&n.id!==s.id)return!1;var i=s.dataset||{};if(t=e.type,a.$element_id=s.id,a.$element_type=i.type,a.$element_content=i.content,a.$element_name=i.name,_.isObject(e.event_prop)&&(r=e.event_prop),t&&_.isClick(t)){if(sa.para.preset_events&&sa.para.preset_events.collect_element&&!1===sa.para.preset_events.collect_element(arguments[0]))return!1;a.$url_path=_.getCurrentPath(),a=_.extend(a,r),sa.track("$MPClick",a)}}function click_proxy(e,t){var a=e[t];e[t]=function(){var e=a.apply(this,arguments),t=arguments[0];return _.isObject(t)&&(sa.para.preset_events.defer_track?setTimeout(function(){clickTrack(t)},0):clickTrack(t)),e}}function tabProxy(e){var t=e.onTabItemTap;e.onTabItemTap=function(e){t&&t.apply(this,arguments);var a={};e&&(a.$element_content=e.text),a.$element_type="tabBar",a.$url_path=_.getCurrentPath(),sa.track("$MPClick",a)}}_.getPageTitle=function(e){if("\u672a\u53d6\u5230"===e||!e)return!1;var t="";try{if(__wxConfig){var a=__wxConfig,r=a.page[e]||a.page[e+".html"],s={},n={};if(a.global&&a.global.window&&a.global.window.navigationBarTitleText&&(s.titleVal=a.global.window.navigationBarTitleText),r&&r.window&&r.window.navigationBarTitleText&&(n.titleVal=r.window.navigationBarTitleText),_.each(globalTitle,function(a,r){if(r===e)return t=a}),0===t.length){var i=_.extend(s,n);t=i.titleVal}}}catch(e){logger.info(e)}return t},_.wxrequest=function(e){if(_.compareSDKVersion(wxSDKVersion,"2.10.0")>=0)e.timeout=sa.para.datasend_timeout,wx.request(e);else{var t=wx.request(e);setTimeout(function(){_.isObject(t)&&_.isFunction(t.abort)&&t.abort()},sa.para.datasend_timeout)}},_.getAppId=function(){var e;if(wx.getAccountInfoSync&&(e=wx.getAccountInfoSync()),_.isObject(e)&&_.isObject(e.miniProgram))return e.miniProgram.appId},_.validId=function(e){return"string"!=typeof e&&"number"!=typeof e||""===e?(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1):"number"!=typeof e||(e=String(e),/^\d+$/.test(e))?e:(logger.info("\u8f93\u5165 ID \u7c7b\u578b\u9519\u8bef"),!1)},_.compareSDKVersion=function(e,t){e=e.split("."),t=t.split(".");for(var a=Math.max(e.length,t.length);e.lengthn)return 1;if(s-1?t.system.split(" ")[1]:t.system,wxSDKVersion=t.SDKVersion},complete:function(){var t=(new Date).getTimezoneOffset(),a=_.getAppId();_.isNumber(t)&&(e.$timezone_offset=t),a&&(e.$app_id=a),sa.initialState.systemIsComplete=!0,sa.initialState.checkIsComplete()}})}wx.getNetworkType({success:function(t){e.$network_type=_.setUpperCase(t.networkType)},complete:t})}},sa._=_,_.eventEmitter=function(){this.sub=[]},_.eventEmitter.prototype={add:function(e){this.sub.push(e)},emit:function(e,t){this.sub.forEach(function(a){a.on(e,t)})}},_.eventSub=function(e){sa.events.add(this),this._events=[],this.handle=e,this.ready=!1},_.eventSub.prototype={on:function(e,t){if(this.ready){if(_.isFunction(this.handle))try{this.handle(e,t)}catch(e){logger.info(e)}}else this._events.push({event:e,data:t})},isReady:function(){var e=this;e.ready=!0,e._events.forEach(function(t){if(_.isFunction(e.handle))try{e.handle(t.event,t.data)}catch(e){logger.info(e)}})}},sa.eventSub=_.eventSub,sa.events=new _.eventEmitter,sa.usePlugin=function(e,t){"function"==typeof e.init&&e.init(sa,t)},sa.prepareData=function(e,t){if(current_scene&&1154===current_scene&&!sa.para.preset_events.moments_page)return!1;var a={distinct_id:this.store.getDistinctId(),lib:{$lib:LIB_NAME,$lib_method:"code",$lib_version:String(LIB_VERSION)},properties:{}};_.extend(a,this.store.getUnionId(),e),_.isObject(e.properties)&&!_.isEmptyObject(e.properties)&&_.extend(a.properties,e.properties),e.type&&"profile"===e.type.slice(0,7)||(a._track_id=Number(String(Math.random()).slice(2,5)+String(Math.random()).slice(2,4)+String(Date.now()).slice(-4)),a.properties=_.extend({},_.info.properties,sa.store.getProps(),_.info.currentProps,a.properties),a.properties.$is_first_day=_.getIsFirstDay()),a.properties.$time&&_.isDate(a.properties.$time)?(a.time=1*a.properties.$time,delete a.properties.$time):a.time=1*new Date,_.parseSuperProperties(a.properties),_.searchObjDate(a),_.searchObjString(a),logger.info(a),sa.events.emit("send",a),sa.sendStrategy.send(a)},sa.store={storageInfo:null,getUUID:function(){return Date.now()+"-"+Math.floor(1e7*Math.random())+"-"+Math.random().toString(16).replace(".","")+"-"+String(31242*Math.random()).replace(".","").slice(0,8)},getStorage:function(){return this.storageInfo?this.storageInfo:(this.storageInfo=sa._.getStorageSync("sensorsdata2015_wechat")||"",this.storageInfo)},_state:{},mem:{mdata:[],getLength:function(){return this.mdata.length},add:function(e){this.mdata.push(e)},clear:function(e){this.mdata.splice(0,e)}},toState:function(e){var t=null;_.isJSONString(e)?(t=JSON.parse(e)).distinct_id?this._state=t:this.set("distinct_id",this.getUUID()):_.isObject(e)&&(t=e).distinct_id?this._state=t:this.set("distinct_id",this.getUUID())},getFirstId:function(){return this._state._first_id||this._state.first_id},getDistinctId:function(){return this._state._distinct_id||this._state.distinct_id},getUnionId:function(){var e={},t=this._state._first_id||this._state.first_id,a=this._state._distinct_id||this._state.distinct_id;return t&&a?(e.login_id=a,e.anonymous_id=t):e.anonymous_id=a,e},getProps:function(){return this._state.props||{}},setProps:function(e,t){var a=this._state.props||{};t?this.set("props",e):(_.extend(a,e),this.set("props",a))},set:function(e,t){var a={};for(var r in"string"==typeof e?a[e]=t:"object"==typeof e&&(a=e),this._state=this._state||{},a)this._state[r]=a[r],"first_id"===r?delete this._state._first_id:"distinct_id"===r&&(delete this._state._distinct_id,sa.events.emit("changeDistinctId"));this.save()},change:function(e,t){this._state["_"+e]=t},encryptStorage:function(){var e=this.getStorage(),t="data:enc;";_.isObject(e)?e=t+_.rot13obfs(JSON.stringify(e)):_.isString(e)&&-1===e.indexOf(t)&&(e=t+_.rot13obfs(e)),sa._.setStorageSync("sensorsdata2015_wechat",e)},save:function(){var e=JSON.parse(JSON.stringify(this._state));if(delete e._first_id,delete e._distinct_id,sa.para.encrypt_storage){e="data:enc;"+_.rot13obfs(JSON.stringify(e))}sa._.setStorageSync("sensorsdata2015_wechat",e)},init:function(){var e=this.getStorage();if(e)_.isString(e)&&-1!==e.indexOf("data:enc;")&&(e=e.substring("data:enc;".length),e=JSON.parse(_.rot13defs(e))),this.toState(e);else{is_first_launch=!0;var t=new Date,a=t.getTime();t.setHours(23),t.setMinutes(59),t.setSeconds(60),sa.setOnceProfile({$first_visit_time:new Date}),this.set({distinct_id:this.getUUID(),first_visit_time:a,first_visit_day_time:t.getTime()})}}},sa.setProfile=function(e,t){sa.prepareData({type:"profile_set",properties:e},t)},sa.setOnceProfile=function(e,t){sa.prepareData({type:"profile_set_once",properties:e},t)},sa.appendProfile=function(e,t){if(!_.isObject(e))return!1;_.each(e,function(t,a){_.isString(t)?e[a]=[t]:_.isArray(t)||(delete e[a],logger.info("appendProfile\u5c5e\u6027\u7684\u503c\u5fc5\u987b\u662f\u5b57\u7b26\u4e32\u6216\u8005\u6570\u7ec4"))}),sa.prepareData({type:"profile_append",properties:e},t)},sa.incrementProfile=function(e,t){if(!_.isObject(e))return!1;var a=e;_.isString(e)&&((e={})[a]=1),sa.prepareData({type:"profile_increment",properties:e},t)},sa.track=function(e,t,a){this.prepareData({type:"track",event:e,properties:t},a)},sa.identify=function(e,t){if(e=_.validId(e)){var a=sa.store.getFirstId();!0===t?a?sa.store.set("first_id",e):sa.store.set("distinct_id",e):a?sa.store.change("first_id",e):sa.store.change("distinct_id",e)}},sa.trackSignup=function(e,t,a,r){var s=sa.store.getFirstId()||sa.store.getDistinctId();sa.store.set("distinct_id",e),sa.prepareData({original_id:s,distinct_id:e,type:"track_signup",event:t,properties:a},r)},sa.registerApp=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&(_.info.currentProps=_.extend(_.info.currentProps,e))},sa.register=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&sa.store.setProps(e)},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.clearAllProps=function(e){var t=sa.store.getProps(),a={};_.isArray(e)&&(_.each(t,function(t,r){_.include(e,r)||(a[r]=t)}),sa.store.setProps(a,!0))},sa.clearAppRegister=function(e){_.isArray(e)&&_.each(_.info.currentProps,function(t,a){_.include(e,a)&&delete _.info.currentProps[a]})},_.setLatestChannel=function(e){_.isEmptyObject(e)||(function(e,t){var a=!1;for(var r in t)e[t[r]]&&(a=!0);return a}(e,latest_source_channel)&&(sa.clearAppRegister(latest_source_channel),sa.clearAllProps(latest_source_channel)),sa.para.is_persistent_save.utm?sa.register(e):sa.registerApp(e))},_.setLatestShare=function(e){(e.$latest_share_depth||e.$latest_share_distinct_id||e.$latest_share_url_path||e.$latest_share_method)&&(sa.clearAppRegister(latest_share_info),sa.clearAllProps(latest_share_info),sa.para.is_persistent_save.share?sa.register(e):sa.registerApp(e))},sa.login=function(e){if(e=_.validId(e)){var t=sa.store.getFirstId(),a=sa.store.getDistinctId();e!==a&&(t?sa.trackSignup(e,"$SignUp"):(sa.store.set("first_id",a),sa.trackSignup(e,"$SignUp")))}},sa.getAnonymousID=function(){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")},sa.logout=function(e){var t=sa.store.getFirstId();t?(sa.store.set("first_id",""),!0===e?sa.store.set("distinct_id",sa.store.getUUID()):sa.store.set("distinct_id",t)):logger.info("\u6ca1\u6709first_id\uff0clogout\u5931\u8d25")},sa.getLocation=function(){wx.getSetting({success:function(e){if(!e.authSetting["scope.userLocation"])return!1;wx.getLocation({type:sa.para.preset_properties.location.type,success:function(e){sa.registerApp({$latitude:e.latitude*Math.pow(10,6),$longitude:e.longitude*Math.pow(10,6),$geo_coordinate_system:_.setUpperCase(sa.para.preset_properties.location.type)})},fail:function(e){console.log("\u83b7\u53d6\u4f4d\u7f6e\u5931\u8d25",e)}})}})},sa.openid={getRequest:function(e){wx.login({success:function(t){t.code&&sa.para.appid&&sa.para.openid_url?_.wxrequest({url:sa.para.openid_url+"&code="+t.code+"&appid="+sa.para.appid,method:"GET",complete:function(t){_.isObject(t)&&_.isObject(t.data)&&t.data.openid?e(t.data.openid):e()}}):e()}})},getWXStorage:function(){var e=sa.store.getStorage();if(e&&_.isObject(e))return e.openid},getOpenid:function(e){if(!sa.para.appid)return e(),!1;var t=this.getWXStorage();t?e(t):this.getRequest(e)}},sa.initial=function(){this._.info.getSystem(),this.store.init()},sa.init=function(e){if(!0===this.hasInit)return!1;this.hasInit=!0,sa.setPara(e),sa.para.encrypt_storage&&this.store.encryptStorage(),sa.para.batch_send&&(wx.getStorage({key:"sensors_mp_prepare_data",complete:function(e){var t=e.data&&_.isArray(e.data)?e.data:[];sa.store.mem.mdata=t.concat(sa.store.mem.mdata),sa.sendStrategy.syncStorage=!0}}),sa.sendStrategy.batchInterval()),sa.initialState.storeIsComplete=!0,sa.initialState.checkIsComplete()},sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib){var e={};_.each(_.info.currentProps,function(t,a){0===a.indexOf("$")&&(e[a]=t)});var t=_.extend(e,{$url_path:_.getCurrentPath(),$is_first_day:_.getIsFirstDay()},_.info.properties,sa.store.getProps());return delete t.$lib,t}return{}},_.autoExeQueue=function(){return{items:[],enqueue:function(e){this.items.push(e),this.start()},dequeue:function(){return this.items.shift()},getCurrentItem:function(){return this.items[0]},isRun:!1,start:function(){this.items.length>0&&!this.isRun&&(this.isRun=!0,this.getCurrentItem().start())},close:function(){this.dequeue(),this.isRun=!1,this.start()}}},sa.requestQueue=function(e){this.url=e.url},sa.requestQueue.prototype.isEnd=function(){this.received||(this.received=!0,this.close())},sa.requestQueue.prototype.start=function(){var e=this;_.wxrequest({url:this.url,method:"GET",complete:function(){e.isEnd()}})},sa.dataQueue=_.autoExeQueue(),sa.sendStrategy={dataHasSend:!0,dataHasChange:!1,syncStorage:!1,failTime:0,onAppHide:function(){sa.para.batch_send&&this.batchSend()},send:function(e){if(!sa.para.server_url)return!1;sa.para.batch_send?(this.dataHasChange=!0,sa.store.mem.getLength()>=500&&(logger.info("\u6570\u636e\u91cf\u5b58\u50a8\u8fc7\u5927\uff0c\u6709\u5f02\u5e38"),sa.store.mem.mdata.shift()),sa.store.mem.add(e),sa.store.mem.getLength()>=sa.para.batch_send.max_length&&this.batchSend()):this.queueSend(e)},queueSend:function(e){e._flush_time=Date.now(),e=JSON.stringify(e),e=-1!==sa.para.server_url.indexOf("?")?sa.para.server_url+"&data="+encodeURIComponent(_.base64Encode(e)):sa.para.server_url+"?data="+encodeURIComponent(_.base64Encode(e));var t=new sa.requestQueue({url:e});t.close=function(){sa.dataQueue.close()},sa.dataQueue.enqueue(t)},wxrequest:function(e){if(_.isArray(e.data)&&e.data.length>0){var t=Date.now();e.data.forEach(function(e){e._flush_time=t}),e.data=JSON.stringify(e.data),_.wxrequest({url:sa.para.server_url,method:"POST",dataType:"text",data:"data_list="+encodeURIComponent(_.base64Encode(e.data)),success:function(){e.success(e.len)},fail:function(){e.fail()}})}else e.success(e.len)},batchSend:function(){if(this.dataHasSend){var e,t,a=sa.store.mem.mdata;(t=(e=a.length>=100?a.slice(0,100):a).length)>0&&(this.dataHasSend=!1,this.wxrequest({data:e,len:t,success:this.batchRemove.bind(this),fail:this.sendFail.bind(this)}))}},sendFail:function(){this.dataHasSend=!0,this.failTime++},batchRemove:function(e){sa.store.mem.clear(e),this.dataHasSend=!0,this.dataHasChange=!0,this.batchWrite(),this.failTime=0},is_first_batch_write:!0,batchWrite:function(){var e=this;this.dataHasChange&&(this.is_first_batch_write&&(this.is_first_batch_write=!1,setTimeout(function(){e.batchSend()},1e3)),this.dataHasChange=!1,this.syncStorage&&sa._.setStorageSync("sensors_mp_prepare_data",sa.store.mem.mdata))},batchInterval:function(){var e=this;!function t(){setTimeout(function(){e.batchWrite(),t()},500)}(),function t(){setTimeout(function(){e.batchSend(),t()},sa.para.batch_send.send_timeout*Math.pow(2,e.failTime))}()}},sa.setOpenid=function(e,t){sa.store.set("openid",e),t?sa.store.set("distinct_id",e):sa.identify(e,!0)},sa.initWithOpenid=function(e,t){(e=e||{}).appid&&(sa.para.appid=e.appid),sa.openid.getOpenid(function(a){a&&sa.setOpenid(a,e.isCoverLogin),t&&_.isFunction(t)&&t(a),sa.init(e)})},sa.setWebViewUrl=function(e,t){if(!_.isString(e)||""===e)return logger.info("error:\u8bf7\u4f20\u5165\u6b63\u786e\u7684 URL \u683c\u5f0f"),!1;e=decodeURIComponent(e);var a,r=/([^?#]+)(\?[^#]*)?(#.*)?/.exec(e),s=r[1]||"",n=r[2]||"",i=r[3]||"",o="",c=sa.store.getDistinctId()||"",u=sa.store.getFirstId()||"";_.urlSafeBase64&&_.urlSafeBase64.encode?c=c?_.urlSafeBase64.trim(_.urlSafeBase64.encode(_.urlBase64Encode(c))):"":this._.rot13obfs&&(c=c?_.rot13obfs(c):""),c=encodeURIComponent(c);var p=u?"f"+c:"d"+c;t?(a=i.indexOf("_sasdk"),o=i.indexOf("?")>-1?a>-1?s+n+"#"+i.substring(1,a)+"_sasdk="+p:s+n+"#"+i.substring(1)+"&_sasdk="+p:s+n+"#"+i.substring(1)+"?_sasdk="+p):(a=n.indexOf("_sasdk"),o=/^\?(\w)+/.test(n)?a>-1?s+"?"+n.substring(1,a)+"_sasdk="+p+i:s+"?"+n.substring(1)+"&_sasdk="+p+i:s+"?"+n.substring(1)+"_sasdk="+p+i);return o},_.each(["setProfile","setOnceProfile","track","quick","incrementProfile","appendProfile","login","logout","registerApp","register","clearAllRegister","clearAllProps","clearAppRegister"],function(e){var t=sa[e];sa[e]=function(){sa.initialState.isComplete?t.apply(sa,arguments):sa.initialState.queue.push([e,arguments])}}),_.setQuery=function(e,t){if(e&&_.isObject(e)&&!_.isEmptyObject(e)){var a=[];return _.each(e,function(e,r){"q"===r&&_.isString(e)&&0===e.indexOf("http")||(t?a.push(r+"="+e):a.push(r+"="+_.decodeURIComponent(e)))}),a.join("&")}return""},_.getUtmFromPage=function(){var e={};try{var t=getCurrentPages(),a=JSON.parse(JSON.stringify(t[t.length-1].options));for(var r in a)a[r]=_.decodeURIComponent(a[r]);e=_.getCustomUtmFromQuery(a,"$","_","$")}catch(e){logger.info(e)}return e},sa.autoTrackCustom={trackCustom:function(e,t,a){var r=sa.para.autoTrack[e],s="";sa.para.autoTrack&&r&&("function"==typeof r?(s=r(),_.isObject(s)&&_.extend(t,s)):_.isObject(r)&&(_.extend(t,r),sa.para.autoTrack[e]=!0),sa.track(a,t))},appLaunch:function(e,t){"object"!=typeof this||this.trackCustom||(this[sa.para.name]=sa);var a={};e&&e.scene?(current_scene=e.scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(a.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),_.setShareInfo(e,a);var r=_.setUtm(e,a);is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):a.$is_first_time=!1,_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),t?(a=_.extend(a,t),sa.track("$MPLaunch",a)):sa.para.autoTrack&&sa.para.autoTrack.appLaunch&&sa.autoTrackCustom.trackCustom("appLaunch",a,"$MPLaunch")},appShow:function(e,t){var a={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(a.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,a);var r=_.setUtm(e,a);_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),t?(a=_.extend(a,t),sa.track("$MPShow",a)):sa.para.autoTrack&&sa.para.autoTrack.appShow&&sa.autoTrackCustom.trackCustom("appShow",a,"$MPShow")},appHide:function(e){var t=(new Date).getTime(),a={};a.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(a.event_duration=(t-mpshow_time)/1e3),e?(a=_.extend(a,e),sa.track("$MPHide",a)):sa.para.autoTrack&&sa.para.autoTrack.appHide&&sa.autoTrackCustom.trackCustom("appHide",a,"$MPHide"),sa.sendStrategy.onAppHide()},pageLoad:function(e){current_scene&&1010===current_scene&&e&&e.sampshare&&delete e.sampshare,e&&_.isObject(e)&&(this.sensors_mp_url_query=_.setQuery(e),this.sensors_mp_encode_url_query=_.setQuery(e,!0))},pageShow:function(){var e={},t=_.getCurrentPath(),a=_.getPageTitle(t);e.$referrer=sa_referrer,e.$url_path=t,sa.status.last_referrer=sa_referrer,e.$url_query=this.sensors_mp_url_query?this.sensors_mp_url_query:"",e=_.extend(e,_.getUtmFromPage()),_.setPageSfSource(e),a&&(e.$title=a),sa.para.onshow?sa.para.onshow(sa,t,this):_.isObject(sa.para.autotrack_exclude_page)&&_.isArray(sa.para.autotrack_exclude_page.pageShow)&&-1!==sa.para.autotrack_exclude_page.pageShow.indexOf(t)||sa.autoTrackCustom.trackCustom("pageShow",e,"$MPViewScreen"),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:t}),sa_referrer=t,sa.status.referrer=t},pageShare:function(e){var t=e.onShareAppMessage;e.onShareAppMessage=function(){share_method="\u8f6c\u53d1\u6d88\u606f\u5361\u7247";var e=t.apply(this,arguments);return sa.para.autoTrack&&sa.para.autoTrack.pageShare&&sa.autoTrackCustom.trackCustom("pageShare",{$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method},"$MPShare"),sa.para.allow_amend_share_path&&("object"!=typeof e&&((e={}).path=_.getCurrentUrl(this)),"object"!=typeof e||void 0!==e.path&&""!==e.path||(e.path=_.getCurrentUrl(this)),"object"==typeof e&&"string"==typeof e.path&&(-1===e.path.indexOf("?")?e.path=e.path+"?":"&"!==e.path.slice(-1)&&(e.path=e.path+"&")),e.path=e.path+"sampshare="+encodeURIComponent(_.getShareInfo())),e}},pageShareTimeline:function(e){var t=e.onShareTimeline;e.onShareTimeline=function(){share_method="\u670b\u53cb\u5708\u5206\u4eab";var e=t.apply(this,arguments);return sa.para.autoTrack&&sa.para.autoTrack.pageShare&&sa.autoTrackCustom.trackCustom("pageShare",{$url_path:_.getCurrentPath(),$share_depth:query_share_depth,$share_method:share_method},"$MPShare"),sa.para.allow_amend_share_path&&("object"!=typeof e&&(e={}),"object"==typeof e&&void 0===e.query&&(e.query=""),"object"==typeof e&&"string"==typeof e.query&&""!==e.query&&"&"!==e.query.slice(-1)&&(e.query=e.query+"&"),e.query=e.query+"sampshare="+encodeURIComponent(_.getShareInfo())),e}},pageAddFavorites:function(){var e={};e.$url_path=_.getCurrentPath(),sa.para.autoTrack&&sa.para.autoTrack.mpFavorite&&sa.autoTrackCustom.trackCustom("mpFavorite",e,"$MPAddFavorites")}},sa.quick=function(){var e=arguments[0],t=arguments[1],a=arguments[2],r=_.isObject(a)?a:{};if("getAnonymousID"===e){if(!_.isEmptyObject(sa.store._state))return sa.store._state._first_id||sa.store._state.first_id||sa.store._state._distinct_id||sa.store._state.distinct_id;logger.info("\u8bf7\u5148\u521d\u59cb\u5316SDK")}else"appLaunch"===e||"appShow"===e?t?sa.autoTrackCustom[e](t,r):logger.info("App\u7684launch\u548cshow\uff0c\u5728sensors.quick\u7b2c\u4e8c\u4e2a\u53c2\u6570\u5fc5\u987b\u4f20\u5165App\u7684options\u53c2\u6570"):"appHide"===e&&(r=_.isObject(t)?t:{},sa.autoTrackCustom[e](r))},sa.appLaunch=function(e,t){var a={};e&&e.scene?(current_scene=e.scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(a.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),_.setShareInfo(e,a);var r=_.setUtm(e,a);is_first_launch?(a.$is_first_time=!0,_.isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):a.$is_first_time=!1,_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),_.isObject(t)&&(a=_.extend(a,t)),sa.track("$MPLaunch",a)},sa.appShow=function(e,t){var a={};mpshow_time=(new Date).getTime(),e&&e.scene?(current_scene=e.scene,a.$scene=_.getMPScene(e.scene)):a.$scene="\u672a\u53d6\u5230\u503c",e&&e.scene&&1010===e.scene&&e.query&&e.query.sampshare&&delete e.query.sampshare,e&&e.path&&(a.$url_path=_.getPath(e.path),!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a.$url_path})),!_.isObject(sa.para.preset_properties.location)||"wgs84"!==sa.para.preset_properties.location.type&&"gcj02"!==sa.para.preset_properties.location.type||sa.getLocation(),_.setShareInfo(e,a);var r=_.setUtm(e,a);_.setLatestChannel(r.pre2),_.setSfSource(e,a),sa.registerApp({$latest_scene:a.$scene}),a.$url_query=_.setQuery(e.query),_.isObject(t)&&(a=_.extend(a,t)),sa.track("$MPShow",a)},sa.appHide=function(e){var t=(new Date).getTime(),a={};a.$url_path=_.getCurrentPath(),mpshow_time&&t-mpshow_time>0&&(t-mpshow_time)/36e5<24&&(a.event_duration=(t-mpshow_time)/1e3),_.isObject(e)&&(a=_.extend(a,e)),sa.track("$MPHide",a),sa.sendStrategy.onAppHide()},sa.pageShow=function(e){var t={},a=_.getCurrentPath(),r=_.getPageTitle(a),s={};try{var n=getCurrentPages();s=n[n.length-1]}catch(e){logger.info(e)}!0===sa.para.preset_properties.url_path&&sa.registerApp({$url_path:a}),r&&(t.$title=r),t.$referrer=sa_referrer,t.$url_path=a,sa.status.last_referrer=sa_referrer,t.$url_query=s.sensors_mp_url_query?s.sensors_mp_url_query:"",t=_.extend(t,_.getUtmFromPage()),_.setPageSfSource(t),_.isObject(e)&&(t=_.extend(t,e)),sa.track("$MPViewScreen",t),sa_referrer=a,sa.status.referrer=a},sa.App=function(e){(e=e||{})[sa.para.name]=sa,App.apply(this,arguments)},wx.onAppShow(function(e){if(!sa.para.launched){var t=wx.getLaunchOptionsSync()||{};sa.autoTrackCustom.appLaunch(t),sa.para.launched=!0}sa.autoTrackCustom.appShow(e)}),wx.onAppHide(function(){sa.autoTrackCustom.appHide()}),sa.Page=function(e){var t=sa.para.autoTrack&&sa.para.autoTrack.mpClick&&_.getMethods(e);if(t)for(var a=0,r=t.length;a