From ea46ae7f8ab392123a9a5228eb672e2c02c2865d Mon Sep 17 00:00:00 2001 From: mehaotian <490272692@qq.com> Date: Wed, 24 Aug 2022 10:42:17 +0800 Subject: [PATCH] =?UTF-8?q?fest(stat):=20=E6=96=B0=E5=A2=9E=20=E9=87=87?= =?UTF-8?q?=E9=9B=86=E9=A1=B9-=20uniPushClientID=20=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/uni-stat/dist/uni-cloud-stat.cjs.js | 17 ++++++++++++++--- packages/uni-stat/dist/uni-cloud-stat.es.js | 17 ++++++++++++++--- packages/uni-stat/dist/uni-stat.cjs.js | 17 ++++++++++++++--- packages/uni-stat/dist/uni-stat.es.js | 17 ++++++++++++++--- packages/uni-stat/src/core/stat.js | 4 +++- packages/uni-stat/src/utils/pageInfo.js | 14 ++++++++++++-- 6 files changed, 71 insertions(+), 15 deletions(-) diff --git a/packages/uni-stat/dist/uni-cloud-stat.cjs.js b/packages/uni-stat/dist/uni-cloud-stat.cjs.js index 0f628fd90..10eeafa2c 100644 --- a/packages/uni-stat/dist/uni-cloud-stat.cjs.js +++ b/packages/uni-stat/dist/uni-cloud-stat.cjs.js @@ -474,7 +474,6 @@ const is_debug = debug; * @param {*} data */ const log = (data, type) => { - let msg_type = ''; switch (data.lt) { case '1': @@ -500,7 +499,7 @@ const log = (data, type) => { // #ifdef APP // 在 app 中,日志转为 字符串 - if(typeof data === 'object') { + if (typeof data === 'object') { data = JSON.stringify(data); } // #endif @@ -532,6 +531,17 @@ const get_report_Interval = (defaultTime) => { // 如果不是整数,则默认为上报间隔时间 if (!reg.test(time)) return defaultTime return Number(time) +}; + +/** + * 获取隐私协议配置 + */ +const is_push_clientid = () => { + if (uniStatisticsConfig.collectItems) { + const ClientID = uniStatisticsConfig.collectItems.uniPushClientID; + return typeof ClientID === 'boolean' ? ClientID : false + } + return false }; const appid = process.env.UNI_APP_ID; // 做应用隔离 @@ -1304,7 +1314,8 @@ class Stat extends Report { * 获取推送id */ pushEvent(options) { - if (uni.getPushClientId) { + const ClientID = is_push_clientid(); + if (uni.getPushClientId && ClientID) { uni.getPushClientId({ success: (res) => { const cid = res.cid || false; diff --git a/packages/uni-stat/dist/uni-cloud-stat.es.js b/packages/uni-stat/dist/uni-cloud-stat.es.js index 27ec6ed10..bb5e3c572 100644 --- a/packages/uni-stat/dist/uni-cloud-stat.es.js +++ b/packages/uni-stat/dist/uni-cloud-stat.es.js @@ -472,7 +472,6 @@ const is_debug = debug; * @param {*} data */ const log = (data, type) => { - let msg_type = ''; switch (data.lt) { case '1': @@ -498,7 +497,7 @@ const log = (data, type) => { // #ifdef APP // 在 app 中,日志转为 字符串 - if(typeof data === 'object') { + if (typeof data === 'object') { data = JSON.stringify(data); } // #endif @@ -530,6 +529,17 @@ const get_report_Interval = (defaultTime) => { // 如果不是整数,则默认为上报间隔时间 if (!reg.test(time)) return defaultTime return Number(time) +}; + +/** + * 获取隐私协议配置 + */ +const is_push_clientid = () => { + if (uniStatisticsConfig.collectItems) { + const ClientID = uniStatisticsConfig.collectItems.uniPushClientID; + return typeof ClientID === 'boolean' ? ClientID : false + } + return false }; const appid = process.env.UNI_APP_ID; // 做应用隔离 @@ -1302,7 +1312,8 @@ class Stat extends Report { * 获取推送id */ pushEvent(options) { - if (uni.getPushClientId) { + const ClientID = is_push_clientid(); + if (uni.getPushClientId && ClientID) { uni.getPushClientId({ success: (res) => { const cid = res.cid || false; diff --git a/packages/uni-stat/dist/uni-stat.cjs.js b/packages/uni-stat/dist/uni-stat.cjs.js index 3a4b61d61..4b720b853 100644 --- a/packages/uni-stat/dist/uni-stat.cjs.js +++ b/packages/uni-stat/dist/uni-stat.cjs.js @@ -453,7 +453,6 @@ const is_debug = debug; * @param {*} data */ const log = (data, type) => { - let msg_type = ''; switch (data.lt) { case '1': @@ -479,7 +478,7 @@ const log = (data, type) => { // #ifdef APP // 在 app 中,日志转为 字符串 - if(typeof data === 'object') { + if (typeof data === 'object') { data = JSON.stringify(data); } // #endif @@ -511,6 +510,17 @@ const get_report_Interval = (defaultTime) => { // 如果不是整数,则默认为上报间隔时间 if (!reg.test(time)) return defaultTime return Number(time) +}; + +/** + * 获取隐私协议配置 + */ +const is_push_clientid = () => { + if (uniStatisticsConfig.collectItems) { + const ClientID = uniStatisticsConfig.collectItems.uniPushClientID; + return typeof ClientID === 'boolean' ? ClientID : false + } + return false }; const appid = process.env.UNI_APP_ID; // 做应用隔离 @@ -1268,7 +1278,8 @@ class Stat extends Report { * 获取推送id */ pushEvent(options) { - if (uni.getPushClientId) { + const ClientID = is_push_clientid(); + if (uni.getPushClientId && ClientID) { uni.getPushClientId({ success: (res) => { const cid = res.cid || false; diff --git a/packages/uni-stat/dist/uni-stat.es.js b/packages/uni-stat/dist/uni-stat.es.js index 389a66f8c..9cc9dea8d 100644 --- a/packages/uni-stat/dist/uni-stat.es.js +++ b/packages/uni-stat/dist/uni-stat.es.js @@ -451,7 +451,6 @@ const is_debug = debug; * @param {*} data */ const log = (data, type) => { - let msg_type = ''; switch (data.lt) { case '1': @@ -477,7 +476,7 @@ const log = (data, type) => { // #ifdef APP // 在 app 中,日志转为 字符串 - if(typeof data === 'object') { + if (typeof data === 'object') { data = JSON.stringify(data); } // #endif @@ -509,6 +508,17 @@ const get_report_Interval = (defaultTime) => { // 如果不是整数,则默认为上报间隔时间 if (!reg.test(time)) return defaultTime return Number(time) +}; + +/** + * 获取隐私协议配置 + */ +const is_push_clientid = () => { + if (uniStatisticsConfig.collectItems) { + const ClientID = uniStatisticsConfig.collectItems.uniPushClientID; + return typeof ClientID === 'boolean' ? ClientID : false + } + return false }; const appid = process.env.UNI_APP_ID; // 做应用隔离 @@ -1266,7 +1276,8 @@ class Stat extends Report { * 获取推送id */ pushEvent(options) { - if (uni.getPushClientId) { + const ClientID = is_push_clientid(); + if (uni.getPushClientId && ClientID) { uni.getPushClientId({ success: (res) => { const cid = res.cid || false; diff --git a/packages/uni-stat/src/core/stat.js b/packages/uni-stat/src/core/stat.js index df79cc259..f2141e30e 100644 --- a/packages/uni-stat/src/core/stat.js +++ b/packages/uni-stat/src/core/stat.js @@ -6,6 +6,7 @@ import { get_platform_name, get_space, is_debug, + is_push_clientid } from '../utils/pageInfo.js' import { dbSet } from '../utils/db.js' class Stat extends Report { @@ -51,7 +52,8 @@ class Stat extends Report { * 获取推送id */ pushEvent(options) { - if (uni.getPushClientId) { + const ClientID = is_push_clientid() + if (uni.getPushClientId && ClientID) { uni.getPushClientId({ success: (res) => { const cid = res.cid || false diff --git a/packages/uni-stat/src/utils/pageInfo.js b/packages/uni-stat/src/utils/pageInfo.js index 1f72f178c..3ffcc8cdd 100644 --- a/packages/uni-stat/src/utils/pageInfo.js +++ b/packages/uni-stat/src/utils/pageInfo.js @@ -481,7 +481,6 @@ export const is_debug = debug * @param {*} data */ export const log = (data, type) => { - let msg_type = '' switch (data.lt) { case '1': @@ -507,7 +506,7 @@ export const log = (data, type) => { // #ifdef APP // 在 app 中,日志转为 字符串 - if(typeof data === 'object') { + if (typeof data === 'object') { data = JSON.stringify(data) } // #endif @@ -540,3 +539,14 @@ export const get_report_Interval = (defaultTime) => { if (!reg.test(time)) return defaultTime return Number(time) } + +/** + * 获取隐私协议配置 + */ +export const is_push_clientid = () => { + if (uniStatisticsConfig.collectItems) { + const ClientID = uniStatisticsConfig.collectItems.uniPushClientID + return typeof ClientID === 'boolean' ? ClientID : false + } + return false +} -- GitLab