All Products
Search
Document Center

Application Real-Time Monitoring Service:RUM SDK configuration reference for mini programs

Last Updated:Mar 11, 2026

Configure the Application Real-Time Monitoring Service (ARMS) Real User Monitoring (RUM) SDK for mini programs using the initialization parameters, data collectors, event filters, custom properties, and APIs described in this reference.

Pass all configuration options to ArmsRum.init():

ArmsRum.init({
  pid: "<your-app-id>",
  endpoint: "<your-endpoint>",
  // Additional parameters
});

Initialization parameters

ParameterTypeRequiredDefaultDescription
pidStringYes-The mini program ID.
endpointStringYes-The address to which monitoring data is reported.
envStringNoprodThe deployment environment. Valid values: prod (production), gray (canary release), pre (pre-release), daily (daily), local (local).
versionStringNo-The mini program version.
userObjectNoSDK-generated user.idUser identity settings. See user parameters.
collectorsObjectNo-Data collector settings. See collectors parameters.
beforeReportFunctionNonoopA callback invoked before each report. Use it to modify or block outgoing data.
reportConfigObjectNo{ flushTime: 3000, maxEventCount: 20 }Data reporting settings. See reportConfig parameters.
sessionConfigObjectNo-Session sampling and timeout settings. See sessionConfig parameters.
parseViewNameFunctionNo-Parses the view name (view.name) from a page URL.
parseResourceNameFunctionNo-Parses the resource name (resource.name) from a resource URL.
evaluateApiFunctionNo-Custom parser for API events. See evaluateApi parameters.
filtersObjectNo-Event filtering rules. See filters parameters.
propertiesObjectNo-Custom properties attached to all events. See properties parameters.

user parameters

Configure user identity for session tracking.

ParameterTypeRequiredDefaultDescription
idStringNoSDK-generatedThe user ID. Generated by the SDK and cannot be modified.
tagsStringNo-User tags for categorization.
nameStringNo-The username.
Important

Do not overwrite user.id. Changing it affects unique visitor (UV) data. To integrate your own account system, set user.name or user.tags instead.

Example

ArmsRum.init({
  pid: "<your-app-id>",
  endpoint: "<your-endpoint>",
  user: {
    name: getYourUserName(),
    tags: getYourTags(),
  }
});

reportConfig parameters

Control how frequently and in what batch size the SDK reports data.

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

Control session sampling rates and timeouts. Use sampling to reduce data volume in high-traffic environments.

ParameterTypeRequiredDefaultDescription
sampleRateNumberNo1The sampling rate. Valid values: 0 to 1. For example, 0.5 applies a 50% sampling rate.
maxDurationNumberNo86400000The maximum session duration in milliseconds. Default: 24 hours.
overtimeNumberNo1800000The session timeout in milliseconds. A session expires after this period of inactivity. Default: 30 minutes.

Local cache

The SDK stores user ID and session data in the mini program's local cache:

  • _arms_uid: the unique user ID (user.id).

  • _arms_session: session metadata in the format ${sessionId}-${sampled}-${startTime}-${lastTime}, where:

    • sessionId: the unique session ID.

    • sampled: whether sampling was triggered.

    • startTime: the session start timestamp.

    • lastTime: the last activity timestamp.

Example

ArmsRum.init({
  pid: "<your-app-id>",
  endpoint: "<your-endpoint>",
  sessionConfig: {
    sampleRate: 0.5,          // 50% sampling rate
    maxDuration: 86400000,    // 24-hour max session
    overtime: 3600000,        // 1-hour inactivity timeout
  },
});

collectors parameters

Collectors gather specific types of monitoring data. Each collector can be enabled (true), disabled (false), or configured with an options object.

ParameterTypeRequiredDefaultDescription
apiBoolean \ObjectNotrueTracks API requests.
jsErrorBoolean \ObjectNotrueTracks JavaScript errors.
consoleErrorBoolean \ObjectNotrueTracks errors from console.error.
actionBoolean \ObjectNotrueTracks user interactions.

Example

Disable user interaction tracking:

ArmsRum.init({
  pid: "<your-app-id>",
  endpoint: "<your-endpoint>",
  collectors: {
    action: false,
  }
});

evaluateApi parameters

The evaluateApi function provides custom parsing for API events, including request and httpRequest events. It accepts three arguments and returns a Promise<IApiBaseAttr>.

Function signature:

evaluateApi: async (options, response, error?) => IApiBaseAttr

Arguments:

ParameterTypeDescription
optionsObjectThe request parameters, including url, headers, and data. The exact fields depend on the request method.
responseObjectThe response body.
errorErrorThe error object. Present only when the request fails.

Return value (IApiBaseAttr):

Returned fields overwrite the SDK defaults. Omitted fields keep their default values.

ParameterTypeRequiredDescription
nameStringNoThe API name, typically a converged URL. Maximum 1,000 characters. For example, /list/123 becomes /list/$id. This value takes precedence over parseResourceName.
messageStringNoA brief description of the API. Maximum 1,000 characters.
successNumberNoThe request result: 1 (success), 0 (failure), -1 (unknown).
durationNumberNoThe total duration of the request.
status_codeNumber \StringNoThe HTTP status code.
snapshotsStringNoDebugging data such as reqHeaders, params, and resHeaders. Maximum 5,000 characters. Snapshots are not indexed and cannot be used as filter conditions for queries or aggregation.

