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");
Sentry.getContext().addTag("tagName", "tagValue");
Sentry.getContext().addTag("tagName", "tagValue")
Updated:
Copied
Sentry.setTag("tagName", "tagValue");
Sentry.setTag("tagName", "tagValue");
Sentry.setTag("tagName", "tagValue")
Previous:
Copied
try {
int x = 1 / 0;
} catch (Exception e) {
Sentry.capture(e);
}
try {
int x = 1 / 0;
} catch (Exception e) {
Sentry.capture(e);
}
try {
val x = 1 / 0
} catch (e: Exception) {
Sentry.capture(e)
}
New:
Copied
try {
int x = 1 / 0;
} catch (Exception e) {
Sentry.captureException(e);
}
try {
int x = 1 / 0;
} catch (Exception e) {
Sentry.captureException(e);
}
try {
val x = 1 / 0
} catch (e: Exception) {
Sentry.captureException(e)
}
Previous:
Copied
Sentry.capture("This is a test");
Sentry.capture("This is a test");
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
Sentry.captureMessage("This is a test"); // SentryLevel.INFO by default
Sentry.captureMessage("This is a test", SentryLevel.WARNING); // or specific level
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()
);
Sentry.getContext().recordBreadcrumb(
new BreadcrumbBuilder().setMessage("User made an action").build()
);
Sentry.getContext().recordBreadcrumb(
BreadcrumbBuilder().setMessage("User made an action").build()
)
New:
Copied
Sentry.addBreadcrumb("User made an action");
Sentry.addBreadcrumb("User made an action");
Sentry.addBreadcrumb("User made an action")
Previous:
Copied
Sentry.getContext().setUser(
new UserBuilder().setEmail("hello@sentry.io").build()
);
Sentry.getContext().setUser(
new UserBuilder().setEmail("hello@sentry.io").build()
);
Sentry.getContext().setUser(
UserBuilder().setEmail("hello@sentry.io").build()
)
New:
Copied
User user = new User();
user.setEmail("hello@sentry.io");
Sentry.setUser(user);
User user = new User();
user.setEmail("hello@sentry.io");
Sentry.setUser(user);
val user = User().apply {
email = "hello@sentry.io"
}
Sentry.setUser(user)
Previous:
Copied
Sentry.getContext().addExtra("extra", "thing");
Sentry.getContext().addExtra("extra", "thing");
Sentry.getContext().addExtra("extra", "thing")
New:
Copied
Sentry.setExtra("extra", "thing");
Sentry.setExtra("extra", "thing");
Sentry.setExtra("extra", "thing")
Following configuration properties have been removed:
buffer.dir- can be set withSentryOptions#cacheDirPathbuffer.size- can be set withSentryOptions#cacheDirSizebuffer.flushtime- can be set withSentryOptions#flushTimeoutMillisbuffer.shutdowntimeoutbuffer.gracefulshutdownasyncasync.shutdowntimeout- can be set withSentryOptions#shutdownTimeoutasync.gracefulshutdownasync.queuesize- can be set withSentryOptions#maxQueueSizeasync.threadsasync.prioritycompressionmaxmessagelengthfactorymdcTagsextra- 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#sampleRatetimeout- throughSentryOptions#connectionTimeoutMillisandSentryOptions#readTimeoutMillis
See Configuration page to find all available configuration properties.
Previous:
Copied
tags=tag1:value1,tag2:value2
tags=tag1:value1,tag2:value2
New:
Copied
tags.tag1=value1
tags.tag2=value2
tags.tag1=value1
tags.tag2=value2
Copied
stacktrace.app.packages=com.mycompany,com.other.name
stacktrace.app.packages=com.mycompany,com.other.name
New:
Copied
in-app-includes=com.mycompany,com.other.name
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
in-app-excludes=com.packages.to.exclude
Was this helpful?
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").