-
Notifications
You must be signed in to change notification settings - Fork 319
Dynamic telemetry initialisation/deinitialisation based on user preferences #7755
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
ChangelogFeatures
Bug fixes and improvements
Known issues
|
| navigationOptions: NavigationOptions, | ||
| userAgent: String | ||
| ) { | ||
| check(!isWrapperInitialized) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really want to crash here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really want to crash here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
libnavigation-core/src/main/java/com/mapbox/navigation/core/telemetry/TelemetryWrapper.kt
Outdated
Show resolved
Hide resolved
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed in order to provide mocked TelemetryWrapper for unit tests.
libnavigation-util/src/main/java/com/mapbox/navigation/utils/internal/Assertions.kt
Outdated
Show resolved
Hide resolved
libnavigation-core/src/main/java/com/mapbox/navigation/core/telemetry/TelemetryWrapper.kt
Outdated
Show resolved
Hide resolved
7860fdb to
8ec962f
Compare
8ec962f to
0804ae7
Compare
| this.userAgent = userAgent | ||
|
|
||
| if (TelemetryUtilsDelegate.getEventsCollectionState()) { | ||
| initializeSdkTelemetry() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.