Example

ArmsRum.init({
  pid: "<your-app-id>",
  endpoint: "<your-endpoint>",
  evaluateApi: async (options, response, error) => {
    const respText = JSON.stringify(response);

    // Returned fields overwrite defaults. Omitted fields keep default values.
    return {
      name: 'my-custom-api',
      success: error ? 0 : 1,
      snapshots: JSON.stringify({
        params: 'page=1&size=10',
        response: respText.substring(0, 2000),
        reqHeaders: '',
        resHeaders: ''
      })
    }
  }
});

filters parameters

Exclude specific resource and exception events from reporting.

ParameterTypeRequiredDescription
resourceMatchOption \MatchOption[]NoExcludes static resource and API events (such as XMLHttpRequest or fetch).
exceptionMatchOption \MatchOption[]NoExcludes exception events.

MatchOption

type MatchOption = string | RegExp | ((value: string) => boolean);

Three matching modes are available:

  • String: matches any URL that starts with the specified value. For example, 'https://api.aliyun.com' matches https://api.aliyun.com/v1/resource.

  • RegExp: matches URLs against a regular expression.

  • Function: a custom function that returns true to exclude the event.

When MatchOption[] is provided, conditions are evaluated in order. An event is excluded if any condition matches.

Example

ArmsRum.init({
  pid: "<your-app-id>",
  endpoint: "<your-endpoint>",
  filters: {
    // Exclude exception events
    exception: [
      'Test error',                    // Prefix match
      /^Script error\.?$/,             // Regex match
      (msg) => {
        return msg.includes('example-error');  // Custom function
      },
    ],
    // Exclude resource and API events
    resource: [
      'https://example.com/',          // Prefix match
      /localhost/i,                     // Regex match (case-insensitive)
      (url) => {
        return url.includes('example-resource');
      },
    ],
  },
});

properties parameters

Attach custom key-value properties to all events.

ParameterTypeRequiredDescription
[key: string]String \NumberNoA custom property. Key: maximum 50 characters (excess is truncated). String value: maximum 2,000 characters. Non-string, non-number values are removed.

Merge behavior:

  • Global properties (set in init()) and event-level properties (set via evaluateApi, sendCustom, sendException, or sendResource) are merged at storage time.

  • Event-level properties take precedence over global properties with the same key.

  • After merging, the total number of key-value pairs cannot exceed 20. 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 the length limit are truncated
    more_than_50_key_limit_012345678901234567890123456789: 'yy',
    more_than_2000_value_limit: new Array(2003).join('1'),
    // Invalid values are removed
    prop_null: null,
    prop_undefined: undefined,
    prop_bool: true,
  },
});

Auto-resolved parameters

The SDK automatically resolves the following properties from IP addresses and UserAgent strings. Manually configured values take precedence over auto-resolved values.

ParameterTypeRequiredDescription
deviceObjectNoDevice information.
osObjectNoOperating system and container information.
geoObjectNoGeolocation information.
ispObjectNoISP information.
netObjectNoNetwork information.

For field descriptions, see Common attributes.

Example

ArmsRum.init({
  pid: "<your-app-id>",
  endpoint: "<your-endpoint>",
  geo: {
    country: '<your-country>',
    city: '<your-city>',
  },
});

SDK APIs

Use the following APIs to read and modify configurations at runtime and to report custom data.

getConfig

Retrieve the current SDK configuration:

const config = ArmsRum.getConfig();

setConfig

Update SDK configuration after initialization:

// Update a single parameter
ArmsRum.setConfig('env', 'pre');

// Update multiple parameters
const config = ArmsRum.getConfig();
ArmsRum.setConfig({
  ...config,
  version: '1.0.0',
  env: 'pre',
});

sendCustom

Report a custom event. Both type and name are required.

ParameterTypeRequiredDefaultDescription
typeStringYes-The event type.
nameStringYes-The event name.
groupStringNo-The event group.
valueNumberNo-A numeric value associated with the event.
ArmsRum.sendCustom({
  type: 'CustomEventType1',
  name: 'customEventName2',
  group: 'customEventGroup3',
  value: 111.11
});

sendException

Report a custom exception. Both name and message are required.

ParameterTypeRequiredDefaultDescription
nameStringYes-The exception name.
messageStringYes-The exception message.
fileStringNo-The file where the exception occurred.
stackStringNo-The stack trace.
lineNumberNo-The line number.
columnNumberNo-The column number.
ArmsRum.sendException({
  // Required
  name: 'customErrorName',
  message: 'custom error message',
  // Optional
  file: 'custom exception filename',
  stack: 'custom exception error.stack',
  line: 1,
  column: 2
});

sendResource

Report a custom resource event. The name, type, and duration parameters are required.

ParameterTypeRequiredDefaultDescription
nameStringYes-The resource name.
typeStringYes-The resource type, such as script, api, or image.
durationStringYes-The response time.
successNumberNo-The request result: 1 (success), 0 (failure), -1 (unknown).
methodStringNo-The request method.
status_codeNumber \StringNo-The HTTP status code.
messageStringNo-A descriptive message.
urlStringNo-The request URL.
trace_idStringNo-The trace ID for distributed tracing.
ArmsRum.sendResource({
  // Required
  name: 'getListByPage',
  message: 'success',
  duration: 800,
  // Optional
  url: 'https://www.example.com/data/getListByPage',
});