Interface UserAction


public interface UserAction
A user action created via the Dynatrace API.

A user action represents a significant operation within the mobile frontend. It groups the requests, navigations, and errors that result from a single user interaction, giving you a complete picture of what happened and how long it took. For example, a user action starts when a user presses a button and ends when the resulting network call completes and a new screen is displayed.

When creating a user action you can specify a custom name, attach event properties, and complete it programmatically using complete().

Example (Kotlin)

 val userAction = Dynatrace.createUserAction(
     UserActionConfiguration("Place Order")
 )
 userAction.addEventProperty("event_properties.cart_size", 3.0)
 userAction.addEventProperty("event_properties.currency", "USD")

 // ... perform the workflow ...

 userAction.addEventProperty("event_properties.succeeded", true)
 userAction.complete()
 

After a user action is completed, subsequent method calls have no effect and do not throw exceptions.

Since:
8.343
See Also:
  • Method Details

    • getCustomName

      String getCustomName()
      Returns the user action name supplied via UserActionConfiguration.
      Returns:
      the custom name supplied via UserActionConfiguration
    • isCompleteAutomatically

      boolean isCompleteAutomatically()
      Returns the current value of the completeAutomatically flag.
      Returns:
      true if the user action will be closed automatically; false if an explicit call to complete() is required
    • setCompleteAutomatically

      void setCompleteAutomatically(boolean enabled)
      Sets whether this user action closes automatically or must be closed manually with complete().

      When true, the user action will be closed automatically once the pending web request or navigation events for this action complete. When false, the user action remains open until complete() is called or the action reaches its maximum duration.

      Parameters:
      enabled - true to enable automatic completion; false to require an explicit complete() call
    • complete

      void complete()
      Closes this user action immediately, regardless of any pending web requests.

      Calling this method on an already-closed user action has no effect.

    • addEventProperty

      void addEventProperty(String key, String value)
      Adds or updates a String event property scoped to this user action.

      Property keys must be prefixed with "event_properties.". Any property without this prefix will be dropped during validation.

      Parameters:
      key - the property key; if null or invalid the key–value pair will be dropped
      value - the property value
    • addEventProperty

      void addEventProperty(String key, int value)
      Adds or updates an int event property scoped to this user action.

      Property keys must be prefixed with "event_properties.". Any property without this prefix will be dropped during validation.

      Parameters:
      key - the property key; if null or invalid the key–value pair will be dropped
      value - the property value
    • addEventProperty

      void addEventProperty(String key, long value)
      Adds or updates a long event property scoped to this user action.

      Property keys must be prefixed with "event_properties.". Any property without this prefix will be dropped during validation.

      Parameters:
      key - the property key; if null or invalid the key–value pair will be dropped
      value - the property value
    • addEventProperty

      void addEventProperty(String key, double value)
      Adds or updates a double event property scoped to this user action.

      Property keys must be prefixed with "event_properties.". Any property without this prefix will be dropped during validation. Non-finite values such as Double.NaN, Double.POSITIVE_INFINITY, and Double.NEGATIVE_INFINITY are not supported and will be nullified.

      Parameters:
      key - the property key; if null or invalid the key–value pair will be dropped
      value - the property value
    • addEventProperty

      void addEventProperty(String key, boolean value)
      Adds or updates a boolean event property scoped to this user action.

      Property keys must be prefixed with "event_properties.". Any property without this prefix will be dropped during validation.

      Parameters:
      key - the property key; if null or invalid the key–value pair will be dropped
      value - the property value