@anka-dev/tracker
Advanced tools
Comparing version 0.4.2 to 0.4.3
/** | ||
* @anka-dev/tracker. | ||
* V0.4.2 | ||
* Wed Nov 14 2018 11:26:11 GMT+0800 (CST) | ||
* V0.4.3 | ||
* Wed Nov 14 2018 11:32:56 GMT+0800 (CST) | ||
* https://github.com/iException/anka-tracker#readme | ||
@@ -9,3 +9,3 @@ * MIT License | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Tracker={})}(this,function(t){"use strict";function e(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function n(t,e,n,r){var o,i=arguments.length,a=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(a=(i<3?o(a):i>3?o(e,n,a):o(e,n))||a);return i>3&&a&&Object.defineProperty(e,n,a),a}function r(t){return new Promise(function(e,n){wx.request(f({},t,{success:function(t){t.statusCode>=200&&t.statusCode<300?e&&e(t.data):n&&n(t.data)},fail:function(t){n&&n(t)}}))})}function o(t){return new Promise(function(e,n){wx.setStorage(f({},t,{success:function(t){e(t)},fail:function(t){n(t)}}))})}function i(t){return new Promise(function(e,n){wx.getStorage({key:t,success:function(t){e(t.data)},fail:function(t){n(t)}})})}function a(){return new Promise(function(t,e){wx.getSystemInfo({success:function(e){t(e)},fail:function(t){e(t)}})})}function c(){return new Promise(function(t,e){wx.getNetworkType({success:function(e){t(e.networkType)},fail:function(t){e(t)}})})}function s(t){wx.onNetworkStatusChange(function(e){t(e.networkType)})}function u(t,e,n){var r=t[e];t[e]=function(t){return n.call(this,t),r&&r.call(this,t)}}function p(){return function(t,e,n){return n.writable=!1,n}}const f=Object.assign||function(t){for(var e,n=1;n<arguments.length;n++){e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t};var l,h=function(){function t(t){this.data=[],this.config=t}return t.prototype.get=function(){return i("tracker_tasks").then(function(t){return Promise.resolve(t)}).catch(function(t){return Promise.resolve([])})},t.prototype.update=function(t){return this.data=t,o({key:"tracker_tasks",data:t})},t}(),d={DEBUG:!0,log:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=new Date,r=this.format(n.getHours())+":"+this.format(n.getMinutes())+":"+this.format(n.getSeconds());this.DEBUG&&console.log.apply(console,["%c[🔍 tracker] "+r,"color:rgba(118,147,92,1);"].concat(t))},format:function(t,e){return void 0===t&&(t=""),void 0===e&&(e=2),("00"+t).slice(0-e)}},y=Object.prototype.hasOwnProperty,g=function(){for(var t=[],e=0;e<256;++e)t.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return t}(),m=function(t){for(var e;t.length;){var n=t.pop();if(e=n.obj[n.prop],Array.isArray(e)){for(var r=[],o=0;o<e.length;++o)void 0!==e[o]&&r.push(e[o]);n.obj[n.prop]=r}}return e},v=function(t,e){for(var n=e&&e.plainObjects?Object.create(null):{},r=0;r<t.length;++r)void 0!==t[r]&&(n[r]=t[r]);return n},w={arrayToObject:v,assign:function(t,e){return Object.keys(e).reduce(function(t,n){return t[n]=e[n],t},t)},compact:function(t){for(var e=[{obj:{o:t},prop:"o"}],n=[],r=0;r<e.length;++r)for(var o=e[r],i=o.obj[o.prop],a=Object.keys(i),c=0;c<a.length;++c){var s=a[c],u=i[s];"object"==typeof u&&null!==u&&-1===n.indexOf(u)&&(e.push({obj:i,prop:s}),n.push(u))}return m(e)},decode:function(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch(e){return t}},encode:function(t){if(0===t.length)return t;for(var e="string"==typeof t?t:String(t),n="",r=0;r<e.length;++r){var o=e.charCodeAt(r);45===o||46===o||95===o||126===o||o>=48&&o<=57||o>=65&&o<=90||o>=97&&o<=122?n+=e.charAt(r):o<128?n+=g[o]:o<2048?n+=g[192|o>>6]+g[128|63&o]:o<55296||o>=57344?n+=g[224|o>>12]+g[128|o>>6&63]+g[128|63&o]:(r+=1,o=65536+((1023&o)<<10|1023&e.charCodeAt(r)),n+=g[240|o>>18]+g[128|o>>12&63]+g[128|o>>6&63]+g[128|63&o])}return n},isBuffer:function(t){return null!==t&&void 0!==t&&!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},isRegExp:function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},merge:function t(e,n,r){if(!n)return e;if("object"!=typeof n){if(Array.isArray(e))e.push(n);else{if("object"!=typeof e)return[e,n];(r.plainObjects||r.allowPrototypes||!y.call(Object.prototype,n))&&(e[n]=!0)}return e}if("object"!=typeof e)return[e].concat(n);var o=e;return Array.isArray(e)&&!Array.isArray(n)&&(o=v(e,r)),Array.isArray(e)&&Array.isArray(n)?(n.forEach(function(n,o){y.call(e,o)?e[o]&&"object"==typeof e[o]?e[o]=t(e[o],n,r):e.push(n):e[o]=n}),e):Object.keys(n).reduce(function(e,o){var i=n[o];return y.call(e,o)?e[o]=t(e[o],i,r):e[o]=i,e},o)}},b=String.prototype.replace,k={default:"RFC3986",formatters:{RFC1738:function(t){return b.call(t,/%20/g,"+")},RFC3986:function(t){return t}},RFC1738:"RFC1738",RFC3986:"RFC3986"},O={brackets:function(t){return t+"[]"},indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},S=Date.prototype.toISOString,j={delimiter:"&",encode:!0,encoder:w.encode,encodeValuesOnly:!1,serializeDate:function(t){return S.call(t)},skipNulls:!1,strictNullHandling:!1},P=function t(e,n,r,o,i,a,c,s,u,p,f,l){var h=e;if("function"==typeof c)h=c(n,h);else if(h instanceof Date)h=p(h);else if(null===h){if(o)return a&&!l?a(n,j.encoder):n;h=""}if("string"==typeof h||"number"==typeof h||"boolean"==typeof h||w.isBuffer(h))return a?[f(l?n:a(n,j.encoder))+"="+f(a(h,j.encoder))]:[f(n)+"="+f(String(h))];var d=[];if(void 0===h)return d;var y;if(Array.isArray(c))y=c;else{var g=Object.keys(h);y=s?g.sort(s):g}for(var m=0;m<y.length;++m){var v=y[m];i&&null===h[v]||(d=Array.isArray(h)?d.concat(t(h[v],r(n,v),r,o,i,a,c,s,u,p,f,l)):d.concat(t(h[v],n+(u?"."+v:"["+v+"]"),r,o,i,a,c,s,u,p,f,l)))}return d},_=function(t,e){var n=t,r=e?w.assign({},e):{};if(null!==r.encoder&&void 0!==r.encoder&&"function"!=typeof r.encoder)throw new TypeError("Encoder has to be a function.");var o=void 0===r.delimiter?j.delimiter:r.delimiter,i="boolean"==typeof r.strictNullHandling?r.strictNullHandling:j.strictNullHandling,a="boolean"==typeof r.skipNulls?r.skipNulls:j.skipNulls,c="boolean"==typeof r.encode?r.encode:j.encode,s="function"==typeof r.encoder?r.encoder:j.encoder,u="function"==typeof r.sort?r.sort:null,p=void 0!==r.allowDots&&r.allowDots,f="function"==typeof r.serializeDate?r.serializeDate:j.serializeDate,l="boolean"==typeof r.encodeValuesOnly?r.encodeValuesOnly:j.encodeValuesOnly;if(void 0===r.format)r.format=k.default;else if(!Object.prototype.hasOwnProperty.call(k.formatters,r.format))throw new TypeError("Unknown format option provided.");var h,d,y=k.formatters[r.format];"function"==typeof r.filter?n=(d=r.filter)("",n):Array.isArray(r.filter)&&(h=d=r.filter);var g=[];if("object"!=typeof n||null===n)return"";var m;m=r.arrayFormat in O?r.arrayFormat:"indices"in r?r.indices?"indices":"repeat":"indices";var v=O[m];h||(h=Object.keys(n)),u&&h.sort(u);for(var b=0;b<h.length;++b){var S=h[b];a&&null===n[S]||(g=g.concat(P(n[S],S,v,i,a,c?s:null,d,u,p,f,y,l)))}var _=g.join(o),D=!0===r.addQueryPrefix?"?":"";return _.length>0?D+_:""},D=Object.prototype.hasOwnProperty,L={allowDots:!1,allowPrototypes:!1,arrayLimit:20,decoder:w.decode,delimiter:"&",depth:5,parameterLimit:1e3,plainObjects:!1,strictNullHandling:!1},C=function(t,e){for(var n={},r=e.ignoreQueryPrefix?t.replace(/^\?/,""):t,o=e.parameterLimit===1/0?void 0:e.parameterLimit,i=r.split(e.delimiter,o),a=0;a<i.length;++a){var c,s,u=i[a],p=u.indexOf("]="),f=-1===p?u.indexOf("="):p+1;-1===f?(c=e.decoder(u,L.decoder),s=e.strictNullHandling?null:""):(c=e.decoder(u.slice(0,f),L.decoder),s=e.decoder(u.slice(f+1),L.decoder)),D.call(n,c)?n[c]=[].concat(n[c]).concat(s):n[c]=s}return n},N=function(t,e,n){for(var r=e,o=t.length-1;o>=0;--o){var i,a=t[o];if("[]"===a)i=(i=[]).concat(r);else{i=n.plainObjects?Object.create(null):{};var c="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,s=parseInt(c,10);!isNaN(s)&&a!==c&&String(s)===c&&s>=0&&n.parseArrays&&s<=n.arrayLimit?(i=[])[s]=r:i[c]=r}r=i}return r},x=function(t,e,n){if(t){var r=n.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,o=/(\[[^[\]]*])/g,i=/(\[[^[\]]*])/.exec(r),a=i?r.slice(0,i.index):r,c=[];if(a){if(!n.plainObjects&&D.call(Object.prototype,a)&&!n.allowPrototypes)return;c.push(a)}for(var s=0;null!==(i=o.exec(r))&&s<n.depth;){if(s+=1,!n.plainObjects&&D.call(Object.prototype,i[1].slice(1,-1))&&!n.allowPrototypes)return;c.push(i[1])}return i&&c.push("["+r.slice(i.index)+"]"),N(c,e,n)}},A={formats:k,parse:function(t,e){var n=e?w.assign({},e):{};if(null!==n.decoder&&void 0!==n.decoder&&"function"!=typeof n.decoder)throw new TypeError("Decoder has to be a function.");if(n.ignoreQueryPrefix=!0===n.ignoreQueryPrefix,n.delimiter="string"==typeof n.delimiter||w.isRegExp(n.delimiter)?n.delimiter:L.delimiter,n.depth="number"==typeof n.depth?n.depth:L.depth,n.arrayLimit="number"==typeof n.arrayLimit?n.arrayLimit:L.arrayLimit,n.parseArrays=!1!==n.parseArrays,n.decoder="function"==typeof n.decoder?n.decoder:L.decoder,n.allowDots="boolean"==typeof n.allowDots?n.allowDots:L.allowDots,n.plainObjects="boolean"==typeof n.plainObjects?n.plainObjects:L.plainObjects,n.allowPrototypes="boolean"==typeof n.allowPrototypes?n.allowPrototypes:L.allowPrototypes,n.parameterLimit="number"==typeof n.parameterLimit?n.parameterLimit:L.parameterLimit,n.strictNullHandling="boolean"==typeof n.strictNullHandling?n.strictNullHandling:L.strictNullHandling,""===t||null===t||void 0===t)return n.plainObjects?Object.create(null):{};for(var r="string"==typeof t?C(t,n):t,o=n.plainObjects?Object.create(null):{},i=Object.keys(r),a=0;a<i.length;++a){var c=i[a],s=x(c,r[c],n);o=w.merge(o,s,n)}return w.compact(o)},stringify:_},E=A.stringify,I=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e(n,t),n.prototype.getCommonData=function(t){var e=this,n=t.onLaunchOption,r=void 0===n?{}:n;return Promise.all([this.getTrackId(),a(),c()]).then(function(t){var n=t[0],o=t[1],i=t[2],a=o.system.split(/\s+/),c=A.stringify(r.query),s={__debug:1,sdk_version:"0.4.2",model:o.model,os:a[0],os_version:a[1],network_type:i,env_version:o.version,ip:"",app_type:"wx",app_id:"",app_name:"",template_version:"",app_category:"",source:r.scene,source_path:r.path||"",source_app_id:r.referrerInfo?r.referrerInfo.appId||"":"",source_params:c,source_src_key:r.query?r.query[e.config.sourceSrcKey]||"":"",track_id:n};return Promise.resolve(s)})},n.prototype.getTrackId=function(){var t=this;return i(this.config.trackIdKey).then(function(t){return Promise.resolve(t)}).catch(function(e){return t.setTrackId()})},n.prototype.setTrackId=function(){var t=this,e=this.genUUId();return o({key:this.config.trackIdKey,data:e}).then(function(){return Promise.resolve(e)},function(){return o({key:t.config.trackIdKey,data:e}),Promise.resolve(e)})},n.prototype.genUUId=function(){return Date.now()+"-"+Math.floor(1e7*Math.random())+"-"+Math.random().toString(16).replace(".","")+"-"+String(31242*Math.random()).replace(".","").slice(0,8)},n}(function(){function t(t){this.config=t}return t.validate=function(t,e){var n={required:[],optional:[]};for(var r in e)e.hasOwnProperty(r)&&!t[r]&&n[1===e[r]?"required":"optional"].push(r);return n},t}()),U=function(){function t(t,e){this.url=t.trackerHost,this.config=t,this.commonData=e}return t.prototype.send=function(t){var e=this.url,n=f({},this.commonData,t.data);if(this.config.attachActionToUrl){var o=n.action||"";e=/\/$/.test(this.url)?""+this.url+o:this.url+"/"+o}return"function"==typeof this.config.beforeSend&&(n=this.config.beforeSend(n)),d.log("打点数据校验结果:",t,I.validate(n,this.config.dataScheme)),r({url:e,method:this.config.httpMethod,data:n}).then(function(){return t.isSucceed(),Promise.resolve(t)}).catch(function(){return t.isFailed(),Promise.resolve(t)})},t}(),q=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e(n,t),n.prototype.getNetworkStatus=function(){return c().then(function(t){return Promise.resolve(t)},function(t){return console.error("[tracker] 获取网络状态失败",t),Promise.resolve("none")})},n.prototype.watchNetworkStatusChange=function(t){s(t)},n}(function(){function t(t){this.config=t}return t}());!function(t){t[t.SUCCESS=-1]="SUCCESS",t[t.PENDING=0]="PENDING",t[t.FAILED=1]="FAILED"}(l||(l={}));var T,M=function(){function t(t){var e=Date.now();this._id=Math.random().toString(16).replace(".",""),this.status=l.PENDING,this.data=t,this.timestamp=e}return t.prototype.isSucceed=function(){this.status=l.SUCCESS},t.prototype.isFailed=function(){this.status++},t}();!function(t){t[t.IDLE=0]="IDLE",t[t.PAUSE=1]="PAUSE",t[t.RUNNING=2]="RUNNING"}(T||(T={}));var R=function(){function t(t){this.queue=[],this.failedQueue=[],this.config=t,this.lastStoreUpdate=0,this.executor=new F}return t.prototype.init=function(t){var e=this;this.sender||(this.store=t.store,this.sender=t.sender,this.executor.init(this.sender,this),this.store.get().then(function(t){var n;(n=e.queue).push.apply(n,t.map(function(t){return new M(t.data)})),e.run()}))},t.prototype.push=function(t){t.status===l.PENDING&&this.queue.length<this.config.queueMaxLength?(this.queue.push(t),this.updateStore(),this.run()):t.status>=l.FAILED&&t.status<=this.config.retry&&(this.failedQueue.push(t),this.updateStore(),this.run())},t.prototype.intrude=function(t){this.sender.send(t)},t.prototype.pop=function(){var t=this.failedQueue.length,e=this.config.groupMaxLength,n=t-e>=0?this.failedQueue.splice(0,e):this.failedQueue.splice(0,t).concat(this.queue.splice(0,e-t));return this.updateStore(),n},t.prototype.updateStore=function(t){var e=Date.now();(this.store&&e-this.lastStoreUpdate>=500||t&&this.store)&&(this.store.update(this.queue.concat(this.failedQueue)),this.lastStoreUpdate=e)},t.prototype.run=function(){setTimeout(this.executor.run.bind(this.executor),0)},t.prototype.suspend=function(t){this.updateStore(!0),this.executor.suspend(t)},t}(),F=function(){function t(){this.status=T.IDLE}return Object.defineProperty(t.prototype,"isIdle",{get:function(){return this.sender&&this.queueManager&&this.status===T.IDLE},enumerable:!0,configurable:!0}),t.prototype.init=function(t,e){this.sender=t,this.queueManager=e},t.prototype.run=function(){this.isIdle&&this.exec()},t.prototype.exec=function(){var t=this,e=this.queueManager.pop();if(!e.length)return void(this.status=T.IDLE);this.status=T.RUNNING,Promise.all(e.map(function(e){return t.sender.send(e)})).then(function(e){e.forEach(function(e){e.status!==l.SUCCESS&&t.queueManager.push(e)})}).then(function(){t.timer=setTimeout(function(){t.exec()},t.queueManager.config.interval)})},t.prototype.suspend=function(t){t?(this.status=T.PAUSE,clearTimeout(this.timer)):this.status===T.PAUSE?(this.status=T.IDLE,this.run()):this.status===T.IDLE&&this.run()},t}(),H=function(){function t(t){this.config=t,this.queueManager=new R(this.config)}return t.prototype.init=function(t){this.queueManager.init(f({},t))},t.prototype.log=function(t){this.queueManager.push(t)},t.prototype.forceLog=function(t){this.queueManager.intrude(t)},t}(),K={debug:!0,httpMethod:"POST",retry:2,interval:1e3,groupMaxLength:5,timestampKey:"timestamp_ms",trackIdKey:"__track_id",queueMaxLength:500,commonData:{},dataScheme:{},sourceSrcKey:"src",detectChanel:!0,detectAppStart:!0,attachActionToUrl:!1},G=function(){function t(t){void 0===t&&(t={}),Object.assign(this,K,t)}return t}(),Q=function(){function t(t){void 0===t&&(t={}),this.config=new G(t),this.core=new H(this.config),d.DEBUG=this.config.debug,this.core.queueManager.suspend(!0),this.networkDetector=new q(this.config),this.commonDataVendor=new I(this.config)}return t.prototype.init=function(t){if(!this.sender){var e=this.handleNetworkStatusChange.bind(this);this.sender=new U(this.config,t),this.store=new h(this.config),this.core.init({sender:this.sender,store:this.store}),this.networkDetector.getNetworkStatus().then(e,e),this.networkDetector.watchNetworkStatusChange(e),d.log("初始化完成")}},t.prototype.handleNetworkStatusChange=function(t){var e="none"===t||t instanceof Error;this.core.queueManager.suspend(e)},t.prototype.log=function(t){var e=Date.now();t[this.config.timestampKey]=e,this.core.log(new M(t))},t.prototype.forceLog=function(t){var e=Date.now();t[this.config.timestampKey]=e,this.core.forceLog(new M(t))},n([p()],t.prototype,"init",null),n([p()],t.prototype,"handleNetworkStatusChange",null),n([p()],t.prototype,"log",null),n([p()],t.prototype,"forceLog",null),t}(),B=function(t){function r(){return null!==t&&t.apply(this,arguments)||this}return e(r,t),r.generateTrackerInstance=function(t){var e={};try{var n=require("./anka-tracker.config.js");Object.assign(e,n)}catch(e){!t&&console.log("缺少配置文件 anka-tracker.config.js",e)}t&&Object.assign(e,t);var o=new r(e);if("undefined"!=typeof App&&"undefined"!=typeof Page){var i=App,a=Page;App=function(t){return u(t,"onLaunch",function(t){o.onLaunchOption=t,o.config.detectChanel&&o.detectChanel(t.query[o.config.sourceSrcKey])}),o.config.detectAppStart&&u(t,"onShow",function(t){o.evt("app_start",{})}),i(t)},Page=function(t){return u(t,"onLoad",function(t){this.__page_params__=t}),"function"==typeof o.config.autoPageView&&u(t,"onShow",function(){var t=getCurrentPages().slice().pop();o.config.autoPageView(t,function(e){o.pv(e.action,e,{page_id:t.route,page_url:t.route,page_params:E(t.__page_params__)})})}),a(t)}}else"undefined"!=typeof wx&&wx.getLaunchOptionsSync?(o.onLaunchOption=wx.getLaunchOptionsSync(),o.config.detectChanel&&o.detectChanel(o.onLaunchOption.query[o.config.sourceSrcKey]),console.log("当前处于小游戏环境!")):console.log("anka-tracker无法再当前环境运行!");return o},r.prototype.asyncInitWithCommonData=function(t){var e=this;return void 0===t&&(t={}),this.commonDataVendor.getCommonData({onLaunchOption:this.onLaunchOption}).then(function(n){e.init(Object.assign(n,e.config.commonData,t))}).catch(function(t){d.log("初始化失败"),console.log(t)})},r.prototype.detectChanel=function(t){if(t){var e={};t.split(/_+/).forEach(function(t,n){e["source_src_key_"+(n+1)]=t}),this.evt("channel",e)}},r.prototype.composeCommonData=function(t){var e=[];return t.map(function(t){"function"==typeof t?e.push(new Promise(function(e){t(e)})):e.push(Promise.resolve(t))}),Promise.all(e).then(function(t){return Promise.resolve(Object.assign.apply(Object,[{}].concat(t)))})},r.prototype.track=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];this.composeCommonData(e).then(function(e){return t.log(e)})},r.prototype.forceTrack=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];this.composeCommonData(e).then(function(e){return t.forceLog(e)})},r.prototype.evt=function(t){void 0===t&&(t="");for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(!t)throw new Error("缺少 action 参数");this.track.apply(this,e.concat([{action:t,tracktype:"event"}]))},r.prototype.forceEvt=function(t){void 0===t&&(t="");for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(!t)throw new Error("缺少 action 参数");this.forceTrack.apply(this,e.concat([{action:t,tracktype:"event"}]))},r.prototype.pv=function(t){var e=this;void 0===t&&(t="");for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];this.composeCommonData(n).then(function(n){e.log(Object.assign(n,e.genLastPageUrl(n),{action:t,tracktype:"pageview"}))})},r.prototype.genLastPageUrl=function(t){var e=this,n=e.last_page_id,r=void 0===n?"":n,o=e.last_page_url,i=void 0===o?"":o;return this.last_page_url=t.page_url||"",this.last_page_id=t.page_id||"",{last_page_id:r,last_page_url:i}},n([p()],r.prototype,"asyncInitWithCommonData",null),n([p()],r.prototype,"detectChanel",null),n([p()],r.prototype,"composeCommonData",null),n([p()],r.prototype,"track",null),n([p()],r.prototype,"forceTrack",null),n([p()],r.prototype,"evt",null),n([p()],r.prototype,"forceEvt",null),n([p()],r.prototype,"pv",null),n([p()],r.prototype,"genLastPageUrl",null),r}(Q),V=B.generateTrackerInstance({});t.Tracker=Q,t.BxTracker=B,t.tracker=V,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.Tracker={})}(this,function(t){"use strict";function e(t,e){function n(){this.constructor=t}for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function n(t,e,n,r){var o,i=arguments.length,a=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(a=(i<3?o(a):i>3?o(e,n,a):o(e,n))||a);return i>3&&a&&Object.defineProperty(e,n,a),a}function r(t){return new Promise(function(e,n){wx.request(f({},t,{success:function(t){t.statusCode>=200&&t.statusCode<300?e&&e(t.data):n&&n(t.data)},fail:function(t){n&&n(t)}}))})}function o(t){return new Promise(function(e,n){wx.setStorage(f({},t,{success:function(t){e(t)},fail:function(t){n(t)}}))})}function i(t){return new Promise(function(e,n){wx.getStorage({key:t,success:function(t){e(t.data)},fail:function(t){n(t)}})})}function a(){return new Promise(function(t,e){wx.getSystemInfo({success:function(e){t(e)},fail:function(t){e(t)}})})}function c(){return new Promise(function(t,e){wx.getNetworkType({success:function(e){t(e.networkType)},fail:function(t){e(t)}})})}function s(t){wx.onNetworkStatusChange(function(e){t(e.networkType)})}function u(t,e,n){var r=t[e];t[e]=function(t){return n.call(this,t),r&&r.call(this,t)}}function p(){return function(t,e,n){return n.writable=!1,n}}const f=Object.assign||function(t){for(var e,n=1;n<arguments.length;n++){e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t};var l,h=function(){function t(t){this.data=[],this.config=t}return t.prototype.get=function(){return i("tracker_tasks").then(function(t){return Promise.resolve(t)}).catch(function(t){return Promise.resolve([])})},t.prototype.update=function(t){return this.data=t,o({key:"tracker_tasks",data:t})},t}(),d={DEBUG:!0,log:function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n=new Date,r=this.format(n.getHours())+":"+this.format(n.getMinutes())+":"+this.format(n.getSeconds());this.DEBUG&&console.log.apply(console,["%c[🔍 tracker] "+r,"color:rgba(118,147,92,1);"].concat(t))},format:function(t,e){return void 0===t&&(t=""),void 0===e&&(e=2),("00"+t).slice(0-e)}},y=Object.prototype.hasOwnProperty,g=function(){for(var t=[],e=0;e<256;++e)t.push("%"+((e<16?"0":"")+e.toString(16)).toUpperCase());return t}(),m=function(t){for(var e;t.length;){var n=t.pop();if(e=n.obj[n.prop],Array.isArray(e)){for(var r=[],o=0;o<e.length;++o)void 0!==e[o]&&r.push(e[o]);n.obj[n.prop]=r}}return e},v=function(t,e){for(var n=e&&e.plainObjects?Object.create(null):{},r=0;r<t.length;++r)void 0!==t[r]&&(n[r]=t[r]);return n},w={arrayToObject:v,assign:function(t,e){return Object.keys(e).reduce(function(t,n){return t[n]=e[n],t},t)},compact:function(t){for(var e=[{obj:{o:t},prop:"o"}],n=[],r=0;r<e.length;++r)for(var o=e[r],i=o.obj[o.prop],a=Object.keys(i),c=0;c<a.length;++c){var s=a[c],u=i[s];"object"==typeof u&&null!==u&&-1===n.indexOf(u)&&(e.push({obj:i,prop:s}),n.push(u))}return m(e)},decode:function(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch(e){return t}},encode:function(t){if(0===t.length)return t;for(var e="string"==typeof t?t:String(t),n="",r=0;r<e.length;++r){var o=e.charCodeAt(r);45===o||46===o||95===o||126===o||o>=48&&o<=57||o>=65&&o<=90||o>=97&&o<=122?n+=e.charAt(r):o<128?n+=g[o]:o<2048?n+=g[192|o>>6]+g[128|63&o]:o<55296||o>=57344?n+=g[224|o>>12]+g[128|o>>6&63]+g[128|63&o]:(r+=1,o=65536+((1023&o)<<10|1023&e.charCodeAt(r)),n+=g[240|o>>18]+g[128|o>>12&63]+g[128|o>>6&63]+g[128|63&o])}return n},isBuffer:function(t){return null!==t&&void 0!==t&&!!(t.constructor&&t.constructor.isBuffer&&t.constructor.isBuffer(t))},isRegExp:function(t){return"[object RegExp]"===Object.prototype.toString.call(t)},merge:function t(e,n,r){if(!n)return e;if("object"!=typeof n){if(Array.isArray(e))e.push(n);else{if("object"!=typeof e)return[e,n];(r.plainObjects||r.allowPrototypes||!y.call(Object.prototype,n))&&(e[n]=!0)}return e}if("object"!=typeof e)return[e].concat(n);var o=e;return Array.isArray(e)&&!Array.isArray(n)&&(o=v(e,r)),Array.isArray(e)&&Array.isArray(n)?(n.forEach(function(n,o){y.call(e,o)?e[o]&&"object"==typeof e[o]?e[o]=t(e[o],n,r):e.push(n):e[o]=n}),e):Object.keys(n).reduce(function(e,o){var i=n[o];return y.call(e,o)?e[o]=t(e[o],i,r):e[o]=i,e},o)}},b=String.prototype.replace,k={default:"RFC3986",formatters:{RFC1738:function(t){return b.call(t,/%20/g,"+")},RFC3986:function(t){return t}},RFC1738:"RFC1738",RFC3986:"RFC3986"},O={brackets:function(t){return t+"[]"},indices:function(t,e){return t+"["+e+"]"},repeat:function(t){return t}},S=Date.prototype.toISOString,j={delimiter:"&",encode:!0,encoder:w.encode,encodeValuesOnly:!1,serializeDate:function(t){return S.call(t)},skipNulls:!1,strictNullHandling:!1},P=function t(e,n,r,o,i,a,c,s,u,p,f,l){var h=e;if("function"==typeof c)h=c(n,h);else if(h instanceof Date)h=p(h);else if(null===h){if(o)return a&&!l?a(n,j.encoder):n;h=""}if("string"==typeof h||"number"==typeof h||"boolean"==typeof h||w.isBuffer(h))return a?[f(l?n:a(n,j.encoder))+"="+f(a(h,j.encoder))]:[f(n)+"="+f(String(h))];var d=[];if(void 0===h)return d;var y;if(Array.isArray(c))y=c;else{var g=Object.keys(h);y=s?g.sort(s):g}for(var m=0;m<y.length;++m){var v=y[m];i&&null===h[v]||(d=Array.isArray(h)?d.concat(t(h[v],r(n,v),r,o,i,a,c,s,u,p,f,l)):d.concat(t(h[v],n+(u?"."+v:"["+v+"]"),r,o,i,a,c,s,u,p,f,l)))}return d},_=function(t,e){var n=t,r=e?w.assign({},e):{};if(null!==r.encoder&&void 0!==r.encoder&&"function"!=typeof r.encoder)throw new TypeError("Encoder has to be a function.");var o=void 0===r.delimiter?j.delimiter:r.delimiter,i="boolean"==typeof r.strictNullHandling?r.strictNullHandling:j.strictNullHandling,a="boolean"==typeof r.skipNulls?r.skipNulls:j.skipNulls,c="boolean"==typeof r.encode?r.encode:j.encode,s="function"==typeof r.encoder?r.encoder:j.encoder,u="function"==typeof r.sort?r.sort:null,p=void 0!==r.allowDots&&r.allowDots,f="function"==typeof r.serializeDate?r.serializeDate:j.serializeDate,l="boolean"==typeof r.encodeValuesOnly?r.encodeValuesOnly:j.encodeValuesOnly;if(void 0===r.format)r.format=k.default;else if(!Object.prototype.hasOwnProperty.call(k.formatters,r.format))throw new TypeError("Unknown format option provided.");var h,d,y=k.formatters[r.format];"function"==typeof r.filter?n=(d=r.filter)("",n):Array.isArray(r.filter)&&(h=d=r.filter);var g=[];if("object"!=typeof n||null===n)return"";var m;m=r.arrayFormat in O?r.arrayFormat:"indices"in r?r.indices?"indices":"repeat":"indices";var v=O[m];h||(h=Object.keys(n)),u&&h.sort(u);for(var b=0;b<h.length;++b){var S=h[b];a&&null===n[S]||(g=g.concat(P(n[S],S,v,i,a,c?s:null,d,u,p,f,y,l)))}var _=g.join(o),D=!0===r.addQueryPrefix?"?":"";return _.length>0?D+_:""},D=Object.prototype.hasOwnProperty,L={allowDots:!1,allowPrototypes:!1,arrayLimit:20,decoder:w.decode,delimiter:"&",depth:5,parameterLimit:1e3,plainObjects:!1,strictNullHandling:!1},C=function(t,e){for(var n={},r=e.ignoreQueryPrefix?t.replace(/^\?/,""):t,o=e.parameterLimit===1/0?void 0:e.parameterLimit,i=r.split(e.delimiter,o),a=0;a<i.length;++a){var c,s,u=i[a],p=u.indexOf("]="),f=-1===p?u.indexOf("="):p+1;-1===f?(c=e.decoder(u,L.decoder),s=e.strictNullHandling?null:""):(c=e.decoder(u.slice(0,f),L.decoder),s=e.decoder(u.slice(f+1),L.decoder)),D.call(n,c)?n[c]=[].concat(n[c]).concat(s):n[c]=s}return n},N=function(t,e,n){for(var r=e,o=t.length-1;o>=0;--o){var i,a=t[o];if("[]"===a)i=(i=[]).concat(r);else{i=n.plainObjects?Object.create(null):{};var c="["===a.charAt(0)&&"]"===a.charAt(a.length-1)?a.slice(1,-1):a,s=parseInt(c,10);!isNaN(s)&&a!==c&&String(s)===c&&s>=0&&n.parseArrays&&s<=n.arrayLimit?(i=[])[s]=r:i[c]=r}r=i}return r},x=function(t,e,n){if(t){var r=n.allowDots?t.replace(/\.([^.[]+)/g,"[$1]"):t,o=/(\[[^[\]]*])/g,i=/(\[[^[\]]*])/.exec(r),a=i?r.slice(0,i.index):r,c=[];if(a){if(!n.plainObjects&&D.call(Object.prototype,a)&&!n.allowPrototypes)return;c.push(a)}for(var s=0;null!==(i=o.exec(r))&&s<n.depth;){if(s+=1,!n.plainObjects&&D.call(Object.prototype,i[1].slice(1,-1))&&!n.allowPrototypes)return;c.push(i[1])}return i&&c.push("["+r.slice(i.index)+"]"),N(c,e,n)}},A={formats:k,parse:function(t,e){var n=e?w.assign({},e):{};if(null!==n.decoder&&void 0!==n.decoder&&"function"!=typeof n.decoder)throw new TypeError("Decoder has to be a function.");if(n.ignoreQueryPrefix=!0===n.ignoreQueryPrefix,n.delimiter="string"==typeof n.delimiter||w.isRegExp(n.delimiter)?n.delimiter:L.delimiter,n.depth="number"==typeof n.depth?n.depth:L.depth,n.arrayLimit="number"==typeof n.arrayLimit?n.arrayLimit:L.arrayLimit,n.parseArrays=!1!==n.parseArrays,n.decoder="function"==typeof n.decoder?n.decoder:L.decoder,n.allowDots="boolean"==typeof n.allowDots?n.allowDots:L.allowDots,n.plainObjects="boolean"==typeof n.plainObjects?n.plainObjects:L.plainObjects,n.allowPrototypes="boolean"==typeof n.allowPrototypes?n.allowPrototypes:L.allowPrototypes,n.parameterLimit="number"==typeof n.parameterLimit?n.parameterLimit:L.parameterLimit,n.strictNullHandling="boolean"==typeof n.strictNullHandling?n.strictNullHandling:L.strictNullHandling,""===t||null===t||void 0===t)return n.plainObjects?Object.create(null):{};for(var r="string"==typeof t?C(t,n):t,o=n.plainObjects?Object.create(null):{},i=Object.keys(r),a=0;a<i.length;++a){var c=i[a],s=x(c,r[c],n);o=w.merge(o,s,n)}return w.compact(o)},stringify:_},E=A.stringify,I=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e(n,t),n.prototype.getCommonData=function(t){var e=this,n=t.onLaunchOption,r=void 0===n?{}:n;return Promise.all([this.getTrackId(),a(),c()]).then(function(t){var n=t[0],o=t[1],i=t[2],a=o.system.split(/\s+/),c=A.stringify(r.query),s={__debug:1,sdk_version:"0.4.3",model:o.model,os:a[0],os_version:a[1],network_type:i,env_version:o.version,ip:"",app_type:"wx",app_id:"",app_name:"",template_version:"",app_category:"",source:r.scene,source_path:r.path||"",source_app_id:r.referrerInfo?r.referrerInfo.appId||"":"",source_params:c,source_src_key:r.query?r.query[e.config.sourceSrcKey]||"":"",track_id:n};return Promise.resolve(s)})},n.prototype.getTrackId=function(){var t=this;return i(this.config.trackIdKey).then(function(t){return Promise.resolve(t)}).catch(function(e){return t.setTrackId()})},n.prototype.setTrackId=function(){var t=this,e=this.genUUId();return o({key:this.config.trackIdKey,data:e}).then(function(){return Promise.resolve(e)},function(){return o({key:t.config.trackIdKey,data:e}),Promise.resolve(e)})},n.prototype.genUUId=function(){return Date.now()+"-"+Math.floor(1e7*Math.random())+"-"+Math.random().toString(16).replace(".","")+"-"+String(31242*Math.random()).replace(".","").slice(0,8)},n}(function(){function t(t){this.config=t}return t.validate=function(t,e){var n={required:[],optional:[]};for(var r in e)e.hasOwnProperty(r)&&!t[r]&&n[1===e[r]?"required":"optional"].push(r);return n},t}()),U=function(){function t(t,e){this.url=t.trackerHost,this.config=t,this.commonData=e}return t.prototype.send=function(t){var e=this.url,n=f({},this.commonData,t.data);if(this.config.attachActionToUrl){var o=n.action||"";e=/\/$/.test(this.url)?""+this.url+o:this.url+"/"+o}return"function"==typeof this.config.beforeSend&&(n=this.config.beforeSend(n)),d.log("打点数据校验结果:",t,I.validate(n,this.config.dataScheme)),r({url:e,method:this.config.httpMethod,data:n}).then(function(){return t.isSucceed(),Promise.resolve(t)}).catch(function(){return t.isFailed(),Promise.resolve(t)})},t}(),q=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return e(n,t),n.prototype.getNetworkStatus=function(){return c().then(function(t){return Promise.resolve(t)},function(t){return console.error("[tracker] 获取网络状态失败",t),Promise.resolve("none")})},n.prototype.watchNetworkStatusChange=function(t){s(t)},n}(function(){function t(t){this.config=t}return t}());!function(t){t[t.SUCCESS=-1]="SUCCESS",t[t.PENDING=0]="PENDING",t[t.FAILED=1]="FAILED"}(l||(l={}));var T,M=function(){function t(t){var e=Date.now();this._id=Math.random().toString(16).replace(".",""),this.status=l.PENDING,this.data=t,this.timestamp=e}return t.prototype.isSucceed=function(){this.status=l.SUCCESS},t.prototype.isFailed=function(){this.status++},t}();!function(t){t[t.IDLE=0]="IDLE",t[t.PAUSE=1]="PAUSE",t[t.RUNNING=2]="RUNNING"}(T||(T={}));var R=function(){function t(t){this.queue=[],this.failedQueue=[],this.config=t,this.lastStoreUpdate=0,this.executor=new F}return t.prototype.init=function(t){var e=this;this.sender||(this.store=t.store,this.sender=t.sender,this.executor.init(this.sender,this),this.store.get().then(function(t){var n;(n=e.queue).push.apply(n,t.map(function(t){return new M(t.data)})),e.run()}))},t.prototype.push=function(t){t.status===l.PENDING&&this.queue.length<this.config.queueMaxLength?(this.queue.push(t),this.updateStore(),this.run()):t.status>=l.FAILED&&t.status<=this.config.retry&&(this.failedQueue.push(t),this.updateStore(),this.run())},t.prototype.intrude=function(t){this.sender.send(t)},t.prototype.pop=function(){var t=this.failedQueue.length,e=this.config.groupMaxLength,n=t-e>=0?this.failedQueue.splice(0,e):this.failedQueue.splice(0,t).concat(this.queue.splice(0,e-t));return this.updateStore(),n},t.prototype.updateStore=function(t){var e=Date.now();(this.store&&e-this.lastStoreUpdate>=500||t&&this.store)&&(this.store.update(this.queue.concat(this.failedQueue)),this.lastStoreUpdate=e)},t.prototype.run=function(){setTimeout(this.executor.run.bind(this.executor),0)},t.prototype.suspend=function(t){this.updateStore(!0),this.executor.suspend(t)},t}(),F=function(){function t(){this.status=T.IDLE}return Object.defineProperty(t.prototype,"isIdle",{get:function(){return this.sender&&this.queueManager&&this.status===T.IDLE},enumerable:!0,configurable:!0}),t.prototype.init=function(t,e){this.sender=t,this.queueManager=e},t.prototype.run=function(){this.isIdle&&this.exec()},t.prototype.exec=function(){var t=this,e=this.queueManager.pop();if(!e.length)return void(this.status=T.IDLE);this.status=T.RUNNING,Promise.all(e.map(function(e){return t.sender.send(e)})).then(function(e){e.forEach(function(e){e.status!==l.SUCCESS&&t.queueManager.push(e)})}).then(function(){t.timer=setTimeout(function(){t.exec()},t.queueManager.config.interval)})},t.prototype.suspend=function(t){t?(this.status=T.PAUSE,clearTimeout(this.timer)):this.status===T.PAUSE?(this.status=T.IDLE,this.run()):this.status===T.IDLE&&this.run()},t}(),H=function(){function t(t){this.config=t,this.queueManager=new R(this.config)}return t.prototype.init=function(t){this.queueManager.init(f({},t))},t.prototype.log=function(t){this.queueManager.push(t)},t.prototype.forceLog=function(t){this.queueManager.intrude(t)},t}(),K={debug:!0,httpMethod:"POST",retry:2,interval:1e3,groupMaxLength:5,timestampKey:"timestamp_ms",trackIdKey:"__track_id",queueMaxLength:500,commonData:{},dataScheme:{},sourceSrcKey:"src",detectChanel:!0,detectAppStart:!0,attachActionToUrl:!1},G=function(){function t(t){void 0===t&&(t={}),Object.assign(this,K,t)}return t}(),Q=function(){function t(t){void 0===t&&(t={}),this.config=new G(t),this.core=new H(this.config),d.DEBUG=this.config.debug,this.core.queueManager.suspend(!0),this.networkDetector=new q(this.config),this.commonDataVendor=new I(this.config)}return t.prototype.init=function(t){if(!this.sender){var e=this.handleNetworkStatusChange.bind(this);this.sender=new U(this.config,t),this.store=new h(this.config),this.core.init({sender:this.sender,store:this.store}),this.networkDetector.getNetworkStatus().then(e,e),this.networkDetector.watchNetworkStatusChange(e),d.log("初始化完成")}},t.prototype.handleNetworkStatusChange=function(t){var e="none"===t||t instanceof Error;this.core.queueManager.suspend(e)},t.prototype.log=function(t){var e=Date.now();t[this.config.timestampKey]=e,this.core.log(new M(t))},t.prototype.forceLog=function(t){var e=Date.now();t[this.config.timestampKey]=e,this.core.forceLog(new M(t))},n([p()],t.prototype,"init",null),n([p()],t.prototype,"handleNetworkStatusChange",null),n([p()],t.prototype,"log",null),n([p()],t.prototype,"forceLog",null),t}(),B=function(t){function r(){return null!==t&&t.apply(this,arguments)||this}return e(r,t),r.generateTrackerInstance=function(t){var e={};try{var n=require("./anka-tracker.config.js");Object.assign(e,n)}catch(e){!t&&console.log("缺少配置文件 anka-tracker.config.js",e)}t&&Object.assign(e,t);var o=new r(e);if("undefined"!=typeof App&&"undefined"!=typeof Page){var i=App,a=Page;App=function(t){return u(t,"onLaunch",function(t){o.onLaunchOption=t,o.config.detectChanel&&o.detectChanel(t.query[o.config.sourceSrcKey])}),o.config.detectAppStart&&u(t,"onShow",function(t){o.evt("app_start",{})}),i(t)},Page=function(t){return u(t,"onLoad",function(t){this.__page_params__=t}),"function"==typeof o.config.autoPageView&&u(t,"onShow",function(){var t=getCurrentPages().slice().pop();o.config.autoPageView(t,function(e){o.pv(e.action,e,{page_id:t.route,page_url:t.route,page_params:E(t.__page_params__)})})}),a(t)}}else"undefined"!=typeof wx&&wx.getLaunchOptionsSync?(o.onLaunchOption=wx.getLaunchOptionsSync(),o.config.detectChanel&&o.detectChanel(o.onLaunchOption.query[o.config.sourceSrcKey]),console.log("当前处于小游戏环境!")):console.log("anka-tracker无法在当前环境运行!");return o},r.prototype.asyncInitWithCommonData=function(t){var e=this;return void 0===t&&(t={}),this.commonDataVendor.getCommonData({onLaunchOption:this.onLaunchOption}).then(function(n){e.init(Object.assign(n,e.config.commonData,t))}).catch(function(t){d.log("初始化失败"),console.log(t)})},r.prototype.detectChanel=function(t){if(t){var e={};t.split(/_+/).forEach(function(t,n){e["source_src_key_"+(n+1)]=t}),this.evt("channel",e)}},r.prototype.composeCommonData=function(t){var e=[];return t.map(function(t){"function"==typeof t?e.push(new Promise(function(e){t(e)})):e.push(Promise.resolve(t))}),Promise.all(e).then(function(t){return Promise.resolve(Object.assign.apply(Object,[{}].concat(t)))})},r.prototype.track=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];this.composeCommonData(e).then(function(e){return t.log(e)})},r.prototype.forceTrack=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];this.composeCommonData(e).then(function(e){return t.forceLog(e)})},r.prototype.evt=function(t){void 0===t&&(t="");for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(!t)throw new Error("缺少 action 参数");this.track.apply(this,e.concat([{action:t,tracktype:"event"}]))},r.prototype.forceEvt=function(t){void 0===t&&(t="");for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];if(!t)throw new Error("缺少 action 参数");this.forceTrack.apply(this,e.concat([{action:t,tracktype:"event"}]))},r.prototype.pv=function(t){var e=this;void 0===t&&(t="");for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];this.composeCommonData(n).then(function(n){e.log(Object.assign(n,e.genLastPageUrl(n),{action:t,tracktype:"pageview"}))})},r.prototype.genLastPageUrl=function(t){var e=this,n=e.last_page_id,r=void 0===n?"":n,o=e.last_page_url,i=void 0===o?"":o;return this.last_page_url=t.page_url||"",this.last_page_id=t.page_id||"",{last_page_id:r,last_page_url:i}},n([p()],r.prototype,"asyncInitWithCommonData",null),n([p()],r.prototype,"detectChanel",null),n([p()],r.prototype,"composeCommonData",null),n([p()],r.prototype,"track",null),n([p()],r.prototype,"forceTrack",null),n([p()],r.prototype,"evt",null),n([p()],r.prototype,"forceEvt",null),n([p()],r.prototype,"pv",null),n([p()],r.prototype,"genLastPageUrl",null),r}(Q),V=B.generateTrackerInstance({});t.Tracker=Q,t.BxTracker=B,t.tracker=V,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=anka-tracker.min.js.map |
{ | ||
"name": "@anka-dev/tracker", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/anka-tracker.min.js", |
@@ -74,3 +74,3 @@ import * as qs from 'qs' | ||
} else { | ||
console.log('anka-tracker无法再当前环境运行!') | ||
console.log('anka-tracker无法在当前环境运行!') | ||
} | ||
@@ -77,0 +77,0 @@ |
Sorry, the diff of this file is not supported yet