Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e05136e
Send events with CoreTelemetry
tatiana-yan Aug 8, 2022
bc35279
initialize telemetry service publish_android_snapshot
tatiana-yan Aug 18, 2022
054a84d
Try to remove MME dependency and use core telemetry instead.
pengdev Sep 9, 2022
c10dbcb
Wire telemetry enable/disable API.
pengdev Sep 9, 2022
d3b7011
Fix MapLoadEvent.
pengdev Sep 13, 2022
8a7f662
Deprecate setDebugLoggingEnabled and setSessionIdRotationInterval, cl…
pengdev Sep 15, 2022
d54134a
Fix tests.
pengdev Sep 15, 2022
844bde8
Change MapTelemetryImpl.Compaion to private, update api files.
pengdev Sep 15, 2022
d45d00e
Adapt changes with common SDK fixes using build from source.
pengdev Sep 15, 2022
0aa0b0f
Update API files.
pengdev Sep 15, 2022
dc63240
Remove logging for LocationLayerWrapper
pengdev Sep 16, 2022
e4a001b
Remove READ_PHONE_STATE in the test app.
pengdev Sep 19, 2022
4fd76ab
Address review comments.
pengdev Sep 20, 2022
5dd509b
Remove mapboxAndroidTelemetry definition from project.
pengdev Sep 20, 2022
4ec29be
Remove EVENTS_ACCESS_TOKEN_RESOURCE_NAME and separate events access t…
pengdev Sep 20, 2022
ccf28e1
Fix MapTelemetryEventsServiceTest.
pengdev Sep 20, 2022
562ccca
Add change log.
pengdev Sep 20, 2022
524811a
Clean up comments.
pengdev Sep 20, 2022
831feb3
Make the test constructor of MapTelemetryImpl internal.
pengdev Sep 20, 2022
b49aa6b
Refactor MapTelemetryTest to test the constructor as well.
pengdev Sep 20, 2022
e563d9b
Fix location component tests.
pengdev Sep 20, 2022
09783c0
Log error message when mapload and turnstile event fails.
pengdev Sep 20, 2022
2e59afd
Improve unit test coverage.
pengdev Sep 20, 2022
b621078
Fix review comment.
pengdev Sep 20, 2022
4770501
Bring back api dependency to mapbox-android-core for location related…
pengdev Sep 21, 2022
f0dd566
Fix review comment.
pengdev Sep 21, 2022
b4408a9
Remove enableTelemetryCollection call during the MapTelemetryImpl con…
pengdev Sep 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we drop a note about known issues with bearing = 0 ?

Copy link
Member Author

Choose a reason for hiding this comment

The 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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package com.mapbox.maps.testapp.utils

import android.app.Activity
import android.widget.Toast
import com.mapbox.android.core.permissions.PermissionsListener
import com.mapbox.android.core.permissions.PermissionsManager
import com.mapbox.common.location.compat.permissions.PermissionsListener
import com.mapbox.common.location.compat.permissions.PermissionsManager
import java.lang.ref.WeakReference

