All Products
Search
Document Center

Application Real-Time Monitoring Service:RUM SDK configuration reference for web and HTML5

Last Updated:Mar 11, 2026

The Real User Monitoring (RUM) SDK for web and HTML5 provides configuration options for data collection, session management, event filtering, and white screen detection. This reference covers common SDK configurations, runtime APIs, and usage examples.

Initialization parameters

Pass these parameters to ArmsRum.init() to configure the SDK at startup.

ParameterTypeRequiredDefaultDescription
pidStringYes-Application ID
endpointStringYes-Data reporting endpoint
envStringNoprodApplication environment. Valid values: prod, gray, pre, daily, local
versionStringNo-Application version
userObjectNo-User settings. See User parameters
spaModeStringNofalseSingle-page application (SPA) route tracking mode. Valid values: hash, history, auto, false
beforeReportFunctionNo-Callback invoked before each report is sent to modify or block the reported data
reportConfigObjectNo-Data reporting settings. See reportConfig parameters
sessionConfigObjectNo-Session sampling and storage settings. See sessionConfig parameters
collectorsObjectNo-Data collector toggles. See collectors parameters
parseViewNameFunctionNo-Custom parser for the view name (view.name). Receives the page URL as input
parseResourceNameFunctionNo-Custom parser for the resource name (resource.name). Receives the resource URL as input
evaluateApiFunctionNo-Custom parser for API events. See evaluateApi parameters
filtersObjectNo-Event filter rules. See filters parameters
whiteScreenObjectNo-White screen detection settings. See whiteScreen parameters
propertiesObjectNo-Global custom properties attached to all events. See properties parameters
remoteConfigObjectNo-Dynamic configuration delivery. See Dynamic configuration

CDN initialization

When loading the SDK through Alibaba Cloud Content Delivery Network (CDN), access it from the RumSDK.default global namespace:

const ArmsRum = window.RumSDK.default;

// Initialize the SDK after it has loaded.
// Skip this step if you defined window.__rum before the SDK script tag.
ArmsRum.init({
  pid: "<your-app-id>",
  endpoint: "<your-endpoint>",
});

// Update configuration at runtime
ArmsRum.setConfig('env', 'pre');

npm initialization

import ArmsRum from '@arms/rum-browser';

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

User parameters

Associate RUM sessions with your business accounts through the user object.

ParameterTypeRequiredDefaultDescription
idStringNo-User ID. Auto-generated by the SDK and cannot be modified
nameStringNo-Username
tagsStringNo-User tags
Important

Do not overwrite user.id. The SDK auto-generates this value, and overwriting it affects unique visitor (UV) calculations. To link sessions to your account system, use 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 the reporting interval and batch size.

ParameterTypeRequiredDefaultValid rangeDescription
flushTimeNumberNo30000 -- 10000Reporting interval in milliseconds. Set to 0 for immediate reporting
maxEventCountNumberNo201 -- 100Maximum number of events per batch

Example

ArmsRum.init({
  pid: "<your-app-id>",
  endpoint: "<your-endpoint>",
  reportConfig: {
    flushTime: 0,       // Report immediately
    maxEventCount: 50,  // Up to 50 events per batch
  },
});

sessionConfig parameters

Configure session sampling, duration limits, and storage.

ParameterTypeRequiredDefaultDescription
sampleRateNumberNo1Sampling rate from 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)
storageStringNolocalStorageWhere to store session data. Valid values: cookie, localStorage

Storage details

The storage parameter determines where the SDK persists the following data:

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

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

    • sessionId -- unique session identifier

    • sampled -- whether this session was selected by sampling

    • startTime -- session start timestamp

    • lastTime -- last activity timestamp

Example

ArmsRum.init({
  pid: "<your-app-id>",
  endpoint: "<your-endpoint>",
  sessionConfig: {
    sampleRate: 0.5,          // Sample 50% of sessions
    maxDuration: 86400000,    // 24-hour maximum
    overtime: 3600000,        // 1-hour inactivity timeout
    storage: 'cookie',        // Use cookie instead of localStorage
  },
});

collectors parameters

Toggle individual data collectors. All collectors are enabled by default.

