提交 d28b01d3 编写于 作者: M mehaotian

fix(stat):修复 ios setTimeout 报错 , 安卓重启的bug,app 端修改 获取 version 的方式

上级 ece5ee98
...@@ -446,16 +446,21 @@ class Util { ...@@ -446,16 +446,21 @@ class Util {
}, 0); }, 0);
} }
_sendReportRequest(options) { _sendReportRequest(options) {
this._navigationBarTitle.lt = '1'; this._navigationBarTitle.lt = '1';
let query = options.query && JSON.stringify(options.query) !== '{}' ? '?' + JSON.stringify(options.query) : ''; let query = options.query && JSON.stringify(options.query) !== '{}' ? '?' + JSON.stringify(options.query) : '';
this.statData.lt = '1'; this.statData.lt = '1';
this.statData.url = options.path + query; this.statData.url = (options.path + query) || '';
this.statData.t = getTime(); this.statData.t = getTime();
this.statData.sc = getScene(options.scene); this.statData.sc = getScene(options.scene);
this.statData.fvts = getFirstVisitTime(); this.statData.fvts = getFirstVisitTime();
this.statData.lvts = getLastVisitTime(); this.statData.lvts = getLastVisitTime();
this.statData.tvc = getTotalVisitCount(); this.statData.tvc = getTotalVisitCount();
this.getNetworkInfo(); if (getPlatformName() === 'n') {
this.getProperty();
} else {
this.getNetworkInfo();
}
} }
_sendPageRequest(opt) { _sendPageRequest(opt) {
...@@ -479,6 +484,13 @@ class Util { ...@@ -479,6 +484,13 @@ class Util {
t: getTime(), t: getTime(),
p: this.statData.p p: this.statData.p
}; };
if (getPlatformName() === 'n' && this.statData.p === 'a') {
setTimeout(() => {
this.request(options);
}, 200);
return
}
this.request(options); this.request(options);
} }
...@@ -499,6 +511,12 @@ class Util { ...@@ -499,6 +511,12 @@ class Util {
t: getTime(), t: getTime(),
p: this.statData.p p: this.statData.p
}; };
if (getPlatformName() === 'n' && this.statData.p === 'a') {
setTimeout(() => {
this.request(options, type);
}, 200);
return
}
this.request(options, type); this.request(options, type);
} }
_sendEventRequest({ _sendEventRequest({
...@@ -531,6 +549,13 @@ class Util { ...@@ -531,6 +549,13 @@ class Util {
}); });
} }
getProperty() {
plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
this.statData.v = wgtinfo.version || '';
this.getNetworkInfo();
});
}
getLocation() { getLocation() {
if (statConfig.getLocation) { if (statConfig.getLocation) {
uni.getLocation({ uni.getLocation({
...@@ -618,28 +643,29 @@ class Util { ...@@ -618,28 +643,29 @@ class Util {
return return
} }
setTimeout(() => { uni.request({
uni.request({ url: STAT_URL,
url: STAT_URL, method: 'POST',
method: 'POST', // header: {
data: optionsData, // 'content-type': 'application/json' // 默认值
success: () => { // },
if (process.env.NODE_ENV === 'development') { data: optionsData,
console.log('stat request success'); 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);
}
} }
}); },
}, 200); fail: (e) => {
if (process.env.NODE_ENV === 'development') {
console.log('stat request fail', e);
}
if (++this._retry < 3) {
setTimeout(() => {
this.request(data);
}, 1000);
}
}
});
} }
/** /**
......
{ {
"name": "@dcloudio/uni-stat", "name": "@dcloudio/uni-stat",
"version": "0.0.111", "version": "0.0.113",
"description": "", "description": "",
"main": "dist/index.js", "main": "dist/index.js",
"scripts": { "scripts": {
......
...@@ -181,16 +181,21 @@ class Util { ...@@ -181,16 +181,21 @@ class Util {
}, 0) }, 0)
} }
_sendReportRequest(options) { _sendReportRequest(options) {
this._navigationBarTitle.lt = '1'; this._navigationBarTitle.lt = '1';
let query = options.query && JSON.stringify(options.query) !== '{}' ? '?' + JSON.stringify(options.query) : ''; let query = options.query && JSON.stringify(options.query) !== '{}' ? '?' + JSON.stringify(options.query) : '';
this.statData.lt = '1'; this.statData.lt = '1';
this.statData.url = options.path + query; this.statData.url = (options.path + query) || '';
this.statData.t = getTime(); this.statData.t = getTime();
this.statData.sc = getScene(options.scene); this.statData.sc = getScene(options.scene);
this.statData.fvts = getFirstVisitTime(); this.statData.fvts = getFirstVisitTime();
this.statData.lvts = getLastVisitTime(); this.statData.lvts = getLastVisitTime();
this.statData.tvc = getTotalVisitCount(); this.statData.tvc = getTotalVisitCount();
this.getNetworkInfo(); if (getPlatformName() === 'n') {
this.getProperty();
} else {
this.getNetworkInfo();
}
} }
_sendPageRequest(opt) { _sendPageRequest(opt) {
...@@ -214,6 +219,13 @@ class Util { ...@@ -214,6 +219,13 @@ class Util {
t: getTime(), t: getTime(),
p: this.statData.p p: this.statData.p
} }
if (getPlatformName() === 'n' && this.statData.p === 'a') {
setTimeout(() => {
this.request(options);
}, 200)
return
}
this.request(options); this.request(options);
} }
...@@ -234,6 +246,12 @@ class Util { ...@@ -234,6 +246,12 @@ class Util {
t: getTime(), t: getTime(),
p: this.statData.p p: this.statData.p
} }
if (getPlatformName() === 'n' && this.statData.p === 'a') {
setTimeout(() => {
this.request(options, type)
}, 200)
return
}
this.request(options, type) this.request(options, type)
} }
_sendEventRequest({ _sendEventRequest({
...@@ -266,6 +284,13 @@ class Util { ...@@ -266,6 +284,13 @@ class Util {
}); });
} }
getProperty() {
plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
this.statData.v = wgtinfo.version || '';
this.getNetworkInfo();
});
}
getLocation() { getLocation() {
if (statConfig.getLocation) { if (statConfig.getLocation) {
uni.getLocation({ uni.getLocation({
...@@ -353,28 +378,29 @@ class Util { ...@@ -353,28 +378,29 @@ class Util {
return return
} }
setTimeout(() => { uni.request({
uni.request({ url: STAT_URL,
url: STAT_URL, method: 'POST',
method: 'POST', // header: {
data: optionsData, // 'content-type': 'application/json' // 默认值
success: () => { // },
if (process.env.NODE_ENV === 'development') { data: optionsData,
console.log('stat request success'); 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);
}
} }
}); },
}, 200) fail: (e) => {
if (process.env.NODE_ENV === 'development') {
console.log('stat request fail', e);
}
if (++this._retry < 3) {
setTimeout(() => {
this.request(data);
}, 1000);
}
}
});
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册