public void MeasureEvent(MATEvent tuneEvent) { AndroidJavaObject tuneEventJavaObject = this.GetTuneEventJavaObject(tuneEvent); object[] args = new object[] { tuneEventJavaObject }; this.ajcInstance.Call("measureEvent", args); }
public static void MeasureEvent(MATEvent matEvent) { if (!Application.isEditor) { int arg_25_0 = (matEvent.eventItems != null) ? matEvent.eventItems.Length : 0; MATAndroid.Instance.MeasureEvent(matEvent); } }
public static void MeasureEvent(MATEvent tuneEvent) { if (!Application.isEditor) { int num = (tuneEvent.eventItems != null) ? tuneEvent.eventItems.Length : 0; MATAndroid.Instance.MeasureEvent(tuneEvent); } }
// Set level ID and measure a level achieved event upon level start public void onLevelStarted(Level level) { // Create a MATEvent for level_achieved with the level ID MATEvent levelEvent = new MATEvent("level_achieved"); levelEvent.contentId = level.ID; // Measure "level_achieved" event for this level ID MATBinding.MeasureEvent (levelEvent); }
public void MeasureEvent(MATEvent matEvent) { AndroidJavaObject mATEventJavaObject = this.GetMATEventJavaObject(matEvent); this.ajcInstance.Call("measureEvent", new object[] { mATEventJavaObject }); }
public MATEventIos(MATEvent matEvent) { this.name = matEvent.name; this.eventId = ((matEvent.name != null) ? null : matEvent.id.ToString()); this.advertiserRefId = matEvent.advertiserRefId; this.attribute1 = matEvent.attribute1; this.attribute2 = matEvent.attribute2; this.attribute3 = matEvent.attribute3; this.attribute4 = matEvent.attribute4; this.attribute5 = matEvent.attribute5; this.contentId = ((matEvent.contentId != null) ? matEvent.contentId.ToString() : null); this.contentType = matEvent.contentType; this.currencyCode = matEvent.currencyCode; int?num = matEvent.level; this.level = (num.HasValue ? matEvent.level.ToString() : null); int?num2 = matEvent.quantity; this.quantity = (num2.HasValue ? matEvent.quantity.ToString() : null); double?num3 = matEvent.rating; this.rating = (num3.HasValue ? matEvent.rating.ToString() : null); double?num4 = matEvent.revenue; this.revenue = (num4.HasValue ? matEvent.revenue.ToString() : null); this.searchString = matEvent.searchString; int?num5 = matEvent.transactionState; this.transactionState = (num5.HasValue ? matEvent.transactionState.ToString() : null); this.date1 = null; this.date2 = null; DateTime dateTime = new DateTime(1970, 1, 1); if (matEvent.date1.HasValue) { TimeSpan timeSpan = new TimeSpan(matEvent.date1.Value.Ticks); double totalMilliseconds = timeSpan.TotalMilliseconds; double arg_221_0 = totalMilliseconds; TimeSpan timeSpan2 = new TimeSpan(dateTime.Ticks); this.date1 = (arg_221_0 - timeSpan2.TotalMilliseconds).ToString(); } if (matEvent.date2.HasValue) { TimeSpan timeSpan3 = new TimeSpan(matEvent.date2.Value.Ticks); double totalMilliseconds2 = timeSpan3.TotalMilliseconds; double arg_27B_0 = totalMilliseconds2; TimeSpan timeSpan4 = new TimeSpan(dateTime.Ticks); this.date2 = (arg_27B_0 - timeSpan4.TotalMilliseconds).ToString(); } }
// On purchase complete, set purchase info and measure purchase in TUNE public void onMarketPurchase(PurchasableVirtualItem pvi, string payload, Dictionary<string, string> extras) { double revenue = 0; string currency = ""; MATItem[] items = new MATItem[] {}; MarketItem item = ((PurchaseWithMarket)pvi.PurchaseType).MarketItem; revenue = item.MarketPriceMicros / 1000000; currency = item.MarketCurrencyCode; // Create event item to store purchase item data MATItem matItem = new MATItem(); matItem.name = item.MarketTitle; matItem.attribute1 = item.ProductId; // Add event item to MATItem array in order to pass to TUNE SDK items[items.Length] = matItem; // Get order ID and receipt data for purchase validation string receipt = ""; string receiptSignature = ""; string orderId = ""; #if UNITY_ANDROID extras.TryGetValue("originalJson", out receipt); extras.TryGetValue("signature", out receiptSignature); extras.TryGetValue("orderId", out orderId); #elif UNITY_IOS extras.TryGetValue("receiptBase64", out receipt); extras.TryGetValue("transactionIdentifier", out orderId); #endif // Create a MATEvent with this purchase data MATEvent purchaseEvent = new MATEvent("purchase"); purchaseEvent.revenue = revenue; purchaseEvent.currencyCode = currency; purchaseEvent.advertiserRefId = orderId; purchaseEvent.receipt = receipt; purchaseEvent.receiptSignature = receiptSignature; // Set event item if it exists if (items.Length != 0) { purchaseEvent.eventItems = items; } // Measure "purchase" event MATBinding.MeasureEvent(purchaseEvent); }
public MATEventIos(MATEvent matEvent) { name = matEvent.name; eventId = null == matEvent.name ? matEvent.id.ToString() : null; advertiserRefId = matEvent.advertiserRefId; attribute1 = matEvent.attribute1; attribute2 = matEvent.attribute2; attribute3 = matEvent.attribute3; attribute4 = matEvent.attribute4; attribute5 = matEvent.attribute5; contentId = null == matEvent.contentId ? null : matEvent.contentId.ToString(); contentType = matEvent.contentType; currencyCode = matEvent.currencyCode; level = null == matEvent.level ? null : matEvent.level.ToString(); quantity = null == matEvent.quantity ? null : matEvent.quantity.ToString(); rating = null == matEvent.rating ? null : matEvent.rating.ToString(); revenue = null == matEvent.revenue ? null : matEvent.revenue.ToString(); searchString = matEvent.searchString; transactionState = null == matEvent.transactionState ? null : matEvent.transactionState.ToString(); date1 = null; date2 = null; // datetime starts in 1970 DateTime datetime = new DateTime(1970, 1, 1); if (matEvent.date1.HasValue) { double millis = new TimeSpan(matEvent.date1.Value.Ticks).TotalMilliseconds; double millisFrom1970 = millis - (new TimeSpan(datetime.Ticks)).TotalMilliseconds; date1 = millisFrom1970.ToString(); } if (matEvent.date2.HasValue) { double millis = new TimeSpan(matEvent.date2.Value.Ticks).TotalMilliseconds; double millisFrom1970 = millis - (new TimeSpan(datetime.Ticks)).TotalMilliseconds; date2 = millisFrom1970.ToString(); } }
public MATEventIos(MATEvent matEvent) { this.name = matEvent.name; this.eventId = (matEvent.name != null) ? null : matEvent.id.ToString(); this.advertiserRefId = matEvent.advertiserRefId; this.attribute1 = matEvent.attribute1; this.attribute2 = matEvent.attribute2; this.attribute3 = matEvent.attribute3; this.attribute4 = matEvent.attribute4; this.attribute5 = matEvent.attribute5; this.contentId = (matEvent.contentId != null) ? matEvent.contentId.ToString() : null; this.contentType = matEvent.contentType; this.currencyCode = matEvent.currencyCode; this.level = matEvent.level.HasValue ? matEvent.level.ToString() : null; this.quantity = matEvent.quantity.HasValue ? matEvent.quantity.ToString() : null; this.rating = matEvent.rating.HasValue ? matEvent.rating.ToString() : null; this.revenue = matEvent.revenue.HasValue ? matEvent.revenue.ToString() : null; this.searchString = matEvent.searchString; this.transactionState = matEvent.transactionState.HasValue ? matEvent.transactionState.ToString() : null; this.date1 = null; this.date2 = null; DateTime time = new DateTime(0x7b2, 1, 1); if (matEvent.date1.HasValue) { TimeSpan span = new TimeSpan(matEvent.date1.Value.Ticks); TimeSpan span2 = new TimeSpan(time.Ticks); this.date1 = (span.TotalMilliseconds - span2.TotalMilliseconds).ToString(); } if (matEvent.date2.HasValue) { TimeSpan span3 = new TimeSpan(matEvent.date2.Value.Ticks); TimeSpan span4 = new TimeSpan(time.Ticks); this.date2 = (span3.TotalMilliseconds - span4.TotalMilliseconds).ToString(); } }
public void MeasureEvent(MATEvent tuneEvent) { AndroidJavaObject objEvent = GetTuneEventJavaObject(tuneEvent); ajcInstance.Call("measureEvent", objEvent); }
private AndroidJavaObject GetTuneEventJavaObject(MATEvent tuneEvent) { // Convert C# MATEvent to new Java MATEvent object AndroidJavaObject objTuneEvent; if (tuneEvent.name == null) { objTuneEvent = new AndroidJavaObject("com.mobileapptracker.MATEvent", tuneEvent.id); } else { objTuneEvent = new AndroidJavaObject("com.mobileapptracker.MATEvent", tuneEvent.name); } // Set the optional params if they exist if (tuneEvent.revenue != null) { objTuneEvent = objTuneEvent.Call <AndroidJavaObject>("withRevenue", tuneEvent.revenue); } if (tuneEvent.currencyCode != null) { objTuneEvent = objTuneEvent.Call <AndroidJavaObject>("withCurrencyCode", tuneEvent.currencyCode); } if (tuneEvent.advertiserRefId != null) { objTuneEvent = objTuneEvent.Call <AndroidJavaObject>("withAdvertiserRefId", tuneEvent.advertiserRefId); } if (tuneEvent.eventItems != null) { // Convert MATItem[] to Arraylist<MATEventItem> AndroidJavaObject objArrayList = new AndroidJavaObject("java.util.ArrayList"); foreach (MATItem item in tuneEvent.eventItems) { // Convert MATItem to MATEventItem AndroidJavaObject objEventItem = new AndroidJavaObject("com.mobileapptracker.MATEventItem", item.name); if (item.quantity != null) { objEventItem = objEventItem.Call <AndroidJavaObject>("withQuantity", item.quantity); } if (item.unitPrice != null) { objEventItem = objEventItem.Call <AndroidJavaObject>("withUnitPrice", item.unitPrice); } if (item.revenue != null) { objEventItem = objEventItem.Call <AndroidJavaObject>("withRevenue", item.revenue); } if (item.attribute1 != null) { objEventItem = objEventItem.Call <AndroidJavaObject>("withAttribute1", item.attribute1); } if (item.attribute2 != null) { objEventItem = objEventItem.Call <AndroidJavaObject>("withAttribute2", item.attribute2); } if (item.attribute3 != null) { objEventItem = objEventItem.Call <AndroidJavaObject>("withAttribute3", item.attribute3); } if (item.attribute4 != null) { objEventItem = objEventItem.Call <AndroidJavaObject>("withAttribute4", item.attribute4); } if (item.attribute5 != null) { objEventItem = objEventItem.Call <AndroidJavaObject>("withAttribute5", item.attribute5); } // Add to list of MATEventItems objArrayList.Call <bool>("add", objEventItem); } objTuneEvent = objTuneEvent.Call <AndroidJavaObject>("withEventItems", objArrayList); } if (tuneEvent.receipt != null && tuneEvent.receiptSignature != null) { objTuneEvent = objTuneEvent.Call <AndroidJavaObject>("withReceipt", tuneEvent.receipt, tuneEvent.receiptSignature); } if (tuneEvent.contentType != null) { objTuneEvent = objTuneEvent.Call <AndroidJavaObject>("withContentType", tuneEvent.contentType); } if (tuneEvent.contentId != null) { objTuneEvent = objTuneEvent.Call <AndroidJavaObject>("withContentId", tuneEvent.contentId); } if (tuneEvent.level != null) { objTuneEvent = objTuneEvent.Call <AndroidJavaObject>("withLevel", tuneEvent.level); } if (tuneEvent.quantity != null) { objTuneEvent = objTuneEvent.Call <AndroidJavaObject>("withQuantity", tuneEvent.quantity); } if (tuneEvent.searchString != null) { objTuneEvent = objTuneEvent.Call <AndroidJavaObject>("withSearchString", tuneEvent.searchString); } if (tuneEvent.date1 != null) { double milliseconds = new TimeSpan(((DateTime)tuneEvent.date1).Ticks).TotalMilliseconds; //datetime starts in 1970 DateTime datetime = new DateTime(1970, 1, 1); double millisecondsFrom1970 = milliseconds - (new TimeSpan(datetime.Ticks)).TotalMilliseconds; // Convert C# DateTime to Java Date AndroidJavaObject objDouble = new AndroidJavaObject("java.lang.Double", millisecondsFrom1970); long longDate = objDouble.Call <long>("longValue"); AndroidJavaObject objDate = new AndroidJavaObject("java.util.Date", longDate); objTuneEvent = objTuneEvent.Call <AndroidJavaObject>("withDate1", objDate); } if (tuneEvent.date2 != null) { double milliseconds = new TimeSpan(((DateTime)tuneEvent.date2).Ticks).TotalMilliseconds; //datetime starts in 1970 DateTime datetime = new DateTime(1970, 1, 1); double millisecondsFrom1970 = milliseconds - (new TimeSpan(datetime.Ticks)).TotalMilliseconds; // Convert C# DateTime to Java Date AndroidJavaObject objDouble = new AndroidJavaObject("java.lang.Double", millisecondsFrom1970); long longDate = objDouble.Call <long>("longValue"); AndroidJavaObject objDate = new AndroidJavaObject("java.util.Date", longDate); objTuneEvent = objTuneEvent.Call <AndroidJavaObject>("withDate2", objDate); } if (tuneEvent.attribute1 != null) { objTuneEvent = objTuneEvent.Call <AndroidJavaObject>("withAttribute1", tuneEvent.attribute1); } if (tuneEvent.attribute2 != null) { objTuneEvent = objTuneEvent.Call <AndroidJavaObject>("withAttribute2", tuneEvent.attribute2); } if (tuneEvent.attribute3 != null) { objTuneEvent = objTuneEvent.Call <AndroidJavaObject>("withAttribute3", tuneEvent.attribute3); } if (tuneEvent.attribute4 != null) { objTuneEvent = objTuneEvent.Call <AndroidJavaObject>("withAttribute4", tuneEvent.attribute4); } if (tuneEvent.attribute5 != null) { objTuneEvent = objTuneEvent.Call <AndroidJavaObject>("withAttribute5", tuneEvent.attribute5); } return(objTuneEvent); }
/// <para> /// Measures the event with MATEvent. /// </para> /// <param name="tuneEvent">MATEvent object of event values to measure</param> public static void MeasureEvent(MATEvent tuneEvent) { if (!Application.isEditor) { int itemCount = null == tuneEvent.eventItems ? 0 : tuneEvent.eventItems.Length; #if UNITY_ANDROID MATAndroid.Instance.MeasureEvent(tuneEvent); #endif #if UNITY_METRO // Set event characteristic values separately SetEventContentType(tuneEvent.contentType); SetEventContentId(tuneEvent.contentId); // Set event characteristic values separately SetEventContentType(tuneEvent.contentType); SetEventContentId(tuneEvent.contentId); if (tuneEvent.level != null) { SetEventLevel((int)tuneEvent.level); } if (tuneEvent.quantity != null) { SetEventQuantity((int)tuneEvent.quantity); } SetEventSearchString(tuneEvent.searchString); if (tuneEvent.rating != null) { SetEventRating((float)tuneEvent.rating); } if (tuneEvent.date1 != null) { SetEventDate1((DateTime)tuneEvent.date1); } if (tuneEvent.date2 != null) { SetEventDate2((DateTime)tuneEvent.date2); } SetEventAttribute1(tuneEvent.attribute1); SetEventAttribute2(tuneEvent.attribute2); SetEventAttribute3(tuneEvent.attribute3); SetEventAttribute4(tuneEvent.attribute4); SetEventAttribute5(tuneEvent.attribute5); #endif #if UNITY_IPHONE MATEventIos eventIos = new MATEventIos(tuneEvent); byte[] receiptBytes = null == tuneEvent.receipt ? null : System.Convert.FromBase64String(tuneEvent.receipt); int receiptByteCount = null == receiptBytes ? 0 : receiptBytes.Length; // Convert MATItem to C-marshallable struct MATItemIos MATItemIos[] items = new MATItemIos[itemCount]; for (int i = 0; i < itemCount; i++) { items[i] = new MATItemIos(tuneEvent.eventItems[i]); } MATExterns.TuneMeasureEvent(eventIos, items, itemCount, receiptBytes, receiptByteCount); #endif #if UNITY_METRO //Convert MATItem[] to MATEventItem[]. These are the same things, but must be converted for recognition of //MobileAppTracker.cs. MATEventItem[] newarr = new MATEventItem[itemCount]; //Conversion is necessary to prevent the need of referencing a separate class. for(int i = 0; i < itemCount; i++) { MATItem item = tuneEvent.eventItems[i]; newarr[i] = new MATEventItem(item.name, item.quantity == null ? 0 : (int)item.quantity, item.unitPrice == null ? 0 : (double)item.unitPrice, item.revenue == null ? 0 : (double)item.revenue, item.attribute1, item.attribute2, item.attribute3, item.attribute4, item.attribute5); } List<MATEventItem> list = newarr.ToList(); MobileAppTracker.Instance.MeasureAction(tuneEvent.name, tuneEvent.revenue == null ? 0 : (double)tuneEvent.revenue, tuneEvent.currencyCode, tuneEvent.advertiserRefId, list); #endif } }
public MATEventIos(MATEvent matEvent) { name = matEvent.name; eventId = null == matEvent.name ? matEvent.id.ToString() : null; advertiserRefId = matEvent.advertiserRefId; attribute1 = matEvent.attribute1; attribute2 = matEvent.attribute2; attribute3 = matEvent.attribute3; attribute4 = matEvent.attribute4; attribute5 = matEvent.attribute5; contentId = null == matEvent.contentId ? null : matEvent.contentId.ToString(); contentType = matEvent.contentType; currencyCode = matEvent.currencyCode; level = null == matEvent.level ? null : matEvent.level.ToString(); quantity = null == matEvent.quantity ? null : matEvent.quantity.ToString(); rating = null == matEvent.rating ? null : matEvent.rating.ToString(); revenue = null == matEvent.revenue ? null : matEvent.revenue.ToString(); searchString = matEvent.searchString; transactionState = null == matEvent.transactionState ? null : matEvent.transactionState.ToString(); date1 = null; date2 = null; // datetime starts in 1970 DateTime datetime = new DateTime(1970, 1, 1); if(matEvent.date1.HasValue) { double millis = new TimeSpan(matEvent.date1.Value.Ticks).TotalMilliseconds; double millisFrom1970 = millis - (new TimeSpan(datetime.Ticks)).TotalMilliseconds; date1 = millisFrom1970.ToString(); } if(matEvent.date2.HasValue) { double millis = new TimeSpan(matEvent.date2.Value.Ticks).TotalMilliseconds; double millisFrom1970 = millis - (new TimeSpan(datetime.Ticks)).TotalMilliseconds; date2 = millisFrom1970.ToString(); } }
private AndroidJavaObject GetMATEventJavaObject(MATEvent matEvent) { // Convert C# MATEvent to new Java matEvent object AndroidJavaObject objMatEvent; if (matEvent.name == null) { objMatEvent = new AndroidJavaObject("com.mobileapptracker.MATEvent", matEvent.id); } else { objMatEvent = new AndroidJavaObject("com.mobileapptracker.MATEvent", matEvent.name); } // Set the optional params if they exist if (matEvent.revenue != null) { objMatEvent = objMatEvent.Call<AndroidJavaObject>("withRevenue", matEvent.revenue); } if (matEvent.currencyCode != null) { objMatEvent = objMatEvent.Call<AndroidJavaObject>("withCurrencyCode", matEvent.currencyCode); } if (matEvent.advertiserRefId != null) { objMatEvent = objMatEvent.Call<AndroidJavaObject>("withAdvertiserRefId", matEvent.advertiserRefId); } if (matEvent.eventItems != null) { // Convert MATItem[] to Arraylist<MATEventItem> AndroidJavaObject objArrayList = new AndroidJavaObject("java.util.ArrayList"); foreach (MATItem item in matEvent.eventItems) { // Convert MATItem to matEventItem AndroidJavaObject objEventItem = new AndroidJavaObject("com.mobileapptracker.MATEventItem", item.name); if (item.quantity != null) { objEventItem = objEventItem.Call<AndroidJavaObject>("withQuantity", item.quantity); } if (item.unitPrice != null) { objEventItem = objEventItem.Call<AndroidJavaObject>("withUnitPrice", item.unitPrice); } if (item.revenue != null) { objEventItem = objEventItem.Call<AndroidJavaObject>("withRevenue", item.revenue); } if (item.attribute1 != null) { objEventItem = objEventItem.Call<AndroidJavaObject>("withAttribute1", item.attribute1); } if (item.attribute2 != null) { objEventItem = objEventItem.Call<AndroidJavaObject>("withAttribute2", item.attribute2); } if (item.attribute3 != null) { objEventItem = objEventItem.Call<AndroidJavaObject>("withAttribute3", item.attribute3); } if (item.attribute4 != null) { objEventItem = objEventItem.Call<AndroidJavaObject>("withAttribute4", item.attribute4); } if (item.attribute5 != null) { objEventItem = objEventItem.Call<AndroidJavaObject>("withAttribute5", item.attribute5); } // Add to list of matEventItems objArrayList.Call<bool>("add", objEventItem); } objMatEvent = objMatEvent.Call<AndroidJavaObject>("withEventItems", objArrayList); } if (matEvent.receipt != null && matEvent.receiptSignature != null) { objMatEvent = objMatEvent.Call<AndroidJavaObject>("withReceipt", matEvent.receipt, matEvent.receiptSignature); } if (matEvent.contentType != null) { objMatEvent = objMatEvent.Call<AndroidJavaObject>("withContentType", matEvent.contentType); } if (matEvent.contentId != null) { objMatEvent = objMatEvent.Call<AndroidJavaObject>("withContentId", matEvent.contentId); } if (matEvent.level != null) { objMatEvent = objMatEvent.Call<AndroidJavaObject>("withLevel", matEvent.level); } if (matEvent.quantity != null) { objMatEvent = objMatEvent.Call<AndroidJavaObject>("withQuantity", matEvent.quantity); } if (matEvent.searchString != null) { objMatEvent = objMatEvent.Call<AndroidJavaObject>("withSearchString", matEvent.searchString); } if (matEvent.date1 != null) { double milliseconds = new TimeSpan(((DateTime)matEvent.date1).Ticks).TotalMilliseconds; //datetime starts in 1970 DateTime datetime = new DateTime(1970, 1, 1); double millisecondsFrom1970 = milliseconds - (new TimeSpan(datetime.Ticks)).TotalMilliseconds; // Convert C# DateTime to Java Date AndroidJavaObject objDouble = new AndroidJavaObject("java.lang.Double", millisecondsFrom1970); long longDate = objDouble.Call<long>("longValue"); AndroidJavaObject objDate = new AndroidJavaObject("java.util.Date", longDate); objMatEvent = objMatEvent.Call<AndroidJavaObject>("withDate1", objDate); } if (matEvent.date2 != null) { double milliseconds = new TimeSpan(((DateTime)matEvent.date2).Ticks).TotalMilliseconds; //datetime starts in 1970 DateTime datetime = new DateTime(1970, 1, 1); double millisecondsFrom1970 = milliseconds - (new TimeSpan(datetime.Ticks)).TotalMilliseconds; // Convert C# DateTime to Java Date AndroidJavaObject objDouble = new AndroidJavaObject("java.lang.Double", millisecondsFrom1970); long longDate = objDouble.Call<long>("longValue"); AndroidJavaObject objDate = new AndroidJavaObject("java.util.Date", longDate); objMatEvent = objMatEvent.Call<AndroidJavaObject>("withDate2", objDate); } if (matEvent.attribute1 != null) { objMatEvent = objMatEvent.Call<AndroidJavaObject>("withAttribute1", matEvent.attribute1); } if (matEvent.attribute2 != null) { objMatEvent = objMatEvent.Call<AndroidJavaObject>("withAttribute2", matEvent.attribute2); } if (matEvent.attribute3 != null) { objMatEvent = objMatEvent.Call<AndroidJavaObject>("withAttribute3", matEvent.attribute3); } if (matEvent.attribute4 != null) { objMatEvent = objMatEvent.Call<AndroidJavaObject>("withAttribute4", matEvent.attribute4); } if (matEvent.attribute5 != null) { objMatEvent = objMatEvent.Call<AndroidJavaObject>("withAttribute5", matEvent.attribute5); } return objMatEvent; }
public void MeasureEvent(MATEvent matEvent) { AndroidJavaObject objEvent = GetMATEventJavaObject(matEvent); ajcInstance.Call("measureEvent", objEvent); }
public MATEvent(string name) { this = new MATEvent(0, 0); this.name = name; }
private AndroidJavaObject GetTuneEventJavaObject(MATEvent tuneEvent) { AndroidJavaObject obj2; if (tuneEvent.name == null) { object[] args = new object[] { tuneEvent.id }; obj2 = new AndroidJavaObject("com.mobileapptracker.MATEvent", args); } else { object[] objArray2 = new object[] { tuneEvent.name }; obj2 = new AndroidJavaObject("com.mobileapptracker.MATEvent", objArray2); } if (tuneEvent.revenue.HasValue) { object[] objArray3 = new object[] { tuneEvent.revenue }; obj2 = obj2.Call <AndroidJavaObject>("withRevenue", objArray3); } if (tuneEvent.currencyCode != null) { object[] objArray4 = new object[] { tuneEvent.currencyCode }; obj2 = obj2.Call <AndroidJavaObject>("withCurrencyCode", objArray4); } if (tuneEvent.advertiserRefId != null) { object[] objArray5 = new object[] { tuneEvent.advertiserRefId }; obj2 = obj2.Call <AndroidJavaObject>("withAdvertiserRefId", objArray5); } if (tuneEvent.eventItems != null) { AndroidJavaObject obj3 = new AndroidJavaObject("java.util.ArrayList", new object[0]); foreach (MATItem item in tuneEvent.eventItems) { object[] objArray6 = new object[] { item.name }; AndroidJavaObject obj4 = new AndroidJavaObject("com.mobileapptracker.MATEventItem", objArray6); if (item.quantity.HasValue) { object[] objArray7 = new object[] { item.quantity }; obj4 = obj4.Call <AndroidJavaObject>("withQuantity", objArray7); } if (item.unitPrice.HasValue) { object[] objArray8 = new object[] { item.unitPrice }; obj4 = obj4.Call <AndroidJavaObject>("withUnitPrice", objArray8); } if (item.revenue.HasValue) { object[] objArray9 = new object[] { item.revenue }; obj4 = obj4.Call <AndroidJavaObject>("withRevenue", objArray9); } if (item.attribute1 != null) { object[] objArray10 = new object[] { item.attribute1 }; obj4 = obj4.Call <AndroidJavaObject>("withAttribute1", objArray10); } if (item.attribute2 != null) { object[] objArray11 = new object[] { item.attribute2 }; obj4 = obj4.Call <AndroidJavaObject>("withAttribute2", objArray11); } if (item.attribute3 != null) { object[] objArray12 = new object[] { item.attribute3 }; obj4 = obj4.Call <AndroidJavaObject>("withAttribute3", objArray12); } if (item.attribute4 != null) { object[] objArray13 = new object[] { item.attribute4 }; obj4 = obj4.Call <AndroidJavaObject>("withAttribute4", objArray13); } if (item.attribute5 != null) { object[] objArray14 = new object[] { item.attribute5 }; obj4 = obj4.Call <AndroidJavaObject>("withAttribute5", objArray14); } object[] objArray15 = new object[] { obj4 }; obj3.Call <bool>("add", objArray15); } object[] objArray16 = new object[] { obj3 }; obj2 = obj2.Call <AndroidJavaObject>("withEventItems", objArray16); } if ((tuneEvent.receipt != null) && (tuneEvent.receiptSignature != null)) { object[] objArray17 = new object[] { tuneEvent.receipt, tuneEvent.receiptSignature }; obj2 = obj2.Call <AndroidJavaObject>("withReceipt", objArray17); } if (tuneEvent.contentType != null) { object[] objArray18 = new object[] { tuneEvent.contentType }; obj2 = obj2.Call <AndroidJavaObject>("withContentType", objArray18); } if (tuneEvent.contentId != null) { object[] objArray19 = new object[] { tuneEvent.contentId }; obj2 = obj2.Call <AndroidJavaObject>("withContentId", objArray19); } if (tuneEvent.level.HasValue) { object[] objArray20 = new object[] { tuneEvent.level }; obj2 = obj2.Call <AndroidJavaObject>("withLevel", objArray20); } if (tuneEvent.quantity.HasValue) { object[] objArray21 = new object[] { tuneEvent.quantity }; obj2 = obj2.Call <AndroidJavaObject>("withQuantity", objArray21); } if (tuneEvent.searchString != null) { object[] objArray22 = new object[] { tuneEvent.searchString }; obj2 = obj2.Call <AndroidJavaObject>("withSearchString", objArray22); } if (tuneEvent.date1.HasValue) { TimeSpan span = new TimeSpan(tuneEvent.date1.Value.Ticks); double totalMilliseconds = span.TotalMilliseconds; DateTime time = new DateTime(0x7b2, 1, 1); TimeSpan span2 = new TimeSpan(time.Ticks); double num3 = totalMilliseconds - span2.TotalMilliseconds; object[] objArray23 = new object[] { num3 }; long num4 = new AndroidJavaObject("java.lang.Double", objArray23).Call <long>("longValue", new object[0]); object[] objArray24 = new object[] { num4 }; AndroidJavaObject obj6 = new AndroidJavaObject("java.util.Date", objArray24); object[] objArray25 = new object[] { obj6 }; obj2 = obj2.Call <AndroidJavaObject>("withDate1", objArray25); } if (tuneEvent.date2.HasValue) { TimeSpan span3 = new TimeSpan(tuneEvent.date2.Value.Ticks); double num5 = span3.TotalMilliseconds; DateTime time2 = new DateTime(0x7b2, 1, 1); TimeSpan span4 = new TimeSpan(time2.Ticks); double num6 = num5 - span4.TotalMilliseconds; object[] objArray26 = new object[] { num6 }; long num7 = new AndroidJavaObject("java.lang.Double", objArray26).Call <long>("longValue", new object[0]); object[] objArray27 = new object[] { num7 }; AndroidJavaObject obj8 = new AndroidJavaObject("java.util.Date", objArray27); object[] objArray28 = new object[] { obj8 }; obj2 = obj2.Call <AndroidJavaObject>("withDate2", objArray28); } if (tuneEvent.attribute1 != null) { object[] objArray29 = new object[] { tuneEvent.attribute1 }; obj2 = obj2.Call <AndroidJavaObject>("withAttribute1", objArray29); } if (tuneEvent.attribute2 != null) { object[] objArray30 = new object[] { tuneEvent.attribute2 }; obj2 = obj2.Call <AndroidJavaObject>("withAttribute2", objArray30); } if (tuneEvent.attribute3 != null) { object[] objArray31 = new object[] { tuneEvent.attribute3 }; obj2 = obj2.Call <AndroidJavaObject>("withAttribute3", objArray31); } if (tuneEvent.attribute4 != null) { object[] objArray32 = new object[] { tuneEvent.attribute4 }; obj2 = obj2.Call <AndroidJavaObject>("withAttribute4", objArray32); } if (tuneEvent.attribute5 != null) { object[] objArray33 = new object[] { tuneEvent.attribute5 }; obj2 = obj2.Call <AndroidJavaObject>("withAttribute5", objArray33); } return(obj2); }
public MATEvent(int id) { this = new MATEvent(0, 0); this.id = new int?(id); }
private AndroidJavaObject GetMATEventJavaObject(MATEvent matEvent) { AndroidJavaObject androidJavaObject; if (matEvent.name == null) { androidJavaObject = new AndroidJavaObject("com.mobileapptracker.MATEvent", new object[] { matEvent.id }); } else { androidJavaObject = new AndroidJavaObject("com.mobileapptracker.MATEvent", new object[] { matEvent.name }); } double?revenue = matEvent.revenue; if (revenue.HasValue) { androidJavaObject = androidJavaObject.Call <AndroidJavaObject>("withRevenue", new object[] { matEvent.revenue }); } if (matEvent.currencyCode != null) { androidJavaObject = androidJavaObject.Call <AndroidJavaObject>("withCurrencyCode", new object[] { matEvent.currencyCode }); } if (matEvent.advertiserRefId != null) { androidJavaObject = androidJavaObject.Call <AndroidJavaObject>("withAdvertiserRefId", new object[] { matEvent.advertiserRefId }); } if (matEvent.eventItems != null) { AndroidJavaObject androidJavaObject2 = new AndroidJavaObject("java.util.ArrayList", new object[0]); MATItem[] eventItems = matEvent.eventItems; for (int i = 0; i < eventItems.Length; i++) { MATItem mATItem = eventItems[i]; AndroidJavaObject androidJavaObject3 = new AndroidJavaObject("com.mobileapptracker.MATEventItem", new object[] { mATItem.name }); int?quantity = mATItem.quantity; if (quantity.HasValue) { androidJavaObject3 = androidJavaObject3.Call <AndroidJavaObject>("withQuantity", new object[] { mATItem.quantity }); } double?unitPrice = mATItem.unitPrice; if (unitPrice.HasValue) { androidJavaObject3 = androidJavaObject3.Call <AndroidJavaObject>("withUnitPrice", new object[] { mATItem.unitPrice }); } double?revenue2 = mATItem.revenue; if (revenue2.HasValue) { androidJavaObject3 = androidJavaObject3.Call <AndroidJavaObject>("withRevenue", new object[] { mATItem.revenue }); } if (mATItem.attribute1 != null) { androidJavaObject3 = androidJavaObject3.Call <AndroidJavaObject>("withAttribute1", new object[] { mATItem.attribute1 }); } if (mATItem.attribute2 != null) { androidJavaObject3 = androidJavaObject3.Call <AndroidJavaObject>("withAttribute2", new object[] { mATItem.attribute2 }); } if (mATItem.attribute3 != null) { androidJavaObject3 = androidJavaObject3.Call <AndroidJavaObject>("withAttribute3", new object[] { mATItem.attribute3 }); } if (mATItem.attribute4 != null) { androidJavaObject3 = androidJavaObject3.Call <AndroidJavaObject>("withAttribute4", new object[] { mATItem.attribute4 }); } if (mATItem.attribute5 != null) { androidJavaObject3 = androidJavaObject3.Call <AndroidJavaObject>("withAttribute5", new object[] { mATItem.attribute5 }); } androidJavaObject2.Call <bool>("add", new object[] { androidJavaObject3 }); } androidJavaObject = androidJavaObject.Call <AndroidJavaObject>("withEventItems", new object[] { androidJavaObject2 }); } if (matEvent.receipt != null && matEvent.receiptSignature != null) { androidJavaObject = androidJavaObject.Call <AndroidJavaObject>("withReceipt", new object[] { matEvent.receipt, matEvent.receiptSignature }); } if (matEvent.contentType != null) { androidJavaObject = androidJavaObject.Call <AndroidJavaObject>("withContentType", new object[] { matEvent.contentType }); } if (matEvent.contentId != null) { androidJavaObject = androidJavaObject.Call <AndroidJavaObject>("withContentId", new object[] { matEvent.contentId }); } int?level = matEvent.level; if (level.HasValue) { androidJavaObject = androidJavaObject.Call <AndroidJavaObject>("withLevel", new object[] { matEvent.level }); } int?quantity2 = matEvent.quantity; if (quantity2.HasValue) { androidJavaObject = androidJavaObject.Call <AndroidJavaObject>("withQuantity", new object[] { matEvent.quantity }); } if (matEvent.searchString != null) { androidJavaObject = androidJavaObject.Call <AndroidJavaObject>("withSearchString", new object[] { matEvent.searchString }); } DateTime?date = matEvent.date1; if (date.HasValue) { DateTime? date2 = matEvent.date1; TimeSpan timeSpan = new TimeSpan(date2.Value.Ticks); double totalMilliseconds = timeSpan.TotalMilliseconds; DateTime dateTime = new DateTime(1970, 1, 1); double arg_465_0 = totalMilliseconds; TimeSpan timeSpan2 = new TimeSpan(dateTime.Ticks); double num = arg_465_0 - timeSpan2.TotalMilliseconds; AndroidJavaObject androidJavaObject4 = new AndroidJavaObject("java.lang.Double", new object[] { num }); long num2 = androidJavaObject4.Call <long>("longValue", new object[0]); AndroidJavaObject androidJavaObject5 = new AndroidJavaObject("java.util.Date", new object[] { num2 }); androidJavaObject = androidJavaObject.Call <AndroidJavaObject>("withDate1", new object[] { androidJavaObject5 }); } DateTime?date3 = matEvent.date2; if (date3.HasValue) { DateTime? date4 = matEvent.date2; TimeSpan timeSpan3 = new TimeSpan(date4.Value.Ticks); double totalMilliseconds2 = timeSpan3.TotalMilliseconds; DateTime dateTime2 = new DateTime(1970, 1, 1); double arg_52E_0 = totalMilliseconds2; TimeSpan timeSpan4 = new TimeSpan(dateTime2.Ticks); double num3 = arg_52E_0 - timeSpan4.TotalMilliseconds; AndroidJavaObject androidJavaObject6 = new AndroidJavaObject("java.lang.Double", new object[] { num3 }); long num4 = androidJavaObject6.Call <long>("longValue", new object[0]); AndroidJavaObject androidJavaObject7 = new AndroidJavaObject("java.util.Date", new object[] { num4 }); androidJavaObject = androidJavaObject.Call <AndroidJavaObject>("withDate2", new object[] { androidJavaObject7 }); } if (matEvent.attribute1 != null) { androidJavaObject = androidJavaObject.Call <AndroidJavaObject>("withAttribute1", new object[] { matEvent.attribute1 }); } if (matEvent.attribute2 != null) { androidJavaObject = androidJavaObject.Call <AndroidJavaObject>("withAttribute2", new object[] { matEvent.attribute2 }); } if (matEvent.attribute3 != null) { androidJavaObject = androidJavaObject.Call <AndroidJavaObject>("withAttribute3", new object[] { matEvent.attribute3 }); } if (matEvent.attribute4 != null) { androidJavaObject = androidJavaObject.Call <AndroidJavaObject>("withAttribute4", new object[] { matEvent.attribute4 }); } if (matEvent.attribute5 != null) { androidJavaObject = androidJavaObject.Call <AndroidJavaObject>("withAttribute5", new object[] { matEvent.attribute5 }); } return(androidJavaObject); }
void OnGUI() { GUIStyle headingLabelStyle = new GUIStyle(); headingLabelStyle.fontStyle = FontStyle.Bold; headingLabelStyle.fontSize = 50; headingLabelStyle.alignment = TextAnchor.MiddleCenter; headingLabelStyle.normal.textColor = Color.white; GUI.Label(new Rect(10, 5, Screen.width - 20, Screen.height/10), "MAT Unity Test App", headingLabelStyle); GUI.skin.button.fontSize = 40; if (GUI.Button (new Rect (10, Screen.height/10, Screen.width - 20, Screen.height/10), "Start MAT")) { print ("Start MAT clicked"); #if (UNITY_ANDROID || UNITY_IPHONE || UNITY_WP8 || UNITY_METRO) MATBinding.Init(MAT_ADVERTISER_ID, MAT_CONVERSION_KEY); MATBinding.SetPackageName(MAT_PACKAGE_NAME); MATBinding.SetFacebookEventLogging(true, false); #endif #if (UNITY_ANDROID || UNITY_IPHONE) MATBinding.CheckForDeferredDeeplinkWithTimeout(750); // 750 ms MATBinding.AutomateIapEventMeasurement(true); #endif } else if (GUI.Button (new Rect (10, 2*Screen.height/10, Screen.width - 20, Screen.height/10), "Set Delegate")) { print ("Set Delegate clicked"); #if (UNITY_ANDROID || UNITY_IPHONE) MATBinding.SetDelegate(true); #endif #if UNITY_WP8 MATBinding.SetMATResponse(new SampleWP8MATResponse()); #endif #if UNITY_METRO MATBinding.SetMATResponse(new SampleWinStoreMATResponse()); #endif } else if (GUI.Button (new Rect (10, 3*Screen.height/10, Screen.width - 20, Screen.height/10), "Enable Debug Mode")) { print ("Enable Debug Mode clicked"); #if (UNITY_ANDROID || UNITY_IPHONE || UNITY_WP8 || UNITY_METRO) // NOTE: !!! ONLY FOR DEBUG !!! // !!! Make sure you set to false // OR // remove the setDebugMode and setAllowDuplicates calls for Production builds !!! MATBinding.SetDebugMode(true); #endif } else if (GUI.Button (new Rect (10, 4*Screen.height/10, Screen.width - 20, Screen.height/10), "Allow Duplicates")) { print ("Allow Duplicates clicked"); #if (UNITY_ANDROID || UNITY_IPHONE || UNITY_WP8 || UNITY_METRO) // NOTE: !!! ONLY FOR DEBUG !!! // !!! Make sure you set to false // OR // remove the setDebugMode and setAllowDuplicates calls for Production builds !!! MATBinding.SetAllowDuplicates(true); #endif } else if (GUI.Button (new Rect (10, 5*Screen.height/10, Screen.width - 20, Screen.height/10), "Measure Session")) { print ("Measure Session clicked"); #if (UNITY_ANDROID || UNITY_IPHONE || UNITY_WP8 || UNITY_METRO) MATBinding.MeasureSession(); #endif } else if (GUI.Button (new Rect (10, 6*Screen.height/10, Screen.width - 20, Screen.height/10), "Measure Event")) { print ("Measure Event clicked"); #if (UNITY_ANDROID || UNITY_IPHONE || UNITY_WP8 || UNITY_METRO) MATBinding.MeasureEvent("evt11"); #endif } else if (GUI.Button (new Rect (10, 7*Screen.height/10, Screen.width - 20, Screen.height/10), "Measure Event With Event Items")) { print ("Measure Event With Event Items clicked"); #if (UNITY_ANDROID || UNITY_IPHONE || UNITY_WP8 || UNITY_METRO) MATItem item1 = new MATItem(); item1.name = "subitem1"; item1.unitPrice = 5; item1.quantity = 5; item1.revenue = 3; item1.attribute2 = "attrValue2"; item1.attribute3 = "attrValue3"; item1.attribute4 = "attrValue4"; item1.attribute5 = "attrValue5"; MATItem item2 = new MATItem(); item2.name = "subitem2"; item2.unitPrice = 1; item2.quantity = 3; item2.revenue = 1.5; item2.attribute1 = "attrValue1"; item2.attribute3 = "attrValue3"; MATItem[] eventItems = { item1, item2 }; MATEvent matEvent = new MATEvent("purchase"); matEvent.revenue = 10; matEvent.currencyCode = "AUD"; matEvent.advertiserRefId = "ref222"; matEvent.attribute1 = "test_attribute1"; matEvent.attribute2 = "test_attribute2"; matEvent.attribute3 = "test_attribute3"; matEvent.attribute4 = "test_attribute4"; matEvent.attribute5 = "test_attribute5"; matEvent.contentType = "test_contentType"; matEvent.contentId = "test_contentId"; matEvent.date1 = DateTime.UtcNow; matEvent.date2 = DateTime.UtcNow.Add(new TimeSpan((new DateTime(2,1,1)).Ticks)); matEvent.level = 3; matEvent.quantity = 2; matEvent.rating = 4.5; matEvent.searchString = "test_searchString"; matEvent.eventItems = eventItems; // transaction state may be set to the value received from the iOS/Android app store. matEvent.transactionState = 1; #if UNITY_IPHONE matEvent.receipt = getSampleiTunesIAPReceipt(); #endif MATBinding.MeasureEvent(matEvent); #endif } else if (GUI.Button (new Rect (10, 8*Screen.height/10, Screen.width - 20, Screen.height/10), "Test Setter Methods")) { print ("Test Setter Methods clicked"); #if (UNITY_ANDROID || UNITY_IPHONE || UNITY_WP8 || UNITY_METRO) MATBinding.SetAge(34); MATBinding.SetAllowDuplicates(true); MATBinding.SetAppAdTracking(true); MATBinding.SetDebugMode(true); MATBinding.SetExistingUser(false); MATBinding.SetFacebookUserId("temp_facebook_user_id"); MATBinding.SetGender(0); MATBinding.SetGoogleUserId("temp_google_user_id"); MATBinding.SetLocation(111,222,333); //MATBinding.SetPackageName(MAT_PACKAGE_NAME); MATBinding.SetPayingUser(true); MATBinding.SetPhoneNumber("111-222-3456"); MATBinding.SetTwitterUserId("twitter_user_id"); MATBinding.SetUserId("temp_user_id"); MATBinding.SetUserName("temp_user_name"); MATBinding.SetUserEmail("*****@*****.**"); //iOS-specific Features #if UNITY_IPHONE #if UNITY_5_0 MATBinding.SetAppleAdvertisingIdentifier(UnityEngine.iOS.Device.advertisingIdentifier, UnityEngine.iOS.Device.advertisingTrackingEnabled); #else MATBinding.SetAppleAdvertisingIdentifier(UnityEngine.iOS.Device.advertisingIdentifier, UnityEngine.iOS.Device.advertisingTrackingEnabled); #endif MATBinding.SetAppleVendorIdentifier(UnityEngine.iOS.Device.vendorIdentifier); MATBinding.SetDelegate(true); MATBinding.SetJailbroken(false); MATBinding.SetShouldAutoDetectJailbroken(true); MATBinding.SetShouldAutoGenerateVendorIdentifier(true); MATBinding.SetUseCookieTracking(false); #endif //Android-specific Features #if UNITY_ANDROID MATBinding.SetAndroidId("111111111111"); MATBinding.SetDeviceId("123456789123456"); MATBinding.SetGoogleAdvertisingId("12345678-1234-1234-1234-123456789012", true); MATBinding.SetMacAddress("AA:BB:CC:DD:EE:FF"); #endif //Windows Phone 8 Specific Features #if UNITY_WP8 MATBinding.SetAppName("testWP8_AppName"); MATBinding.SetAppVersion("testWP8_AppVersion"); MATBinding.SetLastOpenLogId("testWP8_LastOpenLogId"); MATBinding.SetOSVersion("testWP8_OS"); #endif //Android and iOS-specific Features #if (UNITY_ANDROID || UNITY_IPHONE) MATBinding.SetCurrencyCode("CAD"); MATBinding.SetTRUSTeId("1234567890"); MATPreloadData pd = new MATPreloadData("1122334455"); pd.advertiserSubAd = "some_adv_sub_ad_id"; pd.publisherSub3 = "some_pub_sub3"; MATBinding.SetPreloadedApp(pd); #endif #endif } else if (GUI.Button (new Rect (10, 9*Screen.height/10, Screen.width - 20, Screen.height/10), "Test Getter Methods")) { print ("Test Getter Methods clicked"); #if (UNITY_ANDROID || UNITY_IPHONE || UNITY_WP8 || UNITY_METRO) print ("isPayingUser = "******"matId = " + MATBinding.GetMATId()); print ("openLogId = " + MATBinding.GetOpenLogId()); #endif } }