数据分析 Analytics
Analytics API 提供数据埋点和分析能力。
在线试用
事件名 eventId
params(JSON 可选)
快速预设
导入
ts
import woo from 'mini-sdk'
// 或
import { analytics } from 'mini-sdk'API 列表
enableAutoAnalytics
启用自动分析(页面浏览、点击等)。
ts
await woo.enableAutoAnalytics()recordEvent
上报自定义事件。
ts
woo.recordEvent(options: RecordEventOptions): Promise<void>参数:
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
eventId | string | 是 | 事件标识 |
params | Record<string, unknown> | 否 | 事件参数 |
ts
// 上报按钮点击
await woo.recordEvent({
eventId: 'button_click',
params: {
buttonName: 'submit',
page: 'checkout',
},
})
// 上报购买事件
await woo.recordEvent({
eventId: 'purchase',
params: {
productId: 'SKU001',
amount: 99.99,
currency: 'CNY',
},
})enableNotification / disableNotification
启用/禁用推送通知。
ts
await woo.enableNotification()
await woo.disableNotification()类型定义
ts
interface RecordEventOptions {
eventId: string
params?: Record<string, unknown>
}API 速查表
| 方法 | 说明 | 签名 |
|---|---|---|
reportAnalytics | 上报自定义事件 | ({ eventId, params? }) → void |
reportMonitor | 上报性能监控数据 | ({ name, value }) → void |