Report issue

Implementation of “report issue” functionality for end users/testers

Estimated reading time: 2 mins

Last edited: 13 Dec 2019

In this chapter you will learn how to use RevDeBug API to create a “Report Issue” button. In most applications such button would simply open up a form, to be filled up with details about the issue. It’s mundane for the user, and he won’t probably do this. And if so, there is a possibility, that user doesn’t really know what happend, and the description isn’t really accurate and it’s not very helpful in solving the issue.

RevDeBug API has a functionality, that allows you to trigger the Snapshot Recording (a short recording of code execution). The objective of this chapter is to use RevDeBug API to create a “Report Issue” button, that will send you a Snapshot Recording of what happened to your user just before he decided to submit a report.

Enable Snapshot Recording

First you need to add RevDeBug to your application in OnEvent ConnectivityType. To do this, follow this chapter about API installation.

pom.xml

<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <configuration>
            <compilerArgs>
    <arg>-ArecordServerAddress=127.0.0.1</arg>
    <arg>-ArecordServerPort=42734</arg>
                <arg>-ArecordingMode=OnEvent</arg>
                <arg>-AapplicationName=RdbJavaDemo</arg>
                <arg>-AsolutionName=RdbJavaDemo</arg>                   
    <arg>-ArepositoryPath=[STORAGE_PATH]</arg>
                <arg>-AuploadMetadata=true</arg>
                <arg>-AbacklogSize=1000</arg>	
            </compilerArgs>
            <source>1.8</source>
            <target>1.8</target>
        </configuration>
    </plugin>
</plugins>
            
build.gradle

    compileJava {
        options.compilerArgs = [
                "-ArecordServerAddress=127.0.0.1",
                "-ArecordServerPort=42734",
                "-ArecordingMode=OnEvent",
                "-AapplicationName=RdbJavaDemo",
                "-AsolutionName=RdbJavaDemo",
                "-ArepositoryPath=[STORAGE_PATH]",
                "-AuploadMetadata=true",
                "-AbacklogSize=1000"
    ]} 
            

Also take notice of the BacklogSize value. On default it is set to 1000 which means, that in case of a crash, RevDeBug will record 1000 events before it. This data retention value is fully customizable and it purely depends on your needs.

Report Issue button implementation

Finally, we can implement the “Report Issue” button functionality. For example, let’s fire the Snapshot creating method on buttonClick:

MainWindow.java

buttonClick.addActionListener(new ActionListener() {
  @Override
  public void actionPerformed(ActionEvent e) {
    RevDeBug.Storage.getStorageApi().StoreSnapshot("Snapshot Name");
  }
});

And that’s it! As you can see in the code above, you can fully modify the Snapshot name. It would be perfect, if this name was relevant to its content - whether it is current date, username or description of the issue. In the next part you will learn how to customize the Snapshot name.

Custom Snapshot name

To easier identify the snapshot, it is crucial for it to have a more descriptive name than “Snapshot Name”. For example, we could ask the user to enter the custom name with some identification data.

MainWindow.java

private String askUserForRecordingName(){
    return JOptionPane.showInputDialog("Enter the name of the recording");
}

buttonClick.addActionListener(new ActionListener() {
  @Override
  public void actionPerformed(ActionEvent e) {
    String recordingName = askUserForRecordingName();
    RevDeBug.Storage.getStorageApi().StoreSnapshot(recordingName);
  }
});