Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QA] Replace setOf with HashSet.add #3801

Merged
merged 4 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

### Fixes

- Replace setOf with HashSet.add ([#3801](https://github.com/getsentry/sentry-java/pull/3801))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 🚫 The changelog entry seems to be part of an already released section ## 7.16.0.
    Consider moving the entry to the ## Unreleased section, please.

- Cache parsed Dsn ([#3796](https://github.com/getsentry/sentry-java/pull/3796))
- fix invalid profiles when the transaction name is empty ([#3747](https://github.com/getsentry/sentry-java/pull/3747))
- Deprecate `enableTracing` option ([#3777](https://github.com/getsentry/sentry-java/pull/3777))
Expand Down
5 changes: 5 additions & 0 deletions sentry-android-fragment/api/sentry-android-fragment.api
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public final class io/sentry/android/fragment/FragmentLifecycleIntegration : and
public final class io/sentry/android/fragment/FragmentLifecycleState : java/lang/Enum {
public static final field ATTACHED Lio/sentry/android/fragment/FragmentLifecycleState;
public static final field CREATED Lio/sentry/android/fragment/FragmentLifecycleState;
public static final field Companion Lio/sentry/android/fragment/FragmentLifecycleState$Companion;
public static final field DESTROYED Lio/sentry/android/fragment/FragmentLifecycleState;
public static final field DETACHED Lio/sentry/android/fragment/FragmentLifecycleState;
public static final field PAUSED Lio/sentry/android/fragment/FragmentLifecycleState;
Expand All @@ -37,6 +38,10 @@ public final class io/sentry/android/fragment/FragmentLifecycleState : java/lang
public static fun values ()[Lio/sentry/android/fragment/FragmentLifecycleState;
}

public final class io/sentry/android/fragment/FragmentLifecycleState$Companion {
public final fun getStates ()Ljava/util/HashSet;
}

public final class io/sentry/android/fragment/SentryFragmentLifecycleCallbacks : androidx/fragment/app/FragmentManager$FragmentLifecycleCallbacks {
public static final field Companion Lio/sentry/android/fragment/SentryFragmentLifecycleCallbacks$Companion;
public static final field FRAGMENT_LOAD_OP Ljava/lang/String;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class FragmentLifecycleIntegration(

constructor(application: Application) : this(
application = application,
filterFragmentLifecycleBreadcrumbs = FragmentLifecycleState.values().toSet(),
filterFragmentLifecycleBreadcrumbs = FragmentLifecycleState.states,
enableAutoFragmentLifecycleTracing = false
)

Expand All @@ -34,7 +34,7 @@ class FragmentLifecycleIntegration(
enableAutoFragmentLifecycleTracing: Boolean
) : this(
application = application,
filterFragmentLifecycleBreadcrumbs = FragmentLifecycleState.values().toSet()
filterFragmentLifecycleBreadcrumbs = FragmentLifecycleState.states
.takeIf { enableFragmentLifecycleBreadcrumbs }
.orEmpty(),
enableAutoFragmentLifecycleTracing = enableAutoFragmentLifecycleTracing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,21 @@ enum class FragmentLifecycleState(internal val breadcrumbName: String) {
STOPPED("stopped"),
VIEW_DESTROYED("view destroyed"),
DESTROYED("destroyed"),
DETACHED("detached")
DETACHED("detached");

companion object {
val states = HashSet<FragmentLifecycleState>().apply {
add(ATTACHED)
add(SAVE_INSTANCE_STATE)
add(CREATED)
add(VIEW_CREATED)
add(STARTED)
add(RESUMED)
add(PAUSED)
add(STOPPED)
add(VIEW_DESTROYED)
add(DESTROYED)
add(DETACHED)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class SentryFragmentLifecycleCallbacks(
enableAutoFragmentLifecycleTracing: Boolean
) : this(
hub = hub,
filterFragmentLifecycleBreadcrumbs = FragmentLifecycleState.values().toSet()
filterFragmentLifecycleBreadcrumbs = FragmentLifecycleState.states
.takeIf { enableFragmentLifecycleBreadcrumbs }
.orEmpty(),
enableAutoFragmentLifecycleTracing = enableAutoFragmentLifecycleTracing
Expand All @@ -42,7 +42,7 @@ class SentryFragmentLifecycleCallbacks(
enableAutoFragmentLifecycleTracing: Boolean = false
) : this(
hub = HubAdapter.getInstance(),
filterFragmentLifecycleBreadcrumbs = FragmentLifecycleState.values().toSet()
filterFragmentLifecycleBreadcrumbs = FragmentLifecycleState.states
.takeIf { enableFragmentLifecycleBreadcrumbs }
.orEmpty(),
enableAutoFragmentLifecycleTracing = enableAutoFragmentLifecycleTracing
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package io.sentry.android.fragment

import kotlin.test.Test
import kotlin.test.assertEquals

class FragmentLifecycleStateTest {
@Test
fun `states contains all states`() {
assertEquals(FragmentLifecycleState.states, FragmentLifecycleState.values().toSet())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class SentryFragmentLifecycleCallbacksTest {
val span = mock<ISpan>()

fun getSut(
loggedFragmentLifecycleStates: Set<FragmentLifecycleState> = FragmentLifecycleState.values().toSet(),
loggedFragmentLifecycleStates: Set<FragmentLifecycleState> = FragmentLifecycleState.states,
enableAutoFragmentLifecycleTracing: Boolean = false,
tracesSampleRate: Double? = 1.0,
isAdded: Boolean = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ import kotlin.LazyThreadSafetyMode.NONE
public open class DefaultReplayBreadcrumbConverter : ReplayBreadcrumbConverter {
internal companion object {
private val snakecasePattern by lazy(NONE) { "_[a-z]".toRegex() }
private val supportedNetworkData by lazy(NONE) {
setOf(
"status_code",
"method",
"response_content_length",
"request_content_length",
"http.response_content_length",
"http.request_content_length"
)
private val supportedNetworkData = HashSet<String>().apply {
add("status_code")
add("method")
add("response_content_length")
add("request_content_length")
add("http.response_content_length")
add("http.request_content_length")
}
}

Expand Down
Loading