diff --git a/src/main/java/com/segment/analytics/android/integrations/firebase/FirebaseIntegration.java b/src/main/java/com/segment/analytics/android/integrations/firebase/FirebaseIntegration.java index a1dcb8e..a714665 100644 --- a/src/main/java/com/segment/analytics/android/integrations/firebase/FirebaseIntegration.java +++ b/src/main/java/com/segment/analytics/android/integrations/firebase/FirebaseIntegration.java @@ -211,7 +211,7 @@ && isNullOrEmpty(properties.currency())) { } else { property = makeKey(property); } - if (property.equals(Param.ITEMS)) { + if (property.equals(Param.ITEMS) && value != null) { List products = properties.getList("products", ValueMap.class); ArrayList mappedProducts = formatProducts(products); bundle.putParcelableArrayList(property, mappedProducts); diff --git a/src/test/java/com/segment/analytics/android/integration/firebase/FirebaseTest.java b/src/test/java/com/segment/analytics/android/integration/firebase/FirebaseTest.java index f0f5235..091c7af 100644 --- a/src/test/java/com/segment/analytics/android/integration/firebase/FirebaseTest.java +++ b/src/test/java/com/segment/analytics/android/integration/firebase/FirebaseTest.java @@ -152,6 +152,23 @@ public void trackPurchaseWithProducts() { verify(firebase).logEvent(eq("purchase"), bundleEq(expected)); } + @Test + public void trackPurchaseWithNullProducts() { + Properties properties = new Properties() + .putValue("revenue", 100.0) + .putValue("currency", "USD") + .putValue("products", null); + + integration.track(new TrackPayload.Builder().anonymousId("1234").properties(properties).event("Order Completed").build()); + + Bundle expected = new Bundle(); + expected.putDouble("value", 100.0); + expected.putString("currency", "USD"); + expected.putString("items", null); + + verify(firebase).logEvent(eq("purchase"), bundleEq(expected)); + } + @Test public void trackWithEventNameTransformation() { Properties properties = new Properties()