# Configure Actions

To track and collect the most relevant events happening on your app, Codavel SDK uses "actions" to identify and measure where a specific event should start and stop at a given time. This way you can easily compare the network performance of the app requests with and without Bolina in a dashboard in your Codavel Performance Console.

The time of an event can be calculated by Codavel SDK, by calling the methods startAction() and stopAction(), or by setting the value directly using the registerAction() method. In both approaches it is also possible to associate metadata by calling the addMetadata() method.

# Using startAction() and stopAction()

In case you want to use Codavel SDK to measure the time between starting and stopping a specific event, the recommended approach is to use the methods startAction() and stopAction().

  1. When you want to mark the start of an action, add the following line to your code:
  • Swift
  • Objective-C
let actionID = BolinaInterceptor.startAction("Startup", withProtocol: "BOLINA")
1
  1. When you want to mark the stop of the same action, add the following line to your code:
  • Swift
  • Objective-C
BolinaInterceptor.stopAction(actionID)
1
  1. When you want to add metadata to the action, add the following lines to your code: (This data can be anything you wish as long as it is a Dictionary)
  • Swift
  • Objective-C
let metadata:[String:Any] = ["MetadataKey-1":status, "MetadataKey-2":String(duration), ...]
let metadataDictionary = NSMutableDictionary(dictionary: metadata)
BolinaInterceptor.addActionMetadata(actionID, withMetadata: metadataDictionary)
1
2
3
  1. When you finish collecting data to the action, add the following line to your code
  • Swift
  • Objective-C
BolinaInterceptor.processAction(actionID))
1

# Using registerAction()

If you are already measuring the time of an event and want to send that information to Codavel's analytics server, you should use the registerAction() method.

  1. When you want to register the action, add the following line to your code
  • Swift
  • Objective-C
let actionID = BolinaInterceptor.registerAction("Startup", withProtocol: "BOLINA", withValue: "<VALUE>")
1
  1. When you want to add metadata to the action, add the following lines to your code: (This data can be anything you wish as long as it is a Dictionary)
  • Swift
  • Objective-C
let metadata:[String:Any] = ["MetadataKey-1":status, "MetadataKey-2":String(duration), ...]
let metadataDictionary = NSMutableDictionary(dictionary: metadata)
BolinaInterceptor.addActionMetadata(actionID, withMetadata: metadataDictionary)
1
2
3
  1. When you finish collecting data to the action, add the following line to your code
  • Swift
  • Objective-C
BolinaInterceptor.processAction(actionID))
1

# Example

Trace the time to start a video:

  1. Call startAction when the user press the play button and give it a name, e.g. video start
  2. Call stopAction when the video starts playing
  3. Call processAction to save the action and send the action stats to your dashboard