ParameterTypeRequiredDefaultDescription
perfBoolean \ObjectNotruePage performance data
webvitalsBoolean \ObjectNotrueWeb Vitals metrics
apiBoolean \ObjectNotrueAPI requests (XMLHttpRequest, fetch)
staticResourceBoolean \ObjectNotrueStatic resource requests
consoleErrorBoolean \ObjectNotrueConsole errors
jsErrorBoolean \ObjectNotrueJavaScript errors
actionBoolean \ObjectNotrueUser behavior

Example

Disable user interaction tracking:

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

evaluateApi parameters

The evaluateApi function customizes how XMLHttpRequest and fetch events are parsed. It receives three arguments and returns a Promise<IApiBaseAttr>.

Input arguments

ParameterTypeDescription
optionsObjectRequest parameters: url, headers, and data. Exact fields depend on the request method
responseObjectResponse body
errorErrorError object. Present only when the request fails

Return type (IApiBaseAttr)

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

FieldTypeRequiredDescription
nameStringNoAPI name, typically a converged URL (max 1,000 characters). For example, /list/$id for /list/123. Takes precedence over parseResourceName
messageStringNoBrief description of the API call (max 1,000 characters)
successNumberNoRequest result: 1 = success, 0 = failed, -1 = unknown
durationNumberNoTotal API duration
status_codeNumber \StringNoStatus code
snapshotsStringNoDiagnostic snapshot (max 5,000 characters). Stores reqHeaders, params, and resHeaders. Not indexed and cannot be used for querying or aggregation

Example

ArmsRum.init({
  pid: "<your-app-id>",
  endpoint: "<your-endpoint>",
  evaluateApi: async (options, response, error) => {
    let respText = '';
    if (response && response.text) {
      respText = await response.text();
    }

    return {
      name: 'my-custom-api',
      success: error ? 0 : 1,
      snapshots: JSON.stringify({
        params: 'page=1&size=10',
        response: respText.substring(0, 2000),
        reqHeaders: '',
        resHeaders: '',
      }),
      properties: {
        prop_msg: 'custom msg',
        prop_num: 1,
      },
    };
  },
});

filters parameters

Exclude specific resource or exception events from reporting.

ParameterTypeRequiredDescription
resourceMatchOption \MatchOption[]NoExclude static resource and API events (XMLHttpRequest, fetch) that match
exceptionMatchOption \MatchOption[]NoExclude exception events that match

MatchOption type

type MatchOption = string | RegExp | ((value: string) => boolean);
  • String -- matches any URL or message that starts with the specified value. For example, 'https://api.aliyun.com' matches 'https://api.aliyun.com/v1/resource'.

  • RegExp -- matches URLs or messages against a regular expression.

  • Function -- receives the URL or message as input. Return true to exclude the event.

When you pass an array of MatchOption values, conditions are evaluated in order. An event is excluded if any condition matches.

Example

ArmsRum.init({
  pid: "<your-app-id>",
  endpoint: "<your-endpoint>",
  filters: {
    exception: [
      'Test error',                           // Messages starting with 'Test error'
      /^Script error\.?$/,                    // Messages matching this regex
      (msg) => msg.includes('example-error'), // Custom match function
    ],
    resource: [
      'https://example.com/',   // URLs starting with 'https://example.com/'
      /localhost/i,             // URLs containing 'localhost'
      (url) => url.includes('example-resource'),
    ],
  },
});

whiteScreen parameters

Detect blank or white screen states in your application. Supported in Chrome 40 and IE 9+.

ParameterTypeDescription
detectionRulesArray<DetectionRule>One or more detection rules. Rules run in the configured order

DetectionRule

ParameterTypeRequiredDefaultDescription
targetStringYes-CSS selector for the element to monitor
test_whenArrayYes-Events that trigger detection. Valid values: LOAD, ERROR, ROUTE_CHANGE, LEAVE
delayNumberNo0Delay in milliseconds before detection starts after a trigger event (except ERROR and LEAVE)
testerString \FunctionYes-Detection method. Valid values: HAS_CONTENT, SAMPLE, SCREENSHOT, or a custom function
ignoreUrlListArray<String>No[]Page URLs to skip
configOptionsConfigOptionsNo-Tester-specific options. See ConfigOptions

