Skip to content

Session

LucasZF edited this page Oct 1, 2020 · 4 revisions

Configuration

All configuration is inside of ContribSentryOptions, but for Session configuration, you have the following options:

  • GlobalSessionMode: I’t recommended to set it as true since the Session is intended to be used by a Client Application and not a server. (Server session hasn’t been fully tested so expect issues)

  • DistinctId: An unique Id of the Client’s device (must be set by the developer if he wishes to track by the DeviceId and not the UserId)

  • sessionEnable (on constructor): Enables the session module, by default, it’s set to true.

var option = new ContribSentryOptions()
{
    GlobalSessionMode = true,
    DistinctId = "123",
    Environment = "prod"
};

Usage

For starting a session you simply call ContribSentrySdk.StartSession and for finishing the session you call

ContribSentrySdk.StartSession(user);
or
ContribSentrySdk.StartSession(null);//In case you have set the DistinctId

...
SentrySessionSdk.CloseSession();

Xamarin.Android Integration

For registering the Session when the user closes the app you must call the close function in your Main Activity, inside of OnDestroy

protected override void OnDestroy()
{
       ContribSentrySdk.Close();// or ContribSentrySdk.Sleep();
       base.OnDestroy();
}

Xamarin.Forms Integration

Add the calls to SentryContribSdk.Sleep() and Resume() inside of App.xaml.cs under OnSleep and OnResume.