Skip to content

Analytics

The Analytics API provides event tracking and analytics.

Try it online

Event name eventId
params (optional JSON)
Send eventClear history
Quick presets
page_viewClickPurchase

Analytics API demo

Enter an event name and optional params JSON, or use presets; SDK logs appear at the bottom-right, local event history below

Import

ts
import woo from 'mini-sdk'
// 或
import { analytics } from 'mini-sdk'

API reference

enableAutoAnalytics

Enable automatic analytics (page views, clicks, etc.).

ts
await woo.enableAutoAnalytics()

recordEvent

Track a custom event.

ts
woo.recordEvent(options: RecordEventOptions): Promise<void>

Parameters:

FieldTypeRequiredDescription
eventIdstringYesEvent identifier
paramsRecord<string, unknown>NoEvent parameters
ts
// Track a button click
await woo.recordEvent({
  eventId: 'button_click',
  params: {
    buttonName: 'submit',
    page: 'checkout',
  },
})

// Track a purchase
await woo.recordEvent({
  eventId: 'purchase',
  params: {
    productId: 'SKU001',
    amount: 99.99,
    currency: 'CNY',
  },
})

enableNotification / disableNotification

Enable or disable push notifications.

ts
await woo.enableNotification()
await woo.disableNotification()

Type definitions

ts
interface RecordEventOptions {
  eventId: string
  params?: Record<string, unknown>
}

Quick reference

MethodDescriptionSignature
reportAnalyticsTrack a custom event({ eventId, params? }) → void
reportMonitorReport performance monitor data({ name, value }) → void

MiniDev Studio — Mini-app Development Toolkit