Commit 90ba4d42 authored by Colin Lee's avatar Colin Lee
Browse files

For mozilla-mobile/fenix#3186: Support passing a Sentry environment

parent 3d9fca61
......@@ -21,11 +21,13 @@ import mozilla.components.lib.crash.Crash
* @param context The application [Context].
* @param dsn Data Source Name of the Sentry server.
* @param tags A list of additional tags that will be sent together with crash reports.
* @param environment An optional, environment name string or null to set none
*/
class SentryService(
context: Context,
dsn: String,
tags: Map<String, String> = emptyMap(),
environment: String? = null,
private val sendEventForNativeCrashes: Boolean = false,
clientFactory: SentryClientFactory = AndroidSentryClientFactory(context)
) : CrashReporterService {
......@@ -35,6 +37,7 @@ class SentryService(
.build()
.toString(),
clientFactory).apply {
this.environment = environment
tags.forEach { entry ->
addTag(entry.key, entry.value)
}
......
......@@ -127,4 +127,25 @@ class SentryServiceTest {
verify(client).addTag(eq("ac.git"), any())
verify(client).addTag(eq("ac.as.build_version"), any())
}
@Test
fun `SentryService passes an environment or null`() {
val client: SentryClient = mock()
val environmentString = "production"
SentryService(context,
"https://fake:notreal@sentry.prod.example.net/405",
clientFactory = object : SentryClientFactory() {
override fun createSentryClient(dsn: Dsn?): SentryClient = client
},
environment = environmentString)
verify(client).environment = eq(environmentString)
SentryService(context,
"https://fake:notreal@sentry.prod.example.net/405",
clientFactory = object : SentryClientFactory() {
override fun createSentryClient(dsn: Dsn?): SentryClient = client
})
verify(client).environment = null
}
}
......@@ -33,6 +33,9 @@ permalink: /changelog/
* **browser-icons**
* Fixed possible `NullPointerException` when disk cache is written to concurrently.
* **lib-crash**
* Crash reports sent to Sentry now contain optional environment information, if a parameter is passed.
# 0.55.0
* [Commits](https://github.com/mozilla-mobile/android-components/compare/v0.54.0...v0.55.0)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment