New RUM APIs

  • Reference
  • 10-min read
  • Published Aug 07, 2025

Report Events

Dynatrace.sendEvent

Sends a user event with the given fields to the Dynatrace Platform.

The provided fields must be a valid JSON object. Nested objects or arrays are not allowed.

The event will be filled with the provided fields and enriched with basic context information such as user session details and frontend metadata. After auto-enrichment, the event can be modified using an EventModifier. At this stage, it's also possible to use the provided event context objects for further manual enrichment of the event.

  • JavaScript

    sendEvent(fields: JSONObject, eventContext?: unknown): void
  • Android

    public static void sendEvent(JSONObject fields, Object[] eventContext)
  • iOS

    For Swift:

    public static sendEvent(fields: [String: Any]?, eventContext: Any?)

    For Objective-C:

    + (void)sendEventWithFields:(NSDictionary<NSString*,id>* _Nullable)fields eventContext:(id _Nullable)eventContext
  • React Native

    sendEvent(properties: JSONObject, context?: any): void
  • Flutter

    public void sendEvent(Map<String, dynamic> json, dynamic context)

Dynatrace.sendSessionPropertyEvent

Sends a session properties event.

With sendSessionPropertyEvent, you can report properties that apply to all events in the current session. Any custom properties must be added in the session_properties.* namespace, otherwise they will be dropped. Even though you can send multiple sessions properties at once, session aggregation will take only one of the values (first or last) if you report the same value multiple times.

Fields must contain only alphanumeric characters, underscores and dots. Each dot must be followed by a lowercase character. Each underscore must followed by a lowercase character or number.

Properties require a server-side configuration in the settings UI. Otherwise, they'll be dropped during ingest.

  • JavaScript

    sendSessionPropertyEvent(fields: JSONObject): void
  • Android

    public static void sendSessionPropertyEvent(JSONObject properties)
  • iOS

    For Swift:

    public static sendSessionPropertyEvent(_ properties: [String: Any]?)

    For Objective-C:

    + (void)sendSessionPropertyEvent:(NSDictionary<NSString*,id>* _Nullable)properties;
  • React Native

    sendSessionPropertyEvent(properties: JSONObject): void
  • Flutter

    public void sendSessionPropertiesEvent(Map<String, dynamic> json)

Report Errors

Dynatrace.sendExceptionEvent

Sends exception event with a Throwable and EventFieldsProvider.

The EventFieldsProvider is a functional interface that returns a JSONObject containing custom fields that should be added to the event.

If a given Throwable is null, no event is reported to the system.

  • Android

    public static void sendExceptionEvent(Throwable throwable, EventFieldsProvider fieldsProvider)
  • iOS

    For Swift:

    public static sendExceptionEvent(with exception: NSException, fields: [String: Any]?)

    For Objective-C:

    + (void)sendExceptionEventWithException:(NSException* _Nonnull)exception fields:(NSDictionary<NSString*,id>* _Nullable)fields;
  • React Native

    sendExceptionEvent(error: Error, fields?: JSONObject): void
  • Flutter

    public void sendExceptionEvent(dynamic throwable,
    {StackTrace? stacktrace, Map<String, dynamic> fields})

Modifying Events

Dynatrace.addEventModifier

Adds an EventModifier that enriches future events by applying the modifier function to them. When adding a field, you must use the event property namespace.

Certain reserved fields and namespaces can’t be modified (added, removed, or overridden) in any way, while others are open for modification.

  • JavaScript

    addEventModifier(
    eventModifier: (
    jsonEvent: Readonly<JSONEvent>,
    eventContext?: unknown,
    ) => JSONEvent,
    ): Unsubscriber
    // Unsubscribe
    Unsubscriber: () => void
  • Android

    public static boolean addEventModifier(EventModifier eventModifier)
  • iOS

    For Swift:

    public static addEventModifier(eventModifier: (DTXModifyableEvent, Any?) -> DTXModifyableEvent?) -> DTXModifyEventSubscriber

    For Objective-C:

    + (DTXModifyEventSubscriber* _Nonnull)addEventModifier:(DTXModifyableEvent* _Nullable (^ _Nonnull)(DTXModifyableEvent* _Nonnull event, id _Nullable eventContext))eventModifier;
  • React Native

    addEventModifier(eventModifier: IEventModifier): IEventModifier
  • Flutter

    void addEventModifier(EventModifier eventModifier)

Dynatrace.removeEventModifier

Removes a previously added EventModifier.

On JavaScript, this is done via the unsubscriber function.

  • Android

    public static boolean removeEventModifier(EventModifier eventModifier)
  • iOS

    For Swift:

    public static removeEventModifier(_ subscriber: DTXModifyEventSubscriber)

    For Objective-C:

    + (void)removeEventModifier:(DTXModifyEventSubscriber* _Nonnull)subscriber;
  • React Native

    removeEventModifier(eventModifier: IEventModifier): boolean
  • Flutter

    void removeEventModifier(EventModifier eventModifier)

EventModifier

