提交 1d7a1e52 编写于 作者: M mehaotian

fix: 统计新增测试例,放开统计入口,统计debug设置为true ,发版后可关闭

上级 69dca45a
......@@ -49,15 +49,15 @@
// 统计上报 - 应用启动
// #ifdef APP-ANDROID || APP-IOS || WEB
// uni.report({
// name: 'uni-app-launch',
// options: res,
// success(res_data) {
// console.log(res_data);
// }, fail(err) {
// console.log(err);
// }
// })
uni.report({
name: 'uni-app-launch',
options: res,
success(res_data) {
console.log(res_data);
}, fail(err) {
console.log(err);
}
})
// #endif
// #ifdef APP
if (process.env.NODE_ENV !== 'development') { //真机运行可以注释此条件
......@@ -90,14 +90,14 @@
// #ifdef APP-ANDROID || APP-IOS || WEB
// 统计上报 - 应用显示
// uni.report({
// name: 'uni-app-show',
// success(res_data) {
// console.log(res_data);
// }, fail(err) {
// console.log(err);
// }
// })
uni.report({
name: 'uni-app-show',
success(res_data) {
console.log(res_data);
}, fail(err) {
console.log(err);
}
})
// #endif
},
onHide: function () {
......@@ -107,14 +107,14 @@
// #ifdef APP-ANDROID || APP-IOS || WEB
// 统计上报 - 应用进入后台
// uni.report({
// name: 'uni-app-hide',
// success(res) {
// console.log(res);
// }, fail(err) {
// console.log(err);
// }
// })
uni.report({
name: 'uni-app-hide',
success(res) {
console.log(res);
}, fail(err) {
console.log(err);
}
})
// #endif
},
// #ifdef APP-ANDROID
......@@ -144,15 +144,15 @@
// console.log('App onError', err)
// #ifdef APP-ANDROID || APP-IOS || WEB
// 统计上报 - 应用发生错误
// uni.report({
// name: 'uni-app-error',
// options: err,
// success(res) {
// console.log(res);
// }, fail(err) {
// console.log(err);
// }
// })
uni.report({
name: 'uni-app-error',
options: err,
success(res) {
console.log(res);
}, fail(err) {
console.log(err);
}
})
// #endif
},
methods: {
......
// 仅测试 console.log 时机问题
import './test-main-console.uts'
// // #ifdef APP-ANDROID || APP-IOS || WEB
// import { uniStat } from '@/uni_modules/uni-stat/plugin.uts'
// // #endif
// #ifdef APP-ANDROID || APP-IOS || WEB
import { uniStat } from '@/uni_modules/uni-stat/plugin.uts'
// #endif
import App from './App.uvue'
import { createSSRApp } from 'vue'
// // 统计配置
// const uniStatcollectItems = {
// uniStatPageLog: true
// }
// 统计配置
const uniStatcollectItems = {
uniStatPageLog: true
}
// const uniStatOptions = {
// debug: true,
// collectItems: uniStatcollectItems,
// }
const uniStatOptions = {
debug: true,
collectItems: uniStatcollectItems,
}
export function createApp() {
const app = createSSRApp(App)
// // #ifdef APP-ANDROID || APP-IOS || WEB
// app.use(uniStat, uniStatOptions)
// // #endif
// #ifdef APP-ANDROID || APP-IOS || WEB
app.use(uniStat, uniStatOptions)
// #endif
// app.mixin({
// onReady() {
// setTimeout(() => {
......
......@@ -1218,6 +1218,7 @@
},
{
"path": "pages/API/report/report",
"group": "1,17,0",
"style": {
"navigationBarTitleText": "report | 统计采集上报"
}
......
const PAGE_PATH = '/pages/API/report/report'
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isAndroid = platformInfo.startsWith('android')
describe('report', () => {
let page = null
beforeAll(async () => {
page = await program.navigateTo(PAGE_PATH)
await page.waitFor('view')
})
it('Report - onLaunch', async () => {
await page.callMethod('handleAppLaunch')
const msg = await page.data('msg')
expect(msg).toBe('onLaunch --> report:ok')
})
it('Report - onShow', async () => {
await page.callMethod('handleAppShow')
const msg = await page.data('msg')
expect(msg).toBe('onAppShow --> report:ok')
})
it('Report - onHide', async () => {
await page.callMethod('handleAppHide')
const msg = await page.data('msg')
expect(msg).toBe('onAppHide --> report:ok')
})
it('Report - onError', async () => {
await page.callMethod('handleAppError')
const msg = await page.data('msg')
expect(msg).toBe('onAppError --> report:ok')
})
})
......@@ -2,12 +2,30 @@
<!-- #ifdef APP -->
<scroll-view style="flex:1">
<!-- #endif -->
<text class="instructions">
当前页面调用API均为模拟,请查看文档,在特定场景下使用以下 API。请在main.uts中设置统计debug配置为true,并点击按钮查控制台输出。
</text>
<button class="normal-button" type="default" @click="handleAppLunch">
创建本地通知消息 | createPushMessage
</button>
<page-head title="report"></page-head>
<view class="tips">
<view class="tips-title">调用信息:</view>
<view class="tips-content">{{msg}}</view>
</view>
<view class="page">
<button class="normal-button" type="default" @click="handleAppLaunch">
模拟应用启动
</button>
<button class="normal-button" type="default" @click="handleAppHide">
模拟应用切入后台
</button>
<button class="normal-button" type="default" @click="handleAppShow">
模拟应用切入前台
</button>
<button class="normal-button" type="default" @click="handleAppError">
模拟应用错误
</button>
<text class="instructions">
当前页面调用API均为模拟,请查看文档,在特定场景下使用以上 API。请在main.uts中设置统计debug配置为true,并点击按钮查控制台输出。
</text>
</view>
<!-- #ifdef APP -->
</scroll-view>
......@@ -18,29 +36,93 @@
export default {
data() {
return {
msg: '点击按钮,测试上报'
}
},
methods: {
handleAppLunch() {
const options = uni.getLaunchOptionsSync()
handleAppLaunch() {
const options = uni.getLaunchOptionsSync()
uni.report({
name: 'uni-app-launch',
options: options,
success(data) {
console.log(data);
}, fail(err) {
success:(res)=> {
this.msg = 'onLaunch --> ' + res.errMsg
console.log(res);
}, fail:(err)=> {
this.msg = 'onLaunch --> ' + err.errMsg
console.log(err);
}
})
}
},
handleAppHide() {
uni.report({
name: 'uni-app-hide',
success:(res)=> {
this.msg = 'onAppHide --> ' + res.errMsg
console.log(res);
}, fail:(err)=> {
this.msg = 'onAppHide --> ' + err.errMsg
console.log(err);
}
})
},
handleAppShow() {
// const options = uni.getLaunchOptionsSync()
uni.report({
name: 'uni-app-show',
success:(res)=> {
this.msg = 'onAppShow --> ' + res.errMsg
console.log(res);
}, fail:(err)=> {
this.msg = 'onAppShow --> ' + err.errMsg
console.log(err);
}
})
},
handleAppError() {
const errmsg = '测试错误'
uni.report({
name: 'uni-app-error',
options: errmsg,
success:(res)=> {
this.msg = 'onAppError --> ' + res.errMsg
console.log(res);
}, fail:(err)=> {
this.msg = 'onAppError --> ' + err.errMsg
console.log(err);
}
})
},
}
}
</script>
<style>
.page {
padding: 15px;
}
.tips {
margin: 15px;
padding: 15px;
background-color: #f5f5f5;
font-size: 14px;
text-align: center;
}
.tips-title {
font-size: 16px;
color: #333;
margin-bottom: 10px;
}
.tips-content {
font-size: 14px;
color: #999;
}
.normal-button {
width: 100%;
margin-bottom: 10px;
}
.instructions {
......@@ -48,5 +130,7 @@
margin-left: 10px;
margin-right: 10px;
background-color: #eee;
font-size: 12px;
color: #999;
}
</style>
......@@ -11,11 +11,11 @@ const lifecycle = defineMixin({
stat_instance.onLoad(this)
},
// @ts-ignore
onPageShow() {
onShow() {
stat_instance.onShow(this)
},
// @ts-ignore
onPageHide() {
onHide() {
stat_instance.onHide(this)
},
// @ts-ignore
......
......@@ -291,8 +291,6 @@ export class Report {
}
appError(em : any) {
console.log('发生了错误123');
console.log(em);
let errmsg : string
// #ifdef APP-ANDROID
// @ts-ignore
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册