Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public class MapboxTelemetry implements Callback, LocationEngineListener {
protected CopyOnWriteArrayList<TelemetryListener> telemetryListeners;
private Hashtable<String, Object> customTurnstileEvent = null;
private int sessionIdRotationTime = TelemetryConstants.DEFAULT_SESSION_ID_ROTATION_HOURS;
private boolean debugLoggingEnabled = false;

/**
* Private constructor for configuring the single instance per app.
Expand Down Expand Up @@ -167,6 +168,25 @@ public void setSessionIdRotationTime(@IntRange(from = 1, to = 24) int sessionIdR
this.sessionIdRotationTime = sessionIdRotationTime; // in hours
}

// For internal use only
// This is an experimental API. Experimental APIs are quickly evolving and
// might change or be removed in minor versions.
@Experimental
public boolean isDebugLoggingEnabled() {
return debugLoggingEnabled;
}

// For internal use only
// This is an experimental API. Experimental APIs are quickly evolving and
// might change or be removed in minor versions.
@Experimental
public void setDebugLoggingEnabled(boolean debugLoggingEnabled) {
this.debugLoggingEnabled = debugLoggingEnabled;
if (this.client != null) {
this.client.setDebugLoggingEnabled(debugLoggingEnabled);
}
}

/**
* Checks that TelemetryService has been configured by developer
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class TelemetryClient {
private String eventsCnEndpoint = MapboxEvent.MAPBOX_EVENTS_CN_BASE_URL;
private boolean stagingEnvironment = false;
private boolean enableCnEndpoint = false;
private boolean debugLoggingEnabled = false;
private OkHttpClient client;

public TelemetryClient(String accessToken) {
Expand Down Expand Up @@ -88,6 +89,14 @@ public void setEnableCnEndpoint() {
this.enableCnEndpoint = true;
}

public boolean isDebugLoggingEnabled() {
return debugLoggingEnabled;
}

public void setDebugLoggingEnabled(boolean debugLoggingEnabled) {
this.debugLoggingEnabled = debugLoggingEnabled;
}

/**
* Based on http://square.github.io/okhttp/3.x/okhttp/okhttp3/CertificatePinner.html
*
Expand Down Expand Up @@ -218,8 +227,8 @@ private void sendEventsWrapped(Vector<Hashtable<String, Object>> events, Callbac
RequestBody body = RequestBody.create(JSON, payload);
String url = getEventsEndpoint() + "/events/v2?access_token=" + getAccessToken();

// Extra debug in staging mode
if (isStagingEnvironment()) {
// Extra debug if manually enabled or if in staging mode
if (isDebugLoggingEnabled() || isStagingEnvironment()) {
Log.d(LOG_TAG, String.format("Sending POST to %s with %d event(s) (user agent: %s) with payload: %s",
url, events.size(), getUserAgent(), payload));
}
Expand Down