The Application Real-Time Monitoring Service (ARMS) Real User Monitoring (RUM) SDK for minigames provides configuration options to control how monitoring data is collected, sampled, filtered, and reported.
SDK parameters
Pass these parameters to armsRum.init() to initialize the SDK.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| pid | String | Yes | - | Minigame ID. |
| endpoint | String | Yes | - | Endpoint to which monitoring data is reported. |
| env | String | No | prod | Deployment environment. Valid values: prod, gray, pre, daily, local. |
| version | String | No | - | Minigame version. |
| user | Object | No | - | User identity settings. See User parameters. |
| beforeReport | Function | No | - | Callback invoked before each data report. Return modified data to change the report, or return false to block it. |
| reportConfig | Object | No | - | Data reporting settings. See reportConfig parameters. |
| sessionConfig | Object | No | - | Session sampling and timeout settings. See sessionConfig parameters. |
| collectors | Object | No | - | Enable or disable specific data collectors. See collectors parameters. |
| parseResourceName | Function | No | - | Custom function to parse the resource name (resource.name) from a resource URL. |
| evaluateApi | Function | No | - | Custom function to parse API events. See evaluateApi parameters. |
| filters | Object | No | - | Event filtering rules. See filters parameters. |
| properties | Object | No | - | Custom properties attached to all events. See properties parameters. |
User parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| id | String | No | Generated by the SDK | Unique user ID. Generated automatically and cannot be overridden. |
| name | String | No | - | Username. |
| tags | String | No | - | User tags. |
Do not overwrite user.id. Overwriting it affects unique visitor (UV) data. To associate sessions with your own account system, set user.name or user.tags instead.
Example
armsRum.init({
pid: "<your-app-id>",
endpoint: "<your-endpoint>",
user: {
name: "your user.name",
tags: "your user.tags",
},
});reportConfig parameters
Control how frequently data is sent and how many events are batched per request.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| flushTime | Number | No | 3000 | Reporting interval in milliseconds. Valid values: 0 to 10000. Set to 0 for immediate reporting. |
| maxEventCount | Number | No | 20 | Maximum number of events per report. Valid values: 1 to 100. |
Example
armsRum.init({
pid: "<your-app-id>",
endpoint: "<your-endpoint>",
reportConfig: {
flushTime: 0, // Report data immediately
maxEventCount: 50, // Send up to 50 events per batch
},
});sessionConfig parameters
Configure session sampling rates and timeout behavior.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| sampleRate | Number | No | 1 | Sampling rate. Valid values: 0 to 1. For example, 0.5 samples 50% of sessions. |
| maxDuration | Number | No | 86400000 | Maximum session duration in milliseconds. Default: 24 hours. |
| overtime | Number | No | 3600000 | Session inactivity timeout in milliseconds. Default: 1 hour. |
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| sampleRate | Number | No | 1 | Sampling rate. Valid values: 0 to 1. For example, 0.5 samples 50% of sessions. |
| maxDuration | Number | No | 86400000 | Maximum session duration in milliseconds. Default: 24 hours. |
| overtime | Number | No | 1800000 | Session inactivity timeout in milliseconds. Default: half an hour. |
Session storage
The SDK stores user ID and session data in the minigame's local cache:
_arms_uid-- unique user ID (user.id)._arms_session-- session metadata in the format${sessionId}-${sampled}-${startTime}-${lastTime}, where:sessionId-- unique session ID.sampled-- whether sampling was triggered.startTime-- session start timestamp.lastTime-- timestamp of the last activity.
Example
armsRum.init({
pid: "<your-app-id>",
endpoint: "<your-endpoint>",
sessionConfig: {
sampleRate: 0.5, // Sample 50% of sessions
maxDuration: 86400000, // 24-hour max session duration
overtime: 3600000, // 1-hour inactivity timeout
},
});collectors parameters
The SDK uses collectors to gather different types of monitoring data. Set each collector to true (enabled), false (disabled), or an object for fine-grained configuration.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| perf | Boolean | Object | No | true | Minigame performance data. |
| api | Boolean | Object | No | true | API requests. |
| staticResource | Boolean | Object | No | true | Static resource loading. |
| consoleError | Boolean | Object | No | true | Console errors. |
| jsError | Boolean | Object | No | true | JavaScript errors. |
| action | Boolean | Object | No | true | User interactions. |
Example
Disable API request tracking:
armsRum.init({
pid: "<your-app-id>",
endpoint: "<your-endpoint>",
collectors: {
api: false,
},
});evaluateApi parameters
The evaluateApi callback customizes how the SDK parses API request events. It receives three arguments and returns a Promise<IApiBaseAttr>.
Arguments:
| Parameter | Type | Description |
|---|---|---|
| options | Object | Request parameters, including url, headers, and data. The exact fields depend on the request method. |
| response | Object | Response body. |
| error | Error | Error object. Only present when the request fails. |
Return type (IApiBaseAttr):
Any returned fields override the SDK defaults. Omitted fields keep their default values.
| Parameter | Type | Required | Description |
|---|---|---|---|
| name | String | No | API name. Typically a converged URL (for example, /list/$id instead of /list/123). Maximum 1,000 characters. Takes precedence over parseResourceName. |
| message | String | No | Brief description of the API call. Maximum 1,000 characters. |
| success | Number | No | Request result. 1: success. 0: failure. -1: unknown. |
| duration | Number | No | Total request duration in milliseconds. |
| status_code | Number | String | No | HTTP status code. |
| snapshots | String | No | Diagnostic data such as request headers, parameters, and response headers. Maximum 5,000 characters. Snapshots are not indexed and cannot be used as filter or aggregation conditions. |
Example
armsRum.init({
pid: "<your-app-id>",
endpoint: "<your-endpoint>",
evaluateApi: async (options, response, error) => {
// Returned fields override SDK defaults.
// Omitted fields retain their default values.
return {
name: "my-custom-api",
success: error ? 0 : 1,
// Optional: attach diagnostic snapshots
snapshots: JSON.stringify({
params: "page=1&size=10",
response: "",
reqHeaders: "",
resHeaders: "",
}),
properties: {
prop_msg: "custom msg",
prop_num: 1,
},
};
},
});filters parameters
Use filters to exclude specific resource or exception events from reporting.
| Parameter | Type | Required | Description |
|---|---|---|---|
| resource | MatchOption | MatchOption[] | No | Exclude static resource and API events (XMLHttpRequest, fetch) that match the specified patterns. |
| exception | MatchOption | MatchOption[] | No | Exclude exception events that match the specified patterns. |
MatchOption
type MatchOption = string | RegExp | ((value: string, error?: Error) => boolean);String -- matches any URL that starts with the given value. For example,
"https://api.example.com"matches"https://api.example.com/v1/resource".RegExp -- matches URLs against a regular expression.
Function -- return
trueto exclude the event. For exception filters, the function receives anErrorobject as the second argument.
When an array of MatchOption values is provided, they are evaluated in order. An event is excluded if any condition matches.
Example
armsRum.init({
pid: "<your-app-id>",
endpoint: "<your-endpoint>",
filters: {
// Exclude specific exception events
exception: [
"Test error", // Starts with "Test error"
/^Script error\.?$/, // Exact regex match
(msg, error) => {
return msg.includes("example-error");
},
],
// Exclude specific resource or API events
resource: [
"https://example.com/", // Starts with this URL
/localhost/i, // Regex match
(url) => {
return url.includes("example-resource");
},
],
},
});properties parameters
Attach custom key-value properties to all events globally.
| Parameter | Type | Required | Description |
|---|---|---|---|
| [key: string] | String | Number | No | Custom property. Key: maximum 50 characters (truncated if exceeded). String value: maximum 2,000 characters (truncated if exceeded). Non-string and non-number values are removed. |
Merging behavior:
Add event-level properties through
evaluateApi,sendCustom,sendException, orsendResource. Event-level properties apply only to that specific event.When stored, global properties and event-level properties are merged. If both define the same key, the event-level value takes precedence.
After merging, a maximum of 20 key-value pairs are retained. Excess pairs are sorted by key and removed.
Example
armsRum.init({
pid: "<your-app-id>",
endpoint: "<your-endpoint>",
properties: {
prop_string: "xx",
prop_number: 2,
// Keys or values exceeding their limits are truncated.
more_than_50_key_limit_012345678901234567890123456789: "yy",
more_than_2000_value_limit: new Array(2003).join("1"),
// Invalid types are removed:
prop_null: null,
prop_undefined: undefined,
prop_bool: true,
},
});Environment attributes
The SDK automatically resolves device, OS, geolocation, ISP, and network attributes from IP addresses and the UserAgent string. Override any of these by setting them explicitly -- manually configured values take precedence over auto-resolved values.
| Parameter | Type | Description |
|---|---|---|
| device | Object | Device information. |
| os | Object | Operating system and container information. |
| geo | Object | Geolocation information. |
| isp | Object | ISP information. |
| net | Object | Network information. |
For a full list of supported fields, see Common attributes.
Example
armsRum.init({
pid: "<your-app-id>",
endpoint: "<your-endpoint>",
geo: {
country: "your custom country info",
city: "your custom city info",
},
});SDK APIs
Use these APIs to read or modify SDK configurations and report custom data at runtime.
getConfig
Retrieve the current SDK configuration.
const config = armsRum.getConfig();setConfig
Update SDK configuration after initialization.
// Update a single key
armsRum.setConfig("env", "pre");
// Update multiple keys
const config = armsRum.getConfig();
armsRum.setConfig({
...config,
version: "1.0.0",
env: "pre",
});sendCustom
Report a custom event. The type and name parameters are required.
| Parameter | Type | Required | Description |
|---|---|---|---|
| type | String | Yes | Event type. |
| name | String | Yes | Event name. |
| group | String | No | Event group. |
| value | Number | No | Numeric value. |
| properties | Object | No | Custom properties for this event. |
armsRum.sendCustom({
type: "CustomEventType1",
name: "customEventName2",
group: "customEventGroup3",
value: 111.11,
properties: {
prop_msg: "custom msg",
prop_num: 1,
},
});sendException
Report a custom exception. The name and message parameters are required.
| Parameter | Type | Required | Description |
|---|---|---|---|
| name | String | Yes | Exception name. |
| message | String | Yes | Exception message. |
| file | String | No | File where the exception occurred. |
| stack | String | No | Stack trace. |
| line | Number | No | Line number. |
| column | Number | No | Column number. |
| properties | Object | No | Custom properties for this event. |
armsRum.sendException({
name: "customErrorName",
message: "custom error message",
file: "custom exception filename",
stack: "custom exception error.stack",
line: 1,
column: 2,
properties: {
prop_msg: "custom msg",
prop_num: 1,
},
});sendResource
Report a custom resource event. The name, type, and duration parameters are required.
| Parameter | Type | Required | Description |
|---|---|---|---|
| name | String | Yes | Resource name. |
| type | String | Yes | Resource type, such as css, javascript, xmlhttprequest, fetch, api, image, or font. |
| duration | String | Yes | Response time. |
| success | Number | No | Request result. 1: success. 0: failure. -1: unknown. |
| method | String | No | HTTP method. |
| status_code | Number | String | No | HTTP status code. |
| message | String | No | Response message. |
| url | String | No | Request URL. |
| trace_id | String | No | Trace ID for distributed tracing. |
| properties | Object | No | Custom properties for this event. |
armsRum.sendResource({
name: "getListByPage",
type: "api",
duration: 800,
message: "success",
url: "https://www.example.com/data/getListByPage",
properties: {
prop_msg: "custom msg",
prop_num: 1,
},
});