Skip to content

Commit

Permalink
Properly shutdown telemetry client
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasdiez committed Jun 6, 2018
1 parent 3304167 commit 39e30cc
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/main/java/org/jabref/Globals.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.google.common.base.StandardSystemProperty;
import com.microsoft.applicationinsights.TelemetryClient;
import com.microsoft.applicationinsights.TelemetryConfiguration;
import com.microsoft.applicationinsights.internal.shutdown.SDKShutdownActivity;
import com.microsoft.applicationinsights.telemetry.SessionState;

public class Globals {
Expand Down Expand Up @@ -91,10 +92,13 @@ public static void startBackgroundTasks() {
}

private static void stopTelemetryClient() {
if (Globals.prefs.shouldCollectTelemetry()) {
getTelemetryClient().ifPresent(client -> client.trackSessionState(SessionState.End));
getTelemetryClient().ifPresent(client -> client.flush());
}
getTelemetryClient().ifPresent(client -> {
client.trackSessionState(SessionState.End);
client.flush();

// Workaround for bug https://github.com/Microsoft/ApplicationInsights-Java/issues/662
SDKShutdownActivity.INSTANCE.stopAll();
});
}

private static void startTelemetryClient() {
Expand Down

0 comments on commit 39e30cc

Please sign in to comment.