Skip to content

Commit

Permalink
Merge 14cdb86 into db18794
Browse files Browse the repository at this point in the history
  • Loading branch information
lbloder authored Mar 22, 2023
2 parents db18794 + 14cdb86 commit 05c4413
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Unreleased

### Features
- Read integration list written by sentry gradle plugin from manifest ([#2598](https://github.com/getsentry/sentry-java/pull/2598))

## 6.16.0

### Features
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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() {}

Expand Down Expand Up @@ -320,6 +323,16 @@ static void applyMetadata(

options.setSendDefaultPii(
readBool(metadata, logger, SEND_DEFAULT_PII, options.isSendDefaultPii()));

// sdkInfo.addIntegration();

List<String> integrationsFromGradlePlugin =
readList(metadata, logger, SENTRY_GRADLE_PLUGIN_INTEGRATIONS);
if (integrationsFromGradlePlugin != null) {
for (String integration : integrationsFromGradlePlugin) {
SentryIntegrationPackageStorage.getInstance().addIntegration(integration);
}
}
}

options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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")))
}
}

0 comments on commit 05c4413

Please sign in to comment.