From fa3200f5d03bb324e36351c796efa3ba35753f96 Mon Sep 17 00:00:00 2001 From: riyue Date: Fri, 26 Oct 2018 11:37:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +++- package.json | 2 +- sensorsdata.min.js | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8c84365..d53686e 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,9 @@ sensorsdata_conf.js 是配置文件 ## 版本更新记录 1.10.5 1 增加 $url_query 2 增加 sa.initWithOpenid(options,callback) callback(openid) 3 增加sa.status.referrer sa.status.laster_referrer 1.11.1 更新 $manufacturer 设备制造商(brand),修正 $screen_width的 取值(windowWidth) -1.12.1 更新支持插件的小程序 SDK 具体用法参考 https://sensorsdata.cn/manual/mp_sdk_plugin.html +1.12.1 更新支持插件的小程序 SDK 具体用法参考 https://sensorsdata.cn/manual/mp_sdk_plugin.html +1.12.2 修复在开启自动采集分享,且定义空的onShareAppMessage时候,控制台报错的问题 + diff --git a/package.json b/package.json index a9d49ed..beb342f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "sa-sdk-miniprogram", - "version": "1.12.1", + "version": "1.12.2", "description": "sensorsdata miniprogram sdk", "main": "sensorsdata.min.js", "scripts": { diff --git a/sensorsdata.min.js b/sensorsdata.min.js index 12cb753..194f215 100755 --- a/sensorsdata.min.js +++ b/sensorsdata.min.js @@ -1 +1 @@ -var _={},sa={};sa.para=require("./sensorsdata_conf.js"),sa.status={},sa.para.openid_url||(sa.para.openid_url=sa.para.server_url.replace(/\/sa(\.gif){0,1}/,"/mp_login")),"number"!=typeof sa.para.send_timeout&&(sa.para.send_timeout=1e3);var ArrayProto=Array.prototype,FuncProto=Function.prototype,ObjProto=Object.prototype,slice=ArrayProto.slice,toString=ObjProto.toString,hasOwnProperty=ObjProto.hasOwnProperty,LIB_VERSION="1.12.1",LIB_NAME="MiniProgram",source_channel_standard="utm_source utm_medium utm_campaign utm_content utm_term",mp_scene={1001:"\u53d1\u73b0\u680f\u5c0f\u7a0b\u5e8f\u4e3b\u5165\u53e3\uff0c“\u6700\u8fd1\u4f7f\u7528”\u5217\u8868",1005:"\u9876\u90e8\u641c\u7d22\u6846\u7684\u641c\u7d22\u7ed3\u679c\u9875",1006:"\u53d1\u73b0\u680f\u5c0f\u7a0b\u5e8f\u4e3b\u5165\u53e3\u641c\u7d22\u6846\u7684\u641c\u7d22\u7ed3\u679c\u9875",1007:"\u5355\u4eba\u804a\u5929\u4f1a\u8bdd\u4e2d\u7684\u5c0f\u7a0b\u5e8f\u6d88\u606f\u5361\u7247",1008:"\u7fa4\u804a\u4f1a\u8bdd\u4e2d\u7684\u5c0f\u7a0b\u5e8f\u6d88\u606f\u5361\u7247",1011:"\u626b\u63cf\u4e8c\u7ef4\u7801",1012:"\u957f\u6309\u56fe\u7247\u8bc6\u522b\u4e8c\u7ef4\u7801",1013:"\u624b\u673a\u76f8\u518c\u9009\u53d6\u4e8c\u7ef4\u7801",1014:"\u5c0f\u7a0b\u5e8f\u6a21\u7248\u6d88\u606f",1017:"\u524d\u5f80\u4f53\u9a8c\u7248\u7684\u5165\u53e3\u9875",1019:"\u5fae\u4fe1\u94b1\u5305",1020:"\u516c\u4f17\u53f7 profile \u9875\u76f8\u5173\u5c0f\u7a0b\u5e8f\u5217\u8868",1022:"\u804a\u5929\u9876\u90e8\u7f6e\u9876\u5c0f\u7a0b\u5e8f\u5165\u53e3",1023:"\u5b89\u5353\u7cfb\u7edf\u684c\u9762\u56fe\u6807",1024:"\u5c0f\u7a0b\u5e8f profile \u9875",1025:"\u626b\u63cf\u4e00\u7ef4\u7801",1026:"\u9644\u8fd1\u5c0f\u7a0b\u5e8f\u5217\u8868",1027:"\u9876\u90e8\u641c\u7d22\u6846\u641c\u7d22\u7ed3\u679c\u9875“\u4f7f\u7528\u8fc7\u7684\u5c0f\u7a0b\u5e8f”\u5217\u8868",1028:"\u6211\u7684\u5361\u5305",1029:"\u5361\u5238\u8be6\u60c5\u9875",1030:"\u81ea\u52a8\u5316\u6d4b\u8bd5\u4e0b\u6253\u5f00\u5c0f\u7a0b\u5e8f",1031:"\u957f\u6309\u56fe\u7247\u8bc6\u522b\u4e00\u7ef4\u7801",1032:"\u624b\u673a\u76f8\u518c\u9009\u53d6\u4e00\u7ef4\u7801",1034:"\u5fae\u4fe1\u652f\u4ed8\u5b8c\u6210\u9875",1035:"\u516c\u4f17\u53f7\u81ea\u5b9a\u4e49\u83dc\u5355",1036:"App \u5206\u4eab\u6d88\u606f\u5361\u7247",1037:"\u5c0f\u7a0b\u5e8f\u6253\u5f00\u5c0f\u7a0b\u5e8f",1038:"\u4ece\u53e6\u4e00\u4e2a\u5c0f\u7a0b\u5e8f\u8fd4\u56de",1039:"\u6447\u7535\u89c6",1042:"\u6dfb\u52a0\u597d\u53cb\u641c\u7d22\u6846\u7684\u641c\u7d22\u7ed3\u679c\u9875",1043:"\u516c\u4f17\u53f7\u6a21\u677f\u6d88\u606f",1044:"\u5e26 shareTicket \u7684\u5c0f\u7a0b\u5e8f\u6d88\u606f\u5361\u7247\uff08\u8be6\u60c5)",1045:"\u670b\u53cb\u5708\u5e7f\u544a",1046:"\u670b\u53cb\u5708\u5e7f\u544a\u8be6\u60c5\u9875",1047:"\u626b\u63cf\u5c0f\u7a0b\u5e8f\u7801",1048:"\u957f\u6309\u56fe\u7247\u8bc6\u522b\u5c0f\u7a0b\u5e8f\u7801",1049:"\u624b\u673a\u76f8\u518c\u9009\u53d6\u5c0f\u7a0b\u5e8f\u7801",1052:"\u5361\u5238\u7684\u9002\u7528\u95e8\u5e97\u5217\u8868",1053:"\u641c\u4e00\u641c\u7684\u7ed3\u679c\u9875",1054:"\u9876\u90e8\u641c\u7d22\u6846\u5c0f\u7a0b\u5e8f\u5feb\u6377\u5165\u53e3",1056:"\u97f3\u4e50\u64ad\u653e\u5668\u83dc\u5355",1057:"\u94b1\u5305\u4e2d\u7684\u94f6\u884c\u5361\u8be6\u60c5\u9875",1058:"\u516c\u4f17\u53f7\u6587\u7ae0",1059:"\u4f53\u9a8c\u7248\u5c0f\u7a0b\u5e8f\u7ed1\u5b9a\u9080\u8bf7\u9875",1064:"\u5fae\u4fe1\u8fdeWi-Fi\u72b6\u6001\u680f",1067:"\u516c\u4f17\u53f7\u6587\u7ae0\u5e7f\u544a",1068:"\u9644\u8fd1\u5c0f\u7a0b\u5e8f\u5217\u8868\u5e7f\u544a",1069:"\u79fb\u52a8\u5e94\u7528",1071:"\u94b1\u5305\u4e2d\u7684\u94f6\u884c\u5361\u5217\u8868\u9875",1072:"\u4e8c\u7ef4\u7801\u6536\u6b3e\u9875\u9762",1073:"\u5ba2\u670d\u6d88\u606f\u5217\u8868\u4e0b\u53d1\u7684\u5c0f\u7a0b\u5e8f\u6d88\u606f\u5361\u7247",1074:"\u516c\u4f17\u53f7\u4f1a\u8bdd\u4e0b\u53d1\u7684\u5c0f\u7a0b\u5e8f\u6d88\u606f\u5361\u7247",1077:"\u6447\u5468\u8fb9",1078:"\u8fdeWi-Fi\u6210\u529f\u9875",1079:"\u5fae\u4fe1\u6e38\u620f\u4e2d\u5fc3",1081:"\u5ba2\u670d\u6d88\u606f\u4e0b\u53d1\u7684\u6587\u5b57\u94fe",1082:"\u516c\u4f17\u53f7\u4f1a\u8bdd\u4e0b\u53d1\u7684\u6587\u5b57\u94fe",1084:"\u670b\u53cb\u5708\u5e7f\u544a\u539f\u751f\u9875",1089:"\u5fae\u4fe1\u804a\u5929\u4e3b\u754c\u9762\u4e0b\u62c9",1090:"\u957f\u6309\u5c0f\u7a0b\u5e8f\u53f3\u4e0a\u89d2\u83dc\u5355\u5524\u51fa\u6700\u8fd1\u4f7f\u7528\u5386\u53f2",1091:"\u516c\u4f17\u53f7\u6587\u7ae0\u5546\u54c1\u5361\u7247",1092:"\u57ce\u5e02\u670d\u52a1\u5165\u53e3",1095:"\u5c0f\u7a0b\u5e8f\u5e7f\u544a\u7ec4\u4ef6",1096:"\u804a\u5929\u8bb0\u5f55",1097:"\u5fae\u4fe1\u652f\u4ed8\u7b7e\u7ea6\u9875",1099:"\u9875\u9762\u5185\u5d4c\u63d2\u4ef6",1102:"\u516c\u4f17\u53f7 profile \u9875\u670d\u52a1\u9884\u89c8",1103:"\u53d1\u73b0\u680f\u5c0f\u7a0b\u5e8f\u4e3b\u5165\u53e3\uff0c“\u6211\u7684\u5c0f\u7a0b\u5e8f”\u5217\u8868",1104:"\u5fae\u4fe1\u804a\u5929\u4e3b\u754c\u9762\u4e0b\u62c9\uff0c“\u6211\u7684\u5c0f\u7a0b\u5e8f”\u680f"},sa_referrer="\u76f4\u63a5\u6253\u5f00";sa.status.referrer="\u76f4\u63a5\u6253\u5f00";var mpshow_time=null,share_depth=0,share_distinct_id="",is_first_launch=!1;sa.lib_version=LIB_VERSION;var logger="object"==typeof logger?logger:{};function e(e,t,r){if(e[t]){var s=e[t];e[t]="onLaunch"===t?function(){this[sa.para.name]=sa,s.apply(this,arguments),r.apply(this,arguments)}:function(){s.apply(this,arguments),r.apply(this,arguments)}}else e[t]="onLaunch"===t?function(){this[sa.para.name]=sa,r.apply(this,arguments)}:function(){r.apply(this,arguments)}}function appLaunch(e){this[sa.para.name]=sa;var t={};e&&e.path&&(t.$url_path=e.path),_.setShareInfo(e,t);var r=_.setUtm(e,t);is_first_launch?(t.$is_first_time=!0,_.isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):t.$is_first_time=!1,_.isEmptyObject(r.pre2)||sa.registerApp(r.pre2),e.scene=e.scene||"\u672a\u53d6\u5230\u503c",t.$scene=_.getMPScene(e.scene),sa.registerApp({$latest_scene:t.$scene}),t.$url_query=_.setQuery(e.query),sa.para.autoTrack&&sa.para.autoTrack.appLaunch&&sa.autoTrackCustom("appLaunch",t,"$MPLaunch")}function appShow(e){var t={};mpshow_time=(new Date).getTime(),e&&e.path&&(t.$url_path=e.path),_.setShareInfo(e,t);var r=_.setUtm(e,t);_.isEmptyObject(r.pre2)||sa.registerApp(r.pre2),e.scene=e.scene||"\u672a\u53d6\u5230\u503c",t.$scene=_.getMPScene(e.scene),sa.registerApp({$latest_scene:t.$scene}),t.$url_query=_.setQuery(e.query),sa.para.autoTrack&&sa.para.autoTrack.appShow&&sa.autoTrackCustom("appShow",t,"$MPShow")}function appHide(){var e=(new Date).getTime(),t={};t.$url_path=_.getCurrentPath(),mpshow_time&&e-mpshow_time>0&&(e-mpshow_time)/36e5<24&&(t.event_duration=(e-mpshow_time)/1e3),sa.para.autoTrack&&sa.para.autoTrack.appHide&&sa.autoTrackCustom("appHide",t,"$MPHide")}function pageOnload(e){if(e&&_.isObject(e)){var t=_.extend({},e);if(e.q&&_.extend(t,_.getObjFromQuery(_.decodeURIComponent(e.q))),e.scene){var r=e.scene;r=-1!==(r=_.decodeURIComponent(r)).indexOf("?")?"?"+r.replace(/\?/g,""):"?"+r,_.extend(t,_.getObjFromQuery(r))}var s=_.getUtm(t,"$","$latest_");this.sensors_mp_load_utm=s.pre1,this.sensors_mp_url_query=_.setQuery(e)}}function pageOnshow(){var e="\u7cfb\u7edf\u6ca1\u6709\u53d6\u5230\u503c";"object"==typeof this&&("string"==typeof this.route?e=this.route:"string"==typeof this.__route__&&(e=this.__route__));var t={};t.$referrer=sa_referrer,t.$url_path=e,sa.status.last_referrer=sa_referrer,this.sensors_mp_load_utm&&(_.extend(t,this.sensors_mp_load_utm),this.sensors_mp_load_utm=null),this.sensors_mp_url_query&&(t.$url_query=this.sensors_mp_url_query,this.sensors_mp_url_query=""),sa.para.onshow?sa.para.onshow(sa,e,this):sa.autoTrackCustom("pageShow",t,"$MPViewScreen"),sa_referrer=e,sa.status.referrer=e}function pageOnshare(e){var t=e.onShareAppMessage;e.onShareAppMessage=function(){sa.para.autoTrack&&sa.para.autoTrack.pageShare&&sa.autoTrackCustom("pageShare",{$url_path:_.getCurrentPath(),$share_depth:_.getShareDepth()},"$MPShare");var e=t.apply(this,arguments);return sa.para.allow_amend_share_path&&"string"==typeof e.path&&-1!==e.path.indexOf("/")&&(-1===e.path.indexOf("?")?e.path=e.path+"?":"&"!==e.path.slice(-1)&&(e.path=e.path+"&"),e.path=e.path+"sampshare="+encodeURIComponent(_.getShareInfo())),e}}if(logger.info=function(){if(sa.para.show_log&&"object"==typeof console&&console.log)try{return console.log.apply(console,arguments)}catch(e){console.log(arguments[0])}},function(){FuncProto.bind;var e=ArrayProto.forEach,t=ArrayProto.indexOf,r=Array.isArray,s={},n=_.each=function(t,r,n){if(null==t)return!1;if(e&&t.forEach===e)t.forEach(r,n);else if(t.length===+t.length){for(var a=0,i=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,r){_.isObject(t)?_.searchObjString(e[r]):_.isString(t)&&(e[r]=_.formatString(t))})},_.unique=function(e){for(var t,r=[],s={},n=0;n127&&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&&(a+=e.substring(t,r)),a+=o,t=r=n+1)}return r>t&&(a+=e.substring(t,e.length)),a},_.base64Encode=function(e){var t,r,s,n,a,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,c=0,u="",p=[];if(!e)return e;e=_.utf8Encode(e);do{t=(a=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,r=a>>12&63,s=a>>6&63,n=63&a,p[c++]=i.charAt(t)+i.charAt(r)+i.charAt(s)+i.charAt(n)}while(o0&&(_.each(this.queue,function(e){sa[e[0]].apply(sa,slice.call(e[1]))}),sa.queue=[]))}},_.getPrefixUtm=function(e,t,r){if(t=t||"",r=r||"_",!_.isObject(e))return{};var s={},n={};for(var a in e)-1!==(" "+source_channel_standard+" ").indexOf(" "+a+" ")?s[t+a]=e[a]:n[r+a]=e[a];return{$utms:s,otherUtms:n}},_.convertObjToParam=function(e){var t=[];for(var r in e)t.push(r+"="+e[r]);return t.join("&")},_.getSource=function(e){if(_.isObject(e)){if(_.isEmptyObject(e))return{};for(var t in e)-1===(" "+source_channel_standard+" ").indexOf(" "+t+" ")?delete e[t]:e[t]=e[t].replace("?","*");e="?"+(e=_.convertObjToParam(e))}else e=_.decodeURIComponent(e);var r=source_channel_standard.split(" "),s=source_channel_standard.split(" "),n="",a={};return 2!==(e=e.split("?")).length?{}:(e="?"+(e=e[1]),_.isArray(sa.para.source_channel)&&sa.para.source_channel.length>0&&(s=s.concat(sa.para.source_channel),s=_.unique(s)),_.each(s,function(t){n=_.getQueryParam(e,t),(n=_.decodeURIComponent(n)).length&&_.include(r,t)&&(a[t]=n)}),a)},_.getObjFromQuery=function(e){var t=e.split("?"),r={};return t&&t[1]?(_.each(t[1].split("&"),function(e){var t=e.split("=");t[0]&&t[1]&&(r[t[0]]=t[1])}),r):{}},_.getUtm=function(e,t,r){var s=_.getSource(e);return void 0===r&&t?{pre1:_.getPrefixUtm(s,t).$utms||{},pre2:{}}:void 0!==r&&t?{pre1:_.getPrefixUtm(s,t).$utms||{},pre2:_.getPrefixUtm(s,r).$utms||{}}:{pre1:{},pre2:{}}},_.getMPScene=function(e){return"number"==typeof e||"string"==typeof e&&""!==e?(e=String(e),mp_scene[e]||e):"\u672a\u53d6\u5230\u503c"},_.getShareDepth=function(){if("number"==typeof share_depth&&0!==share_depth){var e=sa.store.getDistinctId(),t=sa.store.getFirstId();return!share_distinct_id||share_distinct_id!==e&&share_distinct_id!==t?share_depth+1:share_depth}return 1},_.setShareInfo=function(e,t){var r={};if(!(e&&_.isObject(e.query)&&e.query.sampshare))return{};if(r=_.decodeURIComponent(e.query.sampshare),!_.isJSONString(r))return{};var s=(r=JSON.parse(r)).d,n=r.p,a=r.i;"string"==typeof a?(t.$share_distinct_id=a,share_distinct_id=a):t.$share_distinct_id="\u53d6\u503c\u5f02\u5e38","number"==typeof s?(t.$share_depth=s,share_depth=s):t.$share_depth="\u53d6\u503c\u5f02\u5e38",t.$share_url_path="string"==typeof n?n:"\u53d6\u503c\u5f02\u5e38"},_.getShareInfo=function(){return JSON.stringify({i:sa.store.getDistinctId()||"\u53d6\u503c\u5f02\u5e38",p:_.getCurrentPath(),d:_.getShareDepth()})},_.setUtm=function(e,t){var r={};if(e&&_.isObject(e.query)){var s=(r=_.extend({},e.query)).scene;s&&(s=-1!==(s=_.decodeURIComponent(s)).indexOf("?")?"?"+s.replace(/\?/g,""):"?"+s,_.extend(r,_.getObjFromQuery(s))),e.query.q&&_.extend(r,_.getObjFromQuery(_.decodeURIComponent(e.query.q)))}if(e&&_.isObject(e.referrerInfo)&&e.referrerInfo.extraData){var n={};_.isObject(e.referrerInfo.extraData)&&!_.isEmptyObject(e.referrerInfo.extraData)?n=e.referrerInfo.extraData:_.isJSONString(e.referrerInfo.extraData)&&(n=JSON.parse(e.referrerInfo.extraData)),_.extend(r,n)}var a=_.getUtm(r,"$","$latest_");return _.extend(t,a.pre1),a},_.info={properties:{$lib:LIB_NAME,$lib_version:String(LIB_VERSION)},getSystem:function(){var e=this.properties;function t(){wx.getSystemInfo({success:function(t){e.$manufacturer=t.brand,e.$model=t.model,e.$screen_width=Number(t.screenWidth),e.$screen_height=Number(t.screenHeight),e.$os=t.system.split(" ")[0],e.$os_version=t.system.split(" ")[1]},complete:function(){sa.initialState.systemIsComplete=!0,sa.initialState.checkIsComplete()}})}wx.getNetworkType({success:function(t){e.$network_type=t.networkType},complete:t})}},sa._=_,sa.prepareData=function(e,t){var r={distinct_id:this.store.getDistinctId(),lib:{$lib:LIB_NAME,$lib_method:"code",$lib_version:String(LIB_VERSION)},properties:{}};_.extend(r,e),_.isObject(e.properties)&&!_.isEmptyObject(e.properties)&&_.extend(r.properties,e.properties),e.type&&"profile"===e.type.slice(0,7)||(r.properties=_.extend({},_.info.properties,sa.store.getProps(),r.properties),"object"==typeof sa.store._state&&"number"==typeof sa.store._state.first_visit_day_time&&sa.store._state.first_visit_day_time>(new Date).getTime()?r.properties.$is_first_day=!0:r.properties.$is_first_day=!1),r.properties.$time&&_.isDate(r.properties.$time)?(r.time=1*r.properties.$time,delete r.properties.$time):sa.para.use_client_time&&(r.time=1*new Date),_.searchObjDate(r),_.searchObjString(r),sa.send(r,t)},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=wx.getStorageSync("sensorsdata2015_wechat")||"",this.storageInfo)},_state:{},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},getDistinctId:function(){return this._state.distinct_id},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];this.save()},change:function(e,t){this._state[e]=t},save:function(){wx.setStorageSync("sensorsdata2015_wechat",this._state)},init:function(){var e=this.getStorage();if(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),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.track=function(e,t,r){this.prepareData({type:"track",event:e,properties:t},r)},sa.identify=function(e,t){if("number"==typeof e)e=String(e);else if("string"!=typeof e)return!1;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){sa.prepareData({original_id:sa.store.getFirstId()||sa.store.getDistinctId(),distinct_id:e,type:"track_signup",event:t,properties:r},s),sa.store.set("distinct_id",e)},sa.registerApp=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&(_.info.properties=_.extend(_.info.properties,e))},sa.register=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&sa.store.setProps(e)},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.login=function(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.openid={getRequest:function(e){wx.login({success:function(t){t.code&&sa.para.appid&&sa.para.openid_url?wx.request({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(),_.isObject(this.para.register)&&(_.info.properties=_.extend(_.info.properties,this.para.register))},sa.init=function(e){_.isObject(e)&&(sa.para=_.extend(sa.para,e)),sa.initialState.storeIsComplete=!0,sa.initialState.checkIsComplete()},sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib){var e=_.extend({$url_path:_.getCurrentPath()},_.info.properties,sa.store.getProps());return delete e.$lib,e}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;setTimeout(function(){e.isEnd()},sa.para.send_timeout),wx.request({url:this.url,method:"GET",complete:function(){e.isEnd()}})},sa.dataQueue=_.autoExeQueue(),sa.send=function(e){var t="";e._nocache=(String(Math.random())+String(Math.random())+String(Math.random())).slice(2,15),logger.info(e),e=JSON.stringify(e),t=-1!==sa.para.server_url.indexOf("?")?sa.para.server_url+"&data="+encodeURIComponent(_.base64Encode(e)):sa.para.server_url+"?data="+encodeURIComponent(_.base64Encode(e));var r=new sa.requestQueue({url:t});r.close=function(){sa.dataQueue.close()},sa.dataQueue.enqueue(r)},sa.autoTrackCustom=function(e,t,r){var s=sa.para.autoTrack[e],n="";sa.para.autoTrack&&s&&("function"==typeof s?(n=s(),_.isObject(n)&&_.extend(t,n)):_.isObject(s)&&(_.extend(t,s),sa.para.autoTrack[e]=!0),sa.track(r,t))},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||{},sa.openid.getOpenid(function(r){r&&sa.setOpenid(r,e.isCoverLogin),t&&_.isFunction(t)&&t(r),sa.init(e)})},_.each(["setProfile","setOnceProfile","track","register","clearAllRegister","autoTrackCustom","registerApp"],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){if(e&&_.isObject(e)&&!_.isEmptyObject(e)){var t=[];return _.each(e,function(e,r){t.push(r+"="+e)}),t.join("&")}return""},sa.para.is_plugin)sa.App=function(t){e(t=t||{},"onLaunch",appLaunch),e(t,"onShow",appShow),e(t,"onHide",appHide),App.apply(this,arguments)},sa.Page=function(t){e(t,"onLoad",pageOnload),e(t,"onShow",pageOnshow),"function"==typeof t.onShareAppMessage&&pageOnshare(t),Page.apply(this,arguments)};else if(!1!==sa.para.autoTrack){var oldApp=App;App=function(t){e(t,"onLaunch",appLaunch),e(t,"onShow",appShow),e(t,"onHide",appHide),oldApp.apply(this,arguments)};var oldPage=Page;Page=function(t){e(t,"onLoad",pageOnload),e(t,"onShow",pageOnshow),"function"==typeof t.onShareAppMessage&&pageOnshare(t),oldPage.apply(this,arguments)}}sa.initial(),module.exports=sa; \ No newline at end of file +var _={},sa={};sa.para=require("./sensorsdata_conf.js"),sa.status={},sa.para.openid_url||(sa.para.openid_url=sa.para.server_url.replace(/\/sa(\.gif){0,1}/,"/mp_login")),"number"!=typeof sa.para.send_timeout&&(sa.para.send_timeout=1e3);var ArrayProto=Array.prototype,FuncProto=Function.prototype,ObjProto=Object.prototype,slice=ArrayProto.slice,toString=ObjProto.toString,hasOwnProperty=ObjProto.hasOwnProperty,LIB_VERSION="1.12.2",LIB_NAME="MiniProgram",source_channel_standard="utm_source utm_medium utm_campaign utm_content utm_term",mp_scene={1001:"\u53d1\u73b0\u680f\u5c0f\u7a0b\u5e8f\u4e3b\u5165\u53e3\uff0c“\u6700\u8fd1\u4f7f\u7528”\u5217\u8868",1005:"\u9876\u90e8\u641c\u7d22\u6846\u7684\u641c\u7d22\u7ed3\u679c\u9875",1006:"\u53d1\u73b0\u680f\u5c0f\u7a0b\u5e8f\u4e3b\u5165\u53e3\u641c\u7d22\u6846\u7684\u641c\u7d22\u7ed3\u679c\u9875",1007:"\u5355\u4eba\u804a\u5929\u4f1a\u8bdd\u4e2d\u7684\u5c0f\u7a0b\u5e8f\u6d88\u606f\u5361\u7247",1008:"\u7fa4\u804a\u4f1a\u8bdd\u4e2d\u7684\u5c0f\u7a0b\u5e8f\u6d88\u606f\u5361\u7247",1011:"\u626b\u63cf\u4e8c\u7ef4\u7801",1012:"\u957f\u6309\u56fe\u7247\u8bc6\u522b\u4e8c\u7ef4\u7801",1013:"\u624b\u673a\u76f8\u518c\u9009\u53d6\u4e8c\u7ef4\u7801",1014:"\u5c0f\u7a0b\u5e8f\u6a21\u7248\u6d88\u606f",1017:"\u524d\u5f80\u4f53\u9a8c\u7248\u7684\u5165\u53e3\u9875",1019:"\u5fae\u4fe1\u94b1\u5305",1020:"\u516c\u4f17\u53f7 profile \u9875\u76f8\u5173\u5c0f\u7a0b\u5e8f\u5217\u8868",1022:"\u804a\u5929\u9876\u90e8\u7f6e\u9876\u5c0f\u7a0b\u5e8f\u5165\u53e3",1023:"\u5b89\u5353\u7cfb\u7edf\u684c\u9762\u56fe\u6807",1024:"\u5c0f\u7a0b\u5e8f profile \u9875",1025:"\u626b\u63cf\u4e00\u7ef4\u7801",1026:"\u9644\u8fd1\u5c0f\u7a0b\u5e8f\u5217\u8868",1027:"\u9876\u90e8\u641c\u7d22\u6846\u641c\u7d22\u7ed3\u679c\u9875“\u4f7f\u7528\u8fc7\u7684\u5c0f\u7a0b\u5e8f”\u5217\u8868",1028:"\u6211\u7684\u5361\u5305",1029:"\u5361\u5238\u8be6\u60c5\u9875",1030:"\u81ea\u52a8\u5316\u6d4b\u8bd5\u4e0b\u6253\u5f00\u5c0f\u7a0b\u5e8f",1031:"\u957f\u6309\u56fe\u7247\u8bc6\u522b\u4e00\u7ef4\u7801",1032:"\u624b\u673a\u76f8\u518c\u9009\u53d6\u4e00\u7ef4\u7801",1034:"\u5fae\u4fe1\u652f\u4ed8\u5b8c\u6210\u9875",1035:"\u516c\u4f17\u53f7\u81ea\u5b9a\u4e49\u83dc\u5355",1036:"App \u5206\u4eab\u6d88\u606f\u5361\u7247",1037:"\u5c0f\u7a0b\u5e8f\u6253\u5f00\u5c0f\u7a0b\u5e8f",1038:"\u4ece\u53e6\u4e00\u4e2a\u5c0f\u7a0b\u5e8f\u8fd4\u56de",1039:"\u6447\u7535\u89c6",1042:"\u6dfb\u52a0\u597d\u53cb\u641c\u7d22\u6846\u7684\u641c\u7d22\u7ed3\u679c\u9875",1043:"\u516c\u4f17\u53f7\u6a21\u677f\u6d88\u606f",1044:"\u5e26 shareTicket \u7684\u5c0f\u7a0b\u5e8f\u6d88\u606f\u5361\u7247\uff08\u8be6\u60c5)",1045:"\u670b\u53cb\u5708\u5e7f\u544a",1046:"\u670b\u53cb\u5708\u5e7f\u544a\u8be6\u60c5\u9875",1047:"\u626b\u63cf\u5c0f\u7a0b\u5e8f\u7801",1048:"\u957f\u6309\u56fe\u7247\u8bc6\u522b\u5c0f\u7a0b\u5e8f\u7801",1049:"\u624b\u673a\u76f8\u518c\u9009\u53d6\u5c0f\u7a0b\u5e8f\u7801",1052:"\u5361\u5238\u7684\u9002\u7528\u95e8\u5e97\u5217\u8868",1053:"\u641c\u4e00\u641c\u7684\u7ed3\u679c\u9875",1054:"\u9876\u90e8\u641c\u7d22\u6846\u5c0f\u7a0b\u5e8f\u5feb\u6377\u5165\u53e3",1056:"\u97f3\u4e50\u64ad\u653e\u5668\u83dc\u5355",1057:"\u94b1\u5305\u4e2d\u7684\u94f6\u884c\u5361\u8be6\u60c5\u9875",1058:"\u516c\u4f17\u53f7\u6587\u7ae0",1059:"\u4f53\u9a8c\u7248\u5c0f\u7a0b\u5e8f\u7ed1\u5b9a\u9080\u8bf7\u9875",1064:"\u5fae\u4fe1\u8fdeWi-Fi\u72b6\u6001\u680f",1067:"\u516c\u4f17\u53f7\u6587\u7ae0\u5e7f\u544a",1068:"\u9644\u8fd1\u5c0f\u7a0b\u5e8f\u5217\u8868\u5e7f\u544a",1069:"\u79fb\u52a8\u5e94\u7528",1071:"\u94b1\u5305\u4e2d\u7684\u94f6\u884c\u5361\u5217\u8868\u9875",1072:"\u4e8c\u7ef4\u7801\u6536\u6b3e\u9875\u9762",1073:"\u5ba2\u670d\u6d88\u606f\u5217\u8868\u4e0b\u53d1\u7684\u5c0f\u7a0b\u5e8f\u6d88\u606f\u5361\u7247",1074:"\u516c\u4f17\u53f7\u4f1a\u8bdd\u4e0b\u53d1\u7684\u5c0f\u7a0b\u5e8f\u6d88\u606f\u5361\u7247",1077:"\u6447\u5468\u8fb9",1078:"\u8fdeWi-Fi\u6210\u529f\u9875",1079:"\u5fae\u4fe1\u6e38\u620f\u4e2d\u5fc3",1081:"\u5ba2\u670d\u6d88\u606f\u4e0b\u53d1\u7684\u6587\u5b57\u94fe",1082:"\u516c\u4f17\u53f7\u4f1a\u8bdd\u4e0b\u53d1\u7684\u6587\u5b57\u94fe",1084:"\u670b\u53cb\u5708\u5e7f\u544a\u539f\u751f\u9875",1089:"\u5fae\u4fe1\u804a\u5929\u4e3b\u754c\u9762\u4e0b\u62c9",1090:"\u957f\u6309\u5c0f\u7a0b\u5e8f\u53f3\u4e0a\u89d2\u83dc\u5355\u5524\u51fa\u6700\u8fd1\u4f7f\u7528\u5386\u53f2",1091:"\u516c\u4f17\u53f7\u6587\u7ae0\u5546\u54c1\u5361\u7247",1092:"\u57ce\u5e02\u670d\u52a1\u5165\u53e3",1095:"\u5c0f\u7a0b\u5e8f\u5e7f\u544a\u7ec4\u4ef6",1096:"\u804a\u5929\u8bb0\u5f55",1097:"\u5fae\u4fe1\u652f\u4ed8\u7b7e\u7ea6\u9875",1099:"\u9875\u9762\u5185\u5d4c\u63d2\u4ef6",1102:"\u516c\u4f17\u53f7 profile \u9875\u670d\u52a1\u9884\u89c8",1103:"\u53d1\u73b0\u680f\u5c0f\u7a0b\u5e8f\u4e3b\u5165\u53e3\uff0c“\u6211\u7684\u5c0f\u7a0b\u5e8f”\u5217\u8868",1104:"\u5fae\u4fe1\u804a\u5929\u4e3b\u754c\u9762\u4e0b\u62c9\uff0c“\u6211\u7684\u5c0f\u7a0b\u5e8f”\u680f"},sa_referrer="\u76f4\u63a5\u6253\u5f00";sa.status.referrer="\u76f4\u63a5\u6253\u5f00";var mpshow_time=null,share_depth=0,share_distinct_id="",is_first_launch=!1;sa.lib_version=LIB_VERSION;var logger="object"==typeof logger?logger:{};function e(e,t,r){if(e[t]){var s=e[t];e[t]="onLaunch"===t?function(){this[sa.para.name]=sa,s.apply(this,arguments),r.apply(this,arguments)}:function(){s.apply(this,arguments),r.apply(this,arguments)}}else e[t]="onLaunch"===t?function(){this[sa.para.name]=sa,r.apply(this,arguments)}:function(){r.apply(this,arguments)}}function appLaunch(e){this[sa.para.name]=sa;var t={};e&&e.path&&(t.$url_path=e.path),_.setShareInfo(e,t);var r=_.setUtm(e,t);is_first_launch?(t.$is_first_time=!0,_.isEmptyObject(r.pre1)||sa.setOnceProfile(r.pre1)):t.$is_first_time=!1,_.isEmptyObject(r.pre2)||sa.registerApp(r.pre2),e.scene=e.scene||"\u672a\u53d6\u5230\u503c",t.$scene=_.getMPScene(e.scene),sa.registerApp({$latest_scene:t.$scene}),t.$url_query=_.setQuery(e.query),sa.para.autoTrack&&sa.para.autoTrack.appLaunch&&sa.autoTrackCustom("appLaunch",t,"$MPLaunch")}function appShow(e){var t={};mpshow_time=(new Date).getTime(),e&&e.path&&(t.$url_path=e.path),_.setShareInfo(e,t);var r=_.setUtm(e,t);_.isEmptyObject(r.pre2)||sa.registerApp(r.pre2),e.scene=e.scene||"\u672a\u53d6\u5230\u503c",t.$scene=_.getMPScene(e.scene),sa.registerApp({$latest_scene:t.$scene}),t.$url_query=_.setQuery(e.query),sa.para.autoTrack&&sa.para.autoTrack.appShow&&sa.autoTrackCustom("appShow",t,"$MPShow")}function appHide(){var e=(new Date).getTime(),t={};t.$url_path=_.getCurrentPath(),mpshow_time&&e-mpshow_time>0&&(e-mpshow_time)/36e5<24&&(t.event_duration=(e-mpshow_time)/1e3),sa.para.autoTrack&&sa.para.autoTrack.appHide&&sa.autoTrackCustom("appHide",t,"$MPHide")}function pageOnload(e){if(e&&_.isObject(e)){var t=_.extend({},e);if(e.q&&_.extend(t,_.getObjFromQuery(_.decodeURIComponent(e.q))),e.scene){var r=e.scene;r=-1!==(r=_.decodeURIComponent(r)).indexOf("?")?"?"+r.replace(/\?/g,""):"?"+r,_.extend(t,_.getObjFromQuery(r))}var s=_.getUtm(t,"$","$latest_");this.sensors_mp_load_utm=s.pre1,this.sensors_mp_url_query=_.setQuery(e)}}function pageOnshow(){var e="\u7cfb\u7edf\u6ca1\u6709\u53d6\u5230\u503c";"object"==typeof this&&("string"==typeof this.route?e=this.route:"string"==typeof this.__route__&&(e=this.__route__));var t={};t.$referrer=sa_referrer,t.$url_path=e,sa.status.last_referrer=sa_referrer,this.sensors_mp_load_utm&&(_.extend(t,this.sensors_mp_load_utm),this.sensors_mp_load_utm=null),this.sensors_mp_url_query&&(t.$url_query=this.sensors_mp_url_query,this.sensors_mp_url_query=""),sa.para.onshow?sa.para.onshow(sa,e,this):sa.autoTrackCustom("pageShow",t,"$MPViewScreen"),sa_referrer=e,sa.status.referrer=e}function pageOnshare(e){var t=e.onShareAppMessage;e.onShareAppMessage=function(){sa.para.autoTrack&&sa.para.autoTrack.pageShare&&sa.autoTrackCustom("pageShare",{$url_path:_.getCurrentPath(),$share_depth:_.getShareDepth()},"$MPShare");var e=t.apply(this,arguments);return sa.para.allow_amend_share_path&&(e||((e={}).path=_.getCurrentPath()),"object"==typeof e&&"string"==typeof e.path&&-1!==e.path.indexOf("/")&&(-1===e.path.indexOf("?")?e.path=e.path+"?":"&"!==e.path.slice(-1)&&(e.path=e.path+"&")),e.path=e.path+"sampshare="+encodeURIComponent(_.getShareInfo())),e}}if(logger.info=function(){if(sa.para.show_log&&"object"==typeof console&&console.log)try{return console.log.apply(console,arguments)}catch(e){console.log(arguments[0])}},function(){FuncProto.bind;var e=ArrayProto.forEach,t=ArrayProto.indexOf,r=Array.isArray,s={},n=_.each=function(t,r,n){if(null==t)return!1;if(e&&t.forEach===e)t.forEach(r,n);else if(t.length===+t.length){for(var a=0,i=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,r){_.isObject(t)?_.searchObjString(e[r]):_.isString(t)&&(e[r]=_.formatString(t))})},_.unique=function(e){for(var t,r=[],s={},n=0;n127&&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&&(a+=e.substring(t,r)),a+=o,t=r=n+1)}return r>t&&(a+=e.substring(t,e.length)),a},_.base64Encode=function(e){var t,r,s,n,a,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o=0,c=0,u="",p=[];if(!e)return e;e=_.utf8Encode(e);do{t=(a=e.charCodeAt(o++)<<16|e.charCodeAt(o++)<<8|e.charCodeAt(o++))>>18&63,r=a>>12&63,s=a>>6&63,n=63&a,p[c++]=i.charAt(t)+i.charAt(r)+i.charAt(s)+i.charAt(n)}while(o0&&(_.each(this.queue,function(e){sa[e[0]].apply(sa,slice.call(e[1]))}),sa.queue=[]))}},_.getPrefixUtm=function(e,t,r){if(t=t||"",r=r||"_",!_.isObject(e))return{};var s={},n={};for(var a in e)-1!==(" "+source_channel_standard+" ").indexOf(" "+a+" ")?s[t+a]=e[a]:n[r+a]=e[a];return{$utms:s,otherUtms:n}},_.convertObjToParam=function(e){var t=[];for(var r in e)t.push(r+"="+e[r]);return t.join("&")},_.getSource=function(e){if(_.isObject(e)){if(_.isEmptyObject(e))return{};for(var t in e)-1===(" "+source_channel_standard+" ").indexOf(" "+t+" ")?delete e[t]:e[t]=e[t].replace("?","*");e="?"+(e=_.convertObjToParam(e))}else e=_.decodeURIComponent(e);var r=source_channel_standard.split(" "),s=source_channel_standard.split(" "),n="",a={};return 2!==(e=e.split("?")).length?{}:(e="?"+(e=e[1]),_.isArray(sa.para.source_channel)&&sa.para.source_channel.length>0&&(s=s.concat(sa.para.source_channel),s=_.unique(s)),_.each(s,function(t){n=_.getQueryParam(e,t),(n=_.decodeURIComponent(n)).length&&_.include(r,t)&&(a[t]=n)}),a)},_.getObjFromQuery=function(e){var t=e.split("?"),r={};return t&&t[1]?(_.each(t[1].split("&"),function(e){var t=e.split("=");t[0]&&t[1]&&(r[t[0]]=t[1])}),r):{}},_.getUtm=function(e,t,r){var s=_.getSource(e);return void 0===r&&t?{pre1:_.getPrefixUtm(s,t).$utms||{},pre2:{}}:void 0!==r&&t?{pre1:_.getPrefixUtm(s,t).$utms||{},pre2:_.getPrefixUtm(s,r).$utms||{}}:{pre1:{},pre2:{}}},_.getMPScene=function(e){return"number"==typeof e||"string"==typeof e&&""!==e?(e=String(e),mp_scene[e]||e):"\u672a\u53d6\u5230\u503c"},_.getShareDepth=function(){if("number"==typeof share_depth&&0!==share_depth){var e=sa.store.getDistinctId(),t=sa.store.getFirstId();return!share_distinct_id||share_distinct_id!==e&&share_distinct_id!==t?share_depth+1:share_depth}return 1},_.setShareInfo=function(e,t){var r={};if(!(e&&_.isObject(e.query)&&e.query.sampshare))return{};if(r=_.decodeURIComponent(e.query.sampshare),!_.isJSONString(r))return{};var s=(r=JSON.parse(r)).d,n=r.p,a=r.i;"string"==typeof a?(t.$share_distinct_id=a,share_distinct_id=a):t.$share_distinct_id="\u53d6\u503c\u5f02\u5e38","number"==typeof s?(t.$share_depth=s,share_depth=s):t.$share_depth="\u53d6\u503c\u5f02\u5e38",t.$share_url_path="string"==typeof n?n:"\u53d6\u503c\u5f02\u5e38"},_.getShareInfo=function(){return JSON.stringify({i:sa.store.getDistinctId()||"\u53d6\u503c\u5f02\u5e38",p:_.getCurrentPath(),d:_.getShareDepth()})},_.setUtm=function(e,t){var r={};if(e&&_.isObject(e.query)){var s=(r=_.extend({},e.query)).scene;s&&(s=-1!==(s=_.decodeURIComponent(s)).indexOf("?")?"?"+s.replace(/\?/g,""):"?"+s,_.extend(r,_.getObjFromQuery(s))),e.query.q&&_.extend(r,_.getObjFromQuery(_.decodeURIComponent(e.query.q)))}if(e&&_.isObject(e.referrerInfo)&&e.referrerInfo.extraData){var n={};_.isObject(e.referrerInfo.extraData)&&!_.isEmptyObject(e.referrerInfo.extraData)?n=e.referrerInfo.extraData:_.isJSONString(e.referrerInfo.extraData)&&(n=JSON.parse(e.referrerInfo.extraData)),_.extend(r,n)}var a=_.getUtm(r,"$","$latest_");return _.extend(t,a.pre1),a},_.info={properties:{$lib:LIB_NAME,$lib_version:String(LIB_VERSION)},getSystem:function(){var e=this.properties;function t(){wx.getSystemInfo({success:function(t){e.$manufacturer=t.brand,e.$model=t.model,e.$screen_width=Number(t.screenWidth),e.$screen_height=Number(t.screenHeight),e.$os=t.system.split(" ")[0],e.$os_version=t.system.split(" ")[1]},complete:function(){sa.initialState.systemIsComplete=!0,sa.initialState.checkIsComplete()}})}wx.getNetworkType({success:function(t){e.$network_type=t.networkType},complete:t})}},sa._=_,sa.prepareData=function(e,t){var r={distinct_id:this.store.getDistinctId(),lib:{$lib:LIB_NAME,$lib_method:"code",$lib_version:String(LIB_VERSION)},properties:{}};_.extend(r,e),_.isObject(e.properties)&&!_.isEmptyObject(e.properties)&&_.extend(r.properties,e.properties),e.type&&"profile"===e.type.slice(0,7)||(r.properties=_.extend({},_.info.properties,sa.store.getProps(),r.properties),"object"==typeof sa.store._state&&"number"==typeof sa.store._state.first_visit_day_time&&sa.store._state.first_visit_day_time>(new Date).getTime()?r.properties.$is_first_day=!0:r.properties.$is_first_day=!1),r.properties.$time&&_.isDate(r.properties.$time)?(r.time=1*r.properties.$time,delete r.properties.$time):sa.para.use_client_time&&(r.time=1*new Date),_.searchObjDate(r),_.searchObjString(r),sa.send(r,t)},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=wx.getStorageSync("sensorsdata2015_wechat")||"",this.storageInfo)},_state:{},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},getDistinctId:function(){return this._state.distinct_id},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];this.save()},change:function(e,t){this._state[e]=t},save:function(){wx.setStorageSync("sensorsdata2015_wechat",this._state)},init:function(){var e=this.getStorage();if(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),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.track=function(e,t,r){this.prepareData({type:"track",event:e,properties:t},r)},sa.identify=function(e,t){if("number"==typeof e)e=String(e);else if("string"!=typeof e)return!1;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){sa.prepareData({original_id:sa.store.getFirstId()||sa.store.getDistinctId(),distinct_id:e,type:"track_signup",event:t,properties:r},s),sa.store.set("distinct_id",e)},sa.registerApp=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&(_.info.properties=_.extend(_.info.properties,e))},sa.register=function(e){_.isObject(e)&&!_.isEmptyObject(e)&&sa.store.setProps(e)},sa.clearAllRegister=function(){sa.store.setProps({},!0)},sa.login=function(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.openid={getRequest:function(e){wx.login({success:function(t){t.code&&sa.para.appid&&sa.para.openid_url?wx.request({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(),_.isObject(this.para.register)&&(_.info.properties=_.extend(_.info.properties,this.para.register))},sa.init=function(e){_.isObject(e)&&(sa.para=_.extend(sa.para,e)),sa.initialState.storeIsComplete=!0,sa.initialState.checkIsComplete()},sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib){var e=_.extend({$url_path:_.getCurrentPath()},_.info.properties,sa.store.getProps());return delete e.$lib,e}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;setTimeout(function(){e.isEnd()},sa.para.send_timeout),wx.request({url:this.url,method:"GET",complete:function(){e.isEnd()}})},sa.dataQueue=_.autoExeQueue(),sa.send=function(e){var t="";e._nocache=(String(Math.random())+String(Math.random())+String(Math.random())).slice(2,15),logger.info(e),e=JSON.stringify(e),t=-1!==sa.para.server_url.indexOf("?")?sa.para.server_url+"&data="+encodeURIComponent(_.base64Encode(e)):sa.para.server_url+"?data="+encodeURIComponent(_.base64Encode(e));var r=new sa.requestQueue({url:t});r.close=function(){sa.dataQueue.close()},sa.dataQueue.enqueue(r)},sa.autoTrackCustom=function(e,t,r){var s=sa.para.autoTrack[e],n="";sa.para.autoTrack&&s&&("function"==typeof s?(n=s(),_.isObject(n)&&_.extend(t,n)):_.isObject(s)&&(_.extend(t,s),sa.para.autoTrack[e]=!0),sa.track(r,t))},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||{},sa.openid.getOpenid(function(r){r&&sa.setOpenid(r,e.isCoverLogin),t&&_.isFunction(t)&&t(r),sa.init(e)})},_.each(["setProfile","setOnceProfile","track","register","clearAllRegister","autoTrackCustom","registerApp"],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){if(e&&_.isObject(e)&&!_.isEmptyObject(e)){var t=[];return _.each(e,function(e,r){t.push(r+"="+e)}),t.join("&")}return""},sa.para.is_plugin)sa.App=function(t){e(t=t||{},"onLaunch",appLaunch),e(t,"onShow",appShow),e(t,"onHide",appHide),App.apply(this,arguments)},sa.Page=function(t){e(t,"onLoad",pageOnload),e(t,"onShow",pageOnshow),"function"==typeof t.onShareAppMessage&&pageOnshare(t),Page.apply(this,arguments)};else if(!1!==sa.para.autoTrack){var oldApp=App;App=function(t){e(t,"onLaunch",appLaunch),e(t,"onShow",appShow),e(t,"onHide",appHide),oldApp.apply(this,arguments)};var oldPage=Page;Page=function(t){e(t,"onLoad",pageOnload),e(t,"onShow",pageOnshow),"function"==typeof t.onShareAppMessage&&pageOnshare(t),oldPage.apply(this,arguments)}}sa.initial(),module.exports=sa; \ No newline at end of file