-
Notifications
You must be signed in to change notification settings - Fork 321
Don't send events if telemetry is disabled #6512
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
Changes from 5 commits
7521e3f
3a32b09
cba98ab
2d31b2a
d27578e
1497a1e
8113a69
f6b6626
000cefc
fa03557
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package com.mapbox.navigation.base.internal.metric | ||
|
|
||
| import com.mapbox.bindgen.Value | ||
|
|
||
| fun Value.extractEventsNames(): List<String>? = (this.contents as? List<Value>) | ||
| ?.mapNotNull { (it.contents as? Map<String, Value>)?.get("event")?.contents as? String } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,7 +114,6 @@ import com.mapbox.navigation.core.trip.session.eh.GraphAccessor | |
| import com.mapbox.navigation.core.trip.session.eh.RoadObjectMatcher | ||
| import com.mapbox.navigation.core.trip.session.eh.RoadObjectsStore | ||
| import com.mapbox.navigation.metrics.MapboxMetricsReporter | ||
| import com.mapbox.navigation.metrics.internal.TelemetryUtilsDelegate | ||
| import com.mapbox.navigation.navigator.internal.MapboxNativeNavigator | ||
| import com.mapbox.navigation.navigator.internal.NavigatorLoader | ||
| import com.mapbox.navigation.navigator.internal.router.RouterInterfaceAdapter | ||
|
|
@@ -506,23 +505,21 @@ class MapboxNavigation @VisibleForTesting internal constructor( | |
| ) | ||
|
|
||
| ifNonNull(accessToken) { token -> | ||
| runInTelemetryContext { telemetry -> | ||
| logD( | ||
| "MapboxMetricsReporter.init from MapboxNavigation main", | ||
| telemetry.LOG_CATEGORY | ||
| ) | ||
| MapboxMetricsReporter.init( | ||
| navigationOptions.applicationContext, | ||
| token, | ||
| obtainUserAgent() | ||
| ) | ||
| MapboxMetricsReporter.toggleLogging(navigationOptions.isDebugLoggingEnabled) | ||
| telemetry.initialize( | ||
| this, | ||
| navigationOptions, | ||
| MapboxMetricsReporter, | ||
| ) | ||
| } | ||
| logD( | ||
| "MapboxMetricsReporter.init from MapboxNavigation main", | ||
| MapboxNavigationTelemetry.LOG_CATEGORY | ||
| ) | ||
| MapboxMetricsReporter.init( | ||
|
||
| navigationOptions.applicationContext, | ||
| token, | ||
| obtainUserAgent() | ||
| ) | ||
| MapboxMetricsReporter.toggleLogging(navigationOptions.isDebugLoggingEnabled) | ||
| MapboxNavigationTelemetry.initialize( | ||
|
||
| this, | ||
| navigationOptions, | ||
| MapboxMetricsReporter, | ||
| ) | ||
| } | ||
|
|
||
| val routeOptionsProvider = RouteOptionsUpdater() | ||
|
|
@@ -1047,9 +1044,7 @@ class MapboxNavigation @VisibleForTesting internal constructor( | |
| historyRecordingStateHandler.unregisterAllStateChangeObservers() | ||
| historyRecordingStateHandler.unregisterAllCopilotSessionObservers() | ||
| developerMetadataAggregator.unregisterAllObservers() | ||
| runInTelemetryContext { telemetry -> | ||
| telemetry.destroy(this@MapboxNavigation) | ||
| } | ||
| MapboxNavigationTelemetry.destroy(this@MapboxNavigation) | ||
| threadController.cancelAllNonUICoroutines() | ||
| threadController.cancelAllUICoroutines() | ||
| ifNonNull(reachabilityObserverId) { | ||
|
|
@@ -1455,17 +1450,15 @@ class MapboxNavigation @VisibleForTesting internal constructor( | |
| feedbackMetadata: FeedbackMetadata?, | ||
| userFeedbackCallback: UserFeedbackCallback?, | ||
| ) { | ||
| runInTelemetryContext { telemetry -> | ||
| telemetry.postUserFeedback( | ||
| feedbackType, | ||
| description, | ||
| feedbackSource, | ||
| screenshot, | ||
| feedbackSubType, | ||
| feedbackMetadata, | ||
| userFeedbackCallback, | ||
| ) | ||
| } | ||
| MapboxNavigationTelemetry.postUserFeedback( | ||
| feedbackType, | ||
| description, | ||
| feedbackSource, | ||
| screenshot, | ||
| feedbackSubType, | ||
| feedbackMetadata, | ||
| userFeedbackCallback, | ||
| ) | ||
| } | ||
|
|
||
| @ExperimentalPreviewMapboxNavigationAPI | ||
|
|
@@ -1474,13 +1467,11 @@ class MapboxNavigation @VisibleForTesting internal constructor( | |
| @CustomEvent.Type customEventType: String, | ||
| customEventVersion: String, | ||
| ) { | ||
| runInTelemetryContext { telemetry -> | ||
| telemetry.postCustomEvent( | ||
| payload = payload, | ||
| customEventType = customEventType, | ||
| customEventVersion = customEventVersion | ||
| ) | ||
| } | ||
| MapboxNavigationTelemetry.postCustomEvent( | ||
| payload = payload, | ||
| customEventType = customEventType, | ||
| customEventVersion = customEventVersion | ||
| ) | ||
| } | ||
|
|
||
| /** | ||
|
|
@@ -1493,11 +1484,7 @@ class MapboxNavigation @VisibleForTesting internal constructor( | |
| */ | ||
| @ExperimentalPreviewMapboxNavigationAPI | ||
| fun provideFeedbackMetadataWrapper(): FeedbackMetadataWrapper = | ||
| runInTelemetryContext { telemetry -> | ||
| telemetry.provideFeedbackMetadataWrapper() | ||
| } ?: throw java.lang.IllegalStateException( | ||
| "To get FeedbackMetadataWrapper Telemetry must be enabled" | ||
| ) | ||
| MapboxNavigationTelemetry.provideFeedbackMetadataWrapper() | ||
|
|
||
| /** | ||
| * Start observing alternatives routes for a trip session via [RouteAlternativesObserver]. | ||
|
|
@@ -1773,14 +1760,6 @@ class MapboxNavigation @VisibleForTesting internal constructor( | |
| } | ||
| } | ||
|
|
||
| private inline fun <T> runInTelemetryContext(func: (MapboxNavigationTelemetry) -> T): T? { | ||
| return if (TelemetryUtilsDelegate.getEventsCollectionState()) { | ||
| func(MapboxNavigationTelemetry) | ||
| } else { | ||
| null | ||
| } | ||
| } | ||
|
|
||
| private fun obtainUserAgent(): String { | ||
| return "$MAPBOX_NAVIGATION_USER_AGENT_BASE/${BuildConfig.MAPBOX_NAVIGATION_VERSION_NAME}" | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.