Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
ManifestMetadataReader now accepts integers other than floats
  • Loading branch information
stefanosiano committed Oct 25, 2024
commit 0707cf38b4f5a2f30c77e328dc01b2be252e0ea8
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ private static boolean readBool(
private static @NotNull Double readDouble(
final @NotNull Bundle metadata, final @NotNull ILogger logger, final @NotNull String key) {
// manifest meta-data only reads float
final Double value = ((Float) metadata.getFloat(key, -1)).doubleValue();
final Double value = ((Number) metadata.getFloat(key, metadata.getInt(key, -1))).doubleValue();
logger.log(SentryLevel.DEBUG, key + " read: " + value);
return value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1515,4 +1515,29 @@ class ManifestMetadataReaderTest {
assertTrue(fixture.options.experimental.sessionReplay.maskViewClasses.contains(SentryReplayOptions.IMAGE_VIEW_CLASS_NAME))
assertTrue(fixture.options.experimental.sessionReplay.maskViewClasses.contains(SentryReplayOptions.TEXT_VIEW_CLASS_NAME))
}

@Test
fun `applyMetadata reads integers even when expecting floats`() {
// Arrange
val expectedSampleRate: Int = 1

val bundle = bundleOf(
ManifestMetadataReader.SAMPLE_RATE to expectedSampleRate,
ManifestMetadataReader.TRACES_SAMPLE_RATE to expectedSampleRate,
ManifestMetadataReader.PROFILES_SAMPLE_RATE to expectedSampleRate,
ManifestMetadataReader.REPLAYS_SESSION_SAMPLE_RATE to expectedSampleRate,
ManifestMetadataReader.REPLAYS_ERROR_SAMPLE_RATE to expectedSampleRate
)
val context = fixture.getContext(metaData = bundle)

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

// Assert
assertEquals(expectedSampleRate.toDouble(), fixture.options.sampleRate)
assertEquals(expectedSampleRate.toDouble(), fixture.options.tracesSampleRate)
assertEquals(expectedSampleRate.toDouble(), fixture.options.profilesSampleRate)
assertEquals(expectedSampleRate.toDouble(), fixture.options.experimental.sessionReplay.sessionSampleRate)
assertEquals(expectedSampleRate.toDouble(), fixture.options.experimental.sessionReplay.onErrorSampleRate)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
<!-- <meta-data android:name="io.sentry.traces.sample-rate" android:value="0.8" /> -->

<!-- how to enable profiling when starting transactions -->
<meta-data android:name="io.sentry.traces.profiling.sample-rate" android:value="1.0" />
<meta-data android:name="io.sentry.traces.profiling.sample-rate" android:value="1" />

<!-- how to enable app start profiling -->
<meta-data android:name="io.sentry.traces.profiling.enable-app-start" android:value="true" />
Expand Down Expand Up @@ -165,7 +165,7 @@

<meta-data android:name="io.sentry.enable-metrics" android:value="true" />

<meta-data android:name="io.sentry.session-replay.session-sample-rate" android:value="1.0" />
<meta-data android:name="io.sentry.session-replay.session-sample-rate" android:value="1" />
<meta-data android:name="io.sentry.session-replay.mask-all-text" android:value="true" />
</application>
</manifest>
Loading