From ec7786cbfd770e4a9a2b24eee31822e7c7536211 Mon Sep 17 00:00:00 2001 From: com-xubo <13230610263@163.com> Date: Wed, 25 Jul 2018 17:26:27 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=96=84=E5=B0=8F=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E5=86=B7=E5=90=AF=E5=8A=A8=E6=97=B6=EF=BC=8C$MPLaunch=E3=80=81?= =?UTF-8?q?$MPShow=E3=80=81$MPViewScreen=E4=BA=8B=E4=BB=B6=E8=A7=A6?= =?UTF-8?q?=E5=8F=91=E6=97=B6=E9=97=B4=E6=B7=B7=E4=B9=B1=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sensorsdata.js | 4 +- sensorsdata.min.js | 101 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 102 insertions(+), 3 deletions(-) diff --git a/sensorsdata.js b/sensorsdata.js index 89759e7..4e4e25f 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.9', + LIB_VERSION = '1.9.1', LIB_NAME = 'MiniProgram'; var source_channel_standard = 'utm_source utm_medium utm_campaign utm_content utm_term'; @@ -1156,7 +1156,7 @@ sa.requestQueue.prototype.start = function () { var me = this; setTimeout(function () { me.isEnd(); - }, 300); + }, 600); wx.request({ url: this.url, method: 'GET', diff --git a/sensorsdata.min.js b/sensorsdata.min.js index 213633b..86578d1 100755 --- a/sensorsdata.min.js +++ b/sensorsdata.min.js @@ -1 +1,100 @@ -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.9",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 share_depth=0;var share_distinct_id="";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){if(typeof key==="number"||typeof key==="string"&&key!==""){key=String(key);return mp_scene[key]||key}else{return"未取到值"}};_.getShareDepth=function(){if(typeof share_depth==="number"&&share_depth!==0){var current_id=sa.store.getDistinctId();var current_first_id=sa.store.getFirstId();var latest_id=share_distinct_id;if(latest_id&&(latest_id===current_id||latest_id===current_first_id)){return share_depth}else{return share_depth+1}}else{return 1}};_.setShareInfo=function(para,prop){var share={};if(para&&_.isObject(para.query)&¶.query.sampshare){share=_.decodeURIComponent(para.query.sampshare);if(_.isJSONString(share)){share=JSON.parse(share)}else{return{}}}else{return{}}var depth=share.d;var path=share.p;var id=share.i;if(typeof id==="string"){prop.$share_distinct_id=id;share_distinct_id=id}else{prop.$share_distinct_id="取值异常"}if(typeof depth==="number"){prop.$share_depth=depth;share_depth=depth}else{prop.$share_depth="取值异常"}if(typeof path==="string"){prop.$share_url_path=path}else{prop.$share_url_path="取值异常"}};_.getShareInfo=function(){return JSON.stringify({i:sa.store.getDistinctId()||"取值异常",p:_.getCurrentPath(),d:_.getShareDepth()})};_.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}_.setShareInfo(para,prop);var utms=_.setUtm(para,prop);if(is_first_launch){prop.$is_first_time=true;if(!_.isEmptyObject(utms.pre1)){sa.setOnceProfile(utms.pre1)}}else{prop.$is_first_time=false}if(!_.isEmptyObject(utms.pre2)){sa.registerApp(utms.pre2)}prop.$scene=_.getMPScene(para.scene);sa.registerApp({$latest_scene:prop.$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}_.setShareInfo(para,prop);var utms=_.setUtm(para,prop);if(!_.isEmptyObject(utms.pre2)){sa.registerApp(utms.pre2)}prop.$scene=_.getMPScene(para.scene);sa.registerApp({$latest_scene:prop.$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 oldPage=Page;Page=function(option){e(option,"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(option,"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});if(typeof option.onShareAppMessage==="function"){var oldMessage=option.onShareAppMessage;option.onShareAppMessage=function(){if(sa.para.autoTrack&&sa.para.autoTrack.pageShare){sa.autoTrackCustom("pageShare",{$url_path:_.getCurrentPath(),$share_depth:_.getShareDepth()},"$MPShare")}var oldValue=oldMessage.apply(this,arguments);if(sa.para.allow_amend_share_path&&typeof oldValue.path==="string"&&oldValue.path.indexOf("/")!==-1){if(oldValue.path.indexOf("?")===-1){oldValue.path=oldValue.path+"?"}else{if(oldValue.path.slice(-1)!=="&"){oldValue.path=oldValue.path+"&"}}oldValue.path=oldValue.path+"sampshare="+encodeURIComponent(_.getShareInfo())}return oldValue}}oldPage.apply(this,arguments)};sa.initial();module.exports=sa; \ No newline at end of file +function e(e,t,r){if(e[t]){var n=e[t] + e[t]=function(e){r.call(this,e,t),n.call(this,e)}}else e[t]=function(e){r.call(this,e,t)}}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),t.$scene=_.getMPScene(e.scene),sa.registerApp({$latest_scene:t.$scene}),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),t.$scene=_.getMPScene(e.scene),sa.registerApp({$latest_scene:t.$scene}),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&&24>(e-mpshow_time)/36e5&&(t.event_duration=(e-mpshow_time)/1e3),sa.para.autoTrack&&sa.para.autoTrack.appHide&&sa.autoTrackCustom("appHide",t,"$MPHide")}function appError(){}function appUnLaunch(){}function pageOnunload(e,t){}function pageOnHide(){}function pageOnReady(){}function pageOnPullDownRefresh(){}function pageOnReachBottom(){}function pageOnShareAppMessage(e,t){}var _={},sa={} + sa.para=require("sensorsdata_conf.js"),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.9.1",LIB_NAME="MiniProgram",source_channel_standard="utm_source utm_medium utm_campaign utm_content utm_term",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:"城市服务入口"},sa_referrer="直接打开",mpshow_time=null,share_depth=0,share_distinct_id="",is_first_launch=!1 + sa.lib_version=LIB_VERSION + var logger="object"==typeof logger?logger:{} + 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(){var e=(FuncProto.bind,ArrayProto.forEach),t=ArrayProto.indexOf,r=Array.isArray,n={},i=_.each=function(t,r,i){if(null==t)return!1 + if(e&&t.forEach===e)t.forEach(r,i) + else if(t.length===+t.length){for(var s=0,a=t.length;a>s;s++)if(s in t&&r.call(i,t[s],s,t)===n)return!1}else for(var o in t)if(hasOwnProperty.call(t,o)&&r.call(i,t[o],o,t)===n)return!1} + _.logger=logger,_.extend=function(e){return i(slice.call(arguments,1),function(t){for(var r in t)void 0!==t[r]&&(e[r]=t[r])}),e},_.extend2Lev=function(e){return i(slice.call(arguments,1),function(t){for(var r in t)void 0!==t[r]&&(_.isObject(t[r])&&_.isObject(e[r])?_.extend(e[r],t[r]):e[r]=t[r])}),e},_.coverExtend=function(e){return i(slice.call(arguments,1),function(t){for(var r in t)void 0!==t[r]&&void 0===e[r]&&(e[r]=t[r])}),e},_.isArray=r||function(e){return"[object Array]"===toString.call(e)},_.isFunction=function(e){try{return/^\s*\bfunction\b/.test(e)}catch(t){return!1}},_.isArguments=function(e){return!(!e||!hasOwnProperty.call(e,"callee"))},_.toArray=function(e){return e?e.toArray?e.toArray():_.isArray(e)?slice.call(e):_.isArguments(e)?slice.call(e):_.values(e):[]},_.values=function(e){var t=[] + return null==e?t:(i(e,function(e){t[t.length]=e}),t)},_.include=function(e,r){var s=!1 + return null==e?s:t&&e.indexOf===t?-1!=e.indexOf(r):(i(e,function(e){return s||(s=e===r)?n:void 0}),s)}}(),_.trim=function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},_.isObject=function(e){return"[object Object]"==toString.call(e)&&null!=e},_.isEmptyObject=function(e){if(_.isObject(e)){for(var t in e)if(hasOwnProperty.call(e,t))return!1 + return!0}return!1},_.isUndefined=function(e){return void 0===e},_.isString=function(e){return"[object String]"==toString.call(e)},_.isDate=function(e){return"[object Date]"==toString.call(e)},_.isBoolean=function(e){return"[object Boolean]"==toString.call(e)},_.isNumber=function(e){return"[object Number]"==toString.call(e)&&/[\d\.]+/.test(e+"")},_.isJSONString=function(e){try{JSON.parse(e)}catch(t){return!1}return!0},_.decodeURIComponent=function(e){var t="" + try{t=decodeURIComponent(e)}catch(r){t=e}return t},_.encodeDates=function(e){return _.each(e,function(t,r){_.isDate(t)?e[r]=_.formatDate(t):_.isObject(t)&&(e[r]=_.encodeDates(t))}),e},_.formatDate=function(e){function t(e){return 10>e?"0"+e:e}return e.getFullYear()+"-"+t(e.getMonth()+1)+"-"+t(e.getDate())+" "+t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+"."+t(e.getMilliseconds())},_.searchObjDate=function(e){_.isObject(e)&&_.each(e,function(t,r){_.isObject(t)?_.searchObjDate(e[r]):_.isDate(t)&&(e[r]=_.formatDate(t))})},_.formatString=function(e){return e.length>sa.para.max_string_length?(logger.info("字符串长度超过限制,已经做截取--"+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=[],n={},i=0;in;n++){var a=e.charCodeAt(n),o=null + 128>a?r++:o=a>127&&2048>a?String.fromCharCode(a>>6|192,63&a|128):String.fromCharCode(a>>12|224,a>>6&63|128,63&a|128),null!==o&&(r>t&&(i+=e.substring(t,r)),i+=o,t=r=n+1)}return r>t&&(i+=e.substring(t,e.length)),i},_.base64Encode=function(e){var t,r,n,i,s,a,o,c,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",p=0,f=0,l="",h=[] + if(!e)return e + e=_.utf8Encode(e) + do t=e.charCodeAt(p++),r=e.charCodeAt(p++),n=e.charCodeAt(p++),c=t<<16|r<<8|n,i=c>>18&63,s=c>>12&63,a=c>>6&63,o=63&c,h[f++]=u.charAt(i)+u.charAt(s)+u.charAt(a)+u.charAt(o) + while(p0&&(_.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 n={},i={} + for(var s in e)-1!==(" "+source_channel_standard+" ").indexOf(" "+s+" ")?n[t+s]=e[s]:i[r+s]=e[s] + return{$utms:n,otherUtms:i}},_.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=_.convertObjToParam(e),e="?"+e}else e=_.decodeURIComponent(e) + var r=source_channel_standard.split(" "),n=source_channel_standard.split(" "),i="",s={} + return e=e.split("?"),2!==e.length?{}:(e=e[1],e="?"+e,_.isArray(sa.para.source_channel)&&sa.para.source_channel.length>0&&(n=n.concat(sa.para.source_channel),n=_.unique(n)),_.each(n,function(t){i=_.getQueryParam(e,t),i=_.decodeURIComponent(i),i.length&&_.include(r,t)&&(s[t]=i)}),s)},_.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 n=_.getSource(e) + return void 0===r&&t?{pre1:_.getPrefixUtm(n,t).$utms||{},pre2:{}}:void 0!==r&&t?{pre1:_.getPrefixUtm(n,t).$utms||{},pre2:_.getPrefixUtm(n,r).$utms||{}}:{pre1:{},pre2:{}}},_.getMPScene=function(e){return"number"==typeof e||"string"==typeof e&&""!==e?(e+="",mp_scene[e]||e):"未取到值"},_.getShareDepth=function(){if("number"==typeof share_depth&&0!==share_depth){var e=sa.store.getDistinctId(),t=sa.store.getFirstId(),r=share_distinct_id + return!r||r!==e&&r!==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{} + r=JSON.parse(r) + var n=r.d,i=r.p,s=r.i + "string"==typeof s?(t.$share_distinct_id=s,share_distinct_id=s):t.$share_distinct_id="取值异常","number"==typeof n?(t.$share_depth=n,share_depth=n):t.$share_depth="取值异常","string"==typeof i?t.$share_url_path=i:t.$share_url_path="取值异常"},_.getShareInfo=function(){return JSON.stringify({i:sa.store.getDistinctId()||"取值异常",p:_.getCurrentPath(),d:_.getShareDepth()})},_.setUtm=function(e,t){var r={} + if(e&&_.isObject(e.query)){r=_.extend({},e.query) + var n=r.scene + n&&(n=-1!==n.indexOf("?")?"?"+n.replace(/\?/g,""):"?"+n,_.extend(r,_.getObjFromQuery(n))),e.query.q&&_.extend(r,_.getObjFromQuery(_.decodeURIComponent(e.query.q)))}if(e&&_.isObject(e.referrerInfo)&&e.referrerInfo.extraData){var i={} + _.isObject(e.referrerInfo.extraData)&&!_.isEmptyObject(e.referrerInfo.extraData)?i=e.referrerInfo.extraData:_.isJSONString(e.referrerInfo.extraData)&&(i=JSON.parse(e.referrerInfo.extraData)),_.extend(r,i)}var s=_.getUtm(r,"$","$latest_") + return _.extend(t,s.pre1),s},_.info={properties:{$lib:LIB_NAME,$lib_version:LIB_VERSION+"",$user_agent:"SensorsAnalytics MP SDK"},getSystem:function(){function e(){wx.getNetworkType({success:function(e){r.$network_type=e.networkType},complete:t})}function t(){wx.getSystemInfo({success:function(e){r.$model=e.model,r.$screen_width=+e.windowWidth,r.$screen_height=+e.windowHeight,r.$os=e.system.split(" ")[0],r.$os_version=e.system.split(" ")[1]},complete:function(){sa.initialState.systemIsComplete=!0,sa.initialState.checkIsComplete()}})}var r=this.properties + e()}},sa._=_,sa.prepareData=function(e,t){var r={distinct_id:this.store.getDistinctId(),lib:{$lib:LIB_NAME,$lib_method:"code",$lib_version: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(".","")+"-"+(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),t.distinct_id?this._state=t:this.set("distinct_id",this.getUUID())):_.isObject(e)?(t=e,t.distinct_id?this._state=t:this.set("distinct_id",this.getUUID())):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={} + "string"==typeof e?r[e]=t:"object"==typeof e&&(r=e),this._state=this._state||{} + for(var n in r)this._state[n]=r[n] + 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+="" + else if("string"!=typeof e)return!1 + var r=sa.store.getFirstId() + t===!0?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,n){sa.prepareData({original_id:sa.store.getFirstId()||sa.store.getDistinctId(),distinct_id:e,type:"track_signup",event:t,properties:r},n),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() + return e&&_.isObject(e)?e.openid:void 0},getOpenid:function(e){if(!sa.para.appid)return e(),!1 + var t=this.getWXStorage() + t?e(t):this.getRequest(function(t){t&&e(t)})}},sa.initial=function(){this._.info.getSystem(),this.store.init(),_.isObject(this.para.register)&&(_.info.properties=_.extend(_.info.properties,this.para.register))},sa.init=function(){sa.initialState.storeIsComplete=!0,sa.initialState.checkIsComplete()},sa.getPresetProperties=function(){return _.info&&_.info.properties&&_.info.properties.$lib&&_.info.properties.$user_agent?(delete _.info.properties.$lib,delete _.info.properties.$user_agent,_.extend({$url_path:_.getCurrentPath()},_.info.properties,sa.store.getProps())):{}},_.autoExeQueue=function(){var e={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()}} + return e},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()},600),wx.request({url:this.url,method:"GET",complete:function(){e.isEnd()}})},sa.dataQueue=_.autoExeQueue(),sa.send=function(e){var t="" + e._nocache=(Math.random()+""+(Math.random()+"")+(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 n=sa.para.autoTrack[e],i="" + sa.para.autoTrack&&n&&("function"==typeof n?(i=n(),_.isObject(i)&&_.extend(t,i)):_.isObject(n)&&_.extend(t,n),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){e=e||{},sa.openid.getOpenid(function(t){t&&sa.setOpenid(t,e.isCoverLogin),sa.init()})},_.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])}}) + var p=App + App=function(t){e(t,"onLaunch",appLaunch),e(t,"onShow",appShow),e(t,"onHide",appHide),p(t)} + var oldPage=Page + Page=function(t){if(e(t,"onLoad",function(e){if(e&&_.isObject(e)){var t=_.extend({},e) + e.q&&_.extend(t,_.getObjFromQuery(_.decodeURIComponent(e.q))) + var r=_.getUtm(t,"$","$latest_") + this.sensors_mp_load_utm=r.pre1}}),e(t,"onShow",function(){var e="系统没有取到值" + "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,this.sensors_mp_load_utm&&(_.extend(t,this.sensors_mp_load_utm),this.sensors_mp_load_utm=null),sa.para.onshow?sa.para.onshow(sa,e,this):sa.autoTrackCustom("pageShow",t,"$MPViewScreen"),sa_referrer=e}),"function"==typeof t.onShareAppMessage){var r=t.onShareAppMessage + t.onShareAppMessage=function(){sa.para.autoTrack&&sa.para.autoTrack.pageShare&&sa.autoTrackCustom("pageShare",{$url_path:_.getCurrentPath(),$share_depth:_.getShareDepth()},"$MPShare") + var e=r.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}}oldPage.apply(this,arguments)},sa.initial(),module.exports=sa + \ No newline at end of file