From 0cad5724611d16d3a04687d11592a8a269a96de4 Mon Sep 17 00:00:00 2001 From: mehaotian <490272692@qq.com> Date: Wed, 6 Jul 2022 19:41:26 +0800 Subject: [PATCH] =?UTF-8?q?feat(stat):=20=E6=96=B0=E5=A2=9E=E9=A6=96?= =?UTF-8?q?=E6=AC=A1=E4=B8=8A=E6=8A=A5=EF=BC=8C=E6=96=B0=E5=A2=9Epush=20ci?= =?UTF-8?q?d=20=E4=B8=8A=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/uni-stat/dist/uni-cloud-stat.cjs.js | 94 +++++++++++++++---- packages/uni-stat/dist/uni-cloud-stat.es.js | 94 +++++++++++++++---- packages/uni-stat/dist/uni-stat.cjs.js | 95 ++++++++++++++++---- packages/uni-stat/dist/uni-stat.es.js | 95 ++++++++++++++++---- packages/uni-stat/src/core/report.js | 63 ++++++++++--- packages/uni-stat/src/core/stat.js | 33 +++++-- packages/uni-stat/src/index.js | 2 + packages/uni-stat/src/utils/pageInfo.js | 7 +- 8 files changed, 400 insertions(+), 83 deletions(-) diff --git a/packages/uni-stat/dist/uni-cloud-stat.cjs.js b/packages/uni-stat/dist/uni-cloud-stat.cjs.js index 0cdd25795..23e8c4a61 100644 --- a/packages/uni-stat/dist/uni-cloud-stat.cjs.js +++ b/packages/uni-stat/dist/uni-cloud-stat.cjs.js @@ -490,6 +490,9 @@ const log = (data) => { case '31': msg_type = '应用错误'; break + case '101': + msg_type = 'PUSH'; + break } if (msg_type) { console.log(`=== 统计数据采集:${msg_type} ===`); @@ -914,8 +917,9 @@ class Report { /** * 发送请求,应用维度上报 * @param {Object} options 页面信息 + * @param {Boolean} type 是否立即上报 */ - sendReportRequest(options) { + sendReportRequest(options, type) { this._navigationBarTitle.lt = '1'; this._navigationBarTitle.config = get_page_name(options.path); let is_opt = options.query && JSON.stringify(options.query) !== '{}'; @@ -932,9 +936,9 @@ class Report { cst: options.cst || 1, }); if (get_platform_name() === 'n') { - this.getProperty(); + this.getProperty(type); } else { - this.getNetworkInfo(); + this.getNetworkInfo(type); } } @@ -1015,24 +1019,59 @@ class Report { this.request(options); } + sendPushRequest(options, cid) { + let time = get_time(); + + const statData = { + lt: '101', + cid: cid, + t: time, + ut: this.statData.ut, + }; + + // debug 打印打点信息 + if (is_debug) { + log(statData); + } + + const stat_data = handle_data({ + 101: [statData], + }); + let optionsData = { + usv: STAT_VERSION, //统计 SDK 版本号 + t: time, //发送请求时的时间戮 + requests: stat_data, + }; + + // XXX 安卓需要延迟上报 ,否则会有未知错误,需要验证处理 + if (get_platform_name() === 'n' && this.statData.p === 'a') { + setTimeout(() => { + this.sendRequest(optionsData); + }, 200); + return + } + + this.sendRequest(optionsData); + } + /** * 获取wgt资源版本 */ - getProperty() { + getProperty(type) { plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => { this.statData.v = wgtinfo.version || ''; - this.getNetworkInfo(); + this.getNetworkInfo(type); }); } /** * 获取网络信息 */ - getNetworkInfo() { + getNetworkInfo(type) { uni.getNetworkType({ success: (result) => { this.statData.net = result.networkType; - this.getLocation(); + this.getLocation(type); }, }); } @@ -1040,7 +1079,7 @@ class Report { /** * 获取位置信息 */ - getLocation() { + getLocation(type) { if (stat_config.getLocation) { uni.getLocation({ type: 'wgs84', @@ -1054,13 +1093,13 @@ class Report { this.statData.lat = result.latitude; this.statData.lng = result.longitude; - this.request(this.statData); + this.request(this.statData, type); }, }); } else { this.statData.lat = 0; this.statData.lng = 0; - this.request(this.statData); + this.request(this.statData, type); } } @@ -1205,9 +1244,9 @@ class Stat extends Report { let spaceData = { provider: space.provider, spaceId: space.spaceId, - clientSecret: space.clientSecret + clientSecret: space.clientSecret, }; - if(space.endpoint){ + if (space.endpoint) { spaceData.endpoint = space.endpoint; } uni.__stat_uniCloud_space = uniCloud.init(spaceData); @@ -1216,7 +1255,9 @@ class Stat extends Report { // uni.__stat_uniCloud_space.config.spaceId // ) } else { - console.error('当前尚未关联统计服务空间,请先在manifest.json中配置服务空间!'); + console.error( + '当前尚未关联统计服务空间,请先在manifest.json中配置服务空间!' + ); } } } @@ -1227,6 +1268,23 @@ class Stat extends Report { super(); } + /** + * 获取推送id + */ + pushEvent(options) { + if (uni.getPushClientId) { + uni.getPushClientId({ + success: (res) => { + const cid = res.cid || false; + // 只有获取到才会上传 + if (cid) { + this.sendPushRequest(options,cid); + } + }, + }); + } + } + /** * 进入应用 * @param {Object} options 页面参数 @@ -1237,7 +1295,7 @@ class Stat extends Report { set_page_residence_time(); this.__licationShow = true; dbSet('__launch_options', options); - // 应用初始上报参数为1 + // 应用初始上报参数为1 options.cst = 1; this.sendReportRequest(options, true); } @@ -1313,8 +1371,8 @@ class Stat extends Report { let route = ''; try { - route = get_route(); - }catch(e){ + route = get_route(); + } catch (e) { // 未获取到页面路径 route = ''; } @@ -1324,7 +1382,7 @@ class Stat extends Report { uuid: this.statData.uuid, p: this.statData.p, lt: '31', - url:route, + url: route, ut: this.statData.ut, ch: this.statData.ch, mpsdk: this.statData.mpsdk, @@ -1348,6 +1406,8 @@ const lifecycle = { onLaunch(options) { // 进入应用上报数据 stat.launch(options, this); + // 上报push推送id + stat.pushEvent(options); }, onLoad(options) { stat.load(options, this); diff --git a/packages/uni-stat/dist/uni-cloud-stat.es.js b/packages/uni-stat/dist/uni-cloud-stat.es.js index 7da4867d1..a6842d89c 100644 --- a/packages/uni-stat/dist/uni-cloud-stat.es.js +++ b/packages/uni-stat/dist/uni-cloud-stat.es.js @@ -488,6 +488,9 @@ const log = (data) => { case '31': msg_type = '应用错误'; break + case '101': + msg_type = 'PUSH'; + break } if (msg_type) { console.log(`=== 统计数据采集:${msg_type} ===`); @@ -912,8 +915,9 @@ class Report { /** * 发送请求,应用维度上报 * @param {Object} options 页面信息 + * @param {Boolean} type 是否立即上报 */ - sendReportRequest(options) { + sendReportRequest(options, type) { this._navigationBarTitle.lt = '1'; this._navigationBarTitle.config = get_page_name(options.path); let is_opt = options.query && JSON.stringify(options.query) !== '{}'; @@ -930,9 +934,9 @@ class Report { cst: options.cst || 1, }); if (get_platform_name() === 'n') { - this.getProperty(); + this.getProperty(type); } else { - this.getNetworkInfo(); + this.getNetworkInfo(type); } } @@ -1013,24 +1017,59 @@ class Report { this.request(options); } + sendPushRequest(options, cid) { + let time = get_time(); + + const statData = { + lt: '101', + cid: cid, + t: time, + ut: this.statData.ut, + }; + + // debug 打印打点信息 + if (is_debug) { + log(statData); + } + + const stat_data = handle_data({ + 101: [statData], + }); + let optionsData = { + usv: STAT_VERSION, //统计 SDK 版本号 + t: time, //发送请求时的时间戮 + requests: stat_data, + }; + + // XXX 安卓需要延迟上报 ,否则会有未知错误,需要验证处理 + if (get_platform_name() === 'n' && this.statData.p === 'a') { + setTimeout(() => { + this.sendRequest(optionsData); + }, 200); + return + } + + this.sendRequest(optionsData); + } + /** * 获取wgt资源版本 */ - getProperty() { + getProperty(type) { plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => { this.statData.v = wgtinfo.version || ''; - this.getNetworkInfo(); + this.getNetworkInfo(type); }); } /** * 获取网络信息 */ - getNetworkInfo() { + getNetworkInfo(type) { uni.getNetworkType({ success: (result) => { this.statData.net = result.networkType; - this.getLocation(); + this.getLocation(type); }, }); } @@ -1038,7 +1077,7 @@ class Report { /** * 获取位置信息 */ - getLocation() { + getLocation(type) { if (stat_config.getLocation) { uni.getLocation({ type: 'wgs84', @@ -1052,13 +1091,13 @@ class Report { this.statData.lat = result.latitude; this.statData.lng = result.longitude; - this.request(this.statData); + this.request(this.statData, type); }, }); } else { this.statData.lat = 0; this.statData.lng = 0; - this.request(this.statData); + this.request(this.statData, type); } } @@ -1203,9 +1242,9 @@ class Stat extends Report { let spaceData = { provider: space.provider, spaceId: space.spaceId, - clientSecret: space.clientSecret + clientSecret: space.clientSecret, }; - if(space.endpoint){ + if (space.endpoint) { spaceData.endpoint = space.endpoint; } uni.__stat_uniCloud_space = uniCloud.init(spaceData); @@ -1214,7 +1253,9 @@ class Stat extends Report { // uni.__stat_uniCloud_space.config.spaceId // ) } else { - console.error('当前尚未关联统计服务空间,请先在manifest.json中配置服务空间!'); + console.error( + '当前尚未关联统计服务空间,请先在manifest.json中配置服务空间!' + ); } } } @@ -1225,6 +1266,23 @@ class Stat extends Report { super(); } + /** + * 获取推送id + */ + pushEvent(options) { + if (uni.getPushClientId) { + uni.getPushClientId({ + success: (res) => { + const cid = res.cid || false; + // 只有获取到才会上传 + if (cid) { + this.sendPushRequest(options,cid); + } + }, + }); + } + } + /** * 进入应用 * @param {Object} options 页面参数 @@ -1235,7 +1293,7 @@ class Stat extends Report { set_page_residence_time(); this.__licationShow = true; dbSet('__launch_options', options); - // 应用初始上报参数为1 + // 应用初始上报参数为1 options.cst = 1; this.sendReportRequest(options, true); } @@ -1311,8 +1369,8 @@ class Stat extends Report { let route = ''; try { - route = get_route(); - }catch(e){ + route = get_route(); + } catch (e) { // 未获取到页面路径 route = ''; } @@ -1322,7 +1380,7 @@ class Stat extends Report { uuid: this.statData.uuid, p: this.statData.p, lt: '31', - url:route, + url: route, ut: this.statData.ut, ch: this.statData.ch, mpsdk: this.statData.mpsdk, @@ -1346,6 +1404,8 @@ const lifecycle = { onLaunch(options) { // 进入应用上报数据 stat.launch(options, this); + // 上报push推送id + stat.pushEvent(options); }, onLoad(options) { stat.load(options, this); diff --git a/packages/uni-stat/dist/uni-stat.cjs.js b/packages/uni-stat/dist/uni-stat.cjs.js index 94863d14e..9c85d7984 100644 --- a/packages/uni-stat/dist/uni-stat.cjs.js +++ b/packages/uni-stat/dist/uni-stat.cjs.js @@ -292,7 +292,7 @@ const handle_data = (statData) => { rd.forEach((elm) => { let newData = ''; { - newData = get_splicing(elm); + newData = get_splicing(elm); } if (i === 0) { firstArr.push(newData); @@ -469,6 +469,9 @@ const log = (data) => { case '31': msg_type = '应用错误'; break + case '101': + msg_type = 'PUSH'; + break } if (msg_type) { console.log(`=== 统计数据采集:${msg_type} ===`); @@ -893,8 +896,9 @@ class Report { /** * 发送请求,应用维度上报 * @param {Object} options 页面信息 + * @param {Boolean} type 是否立即上报 */ - sendReportRequest(options) { + sendReportRequest(options, type) { this._navigationBarTitle.lt = '1'; this._navigationBarTitle.config = get_page_name(options.path); let is_opt = options.query && JSON.stringify(options.query) !== '{}'; @@ -911,9 +915,9 @@ class Report { cst: options.cst || 1, }); if (get_platform_name() === 'n') { - this.getProperty(); + this.getProperty(type); } else { - this.getNetworkInfo(); + this.getNetworkInfo(type); } } @@ -994,24 +998,66 @@ class Report { this.request(options); } + sendPushRequest(options, cid) { + let time = get_time(); + + const statData = { + lt: '101', + cid: cid, + t: time, + ut: this.statData.ut, + }; + + // debug 打印打点信息 + if (is_debug) { + log(statData); + } + + const stat_data = handle_data({ + 101: [statData], + }); + let optionsData = { + usv: STAT_VERSION, //统计 SDK 版本号 + t: time, //发送请求时的时间戮 + requests: stat_data, + }; + + { + if (statData.ut === 'h5') { + this.imageRequest(optionsData); + return + } + } + + // XXX 安卓需要延迟上报 ,否则会有未知错误,需要验证处理 + if (get_platform_name() === 'n' && this.statData.p === 'a') { + setTimeout(() => { + this.sendRequest(optionsData); + }, 200); + return + } + + this.sendRequest(optionsData); + } + /** * 获取wgt资源版本 */ - getProperty() { + getProperty(type) { plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => { this.statData.v = wgtinfo.version || ''; - this.getNetworkInfo(); + this.getNetworkInfo(type); }); } /** * 获取网络信息 */ - getNetworkInfo() { + getNetworkInfo(type) { uni.getNetworkType({ success: (result) => { this.statData.net = result.networkType; - this.getLocation(); + this.getLocation(type); }, }); } @@ -1019,7 +1065,7 @@ class Report { /** * 获取位置信息 */ - getLocation() { + getLocation(type) { if (stat_config.getLocation) { uni.getLocation({ type: 'wgs84', @@ -1033,13 +1079,13 @@ class Report { this.statData.lat = result.latitude; this.statData.lng = result.longitude; - this.request(this.statData); + this.request(this.statData, type); }, }); } else { this.statData.lat = 0; this.statData.lng = 0; - this.request(this.statData); + this.request(this.statData, type); } } @@ -1188,6 +1234,23 @@ class Stat extends Report { super(); } + /** + * 获取推送id + */ + pushEvent(options) { + if (uni.getPushClientId) { + uni.getPushClientId({ + success: (res) => { + const cid = res.cid || false; + // 只有获取到才会上传 + if (cid) { + this.sendPushRequest(options,cid); + } + }, + }); + } + } + /** * 进入应用 * @param {Object} options 页面参数 @@ -1198,7 +1261,7 @@ class Stat extends Report { set_page_residence_time(); this.__licationShow = true; dbSet('__launch_options', options); - // 应用初始上报参数为1 + // 应用初始上报参数为1 options.cst = 1; this.sendReportRequest(options, true); } @@ -1274,8 +1337,8 @@ class Stat extends Report { let route = ''; try { - route = get_route(); - }catch(e){ + route = get_route(); + } catch (e) { // 未获取到页面路径 route = ''; } @@ -1285,7 +1348,7 @@ class Stat extends Report { uuid: this.statData.uuid, p: this.statData.p, lt: '31', - url:route, + url: route, ut: this.statData.ut, ch: this.statData.ch, mpsdk: this.statData.mpsdk, @@ -1309,6 +1372,8 @@ const lifecycle = { onLaunch(options) { // 进入应用上报数据 stat.launch(options, this); + // 上报push推送id + stat.pushEvent(options); }, onLoad(options) { stat.load(options, this); diff --git a/packages/uni-stat/dist/uni-stat.es.js b/packages/uni-stat/dist/uni-stat.es.js index 78b405a09..666e22fc6 100644 --- a/packages/uni-stat/dist/uni-stat.es.js +++ b/packages/uni-stat/dist/uni-stat.es.js @@ -290,7 +290,7 @@ const handle_data = (statData) => { rd.forEach((elm) => { let newData = ''; { - newData = get_splicing(elm); + newData = get_splicing(elm); } if (i === 0) { firstArr.push(newData); @@ -467,6 +467,9 @@ const log = (data) => { case '31': msg_type = '应用错误'; break + case '101': + msg_type = 'PUSH'; + break } if (msg_type) { console.log(`=== 统计数据采集:${msg_type} ===`); @@ -891,8 +894,9 @@ class Report { /** * 发送请求,应用维度上报 * @param {Object} options 页面信息 + * @param {Boolean} type 是否立即上报 */ - sendReportRequest(options) { + sendReportRequest(options, type) { this._navigationBarTitle.lt = '1'; this._navigationBarTitle.config = get_page_name(options.path); let is_opt = options.query && JSON.stringify(options.query) !== '{}'; @@ -909,9 +913,9 @@ class Report { cst: options.cst || 1, }); if (get_platform_name() === 'n') { - this.getProperty(); + this.getProperty(type); } else { - this.getNetworkInfo(); + this.getNetworkInfo(type); } } @@ -992,24 +996,66 @@ class Report { this.request(options); } + sendPushRequest(options, cid) { + let time = get_time(); + + const statData = { + lt: '101', + cid: cid, + t: time, + ut: this.statData.ut, + }; + + // debug 打印打点信息 + if (is_debug) { + log(statData); + } + + const stat_data = handle_data({ + 101: [statData], + }); + let optionsData = { + usv: STAT_VERSION, //统计 SDK 版本号 + t: time, //发送请求时的时间戮 + requests: stat_data, + }; + + { + if (statData.ut === 'h5') { + this.imageRequest(optionsData); + return + } + } + + // XXX 安卓需要延迟上报 ,否则会有未知错误,需要验证处理 + if (get_platform_name() === 'n' && this.statData.p === 'a') { + setTimeout(() => { + this.sendRequest(optionsData); + }, 200); + return + } + + this.sendRequest(optionsData); + } + /** * 获取wgt资源版本 */ - getProperty() { + getProperty(type) { plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => { this.statData.v = wgtinfo.version || ''; - this.getNetworkInfo(); + this.getNetworkInfo(type); }); } /** * 获取网络信息 */ - getNetworkInfo() { + getNetworkInfo(type) { uni.getNetworkType({ success: (result) => { this.statData.net = result.networkType; - this.getLocation(); + this.getLocation(type); }, }); } @@ -1017,7 +1063,7 @@ class Report { /** * 获取位置信息 */ - getLocation() { + getLocation(type) { if (stat_config.getLocation) { uni.getLocation({ type: 'wgs84', @@ -1031,13 +1077,13 @@ class Report { this.statData.lat = result.latitude; this.statData.lng = result.longitude; - this.request(this.statData); + this.request(this.statData, type); }, }); } else { this.statData.lat = 0; this.statData.lng = 0; - this.request(this.statData); + this.request(this.statData, type); } } @@ -1186,6 +1232,23 @@ class Stat extends Report { super(); } + /** + * 获取推送id + */ + pushEvent(options) { + if (uni.getPushClientId) { + uni.getPushClientId({ + success: (res) => { + const cid = res.cid || false; + // 只有获取到才会上传 + if (cid) { + this.sendPushRequest(options,cid); + } + }, + }); + } + } + /** * 进入应用 * @param {Object} options 页面参数 @@ -1196,7 +1259,7 @@ class Stat extends Report { set_page_residence_time(); this.__licationShow = true; dbSet('__launch_options', options); - // 应用初始上报参数为1 + // 应用初始上报参数为1 options.cst = 1; this.sendReportRequest(options, true); } @@ -1272,8 +1335,8 @@ class Stat extends Report { let route = ''; try { - route = get_route(); - }catch(e){ + route = get_route(); + } catch (e) { // 未获取到页面路径 route = ''; } @@ -1283,7 +1346,7 @@ class Stat extends Report { uuid: this.statData.uuid, p: this.statData.p, lt: '31', - url:route, + url: route, ut: this.statData.ut, ch: this.statData.ch, mpsdk: this.statData.mpsdk, @@ -1307,6 +1370,8 @@ const lifecycle = { onLaunch(options) { // 进入应用上报数据 stat.launch(options, this); + // 上报push推送id + stat.pushEvent(options); }, onLoad(options) { stat.load(options, this); diff --git a/packages/uni-stat/src/core/report.js b/packages/uni-stat/src/core/report.js index 054371f6c..d26c6621f 100644 --- a/packages/uni-stat/src/core/report.js +++ b/packages/uni-stat/src/core/report.js @@ -287,8 +287,9 @@ export default class Report { /** * 发送请求,应用维度上报 * @param {Object} options 页面信息 + * @param {Boolean} type 是否立即上报 */ - sendReportRequest(options) { + sendReportRequest(options, type) { this._navigationBarTitle.lt = '1' this._navigationBarTitle.config = get_page_name(options.path) let is_opt = options.query && JSON.stringify(options.query) !== '{}' @@ -305,9 +306,9 @@ export default class Report { cst: options.cst || 1, }) if (get_platform_name() === 'n') { - this.getProperty() + this.getProperty(type) } else { - this.getNetworkInfo() + this.getNetworkInfo(type) } } @@ -388,24 +389,66 @@ export default class Report { this.request(options) } + sendPushRequest(options, cid) { + let time = get_time() + + const statData = { + lt: '101', + cid: cid, + t: time, + ut: this.statData.ut, + } + + // debug 打印打点信息 + if (is_debug) { + log(statData) + } + + const stat_data = handle_data({ + 101: [statData], + }) + let optionsData = { + usv: STAT_VERSION, //统计 SDK 版本号 + t: time, //发送请求时的时间戮 + requests: stat_data, + } + + if (__STAT_VERSION__ === '1') { + if (statData.ut === 'h5') { + this.imageRequest(optionsData) + return + } + } + + // XXX 安卓需要延迟上报 ,否则会有未知错误,需要验证处理 + if (get_platform_name() === 'n' && this.statData.p === 'a') { + setTimeout(() => { + this.sendRequest(optionsData) + }, 200) + return + } + + this.sendRequest(optionsData) + } + /** * 获取wgt资源版本 */ - getProperty() { + getProperty(type) { plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => { this.statData.v = wgtinfo.version || '' - this.getNetworkInfo() + this.getNetworkInfo(type) }) } /** * 获取网络信息 */ - getNetworkInfo() { + getNetworkInfo(type) { uni.getNetworkType({ success: (result) => { this.statData.net = result.networkType - this.getLocation() + this.getLocation(type) }, }) } @@ -413,7 +456,7 @@ export default class Report { /** * 获取位置信息 */ - getLocation() { + getLocation(type) { if (stat_config.getLocation) { uni.getLocation({ type: 'wgs84', @@ -427,13 +470,13 @@ export default class Report { this.statData.lat = result.latitude this.statData.lng = result.longitude - this.request(this.statData) + this.request(this.statData, type) }, }) } else { this.statData.lat = 0 this.statData.lng = 0 - this.request(this.statData) + this.request(this.statData, type) } } diff --git a/packages/uni-stat/src/core/stat.js b/packages/uni-stat/src/core/stat.js index 15e29aa66..5d79b71d9 100644 --- a/packages/uni-stat/src/core/stat.js +++ b/packages/uni-stat/src/core/stat.js @@ -23,9 +23,9 @@ class Stat extends Report { let spaceData = { provider: space.provider, spaceId: space.spaceId, - clientSecret: space.clientSecret + clientSecret: space.clientSecret, } - if(space.endpoint){ + if (space.endpoint) { spaceData.endpoint = space.endpoint } uni.__stat_uniCloud_space = uniCloud.init(spaceData) @@ -34,7 +34,9 @@ class Stat extends Report { // uni.__stat_uniCloud_space.config.spaceId // ) } else { - console.error('当前尚未关联统计服务空间,请先在manifest.json中配置服务空间!') + console.error( + '当前尚未关联统计服务空间,请先在manifest.json中配置服务空间!' + ) } } } @@ -45,6 +47,23 @@ class Stat extends Report { super() } + /** + * 获取推送id + */ + pushEvent(options) { + if (uni.getPushClientId) { + uni.getPushClientId({ + success: (res) => { + const cid = res.cid || false + // 只有获取到才会上传 + if (cid) { + this.sendPushRequest(options,cid) + } + }, + }) + } + } + /** * 进入应用 * @param {Object} options 页面参数 @@ -55,7 +74,7 @@ class Stat extends Report { let residence_time = set_page_residence_time() this.__licationShow = true dbSet('__launch_options', options) - // 应用初始上报参数为1 + // 应用初始上报参数为1 options.cst = 1 this.sendReportRequest(options, true) } @@ -131,8 +150,8 @@ class Stat extends Report { let route = '' try { - route = get_route() - }catch(e){ + route = get_route() + } catch (e) { // 未获取到页面路径 route = '' } @@ -142,7 +161,7 @@ class Stat extends Report { uuid: this.statData.uuid, p: this.statData.p, lt: '31', - url:route, + url: route, ut: this.statData.ut, ch: this.statData.ch, mpsdk: this.statData.mpsdk, diff --git a/packages/uni-stat/src/index.js b/packages/uni-stat/src/index.js index 2bcfe7aba..6c7d62c35 100644 --- a/packages/uni-stat/src/index.js +++ b/packages/uni-stat/src/index.js @@ -9,6 +9,8 @@ const lifecycle = { onLaunch(options) { // 进入应用上报数据 stat.launch(options, this) + // 上报push推送id + stat.pushEvent(options) }, onLoad(options) { stat.load(options, this) diff --git a/packages/uni-stat/src/utils/pageInfo.js b/packages/uni-stat/src/utils/pageInfo.js index 7ad14e03c..af00ae34d 100644 --- a/packages/uni-stat/src/utils/pageInfo.js +++ b/packages/uni-stat/src/utils/pageInfo.js @@ -285,9 +285,9 @@ export const handle_data = (statData) => { rd.forEach((elm) => { let newData = '' if (__STAT_VERSION__ === '1') { - newData = get_splicing(elm) + newData = get_splicing(elm) } - if(__STAT_VERSION__ === '2') { + if (__STAT_VERSION__ === '2') { newData = elm } if (i === 0) { @@ -497,6 +497,9 @@ export const log = (data) => { case '31': msg_type = '应用错误' break + case '101': + msg_type = 'PUSH' + break } if (msg_type) { console.log(`=== 统计数据采集:${msg_type} ===`) -- GitLab