All Products
Search
Document Center

Cloud Monitor:Reporting RUM events with the Sentry-compatible SDK

Last Updated:Apr 28, 2026

The Sentry-compatible SDK for Real User Monitoring (RUM) supports reporting the following types of data:

  • Auto-instrumentation — Pageloads (including Web Vitals metrics), resource requests, long tasks, and actions.

  • Custom event — Track business workflows and key operations.

  • Custom log — Record business logs and key milestone information.

  • Exception — Capture and report JavaScript exceptions.

  • User — Associate events with user information for user-centric analysis and search.

1. SDK initialization configuration

To get the most comprehensive RUM data, enable the following options when you call Sentry.init.

Native JavaScript project (browser)

import * as Sentry from "@sentry/browser";

Sentry.init({
  dsn: "https://key@<YOUR-ENDPOINT>/0",
  
  // ─── Basic Configuration ───
  release: "my-web-app@1.2.0",
  environment: "production",

  // ─── Performance Tracing ───
  tracesSampleRate: 1.0, // For production, adjust as needed, for example to 0.2

  integrations:[
    // Auto-instrumentation for pageload, navigation, resource, Web Vitals, etc.
    Sentry.browserTracingIntegration(),
  ],
});

Android project (Kotlin)

import android.app.Application
import io.sentry.android.core.SentryAndroid
import io.sentry.android.core.SentryAndroidOptions

class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()

        SentryAndroid.init(this) { options ->
            options.dsn = "https://key@<YOUR-ENDPOINT>/0"
            
            // ─── Basic Configuration ───
            options.release = "my-android-app@1.2.0"
            options.environment = "production"

            // ─── Performance Tracing ───
            options.tracesSampleRate = 1.0
        }
    }
}
Additional Note for Android: For network requests (resource events), if you are using OkHttp or Retrofit, you must add SentryOkHttpInterceptor() when building your OkHttpClient. Otherwise, the SDK cannot auto-instrument API request latency.

iOS project (Swift)

import UIKit
import Sentry

@main
class AppDelegate: UIResponder, UIApplicationDelegate {

    func application(
        _ application: UIApplication,
        didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
    ) -> Bool {
        
        SentrySDK.start { options in
            options.dsn = "https://key@<YOUR-ENDPOINT>/0"
            
            // ─── Basic Configuration ───
            options.environment = "production"
            options.releaseName = "my-ios-app@1.2.0"
            
            // ─── Performance Tracing ───
            options.tracesSampleRate = 1.0
        }

        return true
    }
}

Key parameters

Parameter

Recommended value

Corresponding RUM data

Description

tracesSampleRate

1.0 (dev/test)

0.1 to 1.0 (production)

View, Resource, long task, action, custom event

The sampling rate for performance tracing. Must be set to a value > 0 to collect performance data.

browserTracingIntegration

Enabled

View (pageload/navigation), Resource, long task, Web Vitals

Automatically creates transactions for pageloads and navigations, and collects metrics such as FCP, LCP, FID, CLS, and INP.

release

Version string

All events

The application version, used for version-based analysis and source map association.

environment

"production", etc.

All events

The environment identifier, used to distinguish between production and test environments.

Auto-instrumented RUM data

With the preceding configuration enabled, the following data is automatically collected with no extra code:

RUM event type

Data source

Description

View

pageload or navigation transaction

Pageloads and navigations, including Web Vitals (FP, FCP, LCP, FID, CLS, INP, TTFB).

Resource

http.client or resource.* span within a transaction

XHR/Fetch requests and loading of static assets (JS, CSS, images, etc.).

Long task

ui.task or ui.long-animation-frame span,

or Vue/React component renders (≥ 50ms)

Tasks that block the main thread.

Action

ui.interaction.* span,

or ui.action.* / ui.click breadcrumb

User interactions such as clicks, inputs, and scrolls, including INP.

Application

app.lifecycle breadcrumb

Application lifecycle events, such as foreground and background transitions (for mobile apps).

Unnecessary parameters

Parameter

Description

replaysSessionSampleRate / replayIntegration

This option is not needed, as Session Replay data is not stored.

profilesSampleRate / browserProfilingIntegration

This option is not needed, as profiling data is not stored.

attachStacktrace

This only affects whether captureMessage includes a stack trace and is not required.

2. Custom events

Use custom events to track the duration and status of business workflows or key operations, such as a payment process, form submission, or search request.

Usage

Report custom events using Sentry.startSpan. The op parameter must be rum.custom.

import * as Sentry from "@sentry/vue"; // or @sentry/react, @sentry/browser, etc.

// Basic usage
Sentry.startSpan(
  {
    op: "rum.custom",
    name: "payment flow",
    attributes: {
      "custom.group": "payment",
      "custom.value": "99.9",
    },
  },
  () => {
    // Business logic...
  }
);

// With custom business attributes
Sentry.startSpan(
  {
    op: "rum.custom",
    name: "product search",
    attributes: {
      "custom.group": "search",
      "custom.value": "42",
      // The following attributes are automatically stored in `properties` and can be queried in the console.
      "keyword": "bluetooth headset",
      "result_count": 42,
      "search_type": "full_text",
    },
  },
  () => {
    // Search logic...
  }
);

Asynchronous scenarios

If your business logic is asynchronous, return a Promise from the callback function. The SDK automatically waits for the promise to resolve before calculating the duration.

await Sentry.startSpan(
  {
    op: "rum.custom",
    name: "upload file",
    attributes: {
      "custom.group": "upload",
      "file_type": "image",
      "file_size": 1024000,
    },
  },
  async () => {
    await uploadFile(file);
  }
);

