RevDeBug API

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

Estimated reading time: 3 mins

Last edited: 08 Aug 2019

RevDeBug API allows to add button, or menu option, that will trigger snapshot - recording of code executed just before user submitted a report. Recording holds a predefined number of code statements executed and their state prior to user triggering the report issues function.

Basic implementation

To implement in your application:

  1. Add RevDeBug.BuidTools Nuget package to your application
  2. Add Reference to RevDeBug.Api.dll located under your solution Nuget package store at packages\RevDeBug.BuildTools.{VersionNumber}\tools\RevDeBug.Api.dll
  3. Make sure, that application is in CrashRecording Mode (in application’s RevDeBug.setup set StateStorageClassName=CrashRecorder)
  4. Add button in your application available for users (i.e. “report issue”), that will call method: RevDeBug.Api.CrashRecorder.Api.StoreSnapshot(“recording name”);
  5. Optionally you can set snapshot name in method arguments, with descriptive name it will be easier to identify snapshot later. Recording name argument may come from user input or can be constructed from application data (username, machine name etc)

Example:

  private string AskUserForRecordingName() {
      return Microsoft.VisualBasic.Interaction.InputBox("Name of the recording", 
              "Name the recording", "Recording", 200, 200);
  }
  private void Button_Click(object sender, RoutedEventArgs e){
    string recordingName = AskUserForRecordingName();
    RevDeBug.Api.CrashRecorder.Api.StoreSnapshot(recordingName);
  }
Implementation of “report issue” button that will start and stop continuous recording

RevDeBug API allows to add user interface option to enable or disable a continuous recording mode. Using it users can record all code and it’s state triggered by their actions “from-to” moment of their choosing (ie. a full testing scenario or a reproducible issue happening on production in a remote installation location).

To implement in your application:

  1. Add RevDeBug.BuidTools Nuget package to your application
  2. Add Reference to RevDeBug.Api.dll located under your solution Nuget package store at packages\RevDeBug.BuildTools.{VersionNumber}\tools\RevDeBug.Api.dll
  3. Make sure, that application is in LiveRecording Mode (in application’s RevDeBug.setup set StateStorageClassName=LiveRecorder)
  4. Application in Live recording mode by default automatically records everything from the application start. This behaviour is controlled by the Recording Server which stores the recordings. As we would like the recording to start from the user defined moment in time the Recording Server need to have parameter RECORDING_MODE='1' passed when launched. In case your Record Server is already running you must restart it with this parameter set
  5. In your application code add a “Report issue” button that will execute the following code:
      if (RevDeBug.Api.CrashRecorder.Api.IsActive) {
        RevDeBug.Api.CrashRecorder.Api.Deactivate();
      } else {
        RevDeBug.Api.CrashRecorder.Api.Activate();
      }
    

    This code will toggle recording mode on each click

  6. In order to show visual feedback to the user, whether RevDeBug is recording at the moment you can query IsActive property: RevDeBug.Api.CrashRecorder.Api.IsActive

Example:

  private void Button_Click(object sender, RoutedEventArgs e){
    if (RevDeBug.Api.CrashRecorder.Api.IsActive) {
      RevDeBug.Api.CrashRecorder.Api.Deactivate();
    }
    else {
      RevDeBug.Api.CrashRecorder.Api.Activate();
    }
    NotifyPropertyChanged(nameof(RevDeBug.Api.CrashRecorder.Api.IsActive));
  }

  public bool IsRevDeBugRecording {
    get {
      return RevDeBug.Api.CrashRecorder.Api.IsActive;
    }
  }
Storing complex user-defined objects properties

To store user-defined (ie with source code available) complex object simply call RevDeBug.Api.CrashRecorder.Api.ComplexObject on that object and all its properties will be automatically inspected and stored in the recording.

  InitializeComponent();
  var converter = new BrushConverter();
  RdbRedBrush = (Brush)converter.ConvertFromString("#b01f1c");
  RevDeBug.Api.CrashRecorder.Api.ComplexObject(RdbRedBrush);

To implement in your application:

  1. Add RevDeBug.BuidTools Nuget package to your application
  2. Add Reference to RevDeBug.Api.dll located under your solution Nuget package store at packages\RevDeBug.BuildTools.{VersionNumber}\tools\RevDeBug.Api.dll
  3. At source code locations where you would like to serialize complex user-defined object’s properties execute method: RevDeBug.API.CrashRecorder.API.ComplexObject(object_reference_here);

Example of object properties overlaid on source code during recording playback:

Value prompts - values overlayed on code

If you want to receive all information not only about unhandled exceptions, but also about handled ones, you can simply tell RevDeBug to store exception in a catch handler. To do so you have to call RevDeBug.Api.CrashRecorder.Api.StoreException and pass the exception object as parameter.

  try {
    InitializeComponent();
    var converter = new BrushConverter();
    RdbRedBrush = (Brush).converter.ConvertFromString("#b01f1c");
  }
  catch(Exception e){
    RevDeBug.Api.CrashRecorder.Api.StoreException(e);
  }

The recorded snapshot of code that led to the exception will be stored on a Recording Server and visible on RevDeBug DevOps Monitoring dashboard in the same manner unhandled exceptions are.

Monitor - code view

To implement in your application:

  1. Add RevDeBug.BuidTools Nuget package to your application
  2. Add Reference to RevDeBug.Api.dll located under your solution Nuget package store at packages\RevDeBug.BuildTools.{VersionNumber}\tools\RevDeBug.Api.dll
  3. At source code locations where you handle an exception (ie inside catch clause) execute method: RevDeBug.API.CrashRecorder.API.ComplexObject(caught_exception_reference_here);

Didn't find what you were looking for?
Contact us at support@revdebug.com