Migrating 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 withSentryOptions#cacheDirPath
buffer.size
- can be set withSentryOptions#cacheDirSize
buffer.flushtime
- can be set withSentryOptions#flushTimeoutMillis
buffer.shutdowntimeout
buffer.gracefulshutdown
async
async.shutdowntimeout
- can be set withSentryOptions#shutdownTimeout
async.gracefulshutdown
async.queuesize
- can be set withSentryOptions#maxQueueSize
async.threads
async.priority
compression
maxmessagelength
factory
mdcTags
extra
- can be set on the scope withScope#extra
Following properties cannot be set anymore through external configuration and have to be set directly on SentryOptions
object when initializing Sentry:
sample.rate
- throughSentryOptions#sampleRate
timeout
- throughSentryOptions#connectionTimeoutMillis
andSentryOptions#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").
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").
- Package:
- maven:io.sentry:sentry
- Version:
- 7.8.0
- Repository:
- https://github.com/getsentry/sentry-java
- API Documentation:
- https://javadoc.io/doc/io.sentry