Android

EventModifier is a functional interface that provides a modifier function that is used to enrich a given event as JSONObject. It receives context objects depending on the type of the event or null if no context is available. The returned event can be a modified version of the event JSON or null if the event should be dropped.

JSONObject modifyEvent(JSONObject event, Object[] eventContext)

It receives context objects depending on the type of the event or null if no context is available. The returned event can be a modified version of the event JSON or null if the event should be dropped.

The following context parameters are to be expected on Android:

Event

Context parameters

Description

OkHttp request monitoring (success)

[Request, Response, null]

Request and Response types from OkHttp framework

OkHttp request monitoring (failed)

[Request, null, Throwable]

Request type from OkHttp framework

HttpURLConnection request monitoring

null

No context provided because information can't be accessed afterwards

Dynatrace.sendEvent(JSONObject fields, Object[] eventContext)

eventContext

Value provided by parameter

Manual web request monitoring, identify user, (manual) error reporting

null

No context defined

Crash reporting

[Throwable, Thread]

Provides the Thread where the crash occurs

Cross-platform events

null

There is no data type conversion between different languages, so the context object is not defined

iOS

The eventModifier provides a closure that can be used to enrich an event as [String: Any]. Additionally, it may receive a context that can be used to additionally enrich the event.

eventModifier: (DTXModifyableEvent, Any?) -> DTXModifyableEvent?

It receives context objects depending on the type of the event or null if no context is available. The returned event can be a modified version of the event JSON or null if the event should be dropped.

The following context parameters are to be expected on iOS:

Event

Context parameters

Description

Web request monitoring (success)

NSURLResponse or NSURLRequest

Request and Response types from the system API

Web request monitoring (failed)

NSError or NSURLResponse or NSURLRequest

Request type from the system API

Dynatrace.sendEvent(JSONObject fields, Object[] eventContext)

eventContext

Value provided by parameter

Manual web request monitoring, identify user, (manual) error reporting

null

No context defined

Crash reporting

null

No context available on iOS

Cross-platform events

null

There is no data type conversion between different languages, so the context object is not defined

React Native

EventModifier is a functional interface that provides a modifier function that is used to enrich a given event as JSONObject. It receives context objects depending on the type of the event or null if no context is available. The returned event can be a modified version of the event JSON or null if the event should be dropped.

modifyEvent(event: JSONObject | null, context?: any): JSONObject | null

It receives context objects depending on the type of the event or null if no context is available. The returned event can be a modified version of the event JSON or null if the event should be dropped.

The following context parameters are to be expected on Android:

Event

Context parameters

Description

Dynatrace.sendEvent(properties: JSONObject, context?: any)

context

Value provided by parameter

Flutter

EventModifier is a functional interface that provides a modifier function that is used to enrich a given event as JSONObject. It receives context objects depending on the type of the event or null if no context is available. The returned event can be a modified version of the event JSON or null if the event should be dropped.

Map<String, dynamic>? modifyEvent(Map<String, dynamic>? event, dynamic context)

It receives context objects depending on the type of the event or null if no context is available. The returned event can be a modified version of the event JSON or null if the event should be dropped.

The following context parameters are to be expected on Android:

Event

Context parameters

Description

Dynatrace.sendEvent(Map<String, dynamic> json, dynamic context)

context

Value provided by parameter

View Tracking for mobile

A view refers to a view/screen/window which is presented to the user at any time. The view-context can be used to analyze a users' flow from one view to another or how much time was spent on a certain view. It’s also useful to contextualize errors/crashes and other performance data, associate it with team ownership and more. That’s why Dynatrace offers this API to manually add the view context to captured user events.

Dynatrace plans to automatically detect views in one of the upcoming releases based on major mobile project setups.

Dynatrace.startView

Starts monitoring of a view.

On every opening of a view the startView method can be called to highlight the current view context of the user. All events captured thereafter can be evaluated in context of that view. When another view was started previously, then this method will stop view monitoring for the previous view and start it for the current view.

  • Android

    public static void startView(String name)
  • iOS

    For Swift:

    public static startView(name: String)

    For Objective-C:

    + (void)startViewWithName:(NSString* _Nonnull)name

Dynatrace.stopView

Stops monitoring of the view that was previously started via startView(String). It will remove the view context and all events captured afterwards will be reported without view information.

  • Android

    public static void stopView()
  • iOS

    For Swift:

    public static stopView()

    For Objective-C:

    + (void)stopView;

ANR Reporting for mobile

With the New RUM Experience, Dynatrace automatically captures “Application Not Responding”(ANR) errors. ANRs are critical to monitor as they cause frustration to the user. The main problem is that the app's main thread, which is responsible for updating the UI, can't process user input events or draw, forcing the app to be closed.

These events are sent only if the mobile app is restarted within a timeframe of 10 minutes by the user.

By default, this feature is turned on. To turn it off use the following configuration options:

Android

OneAgent only reports ANR errors on devices with Android 11 or higher. On older Android versions, the ANR Error event is not available.

