All Products
Search
Document Center

Application Real-Time Monitoring Service:SDK configuration reference

Last Updated:Dec 11, 2025

ARMS Real User Monitoring (RUM) provides various SDK configuration items to meet your specific needs. This topic describes common SDK configurations for Flutter applications.

Startup configuration

The start method is the primary method for the AlibabaCloudRUM Flutter plugin. It initializes the monitoring system and begins monitoring the application.

Future<void> start(Widget topLevelWidget, {Function()? beforeRunApp}) async

Parameter

Description

Restrictions

Result if failed

topLevelWidget

The root widget of the Flutter application.

Not null.

The API call fails.

beforeRunApp

A callback function that is invoked before runApp() is executed. Use this function to perform initialization operations.

Optional. If you set this parameter, you must call WidgetsFlutterBinding.ensureInitialized() in the callback function.

-

Example:

AlibabaCloudRUM().start(
  // The root widget
  MyApp(),
  beforeRunApp: () async => {
    // You must call the following method before this function ends.
    WidgetsFlutterBinding.ensureInitialized(),
    // Other business logic
    // ...
    },
);

Print error messages

By default, when the SDK catches a Flutter exception, it calls FlutterError.dumpErrorToConsole to print the error message to the console. You can use the setDumpError method to enable or disable this feature.

void setDumpError(bool enable)

Parameter

Description

Restrictions

Result if failed

enable

Specifies whether to print error messages to the console.

Valid values:

  • true

  • false

-

Example:

// Disable printing error messages to the console.
AlibabaCloudRUM().setDumpError(false);  

Flutter error callback

Because error monitoring in Flutter is not propagated through layers, the application's original error listener stops functioning after the AlibabaCloudRUM plugin starts monitoring synchronous and asynchronous interfaces. To address this issue, the Flutter plugin provides a unified error callback interface.

void onRUMErrorCallback(bool callback(Object? error, StackTrace? stack, bool isAsync))

Callback function input parameters:

Parameter

Type

Description

error

Object

The cause of the error.

stack

StackTrace

Optional. The error stack.

isAsync

Bool

Optional. Specifies whether the error is asynchronous.

Callback function return value:

Type

Description

Bool

Specifies whether to continue processing the error.

true: The SDK continues to process and report the error.

false: The SDK stops processing the error.

Example:

  AlibabaCloudRUM().onRUMErrorCallback((error, stack, isAsync) {
    // Process the error event.
    // ...
    // logger.d('debuggg error: $error, stack: $stack');

    // Return true to let the SDK report the error.
    return true;
  });

Read device ID

By default, the SDK generates a `deviceId`. You can use the getDeviceId interface to retrieve this device ID.

Future<String?> getDeviceId() async

Example:

AlibabaCloudRUM().getDeviceId().then(((value) => {print("deviceId: ${value}")}));

Custom username

The SDK lets you set user-related information. This helps you associate data analytics with actual users.

Future<void> setUserName(String userName)

Parameter

Description

Restrictions

Result if failed

userName

The username identifier.

The string can be null or empty.

The string can be up to 256 characters long. It must not contain special characters. Only digits, letters, colons (:), spaces, forward slashes (/), underscores (_), hyphens (-), periods (.), and at signs (@) are allowed.

The API call fails. The setting for this call is invalid.

Example:

AlibabaCloudRUM().setUserName("xxxxx");

Custom user extension information

The SDK lets you set user-related information. This helps you associate data analytics with actual users.

  • You can set user extension information in overwrite mode. Calling this method overwrites any previously set user extension information.

    Future<void> setUserExtraInfo(Map<String, dynamic> extraInfo) async

    Parameter

    Description

    Restrictions

    Result if failed

    extraInfo

    The user extension information.

    The map can be null or empty. After conversion to JSON, the length must be within 7,000 characters. Otherwise, the API call fails.

    The API call fails. The setting for this call is invalid.

    Example:

    AlibabaCloudRUM().setUserExtraInfo({"shopId": "xxxxx", "shopName": "yyyyy"});
  • You can append user extension information.

    Future<void> addUserExtraInfo(Map<String, dynamic> extraInfo) async

    Parameter

    Description

    Restrictions

    Result if failed

    extraInfo

    The user extension information.

    The map can be null or empty. After conversion to JSON, the length must be within 7,000 characters. Otherwise, the API call fails.

    The API call fails. The setting for this call is invalid.

    Example:

    AlibabaCloudRUM().addUserExtraInfo({"userId": "11111111"});

