Intake URL and Proxy
By default, the SDK sends RUM data tohttps://browser.flashcat.cloud/api/v2/rum. If your Mini Program cannot access the default URL directly, or you need to route traffic through your own gateway, use proxy.
Use a String Proxy
Whenproxy is a string, the SDK removes trailing / characters and produces {proxy}?ddforward={encodedPath}. ddforward contains the encoded /api/v2/rum path and query parameters.
app.js
Use a Function Proxy
Whenproxy is a function, the SDK gives you path and parameters so you can build the full URL. path is always /api/v2/rum, and parameters includes reporting parameters such as ddsource, ddtags, dd-api-key, the SDK version, and batch time.
app.js
When
proxy is not configured, the SDK uses site to build the intake URL: https://{site}/api/v2/rum. The default site is browser.flashcat.cloud.Distributed Tracing
The SDK can inject W3C Trace Context headers into Mini Program network requests. When enabled, sampledwx.request, wx.uploadFile, and wx.downloadFile calls carry a trace header, and resource events include trace_id and span_id.
app.js
The default header value generated by the SDK follows the
00-{traceId}-{spanId}-{traceFlags} format. For example:
rootTraceContext is configured, the SDK inherits the root context traceId and traceFlags and generates a new spanId. Otherwise, every sampled request creates a new trace context.
Session Behavior
The SDK stores the current session through Mini Program storage and writes the session ID to every RUM event.
Call
stopSession() when the user signs out, switches accounts, or you need to split the session. After the call, the SDK clears the current session and creates a new one for the next event.
app.js
Event Rate Limiting
The SDK rate-limits each event type per minute. The default threshold is3000 events per event type per minute. After the threshold is reached, the SDK drops subsequent events of that type and creates a custom error event that describes the rate limit.
app.js
Pre-send Processing
beforeSend runs before a RUM event is sent. Use it to add fields, redact context, or return false to drop the current event.
app.js
User and Global Context
setUser() sets current user information. When trackAnonymousUser is enabled and the user context is empty, the SDK automatically writes the anonymous ID to usr.id and usr.anonymous_id. If you set user information, the SDK keeps your user fields and adds usr.anonymous_id.
app.js
setGlobalContext() sets global context. The SDK writes this object to the context field on subsequent events.
app.js
Manual Pages and Custom Timings
Automatic page names come from the page instanceroute. If you need to record a virtual page or use a business name for the current page, call startPage().
pages/product/detail.js
addTiming() writes a custom timing to the current view custom_timings. If you pass time, the SDK uses the difference between that time and the current page start time. If you do not pass time, it uses the current time.
pages/product/detail.js
-, _, ., @, and $. Other characters are replaced with _.
Manual Actions, Errors, and Custom Events
pages/order/detail.js
Related Pages
SDK Integration
Install and initialize the WeChat Mini Program RUM SDK.
Compatibility
Learn about Mini Program base library, development tool, and platform API requirements.
Data Collection
Learn which page, action, request, error, and performance data the SDK collects automatically.