How to apply a custom report sender after switching to use 5.8.1
See original GitHub issueHello. Could anybody share info on how to apply a custom report sender after switching to use 5.8.1? I had the following
implementation 'ch.acra:acra-http:5.7.0'
class CustomReportSenderFactory : ReportSenderFactory {
override fun create(context: Context, config: CoreConfiguration): ReportSender {
return CustomReportSender(config)
}
}
class CustomReportSender(config: CoreConfiguration) : HttpSender(config, null, null) {
override fun send(context: Context, report: CrashReportData) {
for (entry in report.toMap()) {
if (entry.key == ReportField.LOGCAT.name || entry.key == ReportField.STACK_TRACE.name) {
val element = (entry.value as? String) ?: continue
report.put(entry.key, filterFileNames(element))
}
}
super.send(context, report)
}
/**
* Remove all file names from the given text
* @param text The given text
* @return the filtered text
*/
private fun filterFileNames(text: String?): String {
val regex = ("(?i)\\b([^\\s:.-]+)[.](" + listOfExtensions.joinToString("|") + ")\\b").toRegex()
return text?.replace(regex, "example.file") ?: ""
}
companion object {
val listOfExtensions = listOf( "DOC", "DOCX", "LOG", "MSG", "ODT", "PAGES", "RTF", "TEX", "TXT")
}
}
@AcraCore(
reportSenderFactoryClasses = [CustomReportSenderFactory::class],
buildConfigClass = BuildConfig::class,
reportFormat = StringFormat.JSON,
reportContent = [
ReportField.LOGCAT,
ReportField.STACK_TRACE]
)
@AcraHttpSender(
uri = "https://my.site/acra",
httpMethod = HttpSender.Method.POST
)
class MyApplication : Application(), Configuration.Provider {
override fun attachBaseContext(base: Context) {
super.attachBaseContext(base)
initACRA()
}
private fun initACRA() {
ACRA.init(this)
val installVersion = SharedPreferencesHelper.getString(
PreferenceManager.getDefaultSharedPreferences(this),
Constants.PREF_KEY_INSTALL_VERSION, "unknown")
ACRA.getErrorReporter().putCustomData(
Constants.PREF_KEY_INSTALL_VERSION.toUpperCase(Locale.getDefault()), installVersion)
}
}
after switching to use 5.8.1
implementation 'ch.acra:acra-http:5.8.1'
//ACRA needs the following dependencies to use a custom report sender
compileOnly("com.google.auto.service:auto-service-annotations:1.0")
annotationProcessor("com.google.auto.service:auto-service:1.0")
@AutoService(ReportSenderFactory::class)
class CustomReportSenderFactory : HasConfigPlugin(HttpSenderConfiguration::class.java), ReportSenderFactory {
override fun create(context: Context, config: CoreConfiguration): ReportSender {
return CustomReportSender(config)
}
}
class CustomReportSender - the same
class MyApplication : Application(), Configuration.Provider {
override fun attachBaseContext(base: Context) {
super.attachBaseContext(base)
initACRA()
}
private fun initACRA() {
initAcra {
reportFormat = StringFormat.JSON
buildConfigClass = BuildConfig::class.java
reportContent = arrayOf(
ReportField.LOGCAT,
ReportField.STACK_TRACE
)
httpSender {
uri = "https://my.site/acra"
httpMethod = HttpSender.Method.POST
}
}
val installVersion = SharedPreferencesHelper.getString(
PreferenceManager.getDefaultSharedPreferences(this),
Constants.PREF_KEY_INSTALL_VERSION, "unknown")
ACRA.errorReporter.putCustomData(
Constants.PREF_KEY_INSTALL_VERSION.toUpperCase(Locale.getDefault()), installVersion)
}
}
What am I doing wrong?
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Report Sender Installation Guide | CloudAnswers Help Center
1. Install Report Sender · 2. Assign the Permission Set · 3. Go to the "Report Sender" tab · 4. Activate report sender...
Read more >Sender - User Guide | BesWebSoft WordPress Plugin - BestWebSoft
Open your WordPress Admin Dashboard and find the menu on the left. 1.2. Open the ”Sender” > “Settings” page. 2. Settings. Use the...
Read more >Apache Kafka Reference Guide - Quarkus
This reference guide demonstrates how your Quarkus application can utilize SmallRye Reactive Messaging to interact with Apache Kafka.
Read more >Reliable group communication with JGroups
The address of the sender. Can be null , and will be filled in by the transport protocol (e.g. UDP) before the message...
Read more >vApp Deployment and Configuration Guide - VMware
7. Click Update to apply your settings. vCenter Operations can send email notifications and scheduled reports. What to do next. Install a custom...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@F43nd1r Also thank you for updating the
docs
This is the replacement, which you already applied. You need to use
kapt
instead ofannotationProcessor
for it to work with kotlin code.