Skip to content

Commit c282367

Browse files
tobiasdiezlenhard
authored andcommitted
Improve telemetry (#3218)
1 parent d941731 commit c282367

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed
Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
package org.jabref;
22

3-
import org.apache.logging.log4j.LogManager;
4-
import org.apache.logging.log4j.Logger;
5-
import org.apache.logging.log4j.Marker;
6-
import org.apache.logging.log4j.MarkerManager;
3+
import org.apache.commons.logging.Log;
4+
import org.apache.commons.logging.LogFactory;
75

86
/**
97
* Catch and log any unhandled exceptions.
108
*/
119
public class FallbackExceptionHandler implements Thread.UncaughtExceptionHandler {
1210

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

1513
public static void installExceptionHandler() {
1614
Thread.setDefaultUncaughtExceptionHandler(new FallbackExceptionHandler());
1715
}
1816

1917
@Override
2018
public void uncaughtException(Thread thread, Throwable exception) {
21-
Logger logger = LogManager.getLogger(FallbackExceptionHandler.class);
22-
logger.error(UncaughtException_MARKER, "Uncaught exception Occurred in " + thread, exception);
19+
LOGGER.error("Uncaught exception occurred in " + thread, exception);
2320
}
2421
}

src/main/java/org/jabref/gui/actions/NewEntryAction.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package org.jabref.gui.actions;
22

33
import java.awt.event.ActionEvent;
4+
import java.util.HashMap;
5+
import java.util.Map;
46

57
import javax.swing.Action;
68
import javax.swing.KeyStroke;
79

10+
import org.jabref.Globals;
811
import org.jabref.gui.EntryTypeDialog;
912
import org.jabref.gui.IconTheme;
1013
import org.jabref.gui.JabRefFrame;
@@ -58,6 +61,8 @@ public void actionPerformed(ActionEvent e) {
5861
return;
5962
}
6063
thisType = tp.getName();
64+
65+
trackNewEntry(tp);
6166
}
6267

6368
if (jabRefFrame.getBasePanelCount() > 0) {
@@ -68,4 +73,12 @@ public void actionPerformed(ActionEvent e) {
6873
LOGGER.info("Action 'New entry' must be disabled when no database is open.");
6974
}
7075
}
76+
77+
private void trackNewEntry(EntryType type) {
78+
Map<String, String> properties = new HashMap<>();
79+
properties.put("EntryType", type.getName());
80+
Map<String, Double> measurements = new HashMap<>();
81+
82+
Globals.getTelemetryClient().ifPresent(client -> client.trackEvent("NewEntry", properties, measurements));
83+
}
7184
}

src/main/java/org/jabref/gui/logging/ApplicationInsightsAppender.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public void append(LogEvent rawEvent) {
3939
Telemetry telemetry;
4040
if (event.isException()) {
4141
ExceptionTelemetry exceptionTelemetry = new ExceptionTelemetry(event.getException());
42+
exceptionTelemetry.getProperties().put("Message", rawEvent.getMessage().getFormattedMessage());
4243
exceptionTelemetry.setSeverityLevel(event.getNormalizedSeverityLevel());
4344
telemetry = exceptionTelemetry;
4445
} else {

0 commit comments

Comments
 (0)