diff --git a/packages/uni-stat/dist/uni-cloud-stat.cjs.js b/packages/uni-stat/dist/uni-cloud-stat.cjs.js index 0f628fd908edb83584391ee9fe97752cd228cb9f..10eeafa2cc08fad9403107fd0445a065f4743edc 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 27ec6ed10cdb56090bdbc7564857bb0e099e50bc..bb5e3c572689b20d37559faee4c3ff8e7f8ff340 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 3a4b61d61c1dc02f4e59effb318a06cb91fa7cd6..4b720b853fe5ca4871731f07c732ee9efc85cefb 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 389a66f8cd10c04937f6c664be687b54c80f77fd..9cc9dea8d8205189d7495bb5cc7bf19570da727d 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 df79cc259d7baecec0d90d345d4457f12f6dbc89..f2141e30ecb20485f17b3cd970d342254c7eac70 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 1f72f178cd4a1f622ff0b39ef4e05b12d1fe6aed..3ffcc8cdd56893b1a8e37a5b811ca29d68be1508 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 +}