Parameters

Parameter

Required

Stored field

Description

op

Yes

Must be "rum.custom". Otherwise, the span is not recognized as a custom event.

name

Yes

custom.name

The event name, used for display and search in the console.

attributes["custom.group"]

Optional

custom.group

The event group, used for aggregated statistics (e.g., "payment", "search").

attributes["custom.value"]

Optional

custom.value

The event value, used for numerical analysis (e.g., amount, quantity).

Other fields in attributes

Optional

properties

Custom business properties. Supports string, number, and boolean values.

Automatically calculated

custom.duration

The execution time of the callback function in milliseconds, collected automatically by the SDK.

3. Custom logs

Use custom logs to record business logs, key milestone information, or warning messages.

Usage

Report custom logs using Sentry.captureMessage:

import * as Sentry from "@sentry/vue";

// Basic usage (default level is "info")
Sentry.captureMessage("User completed the onboarding process");

// Specify a log level
Sentry.captureMessage("Payment retries exceeded the maximum limit", "warning");

Parameters

Parameter

Required

Stored field

Description

message (first parameter)

Yes

custom.log_content / custom.name

The log content.

level (second parameter)

Optional

custom.log_level

The log level. Supported values are "debug", "info", "warning", "error", and "fatal". The default is "info".

4. Exceptions

Use this method to capture runtime exceptions, business logic errors, or rejected Promises. This data is stored as a RUM exception event, which includes the error type, message, and a full stack trace. These events are also automatically processed for error grouping.

Usage

Report exceptions using Sentry.captureException:

import * as Sentry from "@sentry/vue";

// Basic usage — capture an Error object
try {
  riskyOperation();
} catch (err) {
  Sentry.captureException(err);
}

// Manually construct and report an Error
Sentry.captureException(new Error("Payment API returned an abnormal status code"));

// Capture a Promise rejection
fetchOrder(orderId).catch((err) => {
  Sentry.captureException(err);
});

Data storage

Events reported with captureException generate the following RUM data:

Storage model

Description

ExceptionModel

The main error event, including the error type (exception.type), message (exception.message), and stack trace (exception.stack).

NodeStore

Stores the complete raw Sentry Event JSON, used for display on the console's details page.

GroupMessage

Error grouping information, used to aggregate errors in the error list.

Important notes

  • Always pass an Error object: captureException(new Error("msg")) is better than captureException("msg") because the former includes a full stack trace.

  • Difference from captureMessage: captureException creates an exception event, which includes a stack trace and is eligible for error grouping. In contrast, captureMessage creates a lightweight custom log.

  • Do not use captureMessage to report errors: For error scenarios, use captureException to access full error analysis capabilities in the console.

5. User identity configuration

After you set user information with Sentry.setUser, all subsequent events (custom events, custom logs, exceptions, etc.) automatically include the user's identity. This allows you to search for and analyze data by user in the console.

Usage

import * as Sentry from "@sentry/vue";

// Set user information after login
Sentry.setUser({
  id: "user-12345",
  username: "Zhang San",
  data: {
    vip_level: "gold",
    department: "engineering",
  },
});

// Clear user information after logout
Sentry.setUser(null);

Fields

Sentry user field

Stored field

Description

id

userId

A unique identifier for the user. Recommended, as it enables searching by user in the console.

username

userName

The username, used for display in the console.

data

userTags (JSON serialized)

Custom user attributes (such as membership level or department), used for multi-dimensional analysis.

email

This field is not currently stored. Do not rely on it.

ip_address

This is collected automatically from server-side HTTP request headers; do not set it manually.

Important notes

  • Call setUser as early as possible: Set user information immediately after a user logs in to ensure all subsequent events are associated with that user.

  • The id field is the most important: User-based searches in the console rely on this field. Use the user ID from your business system.

  • The data field is ideal for business attributes: Attributes like membership level, user role, or organization are stored as a JSON object in the userTags field.

  • Clear user information on logout: Call Sentry.setUser(null) to prevent events from being incorrectly associated with a logged-out user.

6. Selection guide

Scenario

Recommended method

Stored as

Reason

Track the duration of an operation

startSpan

Custom event

Automatically collects duration, which is ideal for performance analysis.

Record key milestones in a business workflow

startSpan

Custom event

Can include a group, value, and custom properties, which is ideal for aggregated analysis.

Record a log message

captureMessage

Custom log

Lightweight and includes a log level, which is ideal for logging scenarios.

Record a non-critical warning or tip

captureMessage

Custom log

Semantically clear and distinct from captureException.

Capture a JS exception or runtime error

captureException

Exception

Provides a stack trace, error grouping, and trend analysis.

Capture a Promise rejection

captureException

Exception

Same as above; preserves the full call stack.

Capture a business logic error (e.g., a 500 API response)

captureException

Exception

Provides a stack trace for debugging and enables error grouping.

7. Important notes

  1. The op parameter must be rum.custom. Spans with other op values are not converted into custom events.

  2. name should be concise and aggregatable: Avoid writing variables, such as user IDs or order numbers, directly into name. They should be placed in attributes.

  3. Value type of attributes: The value can be a string, number, or boolean. Objects and arrays are not supported.

  4. Use captureException for errors, not captureMessage. Reporting an error requires Sentry.captureException(new Error("...")) to create a full exception event with a stack trace.

  5. Always pass an Error object to captureException: captureException(new Error("msg")) is better than captureException("msg"). The former includes a complete stack trace.