Skip to content

Commit

Permalink
Merge pull request #34 from segment-integrations/niall/update_version
Browse files Browse the repository at this point in the history
Bump FireBase Analytics Version
  • Loading branch information
niallzato authored Mar 11, 2021
2 parents 138afa2 + 65eb607 commit 81b69c9
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ dependencies {
}

api 'com.segment.analytics.android:analytics:4.3.1'
implementation 'com.google.firebase:firebase-analytics:17.2.1'
implementation 'com.google.firebase:firebase-analytics:18.0.0'

testImplementation 'com.segment.analytics.android:analytics-tests:4.3.1'
testImplementation 'junit:junit:4.12'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ private static Map<String, String> createEventMap() {
Map<String, String> EVENT_MAPPER = new HashMap<>();
EVENT_MAPPER.put("Product Added", Event.ADD_TO_CART);
EVENT_MAPPER.put("Checkout Started", Event.BEGIN_CHECKOUT);
EVENT_MAPPER.put("Order Completed", Event.ECOMMERCE_PURCHASE);
EVENT_MAPPER.put("Order Refunded", Event.PURCHASE_REFUND);
EVENT_MAPPER.put("Order Completed", Event.PURCHASE);
EVENT_MAPPER.put("Order Refunded", Event.REFUND);
EVENT_MAPPER.put("Product Viewed", Event.VIEW_ITEM);
EVENT_MAPPER.put("Product List Viewed", Event.VIEW_ITEM_LIST);
EVENT_MAPPER.put("Payment Info Entered", Event.ADD_PAYMENT_INFO);
EVENT_MAPPER.put("Promotion Viewed", Event.PRESENT_OFFER);
EVENT_MAPPER.put("Promotion Viewed", Event.VIEW_PROMOTION);
EVENT_MAPPER.put("Product Added to Wishlist", Event.ADD_TO_WISHLIST);
EVENT_MAPPER.put("Product Shared", Event.SHARE);
EVENT_MAPPER.put("Product Clicked", Event.SELECT_CONTENT);
Expand All @@ -100,6 +100,7 @@ private static Map<String, String> createPropertyMap() {
PROPERTY_MAPPER.put("revenue", Param.VALUE);
PROPERTY_MAPPER.put("order_id", Param.TRANSACTION_ID);
PROPERTY_MAPPER.put("currency", Param.CURRENCY);
PROPERTY_MAPPER.put("products", Param.ITEMS);
return PROPERTY_MAPPER;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,24 @@ public void trackWithProperties() {
verify(firebase).logEvent(eq("foo"), bundleEq(expected));
}

@Test
public void trackPurchaseWithProducts() {
Properties properties = new Properties()
.putValue("revenue", 100.0)
.putValue("currency", "USD");
Properties.Product product1 = new Properties.Product( "123", "abc", 10.0);
properties.putProducts(product1);

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", "[{id=123, sku=abc, price=10.0}]");

verify(firebase).logEvent(eq("purchase"), bundleEq(expected));
}

@Test
public void trackWithEventNameTransformation() {
Properties properties = new Properties()
Expand Down

0 comments on commit 81b69c9

Please sign in to comment.