diff --git a/packages/uni-stat/dist/index.js b/packages/uni-stat/dist/index.js index 7259e501ee80c820bb555f90088892ab349f3d61..dadcf52c0b337bc36668a67e261cdbe31c821673 100644 --- a/packages/uni-stat/dist/index.js +++ b/packages/uni-stat/dist/index.js @@ -446,16 +446,21 @@ class Util { }, 0); } _sendReportRequest(options) { + this._navigationBarTitle.lt = '1'; let query = options.query && JSON.stringify(options.query) !== '{}' ? '?' + JSON.stringify(options.query) : ''; this.statData.lt = '1'; - this.statData.url = options.path + query; + this.statData.url = (options.path + query) || ''; this.statData.t = getTime(); this.statData.sc = getScene(options.scene); this.statData.fvts = getFirstVisitTime(); this.statData.lvts = getLastVisitTime(); this.statData.tvc = getTotalVisitCount(); - this.getNetworkInfo(); + if (getPlatformName() === 'n') { + this.getProperty(); + } else { + this.getNetworkInfo(); + } } _sendPageRequest(opt) { @@ -479,6 +484,13 @@ class Util { t: getTime(), p: this.statData.p }; + if (getPlatformName() === 'n' && this.statData.p === 'a') { + setTimeout(() => { + this.request(options); + }, 200); + return + } + this.request(options); } @@ -499,6 +511,12 @@ class Util { t: getTime(), p: this.statData.p }; + if (getPlatformName() === 'n' && this.statData.p === 'a') { + setTimeout(() => { + this.request(options, type); + }, 200); + return + } this.request(options, type); } _sendEventRequest({ @@ -531,6 +549,13 @@ class Util { }); } + getProperty() { + plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => { + this.statData.v = wgtinfo.version || ''; + this.getNetworkInfo(); + }); + } + getLocation() { if (statConfig.getLocation) { uni.getLocation({ @@ -618,28 +643,29 @@ class Util { return } - setTimeout(() => { - uni.request({ - url: STAT_URL, - method: 'POST', - data: optionsData, - success: () => { - if (process.env.NODE_ENV === 'development') { - console.log('stat request success'); - } - }, - fail: (e) => { - if (process.env.NODE_ENV === 'development') { - console.log('stat request fail', e); - } - if (++this._retry < 3) { - setTimeout(() => { - this.request(data); - }, 1000); - } + uni.request({ + url: STAT_URL, + method: 'POST', + // header: { + // 'content-type': 'application/json' // 默认值 + // }, + data: optionsData, + success: () => { + if (process.env.NODE_ENV === 'development') { + console.log('stat request success'); } - }); - }, 200); + }, + fail: (e) => { + if (process.env.NODE_ENV === 'development') { + console.log('stat request fail', e); + } + if (++this._retry < 3) { + setTimeout(() => { + this.request(data); + }, 1000); + } + } + }); } /** diff --git a/packages/uni-stat/package.json b/packages/uni-stat/package.json index 16f55d24be8e83569126c8977aee1c33fde01199..a96db93befa30e3d43d9deda84125a1b28f953e1 100644 --- a/packages/uni-stat/package.json +++ b/packages/uni-stat/package.json @@ -1,6 +1,6 @@ { "name": "@dcloudio/uni-stat", - "version": "0.0.111", + "version": "0.0.113", "description": "", "main": "dist/index.js", "scripts": { diff --git a/packages/uni-stat/src/stat.js b/packages/uni-stat/src/stat.js index cce8a095efbe0a6ae9fd4e913c0c0ac70ae8d9a7..3389e8b150365c105400ed3b5b1a52b7ef684994 100644 --- a/packages/uni-stat/src/stat.js +++ b/packages/uni-stat/src/stat.js @@ -181,16 +181,21 @@ class Util { }, 0) } _sendReportRequest(options) { + this._navigationBarTitle.lt = '1'; let query = options.query && JSON.stringify(options.query) !== '{}' ? '?' + JSON.stringify(options.query) : ''; this.statData.lt = '1'; - this.statData.url = options.path + query; + this.statData.url = (options.path + query) || ''; this.statData.t = getTime(); this.statData.sc = getScene(options.scene); this.statData.fvts = getFirstVisitTime(); this.statData.lvts = getLastVisitTime(); this.statData.tvc = getTotalVisitCount(); - this.getNetworkInfo(); + if (getPlatformName() === 'n') { + this.getProperty(); + } else { + this.getNetworkInfo(); + } } _sendPageRequest(opt) { @@ -214,6 +219,13 @@ class Util { t: getTime(), p: this.statData.p } + if (getPlatformName() === 'n' && this.statData.p === 'a') { + setTimeout(() => { + this.request(options); + }, 200) + return + } + this.request(options); } @@ -234,6 +246,12 @@ class Util { t: getTime(), p: this.statData.p } + if (getPlatformName() === 'n' && this.statData.p === 'a') { + setTimeout(() => { + this.request(options, type) + }, 200) + return + } this.request(options, type) } _sendEventRequest({ @@ -266,6 +284,13 @@ class Util { }); } + getProperty() { + plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => { + this.statData.v = wgtinfo.version || ''; + this.getNetworkInfo(); + }); + } + getLocation() { if (statConfig.getLocation) { uni.getLocation({ @@ -353,28 +378,29 @@ class Util { return } - setTimeout(() => { - uni.request({ - url: STAT_URL, - method: 'POST', - data: optionsData, - success: () => { - if (process.env.NODE_ENV === 'development') { - console.log('stat request success'); - } - }, - fail: (e) => { - if (process.env.NODE_ENV === 'development') { - console.log('stat request fail', e); - } - if (++this._retry < 3) { - setTimeout(() => { - this.request(data); - }, 1000); - } + uni.request({ + url: STAT_URL, + method: 'POST', + // header: { + // 'content-type': 'application/json' // 默认值 + // }, + data: optionsData, + success: () => { + if (process.env.NODE_ENV === 'development') { + console.log('stat request success'); } - }); - }, 200) + }, + fail: (e) => { + if (process.env.NODE_ENV === 'development') { + console.log('stat request fail', e); + } + if (++this._retry < 3) { + setTimeout(() => { + this.request(data); + }, 1000); + } + } + }); } /**