Skip to content

Commit

Permalink
Add ACRA to track crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
AChep committed Mar 1, 2021
1 parent f4936ef commit 03e8de1
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 2 deletions.
34 changes: 32 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,20 @@ jobs:
- id: env
run: |
echo "POCKET_MODE_RELEASE_TAG=${{ steps.vars.outputs.tag }}" >> $GITHUB_ENV
echo "ACRA_URI=${{ secrets.ACRA_URI }}" >> $GITHUB_ENV
echo "ACRA_USERNAME=${{ secrets.ACRA_USERNAME }}" >> $GITHUB_ENV
echo "ACRA_PASSWORD=${{ secrets.ACRA_PASSWORD }}" >> $GITHUB_ENV
- name: copy secrets
run: |
echo ${{ secrets.GOOGLE_SERVICES }} | base64 -d | zcat >> app/google-services.json
echo ${{ secrets.KEYSTORE_B64 }} | base64 -d | zcat >> app/pocketmode-release.keystore
echo ${{ secrets.KEYSTORE_PROPS_B64 }} | base64 -d | zcat >> app/pocketmode-release.properties
- name: "./gradlew clean bundlePlaystoreRelease assemblePlaystoreRelease assembleOpensourceRelease"
- name: "./gradlew bundlePlaystoreRelease"
uses: eskatos/gradle-command-action@v1
env:
JAVA_HOME: ${{ steps.setup-java.outputs.path }}
with:
arguments: clean bundlePlaystoreRelease assemblePlaystoreRelease assembleOpensourceRelease
arguments: bundlePlaystoreRelease
- name: create release
id: create_release
uses: actions/create-release@v1
Expand All @@ -51,20 +54,47 @@ jobs:
body: ${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: false
- name: upload Release mappings
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: app/build/outputs/mapping/playstore/mapping.txt
asset_name: pocketmode-release-${{ steps.vars.outputs.tag }}-play-store-mapping.txt
asset_content_type: application/zip
- name: "./gradlew assemblePlaystoreRelease assembleOpensourceRelease"
uses: eskatos/gradle-command-action@v1
env:
JAVA_HOME: ${{ steps.setup-java.outputs.path }}
with:
arguments: assemblePlaystoreRelease assembleOpensourceRelease
- name: upload Release [ps] apk
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: app/build/outputs/apk/playstore/release/app-playstore-release.apk
asset_name: pocketmode-release-${{ steps.vars.outputs.tag }}.apk
asset_content_type: application/zip
- name: upload Release [ps] mappings
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: app/build/outputs/mapping/playstore/mapping.txt
asset_name: pocketmode-release-${{ steps.vars.outputs.tag }}-mapping.txt
asset_content_type: application/zip
- name: upload Release [oss] apk
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: app/build/outputs/apk/opensource/release/app-opensource-release.apk
asset_name: pocketmode-release-oss-${{ steps.vars.outputs.tag }}.apk
asset_content_type: application/zip
- name: upload Release [oss] mappings
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: app/build/outputs/mapping/opensource/mapping.txt
asset_name: pocketmode-release-oss-${{ steps.vars.outputs.tag }}-mapping.txt
asset_content_type: application/zip
- name: upload to play store
uses: r0adkll/upload-google-play@v1
with:
Expand Down
11 changes: 11 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ android {
storePassword keystoreProperties['password_key']
}
}

def acraUri = System.getenv("ACRA_URI") ?: ""
def acraUsername = System.getenv("ACRA_USERNAME") ?: ""
def acraPassword = System.getenv("ACRA_PASSWORD") ?: ""

buildTypes {
debug {
applicationIdSuffix '.debug'
Expand All @@ -70,6 +75,11 @@ android {
buildConfigField "String", "MY_LICENSE_KEY", "\"" + keystoreProperties['license_key'] + "\""
}
}
buildTypes.each {
it.buildConfigField("String", "ACRA_URI", '"' + acraUri + '"')
it.buildConfigField("String", "ACRA_USERNAME", '"' + acraUsername + '"')
it.buildConfigField("String", "ACRA_PASSWORD", '"' + acraPassword + '"')
}

flavorDimensions "app"
productFlavors {
Expand Down Expand Up @@ -116,6 +126,7 @@ dependencies {
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
implementation 'com.eightbitlab:blurview:1.6.5'
implementation "ch.acra:acra-http:5.7.0"
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.browser:browser:1.3.0'
Expand Down
25 changes: 25 additions & 0 deletions app/src/main/java/com/artemchep/pocketmode/Heart.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.artemchep.pocketmode

import android.app.Activity
import android.app.Application
import android.content.Context
import android.content.Intent
import android.os.Bundle
import com.artemchep.config.Config
Expand All @@ -10,11 +11,26 @@ import com.artemchep.pocketmode.analytics.AnalyticsHolder
import com.artemchep.pocketmode.analytics.AnalyticsStub
import com.artemchep.pocketmode.analytics.createAnalytics
import com.artemchep.pocketmode.services.PocketService
import org.acra.ACRA
import org.acra.annotation.AcraCore
import org.acra.annotation.AcraHttpSender
import org.acra.data.StringFormat
import org.acra.sender.HttpSender
import org.solovyev.android.checkout.Billing

/**
* @author Artem Chepurnoy
*/
@AcraCore(
reportFormat = StringFormat.JSON,
alsoReportToAndroidFramework = true,
)
@AcraHttpSender(
uri = BuildConfig.ACRA_URI,
basicAuthLogin = BuildConfig.ACRA_USERNAME,
basicAuthPassword = BuildConfig.ACRA_PASSWORD,
httpMethod = HttpSender.Method.POST,
)
class Heart : Application() {
private val cfgObserver = object : Config.OnConfigChangedListener<String> {
override fun onConfigChanged(keys: Set<String>) {
Expand Down Expand Up @@ -46,8 +62,17 @@ class Heart : Application() {
} else AnalyticsStub()
}

override fun attachBaseContext(base: Context?) {
super.attachBaseContext(base)
ACRA.init(this)
}

override fun onCreate() {
super.onCreate()
// don't schedule anything in crash reporter process
if (ACRA.isACRASenderServiceProcess())
return

Cfg.init(this)
Cfg.observe(cfgObserver)

Expand Down

0 comments on commit 03e8de1

Please sign in to comment.