class LocationPermissionHelper(val activity: WeakReference<Activity>) {
Expand Down
4 changes: 1 addition & 3 deletions buildSrc/src/main/kotlin/Project.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ object Dependencies {
const val mapboxCoreCommon = "com.mapbox.common:common:${Versions.mapboxCommon}"
const val mapboxOkHttp = "com.mapbox.common:okhttp:${Versions.mapboxCommon}"
const val mapboxAndroidCore = "com.mapbox.mapboxsdk:mapbox-android-core:${Versions.mapboxAndroidCore}"
const val mapboxAndroidTelemetry = "com.mapbox.mapboxsdk:mapbox-android-telemetry:${Versions.mapboxAndroidTelemetry}"
const val mapboxJavaTurf = "com.mapbox.mapboxsdk:mapbox-sdk-turf:${Versions.mapboxJavaServices}"
const val mapboxGestures = "com.mapbox.mapboxsdk:mapbox-android-gestures:${Versions.mapboxGestures}"
const val androidxAppCompat = "androidx.appcompat:appcompat:${Versions.androidxAppcompat}"
Expand Down Expand Up @@ -111,7 +110,6 @@ object Versions {
const val mapboxGlNative = "10.9.0-beta.1"
const val mapboxCommon = "23.1.0-beta.1"
const val mapboxAndroidCore = "5.0.2"
const val mapboxAndroidTelemetry = "8.1.5"
const val androidxCore = "1.7.0" // last version compatible with kotlin 1.5.31
const val androidxFragmentTesting = "1.5.0"
const val androidxAnnotation = "1.1.0"
Expand Down Expand Up @@ -146,4 +144,4 @@ object Versions {
const val detekt = "1.20.0"
const val compose = "1.1.0-beta03"
const val pluginPlayPublisher = "3.7.0"
}
}
5 changes: 2 additions & 3 deletions module-telemetry/api/metalava.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ package com.mapbox.maps.module.telemetry {

@com.mapbox.annotation.module.MapboxModule(type=com.mapbox.annotation.module.MapboxModuleType) public final class MapTelemetryImpl implements com.mapbox.maps.module.MapTelemetry {
ctor public MapTelemetryImpl(android.content.Context appContext, String accessToken);
ctor @VisibleForTesting public MapTelemetryImpl(com.mapbox.android.telemetry.MapboxTelemetry telemetry, android.content.Context appContext, String accessToken);
method public void disableTelemetrySession();
method public void onAppUserTurnstileEvent();
method public void onPerformanceEvent(android.os.Bundle? data);
method public void setDebugLoggingEnabled(boolean debugLoggingEnabled);
method public boolean setSessionIdRotationInterval(int interval);
method @Deprecated public void setDebugLoggingEnabled(boolean debugLoggingEnabled);
method @Deprecated public boolean setSessionIdRotationInterval(int interval);
method public void setUserTelemetryRequestState(boolean enabled);
}

Expand Down
1 change: 0 additions & 1 deletion module-telemetry/api/module-telemetry.api
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
public final class com/mapbox/maps/module/telemetry/MapTelemetryImpl : com/mapbox/maps/module/MapTelemetry {
public fun <init> (Landroid/content/Context;Ljava/lang/String;)V
public fun <init> (Lcom/mapbox/android/telemetry/MapboxTelemetry;Landroid/content/Context;Ljava/lang/String;)V
public fun disableTelemetrySession ()V
public fun onAppUserTurnstileEvent ()V
public fun onPerformanceEvent (Landroid/os/Bundle;)V
Expand Down
2 changes: 1 addition & 1 deletion module-telemetry/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ android {
dependencies {
implementation(project(":sdk-base"))
implementation(Dependencies.mapboxBase)
implementation(Dependencies.mapboxAndroidTelemetry)
compileOnly(Dependencies.mapboxAnnotations)
kapt(Dependencies.mapboxAnnotationsProcessor)
implementation(Dependencies.kotlin)
Expand All @@ -37,6 +36,7 @@ dependencies {
androidTestImplementation(Dependencies.androidxTestRunner)
androidTestImplementation(Dependencies.androidxJUnitTestRules)
androidTestImplementation(Dependencies.androidxEspresso)
androidTestImplementation(Dependencies.androidxTestJUnit)
detektPlugins(Dependencies.detektFormatting)
}

Expand Down
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
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package com.mapbox.maps.module.telemetry

import android.annotation.SuppressLint
import android.os.Parcel
import com.google.gson.annotations.SerializedName
import com.mapbox.android.telemetry.Event

/**
* Base event class for telemetry events.
*/
@SuppressLint("ParcelCreator")
internal abstract class MapBaseEvent(phoneState: PhoneState) :
Event() {
internal abstract class MapBaseEvent(phoneState: PhoneState) {
@SerializedName("event")
val event: String

Expand All @@ -23,10 +20,4 @@ internal abstract class MapBaseEvent(phoneState: PhoneState) :
}

abstract fun getEventName(): String

override fun describeContents(): Int {
return 0
}

override fun writeToParcel(dest: Parcel, flags: Int) {}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.mapbox.maps.module.telemetry

import android.os.Bundle
import com.mapbox.android.telemetry.TelemetryUtils
import com.mapbox.common.TelemetrySystemUtils

internal object MapEventFactory {
fun buildMapLoadEvent(phoneState: PhoneState): MapLoadEvent {
val userId = TelemetryUtils.retrieveVendorId()
val userId = TelemetrySystemUtils.obtainUniversalUniqueIdentifier()
return MapLoadEvent(userId, phoneState)
}

Expand Down
Loading