-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Filter parity with iOS + ecomm analytics
* filter parity with iOS * sort type consitency * add analytics class supporting ATC and Conversion methods, update readme, update example app * PR changes * ints * update examples * pdp albums set album_id
- Loading branch information
kj13ennett
authored
Jul 17, 2019
1 parent
6a855de
commit 5b53805
Showing
11 changed files
with
256 additions
and
39 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
84 changes: 84 additions & 0 deletions
84
pixleesdk/src/main/java/com/pixlee/pixleesdk/PXLAnalytics.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package com.pixlee.pixleesdk; | ||
|
||
import android.content.Context; | ||
|
||
import org.json.JSONArray; | ||
import org.json.JSONException; | ||
import org.json.JSONObject; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
|
||
|
||
public class PXLAnalytics { | ||
private static final String TAG = "PXLAnalytics"; | ||
|
||
protected Context context; | ||
|
||
|
||
/*** | ||
* Constructor requires the context, which will be passed along to the PXLClient | ||
* for volley configuration. | ||
* @param context - context which will be used for volley configuration | ||
*/ | ||
public PXLAnalytics(Context context) { | ||
this.context = context; | ||
} | ||
|
||
public void addToCart(String sku, String price, Integer quantity, String currency) { | ||
PXLClient pxlClient = PXLClient.getInstance(this.context); | ||
JSONObject body = new JSONObject(); | ||
|
||
try{ | ||
body.put("product_sku", sku); | ||
body.put("price", price); | ||
body.put("quantity", quantity); | ||
if(currency != null){ | ||
body.put("currency", currency); | ||
} | ||
|
||
|
||
} catch (JSONException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
pxlClient.makeAnalyticsCall("events/addToCart", body); | ||
} | ||
|
||
public void addToCart(String sku, String price, Integer quantity) { | ||
this.addToCart(sku, price, quantity, null); | ||
} | ||
|
||
|
||
public void conversion(ArrayList<HashMap<String, Object>> cartContents, String cartTotal, Integer cartTotalQuantity, String orderId, String currency){ | ||
PXLClient pxlClient = PXLClient.getInstance(this.context); | ||
JSONObject body = new JSONObject(); | ||
|
||
try{ | ||
JSONArray cartContentsJson = new JSONArray(cartContents); | ||
body.put("cart_contents", cartContentsJson); | ||
body.put("cart_total", cartTotal); | ||
body.put("cart_total_quantity", cartTotalQuantity); | ||
if(currency != null){ | ||
body.put("currency", currency); | ||
} | ||
if(orderId != null){ | ||
body.put("order_id", orderId); | ||
} | ||
|
||
} catch (JSONException e) { | ||
e.printStackTrace(); | ||
} | ||
|
||
pxlClient.makeAnalyticsCall("events/conversion", body); | ||
|
||
} | ||
public void conversion(ArrayList<HashMap<String, Object>> cartContents, String cartTotal, Integer cartTotalQuantity, String orderId){ | ||
this.conversion(cartContents, cartTotal, cartTotalQuantity, orderId, null); | ||
} | ||
public void conversion(ArrayList<HashMap<String, Object>> cartContents, String cartTotal, Integer cartTotalQuantity) { | ||
this.conversion(cartContents, cartTotal, cartTotalQuantity, null, null); | ||
|
||
} | ||
|
||
} |
This file contains 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
This file contains 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
Oops, something went wrong.