Creating scripts for native mobile applications

You can create scripts for monitoring native applications on mobile devices by leveraging the API calls and HTTP requests from the mobile app.

Identify APIs and HTTP requests to monitor

Consult with the app developers to identify the API calls and HTTP requests that represent key user activities.

Create scripts

Review the Scripting best practices as you plan the tests for monitoring the key user activities. For example, create a separate test for each user activity so you can more easily identify the specific activity associated with any performance issues.

In the Dynatrace Recorder, use the File > New Script command to manually create scripts. See Using the New Script command for details.

Configure the script profile

Best Practice is to select a Mobile Device profile for monitoring your mobile application.

  1. Select Mobile Device.
  2. Click Select device to open the Device Manager.
  3. Expand the device brand and select the device from the list, then click OK to save the selection and close the Device Manager.

Define parameters

Use the Parameters tab to define the parameters for the HTTP requests and JavaScript you'll use in the script actions.

  1. Click the add button Add icon to the right of the Parameters field to add a row for each parameter.
  2. Type the Name and Default Value for the parameter in the fields.
  3. The parameters are saved automatically.

Add actions to the script

To add an action to the script timeline:

  1. Hover over the separator line timeline action separator until it becomes a plus sign .
  2. Click the plus sign to display the actions list.
  3. Click the action to add it to the timeline.

For more information, see Editing script actions.

You will typically use these actions to construct a mobile app script:

  • HTTP action for the API call or HTTP request.
  • Custom action for JavaScript required for the activity.
  • Wait action, as needed, for the time needed to complete network activity before executing the next action.
  • Validate action as needed to confirm that the user activity was performed successfully.

See the example script, below, for details of defining these actions in your script.

For more detailed information about the actions, see Script actions and properties in the Advanced scripting guide.

Organize the actions into logical steps with descriptive names. For example, create a new step for each HTTP request, as shown in the example script.

Test the script

Play back the script to make sure the tests you provision will run successfully.

When the script is complete, upload the script to the Dynatrace Portal.

Script example