[android] - expose public api telemetry (#11503)
This commit is contained in:
@@ -10,7 +10,7 @@ import android.text.TextUtils;
|
||||
|
||||
import com.mapbox.mapboxsdk.constants.MapboxConstants;
|
||||
import com.mapbox.mapboxsdk.exceptions.MapboxConfigurationException;
|
||||
import com.mapbox.mapboxsdk.maps.Events;
|
||||
import com.mapbox.mapboxsdk.maps.Telemetry;
|
||||
import com.mapbox.mapboxsdk.net.ConnectivityReceiver;
|
||||
|
||||
/**
|
||||
@@ -46,7 +46,7 @@ public final class Mapbox {
|
||||
Context appContext = context.getApplicationContext();
|
||||
INSTANCE = new Mapbox(appContext, accessToken);
|
||||
|
||||
Events.initialize();
|
||||
Telemetry.initialize();
|
||||
ConnectivityReceiver.instance(appContext);
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,7 @@ public class AttributionDialogManager implements View.OnClickListener, DialogInt
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
TelemetryEnabler.updateTelemetryState(TelemetryEnabler.State.ENABLED);
|
||||
Events.obtainTelemetry().enable();
|
||||
Telemetry.obtainTelemetry().enable();
|
||||
dialog.cancel();
|
||||
}
|
||||
});
|
||||
@@ -114,7 +114,7 @@ public class AttributionDialogManager implements View.OnClickListener, DialogInt
|
||||
builder.setNegativeButton(R.string.mapbox_attributionTelemetryNegative, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Events.obtainTelemetry().disable();
|
||||
Telemetry.obtainTelemetry().disable();
|
||||
TelemetryEnabler.updateTelemetryState(TelemetryEnabler.State.DISABLED);
|
||||
dialog.cancel();
|
||||
}
|
||||
|
||||
@@ -344,7 +344,7 @@ final class MapGestureDetector {
|
||||
notifyOnMapClickListeners(tapPoint);
|
||||
}
|
||||
|
||||
sendTelemetryEvent(Events.SINGLE_TAP, new PointF(motionEvent.getX(), motionEvent.getY()));
|
||||
sendTelemetryEvent(Telemetry.SINGLE_TAP, new PointF(motionEvent.getX(), motionEvent.getY()));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -375,7 +375,7 @@ final class MapGestureDetector {
|
||||
|
||||
zoomInAnimated(zoomFocalPoint, false);
|
||||
|
||||
sendTelemetryEvent(Events.DOUBLE_TAP, new PointF(motionEvent.getX(), motionEvent.getY()));
|
||||
sendTelemetryEvent(Telemetry.DOUBLE_TAP, new PointF(motionEvent.getX(), motionEvent.getY()));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -439,7 +439,7 @@ final class MapGestureDetector {
|
||||
transform.cancelTransitions();
|
||||
cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE);
|
||||
|
||||
sendTelemetryEvent(Events.PAN, detector.getFocalPoint());
|
||||
sendTelemetryEvent(Telemetry.PAN, detector.getFocalPoint());
|
||||
|
||||
notifyOnMoveBeginListeners(detector);
|
||||
|
||||
@@ -504,7 +504,7 @@ final class MapGestureDetector {
|
||||
// setting focalPoint in #onScaleBegin() as well, because #onScale() might not get called before #onScaleEnd()
|
||||
setScaleFocalPoint(detector);
|
||||
|
||||
sendTelemetryEvent(Events.PINCH, scaleFocalPoint);
|
||||
sendTelemetryEvent(Telemetry.PINCH, scaleFocalPoint);
|
||||
|
||||
notifyOnScaleBeginListeners(detector);
|
||||
|
||||
@@ -626,7 +626,7 @@ final class MapGestureDetector {
|
||||
// setting in #onRotateBegin() as well, because #onRotate() might not get called before #onRotateEnd()
|
||||
setRotateFocalPoint(detector);
|
||||
|
||||
sendTelemetryEvent(Events.ROTATION, rotateFocalPoint);
|
||||
sendTelemetryEvent(Telemetry.ROTATION, rotateFocalPoint);
|
||||
|
||||
notifyOnRotateBeginListeners(detector);
|
||||
|
||||
@@ -744,7 +744,7 @@ final class MapGestureDetector {
|
||||
transform.cancelTransitions();
|
||||
cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE);
|
||||
|
||||
sendTelemetryEvent(Events.PITCH, detector.getFocalPoint());
|
||||
sendTelemetryEvent(Telemetry.PITCH, detector.getFocalPoint());
|
||||
|
||||
// disabling move gesture during shove
|
||||
gesturesManager.getMoveGestureDetector().setEnabled(false);
|
||||
@@ -793,7 +793,7 @@ final class MapGestureDetector {
|
||||
transform.cancelTransitions();
|
||||
cameraChangeDispatcher.onCameraMoveStarted(REASON_API_GESTURE);
|
||||
|
||||
sendTelemetryEvent(Events.TWO_FINGER_TAP, detector.getFocalPoint());
|
||||
sendTelemetryEvent(Telemetry.TWO_FINGER_TAP, detector.getFocalPoint());
|
||||
|
||||
PointF zoomFocalPoint;
|
||||
// Single finger double tap
|
||||
@@ -890,7 +890,7 @@ final class MapGestureDetector {
|
||||
LatLng latLng = projection.fromScreenLocation(focalPoint);
|
||||
MapState state = new MapState(latLng.getLatitude(), latLng.getLongitude(), transform.getZoom());
|
||||
state.setGesture(eventType);
|
||||
Events.obtainTelemetry().push(mapEventFactory.createMapGestureEvent(Event.Type.MAP_CLICK, state));
|
||||
Telemetry.obtainTelemetry().push(mapEventFactory.createMapGestureEvent(Event.Type.MAP_CLICK, state));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -268,7 +268,7 @@ public class MapView extends FrameLayout {
|
||||
@UiThread
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
if (savedInstanceState == null) {
|
||||
MapboxTelemetry telemetry = Events.obtainTelemetry();
|
||||
MapboxTelemetry telemetry = Telemetry.obtainTelemetry();
|
||||
AppUserTurnstile turnstileEvent = new AppUserTurnstile(BuildConfig.MAPBOX_SDK_IDENTIFIER,
|
||||
BuildConfig.MAPBOX_SDK_VERSION);
|
||||
telemetry.push(turnstileEvent);
|
||||
|
||||
@@ -2,11 +2,12 @@ package com.mapbox.mapboxsdk.maps;
|
||||
|
||||
|
||||
import com.mapbox.android.telemetry.MapboxTelemetry;
|
||||
import com.mapbox.android.telemetry.SessionInterval;
|
||||
import com.mapbox.android.telemetry.TelemetryEnabler;
|
||||
import com.mapbox.mapboxsdk.BuildConfig;
|
||||
import com.mapbox.mapboxsdk.Mapbox;
|
||||
|
||||
public class Events {
|
||||
public class Telemetry {
|
||||
static final String TWO_FINGER_TAP = "TwoFingerTap";
|
||||
static final String DOUBLE_TAP = "DoubleTap";
|
||||
static final String SINGLE_TAP = "SingleTap";
|
||||
@@ -16,7 +17,7 @@ public class Events {
|
||||
static final String PITCH = "Pitch";
|
||||
private MapboxTelemetry telemetry;
|
||||
|
||||
private Events() {
|
||||
private Telemetry() {
|
||||
telemetry = new MapboxTelemetry(Mapbox.getApplicationContext(), Mapbox.getAccessToken(),
|
||||
BuildConfig.MAPBOX_EVENTS_USER_AGENT);
|
||||
TelemetryEnabler.State telemetryState = TelemetryEnabler.retrieveTelemetryStateFromPreferences();
|
||||
@@ -29,11 +30,19 @@ public class Events {
|
||||
obtainTelemetry();
|
||||
}
|
||||
|
||||
private static class EventsHolder {
|
||||
private static final Events INSTANCE = new Events();
|
||||
public static void updateDebugLoggingEnabled(boolean debugLoggingEnabled) {
|
||||
TelemetryHolder.INSTANCE.telemetry.updateDebugLoggingEnabled(debugLoggingEnabled);
|
||||
}
|
||||
|
||||
public static boolean updateSessionIdRotationInterval(SessionInterval interval) {
|
||||
return TelemetryHolder.INSTANCE.telemetry.updateSessionIdRotationInterval(interval);
|
||||
}
|
||||
|
||||
private static class TelemetryHolder {
|
||||
private static final Telemetry INSTANCE = new Telemetry();
|
||||
}
|
||||
|
||||
static MapboxTelemetry obtainTelemetry() {
|
||||
return EventsHolder.INSTANCE.telemetry;
|
||||
return TelemetryHolder.INSTANCE.telemetry;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user