initial Sentry integration

Signed-off-by: Jamin W. Collins <jamin.collins@gmail.com>
This commit is contained in:
Jamin W. Collins
2018-08-30 18:02:50 -06:00
parent b56b90ec1a
commit b0e2450a0e
9 changed files with 104 additions and 71 deletions

View File

@@ -28,17 +28,19 @@ import java.util.List;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.KeyStroke;
import forge.model.FModel;
import forge.properties.ForgePreferences;
import net.miginfocom.swing.MigLayout;
import forge.gui.WrapLayout;
import forge.toolbox.FHyperlink;
import forge.toolbox.FLabel;
/**
* The class BugReportDialog. Enables showing and saving error messages that
@@ -59,22 +61,19 @@ public class BugReportDialog {
area.setWrapStyleWord(true);
JPanel helpPanel = new JPanel(new WrapLayout(FlowLayout.LEFT, 4, 2));
for (String word : BugReporter.HELP_URL_LABEL.split(" ")) {
helpPanel.add(new FLabel.Builder().text("<html>" + word + "</html>").useSkinColors(false).build());
}
helpPanel.add(new FHyperlink.Builder().url(BugReporter.HELP_URL).text("<html>this post</html>").useSkinColors(false).build());
JPanel p = new JPanel(new MigLayout("wrap"));
p.add(new FLabel.Builder().text(BugReporter.HELP_TEXT).useSkinColors(false).build(), "gap 5");
p.add(helpPanel, "w 600");
p.add(new JScrollPane(area), "w 100%, h 100%, gaptop 5");
// Button is not modified, String gets the automatic listener to hide
// the dialog
List<Object> options = new ArrayList<Object>();
options.add(new JButton(new _CopyAndGo(area)));
options.add(new JButton(new _Report()));
// option to enable automatic Sentry submission
options.add(new JCheckBox(new _ActivateSentry()));
options.add(new JLabel(BugReporter.SENTRY));
options.add(new JButton(new _SaveAction(area)));
options.add(BugReporter.CONTINUE);
options.add(BugReporter.DISCARD);
if (showExitAppBtn) {
options.add(new JButton(new _ExitAction()));
}
@@ -91,18 +90,29 @@ public class BugReportDialog {
}
@SuppressWarnings("serial")
private static class _CopyAndGo extends AbstractAction {
private final JTextArea text;
private static class _ActivateSentry extends AbstractAction {
public _CopyAndGo(JTextArea text) {
@Override
public void actionPerformed(final ActionEvent actionEvent) {
JCheckBox checkBox = (JCheckBox)actionEvent.getSource();
// enable Sentry use in the future through preference setting
FModel.getPreferences().setPref(ForgePreferences.FPref.USE_SENTRY, checkBox.isSelected());
FModel.getPreferences().save();
}
}
@SuppressWarnings("serial")
private static class _Report extends AbstractAction {
public _Report() {
super(BugReporter.REPORT);
this.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_R, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
this.text = text;
}
@Override
public void actionPerformed(final ActionEvent e) {
BugReporter.copyAndGoToForums(text.getText());
BugReporter.sendSentry();
JOptionPane.getRootFrame().dispose();
}
}

View File

@@ -116,6 +116,7 @@ public enum CSubmenuPreferences implements ICDoc {
lstControls.add(Pair.of(view.getCbUiForTouchScreen(), FPref.UI_FOR_TOUCHSCREN));
lstControls.add(Pair.of(view.getCbTimedTargOverlay(), FPref.UI_TIMED_TARGETING_OVERLAY_UPDATES));
lstControls.add(Pair.of(view.getCbCompactMainMenu(), FPref.UI_COMPACT_MAIN_MENU));
lstControls.add(Pair.of(view.getCbUseSentry(), FPref.USE_SENTRY));
lstControls.add(Pair.of(view.getCbPromptFreeBlocks(), FPref.MATCHPREF_PROMPT_FREE_BLOCKS));
lstControls.add(Pair.of(view.getCbPauseWhileMinimized(), FPref.UI_PAUSE_WHILE_MINIMIZED));
lstControls.add(Pair.of(view.getCbWorkshopSyntax(), FPref.DEV_WORKSHOP_SYNTAX));

View File

@@ -98,6 +98,7 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
private final JCheckBox cbFilterLandsByColorId = new OptionsCheckBox("Filter Lands by Color in Activated Abilities");
private final JCheckBox cbShowStormCount = new OptionsCheckBox("Show Storm Count in Prompt Pane");
private final JCheckBox cbRemindOnPriority = new OptionsCheckBox("Visually Alert on Receipt of Priority");
private final JCheckBox cbUseSentry = new OptionsCheckBox("Automatically submit bug reports.");
private final Map<FPref, KeyboardShortcutField> shortcutFields = new HashMap<>();
@@ -147,6 +148,9 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
pnlPrefs.add(cbCompactMainMenu, titleConstraints);
pnlPrefs.add(new NoteLabel("Enable for a space efficient sidebar that displays only one menu group at a time (RESTART REQUIRED)."), descriptionConstraints);
pnlPrefs.add(cbUseSentry, titleConstraints);
pnlPrefs.add(new NoteLabel("When enabled, automatically submits bug reports to developers."), descriptionConstraints);
pnlPrefs.add(btnResetJavaFutureCompatibilityWarnings, "w 300px!, h 30px!, gap 27px 0 0 20px, span 2 1");
// Gameplay Options
@@ -503,6 +507,11 @@ public enum VSubmenuPreferences implements IVSubmenu<CSubmenuPreferences> {
return cbCompactMainMenu;
}
/** @return {@link javax.swing.JCheckBox} */
public final JCheckBox getCbUseSentry() {
return cbUseSentry;
}
/** @return {@link javax.swing.JCheckBox} */
public final JCheckBox getCbRemoveSmall() {
return cbRemoveSmall;

View File

@@ -22,6 +22,8 @@ import forge.GuiDesktop;
import forge.Singletons;
import forge.card.CardReaderExperiments;
import forge.error.ExceptionHandler;
import forge.util.BuildInfo;
import io.sentry.Sentry;
/**
* Main class for Forge's swing application view.
@@ -31,6 +33,9 @@ public final class Main {
* Main entry point for Forge
*/
public static void main(final String[] args) {
Sentry.init();
Sentry.getStoredClient().setRelease(BuildInfo.getVersionString());
// HACK - temporary solution to "Comparison method violates it's general contract!" crash
System.setProperty("java.util.Arrays.useLegacyMergeSort", "true");