From cb08bf833ddb882f816b2480e7f621f9a391f56c Mon Sep 17 00:00:00 2001 From: Yury Kanetski Date: Mon, 27 Feb 2023 21:16:45 +0100 Subject: [PATCH] try to disable event service for the SDK --- .../metrics/MapboxMetricsReporter.kt | 36 +++++++++---------- .../metrics/events/TelemetryEventsProvider.kt | 2 +- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/libnavigation-metrics/src/main/java/com/mapbox/navigation/metrics/MapboxMetricsReporter.kt b/libnavigation-metrics/src/main/java/com/mapbox/navigation/metrics/MapboxMetricsReporter.kt index e2ef33a7934..8fb55cda7f8 100644 --- a/libnavigation-metrics/src/main/java/com/mapbox/navigation/metrics/MapboxMetricsReporter.kt +++ b/libnavigation-metrics/src/main/java/com/mapbox/navigation/metrics/MapboxMetricsReporter.kt @@ -36,7 +36,7 @@ object MapboxMetricsReporter : MetricsReporter { private const val LOG_CATEGORY = "MapboxMetricsReporter" private val gson = Gson() - private lateinit var eventsManager: EventsServiceInterfacesManager +// private lateinit var eventsManager: EventsServiceInterfacesManager private lateinit var telemetryService: TelemetryService @Volatile @@ -86,10 +86,10 @@ object MapboxMetricsReporter : MetricsReporter { userAgent: String ) { isTelemetryInitialized = true - eventsManager = TelemetryEventsProvider.getOrCreateTelemetryEventsManager(accessToken) +// eventsManager = TelemetryEventsProvider.getOrCreateTelemetryEventsManager(accessToken) val eventsServerOptions = EventsServerOptions(accessToken, userAgent, null) telemetryService = TelemetryServiceProvider.provideTelemetryService(eventsServerOptions) - eventsManager.nativeEventsServiceInterface.registerObserver(eventsServiceObserver) +// eventsManager.nativeEventsServiceInterface.registerObserver(eventsServiceObserver) } /** @@ -111,7 +111,7 @@ object MapboxMetricsReporter : MetricsReporter { fun disable() { isTelemetryInitialized = false removeObserver() - eventsManager.nativeEventsServiceInterface.unregisterObserver(eventsServiceObserver) +// eventsManager.nativeEventsServiceInterface.unregisterObserver(eventsServiceObserver) ioJobController.job.cancelChildren() } @@ -127,13 +127,13 @@ object MapboxMetricsReporter : MetricsReporter { ) return } - eventsManager.nativeEventsServiceInterface.sendEvent( - Event(eventsPriority, metricEvent.toValue(), null) - ) { - if (it != null) { - logE("Failed to send event ${metricEvent.metricName}: $it", LOG_CATEGORY) - } - } +// eventsManager.nativeEventsServiceInterface.sendEvent( +// Event(eventsPriority, metricEvent.toValue(), null) +// ) { +// if (it != null) { +// logE("Failed to send event ${metricEvent.metricName}: $it", LOG_CATEGORY) +// } +// } ioJobController.scope.launch { metricsObserver?.onMetricUpdated(metricEvent.metricName, metricEvent.toJson(gson)) @@ -146,11 +146,11 @@ object MapboxMetricsReporter : MetricsReporter { */ override fun sendTurnstileEvent(turnstileEvent: TurnstileEvent) { ifTelemetryIsRunning { - eventsManager.nativeEventsServiceInterface.sendTurnstileEvent(turnstileEvent) { - if (it != null) { - logE("Failed to send Turnstile event: $it", LOG_CATEGORY) - } - } +// eventsManager.nativeEventsServiceInterface.sendTurnstileEvent(turnstileEvent) { +// if (it != null) { +// logE("Failed to send Turnstile event: $it", LOG_CATEGORY) +// } +// } } } @@ -172,14 +172,14 @@ object MapboxMetricsReporter : MetricsReporter { * Register [EventsServiceObserver] */ fun registerEventsServiceObserver(observer: EventsServiceObserver) { - eventsManager.nativeEventsServiceInterface.registerObserver(observer) +// eventsManager.nativeEventsServiceInterface.registerObserver(observer) } /** * Unregister [EventsServiceObserver] */ fun unregisterEventsServiceObserver(observer: EventsServiceObserver) { - eventsManager.nativeEventsServiceInterface.unregisterObserver(observer) +// eventsManager.nativeEventsServiceInterface.unregisterObserver(observer) } private inline fun ifTelemetryIsRunning(func: () -> Unit) { diff --git a/libnavigation-metrics/src/main/java/com/mapbox/navigation/metrics/events/TelemetryEventsProvider.kt b/libnavigation-metrics/src/main/java/com/mapbox/navigation/metrics/events/TelemetryEventsProvider.kt index b9645feb86d..faa10cb5731 100644 --- a/libnavigation-metrics/src/main/java/com/mapbox/navigation/metrics/events/TelemetryEventsProvider.kt +++ b/libnavigation-metrics/src/main/java/com/mapbox/navigation/metrics/events/TelemetryEventsProvider.kt @@ -4,7 +4,7 @@ import com.mapbox.common.EventsServerOptions import com.mapbox.common.EventsService object TelemetryEventsProvider { - fun getOrCreateTelemetryEventsManager(accessToken: String): EventsServiceInterfacesManager = + fun getOrCreateEventsServiceInterfacesManager(accessToken: String): EventsServiceInterfacesManager = EventsServiceInterfacesManager( EventsService.getOrCreate( EventsServerOptions(accessToken, "MapboxNavigationNative", null)