Skip to content
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Fixes

- Add support for setting in-app-includes/in-app-excludes via AndroidManifest.xml ([#4240](https://github.com/getsentry/sentry-java/pull/4240))

### Features

- The SDK now automatically propagates the trace-context to the native layer. This allows to connect errors on different layers of the application. ([#4137](https://github.com/getsentry/sentry-java/pull/4137))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ final class ManifestMetadataReader {

static final String IGNORED_ERRORS = "io.sentry.ignored-errors";

static final String IN_APP_INCLUDES = "io.sentry.in-app-includes";

static final String IN_APP_EXCLUDES = "io.sentry.in-app-excludes";

static final String ENABLE_AUTO_TRACE_ID_GENERATION =
"io.sentry.traces.enable-auto-id-generation";

Expand Down Expand Up @@ -414,8 +418,21 @@ static void applyMetadata(
.setMaskAllImages(readBool(metadata, logger, REPLAYS_MASK_ALL_IMAGES, true));

options.setIgnoredErrors(readList(metadata, logger, IGNORED_ERRORS));
}

final @Nullable List<String> includes = readList(metadata, logger, IN_APP_INCLUDES);
if (includes != null && !includes.isEmpty()) {
for (final @NotNull String include : includes) {
options.addInAppInclude(include);
}
}

final @Nullable List<String> excludes = readList(metadata, logger, IN_APP_EXCLUDES);
if (excludes != null && !excludes.isEmpty()) {
for (final @NotNull String exclude : excludes) {
options.addInAppExclude(exclude);
}
}
}
options
.getLogger()
.log(SentryLevel.INFO, "Retrieving configuration from AndroidManifest.xml");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1447,4 +1447,54 @@ class ManifestMetadataReaderTest {
// Assert
assertEquals(listOf(FilterString("Some error"), FilterString("Another .*")), fixture.options.ignoredErrors)
}

@Test
fun `applyMetadata reads inAppIncludes to options and sets the value if found`() {
// Arrange
val bundle = bundleOf(ManifestMetadataReader.IN_APP_INCLUDES to "com.example.package1,com.example.package2")
val context = fixture.getContext(metaData = bundle)

// Act
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)

// Assert
assertEquals(listOf("com.example.package1", "com.example.package2"), fixture.options.inAppIncludes)
}

@Test
fun `applyMetadata reads inAppIncludes to options and keeps empty if not found`() {
// Arrange
val context = fixture.getContext()

// Act
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)

// Assert
assertTrue(fixture.options.inAppIncludes.isEmpty())
}

@Test
fun `applyMetadata reads inAppExcludes to options and sets the value if found`() {
// Arrange
val bundle = bundleOf(ManifestMetadataReader.IN_APP_EXCLUDES to "com.example.excluded1,com.example.excluded2")
val context = fixture.getContext(metaData = bundle)

// Act
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)

// Assert
assertEquals(listOf("com.example.excluded1", "com.example.excluded2"), fixture.options.inAppExcludes)
}

@Test
fun `applyMetadata reads inAppExcludes to options and keeps empty if not found`() {
// Arrange
val context = fixture.getContext()

// Act
ManifestMetadataReader.applyMetadata(context, fixture.options, fixture.buildInfoProvider)

// Assert
assertTrue(fixture.options.inAppExcludes.isEmpty())
}
}
Loading