Skip to content

Commit

Permalink
Add support for ignoredErrors option in manifest (#4178)
Browse files Browse the repository at this point in the history
* Add support for `ignoredErrors` option in Manifest

* changelog
  • Loading branch information
lcian authored Feb 20, 2025
1 parent 883b995 commit 4c80d9e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
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)
}
}

0 comments on commit 4c80d9e

Please sign in to comment.