GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — sentry-java/MIGRATION.md at main · sahasan95/sentry-java

Expand file tree

/

MIGRATION.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
155 lines (109 loc) · 2.45 KB
/

MIGRATION.md

Copy path

File metadata and controls

155 lines (109 loc) · 2.45 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

Migrating from sentry-java to sentry-android

Docs

Migration page from sentry-android 1.x to sentry-android 2.x.

Installation

Old:

Sentry.init("___PUBLIC_DSN___", new AndroidSentryClientFactory(context));

New:

The SDK is able to initialize automatically. The only thing required is to make the DSN available. sentry.properties has been discontinued and configurations on this SDK version is over AndroidManifest.xml or code.

<meta-data android:name="io.sentry.dsn" android:value="___PUBLIC_DSN___" />

Or:

If you want to call SentryAndroid.init(...) by yourself, first of all you need to disable the auto-init feature.

<meta-data android:name="io.sentry.auto-init" android:value="false" />
SentryAndroid.init(context, options -> {
  options.setDsn("___PUBLIC_DSN___");    
});

Set tag

Old:

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

New:

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

Capture custom exception

Old:

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

New:

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

Capture a custom event

Old:

Exception exception = new Exception("custom error");
EventBuilder eventBuilder = new EventBuilder()
  .withLevel(Event.Level.ERROR)
  .withSentryInterface(new ExceptionInterface(exception));
Sentry.capture(eventBuilder);

New:

Exception exception = new Exception("custom error");
SentryEvent event = new SentryEvent(exception);
event.setLevel(SentryLevel.ERROR);
Sentry.captureEvent(event);

Capture a message

Old:

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

New:

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

Breadcrumbs

Old:

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

New:

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

User

Old:

Sentry.getContext().setUser(
  new UserBuilder().setEmail("[email protected]").build()
);

New:

User user = new User();
user.setEmail("[email protected]");
Sentry.setUser(user);

Set extra

Old:

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

New:

Sentry.setExtra("extra", "thing");
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.