Example

Example

For example, to print the crash information to the console, you could subscribe to the OnCrash event like this:

JSON
IAgentConfiguration config = AgentConfiguration.Create(appKey);
config.OnCrash += (sender, crashReportSummaries) =>
{
foreach (var crashReportSummary in crashReportSummaries) {
Console.WriteLine($"Crash Detected: {crashReportSummary.ExceptionName}: {crashReportSummary.ExceptionReason} ({crashReportSummary.ExceptionId})");
}
};
Instrumentation.InitWithConfiguration(config);

Programmatically Control Sessions

By default, a mobile session ends after a period of user inactivity. For example, when a user opens your application, the session begins and only ends after the user stops using the app for a set period of time. When the user begins to use the application again, a new session begins.

Instead of having a period of inactivity to define the duration of a session, however, you can use the following API to programmatically control when sessions begin and end:

CODE
static void AppDynamics.Agent.Instrumentation.StartNextSession()

When you call the method StartNextSession, the current session ends and a new session begins. The API enables you to define and frame your sessions so that they align more closely with business goals and expected user flows. For example, you could use the API to define a session that tracks a purchase of a product or registers a new user.

Excessive use of this API will cause sessions to be throttled (excessive use is > 10 calls per minute per Xamarin Agent, but is subject to change). When not using the API, sessions will fall back to the default of ending after a period of user inactivity.