From bd8a6a7ace695190cc9ad957233b4e7b4b22697e Mon Sep 17 00:00:00 2001 From: shengyonggen Date: Sat, 7 Jul 2018 16:10:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sensorsdata.js | 10 +++++----- sensorsdata.min.js | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sensorsdata.js b/sensorsdata.js index 3a3535a..ca26e9b 100755 --- a/sensorsdata.js +++ b/sensorsdata.js @@ -23,7 +23,7 @@ var ArrayProto = Array.prototype, slice = ArrayProto.slice, toString = ObjProto.toString, hasOwnProperty = ObjProto.hasOwnProperty, - LIB_VERSION = '1.6', + LIB_VERSION = '1.7', LIB_NAME = 'MiniProgram'; var source_channel_standard = 'utm_source utm_medium utm_campaign utm_content utm_term'; @@ -683,8 +683,8 @@ _.setUtm = function(para,prop){ } _.extend(query, _.getObjFromQuery(scene)); } - if (para.query.q) { - _.extend(query, _.getObjFromQuery(para.query.q)); + if (para.query.q) { + _.extend(query, _.getObjFromQuery(_.decodeURIComponent(para.query.q))); } } if (para && _.isObject(para.referrerInfo) && para.referrerInfo.extraData) { @@ -1223,7 +1223,7 @@ function appShow(para) { if (para && para.path) { prop.$url_path = para.path; } - + var utms = _.setUtm(para, prop); if (!_.isEmptyObject(utms.pre2)) { @@ -1308,7 +1308,7 @@ Page = function (t) { if (para && _.isObject(para)) { var query = _.extend({}, para); if (para.q) { - _.extend(query, _.getObjFromQuery(para.q)); + _.extend(query, _.getObjFromQuery(_.decodeURIComponent(para.q))); } var utms = _.getUtm(query, '$', '$latest_'); this.sensors_mp_load_utm = utms.pre1; diff --git a/sensorsdata.min.js b/sensorsdata.min.js index a9f3257..a79318b 100755 --- a/sensorsdata.min.js +++ b/sensorsdata.min.js @@ -1 +1 @@ -var _={};var sa={};sa.para=require("sensorsdata_conf.js");if(!sa.para.openid_url){sa.para.openid_url=sa.para.server_url.replace(/\/sa(\.gif){0,1}/,"/mp_login")}var ArrayProto=Array.prototype,FuncProto=Function.prototype,ObjProto=Object.prototype,slice=ArrayProto.slice,toString=ObjProto.toString,hasOwnProperty=ObjProto.hasOwnProperty,LIB_VERSION="1.6",LIB_NAME="MiniProgram";var source_channel_standard="utm_source utm_medium utm_campaign utm_content utm_term";var mp_scene={1001:"发现栏小程序主入口",1005:"顶部搜索框的搜索结果页",1006:"发现栏小程序主入口搜索框的搜索结果页",1007:"单人聊天会话中的小程序消息卡片",1008:"群聊会话中的小程序消息卡片",1011:"扫描二维码",1012:"长按图片识别二维码",1013:"手机相册选取二维码",1014:"小程序模版消息",1017:"前往体验版的入口页",1019:"微信钱包",1020:"公众号 profile 页相关小程序列表",1022:"聊天顶部置顶小程序入口",1023:"安卓系统桌面图标",1024:"小程序 profile 页",1025:"扫描一维码",1026:"附近小程序列表",1027:"顶部搜索框搜索结果页“使用过的小程序”列表",1028:"我的卡包",1029:"卡券详情页",1030:"自动化测试下打开小程序",1031:"长按图片识别一维码",1032:"手机相册选取一维码",1034:"微信支付完成页",1035:"公众号自定义菜单",1036:"App 分享消息卡片",1037:"小程序打开小程序",1038:"从另一个小程序返回",1039:"摇电视",1042:"添加好友搜索框的搜索结果页",1043:"公众号模板消息",1044:"带 shareTicket 的小程序消息卡片(详情)",1047:"扫描小程序码",1048:"长按图片识别小程序码",1049:"手机相册选取小程序码",1052:"卡券的适用门店列表",1053:"搜一搜的结果页",1054:"顶部搜索框小程序快捷入口",1056:"音乐播放器菜单",1057:"钱包中的银行卡详情页",1058:"公众号文章",1059:"体验版小程序绑定邀请页",1064:"微信连Wi-Fi状态栏",1067:"公众号文章广告",1068:"附近小程序列表广告",1071:"钱包中的银行卡列表页",1072:"二维码收款页面",1073:"客服消息列表下发的小程序消息卡片",1074:"公众号会话下发的小程序消息卡片",1078:"连Wi-Fi成功页",1089:"微信聊天主界面下拉",1090:"长按小程序右上角菜单唤出最近使用历史",1092:"城市服务入口"};var sa_referrer="直接打开";var mpshow_time=null;var is_first_launch=false;sa.lib_version=LIB_VERSION;var logger=typeof logger==="object"?logger:{};logger.info=function(){if(sa.para.show_log){if(typeof console==="object"&&console.log){try{return console.log.apply(console,arguments)}catch(e){console.log(arguments[0])}}}};(function(){var nativeBind=FuncProto.bind,nativeForEach=ArrayProto.forEach,nativeIndexOf=ArrayProto.indexOf,nativeIsArray=Array.isArray,breaker={};var each=_.each=function(obj,iterator,context){if(obj==null){return false}if(nativeForEach&&obj.forEach===nativeForEach){obj.forEach(iterator,context)}else if(obj.length===+obj.length){for(var i=0,l=obj.length;isa.para.max_string_length){logger.info("字符串长度超过限制,已经做截取--"+str);return str.slice(0,sa.para.max_string_length)}else{return str}};_.searchObjString=function(o){if(_.isObject(o)){_.each(o,function(a,b){if(_.isObject(a)){_.searchObjString(o[b])}else{if(_.isString(a)){o[b]=_.formatString(a)}}})}};_.unique=function(ar){var temp,n=[],o={};for(var i=0;i127&&c1<2048){enc=String.fromCharCode(c1>>6|192,c1&63|128)}else{enc=String.fromCharCode(c1>>12|224,c1>>6&63|128,c1&63|128)}if(enc!==null){if(end>start){utftext+=string.substring(start,end)}utftext+=enc;start=end=n+1}}if(end>start){utftext+=string.substring(start,string.length)}return utftext};_.base64Encode=function(data){var b64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var o1,o2,o3,h1,h2,h3,h4,bits,i=0,ac=0,enc="",tmp_arr=[];if(!data){return data}data=_.utf8Encode(data);do{o1=data.charCodeAt(i++);o2=data.charCodeAt(i++);o3=data.charCodeAt(i++);bits=o1<<16|o2<<8|o3;h1=bits>>18&63;h2=bits>>12&63;h3=bits>>6&63;h4=bits&63;tmp_arr[ac++]=b64.charAt(h1)+b64.charAt(h2)+b64.charAt(h3)+b64.charAt(h4)}while(i0){_.each(this.queue,function(content){sa[content[0]].apply(sa,slice.call(content[1]))});sa.queue=[]}}}};_.getPrefixUtm=function(utms,prefix,prefix_add){prefix=prefix||"";prefix_add=prefix_add||"_";if(!_.isObject(utms)){return{}}var $utms={},otherUtms={};for(var i in utms){if((" "+source_channel_standard+" ").indexOf(" "+i+" ")!==-1){$utms[prefix+i]=utms[i]}else{otherUtms[prefix_add+i]=utms[i]}}return{$utms:$utms,otherUtms:otherUtms}};_.convertObjToParam=function(obj){var arr=[];for(var i in obj){arr.push(i+"="+obj[i])}return arr.join("&")};_.getSource=function(url){if(_.isObject(url)){if(_.isEmptyObject(url)){return{}}else{for(var i in url){if((" "+source_channel_standard+" ").indexOf(" "+i+" ")===-1){delete url[i]}else{url[i]=url[i].replace("?","*")}}url=_.convertObjToParam(url);url="?"+url}}else{url=_.decodeURIComponent(url)}var campagin_w=source_channel_standard.split(" ");var campaign_keywords=source_channel_standard.split(" ");var kw="";var params={};url=url.split("?");if(url.length===2){url=url[1]}else{return{}}url="?"+url;if(_.isArray(sa.para.source_channel)&&sa.para.source_channel.length>0){campaign_keywords=campaign_keywords.concat(sa.para.source_channel);campaign_keywords=_.unique(campaign_keywords)}_.each(campaign_keywords,function(kwkey){kw=_.getQueryParam(url,kwkey);kw=_.decodeURIComponent(kw);if(kw.length){if(_.include(campagin_w,kwkey)){params[kwkey]=kw}}});return params};_.getObjFromQuery=function(str){var query=str.split("?");var arr=[];var obj={};if(query&&query[1]){_.each(query[1].split("&"),function(value){var arr=value.split("=");if(arr[0]&&arr[1]){obj[arr[0]]=arr[1]}})}else{return{}}return obj};_.getUtm=function(url,prefix1,prefix2){var utms=_.getSource(url);var pre1={};var pre2={};if(typeof prefix2==="undefined"&&prefix1){return{pre1:_.getPrefixUtm(utms,prefix1).$utms||{},pre2:{}}}else if(typeof prefix2!=="undefined"&&prefix1){return{pre1:_.getPrefixUtm(utms,prefix1).$utms||{},pre2:_.getPrefixUtm(utms,prefix2).$utms||{}}}else{return{pre1:{},pre2:{}}}};_.getMPScene=function(key){key=String(key);return mp_scene[key]||key};_.setUtm=function(para,prop){var query={};if(para&&_.isObject(para.query)){query=_.extend({},para.query);var scene=query.scene;if(scene){if(scene.indexOf("?")!==-1){scene="?"+scene.replace(/\?/g,"")}else{scene="?"+scene}_.extend(query,_.getObjFromQuery(scene))}if(para.query.q){_.extend(query,_.getObjFromQuery(para.query.q))}}if(para&&_.isObject(para.referrerInfo)&¶.referrerInfo.extraData){var extraQuery={};if(_.isObject(para.referrerInfo.extraData)&&!_.isEmptyObject(para.referrerInfo.extraData)){extraQuery=para.referrerInfo.extraData}else if(_.isJSONString(para.referrerInfo.extraData)){extraQuery=JSON.parse(para.referrerInfo.extraData)}_.extend(query,extraQuery)}var utms=_.getUtm(query,"$","$latest_");_.extend(prop,utms.pre1);return utms};_.info={properties:{$lib:LIB_NAME,$lib_version:String(LIB_VERSION),$user_agent:"SensorsAnalytics MP SDK"},getSystem:function(){var e=this.properties;var that=this;function getNetwork(){wx.getNetworkType({success:function(t){e.$network_type=t["networkType"]},complete:getSystemInfo})}function getSystemInfo(){wx.getSystemInfo({success:function(t){e.$model=t["model"];e.$screen_width=Number(t["windowWidth"]);e.$screen_height=Number(t["windowHeight"]);e.$os=t["system"].split(" ")[0];e.$os_version=t["system"].split(" ")[1]},complete:function(){sa.initialState.systemIsComplete=true;sa.initialState.checkIsComplete()}})}getNetwork()}};sa._=_;sa.prepareData=function(p,callback){var data={distinct_id:this.store.getDistinctId(),lib:{$lib:LIB_NAME,$lib_method:"code",$lib_version:String(LIB_VERSION)},properties:{}};_.extend(data,p);if(_.isObject(p.properties)&&!_.isEmptyObject(p.properties)){_.extend(data.properties,p.properties)}if(!p.type||p.type.slice(0,7)!=="profile"){data.properties=_.extend({},_.info.properties,sa.store.getProps(),data.properties);if(typeof sa.store._state==="object"&&typeof sa.store._state.first_visit_day_time==="number"&&sa.store._state.first_visit_day_time>(new Date).getTime()){data.properties.$is_first_day=true}else{data.properties.$is_first_day=false}}if(data.properties.$time&&_.isDate(data.properties.$time)){data.time=data.properties.$time*1;delete data.properties.$time}else{if(sa.para.use_client_time){data.time=new Date*1}}_.searchObjDate(data);_.searchObjString(data);sa.send(data,callback)};sa.store={storageInfo:null,getUUID:function(){return""+Date.now()+"-"+Math.floor(1e7*Math.random())+"-"+Math.random().toString(16).replace(".","")+"-"+String(Math.random()*31242).replace(".","").slice(0,8)},getStorage:function(){if(this.storageInfo){return this.storageInfo}else{this.storageInfo=wx.getStorageSync("sensorsdata2015_wechat")||"";return this.storageInfo}},_state:{},toState:function(ds){var state=null;if(_.isJSONString(ds)){state=JSON.parse(ds);if(state.distinct_id){this._state=state}else{this.set("distinct_id",this.getUUID())}}else if(_.isObject(ds)){state=ds;if(state.distinct_id){this._state=state}else{this.set("distinct_id",this.getUUID())}}else{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(newp,isCover){var props=this._state.props||{};if(!isCover){_.extend(props,newp);this.set("props",props)}else{this.set("props",newp)}},set:function(name,value){var obj={};if(typeof name==="string"){obj[name]=value}else if(typeof name==="object"){obj=name}this._state=this._state||{};for(var i in obj){this._state[i]=obj[i]}this.save()},change:function(name,value){this._state[name]=value},save:function(){wx.setStorageSync("sensorsdata2015_wechat",this._state)},init:function(){var info=this.getStorage();if(info){this.toState(info)}else{is_first_launch=true;var time=new Date;var visit_time=time.getTime();time.setHours(23);time.setMinutes(59);time.setSeconds(60);this.set({distinct_id:this.getUUID(),first_visit_time:visit_time,first_visit_day_time:time.getTime()})}}};sa.setProfile=function(p,c){sa.prepareData({type:"profile_set",properties:p},c)};sa.setOnceProfile=function(p,c){sa.prepareData({type:"profile_set_once",properties:p},c)};sa.track=function(e,p,c){this.prepareData({type:"track",event:e,properties:p},c)};sa.identify=function(id,isSave){if(typeof id==="number"){id=String(id)}else if(typeof id!=="string"){return false}var firstId=sa.store.getFirstId();if(isSave===true){if(firstId){sa.store.set("first_id",id)}else{sa.store.set("distinct_id",id)}}else{if(firstId){sa.store.change("first_id",id)}else{sa.store.change("distinct_id",id)}}};sa.trackSignup=function(id,e,p,c){sa.prepareData({original_id:sa.store.getFirstId()||sa.store.getDistinctId(),distinct_id:id,type:"track_signup",event:e,properties:p},c);sa.store.set("distinct_id",id)};sa.registerApp=function(obj){if(_.isObject(obj)&&!_.isEmptyObject(obj)){_.info.properties=_.extend(_.info.properties,obj)}};sa.register=function(obj){if(_.isObject(obj)&&!_.isEmptyObject(obj)){sa.store.setProps(obj)}};sa.clearAllRegister=function(){sa.store.setProps({},true)};sa.login=function(id){var firstId=sa.store.getFirstId();var distinctId=sa.store.getDistinctId();if(id!==distinctId){if(firstId){sa.trackSignup(id,"$SignUp")}else{sa.store.set("first_id",distinctId);sa.trackSignup(id,"$SignUp")}}};sa.openid={getRequest:function(callback){wx.login({success:function(res){if(res.code&&sa.para.appid&&sa.para.openid_url){wx.request({url:sa.para.openid_url+"&code="+res.code+"&appid="+sa.para.appid,method:"GET",complete:function(res2){if(_.isObject(res2)&&_.isObject(res2.data)&&res2.data.openid){callback(res2.data.openid)}else{callback()}}})}else{callback()}}})},getWXStorage:function(){var storageInfo=sa.store.getStorage();if(storageInfo&&_.isObject(storageInfo)){return storageInfo.openid}},getOpenid:function(callback){if(!sa.para.appid){callback();return false}var storageId=this.getWXStorage();if(storageId){callback(storageId)}else{this.getRequest(function(openid){if(openid){callback(openid)}})}}};sa.initial=function(){this._.info.getSystem();this.store.init();if(_.isObject(this.para.register)){_.info.properties=_.extend(_.info.properties,this.para.register)}};sa.init=function(){sa.initialState.storeIsComplete=true;sa.initialState.checkIsComplete()};sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib&&_.info.properties.$user_agent){delete _.info.properties.$lib;delete _.info.properties.$user_agent;return _.extend({$url_path:_.getCurrentPath()},_.info.properties,sa.store.getProps())}else{return{}}};_.autoExeQueue=function(){var queue={items:[],enqueue:function(val){this.items.push(val);this.start()},dequeue:function(){return this.items.shift()},getCurrentItem:function(){return this.items[0]},isRun:false,start:function(){if(this.items.length>0&&!this.isRun){this.isRun=true;this.getCurrentItem().start()}},close:function(){this.dequeue();this.isRun=false;this.start()}};return queue};sa.requestQueue=function(para){this.url=para.url};sa.requestQueue.prototype.isEnd=function(){if(!this.received){this.received=true;this.close()}};sa.requestQueue.prototype.start=function(){var me=this;setTimeout(function(){me.isEnd()},300);wx.request({url:this.url,method:"GET",complete:function(){me.isEnd()}})};sa.dataQueue=_.autoExeQueue();sa.send=function(t){var url="";t._nocache=(String(Math.random())+String(Math.random())+String(Math.random())).slice(2,15);logger.info(t);t=JSON.stringify(t);if(sa.para.server_url.indexOf("?")!==-1){url=sa.para.server_url+"&data="+encodeURIComponent(_.base64Encode(t))}else{url=sa.para.server_url+"?data="+encodeURIComponent(_.base64Encode(t))}var instance=new sa.requestQueue({url:url});instance.close=function(){sa.dataQueue.close()};sa.dataQueue.enqueue(instance)};sa.autoTrackCustom=function(api,prop,event){var temp=sa.para.autoTrack[api];var tempFunc="";if(sa.para.autoTrack&&temp){if(typeof temp==="function"){tempFunc=temp();if(_.isObject(tempFunc)){_.extend(prop,tempFunc)}}else if(_.isObject(temp)){_.extend(prop,temp)}sa.track(event,prop)}};sa.setOpenid=function(openid,isCover){sa.store.set("openid",openid);if(isCover){sa.store.set("distinct_id",openid)}else{sa.identify(openid,true)}};sa.initWithOpenid=function(options){options=options||{};sa.openid.getOpenid(function(openid){if(openid){sa.setOpenid(openid,options.isCoverLogin)}sa.init()})};_.each(["setProfile","setOnceProfile","track","register","clearAllRegister","autoTrackCustom","registerApp"],function(method){var temp=sa[method];sa[method]=function(){if(sa.initialState.isComplete){temp.apply(sa,arguments)}else{sa.initialState.queue.push([method,arguments])}}});function e(t,n,o){if(t[n]){var e=t[n];t[n]=function(t){o.call(this,t,n);e.call(this,t)}}else t[n]=function(t){o.call(this,t,n)}}function appLaunch(para){this[sa.para.name]=sa;var prop={};if(para&¶.path){prop.$url_path=para.path}var utms=_.setUtm(para,prop);if(is_first_launch){if(!_.isEmptyObject(utms.pre1)){sa.setOnceProfile(utms.pre1)}}if(!_.isEmptyObject(utms.pre2)){sa.registerApp(utms.pre2)}prop.$scene=_.getMPScene(para.scene);if(sa.para.autoTrack&&sa.para.autoTrack.appLaunch){sa.autoTrackCustom("appLaunch",prop,"$MPLaunch")}}function appShow(para){var prop={};mpshow_time=(new Date).getTime();if(para&¶.path){prop.$url_path=para.path}var utms=_.setUtm(para,prop);if(!_.isEmptyObject(utms.pre2)){sa.registerApp(utms.pre2)}prop.$scene=_.getMPScene(para.scene);if(sa.para.autoTrack&&sa.para.autoTrack.appShow){sa.autoTrackCustom("appShow",prop,"$MPShow")}}function appHide(){var current_time=(new Date).getTime();var prop={};prop.$url_path=_.getCurrentPath();if(mpshow_time&¤t_time-mpshow_time>0&&(current_time-mpshow_time)/36e5<24){prop.event_duration=(current_time-mpshow_time)/1e3}if(sa.para.autoTrack&&sa.para.autoTrack.appHide){sa.autoTrackCustom("appHide",prop,"$MPHide")}}function appError(){}function appUnLaunch(){}var p=App;App=function(t){e(t,"onLaunch",appLaunch);e(t,"onShow",appShow);e(t,"onHide",appHide);p(t)};function pageOnunload(n,e){}function pageOnHide(){}function pageOnReady(){}function pageOnPullDownRefresh(){}function pageOnReachBottom(){}function pageOnShareAppMessage(n,e){}var v=Page;Page=function(t){e(t,"onLoad",function(para){if(para&&_.isObject(para)){var query=_.extend({},para);if(para.q){_.extend(query,_.getObjFromQuery(para.q))}var utms=_.getUtm(query,"$","$latest_");this.sensors_mp_load_utm=utms.pre1}});e(t,"onShow",function(){var router="系统没有取到值";if(typeof this==="object"){if(typeof this.route==="string"){router=this.route}else if(typeof this.__route__==="string"){router=this.__route__}}var prop={};prop.$referrer=sa_referrer;prop.$url_path=router;if(this.sensors_mp_load_utm){_.extend(prop,this.sensors_mp_load_utm);this.sensors_mp_load_utm=null}if(sa.para.onshow){sa.para.onshow(sa,router,this)}else{sa.autoTrackCustom("pageShow",prop,"$MPViewScreen")}sa_referrer=router});v(t)};sa.initial();module.exports=sa; \ No newline at end of file +var _={};var sa={};sa.para=require("sensorsdata_conf.js");if(!sa.para.openid_url){sa.para.openid_url=sa.para.server_url.replace(/\/sa(\.gif){0,1}/,"/mp_login")}var ArrayProto=Array.prototype,FuncProto=Function.prototype,ObjProto=Object.prototype,slice=ArrayProto.slice,toString=ObjProto.toString,hasOwnProperty=ObjProto.hasOwnProperty,LIB_VERSION="1.7",LIB_NAME="MiniProgram";var source_channel_standard="utm_source utm_medium utm_campaign utm_content utm_term";var mp_scene={1001:"发现栏小程序主入口",1005:"顶部搜索框的搜索结果页",1006:"发现栏小程序主入口搜索框的搜索结果页",1007:"单人聊天会话中的小程序消息卡片",1008:"群聊会话中的小程序消息卡片",1011:"扫描二维码",1012:"长按图片识别二维码",1013:"手机相册选取二维码",1014:"小程序模版消息",1017:"前往体验版的入口页",1019:"微信钱包",1020:"公众号 profile 页相关小程序列表",1022:"聊天顶部置顶小程序入口",1023:"安卓系统桌面图标",1024:"小程序 profile 页",1025:"扫描一维码",1026:"附近小程序列表",1027:"顶部搜索框搜索结果页“使用过的小程序”列表",1028:"我的卡包",1029:"卡券详情页",1030:"自动化测试下打开小程序",1031:"长按图片识别一维码",1032:"手机相册选取一维码",1034:"微信支付完成页",1035:"公众号自定义菜单",1036:"App 分享消息卡片",1037:"小程序打开小程序",1038:"从另一个小程序返回",1039:"摇电视",1042:"添加好友搜索框的搜索结果页",1043:"公众号模板消息",1044:"带 shareTicket 的小程序消息卡片(详情)",1047:"扫描小程序码",1048:"长按图片识别小程序码",1049:"手机相册选取小程序码",1052:"卡券的适用门店列表",1053:"搜一搜的结果页",1054:"顶部搜索框小程序快捷入口",1056:"音乐播放器菜单",1057:"钱包中的银行卡详情页",1058:"公众号文章",1059:"体验版小程序绑定邀请页",1064:"微信连Wi-Fi状态栏",1067:"公众号文章广告",1068:"附近小程序列表广告",1071:"钱包中的银行卡列表页",1072:"二维码收款页面",1073:"客服消息列表下发的小程序消息卡片",1074:"公众号会话下发的小程序消息卡片",1078:"连Wi-Fi成功页",1089:"微信聊天主界面下拉",1090:"长按小程序右上角菜单唤出最近使用历史",1092:"城市服务入口"};var sa_referrer="直接打开";var mpshow_time=null;var is_first_launch=false;sa.lib_version=LIB_VERSION;var logger=typeof logger==="object"?logger:{};logger.info=function(){if(sa.para.show_log){if(typeof console==="object"&&console.log){try{return console.log.apply(console,arguments)}catch(e){console.log(arguments[0])}}}};(function(){var nativeBind=FuncProto.bind,nativeForEach=ArrayProto.forEach,nativeIndexOf=ArrayProto.indexOf,nativeIsArray=Array.isArray,breaker={};var each=_.each=function(obj,iterator,context){if(obj==null){return false}if(nativeForEach&&obj.forEach===nativeForEach){obj.forEach(iterator,context)}else if(obj.length===+obj.length){for(var i=0,l=obj.length;isa.para.max_string_length){logger.info("字符串长度超过限制,已经做截取--"+str);return str.slice(0,sa.para.max_string_length)}else{return str}};_.searchObjString=function(o){if(_.isObject(o)){_.each(o,function(a,b){if(_.isObject(a)){_.searchObjString(o[b])}else{if(_.isString(a)){o[b]=_.formatString(a)}}})}};_.unique=function(ar){var temp,n=[],o={};for(var i=0;i127&&c1<2048){enc=String.fromCharCode(c1>>6|192,c1&63|128)}else{enc=String.fromCharCode(c1>>12|224,c1>>6&63|128,c1&63|128)}if(enc!==null){if(end>start){utftext+=string.substring(start,end)}utftext+=enc;start=end=n+1}}if(end>start){utftext+=string.substring(start,string.length)}return utftext};_.base64Encode=function(data){var b64="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";var o1,o2,o3,h1,h2,h3,h4,bits,i=0,ac=0,enc="",tmp_arr=[];if(!data){return data}data=_.utf8Encode(data);do{o1=data.charCodeAt(i++);o2=data.charCodeAt(i++);o3=data.charCodeAt(i++);bits=o1<<16|o2<<8|o3;h1=bits>>18&63;h2=bits>>12&63;h3=bits>>6&63;h4=bits&63;tmp_arr[ac++]=b64.charAt(h1)+b64.charAt(h2)+b64.charAt(h3)+b64.charAt(h4)}while(i0){_.each(this.queue,function(content){sa[content[0]].apply(sa,slice.call(content[1]))});sa.queue=[]}}}};_.getPrefixUtm=function(utms,prefix,prefix_add){prefix=prefix||"";prefix_add=prefix_add||"_";if(!_.isObject(utms)){return{}}var $utms={},otherUtms={};for(var i in utms){if((" "+source_channel_standard+" ").indexOf(" "+i+" ")!==-1){$utms[prefix+i]=utms[i]}else{otherUtms[prefix_add+i]=utms[i]}}return{$utms:$utms,otherUtms:otherUtms}};_.convertObjToParam=function(obj){var arr=[];for(var i in obj){arr.push(i+"="+obj[i])}return arr.join("&")};_.getSource=function(url){if(_.isObject(url)){if(_.isEmptyObject(url)){return{}}else{for(var i in url){if((" "+source_channel_standard+" ").indexOf(" "+i+" ")===-1){delete url[i]}else{url[i]=url[i].replace("?","*")}}url=_.convertObjToParam(url);url="?"+url}}else{url=_.decodeURIComponent(url)}var campagin_w=source_channel_standard.split(" ");var campaign_keywords=source_channel_standard.split(" ");var kw="";var params={};url=url.split("?");if(url.length===2){url=url[1]}else{return{}}url="?"+url;if(_.isArray(sa.para.source_channel)&&sa.para.source_channel.length>0){campaign_keywords=campaign_keywords.concat(sa.para.source_channel);campaign_keywords=_.unique(campaign_keywords)}_.each(campaign_keywords,function(kwkey){kw=_.getQueryParam(url,kwkey);kw=_.decodeURIComponent(kw);if(kw.length){if(_.include(campagin_w,kwkey)){params[kwkey]=kw}}});return params};_.getObjFromQuery=function(str){var query=str.split("?");var arr=[];var obj={};if(query&&query[1]){_.each(query[1].split("&"),function(value){var arr=value.split("=");if(arr[0]&&arr[1]){obj[arr[0]]=arr[1]}})}else{return{}}return obj};_.getUtm=function(url,prefix1,prefix2){var utms=_.getSource(url);var pre1={};var pre2={};if(typeof prefix2==="undefined"&&prefix1){return{pre1:_.getPrefixUtm(utms,prefix1).$utms||{},pre2:{}}}else if(typeof prefix2!=="undefined"&&prefix1){return{pre1:_.getPrefixUtm(utms,prefix1).$utms||{},pre2:_.getPrefixUtm(utms,prefix2).$utms||{}}}else{return{pre1:{},pre2:{}}}};_.getMPScene=function(key){key=String(key);return mp_scene[key]||key};_.setUtm=function(para,prop){var query={};if(para&&_.isObject(para.query)){query=_.extend({},para.query);var scene=query.scene;if(scene){if(scene.indexOf("?")!==-1){scene="?"+scene.replace(/\?/g,"")}else{scene="?"+scene}_.extend(query,_.getObjFromQuery(scene))}if(para.query.q){_.extend(query,_.getObjFromQuery(_.decodeURIComponent(para.query.q)))}}if(para&&_.isObject(para.referrerInfo)&¶.referrerInfo.extraData){var extraQuery={};if(_.isObject(para.referrerInfo.extraData)&&!_.isEmptyObject(para.referrerInfo.extraData)){extraQuery=para.referrerInfo.extraData}else if(_.isJSONString(para.referrerInfo.extraData)){extraQuery=JSON.parse(para.referrerInfo.extraData)}_.extend(query,extraQuery)}var utms=_.getUtm(query,"$","$latest_");_.extend(prop,utms.pre1);return utms};_.info={properties:{$lib:LIB_NAME,$lib_version:String(LIB_VERSION),$user_agent:"SensorsAnalytics MP SDK"},getSystem:function(){var e=this.properties;var that=this;function getNetwork(){wx.getNetworkType({success:function(t){e.$network_type=t["networkType"]},complete:getSystemInfo})}function getSystemInfo(){wx.getSystemInfo({success:function(t){e.$model=t["model"];e.$screen_width=Number(t["windowWidth"]);e.$screen_height=Number(t["windowHeight"]);e.$os=t["system"].split(" ")[0];e.$os_version=t["system"].split(" ")[1]},complete:function(){sa.initialState.systemIsComplete=true;sa.initialState.checkIsComplete()}})}getNetwork()}};sa._=_;sa.prepareData=function(p,callback){var data={distinct_id:this.store.getDistinctId(),lib:{$lib:LIB_NAME,$lib_method:"code",$lib_version:String(LIB_VERSION)},properties:{}};_.extend(data,p);if(_.isObject(p.properties)&&!_.isEmptyObject(p.properties)){_.extend(data.properties,p.properties)}if(!p.type||p.type.slice(0,7)!=="profile"){data.properties=_.extend({},_.info.properties,sa.store.getProps(),data.properties);if(typeof sa.store._state==="object"&&typeof sa.store._state.first_visit_day_time==="number"&&sa.store._state.first_visit_day_time>(new Date).getTime()){data.properties.$is_first_day=true}else{data.properties.$is_first_day=false}}if(data.properties.$time&&_.isDate(data.properties.$time)){data.time=data.properties.$time*1;delete data.properties.$time}else{if(sa.para.use_client_time){data.time=new Date*1}}_.searchObjDate(data);_.searchObjString(data);sa.send(data,callback)};sa.store={storageInfo:null,getUUID:function(){return""+Date.now()+"-"+Math.floor(1e7*Math.random())+"-"+Math.random().toString(16).replace(".","")+"-"+String(Math.random()*31242).replace(".","").slice(0,8)},getStorage:function(){if(this.storageInfo){return this.storageInfo}else{this.storageInfo=wx.getStorageSync("sensorsdata2015_wechat")||"";return this.storageInfo}},_state:{},toState:function(ds){var state=null;if(_.isJSONString(ds)){state=JSON.parse(ds);if(state.distinct_id){this._state=state}else{this.set("distinct_id",this.getUUID())}}else if(_.isObject(ds)){state=ds;if(state.distinct_id){this._state=state}else{this.set("distinct_id",this.getUUID())}}else{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(newp,isCover){var props=this._state.props||{};if(!isCover){_.extend(props,newp);this.set("props",props)}else{this.set("props",newp)}},set:function(name,value){var obj={};if(typeof name==="string"){obj[name]=value}else if(typeof name==="object"){obj=name}this._state=this._state||{};for(var i in obj){this._state[i]=obj[i]}this.save()},change:function(name,value){this._state[name]=value},save:function(){wx.setStorageSync("sensorsdata2015_wechat",this._state)},init:function(){var info=this.getStorage();if(info){this.toState(info)}else{is_first_launch=true;var time=new Date;var visit_time=time.getTime();time.setHours(23);time.setMinutes(59);time.setSeconds(60);this.set({distinct_id:this.getUUID(),first_visit_time:visit_time,first_visit_day_time:time.getTime()})}}};sa.setProfile=function(p,c){sa.prepareData({type:"profile_set",properties:p},c)};sa.setOnceProfile=function(p,c){sa.prepareData({type:"profile_set_once",properties:p},c)};sa.track=function(e,p,c){this.prepareData({type:"track",event:e,properties:p},c)};sa.identify=function(id,isSave){if(typeof id==="number"){id=String(id)}else if(typeof id!=="string"){return false}var firstId=sa.store.getFirstId();if(isSave===true){if(firstId){sa.store.set("first_id",id)}else{sa.store.set("distinct_id",id)}}else{if(firstId){sa.store.change("first_id",id)}else{sa.store.change("distinct_id",id)}}};sa.trackSignup=function(id,e,p,c){sa.prepareData({original_id:sa.store.getFirstId()||sa.store.getDistinctId(),distinct_id:id,type:"track_signup",event:e,properties:p},c);sa.store.set("distinct_id",id)};sa.registerApp=function(obj){if(_.isObject(obj)&&!_.isEmptyObject(obj)){_.info.properties=_.extend(_.info.properties,obj)}};sa.register=function(obj){if(_.isObject(obj)&&!_.isEmptyObject(obj)){sa.store.setProps(obj)}};sa.clearAllRegister=function(){sa.store.setProps({},true)};sa.login=function(id){var firstId=sa.store.getFirstId();var distinctId=sa.store.getDistinctId();if(id!==distinctId){if(firstId){sa.trackSignup(id,"$SignUp")}else{sa.store.set("first_id",distinctId);sa.trackSignup(id,"$SignUp")}}};sa.openid={getRequest:function(callback){wx.login({success:function(res){if(res.code&&sa.para.appid&&sa.para.openid_url){wx.request({url:sa.para.openid_url+"&code="+res.code+"&appid="+sa.para.appid,method:"GET",complete:function(res2){if(_.isObject(res2)&&_.isObject(res2.data)&&res2.data.openid){callback(res2.data.openid)}else{callback()}}})}else{callback()}}})},getWXStorage:function(){var storageInfo=sa.store.getStorage();if(storageInfo&&_.isObject(storageInfo)){return storageInfo.openid}},getOpenid:function(callback){if(!sa.para.appid){callback();return false}var storageId=this.getWXStorage();if(storageId){callback(storageId)}else{this.getRequest(function(openid){if(openid){callback(openid)}})}}};sa.initial=function(){this._.info.getSystem();this.store.init();if(_.isObject(this.para.register)){_.info.properties=_.extend(_.info.properties,this.para.register)}};sa.init=function(){sa.initialState.storeIsComplete=true;sa.initialState.checkIsComplete()};sa.getPresetProperties=function(){if(_.info&&_.info.properties&&_.info.properties.$lib&&_.info.properties.$user_agent){delete _.info.properties.$lib;delete _.info.properties.$user_agent;return _.extend({$url_path:_.getCurrentPath()},_.info.properties,sa.store.getProps())}else{return{}}};_.autoExeQueue=function(){var queue={items:[],enqueue:function(val){this.items.push(val);this.start()},dequeue:function(){return this.items.shift()},getCurrentItem:function(){return this.items[0]},isRun:false,start:function(){if(this.items.length>0&&!this.isRun){this.isRun=true;this.getCurrentItem().start()}},close:function(){this.dequeue();this.isRun=false;this.start()}};return queue};sa.requestQueue=function(para){this.url=para.url};sa.requestQueue.prototype.isEnd=function(){if(!this.received){this.received=true;this.close()}};sa.requestQueue.prototype.start=function(){var me=this;setTimeout(function(){me.isEnd()},300);wx.request({url:this.url,method:"GET",complete:function(){me.isEnd()}})};sa.dataQueue=_.autoExeQueue();sa.send=function(t){var url="";t._nocache=(String(Math.random())+String(Math.random())+String(Math.random())).slice(2,15);logger.info(t);t=JSON.stringify(t);if(sa.para.server_url.indexOf("?")!==-1){url=sa.para.server_url+"&data="+encodeURIComponent(_.base64Encode(t))}else{url=sa.para.server_url+"?data="+encodeURIComponent(_.base64Encode(t))}var instance=new sa.requestQueue({url:url});instance.close=function(){sa.dataQueue.close()};sa.dataQueue.enqueue(instance)};sa.autoTrackCustom=function(api,prop,event){var temp=sa.para.autoTrack[api];var tempFunc="";if(sa.para.autoTrack&&temp){if(typeof temp==="function"){tempFunc=temp();if(_.isObject(tempFunc)){_.extend(prop,tempFunc)}}else if(_.isObject(temp)){_.extend(prop,temp)}sa.track(event,prop)}};sa.setOpenid=function(openid,isCover){sa.store.set("openid",openid);if(isCover){sa.store.set("distinct_id",openid)}else{sa.identify(openid,true)}};sa.initWithOpenid=function(options){options=options||{};sa.openid.getOpenid(function(openid){if(openid){sa.setOpenid(openid,options.isCoverLogin)}sa.init()})};_.each(["setProfile","setOnceProfile","track","register","clearAllRegister","autoTrackCustom","registerApp"],function(method){var temp=sa[method];sa[method]=function(){if(sa.initialState.isComplete){temp.apply(sa,arguments)}else{sa.initialState.queue.push([method,arguments])}}});function e(t,n,o){if(t[n]){var e=t[n];t[n]=function(t){o.call(this,t,n);e.call(this,t)}}else t[n]=function(t){o.call(this,t,n)}}function appLaunch(para){this[sa.para.name]=sa;var prop={};if(para&¶.path){prop.$url_path=para.path}var utms=_.setUtm(para,prop);if(is_first_launch){if(!_.isEmptyObject(utms.pre1)){sa.setOnceProfile(utms.pre1)}}if(!_.isEmptyObject(utms.pre2)){sa.registerApp(utms.pre2)}prop.$scene=_.getMPScene(para.scene);if(sa.para.autoTrack&&sa.para.autoTrack.appLaunch){sa.autoTrackCustom("appLaunch",prop,"$MPLaunch")}}function appShow(para){var prop={};mpshow_time=(new Date).getTime();if(para&¶.path){prop.$url_path=para.path}var utms=_.setUtm(para,prop);if(!_.isEmptyObject(utms.pre2)){sa.registerApp(utms.pre2)}prop.$scene=_.getMPScene(para.scene);if(sa.para.autoTrack&&sa.para.autoTrack.appShow){sa.autoTrackCustom("appShow",prop,"$MPShow")}}function appHide(){var current_time=(new Date).getTime();var prop={};prop.$url_path=_.getCurrentPath();if(mpshow_time&¤t_time-mpshow_time>0&&(current_time-mpshow_time)/36e5<24){prop.event_duration=(current_time-mpshow_time)/1e3}if(sa.para.autoTrack&&sa.para.autoTrack.appHide){sa.autoTrackCustom("appHide",prop,"$MPHide")}}function appError(){}function appUnLaunch(){}var p=App;App=function(t){e(t,"onLaunch",appLaunch);e(t,"onShow",appShow);e(t,"onHide",appHide);p(t)};function pageOnunload(n,e){}function pageOnHide(){}function pageOnReady(){}function pageOnPullDownRefresh(){}function pageOnReachBottom(){}function pageOnShareAppMessage(n,e){}var v=Page;Page=function(t){e(t,"onLoad",function(para){if(para&&_.isObject(para)){var query=_.extend({},para);if(para.q){_.extend(query,_.getObjFromQuery(_.decodeURIComponent(para.q)))}var utms=_.getUtm(query,"$","$latest_");this.sensors_mp_load_utm=utms.pre1}});e(t,"onShow",function(){var router="系统没有取到值";if(typeof this==="object"){if(typeof this.route==="string"){router=this.route}else if(typeof this.__route__==="string"){router=this.__route__}}var prop={};prop.$referrer=sa_referrer;prop.$url_path=router;if(this.sensors_mp_load_utm){_.extend(prop,this.sensors_mp_load_utm);this.sensors_mp_load_utm=null}if(sa.para.onshow){sa.para.onshow(sa,router,this)}else{sa.autoTrackCustom("pageShow",prop,"$MPViewScreen")}sa_referrer=router});v(t)};sa.initial();module.exports=sa; \ No newline at end of file