Trigger events

EventDescription
LOADPage loading completes
ERRORA global JavaScript error occurs
ROUTE_CHANGEThe route (history or hash) changes
LEAVEThe page is about to close

Detection methods

MethodHow it works
HAS_CONTENTChecks whether nodes exist and contain textContent
SAMPLESets sampling points across the target area and checks whether the topmost DOM element at each point belongs to an allowed element set
SCREENSHOTTakes a canvas screenshot and compares pixel blocks to calculate the white screen rate
Custom functionReceives the target element as input. Return a CustomTesterResult or Promise<CustomTesterResult>

CustomTesterResult type:

type CustomTesterResult = {
  hasContent: boolean;               // true = content exists; false = white screen detected
  message?: string;                  // Error message
  snapshot?: Record<string, any>;    // Diagnostic data
}

ConfigOptions

Options specific to the SCREENSHOT and SAMPLE detection methods.

SCREENSHOT options:

ParameterTypeDefaultDescription
colorRangeArray<String>['rgb(255, 255, 255)']Colors treated as "white." Format: rgb(r, g, b)
fillColorString'rgba(0, 100, 200, 255)'Fill color applied to images, videos, canvases, SVGs, and iframes during screenshotting. Must not overlap with colorRange
horizontalOffsetNumber0Horizontal offset (px) from the target element's left edge. Use this to exclude a left sidebar
verticalOffsetNumber0Vertical offset (px) from the target element's top edge. Use this to exclude a top navbar
pixelsNumber10Pixel block size (pixels x pixels) for comparison
thresholdNumber0.8White screen rate threshold. A rate above this value triggers a white screen event
dprNumber0.3Scaling ratio for the screenshot image
ignoreElementsArray<String>[]CSS selectors for elements to exclude from screenshots

SAMPLE options:

ParameterTypeDefaultDescription
sampleMethod`1 \2 \3`2Sampling pattern: 1 = cross, 2 = intersecting cross, 3 = rice
checkPointsNumber10Number of radial sampling points. Total points: cross/intersecting cross = 4 * checkPoints + 1; rice = 8 * checkPoints + 1
thresholdNumber0.8White screen rate threshold
whiteBoxElementsArray<String>[]CSS selectors for elements considered "white." When the topmost element at a sampling point matches any selector, the white screen count increments

Shared option:

Both SCREENSHOT and SAMPLE support the debug option (Boolean, default: false). When enabled, detection details are printed to the browser developer tools console.

Examples

Screenshot-based detection:

ArmsRum.init({
  pid: "<your-app-id>",
  endpoint: "<your-endpoint>",
  whiteScreen: {
    detectionRules: [{
      target: '#root',
      test_when: ['LOAD', 'ERROR', 'ROUTE_CHANGE', 'LEAVE'],
      delay: 5000,
      tester: 'SCREENSHOT',
      configOptions: {
        colorRange: ['rgb(255, 255, 255)', 'rgb(0, 0, 0)'],
        threshold: 0.9,
        pixels: 10,
        horizontalOffset: 210,
        verticalOffset: 50,
      },
    }],
  },
});

Sampling-based detection:

ArmsRum.init({
  pid: "<your-app-id>",
  endpoint: "<your-endpoint>",
  whiteScreen: {
    detectionRules: [{
      target: '#root',
      test_when: ['LOAD', 'ERROR', 'ROUTE_CHANGE', 'LEAVE'],
      delay: 5000,
      tester: 'SAMPLE',
      configOptions: {
        sampleMethod: 2,
        checkPoints: 10,
        threshold: 0.9,
        whiteBoxElements: ['.el-skeleton'],
      },
    }],
  },
});

Custom detection function:

ArmsRum.init({
  pid: "<your-app-id>",
  endpoint: "<your-endpoint>",
  whiteScreen: {
    detectionRules: [{
      target: '#root',
      test_when: ['LOAD', 'ERROR', 'ROUTE_CHANGE', 'LEAVE'],
      delay: 5000,
      tester: async (element) => {
        return {
          hasContent: false,
          message: 'Custom error message',
          snapshot: {
            checkPoints: 100,
            rate: 0.99,
            checkdata: '......',
          },
        };
      },
    }],
  },
});

