Skip to main content
After initialization, the WeChat Mini Program RUM SDK automatically collects user experience data through Mini Program runtime APIs. You can disable specific collection types through initialization parameters and use manual APIs to add business events.

Collection Overview

Common Event Attributes

Before sending each RUM event, the SDK enriches it with application, session, page, connectivity, user, and context information. These fields let the Explorer correlate events from the same user session, page view, and network state. The SDK reads the initial network type through wx.getNetworkType and updates network state for later events through wx.onNetworkStatusChange.

Page Views

When trackPages is enabled, the SDK wraps the global Page constructor and listens to page lifecycle hooks. Each page creates view events, and the default page name comes from the page instance route. The SDK records the following page information: The SDK updates the active page duration every 3 seconds. When a page moves to the background, is hidden, or unloads, the SDK sends a view update with the hidden or terminated state.

User Actions

When trackActions is enabled, the SDK wraps functions in the page configuration. If a function receives a first argument that contains a string type field, the SDK records a user action. Action events include the following information:
Set data-name on clickable components to make action names easier to identify, for example <button data-name="submit_order">Submit order</button>.

Network Requests

When trackRequests is enabled, the SDK wraps wx.request, wx.uploadFile, and wx.downloadFile. SDK intake requests and calls marked as internal requests are skipped to avoid recursive collection. Network requests create resource events:

Error Collection

When trackErrors is enabled, the SDK subscribes to Mini Program app errors and unhandled Promise rejections. Error events include the error message, optional stack, and source. When manually reporting an error, pass error.stack as the third argument to addError().

Performance Metrics

When trackPerformance is enabled, the SDK reads Mini Program performance APIs. If the runtime supports the corresponding APIs, the SDK writes metrics to view events. If the current Mini Program base library does not support wx.getPerformance or setUpdatePerformanceListener, the SDK skips the corresponding metrics without affecting other data collection.

Custom Events

Calling addCustomEvent(name, context?) creates a custom event. Use it to record business events that cannot be inferred automatically from page lifecycle hooks, actions, or requests.
pages/order/detail.js

Event Correlation

The SDK associates non-view events with the page and session active at the event time:
  • Page events establish the current view and periodically update time spent
  • Action, resource, and error events increment counters on the current view
  • If the current session has expired when an event occurs, the SDK creates a new session
  • Historical view updates and delayed events prefer event time when looking up the page, which prevents attribution to the wrong page

Disable Automatic Collection

Disable collection types you do not need during initialization:
app.js
Disabling an automatic collection type only affects its automatic listener. Manual APIs remain available. For example, after disabling trackActions, you can still call addAction() to report a custom action.

Reporting Batches

The SDK adds collected RUM events to batches before sending them: Unsent payloads are persisted through Mini Program storage and resent the next time the batch reporting module starts. The SDK keeps up to 10 pending payloads with a total size up to 64 KB, and discards payloads older than 24 hours.

SDK Integration

Install and initialize the WeChat Mini Program RUM SDK.

Advanced Configuration

Configure proxying, tracing, sessions, and manual instrumentation.

Compatibility

Learn about Mini Program base library, development tool, and platform API requirements.