Dynamic telemetry initialisation/deinitialisation based on user preferences - #7755
Conversation
ChangelogFeatures
Bug fixes and improvements
Known issues
|
| navigationOptions: NavigationOptions, | ||
| userAgent: String | ||
| ) { | ||
| check(!isWrapperInitialized) { |
There was a problem hiding this comment.
Do we really want to crash here?
There was a problem hiding this comment.
I don't have a strong opinion on this.
If we just return here (without crashing) in case of repeated initialisation, we might skip another issue which caused doubled initialisation. At the same time I don't think the current solution is the best.
I think we could crash only for debug builds, but this practice is not common in our project now. WDYT about the following approach?
if (isWrapperInitialized) {
if (BuildConfig.DEBUG) {
error("Already initialized")
} else {
return
}
}
There was a problem hiding this comment.
Yes, this is nice, but maybe let's not if it, but introduce an utility assert method that will only crash in debug. By the way, isn't there already something like that?
There was a problem hiding this comment.
By the way, isn't there already something like that?
I haven't found anything like that. I've added check and failing only in debug builds
| } | ||
|
|
||
| fun destroy() { | ||
| check(isWrapperInitialized) { |
There was a problem hiding this comment.
Do we really want to crash here?
There was a problem hiding this comment.
Let's discuss it here and I'll fix this place as well, if case of need.
| private var isTelemetryEnabled = false | ||
|
|
||
| private val telemetryStateObserver = TelemetryStateWatcher.Observer { isEnabled -> | ||
| if (!isTelemetryEnabled && isEnabled) { |
There was a problem hiding this comment.
Don't we also have to take isWrapperInitialized flag into account? I mean we shouldn't invoke initializeSdkTelemetry if we hadn't invoked initialize beforehand, right?
There was a problem hiding this comment.
It's not obvious but isTelemetryEnabled can be true only if TelemetryWrapper is initialised. Similary, TelemetryStateWatcher.Observer can be triggered at all only if class is initialised.
I don't like this much, but given that it's incapsulated in one class, it seems to be ok.
Codecov ReportAttention: Patch coverage is
@@ Coverage Diff @@
## main #7755 +/- ##
============================================
+ Coverage 74.12% 74.15% +0.03%
- Complexity 6252 6263 +11
============================================
Files 852 855 +3
Lines 33705 33757 +52
Branches 4012 4021 +9
============================================
+ Hits 24983 25033 +50
+ Misses 7172 7166 -6
- Partials 1550 1558 +8
|
e7d193a to
ab337f5
Compare
| return mapboxNavigation!! | ||
| } | ||
|
|
||
| @VisibleForTesting |
There was a problem hiding this comment.
This is needed in order to provide mocked TelemetryWrapper for unit tests.
7860fdb to
8ec962f
Compare
8ec962f to
0804ae7
Compare
| this.userAgent = userAgent | ||
|
|
||
| if (TelemetryUtilsDelegate.getEventsCollectionState()) { | ||
| initializeSdkTelemetry() |
There was a problem hiding this comment.
Hmm, what if someone disables the telemetry at runtime? Should we stop sending events? It's not supported now, right?
There was a problem hiding this comment.
Yes, right, nothing changes here comparing to older SDK versions. It's not that easy to solve the issue you described beucase we might end up with incomplete telemetry events (for example, departure event witout arrival). We'll have to solve this later.
…rences (#7755) * Dynamic telemetry initialisation/deinitialisation based on user preference * Fix tests * TODO issue; Changelog * Fail only in debug mode * Don't observe telemetry state changes for now * Address PR comments; Add tests
…rences (#7755) * Dynamic telemetry initialisation/deinitialisation based on user preference * Fix tests * TODO issue; Changelog * Fail only in debug mode * Don't observe telemetry state changes for now * Address PR comments; Add tests
* Dynamic telemetry initialisation/deinitialisation based on user preferences (#7755) * Dynamic telemetry initialisation/deinitialisation based on user preference * Fix tests * TODO issue; Changelog * Fail only in debug mode * Don't observe telemetry state changes for now * Address PR comments; Add tests * Rename changelog file
Description
https://mapbox.atlassian.net/browse/NAVAND-1795
Fixed a crash that can happen when user dynamically changes telemetry collection preferences.