diff --git a/CHANGELOG.md b/CHANGELOG.md index 24100bd20e7..78f203c33d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - The Spring Boot integration can now be configured to add the `SentryAppender` to specific loggers instead of the `ROOT` logger ([#2173](https://github.com/getsentry/sentry-java/pull/2173)) - You can specify the loggers using `"sentry.logging.loggers[0]=foo.bar` and `"sentry.logging.loggers[1]=baz` in your `application.properties` - Add capabilities to track Jetpack Compose composition/rendering time ([#2507](https://github.com/getsentry/sentry-java/pull/2507)) +- Read integration list written by sentry gradle plugin from manifest ([#2598](https://github.com/getsentry/sentry-java/pull/2598)) ### Fixes diff --git a/sentry-android-core/src/main/java/io/sentry/android/core/ManifestMetadataReader.java b/sentry-android-core/src/main/java/io/sentry/android/core/ManifestMetadataReader.java index df9077838ee..d0c174da3c0 100644 --- a/sentry-android-core/src/main/java/io/sentry/android/core/ManifestMetadataReader.java +++ b/sentry-android-core/src/main/java/io/sentry/android/core/ManifestMetadataReader.java @@ -5,6 +5,7 @@ import android.content.pm.PackageManager; import android.os.Bundle; import io.sentry.ILogger; +import io.sentry.SentryIntegrationPackageStorage; import io.sentry.SentryLevel; import io.sentry.protocol.SdkVersion; import io.sentry.util.Objects; @@ -86,6 +87,8 @@ final class ManifestMetadataReader { static final String PERFORM_FRAMES_TRACKING = "io.sentry.traces.frames-tracking"; + static final String SENTRY_GRADLE_PLUGIN_INTEGRATIONS = "io.sentry.integrations"; + /** ManifestMetadataReader ctor */ private ManifestMetadataReader() {} @@ -320,6 +323,16 @@ static void applyMetadata( options.setSendDefaultPii( readBool(metadata, logger, SEND_DEFAULT_PII, options.isSendDefaultPii())); + + // sdkInfo.addIntegration(); + + List integrationsFromGradlePlugin = + readList(metadata, logger, SENTRY_GRADLE_PLUGIN_INTEGRATIONS); + if (integrationsFromGradlePlugin != null) { + for (String integration : integrationsFromGradlePlugin) { + SentryIntegrationPackageStorage.getInstance().addIntegration(integration); + } + } } options diff --git a/sentry-android-core/src/test/java/io/sentry/android/core/ManifestMetadataReaderTest.kt b/sentry-android-core/src/test/java/io/sentry/android/core/ManifestMetadataReaderTest.kt index 0bb4210cddc..457f0cd0d1b 100644 --- a/sentry-android-core/src/test/java/io/sentry/android/core/ManifestMetadataReaderTest.kt +++ b/sentry-android-core/src/test/java/io/sentry/android/core/ManifestMetadataReaderTest.kt @@ -15,6 +15,7 @@ import org.mockito.kotlin.verify import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFalse +import kotlin.test.assertNotNull import kotlin.test.assertNull import kotlin.test.assertTrue @@ -1202,4 +1203,19 @@ class ManifestMetadataReaderTest { // Assert assertFalse(fixture.options.isEnableTimeToFullDisplayTracing) } + + @Test + fun `applyMetadata reads enabled integrations to SDK Version`() { + // Arrange + val bundle = bundleOf(ManifestMetadataReader.SENTRY_GRADLE_PLUGIN_INTEGRATIONS to "Database Instrumentation,OkHttp Instrumentation") + val context = fixture.getContext(metaData = bundle) + + // Act + ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider) + + // Assert + val resultingSet = fixture.options.sdkVersion?.integrationSet + assertNotNull(resultingSet) + assert(resultingSet.containsAll(listOf("Database Instrumentation", "OkHttp Instrumentation"))) + } }