-
Notifications
You must be signed in to change notification settings - Fork 398
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent redundant error message uploads by first checking with the server if an error report already exists. If the error report exists, then we will show a prompt to the user and give them a link to the existing error report. Change Summary: - Add columns in error report history table to track the title of the error report, reporting game version, and the issue link that was created. - Add APIs to error reporting DAO to get the link of an existing error report by title and game version. - Add server API to check if an error report exists - Update client so that after clicking 'upload error report', we first query the server if an error report exists. If one exists, we show the link to the user, othewise we show the user the upload form. Note: we use both title and game version for de-duplication. This may lead to some duplication as version number changes, but in case we do not fix a problem or if the title matches but is actually different in a different version we will allow the error report upload.
- Loading branch information
1 parent
c84ae44
commit 6af5f46
Showing
26 changed files
with
538 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
game-core/src/main/java/org/triplea/debug/error/reporting/CanNotUploadSwingView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.triplea.debug.error.reporting; | ||
|
||
import java.util.Optional; | ||
import javax.swing.JFrame; | ||
import javax.swing.JOptionPane; | ||
import lombok.experimental.UtilityClass; | ||
import org.triplea.http.client.error.report.CanUploadErrorReportResponse; | ||
import org.triplea.swing.JEditorPaneWithClickableLinks; | ||
import org.triplea.swing.jpanel.JPanelBuilder; | ||
|
||
/** | ||
* Shows a dialog that gives a message to user about why they cannot report an error (usually | ||
* because it already exists). If a link to an error report is provided in the server response, this | ||
* dialog renders a clickable link the user can click to open the bug report. | ||
*/ | ||
@UtilityClass | ||
class CanNotUploadSwingView { | ||
|
||
static void showView( | ||
final JFrame parent, final CanUploadErrorReportResponse canUploadErrorReportResponse) { | ||
|
||
JOptionPane.showMessageDialog( | ||
parent, | ||
new JPanelBuilder() | ||
.border(10) | ||
.add( | ||
new JEditorPaneWithClickableLinks( | ||
createWindowTextContents(canUploadErrorReportResponse))) | ||
.build(), | ||
"", | ||
JOptionPane.INFORMATION_MESSAGE); | ||
} | ||
|
||
private static String createWindowTextContents( | ||
final CanUploadErrorReportResponse reportResponse) { | ||
return reportResponse.getResponseDetails() | ||
+ "<br>" | ||
+ Optional.ofNullable(reportResponse.getExistingBugReportUrl()) | ||
.map(url -> JEditorPaneWithClickableLinks.toLink(url, url)) | ||
.orElse(""); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
game-core/src/main/java/org/triplea/debug/error/reporting/UploadDecisionModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.triplea.debug.error.reporting; | ||
|
||
import games.strategy.engine.ClientContext; | ||
import java.util.logging.LogRecord; | ||
import javax.swing.JFrame; | ||
import lombok.experimental.UtilityClass; | ||
import org.triplea.http.client.error.report.CanUploadRequest; | ||
import org.triplea.http.client.error.report.ErrorReportClient; | ||
|
||
/** | ||
* Decision module to handle the case where a user wishes to report an error to TripleA. First we | ||
* need to invoke the 'can-upload' API on the server which will tell us if there is an existing bug | ||
* report. If so we render a window that will let them see the bug report, otherwise we show the bug | ||
* upload report form. | ||
*/ | ||
@UtilityClass | ||
public class UploadDecisionModule { | ||
|
||
public static void processUploadDecision( | ||
final JFrame parentWindow, final ErrorReportClient uploader, final LogRecord logRecord) { | ||
|
||
final var canUploadRequest = | ||
CanUploadRequest.builder() | ||
.errorTitle(StackTraceErrorReportFormatter.createTitle(logRecord)) | ||
.gameVersion(ClientContext.engineVersion().toString()) | ||
.build(); | ||
|
||
final var canUploadErrorReportResponse = uploader.canUploadErrorReport(canUploadRequest); | ||
|
||
if (canUploadErrorReportResponse.getCanUpload()) { | ||
StackTraceReportView.showWindow(parentWindow, uploader, logRecord); | ||
} else { | ||
CanNotUploadSwingView.showView(parentWindow, canUploadErrorReportResponse); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...ents/src/main/java/org/triplea/http/client/error/report/CanUploadErrorReportResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package org.triplea.http.client.error.report; | ||
|
||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
import lombok.Builder; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
|
||
@ToString | ||
@Builder | ||
@Getter | ||
@EqualsAndHashCode | ||
public class CanUploadErrorReportResponse { | ||
/** | ||
* True means a user can upload an error report. False means an error report is already uploaded. | ||
* If true, then responseDetails and existingBugReportUrl will be null. | ||
*/ | ||
@Nonnull private final Boolean canUpload; | ||
/** | ||
* Contains any message details that should be displayed to the user. EG: "This error is already | ||
* uploaded" | ||
*/ | ||
@Nullable private final String responseDetails; | ||
/** Contains a link to any existing error report that matches the same error the user sees. */ | ||
@Nullable private final String existingBugReportUrl; | ||
} |
19 changes: 19 additions & 0 deletions
19
http-clients/src/main/java/org/triplea/http/client/error/report/CanUploadRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.triplea.http.client.error.report; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.ToString; | ||
|
||
@ToString | ||
@EqualsAndHashCode | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Getter | ||
public class CanUploadRequest { | ||
private String gameVersion; | ||
private String errorTitle; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.