Defining App Moments

Defining App Moments

You should define 2-3 moments in your app that are of the utmost importance to the experience of your users. In addition to app startup, these could be media uploads or downloads, content loading, video streaming, in-app purchases, or any other critical path in your app that could drastically harm a user’s experience if something goes haywire.

Recommendations for implementing successfully:

Measuring Custom Moments

Measuring custom moments is done with calls to beginEventWithName: and endEventWithName:. The name is used to match an end event with its corresponding start event, as well as for display on the web dashboard.

There are more parameters you can pass to the begin method as well, using beginEventWithName:identifier:allowScreenshot:properties:. Moments can optionally take a screenshot if we detect that something has gone wrong, and you can log arbitrary values in the properties dictionary (up to 10 keys).

Here’s a sample custom moment for a networking call using NSURLSession


NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration];
NSURL *url = [NSURL URLWithString:@""];

NSURLSessionDataTask *dataTask = [session dataTaskWithURL:url completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
    [[Embrace sharedInstance] endEventWithName:@"foo_request"];

[[Embrace sharedInstance] beginEventWithName:@"foo_request" identifier:nil allowScreenshot:YES properties:@{@"foo": @"bar"}];
[dataTask resume];


let session = URLSession.init(configuration: URLSessionConfiguration.default)
guard let url = URL.init(string: "") else { return }
let dataTask = session.dataTask(with: url, completionHandler: { (data: Data?, response: URLResponse?, error: Error?) in
    Embrace.sharedInstance().endEvent(withName: "foo_request")

Embrace.sharedInstance().beginEvent(withName: "foo_request", identifier: "", allowScreenshot: true, properties: ["foo": "bar"])

If you’re trying to measure the performance of several similar requests or interactions, you can use beginEventWithName:identifier: and endEventWithName:identifier: to prevent naming collisions. This will record measurements for a given name, identifier pair.