Skip to content
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

Introduce MapTelemetry.getUserTelemetryRequestState API - MAPSAND-645 #1877

Merged
merged 3 commits into from
Dec 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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?);
pengdev marked this conversation as resolved.
Show resolved Hide resolved
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 {
Copy link
Member Author

Choose a reason for hiding this comment

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

Note that MapTelemetry interface is rewritten in Java: for more context in #1670 (comment), as we want to make the default interface backwards-compatible with Java, writing default method with @JvmDefault in Kotlin will require -Xjvm-default compiler option.

As summarised by @kmadsen

The -Xjvm-default compiler flag may do what we want in the future. But right now, it does not generate default interfaces in an SDK. The app developer has to include the flag in their app to make the app compile when it uses an sdk that is relying on the flag.


/**
* 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();
}
}