Skip to content

Commit a4ad5e4

Browse files
author
Niall Brennan
committed
update event and property mappings
1 parent d60884b commit a4ad5e4

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

src/main/java/com/segment/analytics/android/integrations/firebase/FirebaseIntegration.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ private static Map<String, String> createEventMap() {
7171
Map<String, String> EVENT_MAPPER = new HashMap<>();
7272
EVENT_MAPPER.put("Product Added", Event.ADD_TO_CART);
7373
EVENT_MAPPER.put("Checkout Started", Event.BEGIN_CHECKOUT);
74-
EVENT_MAPPER.put("Order Completed", Event.ECOMMERCE_PURCHASE);
75-
EVENT_MAPPER.put("Order Refunded", Event.PURCHASE_REFUND);
74+
EVENT_MAPPER.put("Order Completed", Event.PURCHASE);
75+
EVENT_MAPPER.put("Order Refunded", Event.REFUND);
7676
EVENT_MAPPER.put("Product Viewed", Event.VIEW_ITEM);
7777
EVENT_MAPPER.put("Product List Viewed", Event.VIEW_ITEM_LIST);
7878
EVENT_MAPPER.put("Payment Info Entered", Event.ADD_PAYMENT_INFO);
79-
EVENT_MAPPER.put("Promotion Viewed", Event.PRESENT_OFFER);
79+
EVENT_MAPPER.put("Promotion Viewed", Event.VIEW_PROMOTION);
8080
EVENT_MAPPER.put("Product Added to Wishlist", Event.ADD_TO_WISHLIST);
8181
EVENT_MAPPER.put("Product Shared", Event.SHARE);
8282
EVENT_MAPPER.put("Product Clicked", Event.SELECT_CONTENT);
@@ -100,6 +100,7 @@ private static Map<String, String> createPropertyMap() {
100100
PROPERTY_MAPPER.put("revenue", Param.VALUE);
101101
PROPERTY_MAPPER.put("order_id", Param.TRANSACTION_ID);
102102
PROPERTY_MAPPER.put("currency", Param.CURRENCY);
103+
PROPERTY_MAPPER.put("products", Param.ITEMS);
103104
return PROPERTY_MAPPER;
104105
}
105106

src/test/java/com/segment/analytics/android/integration/firebase/FirebaseTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import com.google.firebase.analytics.FirebaseAnalytics;
88
import com.segment.analytics.Properties;
9+
import com.segment.analytics.ValueMap;
910
import com.segment.analytics.android.integrations.firebase.FirebaseIntegration;
1011
import com.segment.analytics.integrations.IdentifyPayload;
1112
import com.segment.analytics.integrations.Logger;
@@ -119,6 +120,24 @@ public void trackWithProperties() {
119120
verify(firebase).logEvent(eq("foo"), bundleEq(expected));
120121
}
121122

123+
@Test
124+
public void trackPurchaseWithProducts() {
125+
Properties properties = new Properties()
126+
.putValue("revenue", 100.0)
127+
.putValue("currency", "USD");
128+
Properties.Product product1 = new Properties.Product( "123", "abc", 10.0);
129+
properties.putProducts(product1);
130+
131+
integration.track(new TrackPayload.Builder().anonymousId("1234").properties(properties).event("Order Completed").build());
132+
133+
Bundle expected = new Bundle();
134+
expected.putDouble("value", 100.0);
135+
expected.putString("currency", "USD");
136+
expected.putString("items", "[{id=123, sku=abc, price=10.0}]");
137+
138+
verify(firebase).logEvent(eq("purchase"), bundleEq(expected));
139+
}
140+
122141
@Test
123142
public void trackWithEventNameTransformation() {
124143
Properties properties = new Properties()

0 commit comments

Comments
 (0)