Upgrading from v0.5.4 or earlier to v1.0.0+

This package used to be divided into five modules

  • rollbar-utilities
  • rollbar-testing
  • rollbar-sender
  • rollbar-payload
  • rollbar

As of 1.0.0 we have changed the project structure to these modules

  • rollbar-api
  • rollbar-java
  • rollbar-web
  • rollbar-android

rollbar-api contains roughly the same objects as rollbar-payload previously did. The main difference being that the objects are now constructed via builders rather than a new allocation in every setter. Therefore, any usage of rollbar-payload objects is still possible, but the style is slightly changed. For example, one of the examples for specifying the server information from the old documentation stated:

Server s = new Server()
    .host("www.rollbar.com")
    .branch("master")
    .codeVersion("b01ff9e")
    .put("TAttUQoLtUaE", 42);

The equivalent is now:

Server s = new Server.Builder()
    .host("www.rollbar.com")
    .branch("master")
    .codeVersion("b01ff9e")
    .build();

The Extensible base class from rollbar-utilities is no longer used in favor of sticking more closely to the spec.

The other use cases from those old docs was calling send directly on a Payload object:

// Throwable t
Payload p = Payload.fromError(SERVER_POST_ACCESS_TOKEN, ENVIRONMENT, t, null);
p.send();

This is no longer directly supported. The equivalent is to use Rollbar directly, either by
constructing a new instance (new Rollbar(config)) or by using the library managed singleton
(Rollbar.init(config)):

// Throwable t
Config config = withAccessToken(SERVER_POST_ACCESS_TOKEN)
        .environment("development")
        .build();
Rollbar rollbar = Rollbar.init(config);
rollbar.error(t);

There is a shim that has the same basic API as the old library located in the rollbar-java package at com.rollbar.Rollbar. This class is marked as deprecated as it is only intended to make upgrading slightly more convenient. This old example code should still work thanks to this shim class:

import com.rollbar.Rollbar;
public class MainClass {
    public static final Rollbar rollbar = new Rollbar("ACCESS_TOKEN", "production");
    public int main(String[] args) {
        rollbar.handleUncaughtErrors();
        OtherClass.runProgram();
        return 0;
    }
}

However, we strongly advise upgrading to at least this equivalent using the new library:

 import com.rollbar.notifier.Rollbar;
 public class MainClass {
     public static final Rollbar rollbar = new Rollbar(
         withAccessToken("ACCESS_TOKEN")
             .environment("production")
             .handleUncaughtErrors(true)
             .build());
     public int main(String[] args) {
         OtherClass.runProgram();
         return 0;
     }
 }

📘

For more information on rollbar-java, please see the docs here.