
简体中文
uni统计自定义上报方法。
本 API 是 uni ext api,需下载插件:uni-stat
uni.report
需要依赖 uni统计
,集成方式请查看文档。
Web | 微信小程序 | Android | iOS | HarmonyOS |
---|---|---|---|---|
4.33 | - | 4.33 | 4.33 | - |
名称 | 类型 | 必填 | 默认值 | 兼容性 | 描述 | ||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | ReportOptions | 是 | - | - | 自定义事件参数 | ||||||||||||||||||||||||||||||||||||
|
名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
---|---|---|---|---|---|
errMsg | string | 是 | - | - | 成功的详细信息 |
名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
errCode | number | 是 | - | - | 错误码 | ||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||
errSubject | string | 是 | - | - | 统一错误主题(模块)名称 | ||||||||||||||||||||||||||||||
data | any | 否 | - | - | 错误信息中包含的数据 | ||||||||||||||||||||||||||||||
cause | Error | 否 | - | - | 源错误信息,可以包含多个错误,详见SourceError | ||||||||||||||||||||||||||||||
errMsg | string | 是 | - | - | - |
// 参数支持字符串
uni.report({
name:'购买',
options:'购买成功'
})
// 参数支持对象
uni.report({
name:'购买',
options:{
id:'1000',
name:'上衣',
price:'998',
msg:'购买成功'
// ...
}
})
示例为 alpha 分支:hello uni-app x(alpha)
master 分支:hello uni-app x(master)
Template
Script
<template>
<!-- #ifdef APP -->
<scroll-view style="flex:1">
<!-- #endif -->
<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>
<button class="normal-button" type="default" @click="handleTitle">
模拟自定义title
</button>
<button class="normal-button" type="default" @click="handleEvent">
模拟自定义事件
</button>
<text class="instructions">
当前页面调用API均为模拟,请查看文档,在特定场景下使用以上 API。请在main.uts中设置统计debug配置为true,并点击按钮查控制台输出。
</text>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<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 {
margin-top: 10px;
margin-left: 10px;
margin-right: 10px;
background-color: #eee;
font-size: 12px;
color: #999;
}
</style>
名称 | 类型 | 必备 | 默认值 | 兼容性 | 描述 |
---|---|---|---|---|---|
errMsg | string | 是 | - | 错误信息 |