All Products
Search
Document Center

Application Real-Time Monitoring Service:Browser Monitoring SDK configuration

Last Updated:Mar 11, 2026

The ARMS Browser Monitoring SDK provides configuration items that control data collection and reporting. Use these items to filter URLs, APIs, and JavaScript errors, aggregate pages by normalizing URLs, and reduce data volume through sampling.

How to set configuration items

Two methods are available:

  • At initialization -- Add parameters to config when installing the Browser Monitoring agent on a page.

  • After initialization -- Call __bl.setConfig(next) to update configuration at runtime.

Initialization example

This snippet installs the agent with the required pid plus three optional parameters -- enableSPA, sendResource, and release:

<script>
!(function(c,b,d,a){c[a]||(c[a]={});c[a].config={
  pid: "<your-pid>",
  enableSPA: true,
  sendResource: true,
  release: "1.0.0"
};
with(b)with(body)with(insertBefore(createElement("script"),firstChild))setAttribute("crossorigin","",src=d)
})(window,document,"https://retcode.alicdn.com/retcode/bl.js","__bl");
</script>

Runtime updates with setConfig

Call __bl.setConfig(next) to modify configuration after page load.

ParameterTypeRequiredDescription
nextObjectYesKey-value pairs of configuration items to update
__bl.setConfig({
    uid: "user-12345",
    tag: "checkout-flow"
});
Important

The following parameters only take effect at initialization and cannot be changed through setConfig: disableHook and release.


Configuration reference

The following table lists all configuration items grouped by function. Each item is described in detail in the sections that follow.

Identity

ParameterTypeDefaultDescription
pidStringNoneProject ID (required)
uidStringAuto-generatedUser identifier
setUsernameFunctionNoneCallback that returns a username for session tracing

Page and URL

ParameterTypeDefaultDescription
pageStringhost + pathnameCustom page name
tagStringNoneCustom tag attached to every log entry
ignoreUrlCaseBooleantrueCase-insensitive page URL matching
urlHelperString \RegExp \Object \Function \ArraySee belowNormalize page URLs for aggregation
apiHelperString \RegExp \Object \Function \ArraySee belowNormalize API URLs for aggregation

SPA support

ParameterTypeDefaultDescription
enableSPABooleanfalseReport PV on each route change
parseHashFunctionSee belowConvert URL hash to page name

Data filtering

ParameterTypeDefaultDescription
ignoreObjectSee belowSuppress log reporting for matching URLs, APIs, or errors
parseResponseFunctionSee belowExtract msg and code from API responses

Sampling

ParameterTypeDefaultDescription
sampleInteger (1--100)1Sampling rate for performance and successful API logs
pvSampleInteger (1--100)1Sampling rate for PV logs

Performance and resource tracking

ParameterTypeDefaultDescription
sendResourceBooleanfalseReport static resources loaded on the page
useFmpBooleanfalseCollect First Meaningful Paint (FMP) data
autoSendPerfBooleantrueSend performance logs automatically
disableHookBooleanfalseDisable AJAX request listeners

Tracing and diagnostics

ParameterTypeDefaultDescription
enableLinkTraceBooleanfalseEnable front-to-back tracing
behaviorBooleanBrowser: true; Mini program: falseRecord user actions before errors

Application metadata

ParameterTypeDefaultDescription
releaseStringundefinedApplication version string
environmentStringprodDeployment environment label
disabledBooleanfalseDisable all log reporting

Custom fields

ParameterTypeDefaultDescription
c1, c2, c3StringNoneCustom fields attached to every log entry

Identity

pid

PropertyValue
TypeString
RequiredYes
DefaultNone

Unique project ID, generated automatically when ARMS creates a site.

uid

PropertyValue
TypeString
RequiredYes (Weex); No (other scenarios)
DefaultWeex: None; Others: auto-generated by the SDK, refreshed every six months

User identifier for searching and tracking individual users. Specify a custom value, or let the SDK generate one automatically.

__bl.setConfig({
    uid: "user-12345"
});
Note

In mini program monitoring, setConfig cannot modify uid. Use setUsername instead.

setUsername

PropertyValue
TypeFunction
RequiredNo
DefaultNone

A callback that returns a username string. Once set, enables end-to-end session tracing and session lookup by username for troubleshooting.

__bl.setConfig({
    setUsername: function () {
        return "username_xxx";
    }
});

Behavior:

  • If the username is unavailable at page load, return null -- not a placeholder. The SDK calls setUsername again when sending logs. Returning a placeholder means that value is used and setUsername is not called again.

  • setUsername accepts only one assignment per runtime. Restart the application to reassign it.


Page and URL configuration

page

PropertyValue
TypeString
RequiredNo
Defaulthost + pathname of the current URL

Overrides the automatically detected page name with a custom value.

