All configuration options and APIs for the ARMS RUM Electron SDK. Pass a configuration object to armsRum.init() to initialize the SDK.
SDK configuration (basic)
|
Parameter |
Type |
Description |
Required |
Default |
|
endpoint |
string |
The endpoint URL for data reporting. |
Yes |
- |
|
enable |
boolean |
Enables or disables the SDK. |
No |
true |
|
env |
‘prod’ | ‘gray’ | ‘pre’ | ‘daily’ | ‘local’ | string |
The application's environment. |
No |
- |
|
version |
string |
The application's version. |
No |
- |
The endpoint parameter is required and must be the complete endpoint URL. You can obtain this URL from the ARMS console under Real User Monitoring > application list after creating an application.
import armsRum from '@arms/rum-electron';
armsRum.init({
endpoint: '<YOUR-ENDPOINT>',
enable: true,
env: 'prod',
version: '1.0.0',
});
App configuration
The app object provides extended application metadata for filtering and aggregating data by different dimensions in the ARMS console.
|
Parameter |
Type |
Description |
Required |
Default |
|
app |
object |
Extended application information. |
No |
- |
|
app.name |
string |
The application's name. |
No |
- |
|
app.version |
string |
The application's version. |
No |
- |
|
app.channel |
string |
The release channel. |
No |
- |
|
app.env |
string |
The application's environment. |
No |
- |
|
app.type |
string |
The application type. |
No |
- |
|
app.package |
string |
The package name. |
No |
- |
|
app.framework |
string |
The technology framework. |
No |
- |
armsRum.init({
endpoint: '<YOUR-ENDPOINT>',
app: {
name: 'MyElectronApp',
version: '2.1.0',
channel: 'stable',
env: 'prod',
type: 'electron',
package: 'com.example.my-app',
framework: 'react',
},
});
User configuration
The user object identifies the current user, enabling user-level troubleshooting in the ARMS console.
|
Parameter |
Type |
Description |
Required |
Default |
|
user |
object |
Contains user information. |
No |
- |
|
user.name |
string |
The user's name. |
No |
- |
|
user.tags |
string |
Tags associated with the user. |
No |
- |
armsRum.init({
endpoint: '<YOUR-ENDPOINT>',
user: {
name: 'test-user',
tags: 'vip,enterprise',
},
});
sessionConfig configuration
The sessionConfig option controls session sampling and lifecycle policies.
|
Parameter |
Type |
Description |
Required |
Default |
|
sampleRate |
number |
Session sample rate (0–1). |
No |
1 |
|
maxDuration |
number |
Maximum session duration, in milliseconds. |
No |
- |
|
overtime |
number |
Session inactivity timeout, in milliseconds. |
No |
- |
The sampleRate must be a number between 0 and 1. A value of 1 means 100% of sessions are captured, while 0.1 means 10% are captured. Lowering the sample rate reduces data volume and cost.
armsRum.init({
endpoint: '<YOUR-ENDPOINT>',
sessionConfig: {
sampleRate: 1,
maxDuration: 4 * 60 * 60 * 1000, // Session lasts for a maximum of 4 hours
overtime: 30 * 60 * 1000, // Session times out after 30 minutes of inactivity
},
});
collectors configuration (main process)
The collectors option enables or disables individual main-process collectors. Each collector accepts a boolean or an ICollectorConfig object for fine-grained control.
|
Parameter |
Type |
Description |
Required |
Default |
|
jsError |
boolean | ICollectorConfig |
Captures uncaught exceptions and promise rejections. |
No |
true |
|
consoleError |
boolean | ICollectorConfig |
Intercepts and reports console.error calls. |
No |
true |
|
crash |
boolean | ICollectorConfig |
Captures native crashes. |
No |
true |
|
api |
boolean | ICollectorConfig |
API request monitoring. |
No |
true |
|
application |
boolean | ICollectorConfig |
Application startup metrics. |
No |
true |
The crash collector uses Electron's crashReporter module to capture native crashes in both the main and renderer processes and supports parsing minidump files with WASM.
armsRum.init({
endpoint: '<YOUR-ENDPOINT>',
collectors: {
jsError: true,
consoleError: false,
crash: true,
api: {
enable: true,
// You can further configure filters and other options in ICollectorConfig
},
application: true,
},
});
browserCollectors configuration (renderer process)
This configuration takes effect only when autoInject: true. If autoInject is false, you must configure the renderer process collectors separately within the Browser SDK.
The browserCollectors option configures the collectors automatically injected into the Browser SDK in the renderer process. Each collector accepts a boolean or an ICollectorConfig object.
|
Parameter |
Type |
Description |
Required |
Default |
|
perf |
boolean | ICollectorConfig |
Collects page load performance metrics. |
No |
true |
|
webvitals |
boolean | ICollectorConfig |
Core Web Vitals (LCP, FID, CLS). |
No |
true |
|
exception |
boolean | ICollectorConfig |
Uncaught exceptions and promise rejections. |
No |
true |
|
whiteScreen |
boolean | ICollectorConfig |
White screen detection. |
No |
true |
|
api |
boolean | ICollectorConfig |
Monitors HTTP requests (XHR and Fetch). |
No |
true |
|
staticResource |
boolean | ICollectorConfig |
Static resource load monitoring. |
No |
true |
|
click |
boolean | ICollectorConfig |
User click events. |
No |
true |
|
longTask |
boolean | ICollectorConfig |
Long task detection (>50ms). |
No |
true |
armsRum.init({
endpoint: '<YOUR-ENDPOINT>',
autoInject: true,
browserCollectors: {
perf: true,
webvitals: true,
exception: true,
whiteScreen: true,
api: true,
staticResource: true,
click: false, // Disable click event collection
longTask: true,
},
});
tracing configuration
The tracing option configures distributed tracing. Pass a boolean to enable or disable it, or an ITracingOption object for detailed configuration.
|
Parameter |
Type |
Description |
Required |
Default |
|
enable |
boolean |
Enables or disables distributed tracing. |
No |
false |
|
sample |
number |
Sample rate (0–1). |
No |
- |
|
propagatorTypes |
Array<string> |
Propagation protocol types. Supported values: |
No |
- |
|
allowedUrls |
Array<MatchOption | TraceOption> |
URL patterns for injecting trace headers. |
No |
- |
|
tracestate |
boolean |
Specifies whether to include tracestate. |
No |
false |
|
baggage |
boolean |
Specifies whether to include baggage. |
No |
false |
propagatorTypes supports multiple propagation protocols. Select a protocol based on the tracing system your backend uses. allowedUrls supports string or regular expression matching; trace headers are injected only into matching requests.
armsRum.init({
endpoint: '<YOUR-ENDPOINT>',
tracing: {
enable: true,
sample: 0.5,
propagatorTypes: ['tracecontext', 'b3'],
allowedUrls: [
'https://api.example.com',
/\/api\/v\d+\//,
],
tracestate: true,
baggage: false,
},
});
Other configurations
|
Parameter |
Type |
Description |
Required |
Default |
|
autoInject |
boolean |
Whether to automatically inject the Browser SDK into all |
No |
true |
|
partition |
string |
A custom session partition. |
No |
- |
|
spaMode |
boolean | ‘auto’ | ‘hash’ | ‘history’ |
The routing mode for SPA tracking. |
No |
false |
|
evaluateApi |
Function |
A custom callback to parse API requests. |
No |
- |
|
parseViewName |
Function |
A custom function to parse page view names. |
No |
- |
|
beforeReport |
Function |
A callback to modify or drop data before it is reported. |
No |
- |
|
properties |
Record<string, number | string> |
Global custom properties. |
No |
- |
By default, autoInject is true, meaning the SDK automatically injects the Browser SDK into the renderer process of every BrowserWindow. If you set this to false, you must manually import and initialize the Browser SDK in each renderer process:
// Initialize manually in the renderer process
import armsRum from '@arms/rum-electron/browser';
armsRum.init({ endpoint: '<YOUR-ENDPOINT>' });
armsRum.init({
endpoint: '<YOUR-ENDPOINT>',
autoInject: true,
partition: 'persist:main',
spaMode: 'hash',
parseViewName: (url: string) => {
// Custom logic to parse the page view name
const match = url.match(/\/app\/([^/?#]+)/);
return match ? match[1] : url;
},
beforeReport: (bundle: any) => {
// Return the modified data to continue reporting.
// Return null or undefined to drop the data.
console.log('beforeReport', bundle);
return bundle;
},
properties: {
department: 'engineering',
region: 'cn-hangzhou',
},
});
-
Use the
partitionoption to specify a custom Electron session partition. If yourBrowserWindowuses apartitionconfiguration, you must specify the same value here to ensure the preload script is correctly registered for the corresponding session. -
Possible values for
spaModeare:-
false: Disables SPA route tracking. This is the default behavior, where only full page loads are tracked. -
trueor'auto': Automatically detects the routing mode, prioritizing hash changes over pathname changes. -
'hash': Hash routing mode (for example, React HashRouter). -
'history': History API routing mode (for example, React BrowserRouter).
-
SDK API
armsRum.init(config)
Initializes the SDK. This method must be called before the app.ready event is emitted.
init(config: IElectronConfig): Promise<ArmsRum>
init() must be called before the Electron app.ready event, because the SDK needs to register the custom protocol (rum-event://) before the ready event to support a fallback reporting channel.
import { app } from 'electron';
import armsRum from '@arms/rum-electron';
// Call init before app.ready
armsRum.init({
endpoint: '<YOUR-ENDPOINT>',
env: 'prod',
version: '1.0.0',
});
app.whenReady().then(() => {
// Create BrowserWindow instances, etc.
});
armsRum.getConfig()
Gets the current SDK configuration.
getConfig(): IElectronConfigconst config = armsRum.getConfig();
console.log('Current config:', config.endpoint, config.env);
armsRum.setConfig()
Dynamically updates the SDK configuration. Two signatures are supported.
// Update a single option.
setConfig<T extends keyof IElectronConfig>(key: T, value: IElectronConfig[T]): void
// Update multiple options.
setConfig(config: Partial<IElectronConfig>): void// Update a single option
armsRum.setConfig('enable', false);
armsRum.setConfig('env', 'daily');
// Update multiple options
const config = armsRum.getConfig();
armsRum.setConfig({
...config,
enable: true,
env: 'prod',
version: '2.0.0',
});
armsRum.registerSession(partition)
Registers the RUM preload script for a BrowserWindow that uses a custom partition. Call this after init() and before creating the corresponding BrowserWindow to ensure it takes effect on the initial page load.
registerSession(partition: string): Promise<ArmsRum>
When BrowserWindow uses a custom partition (such as persist:main), call this method to register a preload script for that session. If a default partition is already specified in init() through the partition configuration, you do not need to call this method again.
import armsRum from '@arms/rum-electron';
import { BrowserWindow } from 'electron';
armsRum.init({
endpoint: '<YOUR-ENDPOINT>',
}).then(() => {
// Register the preload script for the custom partition
armsRum.registerSession('persist:main');
});
// Then, create a window that uses this partition
const win = new BrowserWindow({
webPreferences: {
partition: 'persist:main',
// ...
},
});