File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
main/java/com/segment/analytics/android/integrations/firebase
test/java/com/segment/analytics/android/integration/firebase Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -211,7 +211,7 @@ && isNullOrEmpty(properties.currency())) {
211211 } else {
212212 property = makeKey (property );
213213 }
214- if (property .equals (Param .ITEMS )) {
214+ if (property .equals (Param .ITEMS ) && value != null ) {
215215 List <ValueMap > products = properties .getList ("products" , ValueMap .class );
216216 ArrayList <Bundle > mappedProducts = formatProducts (products );
217217 bundle .putParcelableArrayList (property , mappedProducts );
Original file line number Diff line number Diff line change @@ -152,6 +152,23 @@ public void trackPurchaseWithProducts() {
152152 verify (firebase ).logEvent (eq ("purchase" ), bundleEq (expected ));
153153 }
154154
155+ @ Test
156+ public void trackPurchaseWithNullProducts () {
157+ Properties properties = new Properties ()
158+ .putValue ("revenue" , 100.0 )
159+ .putValue ("currency" , "USD" )
160+ .putValue ("products" , null );
161+
162+ integration .track (new TrackPayload .Builder ().anonymousId ("1234" ).properties (properties ).event ("Order Completed" ).build ());
163+
164+ Bundle expected = new Bundle ();
165+ expected .putDouble ("value" , 100.0 );
166+ expected .putString ("currency" , "USD" );
167+ expected .putString ("items" , null );
168+
169+ verify (firebase ).logEvent (eq ("purchase" ), bundleEq (expected ));
170+ }
171+
155172 @ Test
156173 public void trackWithEventNameTransformation () {
157174 Properties properties = new Properties ()
You can’t perform that action at this time.
0 commit comments