@@ -149,8 +149,16 @@ public static Hashtable<String, Object> buildFeedbackEvent(
149149 event .put (KEY_SCREENSHOT , encodedSnapshot );
150150 event .put (KEY_START_TIMESTAMP , TelemetryUtils .generateCreateDateFormatted (startTimestamp ));
151151 event .put (KEY_FEEDBACK_TYPE , feedbackType );
152- event .put (KEY_LOCATIONS_BEFORE , locationsBefore );
153- event .put (KEY_LOCATIONS_AFTER , locationsAfter );
152+ if (locationsBefore != null ) {
153+ event .put (KEY_LOCATIONS_BEFORE , locationsBefore );
154+ } else {
155+ event .put (KEY_LOCATIONS_BEFORE , JSONObject .NULL );
156+ }
157+ if (locationsAfter != null ) {
158+ event .put (KEY_LOCATIONS_AFTER , locationsAfter );
159+ } else {
160+ event .put (KEY_LOCATIONS_AFTER , JSONObject .NULL );
161+ }
154162 event .put (KEY_DISTANCE_COMPLETED , distanceCompleted );
155163 event .put (KEY_DISTANCE_REMAINING , distanceRemaining );
156164 event .put (KEY_DURATION_REMAINING , durationRemaining );
@@ -182,8 +190,16 @@ public static Hashtable<String, Object> buildRerouteEvent(
182190 event .put (KEY_EVENT , TYPE_REROUTE );
183191 event .put (KEY_FEEDBACK_ID , feedbackId );
184192 event .put (KEY_START_TIMESTAMP , TelemetryUtils .generateCreateDateFormatted (startTimestamp ));
185- event .put (KEY_LOCATIONS_BEFORE , locationsBefore );
186- event .put (KEY_LOCATIONS_AFTER , locationsAfter );
193+ if (locationsBefore != null ) {
194+ event .put (KEY_LOCATIONS_BEFORE , locationsBefore );
195+ } else {
196+ event .put (KEY_LOCATIONS_BEFORE , JSONObject .NULL );
197+ }
198+ if (locationsAfter != null ) {
199+ event .put (KEY_LOCATIONS_AFTER , locationsAfter );
200+ } else {
201+ event .put (KEY_LOCATIONS_AFTER , JSONObject .NULL );
202+ }
187203 event .put (KEY_DISTANCE_COMPLETED , distanceCompleted );
188204 event .put (KEY_DISTANCE_REMAINING , distanceRemaining );
189205 event .put (KEY_DURATION_REMAINING , durationRemaining );
@@ -302,14 +318,47 @@ private static Hashtable<String, Object> getStepMetadata(
302318 int distance , int duration , int distanceRemaining , int durationRemaining
303319 ) {
304320 Hashtable <String , Object > event = new Hashtable <>();
305- event .put (KEY_UPCOMING_INSTRUCTION , upcomingInstruction );
306- event .put (KEY_UPCOMING_TYPE , upcomingType );
307- event .put (KEY_UPCOMING_MODIFIER , upcomingModifier );
308- event .put (KEY_UPCOMING_NAME , upcomingName );
309- event .put (KEY_PREVIOUS_INSTRUCTION , previousInstruction );
310- event .put (KEY_PREVIOUS_TYPE , previousType );
311- event .put (KEY_PREVIOUS_MODIFIER , previousModifier );
312- event .put (KEY_PREVIOUS_NAME , previousName );
321+ if (upcomingInstruction != null ) {
322+ event .put (KEY_UPCOMING_INSTRUCTION , upcomingInstruction );
323+ } else {
324+ event .put (KEY_UPCOMING_INSTRUCTION , JSONObject .NULL );
325+ }
326+ if (upcomingType != null ) {
327+ event .put (KEY_UPCOMING_TYPE , upcomingType );
328+ } else {
329+ event .put (KEY_UPCOMING_TYPE , JSONObject .NULL );
330+ }
331+ if (upcomingModifier != null ) {
332+ event .put (KEY_UPCOMING_MODIFIER , upcomingModifier );
333+ } else {
334+ event .put (KEY_UPCOMING_MODIFIER , JSONObject .NULL );
335+ }
336+ if (upcomingName != null ) {
337+ event .put (KEY_UPCOMING_NAME , upcomingName );
338+ } else {
339+ event .put (KEY_UPCOMING_NAME , JSONObject .NULL );
340+ }
341+ if (previousInstruction != null ) {
342+ event .put (KEY_PREVIOUS_INSTRUCTION , previousInstruction );
343+ } else {
344+ event .put (KEY_PREVIOUS_INSTRUCTION , JSONObject .NULL );
345+ }
346+ if (previousType != null ) {
347+ event .put (KEY_PREVIOUS_TYPE , previousType );
348+ } else {
349+ event .put (KEY_PREVIOUS_TYPE , JSONObject .NULL );
350+ }
351+ if (previousModifier != null ) {
352+ event .put (KEY_PREVIOUS_MODIFIER , previousModifier );
353+ } else {
354+ event .put (KEY_PREVIOUS_MODIFIER , JSONObject .NULL );
355+ }
356+ if (previousName != null ) {
357+ event .put (KEY_PREVIOUS_NAME , previousName );
358+ } else {
359+ event .put (KEY_PREVIOUS_NAME , JSONObject .NULL );
360+ }
361+
313362 event .put (KEY_DISTANCE , distance );
314363 event .put (KEY_DURATION , duration );
315364 event .put (KEY_DISTANCE_REMAINING , distanceRemaining );
0 commit comments