تخطَّ إلى المحتوى

أندرويد (Kotlin)

التثبيت

dependencies {
    implementation("com.heysada:athar:0.1.0")
}

شرح الاستخدام أدناه بالإنجليزية، كما يظهر في سجل الحزمة، والشيفرة نفسها في كل لغة.

Crash and error reporting for Android apps, and for JVM apps on desktop or server. It reports:

  • uncaught exceptions;
  • ANRs: the main thread blocked for 5 s below Android 11, the system’s own ANR from Android 11;
  • native (NDK) crashes;
  • breadcrumbs, release health (crash-free sessions and users per release), and user feedback.

In the panel, issues are grouped, retraced with your R8 mapping, and explained in English or Arabic.

It is a thin layer over the official Sentry SDK for Android (sentry-android-core and sentry-android-ndk, MIT), set up with your app’s Sentry DSN. Consent, the user and the install id come from the shared core.

Use it

class ShopApp : Application() {
    override fun onCreate() {
        super.onCreate()
        Errors.init(
            this,
            ErrorsOptions(
                dsn = "https://ik_…@in.example.com/ingest/7", // Apps → your app → its key's DSN
                release = "com.example.shop@${BuildConfig.VERSION_NAME}+${BuildConfig.VERSION_CODE}",
            ),
        )
    }
}

Later, Errors.captureException(e) reports a caught error, Errors.identify(userId) (suspend) names your user, and Errors.sendFeedback(text, eventId) attaches what the user wrote.

  • ANRs from Android 11 come from the system’s record of why the app was stopped, so the report is sent on the app’s next launch.
  • Release health needs release: sessions are counted per release.

R8 mapping

Before the release build, write the mapping’s id into an asset folder. After the build, upload the mapping under that id:

npx @heysada/athar-cli proguard-uuid app/build/generated/debug-meta  # add it to the app's assets dirs
./gradlew :app:assembleRelease
npx @heysada/athar-cli proguard app/build/outputs/mapping/release/mapping.txt \
  --meta app/build/generated/debug-meta/sentry-debug-meta.properties
  • Strict mode (requireConsent = true): nothing is collected until Errors.grant(). Until then the Sentry SDK isn’t even started, so no handlers, sessions or requests run. revoke() and setEnabled(false) stop it, and the answer is kept across launches.
  • The library’s manifest sets io.sentry.auto-init to false, so a DSN placed in your manifest can’t start Sentry behind this choice.
  • No IP address, host name, cookies or headers are sent. The user is only the id you give, or else a random id for this install.