Skip to content

Commit

Permalink
ACRA: switch from email to HTTP sending
Browse files Browse the repository at this point in the history
  • Loading branch information
johan12345 committed Aug 30, 2023
1 parent 76d31f8 commit fdf4b20
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/apikeys-ci.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
<string name="chargeprice_key" translatable="false">ci</string>
<string name="openchargemap_key" translatable="false">ci</string>
<string name="fronyx_key" translatable="false">ci</string>
<string name="acra_credentials" translatable="false">ci:ci</string>
</resources>
7 changes: 7 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ android {
if (fronyxKey != null) {
variant.resValue "string", "fronyx_key", fronyxKey
}
def acraKey = env.ACRA_CRASHREPORT_CREDENTIALS ?: project.findProperty("ACRA_CRASHREPORT_CREDENTIALS")
if (acraKey == null && project.hasProperty("ACRA_CRASHREPORT_CREDENTIALS_ENCRYPTED")) {
acraKey = decode(project.findProperty("ACRA_CRASHREPORT_CREDENTIALS_ENCRYPTED"), "FmK.d,-f*p+rD+WK!eds")
}
if (acraKey != null) {
variant.resValue "string", "acra_credentials", acraKey
}
}

packagingOptions {
Expand Down
13 changes: 9 additions & 4 deletions app/src/main/java/net/vonforst/evmap/EvMapApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import net.vonforst.evmap.storage.PreferenceDataSource
import net.vonforst.evmap.ui.updateAppLocale
import net.vonforst.evmap.ui.updateNightMode
import org.acra.config.dialog
import org.acra.config.httpSender
import org.acra.config.limiter
import org.acra.config.mailSender
import org.acra.data.StringFormat
import org.acra.ktx.initAcra
import org.acra.sender.HttpSender
import java.time.Duration

class EvMapApplication : Application(), Configuration.Provider {
Expand All @@ -33,10 +34,14 @@ class EvMapApplication : Application(), Configuration.Provider {
if (!BuildConfig.DEBUG) {
initAcra {
buildConfigClass = BuildConfig::class.java
reportFormat = StringFormat.KEY_VALUE_LIST

mailSender {
mailTo = "evmap+crashreport@vonforst.net"
reportFormat = StringFormat.JSON
httpSender {
uri = getString(R.string.acra_backend_url)
val creds = getString(R.string.acra_credentials).split(":")
basicAuthLogin = creds[0]
basicAuthPassword = creds[1]
httpMethod = HttpSender.Method.POST
}

dialog {
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/donottranslate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@
<string name="donate_link" translatable="false">https://ev-map.app/donate/</string>
<string name="tesla_referral_link" translatable="false">http://ts.la/johan94494</string>
<string name="copyright_summary">©2020–2023 Johan von Forstner and contributors</string>
<string name="acra_backend_url" translatable="false">https://acra.muc.vonforst.net/report</string>
</resources>
13 changes: 12 additions & 1 deletion doc/api_keys.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ be put into the app in the form of a resource file called `apikeys.xml` under
<string name="fronyx_key" translatable="false">
insert your Fronyx key here
</string>
<string name="acra_credentials" translatable="false">
insert your ACRA crash reporting credentials here
</string>
</resources>
```

Expand Down Expand Up @@ -186,4 +189,12 @@ The API is not publically available, contact [fronyx](https://fronyx.io/contact-
key and documentation.

If you don't want to test this functionality, simply leave the API key blank.
</details>
</details>

Crash reporting
---------------

Crash reporting for release builds is done using [ACRA](https://github.com/ACRA/acra).
This should not be needed for debugging.
If you still want to try it out, you can host any compatible backend such as
[Acrarium](https://github.com/F43nd1r/Acrarium/) yourself.

0 comments on commit fdf4b20

Please sign in to comment.