Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ignoredErrors option in manifest #4178

Merged
merged 4 commits into from
Feb 20, 2025
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Features

- The `ignoredErrors` option is now configurable via the manifest property `io.sentry.traces.ignored-errors` ([#4178](https://github.com/getsentry/sentry-java/pull/4178))

### Fixes

- `SentryOptions.setTracePropagationTargets` is no longer marked internal ([#4170](https://github.com/getsentry/sentry-java/pull/4170))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ final class ManifestMetadataReader {

static final String MAX_BREADCRUMBS = "io.sentry.max-breadcrumbs";

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

/** ManifestMetadataReader ctor */
private ManifestMetadataReader() {}

Expand Down Expand Up @@ -400,6 +402,8 @@ static void applyMetadata(
options
.getSessionReplay()
.setMaskAllImages(readBool(metadata, logger, REPLAYS_MASK_ALL_IMAGES, true));

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

options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.content.Context
import android.os.Bundle
import androidx.core.os.bundleOf
import androidx.test.ext.junit.runners.AndroidJUnit4
import io.sentry.FilterString
import io.sentry.ILogger
import io.sentry.SentryLevel
import io.sentry.SentryReplayOptions
Expand Down Expand Up @@ -1433,4 +1434,17 @@ class ManifestMetadataReaderTest {
// Assert
assertEquals(100, fixture.options.maxBreadcrumbs)
}

@Test
fun `applyMetadata reads ignoredErrors to options and sets the value if found`() {
// Arrange
val bundle = bundleOf(ManifestMetadataReader.IGNORED_ERRORS to "Some error,Another .*")
val context = fixture.getContext(metaData = bundle)

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

// Assert
assertEquals(listOf(FilterString("Some error"), FilterString("Another .*")), fixture.options.ignoredErrors)
}
}
Loading