Skip to content

Commit

Permalink
Merge 7cd8750 into 9182d86
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanosiano authored Oct 17, 2024
2 parents 9182d86 + 7cd8750 commit a5fea3a
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 15 deletions.
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))
- 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

0 comments on commit a5fea3a

Please sign in to comment.