Created
December 14, 2015 18:54
-
-
Save cami7ord/e0e90b98cbf2f06f8fd3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.mercadoni.user.android.managers; | |
import android.content.Context; | |
import android.os.Bundle; | |
import com.ad4screen.sdk.A4S; | |
import com.ad4screen.sdk.analytics.Cart; | |
import com.ad4screen.sdk.analytics.Item; | |
import com.ad4screen.sdk.analytics.Purchase; | |
import java.text.SimpleDateFormat; | |
import java.util.Date; | |
public class AccengageManager { | |
private static AccengageManager ourInstance = new AccengageManager(); | |
public static AccengageManager getInstance() { | |
return ourInstance; | |
} | |
public static SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss zzz"); | |
private AccengageManager() { | |
} | |
// PERSONALIZED EVENTS | |
public void registerUserCountry(Context context, String email, String country, String city) { | |
A4S.get(context).trackEvent(1000, email, country, city); | |
} | |
public void registerUserPurchase(Context context, String email, String country, String city, String purchaseId, String total) { | |
A4S.get(context).trackEvent(1001, email, country, city, purchaseId, total); | |
} | |
public void registerRetailerOnCart(Context context, String email, String cartId, String retailerName, String retailerLocation) { | |
A4S.get(context).trackEvent(1002, email, cartId, retailerName, retailerLocation); | |
} | |
// UPDATE DEVICE INFORMATION | |
public void updateDeviceInformation(Context context, String firstName, String countryCode, int purchaseCounter, Date lastPurchase) { | |
Bundle bundle = new Bundle(); | |
bundle.putString("firstName", firstName); | |
bundle.putString("countryCode", countryCode); | |
bundle.putInt("purchaseCounter", purchaseCounter); | |
bundle.putString("lastPurchaseDate", dateFormat.format(lastPurchase)); | |
A4S.get(context).updateDeviceInfo(bundle); | |
} | |
// DEFAULT EVENTS | |
// Not being used since we dont need to know the products bought for the moment. | |
public void trackAddToCartEvent(Context context, String purchaseId, String purchaseCurrency, long totalPrice) { | |
Item item = new Item("ArticleID", "Label", "Category", "Currency", 12.30, 1); | |
Cart cart = new Cart("CartId", item); | |
A4S.get(context).trackAddToCart(cart); | |
} | |
public void trackPurchaseEvent(Context context, String purchaseId, String purchaseCurrency, String totalPrice) { | |
Purchase purchase = new Purchase(purchaseId, purchaseCurrency, Long.parseLong(totalPrice)); | |
A4S.get(context).trackPurchase(purchase); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment