File tree Expand file tree Collapse file tree 2 files changed +19
-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 +19
-1
lines changed Original file line number Diff line number Diff line change 26
26
27
27
import static com .segment .analytics .internal .Utils .hasPermission ;
28
28
import static com .segment .analytics .internal .Utils .isNullOrEmpty ;
29
+ import static java .util .Objects .isNull ;
29
30
30
31
/**
31
32
* Google Analytics for Firebase is a free app measurement solution that provides insight on app
@@ -211,7 +212,7 @@ && isNullOrEmpty(properties.currency())) {
211
212
} else {
212
213
property = makeKey (property );
213
214
}
214
- if (property .equals (Param .ITEMS )) {
215
+ if (property .equals (Param .ITEMS ) && value != null ) {
215
216
List <ValueMap > products = properties .getList ("products" , ValueMap .class );
216
217
ArrayList <Bundle > mappedProducts = formatProducts (products );
217
218
bundle .putParcelableArrayList (property , mappedProducts );
Original file line number Diff line number Diff line change @@ -152,6 +152,23 @@ public void trackPurchaseWithProducts() {
152
152
verify (firebase ).logEvent (eq ("purchase" ), bundleEq (expected ));
153
153
}
154
154
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
+
155
172
@ Test
156
173
public void trackWithEventNameTransformation () {
157
174
Properties properties = new Properties ()
You can’t perform that action at this time.
0 commit comments