Skip to content

Commit

Permalink
Add Sentry for error/logging/reporting, no ips are stored, also fixed…
Browse files Browse the repository at this point in the history
…/added missing fossil
  • Loading branch information
John Redwood committed Feb 16, 2019
1 parent 383bc49 commit a97056f
Show file tree
Hide file tree
Showing 22 changed files with 120 additions and 81 deletions.
30 changes: 29 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,34 @@
<artifactId>gson</artifactId>
<version>2.3</version>
</dependency>

<dependency>
<groupId>io.sentry</groupId>
<artifactId>sentry</artifactId>
<version>1.7.20</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
</dependencies>

<build>
<finalName>Trademaster_v${project.version}</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>

<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
Expand All @@ -63,6 +87,10 @@
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.1.1</version>
</plugin>
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
Expand All @@ -75,7 +103,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.1</version>
<version>3.2.1</version>
<configuration>
</configuration>
<executions>
Expand Down
31 changes: 19 additions & 12 deletions src/main/java/com/stefank/Main.java
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
package com.stefank;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import gui.MainFrame;
import io.sentry.Sentry;
import io.sentry.SentryClient;
import io.sentry.SentryClientFactory;
import items.PoeNinjaPrices;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;


public class Main {

public static void main(String[] args)
{
PoeNinjaPrices prices = new PoeNinjaPrices();
prices.getPrices();
ExecutorService executor = Executors.newFixedThreadPool(3);
MainFrame mainFrame = new MainFrame(prices);
executor.execute( new WindowManager(mainFrame));
}

public static void main(String... args) {
initSentry();
PoeNinjaPrices prices = new PoeNinjaPrices();
prices.getPrices();
ExecutorService executor = Executors.newFixedThreadPool(3);
MainFrame mainFrame = new MainFrame(prices);
executor.execute(new WindowManager(mainFrame));
}

private static void initSentry() {
Sentry.init();
}
}
5 changes: 3 additions & 2 deletions src/main/java/connector/PoeTradeFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.io.InputStreamReader;
import java.util.List;

