How do I enrich mobile user experience data via the OneAgent SDK for Mobile?

The OneAgent SDK for Android and iOS can be used to report additional details about the mobile user sessions in your app. The OneAgent SDK for Mobile enables you to create custom user actions, measure web requests, report errors, and tag specific users. This topic explains how to enable these capabilities for both Android and iOS apps.

For iOS, the OneAgent SDK is available automatically once you add the Dynatrace CocoaPod to your project. The OneAgent SDK for Mobile can be used in Swift as well as in Objective-C.

In Android, you can use the OneAgent SDK either with the Dynatrace Gradle plugin or the command line. You must use the OneAgent SDK when you want to manually instrument your Android app.

Note: For Android, you can view all technical information in the JavaDoc for OneAgent SDK.

Start OneAgent

Create custom user actions

You can define your own custom user actions. First, you have to create them. Then you can enrich them with additional information and finally you have to close them. OneAgent discards all action-related monitoring data, when the action isn't closed.

With a user action you can perform the following monitoring operations:

  • report an event
  • report a value
  • report an error
  • attach a web request to the user action
  • create a child action

Child actions

Child actions are similar to parent actions. When the parent action is closed, OneAgent automatically closes all nested/child actions of the parent action.

User action sample

The following code snippet shows a sample instrumentation of the fictional method search, which makes a web request to an instrumented server and parses the received result.

Report event

The report event feature allows you to report the time point of a specific event. The event must be part of a user action.

Report value

The report value feature allows you to report your own metrics. These metrics must be part of a user action.

Report errors

The reporting error feature is different from the reporting value feature in that it is specifically identified as an error type of event.

You can also report errors as stand-alone error event.

Measure web requests

To monitor a web request the Dynatrace tag has to be placed on the HTTP request. The tag is needed to correlate the server-side monitoring data to the corresponding mobile web request. Additionally, the timing values from the mobile side have to be measured.

Tag specific users

Dynatrace enables you to tag each user of your mobile apps with a unique user name. This enables you to search and filter specific user sessions and analyze individual user behavior over time. The steps below explain how to manually tag an individual user via the Dynatrace API.

Configure data privacy (user opt-in mode)

As of version 7.1.4, the OneAgent SDK enables you to dynamically adjust data-privacy settings so that you can build your apps in compliance with GDPR data-privacy regulations. To activate this feature, enable the DTXUserOptIn flag.

The privacy API methods allow you to dynamically activate/deactivate crash reporting and to change the data-collection level based on the individual preferences of your end users. Each end user can select from three data-privacy levels:

  • off: OneAgent won't capture any monitoring data.
  • performance: OneAgent will only capture anonymous performance data. Monitoring data that can be used to identify individual users (for example, user tags or custom values), will not be captured.
  • user behavior: OneAgent will capture both performance and user data. In this mode OneAgent recognizes and reports on users who re-visit in future sessions.

When OneAgent starts for the first time, OneAgent deactivates crash reporting and sets the data-collection level to off. You should change the privacy settings (based on each user's individual preference), when your app starts for the first time. OneAgent does not provide a privacy settings dialog or any similar UI component. You must integrate a privacy dialog into your app. We recommend that you display the privacy dialog before your app is displayed and then apply the user's privacy preference. You should also enable your users to change their privacy settings in the future.

OneAgent persists the privacy setting and automatically applies it when the app is restarted. Each time the user changes the data-collection level, a new session with the new privacy settings will be generated by OneAgent. Do not wrap this API method with a user action. Otherwise, OneAgent can't attach the user action to the correct session.

Create custom HTTP headers