Name: OkReport
Owner: Cookpad Inc.
Description: Android library to submit reports without leaving the app.
Created: 2017-07-31 10:55:57.0
Updated: 2018-04-04 11:25:40.0
Pushed: 2017-08-16 10:30:19.0
Size: 7826
Language: Kotlin
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
An Android library which allows testers to submit reports without living the app.
Because not all bugs are easy to catch, because not all bugs end with a clean reported crash on some fancy console as the result of a nice pipeline settled for logging exceptions. That's it, there is always some wrong behaviour which can not be typified as a bug per se; and therefore, it requires the supervision of a human eye to acknowledge it as a malfunction of the system. OkReport is the perfect tool for tracking that.
Add to top level gradle.build file
rojects {
repositories {
maven { url "https://jitpack.io" }
}
Add to app module gradle.build file
ndencies {
compile 'com.github.cookpad:OkReport:core:0.0.5'
//Post the report on a Slack channel
debugCompile 'com.github.cookpad:OkReport:slack_reporter:0.0.5'
releaseCompile 'com.github.cookpad:OkReport:slack_reporter_no_op:0.0.5'
//Trigger the report screen when the device is shaken
debugCompile 'com.github.cookpad:OkReport:shake_gesture:0.0.5'
releaseCompile 'com.github.cookpad:OkReport:shake_gesture_no_op:0.0.5'
s OkReportApp : Application() {
override fun onCreate() {
super.onCreate()
// Triggers the report screen when the device is shaken.
val shakeGesture = ShakeGesture(this)
// Posts the data retrieved from OkReport into a Slack channel.
val slackReporter = slackReporter()
// Entry point to start OkReport. Call it just one time per life-time application.
initOkReport(this, shakeGesture, slackReporter)
}
private fun slackReporter() : Reporter {
// Slack's token required to upload the images to Slack hosts. Go to https://api.slack.com/custom-integrations/legacy-tokens and create one.
val legacyToken = ""
// Webhook's url in which SlackReporter relies to perform the publishing report. Go to https://api.slack.com/incoming-webhooks and create one.
val webhookURL = ""
// Name or id of the channel where report's image should be published. See limitation section for more details.
val channelImages = "image_noise"
// Handy information about the device and the build version, such us device model, locale or current version code.
val deviceSpecs = collectDeviceSpecs(this)
// False by default, if true, it triggers desktop and push notifications to all team members in the channel where the report has been posted.
val notifyChannel = true
return SlackReporter(legacyToken, webhookURL, collectDeviceSpecs(this), channelImages, notifyChannel)
}
OkReport's sources is composed by several Android modules. This loosely coupled system allows clients to provide their own implementations when some customization is required.
The entry point of OkReport is a TriggerGesture
. By adding shake_gesture
module, OkReport triggers the report screen when the device is shaken. But clients can supply their own implementation if other trigger gesture is required.
If you consider that some gesture may be interesting to add to this lib, please submit a PR as a new separate module with its own no-op version. TriggerGesture
is the interface
that has be implemented to fulfill the contract:
rface TriggerGesture {
fun onTrigger(callback: () -> Unit)
s CustomTriggerGesture(context: Context) : TriggerGesture {
override fun onTrigger(callback: () -> Unit) {
//When the internal event is triggered, make a call to the callback function.
customListener {
callback()
}
}
OkReport logs reports by delegating this responsibility to a given Reporter
. By adding slack_reporter
module, OkReport posts the data retrieved from OkReport into a Slack channel. But clients can supply their own implementation if other logger mechanism is required.
If you consider that some Reporter may be interesting to add to this lib, please submit a PR as a new separate module with its own no-op version. Reporter
is the interface
that has be implemented to fulfill the contract:
rface Reporter {
fun sendReport(report: Report, reporterCallback: ReporterCallback)
rface ReporterCallback {
fun success(message: String)
fun error(error: Throwable)
s CustomReporter() : Reporter {
override fun sendReport(report: Report, reporterCallback: ReporterCallback) {
//Take report's data and send it whatever you want.
val response = someServer.sendReport(report)
//And let know OkReport about the result
if (response.ok) {
reporterCallback.success("ok")
} else {
reporterCallback.error(RuntimeException("ko"))
}
}
SlackReporter
you must to supply the name or id of an already existing channel¡s organization where images will be posted isolatedly.