import io.sentry.Sentry;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
Expand Down Expand Up @@ -98,7 +99,7 @@ private String getRequestLinkForSearchData(List<NameValuePair> searchData) {
try {
response = this.sendPost(this.POE_SEARCHLINK, searchData);
} catch (Exception e) {
e.printStackTrace();
Sentry.capture(e);
}
String requestLink = this.filterLinkFromResponse(response);

Expand All @@ -112,7 +113,7 @@ public String getAllMapsFromRequestAsHtml(List<NameValuePair> searchData) {
try {
response = this.sendGet(requestLink);
} catch (Exception e) {
e.printStackTrace();
Sentry.capture(e);
}

return response;
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/gui/IHideable.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

public interface IHideable {

public void setFrameVisible();
public boolean isUserWantsMinimize();
public void setFrameInvisible();
public boolean isFrameVisible();
void setFrameVisible();
boolean isUserWantsMinimize();
void setFrameInvisible();
boolean isFrameVisible();
}
51 changes: 25 additions & 26 deletions src/main/java/gui/MainFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import io.sentry.Sentry;
import listener.*;
import org.json.JSONArray;
import org.json.JSONObject;
Expand Down Expand Up @@ -46,31 +47,31 @@ public class MainFrame extends JDialog implements IHideable {
public static final String[] AVAILABLE_LEAGUES = new String[]{"Standard", "Hardcore", "Betrayal", "Hardcore Betrayal"};

private static final long serialVersionUID = 1L;
PoeNinjaPrices poeNinjaPrices;
private PoeNinjaPrices poeNinjaPrices;
private static final Charset UTF_8 = Charset.forName("UTF-8");
private static final Charset ISO = Charset.forName("ISO-8859-1");
String[] currencys = { "ANY", "chaos", "alch", "chisel", "vaal", "fuse" };
private String[] currencys = { "ANY", "chaos", "alch", "chisel", "vaal", "fuse" };
private Point mouseClickPoint; // Will reference to the last pressing (not clicking) position
private User32 user32 = User32.INSTANCE;
TradeableBulk tradeables;
CurrencyOffers currencyOffers;
boolean isVisible;
List<Map> maps;
List<Map> tradeableMaps;
SearchParameter searchBuilder;
String currency = "";
String mapName = "";
boolean selectedCurrency = false;
boolean selectedTier = false;
boolean selectedMap = false;
boolean validAmountInput = false;
boolean validPricePerMapInput = false;
boolean loadedShapedMaps = false;
boolean loadedElderMaps = false;
boolean validMaxPayInput = false;
boolean validAmountCurrencyInput = false;
boolean userWantsMinimize = false;
private TradeableBulk tradeables;
private CurrencyOffers currencyOffers;

private boolean isVisible;
private List<Map> maps;
private List<Map> tradeableMaps;
private SearchParameter searchBuilder;
private String currency = "";
private String mapName = "";
private boolean selectedCurrency = false;
private boolean selectedTier = false;
private boolean selectedMap = false;
private boolean validAmountInput = false;
private boolean validPricePerMapInput = false;
private boolean loadedShapedMaps = false;
private boolean loadedElderMaps = false;
private boolean validMaxPayInput = false;
private boolean validAmountCurrencyInput = false;
private boolean userWantsMinimize = false;
private JTabbedPane tabbedPane;

private PanelSingleMaps singleMapsPanel;
Expand Down Expand Up @@ -105,7 +106,7 @@ private void initFrame() {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e1 ) {
e1.printStackTrace();
Sentry.capture(e1);
}

tabbedPane.setBackground(new Color(32, 178, 170));
Expand Down Expand Up @@ -247,8 +248,7 @@ public void loadMapsFromJson() {
bytes = text.getBytes("UTF-8");
mapsAsJsonString = new String(bytes, "UTF-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Sentry.capture(e);
}
JSONObject json = new JSONObject(mapsAsJsonString);
JSONArray maps = json.getJSONArray("Maps");
Expand All @@ -275,8 +275,7 @@ public void loadCurrencyFromJson() {
bytes = text.getBytes("UTF-8");
currencysAsJson = new String(bytes, "UTF-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Sentry.capture(e);
}

JSONObject json = new JSONObject(currencysAsJson);
Expand Down
11 changes: 4 additions & 7 deletions src/main/java/gui/MinimizedFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import javax.swing.JTextField;
import com.stefank.Main;

import io.sentry.Sentry;
import listener.MaximizeButtonListener;

import java.awt.Image;
Expand All @@ -16,15 +17,12 @@
import java.awt.Color;

public class MinimizedFrame extends JFrame implements IHideable {

/**
*
*/

private static final long serialVersionUID = 1L;
private JTextField txtTest;
private boolean userWantsMinimize;
private boolean isVisible;
MainFrame mainFrame;
private MainFrame mainFrame;


public MinimizedFrame(MainFrame mainFrame) {
Expand All @@ -51,8 +49,7 @@ public MinimizedFrame(MainFrame mainFrame) {
try {
maximizeIcon = ImageIO.read(Main.class.getResourceAsStream("maximize.png"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
Sentry.capture(e);
}
btnMaximize.setIcon(new ImageIcon(maximizeIcon));
btnMaximize.setFocusPainted(false);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/gui/PanelBase.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gui;

import com.stefank.Main;
import io.sentry.Sentry;

import javax.imageio.ImageIO;
import javax.swing.*;
Expand Down Expand Up @@ -36,7 +37,7 @@ private void init() {
cancelIcon = ImageIO.read(Main.class.getResourceAsStream("cancel.png"));
minimizeIcon = ImageIO.read(Main.class.getResourceAsStream("minimize.png"));
} catch (IOException e) {
e.printStackTrace();
Sentry.capture(e);
}

setLayout(null);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/handler/PoeNinjaHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.google.gson.Gson;

import connector.PoeNinjaFetcher;
import io.sentry.Sentry;
import items.TradeableBulk;
import jsonNinjaResult.Result;

Expand Down Expand Up @@ -56,8 +57,7 @@ public void handleBulkRequests() {
}

} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
Sentry.capture(e);
}

this.tradeables.generateTradebleItems(this.minBulk);
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/helper/RobotHelper.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package helper;

import io.sentry.Sentry;

import java.awt.AWTException;
import java.awt.Robot;
import java.awt.event.KeyEvent;
Expand Down Expand Up @@ -37,12 +39,10 @@ public static void sendClipboardTextToChat() {
Thread.sleep(32);
robot.keyRelease(KeyEvent.VK_ENTER);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
Sentry.capture(e1);
}
} catch (AWTException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
Sentry.capture(e1);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/items/PoeNinjaPrices.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import connector.PoeNinjaPriceFetcher;
import handler.CurrencyPoeTradeHandler;
import handler.PoeNinjaPriceCheckHandler;
import io.sentry.Sentry;

public class PoeNinjaPrices {

Expand All @@ -26,7 +27,7 @@ public void getPrices() {
try {
pricesAsJsonText = fetcher.sendGet();
} catch (Exception e) {
e.printStackTrace();
Sentry.capture(e);
}

PoeNinjaPriceCheckHandler handler = new PoeNinjaPriceCheckHandler(pricesAsJsonText);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/listener/AmountTxtBoxListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import javax.swing.text.BadLocationException;

import gui.MainFrame;
import io.sentry.Sentry;

public class AmountTxtBoxListener implements DocumentListener {

Expand All @@ -20,8 +21,7 @@ public void insertUpdate(DocumentEvent e) {
try {
userInput = e.getDocument().getText(0, e.getDocument().getLength());
} catch (BadLocationException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
Sentry.capture(e1);
}

if(isNumeric(userInput) && Integer.valueOf(userInput) >= 1 && Integer.valueOf(userInput) <= 100) { // between 1 and 100
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/listener/CurrencyTabCmbBoxPayListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import javax.swing.JComboBox;

import io.sentry.Sentry;
import org.json.JSONObject;

import com.stefank.Main;
Expand Down Expand Up @@ -34,8 +35,7 @@ public void actionPerformed(ActionEvent e) {
bytes = text.getBytes("UTF-8");
mapsAsJsonString = new String(bytes, "UTF-8");
} catch (UnsupportedEncodingException event) {
// TODO Auto-generated catch block
event.printStackTrace();
Sentry.capture(event);
}
JSONObject json = new JSONObject(mapsAsJsonString);
JSONObject currencys = (JSONObject) json.get("Currency");
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/listener/CurrencyTabCmbBoxWantListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import javax.swing.JComboBox;

import io.sentry.Sentry;
import org.json.JSONObject;

import com.stefank.Main;
Expand Down Expand Up @@ -34,7 +35,7 @@ public void actionPerformed(ActionEvent e) {
bytes = text.getBytes("UTF-8");
mapsAsJsonString = new String(bytes, "UTF-8");
} catch (UnsupportedEncodingException event) {
event.printStackTrace();
Sentry.capture(event);
}
JSONObject json = new JSONObject(mapsAsJsonString);
JSONObject currencys = (JSONObject) json.get("Currency");
Expand Down
Loading

0 comments on commit a97056f

Please sign in to comment.