Skip to content

Commit 81b69c9

Browse files
authored
Merge pull request #34 from segment-integrations/niall/update_version
Bump FireBase Analytics Version
2 parents 138afa2 + 65eb607 commit 81b69c9

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ dependencies {
5555
}
5656

5757
api 'com.segment.analytics.android:analytics:4.3.1'
58-
implementation 'com.google.firebase:firebase-analytics:17.2.1'
58+
implementation 'com.google.firebase:firebase-analytics:18.0.0'
5959

6060
testImplementation 'com.segment.analytics.android:analytics-tests:4.3.1'
6161
testImplementation 'junit:junit:4.12'

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: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,24 @@ public void trackWithProperties() {
119119
verify(firebase).logEvent(eq("foo"), bundleEq(expected));
120120
}
121121

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

0 commit comments

Comments
 (0)