-
Notifications
You must be signed in to change notification settings - Fork 151
Integrate core telemetry - MAPSAND-244 #1672
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 all commits
e05136e
bc35279
054a84d
c10dbcb
d3b7011
8a7f662
d54134a
844bde8
d45d00e
0aa0b0f
dc63240
e4a001b
4fd76ab
5dd509b
4ec29be
ccf28e1
562ccca
524811a
831feb3
b49aa6b
e563d9b
09783c0
2e59afd
b621078
4770501
f0dd566
b4408a9
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 |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ Mapbox welcomes participation and contributions from everyone. | |
| * Vector tiles without symbols are not hold for fade-out animation so that less amount of vector tiles are managed at a time. ([1679](https://github.com/mapbox/mapbox-maps-android/pull/1679)) | ||
| * Add support to set location puck opacity. ([1659](https://github.com/mapbox/mapbox-maps-android/pull/1659)) | ||
| * Support `pitch` and `distanceFromCenter` filters in symbol layers. ([1662](https://github.com/mapbox/mapbox-maps-android/pull/1662)) | ||
| * Migrated telemetry APIs from [mobile-events-android](https://github.com/mapbox/mapbox-events-android) to common SDK implementation. ([1672](https://github.com/mapbox/mapbox-maps-android/pull/1672)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we drop a note about known issues with bearing = 0 ?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we ever linked known issues to the change log, we will patch the issue shortly in beta.2 or rc release. |
||
|
|
||
| ## Bug fixes 🐞 | ||
| * Fix scale bar truncated at high zoom levels near the poles. ([1620](https://github.com/mapbox/mapbox-maps-android/pull/1620)) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package com.mapbox.maps.module.telemetry | ||
|
|
||
| import com.mapbox.bindgen.ExpectedFactory | ||
| import com.mapbox.common.* | ||
| import java.lang.RuntimeException | ||
| import java.util.concurrent.atomic.AtomicLong | ||
|
|
||
| class DummyHttpClient : HttpServiceInterface { | ||
| private val requestId = AtomicLong(0) | ||
|
|
||
| override fun setMaxRequestsPerHost(max: Byte) {} | ||
|
|
||
| override fun setInterceptor(interceptor: HttpServiceInterceptorInterface?) {} | ||
|
|
||
| override fun download(options: DownloadOptions, callback: DownloadStatusCallback): Long { | ||
| throw RuntimeException("no impl") | ||
| } | ||
|
|
||
| override fun cancelRequest(id: Long, callback: ResultCallback) {} | ||
|
|
||
| override fun request(request: HttpRequest, callback: HttpResponseCallback): Long { | ||
| val headers = HashMap<String, String>() | ||
| var data = ByteArray(0) | ||
| val resultData = HttpResponseData(headers, 200, data) | ||
| val response = HttpResponse(request, ExpectedFactory.createValue(resultData)) | ||
| callback.run(response) | ||
| return requestId.incrementAndGet() | ||
| } | ||
|
|
||
| override fun supportsKeepCompression(): Boolean { | ||
| return false | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| package com.mapbox.maps.module.telemetry | ||
|
|
||
| import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
| import androidx.test.platform.app.InstrumentationRegistry | ||
| import com.mapbox.bindgen.Value | ||
| import com.mapbox.common.* | ||
| import org.junit.Assert | ||
| import org.junit.Before | ||
| import org.junit.Test | ||
| import org.junit.runner.RunWith | ||
| import java.util.concurrent.CountDownLatch | ||
| import java.util.concurrent.TimeUnit | ||
| import java.util.concurrent.TimeoutException | ||
|
|
||
| @RunWith(AndroidJUnit4::class) | ||
| class MapTelemetryEventsServiceTest { | ||
| private lateinit var eventsService: EventsService | ||
| private lateinit var telemetry: MapTelemetryImpl | ||
|
|
||
| @Before | ||
| fun setUp() { | ||
| HttpServiceFactory.setUserDefined(DummyHttpClient()) | ||
| val context = InstrumentationRegistry.getInstrumentation().context | ||
|
|
||
| val options = EventsServerOptions("empty", "empty", null) | ||
| eventsService = EventsService.getOrCreate(options) | ||
| val telemetryService = TelemetryService.getOrCreate(options) | ||
|
|
||
| telemetry = MapTelemetryImpl(context, "sk.foobar", eventsService, telemetryService) | ||
| } | ||
|
|
||
| @Test | ||
| fun testSetUserTelemetryRequestStateDisabled() { | ||
| telemetry.setUserTelemetryRequestState(false) | ||
| Assert.assertFalse(TelemetryUtils.getEventsCollectionState()) | ||
| } | ||
|
|
||
| @Test | ||
| fun testSetUserTelemetryRequestStateEnabled() { | ||
| telemetry.setUserTelemetryRequestState(true) | ||
| Assert.assertTrue(TelemetryUtils.getEventsCollectionState()) | ||
| } | ||
|
|
||
| @Test | ||
| fun testDisableTelemetrySession() { | ||
| telemetry.disableTelemetrySession() | ||
| val latch = CountDownLatch(1) | ||
| val eventsServiceObserver = object : EventsServiceObserver { | ||
| override fun didEncounterError(error: EventsServiceError, events: Value) { | ||
| latch.countDown() | ||
| } | ||
|
|
||
| override fun didSendEvents(events: Value) { | ||
| } | ||
| } | ||
|
|
||
| eventsService.registerObserver(eventsServiceObserver) | ||
| for (i in 0 until TEST_ITERATIONS) { | ||
| telemetry.onPerformanceEvent(null) | ||
| } | ||
|
|
||
| if (!latch.await(10000, TimeUnit.MILLISECONDS)) { | ||
| throw TimeoutException() | ||
| } | ||
|
|
||
| eventsService.unregisterObserver(eventsServiceObserver) | ||
| TelemetryUtils.setEventsCollectionState(true) { } | ||
| } | ||
|
|
||
| @Test | ||
| @Throws(InterruptedException::class, TimeoutException::class) | ||
| fun testPerformanceEvent() { | ||
| telemetry.setUserTelemetryRequestState(true) | ||
| val latch = CountDownLatch(1) | ||
| val eventsServiceObserver = object : EventsServiceObserver { | ||
| override fun didEncounterError(error: EventsServiceError, events: Value) { | ||
| } | ||
|
|
||
| override fun didSendEvents(events: Value) { | ||
| latch.countDown() | ||
| } | ||
| } | ||
|
|
||
| eventsService.registerObserver(eventsServiceObserver) | ||
| for (i in 0 until TEST_ITERATIONS) { | ||
| telemetry.onPerformanceEvent(null) | ||
| } | ||
|
|
||
| if (!latch.await(10000, TimeUnit.MILLISECONDS)) { | ||
| throw TimeoutException() | ||
| } | ||
|
|
||
| eventsService.unregisterObserver(eventsServiceObserver) | ||
| } | ||
|
|
||
| companion object { | ||
| private const val TEST_ITERATIONS = 190 | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.