RUMM-2076 Add the Configuration#setVitalsMonitorUpdateFrequency API#926
Conversation
c559098 to
7720585
Compare
| * Defines the frequency at which mobile vitals monitor updates the data. | ||
| */ | ||
| enum class VitalsUpdateFrequency( | ||
| internal val frequencyInMs: Long |
There was a problem hiding this comment.
This should be renamed periodInMs.
Frequency is measured in Hertz. The value in ms is the period (the inverse of frequency). E.g. for a period of 100ms, the frequency is 10 Hz.
| if (configuration.vitalsMonitorUpdateFrequency != VitalsUpdateFrequency.NEVER) { | ||
| initializeVitalMonitors(configuration.vitalsMonitorUpdateFrequency.frequencyInMs) | ||
| } |
There was a problem hiding this comment.
Two quick things, first of all, it'd make the onInitialize method easier to read if you'd call just
initializeVitalMonitors(configuration.vitalsMonitorUpdateFrequency)
and did the check just there. Also let's only extract the periodInMs when it's actually needed
There was a problem hiding this comment.
I had it like that in the first place, honestly was not sure which way would be better as doing the check in the method means a premature return, sometimes I like to avoid this. But yeah, I think it looks cleaner like that.
| fun `M use the given frequency W setVitalsMonitorUpdateFrequency`(forge: Forge) { | ||
| // Given | ||
| val fakeFrequency = forge.aValueFrom(VitalsUpdateFrequency::class.java) | ||
|
|
There was a problem hiding this comment.
| fun `M use the given frequency W setVitalsMonitorUpdateFrequency`(forge: Forge) { | |
| // Given | |
| val fakeFrequency = forge.aValueFrom(VitalsUpdateFrequency::class.java) | |
| fun `M use the given frequency W setVitalsMonitorUpdateFrequency`( | |
| @Forgery fakeFrequency: VitalsUpdateFrequency | |
| ) { |
|
|
||
| @Test | ||
| fun `𝕄 setup vital monitors 𝕎 initialize()`() { | ||
| fun `𝕄 setup vital monitors 𝕎 initialize { frequency != NEVER }`(forge: Forge) { |
There was a problem hiding this comment.
@ParameterizedTest
@EnumSource(VitalsUpdateFrequency::class, names = ["NEVER"], mode = EnumSource.Mode.EXCLUDE)
fun `𝕄 setup vital monitors 𝕎 initialize { frequency != NEVER }`(fakeFrequency: VitalsUpdateFrequency) {
…
)
There was a problem hiding this comment.
Yeah...make sense to have a parameterized test here instead.
|
|
||
| @Test | ||
| fun `𝕄 initialize vital executor 𝕎 initialize()`() { | ||
| fun `𝕄 initialize vital executor 𝕎 initialize { frequency != NEVER }()`(forge: Forge) { |
There was a problem hiding this comment.
@ParameterizedTest
@EnumSource(VitalsUpdateFrequency::class, names = ["NEVER"], mode = EnumSource.Mode.EXCLUDE)
fun `𝕄 initialize vital executor 𝕎 initialize { frequency != NEVER }`(fakeFrequency: VitalsUpdateFrequency) {
…
)
| rumEventMapper = NoOpEventMapper(), | ||
| backgroundEventTracking = false | ||
| backgroundEventTracking = false, | ||
| vitalsMonitorUpdateFrequency = VitalsUpdateFrequency.AVERAGE |
There was a problem hiding this comment.
so we are moving from 100 ms to 500 ms by default?
There was a problem hiding this comment.
Yeah, that was the agreement :)
7720585 to
a835ed6
Compare
Codecov Report
@@ Coverage Diff @@
## develop #926 +/- ##
===========================================
- Coverage 82.86% 82.76% -0.10%
===========================================
Files 263 265 +2
Lines 8977 9006 +29
Branches 1449 1449
===========================================
+ Hits 7438 7453 +15
- Misses 1144 1159 +15
+ Partials 395 394 -1
|
|
|
||
| @AfterEach | ||
| fun `stop RUM`() { | ||
| RumFeature.stop() |
There was a problem hiding this comment.
I think it is not needed, because parent class SdkFeatureTest will do a call to the testedFeature#stop
| * @param frequency as [VitalsUpdateFrequency] | ||
| * @see [VitalsUpdateFrequency] | ||
| */ | ||
| fun setVitalsUpdateFrequency(frequency: VitalsUpdateFrequency): Builder { |
There was a problem hiding this comment.
We need to add the E2E test for this one.
There was a problem hiding this comment.
Good point, I will add a task for this.
9983485 to
d0feae5
Compare
| vitalReader: VitalReader, | ||
| vitalObserver: VitalObserver | ||
| vitalObserver: VitalObserver, | ||
| updateFrequencyInMs: Long |
There was a problem hiding this comment.
This should be named periodInMs too
d0feae5 to
b63545e
Compare
What does this PR do?
In this PR we are introduce a new API :
ConfigurationBuilder.setVitalsUpdateFrequency(frequency)where the frequency is an enum :This will allow the client to customise the update frequency for mobile vitals reader or disable this feature.
Motivation
What inspired you to submit this pull request?
Additional Notes
Anything else we should know when reviewing?
Review checklist (to be filled by reviewers)