
Configures Sentry with privacy-focused defaults: disables auto-install, performance tracing, session tracking; anonymizes user/device, preserves only last-screen breadcrumb, and attaches build metadata to crashes.
Available on Maven Central:
implementation("ch.ubique.kmp:sentry:1.0.0")You may find the current version and version history in the Releases list.
Call initUbiqueSentry() in your Application class' onCreate(), or UbiqueSentry.init() if elsewhere.
class ExampleApplication : Application() {
override fun onCreate() {
initUbiqueSentry(
isProduction = BuildConfig.IS_FLAVOR_PROD,
environment = when {
BuildConfig.DEBUG -> "debug"
else -> BuildConfig.FLAVOR
},
buildTimestamp = BuildConfig.BUILD_TIMESTAMP,
buildNumber = BuildConfig.BUILD_NUMBER,
vcsBranch = BuildConfig.BRANCH,
alpakaBuildId = BuildConfig.BUILD_ID,
)
}
}| Parameter | Description |
|---|---|
isProduction |
true if this is a production build (public release). |
environment |
Current environment (e.g. "debug", "dev", "prod"). |
buildTimestamp |
Build timestamp in milliseconds since epoch. |
buildNumber |
Current build number (or null). |
vcsBranch |
Current VCS branch name (or null). |
alpakaBuildId |
Current Alpaka build ID (or null). |
dsn |
Optional Sentry DSN. If null, it will be read from the application's manifest. |
isEnabled |
Whether Sentry should be immediately enabled (defaults to true). |
beforeSend |
Callback to modify or drop a SentryEvent before it is sent. |
configuration |
Callback for further customizations to the SentryAndroidOptions. |
To log Compose Navigation breadcrumbs,
call withSentryObservableEffect()
on your NavHostControllers:
val navController = rememberNavController().withSentryObservableEffect(
enableNavigationBreadcrumbs = true,
enableNavigationTracing = false,
)Call initialize() early in your app's lifecycle (e.g. in your AppDelegate):
import UbiqueSentry
UbiqueSentryKt.initialize(
isProduction: true,
environment: "prod",
buildTimestamp: 1698765432000,
vcsBranch: "develop",
dsn: "https://123abc@sentry/42",
)| Parameter | Description |
|---|---|
isProduction |
true if this is a production build (public release). |
environment |
Current environment (e.g. "debug", "dev", "prod"). |
buildTimestamp |
Build timestamp in milliseconds since epoch. |
vcsBranch |
Current VCS branch name (or nil). |
dsn |
Optional Sentry DSN. If nil, the SDK reads it from SENTRY_DSN env variable. |
isEnabled |
Whether Sentry should be immediately enabled (defaults to true). |
beforeSend |
Callback to modify or drop a SentryEvent before it is sent. |
configuration |
Callback for further customizations to the Sentry options. |
To enable or disable Sentry at runtime, set UbiqueSentry.isEnabled at your will.
Use UbiqueSentry.captureException() to record non-fatal exceptions.
Use UbiqueSentry.captureMessage() to send a message as a non-fatal exception to Sentry:
The message is wrapped in a NonFatalException internally and supports the same optional level, extras,
and scopeCallback parameters as captureException().
Use UbiqueSentry.addBreadcrumb() to add a breadcrumb to the current Sentry scope.
The breadcrumb parameter accepts a Breadcrumb instance (e.g. created via Breadcrumb.ui(), Breadcrumb.navigation(), etc.),
and the optional data parameter allows attaching additional key-value pairs to the breadcrumb.
Use UbiqueSentry.crash() to trigger a test crash by throwing an Exception.
Most features of this library can be implemented with test-driven development using unit tests with a mock webserver instance.
To test any changes locally in an app, you can either include the library via dependency substitution in an application project, or deploy a build to your local maven repository and include that from any application:
Define a unique custom version by setting the VERSION_NAME variable in the gradle.properties file.
Deploy the library artifact by running ./gradlew publishToMavenLocal
Reference the local maven repository in your application's build script:
repositories {
mavenLocal()
}And apply the local library version:
dependencies {
implementation("ch.ubique.kmp:sentry:$yourLocalVersion")
}Create a Release,
setting the Tag to the desired version prefixed with a v.
Each release on GitHub will be deployed to Maven Central.
ch.ubique.kmp
sentry
major.minor.revision
Available on Maven Central:
implementation("ch.ubique.kmp:sentry:1.0.0")You may find the current version and version history in the Releases list.
Call initUbiqueSentry() in your Application class' onCreate(), or UbiqueSentry.init() if elsewhere.
class ExampleApplication : Application() {
override fun onCreate() {
initUbiqueSentry(
isProduction = BuildConfig.IS_FLAVOR_PROD,
environment = when {
BuildConfig.DEBUG -> "debug"
else -> BuildConfig.FLAVOR
},
buildTimestamp = BuildConfig.BUILD_TIMESTAMP,
buildNumber = BuildConfig.BUILD_NUMBER,
vcsBranch = BuildConfig.BRANCH,
alpakaBuildId = BuildConfig.BUILD_ID,
)
}
}| Parameter | Description |
|---|---|
isProduction |
true if this is a production build (public release). |
environment |
Current environment (e.g. "debug", "dev", "prod"). |
buildTimestamp |
Build timestamp in milliseconds since epoch. |
buildNumber |
Current build number (or null). |
vcsBranch |
Current VCS branch name (or null). |
alpakaBuildId |
Current Alpaka build ID (or null). |
dsn |
Optional Sentry DSN. If null, it will be read from the application's manifest. |
isEnabled |
Whether Sentry should be immediately enabled (defaults to true). |
beforeSend |
Callback to modify or drop a SentryEvent before it is sent. |
configuration |
Callback for further customizations to the SentryAndroidOptions. |
To log Compose Navigation breadcrumbs,
call withSentryObservableEffect()
on your NavHostControllers:
val navController = rememberNavController().withSentryObservableEffect(
enableNavigationBreadcrumbs = true,
enableNavigationTracing = false,
)Call initialize() early in your app's lifecycle (e.g. in your AppDelegate):
import UbiqueSentry
UbiqueSentryKt.initialize(
isProduction: true,
environment: "prod",
buildTimestamp: 1698765432000,
vcsBranch: "develop",
dsn: "https://123abc@sentry/42",
)| Parameter | Description |
|---|---|
isProduction |
true if this is a production build (public release). |
environment |
Current environment (e.g. "debug", "dev", "prod"). |
buildTimestamp |
Build timestamp in milliseconds since epoch. |
vcsBranch |
Current VCS branch name (or nil). |
dsn |
Optional Sentry DSN. If nil, the SDK reads it from SENTRY_DSN env variable. |
isEnabled |
Whether Sentry should be immediately enabled (defaults to true). |
beforeSend |
Callback to modify or drop a SentryEvent before it is sent. |
configuration |
Callback for further customizations to the Sentry options. |
To enable or disable Sentry at runtime, set UbiqueSentry.isEnabled at your will.
Use UbiqueSentry.captureException() to record non-fatal exceptions.
Use UbiqueSentry.captureMessage() to send a message as a non-fatal exception to Sentry:
The message is wrapped in a NonFatalException internally and supports the same optional level, extras,
and scopeCallback parameters as captureException().
Use UbiqueSentry.addBreadcrumb() to add a breadcrumb to the current Sentry scope.
The breadcrumb parameter accepts a Breadcrumb instance (e.g. created via Breadcrumb.ui(), Breadcrumb.navigation(), etc.),
and the optional data parameter allows attaching additional key-value pairs to the breadcrumb.
Use UbiqueSentry.crash() to trigger a test crash by throwing an Exception.
Most features of this library can be implemented with test-driven development using unit tests with a mock webserver instance.
To test any changes locally in an app, you can either include the library via dependency substitution in an application project, or deploy a build to your local maven repository and include that from any application:
Define a unique custom version by setting the VERSION_NAME variable in the gradle.properties file.
Deploy the library artifact by running ./gradlew publishToMavenLocal
Reference the local maven repository in your application's build script:
repositories {
mavenLocal()
}And apply the local library version:
dependencies {
implementation("ch.ubique.kmp:sentry:$yourLocalVersion")
}Create a Release,
setting the Tag to the desired version prefixed with a v.
Each release on GitHub will be deployed to Maven Central.
ch.ubique.kmp
sentry
major.minor.revision