Migrating Version 1.x to 4.x

Learn about migrating from version 1.x to 4.x

Our update to the API follows the Unified API more closely. It's a completely updated code base, written to support our Android SDK.

Previous:

Copied
Sentry.getContext().addTag("tagName", "tagValue");

Updated:

Copied
Sentry.setTag("tagName", "tagValue");

Previous:

Copied
try {
  int x = 1 / 0;
} catch (Exception e) {
  Sentry.capture(e);
}

New:

Copied
try {
  int x = 1 / 0;
} catch (Exception e) {
  Sentry.captureException(e);
}

Previous:

Copied
Sentry.capture("This is a test");

New:

Copied
Sentry.captureMessage("This is a test"); // SentryLevel.INFO by default
Sentry.captureMessage("This is a test", SentryLevel.WARNING); // or specific level

Previous:

Copied
Sentry.getContext().recordBreadcrumb(
  new BreadcrumbBuilder().setMessage("User made an action").build()
);

New:

Copied
Sentry.addBreadcrumb("User made an action");

Previous:

Copied
Sentry.getContext().setUser(
  new UserBuilder().setEmail("hello@sentry.io").build()
);

New:

Copied
User user = new User();
user.setEmail("hello@sentry.io");
Sentry.setUser(user);

Previous:

Copied
Sentry.getContext().addExtra("extra", "thing");

New:

Copied
Sentry.setExtra("extra", "thing");

Following configuration properties have been removed:

  • buffer.dir - can be set with SentryOptions#cacheDirPath
  • buffer.size - can be set with SentryOptions#cacheDirSize
  • buffer.flushtime - can be set with SentryOptions#flushTimeoutMillis
  • buffer.shutdowntimeout
  • buffer.gracefulshutdown
  • async
  • async.shutdowntimeout - can be set with SentryOptions#shutdownTimeout
  • async.gracefulshutdown
  • async.queuesize - can be set with SentryOptions#maxQueueSize
  • async.threads
  • async.priority
  • compression
  • maxmessagelength
  • factory
  • mdcTags
  • extra - can be set on the scope with Scope#extra

Following properties cannot be set anymore through external configuration and have to be set directly on SentryOptions object when initializing Sentry:

  • sample.rate - through SentryOptions#sampleRate
  • timeout - through SentryOptions#connectionTimeoutMillis and SentryOptions#readTimeoutMillis

See Configuration page to find all available configuration properties.

Previous:

Copied
tags=tag1:value1,tag2:value2

New:

Copied
tags.tag1=value1
tags.tag2=value2

Copied
stacktrace.app.packages=com.mycompany,com.other.name

New:

Copied
in-app-includes=com.mycompany,com.other.name

There is also an option to exclude certain packages from stack traces:

Copied
in-app-excludes=com.packages.to.exclude
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").