Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve telemetry #3218

Merged
merged 1 commit into from
Sep 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions src/main/java/org/jabref/FallbackExceptionHandler.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
package org.jabref;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.MarkerManager;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
* Catch and log any unhandled exceptions.
*/
public class FallbackExceptionHandler implements Thread.UncaughtExceptionHandler {

private static final Marker UncaughtException_MARKER = MarkerManager.getMarker("UncaughtException");
private static final Log LOGGER = LogFactory.getLog(FallbackExceptionHandler.class);

public static void installExceptionHandler() {
Thread.setDefaultUncaughtExceptionHandler(new FallbackExceptionHandler());
}

@Override
public void uncaughtException(Thread thread, Throwable exception) {
Logger logger = LogManager.getLogger(FallbackExceptionHandler.class);
logger.error(UncaughtException_MARKER, "Uncaught exception Occurred in " + thread, exception);
LOGGER.error("Uncaught exception occurred in " + thread, exception);
}
}
13 changes: 13 additions & 0 deletions src/main/java/org/jabref/gui/actions/NewEntryAction.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package org.jabref.gui.actions;

import java.awt.event.ActionEvent;
import java.util.HashMap;
import java.util.Map;

import javax.swing.Action;
import javax.swing.KeyStroke;

import org.jabref.Globals;
import org.jabref.gui.EntryTypeDialog;
import org.jabref.gui.IconTheme;
import org.jabref.gui.JabRefFrame;
Expand Down Expand Up @@ -58,6 +61,8 @@ public void actionPerformed(ActionEvent e) {
return;
}
thisType = tp.getName();

trackNewEntry(tp);
}

if (jabRefFrame.getBasePanelCount() > 0) {
Expand All @@ -68,4 +73,12 @@ public void actionPerformed(ActionEvent e) {
LOGGER.info("Action 'New entry' must be disabled when no database is open.");
}
}

private void trackNewEntry(EntryType type) {
Map<String, String> properties = new HashMap<>();
properties.put("EntryType", type.getName());
Map<String, Double> measurements = new HashMap<>();

Globals.getTelemetryClient().ifPresent(client -> client.trackEvent("NewEntry", properties, measurements));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public void append(LogEvent rawEvent) {
Telemetry telemetry;
if (event.isException()) {
ExceptionTelemetry exceptionTelemetry = new ExceptionTelemetry(event.getException());
exceptionTelemetry.getProperties().put("Message", rawEvent.getMessage().getFormattedMessage());
exceptionTelemetry.setSeverityLevel(event.getNormalizedSeverityLevel());
telemetry = exceptionTelemetry;
} else {
Expand Down