Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.flashcat.cloud/llms.txt

Use this file to discover all available pages before exploring further.

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

Data typeDefault stateCollection sourceEvent type
Page viewsEnabledPage lifecycle hooks: onLoad, onShow, onReady, onHide, onUnloadview
User actionsEnabledPage methods that receive an event object with a type fieldaction
Network requestsEnabledwx.request, wx.uploadFile, wx.downloadFileresource
App errorsEnabledwx.onError, wx.onUnhandledRejectionerror
Performance metricsEnabledwx.getPerformance and page setUpdatePerformanceListenerview
Custom eventsManualaddCustomEvent()custom

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.
FieldDescription
application.idRUM application ID from the applicationId initialization parameter
session.idSession ID generated by the SDK
session.typeAlways user
session.has_replayAlways false
session.sampled_for_replayAlways false
sourceAlways miniprogram
view.idPage view ID associated with the current event
view.name / view.urlPage name associated with the current event, defaulting to the Mini Program page route
connectivity.statusNetwork connection status, either connected or not_connected
connectivity.interfacesNetwork interface, such as wifi, cellular, none, or unknown
connectivity.effective_typeCellular network type, such as 2g, 3g, or 4g
usrUser information set through setUser(), or anonymous user information generated by the SDK
contextGlobal context set through setGlobalContext()
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:
FieldDescription
view.idUnique page ID generated by the SDK
view.name / view.urlPage route name, or unknown when unavailable
view.referrerPrevious page name
view.loading_typePage loading type, either initial_load or route_change
view.loading_timeTime from onLoad to onReady
view.time_spentAccumulated time while the page is active in the foreground
view.onload_to_onshowTime from onLoad to the first onShow
view.onshow_to_onreadyTime from the first onShow to onReady
view.action.countNumber of actions associated with the current view
view.error.countNumber of errors associated with the current view
view.resource.countNumber of resource requests associated with the current view
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:
FieldDescription
action.typeMini Program event type, such as tap
action.target.nameRead from event.currentTarget.dataset.name, dataset.content, or dataset.type; falls back to unknown
_dd.action.positionRecords x and y when the event contains coordinates
action.loading_timeTime until page activity becomes idle after the action
action.error.countNumber of errors produced during the action
action.resource.countNumber of resource requests produced during the action
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:
FieldDescription
resource.typexhr, upload, or download
resource.urlRequest URL
resource.methodRequest method. wx.request defaults to GET, uploads are always POST, and downloads are always GET
resource.status_codeHTTP status code when the request succeeds
resource.durationRequest duration
resource.error_messageError message when the request fails
resource.trace_id / resource.span_idTrace identifiers generated when distributed tracing is enabled and sampled

Error Collection

When trackErrors is enabled, the SDK subscribes to Mini Program app errors and unhandled Promise rejections.
SourceSDK sourceDescription
wx.onErrorappMini Program runtime errors
wx.onUnhandledRejectionpromiseUnhandled Promise rejections
addError()customBusiness errors that you report manually
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.
MetricDescription
view.app_launchMini Program startup duration from the navigation entry named appLaunch
view.evaluate_scriptMain package script execution duration from the script entry named evaluateScript
view.first_renderFirst render duration from the render entry named firstRender
view.first_render_detailFirst render breakdown, including view layer ready, initial data send, initial data receive, render start, and render end
view.performance.fcp.timestampFirst Contentful Paint timestamp
view.performance.lcp.timestampLargest Contentful Paint timestamp
view.setdata.countNumber of setData updates in the current view
view.setdata.durationAccumulated setData update duration in the current view
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.
FieldDescription
event.nameCustom event name
event.contextCustom event context object
pages/order/detail.js
import { flashcatRum } from "@flashcatcloud/miniprogram-rum";

flashcatRum.addCustomEvent("order_status_changed", {
  orderId: "order-123",
  status: "paid"
});

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
import { flashcatRum } from "@flashcatcloud/miniprogram-rum";

flashcatRum.init({
  applicationId: "<YOUR_APPLICATION_ID>",
  clientToken: "<YOUR_CLIENT_TOKEN>",
  trackActions: false,
  trackRequests: false,
  trackPerformance: false
});
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:
ConfigurationValue
Default flush interval15000 milliseconds, configurable through flushInterval
Maximum messages per batch50
Maximum batch size64 KB
Maximum message size256 KB
Background flushThe SDK flushes the batch when the Mini Program triggers onAppHide
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.