Collect Additional Types of Data
You can use methods available in the ADEUMInstrumentation class to collect six additional types of data:
| Type of Data | Description | Specifications | Where Data is Displayed |
|---|---|---|---|
| Info points | How often a method is invoked, and how long it takes to run. |
|
|
| Custom timers | Any arbitrary sequence of events within your code timed, even spanning multiple methods. |
|
|
| Custom metrics | Any integer-based data you wish to collect. |
|
|
| User data | Any string key/value pair you think might be useful. This data is included with all listed instrumentation types until it is cleared. |
|
|
| Breadcrumbs | The context for a crash. |
|
|
| User interaction | Capture when users press buttons, click on lists, and select text. |
|
Info Points
- Objective-C
-
JSON
- (void)myMethod { id tracker = [ADEumInstrumentation beginCall:self selector:_cmd]; // Implementation of method here ... [ADEumInstrumentation endCall:tracker]; } - Swift
-
JAVASCRIPT
func myMethod() { let tracker = ADEumInstrumentation.beginCall(self, selector: #function) // Implementation of method here ... ADEumInstrumentation.endCall(tracker) }
Custom Timers
startTimer and stopTimer. For example, to track the time a user spends viewing a screen, the instrumentation could look like this:
- Objective-C
-
JSON
- (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; [ADEumInstrumentation startTimerWithName:@"View Lifetime"]; } - (void)viewDidDisappear:(BOOL)animated { [super viewDidDisappear:animated]; [ADEumInstrumentation stopTimerWithName:@"View Lifetime"]; } - Swift
-
JSON
func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) ADEumInstrumentation.startTimer(withName: "View Lifetime") } func viewDidDisappear(_ animated: Bool) { super.viewDidDisappear(animated) ADEumInstrumentation.stopTimer(withName: "View Lifetime") }
This information appears in the Custom Data view of the Controller UI.
startTimerWithName again with the same name value resets a named timer.
Custom Metrics
Any integer-based data can be passed to the agent. The first parameter to the report.MetricWithName call is the name you want the metric to appear under in the Controller UI. The metric name should only contain alphanumeric characters and spaces. Illegal characters are replaced by their ASCII hex value.
Reporting a metric called "My custom metric", for example, would look something like this:
[ADEumInstrumentation reportMetricWithName:@"My custom metric" value:<#VALUE HERE#>];
This information appears in the Custom Data view of the Controller UI.
Custom User Data
You can set, and later remove any string key/value pair using with the following methods:
setUserData(key, value, success, error)removeUserData(key)
Once this is set, user data continues to be sent along with any instrumentation for network requests, sessions, or crashes. You can remove any previously set user data on a per-key basis. Alternatively, you can remove previously set user data for all keys using clearAllUserData().
Parameters
The following table describes the parameters:
| Name | Type | Description |
|---|---|---|
| key | string | The key identifying the key-value pair. |
| value | string | The value associated with the key. |
| success | function | The user-defined callback for successful cases. |
| error | function | The user-defined callback for failed cases. |
Example
- Objective-C
-
JSON
- (void) onUserLoggedIn:(NSString *)userid { [ADEumInstrumentation setUserData:@"User ID" value:userid]; ... } - Swift
-
JSON
func onUserLogged(in userid: String?) { ADEumInstrumentation.setUserData("User ID", value: userid) }
- Objective-C
-
JSON
- (void) onUserLoggedIn:(NSString *)userid { [ADEumInstrumentation removeUserData:@"User ID"]; ... } - Swift
-
JSON
func onUserLogged(in userid: String?) { ADEumInstrumentation.removeUserData("User ID") ... }
Understanding clearAllUserData()
The clearAllUserData() API clears all user data in the sense of clearing all of the above enumerated types of data at once. It does not clear any other data outside of the scope of items set with the Splunk AppDynamics setUserData() list of APIs described above. Also, it does not remove any user data already attached to existing instrumentation beacons that were previously queued for sending, and it does not affect user data attached on a per-request basis to network request instrumentation.
Example
clearAllUserData SDK API:
- Objective-C
-
CODE
- (void) onUserLoggedOut { [ADEumInstrumentation clearAllUserData]; ... } - Swift
-
CODE
func onUserLoggedOut() { ADEumInstrumentation.clearAllUserData() ... }
Breadcrumbs
Breadcrumbs allow you to situate a crash in the context of your user's experience. Set a breadcrumb when something interesting happens. If your application crashes at some point in the future, the breadcrumb will be displayed along with the crash report.
There are two ways of leaving breadcrumbs:
Using this method means that breadcrumbs are reported in crash reports only.
+ (void)leaveBreadcrumb:(NSString *)breadcrumb
Using this method lets you fine tune where the breadcrumbs are reported, either only in crash reports or in crash reports and sessions.
+ (void)leaveBreadcrumb:(NSString *)breadcrumb mode:(ADEumBreadcrumbVisibility)mode
Where mode is either:
ADEumBreadcrumbVisibilityCrashesOnlyADEumBreadcrumbVisibilityCrashesAndSessions