Skip to main content

Moments

Overview

Embrace also contains a powerful stopwatch and abandonment tracking feature. Embrace uses this mechanism to measure your application launch performance. This is why you must call endAppStartup somewhere in your application, as mentioned in the Session Reporting section.

You can use that same mechanism yourself to measure any portion of your application. We call this concept moments. This API is also immediate mode (like logs), meaning your users will incur a networking call whenever you start and stop a moment.

info

The performance of the networking calls that moments make are unrelated to the performance of the moment itself.

Moments are best used for tracking critical user flows that are generally short in nature. For more suggestions on what to measure with moments, see the Best Practices page.

Starting a Moment

Here's what a call to start a moment looks like.

Embrace.sharedInstance().startMoment(withName: "add_item")

In a sample scenario, this is a moment we're using to measure how quickly our UITableView renders after adding a new item using the plus button. We start the moment when we add the item, and we'll end it when the animation finishes. Our UX designers have been experimenting with different animation styles, and we've read in our reviews that some users get annoyed by the animation and quit the app over it. We wanted to verify that for ourselves.

You can also start a moment with properties and identifier. For more on this, check out the API docs.

Limits on Properties
  • Property keys have a limit of 128 characters.
  • Property values have a limit of 256 characters.
  • You can have up to 100 properties(the limit can be increased on Android SDK 5.14.2 or iOS SDK 5.16.1 and above). Reach out to support@embrace.io to enable this.

Ending a Moment

Here's how to end a moment.

Embrace.sharedInstance().endMoment(withName: "add_item")

Once you start a moment, a timer is started. If you end the moment within a configurable threshold, then the timer ends and the client's measurement is used to report performance. You can end the moment from multiple locations in your app, or from multiple threads.

Tracking Abandonment

In addition to performance, moments also measure abandonment by default. For more on tracking abandonment, see the Best Practices section.