sentry-docs icon indicating copy to clipboard operation
sentry-docs copied to clipboard

Documentation of Android Timber integration is incorrect/misleading

Open hirschbp opened this issue 2 years ago • 4 comments

Core or SDK?

Platform/SDK

Which part? Which one?

Android Timber Integration Documentation

Description

The part of the documentation about manual initialization and adding of SentryTimberIntegration is at least misleading. The code example looks like this:

import io.sentry.android.timber.SentryTimberIntegration
import timber.log.Timber
// import BuildConfig

SentryAndroid.init(this) { options ->
  if (!BuildConfig.DEBUG) {

    // default values:
    // minEventLevel = ERROR
    // minBreadcrumbLevel = INFO
    options.addIntegration(
      SentryTimberIntegration(
        minEventLevel = SentryLevel.ERROR,
        minBreadcrumbLevel = SentryLevel.INFO
      )
    )
  } else {
    Timber.plant(Timber.DebugTree())
  }
}

From your code example I would expect that in the case of BuildConfg.DEBUG no SentryTimberTree is added to Timber. However, after a lot of trouble shooting I found in the source code, that a default SentryTimberTree is always added to Timber in the SentryAndroid.init() call as soon as Timber and the Sentry.Timber plugin is available in the classpath. Therefore, also all debug builds are logging to Sentry in this case.

Suggested Solution

Either this is a bug in your code, so that when auto-init is set to false, manually calling SentryAndroid.init() should not automatically add a Tree to Timber if you do no do that explicitly.

Or if this is intended behavior, at least your code example/documentation page should hint that behavior.

hirschbp avatar May 26 '23 13:05 hirschbp

Assigning to @getsentry/support for routing, due by (sfo). ⏲️

getsantry[bot] avatar May 26 '23 13:05 getsantry[bot]

Routing to @getsentry/product-owners-sdks-mobile for triage, due by (vie). ⏲️

getsantry[bot] avatar May 26 '23 20:05 getsantry[bot]

hey @hirschbp, apologies for the confusion. We actually mention this behavior, but in the auto-installation section and not the manual one (the one you're referring to) image

I think we should better support this case, so it's not only the documentation problem here, but the usage problem rather. We'll think of something and come up with a solution. Thanks for reporting!

romtsn avatar May 30 '23 07:05 romtsn

How can I disable Timber Integration for DevDebug build variant, but enable Timber Integration for a specific build variant? Is it possible to do both programmatically?

phileo avatar Jun 18 '23 16:06 phileo