Skip to content

Commit

Permalink
Users must opt into sessions
Browse files Browse the repository at this point in the history
  • Loading branch information
niemyjski committed Jan 25, 2016
1 parent ba63a60 commit f1b80ed
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 6 deletions.
10 changes: 7 additions & 3 deletions Source/Platforms/Windows/ExceptionlessWindowsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ public static class ExceptionlessWindowsExtensions {
/// <param name="client">The ExceptionlessClient.</param>
/// <param name="showDialog">Controls whether a dialog is shown when an unhandled exception occurs.</param>
public static void Register(this ExceptionlessClient client, bool showDialog = true) {
client.Configuration.UseSessions();
client.Configuration.AddPlugin<SetEnvironmentUserPlugin>();
client.Startup();
client.SubmitSessionStart();

if (client.Configuration.SessionsEnabled)
client.SubmitSessionStart();

client.RegisterApplicationThreadExceptionHandler();

// make sure that queued events are sent when the app exits
Expand Down Expand Up @@ -60,7 +62,9 @@ private static void OnSubmittingEvent(object sender, EventSubmittingEventArgs e)
private static void RegisterOnProcessExitHandler(this ExceptionlessClient client) {
if (_onProcessExit == null) {
_onProcessExit = (sender, args) => {
client.SubmitSessionEnd();
if (client.Configuration.SessionsEnabled)
client.SubmitSessionEnd();

client.ProcessQueue();
};
}
Expand Down
13 changes: 13 additions & 0 deletions Source/Platforms/Windows/NuGet/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ the following method.

exception.ToExceptionless().Submit()

-------------------------------------
Session Tracking
-------------------------------------
Exceptionless can also track user sessions which enables powerful application analytics.

Session tracking can be enabled by simply adding this line to the startup of your application:

ExceptionlessClient.Default.Configuration.UseSessions()

You will also need to tell Exceptionless who the current user is in your application when the user logs in:

ExceptionlessClient.Default.Configuration.SetUserIdentity("UNIQUE_ID_OR_EMAIL_ADDRESS", "Display Name")

-------------------------------------
Documentation and Support
-------------------------------------
Expand Down
10 changes: 7 additions & 3 deletions Source/Platforms/Wpf/ExceptionlessWpfExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ public static class ExceptionlessWpfExtensions {
/// <param name="client">The ExceptionlessClient.</param>
/// <param name="showDialog">Controls whether a dialog is shown when an unhandled exception occurs.</param>
public static void Register(this ExceptionlessClient client, bool showDialog = true) {
client.Configuration.UseSessions();
client.Configuration.AddPlugin<SetEnvironmentUserPlugin>();
client.Startup();
client.SubmitSessionStart();

if (client.Configuration.SessionsEnabled)
client.SubmitSessionStart();

client.RegisterApplicationThreadExceptionHandler();
client.RegisterApplicationDispatcherUnhandledExceptionHandler();

Expand Down Expand Up @@ -70,7 +72,9 @@ private static bool ShowDialog(EventSubmittingEventArgs e) {
private static void RegisterOnProcessExitHandler(this ExceptionlessClient client) {
if (_onProcessExit == null) {
_onProcessExit = (sender, args) => {
client.SubmitSessionEnd();
if (client.Configuration.SessionsEnabled)
client.SubmitSessionEnd();

client.ProcessQueue();
};
}
Expand Down
13 changes: 13 additions & 0 deletions Source/Platforms/Wpf/NuGet/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ the following method.

exception.ToExceptionless().Submit()

-------------------------------------
Session Tracking
-------------------------------------
Exceptionless can also track user sessions which enables powerful application analytics.

Session tracking can be enabled by simply adding this line to the startup of your application:

ExceptionlessClient.Default.Configuration.UseSessions()

You will also need to tell Exceptionless who the current user is in your application when the user logs in:

ExceptionlessClient.Default.Configuration.SetUserIdentity("UNIQUE_ID_OR_EMAIL_ADDRESS", "Display Name")

-------------------------------------
Documentation and Support
-------------------------------------
Expand Down
5 changes: 5 additions & 0 deletions Source/Shared/Configuration/ExceptionlessConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,11 @@ public string ApiKey {
/// </value>
public bool IncludePrivateInformation { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to automatically send session start, session heartbeats and session end events.
/// </summary>
public bool SessionsEnabled { get; set; }

/// <summary>
/// Maximum number of events that should be sent to the server together in a batch. (Defaults to 50)
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ public static string GetInstallId(this ExceptionlessConfiguration config) {
}

public static void UseSessions(this ExceptionlessConfiguration config, bool sendHeartbeats = true) {
config.SessionsEnabled = true;

if (sendHeartbeats)
config.AddPlugin<HeartbeatPlugin>();
}
Expand Down

0 comments on commit f1b80ed

Please sign in to comment.