Fix wrong variable being used, improve tests
This commit is contained in:
parent
7864066f9a
commit
fba32a2938
2 changed files with 7 additions and 18 deletions
|
|
@ -124,7 +124,7 @@ class SentryAnalyticsProvider(
|
||||||
transaction.removeExtra(invalidExtra.key)
|
transaction.removeExtra(invalidExtra.key)
|
||||||
}
|
}
|
||||||
val invalidTags = transaction.tags?.filter { it.value.startsWith("@") }.orEmpty()
|
val invalidTags = transaction.tags?.filter { it.value.startsWith("@") }.orEmpty()
|
||||||
for (invalidTag in invalidExtras) {
|
for (invalidTag in invalidTags) {
|
||||||
transaction.removeTag(invalidTag.key)
|
transaction.removeTag(invalidTag.key)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -157,11 +157,13 @@ class SentryAnalyticsProviderTest {
|
||||||
val transaction = SentryTransaction(Sentry.startTransaction("foo", "bar") as SentryTracer)
|
val transaction = SentryTransaction(Sentry.startTransaction("foo", "bar") as SentryTracer)
|
||||||
// Add a user id value
|
// Add a user id value
|
||||||
transaction.setExtra("user", "@some:user")
|
transaction.setExtra("user", "@some:user")
|
||||||
|
transaction.setTag("user", "@some:user")
|
||||||
|
|
||||||
val result = prepareTransactionBeforeSend(transaction)
|
val result = prepareTransactionBeforeSend(transaction)
|
||||||
|
|
||||||
// The user id value should have been removed
|
// The user id value should have been removed
|
||||||
assertThat(result.getExtra("user")).isNull()
|
assertThat(result.getExtra("user")).isNull()
|
||||||
|
assertThat(result.getTag("user")).isNull()
|
||||||
|
|
||||||
// The DB sizes should be included
|
// The DB sizes should be included
|
||||||
assertThat(result.getExtra(AnalyticsUserData.STATE_STORE_SIZE)).isEqualTo(10)
|
assertThat(result.getExtra(AnalyticsUserData.STATE_STORE_SIZE)).isEqualTo(10)
|
||||||
|
|
@ -172,7 +174,7 @@ class SentryAnalyticsProviderTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `prepareTransactionBeforeSend removes unwanted data and doesn't add anything if no session id is provided`() {
|
fun `prepareTransactionBeforeSend doesn't add DB info if no session id is provided`() {
|
||||||
createSentryAnalyticsProvider(
|
createSentryAnalyticsProvider(
|
||||||
getDatabaseSizesUseCase = GetDatabaseSizesUseCase {
|
getDatabaseSizesUseCase = GetDatabaseSizesUseCase {
|
||||||
Result.success(
|
Result.success(
|
||||||
|
|
@ -186,21 +188,14 @@ class SentryAnalyticsProviderTest {
|
||||||
init()
|
init()
|
||||||
|
|
||||||
val transaction = SentryTransaction(Sentry.startTransaction("foo", "bar") as SentryTracer)
|
val transaction = SentryTransaction(Sentry.startTransaction("foo", "bar") as SentryTracer)
|
||||||
// Add a user id value
|
|
||||||
transaction.setExtra("user", "@some:user")
|
|
||||||
|
|
||||||
val result = prepareTransactionBeforeSend(transaction)
|
val result = prepareTransactionBeforeSend(transaction)
|
||||||
|
|
||||||
// The user id value should have been removed
|
|
||||||
assertThat(result.getExtra("user")).isNull()
|
|
||||||
|
|
||||||
// The DB sizes are missing since there was no session id to query them
|
// The DB sizes are missing since there was no session id to query them
|
||||||
assertThat(result.extras).isEmpty()
|
assertThat(result.extras).isNull()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `prepareTransactionBeforeSend removes unwanted data and doesn't add anything if no store sizes are available`() {
|
fun `prepareTransactionBeforeSend doesn't add DB info if no store sizes are available`() {
|
||||||
createSentryAnalyticsProvider(
|
createSentryAnalyticsProvider(
|
||||||
getDatabaseSizesUseCase = GetDatabaseSizesUseCase {
|
getDatabaseSizesUseCase = GetDatabaseSizesUseCase {
|
||||||
Result.success(
|
Result.success(
|
||||||
|
|
@ -214,16 +209,10 @@ class SentryAnalyticsProviderTest {
|
||||||
init()
|
init()
|
||||||
|
|
||||||
val transaction = SentryTransaction(Sentry.startTransaction("foo", "bar") as SentryTracer)
|
val transaction = SentryTransaction(Sentry.startTransaction("foo", "bar") as SentryTracer)
|
||||||
// Add a user id value
|
|
||||||
transaction.setExtra("user", "@some:user")
|
|
||||||
|
|
||||||
val result = prepareTransactionBeforeSend(transaction)
|
val result = prepareTransactionBeforeSend(transaction)
|
||||||
|
|
||||||
// The user id value should have been removed
|
|
||||||
assertThat(result.getExtra("user")).isNull()
|
|
||||||
|
|
||||||
// The DB sizes are missing since there was no session id to query them
|
// The DB sizes are missing since there was no session id to query them
|
||||||
assertThat(result.extras).isEmpty()
|
assertThat(result.extras).isNull()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue