Skip to content

Commit 0a04d7f

Browse files
Do not enable Sentry SDK for Android when mixed versions are detected (#4271)
* Check for mixed SDK versions * Format code * format + api * Init noops if mixed versions detected * Add BuildConfig * config entries for agentless module sdk names --------- Co-authored-by: Sentry Github Bot <bot+github-bot@sentry.io>
1 parent c6e6bbc commit 0a04d7f

File tree

31 files changed

+186
-2
lines changed

31 files changed

+186
-2
lines changed

buildSrc/src/main/java/Config.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ object Config {
253253
val SENTRY_SPRING_BOOT_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.spring-boot"
254254
val SENTRY_SPRING_BOOT_JAKARTA_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.spring-boot.jakarta"
255255
val SENTRY_OPENTELEMETRY_AGENT_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.opentelemetry.agent"
256+
val SENTRY_OPENTELEMETRY_AGENTLESS_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.opentelemetry.agentless"
257+
val SENTRY_OPENTELEMETRY_AGENTLESS_SPRING_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.opentelemetry.agentless-spring"
256258
val SENTRY_APOLLO3_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.apollo3"
257259
val SENTRY_APOLLO4_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.apollo4"
258260
val SENTRY_APOLLO_SDK_NAME = "$SENTRY_JAVA_SDK_NAME.apollo"

sentry-android-fragment/src/main/java/io/sentry/android/fragment/FragmentLifecycleIntegration.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ public class FragmentLifecycleIntegration(
2222
Integration,
2323
Closeable {
2424

25+
private companion object {
26+
init {
27+
SentryIntegrationPackageStorage.getInstance()
28+
.addPackage("maven:io.sentry:sentry-android-fragment", BuildConfig.VERSION_NAME)
29+
}
30+
}
31+
2532
public constructor(application: Application) : this(
2633
application = application,
2734
filterFragmentLifecycleBreadcrumbs = FragmentLifecycleState.states,

sentry-android-navigation/src/main/java/io/sentry/android/navigation/SentryNavigationListener.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,5 +195,10 @@ public class SentryNavigationListener @JvmOverloads constructor(
195195

196196
public companion object {
197197
public const val NAVIGATION_OP: String = "navigation"
198+
199+
init {
200+
SentryIntegrationPackageStorage.getInstance()
201+
.addPackage("maven:io.sentry:sentry-android-navigation", BuildConfig.VERSION_NAME)
202+
}
198203
}
199204
}

sentry-android-ndk/src/main/java/io/sentry/android/ndk/SentryNdkUtil.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.sentry.android.ndk;
22

3+
import io.sentry.SentryIntegrationPackageStorage;
34
import io.sentry.protocol.SdkVersion;
45
import org.jetbrains.annotations.Nullable;
56

@@ -8,6 +9,11 @@
89
*/
910
final class SentryNdkUtil {
1011

12+
static {
13+
SentryIntegrationPackageStorage.getInstance()
14+
.addPackage("maven:io.sentry:sentry-android-ndk", BuildConfig.VERSION_NAME);
15+
}
16+
1117
private SentryNdkUtil() {}
1218

1319
/**

sentry-android-replay/src/main/java/io/sentry/android/replay/ReplayIntegration.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ public class ReplayIntegration(
7171
IConnectionStatusObserver,
7272
IRateLimitObserver {
7373

74+
private companion object {
75+
init {
76+
SentryIntegrationPackageStorage.getInstance()
77+
.addPackage("maven:io.sentry:sentry-android-replay", BuildConfig.VERSION_NAME)
78+
}
79+
}
80+
7481
// needed for the Java's call site
7582
public constructor(context: Context, dateProvider: ICurrentDateProvider) : this(
7683
context.appContext(),

sentry-android-timber/src/main/java/io/sentry/android/timber/SentryTimberIntegration.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ public class SentryTimberIntegration(
2121
private lateinit var tree: SentryTimberTree
2222
private lateinit var logger: ILogger
2323

24+
private companion object {
25+
init {
26+
SentryIntegrationPackageStorage.getInstance()
27+
.addPackage("maven:io.sentry:sentry-android-timber", VERSION_NAME)
28+
}
29+
}
30+
2431
override fun register(scopes: IScopes, options: SentryOptions) {
2532
logger = options.logger
2633

sentry-apollo-3/src/main/java/io/sentry/apollo3/SentryApollo3HttpInterceptor.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,5 +453,10 @@ class SentryApollo3HttpInterceptor @JvmOverloads constructor(
453453
const val SENTRY_APOLLO_3_VARIABLES = "SENTRY-APOLLO-3-VARIABLES"
454454
const val SENTRY_APOLLO_3_OPERATION_TYPE = "SENTRY-APOLLO-3-OPERATION-TYPE"
455455
const val DEFAULT_CAPTURE_FAILED_REQUESTS = true
456+
457+
init {
458+
SentryIntegrationPackageStorage.getInstance()
459+
.addPackage("maven:io.sentry:sentry-apollo-3", BuildConfig.VERSION_NAME)
460+
}
456461
}
457462
}

sentry-apollo-4/src/main/java/io/sentry/apollo4/SentryApollo4HttpInterceptor.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,5 +449,10 @@ class SentryApollo4HttpInterceptor @JvmOverloads constructor(
449449

450450
companion object {
451451
const val DEFAULT_CAPTURE_FAILED_REQUESTS = true
452+
453+
init {
454+
SentryIntegrationPackageStorage.getInstance()
455+
.addPackage("maven:io.sentry:sentry-apollo-4", BuildConfig.VERSION_NAME)
456+
}
452457
}
453458
}

sentry-apollo/src/main/java/io/sentry/apollo/SentryApolloInterceptor.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ class SentryApolloInterceptor(
3636
private val beforeSpan: BeforeSpanCallback? = null
3737
) : ApolloInterceptor {
3838

39+
private companion object {
40+
init {
41+
SentryIntegrationPackageStorage.getInstance().addPackage("maven:io.sentry:sentry-apollo", BuildConfig.VERSION_NAME)
42+
}
43+
}
44+
3945
constructor(scopes: IScopes) : this(scopes, null)
4046
constructor(beforeSpan: BeforeSpanCallback) : this(ScopesAdapter.getInstance(), beforeSpan)
4147

sentry-compose-helper/src/jvmMain/java/io/sentry/compose/gestures/ComposeGestureTargetLocator.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ public final class ComposeGestureTargetLocator implements GestureTargetLocator {
3333
private volatile @Nullable SentryComposeHelper composeHelper;
3434
private final @NotNull AutoClosableReentrantLock lock = new AutoClosableReentrantLock();
3535

36+
static {
37+
SentryIntegrationPackageStorage.getInstance()
38+
.addPackage("maven:io.sentry:sentry-compose", BuildConfig.VERSION_NAME);
39+
}
40+
3641
public ComposeGestureTargetLocator(final @NotNull ILogger logger) {
3742
this.logger = logger;
3843
SentryIntegrationPackageStorage.getInstance().addIntegration("ComposeUserInteraction");

0 commit comments

Comments
 (0)