flashcatRum instance through @flashcatcloud/miniprogram-rum. After initialization, the SDK automatically collects page lifecycle events, user actions, network requests, app errors, and performance metrics, then reports them to Flashduty RUM.
Prerequisites
Before integrating the SDK, complete these steps:- Create or select a RUM application in the Flashduty console, then obtain the Application ID and Client Token
- Confirm that your Mini Program can access the RUM intake URL. The default URL is
https://browser.flashcat.cloud/api/v2/rum; configureproxyif your network policy requires forwarding - Configure the request domain allowlist in the WeChat Official Platform: go to Development > Development Management > Development Settings > Server Domain and add
https://browser.flashcat.cloud(or your proxy domain) to the request legal domains. Without this, WeChat blocks all reporting requests on real devices; during development, you can temporarily check the “Do not verify legal domains” option in WeChat DevTools - If you use WeChat DevTools, build npm so
miniprogram_npmcan reference the SDK package
Install the SDK
Install the RUM SDK in the Mini Program project root:Initialize the SDK
Initialize the SDK as early as possible in the Mini Program entry file. The SDK wraps page lifecycle hooks, request methods, and app error listeners during initialization, so initializing it inapp.js is recommended.
app.js
Initialization Parameters
Required Parameters
string
required
RUM application ID. The SDK writes it to
application.id so Mini Program data is associated with the correct application.string
required
Client reporting token. The SDK appends this value to RUM intake requests as the
dd-api-key parameter.Basic Optional Parameters
string
default:"browser.flashcat.cloud"
RUM intake site. When
proxy is not configured, the SDK sends events to https://{site}/api/v2/rum.string | function
Custom reporting proxy. A string proxy produces
{proxy}?ddforward={encodedPath}. A function proxy receives { path, parameters } and returns the full intake URL.string
Service name. The SDK writes it as the
service:<value> tag so you can filter RUM data by service.string
Environment name. The SDK writes it as the
env:<value> tag, such as production or staging.string
Application version. The SDK writes it as the
version:<value> tag for release-based error and performance analysis.number
default:"100"
Session sample rate. The value represents the percentage of sessions to collect.
100 collects all sessions, while 0 collects no session events.For production environments, a lower sample rate (for example,
10 for 10% sampling) is typically recommended to reduce storage cost.number
default:"15000"
Batch flush interval in milliseconds. By default, the SDK tries to flush event batches every 15 seconds and also flushes when the Mini Program moves to the background.
(event: unknown) => boolean | void
Callback executed before an event is sent. Return
false to prevent the current event from being sent to Flashduty.boolean
default:"false"
Enables debug logs. When enabled, the SDK logs initialization, monitoring startup, event collection, and batch reporting details to the console.
boolean
default:"true"
Controls whether the SDK generates an anonymous user ID when no user information is set. When enabled, the SDK writes the anonymous ID to
usr.id and usr.anonymous_id.Collection Toggles
The following toggles control automatic collection. They are all enabled by default:Use User Information and Global Context
After sign-in, usesetUser() to associate events with the current user. The SDK writes these fields to the usr object on subsequent RUM events.
app.js
setGlobalContext() to add business context. Global context is written to the context field on subsequent events.
app.js
Manually Report Events
In addition to automatic collection, you can add business events, errors, actions, and custom timings manually.pages/order/detail.js
Next Steps
Advanced Configuration
Configure proxying, distributed tracing, sessions, and manual instrumentation.
Compatibility
Learn about Mini Program base library, development tool, and platform API requirements.
Data Collection
Learn which event types, fields, and platform APIs the SDK collects automatically.