Using the ConfigurationBuilder when starting the agent manually:

public ConfigurationBuilder withAnrReporting(boolean enabled)

Using the DSL:

dynatrace {
configurations {
sampleConfig {
anrReporting false
...
}
}
}

iOS

Using the dictionary configuration when starting the agent manually:

Dynatrace.startup(withConfig: ["DTXANRReportingEnabled": false,])

Using the plist file:

<key>DTXANRReportingEnabled</key>
<false/>

React Native

Using the dynatrace.config.js file:

module.exports = {
react: {
...
},
android: {
// Those configs are copied 1:1
config: `
dynatrace {
configurations {
defaultConfig {
...
anrReporting false
}
}
}
`
},
ios: {
// Those configs are copied 1:1
config: `
...
<key>DTXANRReportingEnabled</key>
<false/>
`
}

Flutter

Using the dynatrace.config.yaml file:

android:
config:
"dynatrace {
configurations {
defaultConfig {
...
anrReporting false
}
}
}"
ios:
config:
"...
<key>DTXANRReportingEnabled</key>
<false/>"

Native Crash Reporting for Android

Native crashes are crashes that originate in C/C++ code added via NDK. The official Android documentation lists examples and how to diagnose them.

With the New RUM Experience, Dynatrace automatically captures native crashes. Events are sent only if the mobile app is restarted within a timeframe of 10 minutes by the end user.

By default, this feature is turned on. To turn it off use the following configuration options:

  • On older Android versions, the ANR Error event is not available. OneAgent only reports ANR errors on devices with Android 11 or higher. For Android 11 or higher, using the ConfigurationBuilder when starting the agent manually:

    public ConfigurationBuilder withNativeCrashReporting(boolean enabled)
  • Using the DSL:

    dynatrace {
    configurations {
    sampleConfig {
    nativeCrashReporting false
    ...
    }
    }
    }

Enable new RUM capturing on Grail as default for mobile

Once new RUM is enabled for a mobile app monitored by Dynatrace, data is stored on Grail. On each end user device on which the mobile app is installed, the new configuration will be applied only after the first session is finished. Upon the very first app start OneAgent will initiate non-Grail communication and upgrade to Grail only if ordered by server configuration, and only on the next app start.

Hence, the first session will be captured only on RUM Classic, unless the following build-time configuration is additionally applied:

Android

To avoid that and to start with Grail right away, the startupWithGrailEnabled flag must be set to true.

This can be done using the ConfigurationBuilder:

public ConfigurationBuilder withStartupWithGrailEnabled(boolean enabled)

Using the DSL:

dynatrace {
configurations {
sampleConfig {
agentBehavior{
startupWithGrailEnabled true
}
}
}
}

iOS

To avoid that and to start with Grail right away, the DTXStartupWithGrailEnabled flag must be set to true.

This can be done in the .plist file:

<key>DTXStartupWithGrailEnabled</key>
<true/>

If the Dynatrace.startup(withConfig:) method is used, it needs to be added there.

Dynatrace.startup(withConfig: ["DTXStartupWithGrailEnabled": true,])

Add custom OkHttp client to Android

OneAgent for Android now allows you to specify a custom OkHttp client to use for network requests, that are used to transmit RUM data to Grail.

This can be set using manual startup with the ConfigurationBuilder:

public ConfigurationBuilder withOkHttpClient(okhttp3.OkHttpClient httpClient)

Likewise, an OkHttp factory can be provided to achieve the same result:

public ConfigurationBuilder withOkHttpFactory(okhttp3.Call.Factory httpFactory)

IdentifyUser

Use to identify individual users across different browsers, devices, and user sessions.

Mobile only

Sessions split due to idle or duration timeout are re-tagged automatically.

When OneAgent ends a tagged session because the session duration has reached its set limit or due to the user's inactivity, the subsequent session is re-tagged automatically. You don't need to provide the user identification information again.

However, note that OneAgent does not re-tag the subsequent session in the following cases:

  • When the user or the mobile operating system closes or force stops the app
  • When OneAgent ends the current user session and generates a new session after the privacy settings have been changed
  • JavaScript

    identifyUser(value: string): void
  • Android

    void identifyUser(String userId)
  • iOS

    For Swift:

    public static identifyUser(_ userId: String?) -> DTX_StatusCode

    For Objective-C:

    + (DTX_StatusCode)identifyUser:(NSString* _Nullable)userId;
  • React Native

    identifyUser(String userId): void
  • Flutter

    void identifyUser(String userId)

Limitations

  • Some advanced features available in RUM Classic are not yet supported in the new APIs.
  • The new APIs require updated OneAgent versions for both mobile and web applications.
  • Not all SDK methods from RUM Classic are available in the new APIs.
  • Custom session properties require server-side configuration; otherwise, they are dropped.

Mobile-specific limitations

  • Initial session after enabling new RUM is still captured using RUM Classic unless startup flags are set. See the Mobile only section for more information.
  • ANR and crash events are reported after the app is restarted.