Custom global extension information

The SDK lets you set global extension information to associate data analytics with specific scenarios.

  • This method sets the global extension information by overwriting any previously set global extension information.

    Future<void> setExtraInfo(Map<String, dynamic> extraInfo) async

    Parameter

    Description

    Restrictions

    Result if failed

    extraInfo

    The global extension information.

    The map can be null or empty. After conversion to JSON, the length must be within 7,000 characters. Otherwise, the API call fails.

    The API call fails. The setting for this call is invalid.

    Example:

    AlibabaCloudRUM().setExtraInfo({"global_key": "global_value", "global_key2": "global_value2"});
  • You can append global extension information.

    Future<void> addExtraInfo(Map<String, dynamic> extraInfo) async

    Parameter

    Description

    Restrictions

    Result if failed

    extraInfo

    The global extension information.

    The map can be null or empty. After conversion to JSON, the length must be within 7,000 characters. Otherwise, the API call fails.

    The API call fails. The setting for this call is invalid.

    Example:

    AlibabaCloudRUM().addExtraInfo({"global_userId": "2222222222"});

Custom Exception

You can call the custom exception interface and pass the required parameters to collect data on custom exceptions.

Future<void> setCustomException(String exceptionType, String causedBy, String errorDump)

Parameter

Description

Restrictions

Result if failed

exceptionType

The exception type. (Required)

The string must be 1 to 256 characters long.

The API call fails.

causedBy

The cause of the exception. (Required)

The string can be up to 512 characters long. If the string is longer, it is truncated.

Not applicable.

errorDump

The exception information. (Optional)

The string can be null or empty.

The string can be up to 10,000 characters long. If the string is longer, it is truncated.

Not applicable.

Example:

AlibabaCloudRUM().setCustomException("custom exception type", 
    "caused by customer", 
    "Custom error dump");

Custom events

The SDK supports reporting custom events. You can call the relevant interface and pass the required parameters to collect data on custom events.

Future<void> setCustomEvent(String name, {String? group, String? snapshots, double? value, Map<String, String>? attributes})

Parameter

Description

Restrictions

Result if failed

name

The event name. (Required)

The string can be up to 512 characters long. If the string is longer, it is truncated.

The API call fails.

group

The event group. (Optional)

The string can be null or empty.

The string can be up to 256 characters long. If the string is longer, it is truncated.

Not applicable.

snapshots

The event snapshot. (Optional)

The string can be null or empty.

The string can be up to 7,000 characters long. If the string is longer, it is truncated.

Not applicable.

value

The event value. (Optional)

Type: Double.

Not applicable.

attributes

Key-value information. (Optional)

After conversion to a JSON string, the length must not exceed 7,000 characters.

Not applicable.

Example:

AlibabaCloudRUM().setCustomEvent("search_shop",
    group: "shop",
    snapshots: 'Search: ${search.toString()}',
    value: 1,
    attributes: {"search": "xxxxx"});

Custom logs

The SDK supports reporting custom log information. You can call the relevant interface and pass the required parameters to collect custom log data.

Future<void> setCustomLog(String logInfo, {String? name, String? snapshots, String? level, Map<String, String>? attributes})

Parameter

Description

Restrictions

Result if failed

logInfo

The log information. (Required)

The string must be 1 to 10,000 characters long. If the string is longer, it is truncated.

The API call fails.

name

The log name. (Optional)

The string must be 1 to 256 characters long.

Not applicable.

snapshots

The log snapshot. (Optional)

The string can be null or empty.

The string can be up to 7,000 characters long. If the string is longer, it is truncated.

Not applicable.

level

The log level. (Optional)

The string must be 1 to 256 characters long. The default value is INFO.

Not applicable.

attributes

Additional log information. (Optional)

The map can be null or empty.

After conversion to a JSON string, its length is counted towards the same character limit as logInfo. If the combined length exceeds the limit, the API call fails.

Not applicable.

Example:

AlibabaCloudRUM().setCustomLog("2024-08-20 14:00:05 Print shopinfo info.",
    name: "shop",
    snapshots: 'Shop: ${shop.toString()}',
    level: "DEBUG",
    attributes: {"shopId": "xxxxx", "shopName": "yyyyy"});