All Products
Search
Document Center

Application Real-Time Monitoring Service:Sample configurations for the RUM SDK for minigames

Last Updated:Mar 11, 2026

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.

ParameterTypeRequiredDefaultDescription
pidStringYes-Minigame ID.
endpointStringYes-Endpoint to which monitoring data is reported.
envStringNoprodDeployment environment. Valid values: prod, gray, pre, daily, local.
versionStringNo-Minigame version.
userObjectNo-User identity settings. See User parameters.
beforeReportFunctionNo-Callback invoked before each data report. Return modified data to change the report, or return false to block it.
reportConfigObjectNo-Data reporting settings. See reportConfig parameters.
sessionConfigObjectNo-Session sampling and timeout settings. See sessionConfig parameters.
collectorsObjectNo-Enable or disable specific data collectors. See collectors parameters.
parseResourceNameFunctionNo-Custom function to parse the resource name (resource.name) from a resource URL.
evaluateApiFunctionNo-Custom function to parse API events. See evaluateApi parameters.
filtersObjectNo-Event filtering rules. See filters parameters.
propertiesObjectNo-Custom properties attached to all events. See properties parameters.

User parameters

ParameterTypeRequiredDefaultDescription
idStringNoGenerated by the SDKUnique user ID. Generated automatically and cannot be overridden.
nameStringNo-Username.
tagsStringNo-User tags.
Important

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.

ParameterTypeRequiredDefaultDescription
flushTimeNumberNo3000Reporting interval in milliseconds. Valid values: 0 to 10000. Set to 0 for immediate reporting.
maxEventCountNumberNo20Maximum 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.

ParameterTypeRequiredDefaultDescription
sampleRateNumberNo1Sampling rate. Valid values: 0 to 1. For example, 0.5 samples 50% of sessions.
maxDurationNumberNo86400000Maximum session duration in milliseconds. Default: 24 hours.
overtimeNumberNo3600000Session inactivity timeout in milliseconds. Default: 1 hour.
ParameterTypeRequiredDefaultDescription
sampleRateNumberNo1Sampling rate. Valid values: 0 to 1. For example, 0.5 samples 50% of sessions.
maxDurationNumberNo86400000Maximum session duration in milliseconds. Default: 24 hours.
overtimeNumberNo1800000Session 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.

ParameterTypeRequiredDefaultDescription
perfBoolean | ObjectNotrueMinigame performance data.
apiBoolean | ObjectNotrueAPI requests.
staticResourceBoolean | ObjectNotrueStatic resource loading.
consoleErrorBoolean | ObjectNotrueConsole errors.
jsErrorBoolean | ObjectNotrueJavaScript errors.
actionBoolean | ObjectNotrueUser 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:

ParameterTypeDescription
optionsObjectRequest parameters, including url, headers, and data. The exact fields depend on the request method.
responseObjectResponse body.
errorErrorError object. Only present when the request fails.

Return type (IApiBaseAttr):

Any returned fields override the SDK defaults. Omitted fields keep their default values.

ParameterTypeRequiredDescription
nameStringNoAPI name. Typically a converged URL (for example, /list/$id instead of /list/123). Maximum 1,000 characters. Takes precedence over parseResourceName.
messageStringNoBrief description of the API call. Maximum 1,000 characters.
successNumberNoRequest result. 1: success. 0: failure. -1: unknown.
durationNumberNoTotal request duration in milliseconds.
status_codeNumber | StringNoHTTP status code.
snapshotsStringNoDiagnostic 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.

ParameterTypeRequiredDescription
resourceMatchOption | MatchOption[]NoExclude static resource and API events (XMLHttpRequest, fetch) that match the specified patterns.
exceptionMatchOption | MatchOption[]NoExclude 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 true to exclude the event. For exception filters, the function receives an Error object 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.

ParameterTypeRequiredDescription
[key: string]String | NumberNoCustom 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, or sendResource. 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.

ParameterTypeDescription
deviceObjectDevice information.
osObjectOperating system and container information.
geoObjectGeolocation information.
ispObjectISP information.
netObjectNetwork 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.

ParameterTypeRequiredDescription
typeStringYesEvent type.
nameStringYesEvent name.
groupStringNoEvent group.
valueNumberNoNumeric value.
propertiesObjectNoCustom 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.

ParameterTypeRequiredDescription
nameStringYesException name.
messageStringYesException message.
fileStringNoFile where the exception occurred.
stackStringNoStack trace.
lineNumberNoLine number.
columnNumberNoColumn number.
propertiesObjectNoCustom 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.

ParameterTypeRequiredDescription
nameStringYesResource name.
typeStringYesResource type, such as css, javascript, xmlhttprequest, fetch, api, image, or font.
durationStringYesResponse time.
successNumberNoRequest result. 1: success. 0: failure. -1: unknown.
methodStringNoHTTP method.
status_codeNumber | StringNoHTTP status code.
messageStringNoResponse message.
urlStringNoRequest URL.
trace_idStringNoTrace ID for distributed tracing.
propertiesObjectNoCustom 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,
  },
});