提交 9821edb3 编写于 作者: fxy060608's avatar fxy060608

chore(stat): build

上级 752dc8cc
......@@ -18,8 +18,7 @@ const STAT_H5_URL = 'https://tongji.dcloud.io/uni/stat.gif';
const PAGE_PVER_TIME = 1800; // 页面在前台无操作结束访问时间 单位s
const APP_PVER_TIME = 300; // 应用在后台结束访问时间 单位s
const OPERATING_TIME = 10; // 数据上报时间 单位s
const DIFF_TIME = 60 * 1000 * 60 * 24;
const DEBUG = true;
const DIFF_TIME = 60 * 1000 * 60 * 24;
let statConfig = {
appid: ''
......@@ -1037,14 +1036,7 @@ class Report {
* @param {Object} optionsData 需要上报的数据
*/
sendRequest(optionsData) {
if (DEBUG) {
console.log('----- 数据上报开始 -----');
console.log('上报数据:', optionsData);
console.log('----- 数据上报结束 -----');
}
{
console.log('-- callFunction 上报');
if (!uniCloud.config) {
console.error('当前尚未绑定服务空间.');
return
......@@ -1052,12 +1044,8 @@ class Report {
uniCloud.callFunction({
name: 'uni-stat-report',
data: optionsData,
success: (res) => {
console.log(res);
},
fail: (err) => {
console.log(err);
}
success: (res) => {},
fail: (err) => {}
});
}
}
......@@ -1248,17 +1236,17 @@ const lifecycle = {
function main() {
console.log('--- 统计开启');
// if (process.env.NODE_ENV === 'development') {
// uni.report = function(type, options) {}
// } else {
// console.log('--- 统计开启')
if (process.env.NODE_ENV === 'development') {
uni.report = function(type, options) {};
} else {
// #ifdef VUE3
// uni.onCreateVueApp((app) => {
// app.mixin(lifecycle)
// uni.report = function(type, options) {
// stat.sendEvent(type, options)
// }
// })
uni.onCreateVueApp((app) => {
app.mixin(lifecycle);
uni.report = function(type, options) {
stat.sendEvent(type, options);
};
});
uni.onAppLaunch((options) => {
stat.launch(options);
// 小程序平台此时也无法获取getApp,统一在options中传递一个app mixin对象
......@@ -1266,15 +1254,15 @@ function main() {
uni.report = function (type, options) {
stat.sendEvent(type, options);
};
});
if (get_platform_name() !== 'h5' && get_platform_name() !== 'n') {
uni.onAppHide(() => {
stat.appHide(get_page_vm());
});
uni.onAppShow(() => {
stat.appShow(get_page_vm());
});
});
if (get_platform_name() !== 'h5' && get_platform_name() !== 'n') {
uni.onAppHide(() => {
stat.appHide(get_page_vm());
});
uni.onAppShow(() => {
stat.appShow(get_page_vm());
});
}
// #endif
......@@ -1285,6 +1273,7 @@ function main() {
stat.sendEvent(type, options);
};
// #endif
}
}
main();
......@@ -12,8 +12,7 @@ const STAT_H5_URL = 'https://tongji.dcloud.io/uni/stat.gif';
const PAGE_PVER_TIME = 1800; // 页面在前台无操作结束访问时间 单位s
const APP_PVER_TIME = 300; // 应用在后台结束访问时间 单位s
const OPERATING_TIME = 10; // 数据上报时间 单位s
const DIFF_TIME = 60 * 1000 * 60 * 24;
const DEBUG = true;
const DIFF_TIME = 60 * 1000 * 60 * 24;
let statConfig = {
appid: ''
......@@ -1031,14 +1030,7 @@ class Report {
* @param {Object} optionsData 需要上报的数据
*/
sendRequest(optionsData) {
if (DEBUG) {
console.log('----- 数据上报开始 -----');
console.log('上报数据:', optionsData);
console.log('----- 数据上报结束 -----');
}
{
console.log('-- callFunction 上报');
if (!uniCloud.config) {
console.error('当前尚未绑定服务空间.');
return
......@@ -1046,12 +1038,8 @@ class Report {
uniCloud.callFunction({
name: 'uni-stat-report',
data: optionsData,
success: (res) => {
console.log(res);
},
fail: (err) => {
console.log(err);
}
success: (res) => {},
fail: (err) => {}
});
}
}
......@@ -1242,17 +1230,17 @@ const lifecycle = {
function main() {
console.log('--- 统计开启');
// if (process.env.NODE_ENV === 'development') {
// uni.report = function(type, options) {}
// } else {
// console.log('--- 统计开启')
if (process.env.NODE_ENV === 'development') {
uni.report = function(type, options) {};
} else {
// #ifdef VUE3
// uni.onCreateVueApp((app) => {
// app.mixin(lifecycle)
// uni.report = function(type, options) {
// stat.sendEvent(type, options)
// }
// })
uni.onCreateVueApp((app) => {
app.mixin(lifecycle);
uni.report = function(type, options) {
stat.sendEvent(type, options);
};
});
uni.onAppLaunch((options) => {
stat.launch(options);
// 小程序平台此时也无法获取getApp,统一在options中传递一个app mixin对象
......@@ -1260,15 +1248,15 @@ function main() {
uni.report = function (type, options) {
stat.sendEvent(type, options);
};
});
if (get_platform_name() !== 'h5' && get_platform_name() !== 'n') {
uni.onAppHide(() => {
stat.appHide(get_page_vm());
});
uni.onAppShow(() => {
stat.appShow(get_page_vm());
});
});
if (get_platform_name() !== 'h5' && get_platform_name() !== 'n') {
uni.onAppHide(() => {
stat.appHide(get_page_vm());
});
uni.onAppShow(() => {
stat.appShow(get_page_vm());
});
}
// #endif
......@@ -1279,6 +1267,7 @@ function main() {
stat.sendEvent(type, options);
};
// #endif
}
}
main();
// 访问开始即启动小程序,访问结束结分为:进入后台超过5min、在前台无任何操作超过30min、在新的来源打开小程序;
export const STAT_VERSION = '0.0.1'
// 访问开始即启动小程序,访问结束结分为:进入后台超过5min、在前台无任何操作超过30min、在新的来源打开小程序;
export const STAT_VERSION = '0.0.1'
export const STAT_URL = 'https://tongji.dcloud.io/uni/stat'
export const STAT_H5_URL = 'https://tongji.dcloud.io/uni/stat.gif'
export const STAT_KEY = 'qkTHEIegZGcL5iy3'
export const PAGE_PVER_TIME = 1800 // 页面在前台无操作结束访问时间 单位s
export const APP_PVER_TIME = 300 // 应用在后台结束访问时间 单位s
export const OPERATING_TIME = 10 // 数据上报时间 单位s
export const STAT_KEY = 'qkTHEIegZGcL5iy3'
export const PAGE_PVER_TIME = 1800 // 页面在前台无操作结束访问时间 单位s
export const APP_PVER_TIME = 300 // 应用在后台结束访问时间 单位s
export const OPERATING_TIME = 10 // 数据上报时间 单位s
export const DIFF_TIME = 60 * 1000 * 60 * 24
export const DEBUG = true
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册