properties parameters

Attach global custom properties to all reported events.

ParameterTypeRequiredDescription
[key: string]String \NumberNoCustom key-value pair. The key must be a string that conforms to the JSON specification, with a maximum of 50 characters (truncated if longer). String value: max 2,000 characters. Non-string and non-number values are dropped

Merge behavior

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

  • Event-level properties take precedence. If the same key exists in both, the event-level value wins.

  • After merging, a maximum of 20 key-value pairs are kept. 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 longer than 50 characters are truncated
    more_than_50_key_limit_012345678901234567890123456789: 'yy',
    // String values longer than 2,000 characters are truncated
    more_than_2000_value_limit: new Array(2003).join('1'),
    // Invalid types -- these pairs are removed
    prop_null: null,
    prop_undefined: undefined,
    prop_bool: true,
  },
});

Dynamic configuration

The SDK supports remote delivery of configuration settings. During initial load, the SDK fetches remote settings that override the static values from init() and updates features such as instrumentation and data reporting accordingly.

Step 1: Configure in the ARMS console

  1. Go to Application List and open your application.

  2. Go to Application Settings > SDK config.

  3. Set the desired configuration values.

  4. Click Confirm Update Dynamic Configuration to push the settings to the remote Object Storage Service (OSS) server.

Step 2: Enable in the SDK

Add the remoteConfig field to your initialization code with the region where your application is hosted.

CDN:

window.__rum = {
  pid: "<your-app-id>",
  endpoint: "<your-endpoint>",
  remoteConfig: {
    region: "cn-hangzhou"  // Example: "ap-southeast-1" for Singapore
  }
};
<script async src="https://xxid-sdk.rum.aliyuncs.com/v2/browser-sdk.js"></script>

npm:

import ArmsRum from '@arms/rum-browser';

ArmsRum.init({
  pid: "<your-app-id>",
  endpoint: "<your-endpoint>",
  remoteConfig: {
    region: "cn-hangzhou"  // Example: "ap-southeast-1" for Singapore
  }
});

Caching behavior

After retrieving the remote configuration, the SDK caches the settings locally. On subsequent initializations, the SDK prioritizes the cached configuration.

Dynamic configuration requires SDK version 0.0.37 or later when importing through CDN with a pinned version.

Auto-resolved parameters

The SDK auto-resolves these properties from IP addresses and User-Agent headers. Explicitly set values take precedence over auto-resolved values.

ParameterTypeRequiredDescription
deviceObjectNoDevice information
osObjectNoOperating system and container information
geoObjectNoGeolocation
ispObjectNoISP/carrier information
netObjectNoNetwork connection information

For field details, see the Common properties section in the Log data topic.

Example

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

SDK APIs

After initialization, use these methods to modify configuration and report custom data.

getConfig

Retrieve the current SDK configuration:

const config = ArmsRum.getConfig();

setConfig

Update SDK configuration at runtime. Pass a single key-value pair or a full configuration object:

// Set a single value
ArmsRum.setConfig('env', 'pre');

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

sendCustom

Report a custom event. The type and name fields are required.

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

ParameterTypeRequiredDescription
nameStringYesException name
messageStringYesException message
fileStringNoSource file
stackStringNoStack trace
lineNumberNoLine number
columnNumberNoColumn number
propertiesObjectNoCustom properties
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 fields are required.

ParameterTypeRequiredDescription
nameStringYesResource name
typeStringYesResource type (for example, css, javascript, xmlhttprequest, fetch, api, image, font)
durationStringYesResponse time
successNumberNoResult: 1 = success, 0 = failed, -1 = unknown
methodStringNoHTTP method
status_codeNumber \StringNoStatus code
messageStringNoResponse message
urlStringNoRequest URL
trace_idStringNoDistributed trace ID
propertiesObjectNoCustom properties
ArmsRum.sendResource({
  name: 'getListByPage',
  message: 'success',
  duration: 800,
  url: 'https://www.aliyun.com/data/getListByPage',
  properties: {
    prop_msg: 'custom msg',
    prop_num: 1,
  },
});