Skip to content

Instantly share code, notes, and snippets.

@baz8080
Created March 29, 2021 20:20
Show Gist options
  • Save baz8080/e931fed449357d6760d3bab2378bd9a4 to your computer and use it in GitHub Desktop.
Save baz8080/e931fed449357d6760d3bab2378bd9a4 to your computer and use it in GitHub Desktop.
How to use self hosted Rollbar instance in Android SDK
implementation('com.rollbar:rollbar-android:1.7.5')
Rollbar.init(this, "{access_token}", "production", true, true)
val rollbar = Rollbar.instance()
val originalConfig = rollbar.config()
val id = 123
// There's essential config in the default 'originalConfig', so start from that.
val config = ConfigBuilder.withConfig(originalConfig)
.endpoint("https://{self_hosted_domain}/api/1/item/")
.sender(null) // working around a bug in their builder. tested version: 1.7.5
.context { "{zendesk_subdomain}" }
.person { Person.Builder().metadata(mapOf("uid" to id)).build() }
.custom { mapOf("auth_type" to "{auth_type}") }
.handleUncaughtErrors(true)
.filter(object : Filter {
// Only report our own crashes.
override fun postProcess(data: Data?): Boolean {
if (data?.isUncaught == true) {
if (data.body.contents.toString().contains("className='zendesk.")) {
return false
}
}
return true
}
override fun preProcess(
level: Level?,
error: Throwable?,
custom: MutableMap<String, Any>?,
description: String?
): Boolean {
return false
}
})
.build()
rollbar.configure(config)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment