Skip to content

Commit

Permalink
Introduce MapTelemetry.getUserTelemetryRequestState API - MAPSAND-645 (
Browse files Browse the repository at this point in the history
…#1877)

* Introduce MapTelemetry.getTelemetryCollectionState API.

* Add JavaInterfaceChecker for the default function.

* Address review comments.
  • Loading branch information
pengdev committed Dec 2, 2022
1 parent 95f5557 commit ceafe03
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 16 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Mapbox welcomes participation and contributions from everyone.

# main

# 10.10.0
## Features ✨ and improvements 🏁
* Introduce `MapTelemetry.getUserTelemetryRequestState` API. ([1877](https://github.com/mapbox/mapbox-maps-android/pull/1877))

# 10.10.0-rc.1 November 18, 2022
## Features ✨ and improvements 🏁
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.AttributeSet;
import android.view.Surface;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.mapbox.android.gestures.AndroidGesturesManager;
import com.mapbox.android.gestures.MoveGestureDetector;
Expand Down Expand Up @@ -58,6 +59,7 @@
import com.mapbox.maps.extension.style.layers.properties.generated.IconAnchor;
import com.mapbox.maps.extension.style.types.Formatted;
import com.mapbox.maps.extension.style.types.FormattedSection;
import com.mapbox.maps.module.MapTelemetry;
import com.mapbox.maps.plugin.LocationPuck;
import com.mapbox.maps.plugin.LocationPuck2D;
import com.mapbox.maps.plugin.LocationPuck3D;
Expand Down Expand Up @@ -546,4 +548,37 @@ private void viewport(MapView mapView) {
}
});
}


private class CustomTelemetry implements MapTelemetry {
@Override
public void onAppUserTurnstileEvent() {

}

@Override
public void setUserTelemetryRequestState(boolean enabled) {

}

@Override
public void disableTelemetrySession() {

}

@Override
public void setDebugLoggingEnabled(boolean debugLoggingEnabled) {

}

@Override
public boolean setSessionIdRotationInterval(int interval) {
return false;
}

@Override
public void onPerformanceEvent(@Nullable Bundle data) {

}
}
}
9 changes: 5 additions & 4 deletions sdk-base/api/metalava.txt
Original file line number Diff line number Diff line change
Expand Up @@ -556,11 +556,12 @@ package com.mapbox.maps.module {

public interface MapTelemetry {
method public void disableTelemetrySession();
method public default boolean getUserTelemetryRequestState();
method public void onAppUserTurnstileEvent();
method public void onPerformanceEvent(android.os.Bundle? data);
method @Deprecated public void setDebugLoggingEnabled(boolean debugLoggingEnabled);
method @Deprecated public boolean setSessionIdRotationInterval(int interval);
method public void setUserTelemetryRequestState(boolean enabled);
method public void onPerformanceEvent(android.os.Bundle?);
method @Deprecated public void setDebugLoggingEnabled(boolean);
method @Deprecated public boolean setSessionIdRotationInterval(int);
method public void setUserTelemetryRequestState(boolean);
}

}
Expand Down
1 change: 1 addition & 0 deletions sdk-base/api/sdk-base.api
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ public abstract interface class com/mapbox/maps/extension/style/StyleInterface :

public abstract interface class com/mapbox/maps/module/MapTelemetry {
public abstract fun disableTelemetrySession ()V
public fun getUserTelemetryRequestState ()Z
public abstract fun onAppUserTurnstileEvent ()V
public abstract fun onPerformanceEvent (Landroid/os/Bundle;)V
public abstract fun setDebugLoggingEnabled (Z)V
Expand Down
Original file line number Diff line number Diff line change
@@ -1,52 +1,67 @@
package com.mapbox.maps.module
package com.mapbox.maps.module;

import android.os.Bundle
import android.os.Bundle;

import androidx.annotation.Nullable;

import com.mapbox.common.TelemetryUtils;

/**
* Definition of map telemetry
*/
interface MapTelemetry {
public interface MapTelemetry {

/**
* Register the app user turnstile event
*/
fun onAppUserTurnstileEvent()
void onAppUserTurnstileEvent();

/**
* Set the end-user selected state to participate or opt-out in telemetry collection.
*/
fun setUserTelemetryRequestState(enabled: Boolean)
void setUserTelemetryRequestState(boolean enabled);

/**
* Disables a started telemetry service for this session only.
*/
fun disableTelemetrySession()
void disableTelemetrySession();

/**
* Set the debug logging enabled states.
*
* @deprecated
* Note this method is deprecated, there will be no operations when it is called.
*
* @param debugLoggingEnabled whether to enable the debug logging for telemetry.
*/
@Deprecated("setDebugLoggingEnabled has been deprecated and will do no operations")
fun setDebugLoggingEnabled(debugLoggingEnabled: Boolean)
@Deprecated
void setDebugLoggingEnabled(boolean debugLoggingEnabled);

/**
* Set the telemetry rotation session id interval.
*
* @deprecated
* Note this method is deprecated, there will be no operations when it is called.
*
* @param interval the selected session interval
* @return true if rotation session id was updated
*/
@Deprecated("setSessionIdRotationInterval has been deprecated and will do no operations")
fun setSessionIdRotationInterval(interval: Int): Boolean
@Deprecated
boolean setSessionIdRotationInterval(int interval);

/**
* Register a performance event.
*
* @param data performance event data
*/
fun onPerformanceEvent(data: Bundle?)
void onPerformanceEvent(@Nullable Bundle data);

/**
* Get the end-user selected state to participate or opt-out in telemetry collection.
*
* @return true if end-user opted-in in telemetry collection, false otherwise.
*/
default boolean getUserTelemetryRequestState() {
return TelemetryUtils.getEventsCollectionState();
}
}

0 comments on commit ceafe03

Please sign in to comment.