提交 72be4121 编写于 作者: M mehaotian

fix: 新增统计测试例

上级 93c1b2b9
...@@ -48,15 +48,17 @@ ...@@ -48,15 +48,17 @@
// } as PerformanceObserverOptions) // } as PerformanceObserverOptions)
// 统计上报 - 应用启动 // 统计上报 - 应用启动
// uni.report({ // #ifdef APP-ANDROID || APP-IOS || WEB
// name: 'uni-app-launch', uni.report({
// options: res, name: 'uni-app-launch',
// success(res_data) { options: res,
// console.log(res_data); success(res_data) {
// }, fail(err) { console.log(res_data);
// console.log(err); }, fail(err) {
// } console.log(err);
// }) }
})
// #endif
// #ifdef APP // #ifdef APP
if (process.env.NODE_ENV !== 'development') { //真机运行可以注释此条件 if (process.env.NODE_ENV !== 'development') { //真机运行可以注释此条件
uni.getPrivacySetting({ uni.getPrivacySetting({
...@@ -86,30 +88,34 @@ ...@@ -86,30 +88,34 @@
setLifeCycleNum(state.lifeCycleNum + 100) setLifeCycleNum(state.lifeCycleNum + 100)
console.log('App Show') console.log('App Show')
// #ifdef APP-ANDROID || APP-IOS || WEB
// 统计上报 - 应用显示 // 统计上报 - 应用显示
// uni.report({ uni.report({
// name: 'uni-app-show', name: 'uni-app-show',
// success(res_data) { success(res_data) {
// console.log(res_data); console.log(res_data);
// }, fail(err) { }, fail(err) {
// console.log(err); console.log(err);
// } }
// }) })
// #endif
}, },
onHide: function () { onHide: function () {
// 自动化测试 // 自动化测试
setLifeCycleNum(state.lifeCycleNum - 100) setLifeCycleNum(state.lifeCycleNum - 100)
console.log('App Hide') console.log('App Hide')
// #ifdef APP-ANDROID || APP-IOS || WEB
// 统计上报 - 应用进入后台 // 统计上报 - 应用进入后台
// uni.report({ uni.report({
// name: 'uni-app-hide', name: 'uni-app-hide',
// success(res) { success(res) {
// console.log(res); console.log(res);
// }, fail(err) { }, fail(err) {
// console.log(err); console.log(err);
// } }
// }) })
// #endif
}, },
// #ifdef APP-ANDROID // #ifdef APP-ANDROID
onLastPageBackPress: function () { onLastPageBackPress: function () {
...@@ -136,18 +142,18 @@ ...@@ -136,18 +142,18 @@
// #endif // #endif
onError(err : any) { onError(err : any) {
console.log('App onError', err) console.log('App onError', err)
// // #ifdef APP-ANDROID || APP-IOS || WEB // #ifdef APP-ANDROID || APP-IOS || WEB
// // 统计上报 - 应用发生错误 // 统计上报 - 应用发生错误
// uni.report({ uni.report({
// name: 'uni-app-error', name: 'uni-app-error',
// options: err, options: err,
// success(res) { success(res) {
// console.log(res); console.log(res);
// }, fail(err) { }, fail(err) {
// console.log(err); console.log(err);
// } }
// }) })
// // #endif // #endif
}, },
methods: { methods: {
increasetLifeCycleNum() { increasetLifeCycleNum() {
......
// 仅测试 console.log 时机问题 // 仅测试 console.log 时机问题
import './test-main-console.uts' import './test-main-console.uts'
// import { uniStat } from '@/uni_modules/uni-stat/plugin.uts' // #ifdef APP-ANDROID || APP-IOS || WEB
import { uniStat } from '@/uni_modules/uni-stat/plugin.uts'
// #endif
import App from './App.uvue' import App from './App.uvue'
import { createSSRApp } from 'vue' import { createSSRApp } from 'vue'
// 统计配置 // 统计配置
// const collectItems = { const uniStatcollectItems = {
// uniStatPageLog: true uniStatPageLog: true
// } }
// const statOptions = { const uniStatOptions = {
// debug: false, debug: true,
// collectItems: collectItems, collectItems: uniStatcollectItems,
// } }
export function createApp() { export function createApp() {
const app = createSSRApp(App) const app = createSSRApp(App)
// app.use(uniStat, statOptions) // #ifdef APP-ANDROID || APP-IOS || WEB
app.use(uniStat, uniStatOptions)
// #endif
// app.mixin({ // app.mixin({
// onReady() { // onReady() {
// setTimeout(() => { // setTimeout(() => {
......
...@@ -64,6 +64,7 @@ ...@@ -64,6 +64,7 @@
"navigationBarTitleText": "swiper | 滑块视图容器" "navigationBarTitleText": "swiper | 滑块视图容器"
} }
}, },
// #ifdef APP-ANDROID || APP-IOS || WEB
{ {
"path": "pages/component/list-view/list-view", "path": "pages/component/list-view/list-view",
"group": "0,1,6", "group": "0,1,6",
...@@ -118,6 +119,7 @@ ...@@ -118,6 +119,7 @@
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
// #endif
{ {
"path": "pages/component/text/text", "path": "pages/component/text/text",
"group": "0,2,1", "group": "0,2,1",
...@@ -376,7 +378,7 @@ ...@@ -376,7 +378,7 @@
"navigationBarTitleText": "Touch Events bubbles" "navigationBarTitleText": "Touch Events bubbles"
} }
}, },
// #ifndef WEB // #ifdef APP-ANDROID || APP-IOS
{ {
"path": "pages/component/nested-scroll-header/nested-scroll-header", "path": "pages/component/nested-scroll-header/nested-scroll-header",
"group": "0,1,8,0", "group": "0,1,8,0",
...@@ -385,7 +387,7 @@ ...@@ -385,7 +387,7 @@
} }
}, },
// #endif // #endif
// #ifndef WEB // #ifdef APP-ANDROID || APP-IOS
{ {
"path": "pages/component/nested-scroll-body/nested-scroll-body", "path": "pages/component/nested-scroll-body/nested-scroll-body",
"group": "0,1,8,1", "group": "0,1,8,1",
...@@ -394,6 +396,7 @@ ...@@ -394,6 +396,7 @@
} }
}, },
// #endif // #endif
// #ifdef APP-ANDROID || APP-IOS || WEB
{ {
"path": "pages/component/swiper/swiper-list-view", "path": "pages/component/swiper/swiper-list-view",
"style": { "style": {
...@@ -401,7 +404,8 @@ ...@@ -401,7 +404,8 @@
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
// #ifdef WEB // #endif
// #ifdef WEB || MP
{ {
"path": "pages/component/movable-view/movable-view", "path": "pages/component/movable-view/movable-view",
"group": "0,1,4,1", "group": "0,1,4,1",
...@@ -410,7 +414,7 @@ ...@@ -410,7 +414,7 @@
} }
}, },
// #endif // #endif
// #ifdef WEB // #ifdef WEB || MP
{ {
"path": "pages/component/label/label", "path": "pages/component/label/label",
"group": "0,3,5", "group": "0,3,5",
...@@ -419,7 +423,7 @@ ...@@ -419,7 +423,7 @@
} }
}, },
// #endif // #endif
// #ifdef WEB // #ifdef WEB || MP
{ {
"path": "pages/component/picker/picker", "path": "pages/component/picker/picker",
"group": "0,3,6", "group": "0,3,6",
...@@ -428,7 +432,6 @@ ...@@ -428,7 +432,6 @@
} }
}, },
// #endif // #endif
// #ifdef WEB || APP
{ {
"path": "pages/component/map/map", "path": "pages/component/map/map",
"group": "0,6", "group": "0,6",
...@@ -436,8 +439,7 @@ ...@@ -436,8 +439,7 @@
"navigationBarTitleText": "map | 地图" "navigationBarTitleText": "map | 地图"
} }
}, },
// #endif // #ifdef WEB || MP
// #ifdef WEB
{ {
"path": "pages/component/cover-view/cover-view", "path": "pages/component/cover-view/cover-view",
"group": "0,1,5,0", "group": "0,1,5,0",
...@@ -446,7 +448,7 @@ ...@@ -446,7 +448,7 @@
} }
}, },
// #endif // #endif
// #ifdef WEB // #ifdef WEB || MP
{ {
"path": "pages/component/editor/editor", "path": "pages/component/editor/editor",
"group": "0,3,4", "group": "0,3,4",
...@@ -455,6 +457,7 @@ ...@@ -455,6 +457,7 @@
} }
}, },
// #endif // #endif
// #ifdef APP-ANDROID || APP-IOS || WEB
{ {
"path": "pages/component/list-view/issue-2199", "path": "pages/component/list-view/issue-2199",
"style": { "style": {
...@@ -462,6 +465,8 @@ ...@@ -462,6 +465,8 @@
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
// #endif
// #ifdef APP-ANDROID || APP-IOS || WEB || MP-WEIXIN
{ {
"path": "pages/component/canvas/canvas", "path": "pages/component/canvas/canvas",
"group": "0,7", "group": "0,7",
...@@ -469,12 +474,16 @@ ...@@ -469,12 +474,16 @@
"navigationBarTitleText": "canvas | 画布" "navigationBarTitleText": "canvas | 画布"
} }
}, },
// #endif
// #ifdef APP-ANDROID || APP-IOS || WEB || MP-WEIXIN
{ {
"path": "pages/component/canvas/canvas-context", "path": "pages/component/canvas/canvas-context",
"style": { "style": {
"navigationBarTitleText": "createCanvasContextAsync" "navigationBarTitleText": "createCanvasContextAsync"
} }
}, },
// #endif
// #ifdef APP-ANDROID || APP-IOS || WEB || MP-WEIXIN
{ {
"path": "pages/component/canvas/canvas/ball", "path": "pages/component/canvas/canvas/ball",
"group": "0,7", "group": "0,7",
...@@ -482,6 +491,8 @@ ...@@ -482,6 +491,8 @@
"navigationBarTitleText": "ball" "navigationBarTitleText": "ball"
} }
}, },
// #endif
// #ifdef APP-ANDROID || APP-IOS || WEB || MP-WEIXIN
{ {
"path": "pages/component/canvas/canvas/doodle", "path": "pages/component/canvas/canvas/doodle",
"group": "0,7", "group": "0,7",
...@@ -489,7 +500,8 @@ ...@@ -489,7 +500,8 @@
"navigationBarTitleText": "涂鸦" "navigationBarTitleText": "涂鸦"
} }
}, },
// #ifndef WEB // #endif
// #ifdef APP-ANDROID || APP-IOS
{ {
"path": "pages/component/native-view/native-view", "path": "pages/component/native-view/native-view",
"group": "0,2,4", "group": "0,2,4",
...@@ -498,7 +510,7 @@ ...@@ -498,7 +510,7 @@
} }
}, },
// #endif // #endif
// #ifndef WEB // #ifdef APP-ANDROID || APP-IOS
{ {
"path": "pages/component/ad/ad", "path": "pages/component/ad/ad",
"group": "0,8", "group": "0,8",
...@@ -508,7 +520,7 @@ ...@@ -508,7 +520,7 @@
} }
}, },
// #endif // #endif
// #ifndef WEB // #ifdef APP-ANDROID || APP-IOS
{ {
"path": "pages/component/ad/list-view-ad", "path": "pages/component/ad/list-view-ad",
"style": { "style": {
...@@ -531,7 +543,7 @@ ...@@ -531,7 +543,7 @@
"navigationBarTitleText": "getApp | 获取当前应用实例" "navigationBarTitleText": "getApp | 获取当前应用实例"
} }
}, },
// #ifdef APP-ANDROID // #ifdef APP
{ {
"path": "pages/API/exit/exit", "path": "pages/API/exit/exit",
"group": "1,1,5", "group": "1,1,5",
...@@ -647,7 +659,7 @@ ...@@ -647,7 +659,7 @@
"navigationBarTitleText": "storage | key-value本地数据存储" "navigationBarTitleText": "storage | key-value本地数据存储"
} }
}, },
// #ifndef WEB // #ifdef APP-ANDROID || APP-IOS
{ {
"path": "pages/API/get-file-system-manager/get-file-system-manager", "path": "pages/API/get-file-system-manager/get-file-system-manager",
"group": "1,11,0", "group": "1,11,0",
...@@ -656,7 +668,7 @@ ...@@ -656,7 +668,7 @@
} }
}, },
// #endif // #endif
// #ifndef WEB // #ifdef APP-ANDROID || APP-IOS
{ {
"path": "pages/API/env/env", "path": "pages/API/env/env",
"group": "1,1,0", "group": "1,1,0",
...@@ -713,7 +725,7 @@ ...@@ -713,7 +725,7 @@
"navigationBarTitleText": "getLocation | 获取当前位置" "navigationBarTitleText": "getLocation | 获取当前位置"
} }
}, },
// #ifdef WEB // #ifdef WEB || MP
{ {
"path": "pages/API/open-location/open-location", "path": "pages/API/open-location/open-location",
"group": "1,9,1", "group": "1,9,1",
...@@ -722,7 +734,7 @@ ...@@ -722,7 +734,7 @@
} }
}, },
// #endif // #endif
// #ifdef WEB // #ifdef WEB || MP
{ {
"path": "pages/API/choose-location/choose-location", "path": "pages/API/choose-location/choose-location",
"group": "1,9,2", "group": "1,9,2",
...@@ -819,7 +831,7 @@ ...@@ -819,7 +831,7 @@
"navigationBarTitleText": "getAppBaseInfo | 获取APP基础信息" "navigationBarTitleText": "getAppBaseInfo | 获取APP基础信息"
} }
}, },
// #ifndef WEB // #ifdef APP-ANDROID || APP-IOS
{ {
"path": "pages/API/get-system-setting/get-system-setting", "path": "pages/API/get-system-setting/get-system-setting",
"group": "1,6,5", "group": "1,6,5",
...@@ -828,7 +840,7 @@ ...@@ -828,7 +840,7 @@
} }
}, },
// #endif // #endif
// #ifndef WEB // #ifdef APP-ANDROID || APP-IOS
{ {
"path": "pages/API/element-takesnapshot/element-takesnapshot", "path": "pages/API/element-takesnapshot/element-takesnapshot",
"group": "1,30", "group": "1,30",
...@@ -838,7 +850,7 @@ ...@@ -838,7 +850,7 @@
} }
}, },
// #endif // #endif
// #ifndef WEB // #ifdef APP-ANDROID || APP-IOS
{ {
"path": "pages/API/get-app-authorize-setting/get-app-authorize-setting", "path": "pages/API/get-app-authorize-setting/get-app-authorize-setting",
"group": "1,6,4", "group": "1,6,4",
...@@ -868,7 +880,7 @@ ...@@ -868,7 +880,7 @@
"navigationBarTitleText": "getImageInfo | 获取图片信息" "navigationBarTitleText": "getImageInfo | 获取图片信息"
} }
}, },
// #ifndef WEB // #ifdef APP-ANDROID || APP-IOS
{ {
"path": "pages/API/compress-image/compress-image", "path": "pages/API/compress-image/compress-image",
"group": "1,7,4", "group": "1,7,4",
...@@ -884,7 +896,7 @@ ...@@ -884,7 +896,7 @@
"navigationBarTitleText": "chooseVideo | 拍摄视频或从相册中选择视频" "navigationBarTitleText": "chooseVideo | 拍摄视频或从相册中选择视频"
} }
}, },
// #ifndef WEB // #ifdef APP-ANDROID || APP-IOS
{ {
"path": "pages/API/save-image-to-photos-album/save-image-to-photos-album", "path": "pages/API/save-image-to-photos-album/save-image-to-photos-album",
"group": "1,7,2", "group": "1,7,2",
...@@ -893,7 +905,7 @@ ...@@ -893,7 +905,7 @@
} }
}, },
// #endif // #endif
// #ifndef WEB // #ifdef APP-ANDROID || APP-IOS
{ {
"path": "pages/API/save-video-to-photos-album/save-video-to-photos-album", "path": "pages/API/save-video-to-photos-album/save-video-to-photos-album",
"group": "1,7,6", "group": "1,7,6",
...@@ -909,7 +921,7 @@ ...@@ -909,7 +921,7 @@
"navigationBarTitleText": "getVideoInfo | 获取视频信息" "navigationBarTitleText": "getVideoInfo | 获取视频信息"
} }
}, },
// #ifndef WEB // #ifdef APP-ANDROID || APP-IOS
{ {
"path": "pages/API/compress-video/compress-video", "path": "pages/API/compress-video/compress-video",
"group": "1,7,8", "group": "1,7,8",
...@@ -974,7 +986,7 @@ ...@@ -974,7 +986,7 @@
"navigationStyle": "custom" "navigationStyle": "custom"
} }
}, },
// #ifndef WEB // #ifdef APP-ANDROID || APP-IOS
{ {
"path": "pages/API/element-draw/element-draw", "path": "pages/API/element-draw/element-draw",
"group": "1,30", "group": "1,30",
...@@ -984,7 +996,7 @@ ...@@ -984,7 +996,7 @@
} }
}, },
// #endif // #endif
// #ifndef WEB // #ifdef APP-ANDROID || APP-IOS
{ {
"path": "pages/API/facial-recognition-meta-info/facial-recognition-meta-info", "path": "pages/API/facial-recognition-meta-info/facial-recognition-meta-info",
"group": "1,12,1", "group": "1,12,1",
...@@ -994,7 +1006,7 @@ ...@@ -994,7 +1006,7 @@
} }
}, },
// #endif // #endif
// #ifndef WEB // #ifdef APP-ANDROID || APP-IOS
{ {
"path": "pages/API/get-univerify-manager/get-univerify-manager", "path": "pages/API/get-univerify-manager/get-univerify-manager",
"group": "1,12,0", "group": "1,12,0",
...@@ -1022,7 +1034,7 @@ ...@@ -1022,7 +1034,7 @@
} }
}, },
// #endif // #endif
// #ifndef WEB // #ifdef APP-ANDROID || APP-IOS
{ {
"path": "pages/API/request-payment/request-payment", "path": "pages/API/request-payment/request-payment",
"group": "1,14,0", "group": "1,14,0",
...@@ -1032,7 +1044,7 @@ ...@@ -1032,7 +1044,7 @@
} }
}, },
// #endif // #endif
// #ifndef WEB // #ifdef APP-ANDROID || APP-IOS
{ {
"path": "pages/API/create-rewarded-video-ad/create-rewarded-video-ad", "path": "pages/API/create-rewarded-video-ad/create-rewarded-video-ad",
"group": "1,13,0", "group": "1,13,0",
...@@ -1076,7 +1088,7 @@ ...@@ -1076,7 +1088,7 @@
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
// #ifdef WEB // #ifdef WEB || MP
{ {
"path": "pages/API/make-phone-call/make-phone-call", "path": "pages/API/make-phone-call/make-phone-call",
"group": "1,6,8", "group": "1,6,8",
...@@ -1085,7 +1097,7 @@ ...@@ -1085,7 +1097,7 @@
} }
}, },
// #endif // #endif
// #ifdef WEB || APP-ANDROID // #ifdef WEB || MP || APP
{ {
"path": "pages/API/create-inner-audio-context/create-inner-audio-context", "path": "pages/API/create-inner-audio-context/create-inner-audio-context",
"group": "1,7,9", "group": "1,7,9",
...@@ -1094,7 +1106,7 @@ ...@@ -1094,7 +1106,7 @@
} }
}, },
// #endif // #endif
// #ifdef WEB || APP-ANDROID // #ifdef WEB || MP || APP
{ {
"path": "pages/API/create-inner-audio-context/inner-audio-format", "path": "pages/API/create-inner-audio-context/inner-audio-format",
"style": { "style": {
...@@ -1102,7 +1114,7 @@ ...@@ -1102,7 +1114,7 @@
} }
}, },
// #endif // #endif
// #ifdef WEB || APP-ANDROID // #ifdef WEB || MP || APP
{ {
"path": "pages/API/create-inner-audio-context/inner-audio-path", "path": "pages/API/create-inner-audio-context/inner-audio-path",
"style": { "style": {
...@@ -1110,7 +1122,7 @@ ...@@ -1110,7 +1122,7 @@
} }
}, },
// #endif // #endif
// #ifdef WEB // #ifdef WEB || MP
{ {
"path": "pages/API/clipboard/clipboard", "path": "pages/API/clipboard/clipboard",
"group": "1,6,9", "group": "1,6,9",
...@@ -1119,7 +1131,7 @@ ...@@ -1119,7 +1131,7 @@
} }
}, },
// #endif // #endif
// #ifdef WEB // #ifdef WEB || MP
{ {
"path": "pages/API/compass/compass", "path": "pages/API/compass/compass",
"group": "1,6,10", "group": "1,6,10",
...@@ -1128,7 +1140,7 @@ ...@@ -1128,7 +1140,7 @@
} }
}, },
// #endif // #endif
// #ifndef WEB // #ifdef APP-ANDROID || APP-IOS
{ {
"path": "pages/API/theme-change/theme-change", "path": "pages/API/theme-change/theme-change",
"group": "1,4,7", "group": "1,4,7",
...@@ -1138,6 +1150,7 @@ ...@@ -1138,6 +1150,7 @@
} }
}, },
// #endif // #endif
// #ifdef APP-ANDROID || APP-IOS || WEB
{ {
"path": "pages/API/get-element-by-id/get-element-by-id", "path": "pages/API/get-element-by-id/get-element-by-id",
"group": "1,3,0", "group": "1,3,0",
...@@ -1145,12 +1158,15 @@ ...@@ -1145,12 +1158,15 @@
"navigationBarTitleText": "getElementById | 通过 id 获取 element" "navigationBarTitleText": "getElementById | 通过 id 获取 element"
} }
}, },
// #endif
// #ifdef APP-ANDROID || APP-IOS || WEB
{ {
"path": "pages/API/get-element-by-id/get-element-by-id-multiple-root-node", "path": "pages/API/get-element-by-id/get-element-by-id-multiple-root-node",
"style": { "style": {
"navigationBarTitleText": "获取节点-多根节点" "navigationBarTitleText": "获取节点-多根节点"
} }
}, },
// #endif
{ {
"path": "pages/API/create-selector-query/create-selector-query", "path": "pages/API/create-selector-query/create-selector-query",
"group": "1,3,1", "group": "1,3,1",
...@@ -1158,7 +1174,7 @@ ...@@ -1158,7 +1174,7 @@
"navigationBarTitleText": "createSelectorQuery | 创建 SelectorQuery 实例" "navigationBarTitleText": "createSelectorQuery | 创建 SelectorQuery 实例"
} }
}, },
// #ifndef WEB // #ifdef APP-ANDROID || APP-IOS
{ {
"path": "pages/API/get-native-view/element-getnativeview", "path": "pages/API/get-native-view/element-getnativeview",
"group": "1,30", "group": "1,30",
...@@ -1175,7 +1191,7 @@ ...@@ -1175,7 +1191,7 @@
"navigationBarTitleText": "UniResizeObserver" "navigationBarTitleText": "UniResizeObserver"
} }
}, },
// #ifndef WEB // #ifdef APP-ANDROID || APP-IOS
{ {
"path": "pages/API/provider/provider", "path": "pages/API/provider/provider",
"group": "1,1,6", "group": "1,1,6",
...@@ -1183,6 +1199,8 @@ ...@@ -1183,6 +1199,8 @@
"navigationBarTitleText": "provider | 服务提供商" "navigationBarTitleText": "provider | 服务提供商"
} }
}, },
// #endif
// #ifdef APP-ANDROID || APP-IOS
{ {
"path": "pages/API/privacy/privacy", "path": "pages/API/privacy/privacy",
"group": "1,1,8", "group": "1,1,8",
...@@ -1193,37 +1211,54 @@ ...@@ -1193,37 +1211,54 @@
// #endif // #endif
{ {
"path": "pages/API/uni-push/uni-push", "path": "pages/API/uni-push/uni-push",
"group": "1,15,0", "group": "1,16,0",
"style": { "style": {
"navigationBarTitleText": "推送" "navigationBarTitleText": "推送"
} }
}, },
// #ifdef APP-ANDROID || APP-IOS || WEB
{
"path" : "pages/API/uni-stat/uni-stat",
"style" :
{
"navigationBarTitleText" : "统计"
}
},
// #endif
// #ifdef APP-ANDROID || APP-IOS || WEB
{ {
"path": "pages/API/dialog-page/dialog-page", "path": "pages/API/dialog-page/dialog-page",
"group": "1,2,1", "group": "1,2,1",
"style": { "style": {
"navigationBarTitleText": "dialogPage | 弹框页面" "navigationBarTitleText": "dialogPage"
} }
}, },
// #endif
// #ifdef APP-ANDROID || APP-IOS || WEB
{ {
"path": "pages/API/dialog-page/next-page", "path": "pages/API/dialog-page/next-page",
"style": { "style": {
"navigationBarTitleText": "dialogNextPage" "navigationBarTitleText": "dialogNextPage"
} }
}, },
// #endif
// #ifdef APP-ANDROID || APP-IOS || WEB
{ {
"path": "pages/API/dialog-page/dialog-1", "path": "pages/API/dialog-page/dialog-1",
"style": { "style": {
"navigationBarTitleText": "dialogPage1" "navigationBarTitleText": "dialogPage1"
} }
}, },
// #endif
// #ifdef APP-ANDROID || APP-IOS || WEB
{ {
"path": "pages/API/dialog-page/dialog-2", "path": "pages/API/dialog-page/dialog-2",
"style": { "style": {
"navigationBarTitleText": "dialogPage1" "navigationBarTitleText": "dialogPage1"
} }
}, },
// #ifndef WEB // #endif
// #ifdef APP-ANDROID || APP-IOS
{ {
"path": "pages/API/create-interstitial-ad/create-interstitial-ad", "path": "pages/API/create-interstitial-ad/create-interstitial-ad",
"group": "1,13,1", "group": "1,13,1",
...@@ -1235,10 +1270,11 @@ ...@@ -1235,10 +1270,11 @@
// #endif // #endif
// #ifdef APP-ANDROID || APP-IOS // #ifdef APP-ANDROID || APP-IOS
{ {
"path" : "uni_modules/uni-upgrade-center-app/pages/uni-app-x/upgrade-popup", "path": "pages/API/share-with-system/share-with-system",
"style" : "group": "1,15,0",
{ "style": {
"navigationBarTitleText" : "" "navigationBarTitleText": "shareWithSystem",
"enablePullDownRefresh": false
} }
}, },
// #endif // #endif
...@@ -1689,13 +1725,16 @@ ...@@ -1689,13 +1725,16 @@
"navigationBarTitleText": "css 变量" "navigationBarTitleText": "css 变量"
} }
}, },
// #ifdef APP-ANDROID || APP-IOS || WEB
{ {
"path": "pages/CSS/overflow/overflow-visible-event", "path": "pages/CSS/overflow/overflow-visible-event",
"group": "2,11", "group": "2,11",
"style": { "style": {
"navigationBarTitleText": "overflow-visible-event" "navigationBarTitleText": "overflow-visible-event"
} }
}, }
// #endif
,
{ {
"path": "pages/tabBar/template", "path": "pages/tabBar/template",
"style": { "style": {
...@@ -1829,23 +1868,14 @@ ...@@ -1829,23 +1868,14 @@
} }
}, },
// #endif // #endif
// #ifdef APP-ANDROID || APP-IOS || WEB
{ {
"path": "pages/template/schema/schema", "path": "pages/template/schema/schema",
"style": { "style": {
"navigationBarTitleText": "打开schema示例" "navigationBarTitleText": "打开schema示例"
} }
}, },
// #ifdef APP-ANDROID || APP-IOS
{
"path": "pages/API/share-with-system/share-with-system",
"group": "1,15,0",
"style": {
"navigationBarTitleText": "shareWithSystem",
"enablePullDownRefresh": false
}
},
// #endif // #endif
// #ifdef APP || WEB // #ifdef APP || WEB
{ {
"path": "uni_modules/uni-pay-x/pages/success/success", "path": "uni_modules/uni-pay-x/pages/success/success",
...@@ -1871,6 +1901,7 @@ ...@@ -1871,6 +1901,7 @@
} }
}, },
// #endif // #endif
// #ifdef APP-ANDROID || APP-IOS || WEB
{ {
"path": "pages/template/custom-long-list/custom-long-list", "path": "pages/template/custom-long-list/custom-long-list",
"style": { "style": {
...@@ -1878,6 +1909,7 @@ ...@@ -1878,6 +1909,7 @@
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
// #endif
{ {
"path": "pages/template/test-background-color-content/test-background-color-content", "path": "pages/template/test-background-color-content/test-background-color-content",
"style": { "style": {
...@@ -1887,10 +1919,9 @@ ...@@ -1887,10 +1919,9 @@
}, },
// #ifdef APP-IOS // #ifdef APP-IOS
{ {
"path" : "pages/API/event-bus/uts-event-bus", "path": "pages/API/event-bus/uts-event-bus",
"style" : "style": {
{ "navigationBarTitleText": ""
"navigationBarTitleText" : ""
} }
}, },
// #endif // #endif
...@@ -1900,6 +1931,14 @@ ...@@ -1900,6 +1931,14 @@
"style": { "style": {
"navigationBarTitleText": "" "navigationBarTitleText": ""
} }
},
// #endif
// #ifdef APP-ANDROID || APP-IOS
{
"path": "uni_modules/uni-upgrade-center-app/pages/uni-app-x/upgrade-popup",
"style": {
"navigationBarTitleText": ""
}
} }
// #endif // #endif
], ],
...@@ -2517,6 +2556,16 @@ ...@@ -2517,6 +2556,16 @@
} }
] ]
}, },
{
"id": "api.share",
"name": "分享",
"children": [
{
"id": "api.share.shareWithSystem",
"name": "shareWithSystem"
}
]
},
{ {
"id": "api.push", "id": "api.push",
"name": "推送", "name": "推送",
...@@ -2527,7 +2576,6 @@ ...@@ -2527,7 +2576,6 @@
} }
] ]
}, },
null,
{ {
"id": "api.unicloud", "id": "api.unicloud",
"name": "uniCloud客户端API", "name": "uniCloud客户端API",
......
<template>
<!-- #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>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script>
export default {
data() {
return {
}
},
methods: {
handleAppLunch() {
const options = uni.getLaunchOptionsSync()
uni.report({
name: 'uni-app-launch',
options: options,
success(data) {
console.log(data);
}, fail(err) {
console.log(err);
}
})
}
}
}
</script>
<style>
.normal-button {
width: 100%;
}
.instructions {
margin-top: 10px;
margin-left: 10px;
margin-right: 10px;
background-color: #eee;
}
</style>
...@@ -7,13 +7,29 @@ const stat_instance = Stat.getInstance() ...@@ -7,13 +7,29 @@ const stat_instance = Stat.getInstance()
const lifecycle = defineMixin({ const lifecycle = defineMixin({
// onLaunch(options : OnLaunchOptions) { stat_instance.onLaunch(options, this) }, // onLaunch(options : OnLaunchOptions) { stat_instance.onLaunch(options, this) },
// @ts-ignore // @ts-ignore
onLoad() { stat_instance.onLoad(this) }, onLoad() {
if (this instanceof Page) {
stat_instance.onLoad(this)
}
},
// @ts-ignore // @ts-ignore
onShow() { stat_instance.onShow(this) }, onShow() {
if (this instanceof Page) {
stat_instance.onShow(this)
}
},
// @ts-ignore // @ts-ignore
onHide() { stat_instance.onHide(this) }, onHide() {
if (this instanceof Page) {
stat_instance.onHide(this)
}
},
// @ts-ignore // @ts-ignore
onUnload() { stat_instance.onUnload(this) }, onUnload() {
if (this instanceof Page) {
stat_instance.onUnload(this)
}
},
// onError(error : string) { stat_instance.onError(error) } // onError(error : string) { stat_instance.onError(error) }
}) })
......
# uni-app x 专用的 uni 统计插件 # uni统计 for uni-app x
>
> 注意:当前版本 uni 统计仅支持 uni-app x ,与 uni统计1.0和uni统计2.0 数据不兼容。 > 注意:当前版本 uni 统计仅支持 uni-app x ,与 uni统计1.0和uni统计2.0 数据不兼容。
>
> uni统计for uni-app x需要单独下载使用,无需在 manifest.json 中配置开关,只需在前端代码中配置即可。
>
> 依赖 `Hbuilder X Alpha版 4.32+`。
## 配置 uni统计后台 uni统计`uni-app x`版本,[使用教程](https://uniapp.dcloud.net.cn/uni-stat-uniappx)
与uni统计2.0后台配置一样,只是数据不互通,详情参考 [创建 admin 项目](https://uniapp.dcloud.net.cn/uni-stat-v2.html#%E5%90%8E%E5%8F%B0%E6%8A%A5%E8%A1%A8%E9%85%8D%E7%BD%AE)
## 前端配置
因为当前版本 uni统计是单独的插件,需要在插件市场中下载使用
[下载uni统计](https://ext.dcloud.net.cn/plugin?name=uni-stat)
### 配置说明
**uniStatistics说明**
|字段 | 类型 | 默认值 | 可选值 | 说明 |
|:-: |:-: |:-: |:-: |:-: |
|debug | Boolean |false | true/ false |开启统计调试模式 ,会产生大量日志,且会在开发阶段上报数据,应用发布请关闭此项 |
|reportInterval | Number |10 | - |前端数据上报周期 |
|collectItems |Object |- | - |采集项配置 |
**collectItems 采集项配置说明**
|字段 |类型| 默认值 |可选值 |说明|
|:-:|:-: |:-: |:-: |:-:|
|uniPushClientID| Boolean |false| true/false |是否开启推送PushClientID的采集|
|uniStatPageLog| Boolean |true| true/false |是否开启页面数据采集|
### 如何引用
在 main.uts 中 ,通过vue插件的方式加载 uni统计
```js
import App from './App.uvue'
import { createSSRApp } from 'vue'
// 引入uni统计插件
import { uniStat } from '@/uni_modules/uni-stat/plugin.uts'
// uni统计采集项配置
const collectItems = {
uniStatPageLog: true
}
// uni统计基础配置
const statOptions = {
debug: true,
collectItems: collectItems
}
export function createApp() {
const app = createSSRApp(App)
// 载入uni统计插件 ,use 第二个参数不能为空,如需使用默认配置,请传入 {}
app.use(uniStat, statOptions)
return {
app
}
}
```
### 如何使用
因版本限制,uni统计无法自动采集应用相关的数据,如应用启动、进入后台、进入前台等信息,需要用户手动调用 uni.report() 来实现对应的数据采集。
**使用示例**
```js
<script lang="uts">
export default {
onLaunch: function (options) {
console.log('App Launch')
uni.report({
name: 'uni-app-launch',
options: options,
success(res) {
console.log(res);
}, fail(err) {
console.log(err);
}
})
},
onShow: function () {
console.log('App Show')
uni.report({
name: 'uni-app-show',
success(res) {
console.log(res);
}, fail(err) {
console.log(err);
}
})
},
onHide: function () {
console.log('App Hide')
uni.report({
name: 'uni-app-hide',
success(res) {
console.log(res);
}, fail(err) {
console.log(err);
}
})
},
onError(err : any) {
console.log('错误');
uni.report({
name: 'uni-app-error',
options: err,
success(res) {
console.log(res);
}, fail(err) {
console.log(err);
}
})
}
}
</script>
```
### 影响范围
`uni-app-launch` 是整个统计的入口,会采集应用启动的相关数据会影响的统计数据为:
- 日活
- 新增
- 总设备数
`uni-app-show` 是应用从后台进入前台调用,会影响:
- 日活
`uni-app-hide` 是应用从前台进入后台调用,会影响:
- 页面访问次数
### uni.report(OBJECT) 说明
**OBJECT参数说明**
|参数名 |类型 |必填 |说明 |
|:-: |:-: |:-: |:-: |
|name | String | 是 |事件名称 ,内置名称见下方 **name 内置事件说明** |
|options | Any | 否 |事件自定义参数 |
|success | Function| 否 |接口调用成功的回调函数 |
|fail |Function | 否 |接口调用失败的回调函数 |
|complete | Function| 否 |接口调用结束的回调函数(调用成功、失败都会执行) |
**name 内置事件说明**
|事件名 |调用声明周期 |事件说明 |
|:-: |:-: |:-: |
|uni-app-launch | App.onLaunch| 应用启动 |
|uni-app-show | App.onShow | 应用进入前台 |
|uni-app-hide | App.onHide | 应用进入后台 |
|uni-app-error | App.onError | 应用发生错误 |
|title | any | 内容统计采集标题 |
**如何使用自定义上报**
```js
// 参数支持字符串
uni.report({
name:'购买',
options:'购买成功'
})
// 参数支持对象
uni.report({
name:'购买',
options:{
id:'1000',
name:'上衣',
price:'998',
msg:'购买成功'
// ...
}
})
```
...@@ -246,15 +246,24 @@ export class Stat { ...@@ -246,15 +246,24 @@ export class Stat {
return return
} }
if (name == 'uni-app-show') { if (name == 'uni-app-show') {
this.registerEvent(StatType.LifeCycleAppShow, null, null) this.registerEvent(StatType.LifeCycleAppShow, null, null)
return return
} }
if (name == 'uni-app-hide') { if (name == 'uni-app-hide') {
this.registerEvent(StatType.LifeCycleAppHide, null, null) this.registerEvent(StatType.LifeCycleAppHide, null, null)
return return
} }
if (name == 'uni-page-show') {
this.report.pageShow(options as Page)
return
}
if (name == 'uni-page-hide') {
this.report.pageHide(options as Page)
return
}
if (name == 'uni-app-error') { if (name == 'uni-app-error') {
this.registerEvent(StatType.LifeCycleError, null, null, options) this.registerEvent(StatType.LifeCycleError, null, null, options)
......
...@@ -25,5 +25,5 @@ export const report : Report = function (options : ReportOptions) { ...@@ -25,5 +25,5 @@ export const report : Report = function (options : ReportOptions) {
} }
export { Stat } from './common/core/stat.uts' export { Stat } from './common/core/stat.uts'
// // --- 导出统计类型 --- // --- 导出统计类型 ---
export { UniStatOptions, UniStatCollectItemsOptions } from './interface.uts' export { UniStatOptions, UniStatCollectItemsOptions } from './interface.uts'
export type ReportSuccess = { export type ReportSuccess = {
/**
* 成功的详细信息
*/
errMsg : string, errMsg : string,
} }
...@@ -9,12 +12,9 @@ export type ReportFail = { ...@@ -9,12 +12,9 @@ export type ReportFail = {
errMsg : string, errMsg : string,
} }
export type ReportOptions = { export type ReportOptions = {
/** /**
* 自定义事件名称 * 自定义事件名称,内置名称(不允许覆盖):
* 内置名称(不允许覆盖):
* uni-app-launch : 应用启动 * uni-app-launch : 应用启动
* uni-app-show : 应用进入前台 * uni-app-show : 应用进入前台
* uni-app-hide : 应用进入后台 * uni-app-hide : 应用进入后台
...@@ -34,28 +34,24 @@ export type ReportOptions = { ...@@ -34,28 +34,24 @@ export type ReportOptions = {
*/ */
fail ?: (res : ReportFail) => void fail ?: (res : ReportFail) => void
/** /**
* 接口调用成功的回调 * 接口调用成功的回调函数
*/ */
complete ?: (res : any) => void complete ?: (res : any) => void
} }
export type ReportResult = { export type ReportResult = {}
}
/** /**
* 自定义事件信息 * 自定义事件信息
* @param {ReportOptions} options * @param {ReportOptions} options
* *
*
* @tutorial https://uniapp.dcloud.net.cn/xxxx
* @platforms APP-IOS = ^9.0,APP-ANDROID = ^22 * @platforms APP-IOS = ^9.0,APP-ANDROID = ^22
* @since 4.25 * @since 4.25
*/ */
export type Report = (options : ReportOptions) => void export type Report = (options : ReportOptions) => void
interface Uni { export interface Uni {
/** /**
* 统计自定义事件 * 统计自定义事件
* @description 统计自定义事件上报 * @description 统计自定义事件上报
...@@ -71,46 +67,21 @@ interface Uni { ...@@ -71,46 +67,21 @@ interface Uni {
* ``` * ```
* @remark * @remark
* - 该接口需要同步调用 * - 该接口需要同步调用
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "4.4.4",
* "uniVer": "3.6.11",
* "unixVer": "3.9.0"
* },
* "ios": {
* "osVer": "9.0",
* "uniVer": "3.6.11",
* "unixVer": "3.9.0"
* }
* }
* }
* @uniVueVersion 2,3 //支持的vue版本
*
*/ */
report(options : ReportOptions) : void, report(options : ReportOptions) : void,
} }
// 统计插件参数类型 // 统计插件参数类型
export type UniStatOptions = { export type UniStatOptions = {
/* 是否开启debug模式,默认 false */ /**
* 是否开启debug模式
* @defaultValue false
*/
debug ?: boolean debug ?: boolean
/* 前端数据上报周期 ,默认 10s ,单位s */ /**
* 前端数据上报周期 ,单位s
* @defaultValue 10
*/
reportInterval ?: number reportInterval ?: number
/* 多服务空间配置 */ /* 多服务空间配置 */
uniCloud ?: UniCloudInitOptions uniCloud ?: UniCloudInitOptions
...@@ -119,9 +90,15 @@ export type UniStatOptions = { ...@@ -119,9 +90,15 @@ export type UniStatOptions = {
} }
export type UniStatCollectItemsOptions = { export type UniStatCollectItemsOptions = {
/* 是否开启推送PushClientID的采集,默认false */ /**
* 是否开启推送PushClientID的采集
* @defaultValue false
*/
uniPushClientID ?: boolean uniPushClientID ?: boolean
/* 是否开启页面数据采集,默认true */ /**
* 是否开启页面数据采集
* @defaultValue true
*/
uniStatPageLog ?: boolean uniStatPageLog ?: boolean
} }
...@@ -194,7 +171,6 @@ export type PageParams = { ...@@ -194,7 +171,6 @@ export type PageParams = {
urlref_tt ?: string urlref_tt ?: string
} }
/** /**
* 上传 unicloud 参数 * 上传 unicloud 参数
*/ */
...@@ -223,6 +199,9 @@ export type CustomUnicloudConfig = { ...@@ -223,6 +199,9 @@ export type CustomUnicloudConfig = {
secretId ?: string secretId ?: string
} }
/**
* 事件类型
*/
export type EventParams = { export type EventParams = {
/** 事件名字*/ /** 事件名字*/
key : string key : string
...@@ -230,7 +209,6 @@ export type EventParams = { ...@@ -230,7 +209,6 @@ export type EventParams = {
value ?: string value ?: string
} }
/** /**
* 统计默认值 * 统计默认值
*/ */
...@@ -330,7 +308,6 @@ export type StatDefault = { ...@@ -330,7 +308,6 @@ export type StatDefault = {
em ?:string em ?:string
} }
/** /**
* 应用首次启动上报参数 * 应用首次启动上报参数
*/ */
...@@ -470,7 +447,6 @@ export type PageReportParams = { ...@@ -470,7 +447,6 @@ export type PageReportParams = {
t : number t : number
/** 上报时机,参看 ReprotCstType */ /** 上报时机,参看 ReprotCstType */
cst ?: number cst ?: number
} }
export type ErrorCallback = (is_err : boolean, errMsg : string) => void export type ErrorCallback = (is_err : boolean, errMsg : string) => void
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册