获取更多动态,关注公众号:黑客下午茶

Migration Guide

Migrating from io.sentry:sentry 1.x to io.sentry:sentry 3.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.

API Changes

Set tag

Previous:

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

Updated:

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

Capture custom exception

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);
}

Capture a message

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");

User

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);

Set extra

Previous:

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

New:

Copied
Sentry.setExtra("extra", "thing");
You can edit this page on GitHub.