Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- `count`: A metric that increments counts
- `gauge`: A metric that tracks a value that can go up or down
- `distribution`: A metric that tracks the statistical distribution of values
- Added `io.sentry.ndk.sdk-name` Android manifest option to configure the native SDK's name ([#5027](https://github.com/getsentry/sentry-java/pull/5027))

## 8.29.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ final class ManifestMetadataReader {
static final String AUTO_INIT = "io.sentry.auto-init";
static final String NDK_ENABLE = "io.sentry.ndk.enable";
static final String NDK_SCOPE_SYNC_ENABLE = "io.sentry.ndk.scope-sync.enable";
static final String NDK_SDK_NAME = "io.sentry.ndk.sdk-name";
static final String RELEASE = "io.sentry.release";
static final String ENVIRONMENT = "io.sentry.environment";
static final String SDK_NAME = "io.sentry.sdk.name";
Expand Down Expand Up @@ -252,6 +253,12 @@ static void applyMetadata(
options.setEnableScopeSync(
readBool(metadata, logger, NDK_SCOPE_SYNC_ENABLE, options.isEnableScopeSync()));

final @Nullable String nativeSdkName =
readString(metadata, logger, NDK_SDK_NAME, options.getNativeSdkName());
if (nativeSdkName != null) {
options.setNativeSdkName(nativeSdkName);
}

options.setRelease(readString(metadata, logger, RELEASE, options.getRelease()));

options.setEnvironment(readString(metadata, logger, ENVIRONMENT, options.getEnvironment()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,32 @@ class ManifestMetadataReaderTest {
assertTrue(fixture.options.isEnableScopeSync)
}

@Test
fun `applyMetadata reads nativeSdkName to options`() {
// Arrange
val expectedValue = "sentry.native.android.unity"
val bundle = bundleOf(ManifestMetadataReader.NDK_SDK_NAME to expectedValue)
val context = fixture.getContext(metaData = bundle)

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

// Assert
assertEquals(expectedValue, fixture.options.nativeSdkName)
}

@Test
fun `applyMetadata reads nativeSdkName and keeps default`() {
// Arrange
val context = fixture.getContext()

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

// Assert
assertNull(fixture.options.nativeSdkName)
}

@Test
fun `applyMetadata reads tracesSampleRate from metadata`() {
// Arrange
Expand Down
Loading