Note

You can use the ignoreErrors property to filter errors you want to report. For more information, see ignore.

tag

PropertyValue
TypeString
RequiredNo
DefaultNone

A custom tag attached to every log entry. Use tags to categorize or filter logs in the ARMS console.

ignoreUrlCase

PropertyValue
TypeBoolean
RequiredNo
Defaulttrue

When set to true, page URL matching is case-insensitive.

urlHelper

PropertyValue
TypeString \RegExp \Object\ \Function \Array
RequiredNo
DefaultSee below

Normalizes page URLs by removing dynamic segments so that similar pages aggregate under one entry. Replaces the deprecated ignoreUrlPath parameter.

Why normalize URLs: A URL like example.com/projects/123456 generates a unique page name per project ID. urlHelper strips dynamic segments so all project pages aggregate as example.com/projects/**.

Default value:

[
    // Replace digit sequences (2-20 chars) with **
    {rule: /\/([a-z\-_]+)?\d{2,20}/g, target: '/$1**'},
    // Remove trailing slash
    /\/$/
]

Supported value types:

TypeBehavior
String or RegExpMatched substrings are removed
Object {rule, target}Works like String.replace(rule, target)
FunctionReceives the original URL, returns the page name
ArrayApplies multiple rules in sequence; each element can be any of the above types
Important
  • If both ignoreUrlPath and urlHelper are set, urlHelper takes precedence.

  • urlHelper only applies when the page URL is auto-detected. It has no effect when setPage, setConfig, or enableSPA: true overrides the page name. For more information, see SDK methods.

apiHelper

PropertyValue
TypeString \RegExp \Object\ \Function \Array
RequiredNo
Default{rule: /(\w+)\/\d{2,}/g, target: '$1'}

Normalizes API URLs by removing dynamic segments, the same way urlHelper normalizes page URLs. Replaces the deprecated ignoreApiPath parameter.

Important

If both ignoreApiPath and apiHelper are set, apiHelper takes precedence.

Reporting query parameters in API data: To include query parameters (for example, pid in https://arms.console.aliyun.com/apm?pid=fr6fbgbeot), disable automatic reporting with the ignore parameter and call api() manually. For details, see api().


SPA support

enableSPA

PropertyValue
TypeBoolean
RequiredNo (Web only)
Defaultfalse

Listens for hashchange events and reports a new page view (PV) on each route change. Enable this for single-page applications (SPAs).

parseHash

PropertyValue
TypeFunction
RequiredNo
DefaultSee below

Used with enableSPA. When enableSPA is true and a hashchange event fires, parseHash converts the URL hash into a page name for the Page field. For details, see Page data reporting of SPAs.

Default value:

function (hash) {
    var page = hash ? hash.replace(/^#/, '').replace(/\?.*$/, '') : '';
    return page || '[index]';
}

Typically, the default is sufficient. To map hashes to custom page names, override this function:

var PAGE_MAP = {
    '/': 'Homepage',
    '/contact': 'Contact us',
    '/list': 'Data list'
};

window.addEventListener('load', function (e) {
    __bl.setConfig({
        parseHash: function (hash) {
            var key = hash.replace(/\?.*$/, '');
            return PAGE_MAP[key] || 'Unknown page';
        }
    });
});

Data filtering

ignore

PropertyValue
TypeObject
RequiredNo
Default{ignoreUrls: [], ignoreApis: [], ignoreErrors: [], ignoreResErrors: []}

Suppresses log reporting for URLs, APIs, JavaScript errors, or resource errors that match specified rules. Contains four sub-properties.

Each sub-property accepts a String, RegExp, Function, or an Array of these types.

ignoreUrls

Suppresses logs from matching page URLs.

__bl.setConfig({
    ignore: {
        ignoreUrls: [
            'http://host1/',                     // Exact string match
            /.+?host2.+/,                        // Regex match
            function(str) {                      // Custom function
                if (str && str.indexOf('host3') >= 0) {
                    return true;   // Suppress
                }
                return false;      // Report
            }
        ]
    }
});

ignoreApis

Suppresses logs from matching API URLs.

__bl.setConfig({
    ignore: {
        ignoreApis: [
            'api1', 'api2', 'api3',              // String matches
            /^random/,                            // Regex match
            function(str) {                       // Custom function
                if (str && str.indexOf('api3') >= 0) return true;
                return false;
            }
        ]
    }
});

ignoreErrors

Suppresses matching JavaScript error messages.

__bl.setConfig({
    ignore: {
        ignoreErrors: [
            'test error',                         // String match
            /^Script error\.?$/,                  // Regex match
            function(str) {                       // Custom function
                if (str && str.indexOf('Unknown error') >= 0) return true;
                return false;
            }
        ]
    }
});

ignoreResErrors

Suppresses matching resource loading errors.

__bl.setConfig({
    ignore: {
        ignoreResErrors: [
            'http://xx/picture.jpg',              // String match
            /jpg$/,                               // Regex match
            function(str) {                       // Custom function
                if (str && str.indexOf('xx.jpg') >= 0) return true;
                return false;
            }
        ]
    }
});

parseResponse

PropertyValue
TypeFunction
RequiredNo
DefaultSee below

Parses API response data during automatic reporting. Extracts msg and code from the response object.

Default value:

function (res) {
    if (!res || typeof res !== 'object') return {};
    var code = res.code;
    var msg = res.msg || res.message || res.subMsg || res.errorMsg || res.ret || res.errorResponse || '';
    if (typeof msg === 'object') {
        code = code || msg.code;
        msg = msg.msg || msg.message || msg.info || msg.ret || JSON.stringify(msg);
    }
    return {msg: msg, code: code, success: true};
}

Override this function if your API responses use a different structure.


Sampling

sample

PropertyValue
TypeInteger
RequiredNo
Default1
Range1--100

Controls the sampling rate for performance logs and successful API logs. Sampling rate = 1 / sample:

ValueSampling rate
1100% (all data)
1010%
1001%

Sampling reduces data volume and collection overhead. To reduce costs, you can also use the ignore parameter to stop reporting data that does not require monitoring. For more information, see ignore.

ARMS compensates for sampling during processing, so aggregate metrics like JS error rate and API failure rate remain accurate. However, individual log details may be lost.

For more information about the affected metrics, see Statistical metrics.

Warning

Random sampling on low-traffic sites introduces significant statistical deviation. Use this parameter only for sites with over 1 million daily page views.

pvSample

PropertyValue
TypeInteger
RequiredNo
Default1
Range1--100

Controls the sampling rate for page view (PV) logs. Same formula as sample: sampling rate = 1 / pvSample.

ARMS compensates for sampling during processing, so aggregate metrics such as JS error rate remain accurate.


Performance and resource tracking

sendResource

PropertyValue
TypeBoolean
RequiredNo
Defaultfalse

When set to true, reports all static resources loaded on the page at the load event. Use the Session Traces waterfall chart to identify resources causing slow page loads.

<script>
!(function(c,b,d,a){c[a]||(c[a]={});c[a].config={pid:"<your-pid>",sendResource:true};
with(b)with(body)with(insertBefore(createElement("script"),firstChild))setAttribute("crossorigin","",src=d)
})(window,document,"https://retcode.alicdn.com/retcode/bl.js","__bl");
</script>
Note

Set sendResource in config at initialization, not through setConfig. Calling setConfig may execute after the load event completes, at which point static resource data is no longer available.

useFmp

PropertyValue
TypeBoolean
RequiredNo
Defaultfalse

Enables First Meaningful Paint (FMP) data collection for first-screen rendering analysis.

autoSendPerf

PropertyValue
TypeBoolean
RequiredNo
Defaulttrue

Controls whether performance logs are sent automatically.

disableHook

PropertyValue
TypeBoolean
RequiredNo
Defaultfalse

Disables AJAX request listeners. By default, the SDK intercepts AJAX calls to report API success rates.

Important

This parameter only takes effect at initialization.


Tracing and diagnostics

enableLinkTrace

PropertyValue
TypeBoolean
RequiredNo (Web, Alipay mini programs, WeChat mini programs, and DingTalk mini programs only)
Defaultfalse

Enables front-to-back tracing, correlating browser requests with server-side traces. For details, see Use the front-to-back tracing feature to diagnose API errors.

behavior

PropertyValue
TypeBoolean
RequiredNo (Web and mini programs only)
DefaultBrowser: true; Mini program: false

Records the sequence of user actions leading up to errors, aiding troubleshooting.


Application metadata

release

PropertyValue
TypeString
RequiredNo
Defaultundefined

Application version string. Set this to compare monitoring data across different releases.

Important

Set release in config at initialization. Do not use setConfig.

environment

PropertyValue
TypeString
RequiredNo
Defaultprod

Deployment environment label. Valid values:

ValueEnvironment
prodProduction
grayPhased release
preStaging
dailyDaily / Development
localLocal

disabled

PropertyValue
TypeBoolean
RequiredNo
Defaultfalse

When set to true, disables all log reporting.


Custom fields

c1, c2, c3

PropertyValue
TypeString
RequiredNo
DefaultNone

Three custom fields attached to every log entry. Carry business-specific data such as VIP level of a user, A/B test group, or feature flags.

__bl.setConfig({
    c1: "premium",
    c2: "experiment-group-B",
    c3: "feature-darkmode"
});
Note

Values set for c1, c2, and c3 are included in all logs reported from the current page.