Skip to content

Commit 5d474aa

Browse files
add telem percent time in foreground and in portrait track support (#616)
1 parent 0743009 commit 5d474aa

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

mapbox/libandroid-telemetry/src/main/java/com/mapbox/services/android/telemetry/MapboxTelemetry.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,4 +812,22 @@ public void addAbsoluteDistanceToDestination(int absoluteDistanceToDestination,
812812
Hashtable<String, Object> eventWithAttributes) {
813813
eventWithAttributes.put(MapboxNavigationEvent.KEY_ABSOLUTE_DISTANCE_TO_DESTINATION, absoluteDistanceToDestination);
814814
}
815+
816+
// For internal use only
817+
// This is an experimental API. Experimental APIs are quickly evolving and
818+
// might change or be removed in minor versions.
819+
@Experimental
820+
public void addPercentTimeInForeground(@IntRange(from = 0, to = 100) int percentTimeInForeground,
821+
Hashtable<String, Object> eventWithAttributes) {
822+
eventWithAttributes.put(MapboxNavigationEvent.KEY_PERCENT_TIME_IN_FOREGROUND, percentTimeInForeground);
823+
}
824+
825+
// For internal use only
826+
// This is an experimental API. Experimental APIs are quickly evolving and
827+
// might change or be removed in minor versions.
828+
@Experimental
829+
public void addPercentTimeInPortrait(@IntRange(from = 0, to = 100) int percentTimeInPortrait,
830+
Hashtable<String, Object> eventWithAttributes) {
831+
eventWithAttributes.put(MapboxNavigationEvent.KEY_PERCENT_TIME_IN_PORTRAIT, percentTimeInPortrait);
832+
}
815833
}

mapbox/libandroid-telemetry/src/main/java/com/mapbox/services/android/telemetry/http/TelemetryClient.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ private void sendEventsWrapped(Vector<Hashtable<String, Object>> events, Callbac
213213
jsonObject.putOpt(MapboxNavigationEvent.KEY_LOCATION_ENGINE, evt.get(MapboxNavigationEvent.KEY_LOCATION_ENGINE));
214214
jsonObject.putOpt(MapboxNavigationEvent.KEY_ABSOLUTE_DISTANCE_TO_DESTINATION,
215215
evt.get(MapboxNavigationEvent.KEY_ABSOLUTE_DISTANCE_TO_DESTINATION));
216+
jsonObject.putOpt(MapboxNavigationEvent.KEY_PERCENT_TIME_IN_FOREGROUND,
217+
evt.get(MapboxNavigationEvent.KEY_PERCENT_TIME_IN_FOREGROUND));
218+
jsonObject.putOpt(MapboxNavigationEvent.KEY_PERCENT_TIME_IN_PORTRAIT,
219+
evt.get(MapboxNavigationEvent.KEY_PERCENT_TIME_IN_PORTRAIT));
216220

217221
// Step metadata
218222
jsonObject.putOpt(MapboxNavigationEvent.KEY_UPCOMING_INSTRUCTION,

mapbox/libandroid-telemetry/src/main/java/com/mapbox/services/android/telemetry/navigation/MapboxNavigationEvent.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ public class MapboxNavigationEvent {
7474
public static final String KEY_STEP_COUNT = "stepCount";
7575
public static final String KEY_LOCATION_ENGINE = "locationEngine";
7676
public static final String KEY_ABSOLUTE_DISTANCE_TO_DESTINATION = "absoluteDistanceToDestination";
77+
public static final String KEY_PERCENT_TIME_IN_FOREGROUND = "percentTimeInForeground";
78+
public static final String KEY_PERCENT_TIME_IN_PORTRAIT = "percentTimeInPortrait";
7779

7880
// Step metadata
7981
public static final String KEY_UPCOMING_INSTRUCTION = "upcomingInstruction";

0 commit comments

Comments
 (0)