public async Task EventItemsTest() { string eventName = "testEventItem"; double revenue = 14.99; string currency = "USD"; string refId = "1234"; MATEventItem item1 = new MATEventItem("testItem", 15, 1.05, 12.34, "attribute1", "attribute2", "attribute3", "attribute4", "attribute5"); MATEventItem item2 = new MATEventItem("testItem2", 9, 2.99, 19.99, "sword1", "sword2", "sword3", "sword4", "sword5"); List <MATEventItem> itemList = new List <MATEventItem>(); itemList.Add(item1); itemList.Add(item2); MATTestWrapper.Instance.MeasureAction(eventName, revenue, currency, refId, itemList); await Task.Delay(TimeSpan.FromSeconds(5)); Assert.IsTrue(param.CheckDefaultValues()); Assert.IsTrue(param.CheckActionIsConversion()); Assert.IsTrue(param.CheckKeyIsEqualToValue("site_event_name", eventName)); Assert.IsTrue(param.CheckKeyIsEqualToValue("revenue", revenue.ToString())); Assert.IsTrue(param.CheckKeyIsEqualToValue("currency_code", currency)); Assert.IsTrue(param.CheckKeyIsEqualToValue("advertiser_ref_id", refId)); Assert.IsTrue(param.CheckEventItems(itemList)); }
private void ActionBtn_Click(object sender, RoutedEventArgs e) { MATEventItem item1 = new MATEventItem("test item"); List <MATEventItem> items = new List <MATEventItem>(); items.Add(item1); mobileAppTracker.MeasureAction("test event", 0.99, "USD", "123", items); }
public async Task ActionEventItemsTest() { MATEventItem item1 = new MATEventItem("testItem", 15, 1.05, 12.34, "attribute1", "attribute2", "attribute3", "attribute4", "attribute5"); MATEventItem item2 = new MATEventItem("testItem2", 9, 2.99, 19.99, "sword1", "sword2", "sword3", "sword4", "sword5"); List <MATEventItem> itemList = new List <MATEventItem>(); itemList.Add(item1); itemList.Add(item2); MATTestWrapper.Instance.MeasureAction("testEventItems", 0, "USD", "1234", itemList); await Task.Delay(TimeSpan.FromSeconds(5)); Assert.IsTrue(callSuccess); Assert.IsFalse(callFailed); }
void OnGUI() { if (GUI.Button(new Rect(10, 10, 350, 100), "Track Install")) { print("trackInstall clicked"); trackInstall(); } if (GUI.Button(new Rect(10, 120, 350, 100), "Track Action")) { print("trackAction clicked"); trackAction("evt11", false, 0.35, "CAD"); } if (GUI.Button(new Rect(10, 230, 350, 100), "Track Action With Event")) { print("trackActionWithEvent clicked"); MATEventItem item1 = new MATEventItem(); item1.item = "subitem1"; item1.unitPrice = 5; item1.quantity = 5; item1.revenue = 3; MATEventItem item2 = new MATEventItem(); item2.item = "subitem2"; item2.unitPrice = 1; item2.quantity = 3; item2.revenue = 1.5; MATEventItem[] arr = { item1, item2 }; // transaction state may be set to the value received from the iOS/Android app store. int transactionState = 1; trackActionWithEventItem("event6With2Items", false, arr, arr.Length, null, 10, "USD", transactionState); } }
public bool CheckEventItems(List <MATEventItem> items) { if (dictionary == null) { return(false); } string unescapedEventItems = Uri.UnescapeDataString(dictionary["site_event_items"].ToString()); List <MATEventItem> siteEventItems = JsonConvert.DeserializeObject <List <MATEventItem> >(unescapedEventItems); for (int i = 0; i < items.Count; i++) { MATEventItem origItem = items[i]; MATEventItem requestItem = siteEventItems[i]; if (!origItem.Equals(requestItem)) { return(false); } } return(true); }
protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); //Create the user interface in code var layout = new LinearLayout (this); layout.Orientation = Orientation.Vertical; // Get our button from the layout resource, // and attach an event to it var aButton = new Button (this); aButton.Text = "Start MobileAppTracker"; aButton.Click += delegate { Log.Info (TAG, "MobileAppTracker constructor"); mat = new MobileAppTracker (this, MAT_ADVERTISER_ID, MAT_CONVERSION_KEY); }; layout.AddView (aButton); aButton = new Button (this); aButton.Text = "Toggle Debug Mode"; aButton.Click += (sender, e) => { isDebug = !isDebug; Log.Info (TAG, "SetDebugMode = " + isDebug); mat.SetDebugMode(isDebug); }; layout.AddView (aButton); aButton = new Button (this); aButton.Text = "Toggle Allow Duplicates"; aButton.Click += (sender, e) => { isAllowDup = !isAllowDup; Log.Info (TAG, "SetAllowDuplicates = " + isAllowDup); mat.SetAllowDuplicates(isAllowDup); }; layout.AddView (aButton); aButton = new Button (this); aButton.Text = "Test Install"; aButton.Click += (sender, e) => { Log.Info (TAG, "TrackInstall"); mat.TrackInstall(); }; layout.AddView (aButton); aButton = new Button (this); aButton.Text = "Test Update"; aButton.Click += (sender, e) => { Log.Info (TAG, "TrackUpdate"); mat.TrackUpdate(); }; layout.AddView (aButton); aButton = new Button (this); aButton.Text = "Test Event"; aButton.Click += (sender, e) => { Log.Info (TAG, "Track Event"); mat.TrackAction("event1"); }; layout.AddView (aButton); aButton = new Button (this); aButton.Text = "Test Event With Items"; aButton.Click += (sender, e) => { Log.Info (TAG, "Track Event With Items"); MATEventItem item1 = new MATEventItem("apple", 1, 0.99, 0.99); MATEventItem item2 = new MATEventItem("banana", "att1", "att2", "att3", "att4", "att5"); List<MATEventItem> list = new List<MATEventItem>(); list.Add(item1); list.Add(item2); mat.TrackAction("checkout", list); }; layout.AddView (aButton); aButton = new Button (this); aButton.Text = "Test Setters"; aButton.Click += (sender, e) => { Log.Info (TAG, "Test Setters"); mat.PackageName = "com.abc.xyz"; mat.SiteId = "12345"; mat.UserId = "user123"; mat.TRUSTeId = "truste123"; mat.RefId = "ref123"; mat.Latitude = 1.23; mat.Longitude = 12.3; mat.Altitude = 123.4; mat.AdvertiserId = "5432"; mat.Gender = MobileAppTracker.GenderFemale; mat.CurrencyCode = "RUB"; mat.Age = 23; mat.SetFacebookUserId("tempFacebookId"); mat.SetGoogleUserId("tempGoogleId"); mat.SetTwitterUserId("tempTwitterId"); String matData = "\nPackageName = " + mat.PackageName + "\nSiteId = " + mat.SiteId + "\nUserId = " + mat.UserId + "\nTRUSTeId = " + mat.TRUSTeId + "\nRefId = " + mat.RefId + "\nLatitude = " + mat.Latitude + "\nLongitude = " + mat.Longitude + "\nAltitude = " + mat.Altitude + "\nAdvertiserId = " + mat.AdvertiserId + "\nGender = " + mat.Gender + "\nCurrencyCode = " + mat.CurrencyCode + "\nAge = " + mat.Age; Log.Info (TAG, "MAT Data: " + matData); }; layout.AddView (aButton); SetContentView (layout); }
/// <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 } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); //Create the user interface in code var layout = new LinearLayout(this); layout.Orientation = Orientation.Vertical; // Get our button from the layout resource, // and attach an event to it var aButton = new Button(this); aButton.Text = "Start MobileAppTracker"; aButton.Click += delegate { Log.Info(TAG, "MobileAppTracker constructor"); MobileAppTracker.Init(this.ApplicationContext, MAT_ADVERTISER_ID, MAT_CONVERSION_KEY); }; layout.AddView(aButton); aButton = new Button(this); aButton.Text = "Toggle Debug Mode"; aButton.Click += (sender, e) => { isDebug = !isDebug; Log.Info(TAG, "SetDebugMode = " + isDebug); MobileAppTracker.Instance.SetDebugMode(isDebug); }; layout.AddView(aButton); aButton = new Button(this); aButton.Text = "Toggle Allow Duplicates"; aButton.Click += (sender, e) => { isAllowDup = !isAllowDup; Log.Info(TAG, "SetAllowDuplicates = " + isAllowDup); MobileAppTracker.Instance.SetAllowDuplicates(isAllowDup); }; layout.AddView(aButton); aButton = new Button(this); aButton.Text = "Test Session"; aButton.Click += (sender, e) => { Log.Info(TAG, "MeasureSession"); MobileAppTracker.Instance.MeasureSession(); }; layout.AddView(aButton); aButton = new Button(this); aButton.Text = "Test Event"; aButton.Click += (sender, e) => { Log.Info(TAG, "Measure Event"); MobileAppTracker.Instance.MeasureAction("event1"); }; layout.AddView(aButton); aButton = new Button(this); aButton.Text = "Test Event With Items"; aButton.Click += (sender, e) => { Log.Info(TAG, "Measure Event With Items"); MATEventItem item1 = new MATEventItem("apple", 1, 0.99, 0.99); MATEventItem item2 = new MATEventItem("banana", "attr1", "attr2", "attr3", "attr4", "attr5"); List <MATEventItem> list = new List <MATEventItem>(); list.Add(item1); list.Add(item2); MobileAppTracker.Instance.MeasureAction("checkout", list, 0, null, null); }; layout.AddView(aButton); aButton = new Button(this); aButton.Text = "Test Setters"; aButton.Click += (sender, e) => { Log.Info(TAG, "Test Setters"); MobileAppTracker.Instance.PackageName = "com.abc.xyz"; MobileAppTracker.Instance.SiteId = "12345"; MobileAppTracker.Instance.UserId = "user123"; MobileAppTracker.Instance.TRUSTeId = "truste123"; MobileAppTracker.Instance.Latitude = 1.23; MobileAppTracker.Instance.Longitude = 12.3; MobileAppTracker.Instance.Altitude = 123.4; MobileAppTracker.Instance.Gender = MobileAppTracker.GenderFemale; MobileAppTracker.Instance.CurrencyCode = "RUB"; MobileAppTracker.Instance.Age = 23; MobileAppTracker.Instance.ExistingUser = false; MobileAppTracker.Instance.IsPayingUser = true; MobileAppTracker.Instance.UserEmail = "*****@*****.**"; MobileAppTracker.Instance.UserName = "******"; MobileAppTracker.Instance.SetGoogleAdvertisingId("12345678-1234-1234-1234-123456789012", false); MobileAppTracker.Instance.FacebookUserId = "tempFacebookId"; MobileAppTracker.Instance.GoogleUserId = "tempGoogleId"; MobileAppTracker.Instance.TwitterUserId = "tempTwitterId"; String matData = "\nPackageName = " + MobileAppTracker.Instance.PackageName + "\nSiteId = " + MobileAppTracker.Instance.SiteId + "\nUserId = " + MobileAppTracker.Instance.UserId + "\nTRUSTeId = " + MobileAppTracker.Instance.TRUSTeId + "\nRefId = " + MobileAppTracker.Instance.RefId + "\nLatitude = " + MobileAppTracker.Instance.Latitude + "\nLongitude = " + MobileAppTracker.Instance.Longitude + "\nAltitude = " + MobileAppTracker.Instance.Altitude + "\nAdvertiserId = " + MobileAppTracker.Instance.AdvertiserId + "\nGender = " + MobileAppTracker.Instance.Gender + "\nCurrencyCode = " + MobileAppTracker.Instance.CurrencyCode + "\nAge = " + MobileAppTracker.Instance.Age; Log.Info(TAG, "MAT Data: " + matData); }; layout.AddView(aButton); aButton = new Button(this); aButton.Text = "Test Getters"; aButton.Click += (sender, e) => { Log.Info(TAG, "Test Getters"); String matId = MobileAppTracker.Instance.MatId; String openLogId = MobileAppTracker.Instance.OpenLogId; bool isPaying = MobileAppTracker.Instance.IsPayingUser; String matData = "\nMatId = " + matId + "\nOpenLogId = " + openLogId + "\nIsPayingUser = " + isPaying; Log.Info(TAG, matData); }; layout.AddView(aButton); SetContentView(layout); }
public override void ViewDidLoad() { base.ViewDidLoad(); btnStart.TouchUpInside += delegate { MobileAppTracker.InitTracker(MAT_ADVERTISER_ID, MAT_CONVERSION_KEY); MobileAppTracker.SetPackageName(MAT_PACKAGE_NAME); MobileAppTracker.SetAppleAdvertisingIdentifier(ASIdentifierManager.SharedManager.AdvertisingIdentifier, ASIdentifierManager.SharedManager.IsAdvertisingTrackingEnabled); MobileAppTracker.CheckForDeferredDeeplinkWithTimeout(0.75); // 0.75 sec MobileAppTracker.SetFacebookEventLogging(true, false); Console.WriteLine("MAT Tracker Started : adv id = {0}, conv key = {1}, package name = {2}", MAT_ADVERTISER_ID, MAT_CONVERSION_KEY, MAT_PACKAGE_NAME); }; btnDelegate.TouchUpInside += delegate { Console.WriteLine("matDelegate = " + matDelegate); MobileAppTracker.SetDelegate(matDelegate); }; btnDebug.TouchUpInside += delegate { MobileAppTracker.SetDebugMode(true); }; btnAllowDup.TouchUpInside += delegate { MobileAppTracker.SetAllowDuplicates(true); }; btnSession.TouchUpInside += delegate { MobileAppTracker.MeasureSession(); }; btnAction.TouchUpInside += delegate { MobileAppTracker.MeasureAction("eventAction1"); MobileAppTracker.MeasureAction("eventAction2", "ref1"); MobileAppTracker.MeasureAction("eventAction3", "ref2", 1.99f, "GBP"); MobileAppTracker.MeasureAction(932851438); MobileAppTracker.MeasureAction(932851438, "ref3"); MobileAppTracker.MeasureAction(932851438, "ref4", 1.99f, "GBP"); }; btnActionWithItems.TouchUpInside += delegate { MATEventItem item1 = MATEventItem.EventItemWithName("item1", 0.99f, 1, 0.99f, "1", "2", "3", "4", "5"); MATEventItem item2 = MATEventItem.EventItemWithName("item2", 0.50f, 2, 1.0f); MobileAppTracker.MeasureAction("eventItems", new MATEventItem[] { item1, item2 }); MobileAppTracker.MeasureAction("eventItems", new MATEventItem[] { item1, item2 }, "ref5"); MobileAppTracker.MeasureAction("eventItems", new MATEventItem[] { item1, item2 }, "ref6", 0.89f, "CAD", 0); MobileAppTracker.MeasureAction(932851438, new MATEventItem[] { item1, item2 }); MobileAppTracker.MeasureAction(932851438, new MATEventItem[] { item1, item2 }, "ref7"); MobileAppTracker.MeasureAction(932851438, new MATEventItem[] { item1, item2 }, "ref8", 0.89f, "CAD", 0); }; btnActionWithReceipt.TouchUpInside += delegate { MATEventItem item1 = MATEventItem.EventItemWithName("item1", 0.99f, 1, 0.99f, "6", "7", "8", "9", "10"); MATEventItem item2 = MATEventItem.EventItemWithName("item2", 0.50f, 2, 1.0f); MobileAppTracker.MeasureAction("eventReceipt", new MATEventItem[] { item1, item2 }, "ref9", 132.6f, "RUB", 0, NSData.FromString(GetSampleiTunesIAPReceipt())); MobileAppTracker.MeasureAction(932851438, new MATEventItem[] { item1, item2 }, "ref10", 132.6f, "RUB", 0, NSData.FromString(GetSampleiTunesIAPReceipt())); }; btnSetterMethods.TouchUpInside += delegate { Console.WriteLine("MAT setter methods"); MobileAppTracker.SetTRUSTeId("tempTrusteTPID"); MobileAppTracker.SetUserId("tempUserId"); MobileAppTracker.SetUserEmail("*****@*****.**"); MobileAppTracker.SetUserName("tempUserName"); MobileAppTracker.SetCurrencyCode("GBP"); MobileAppTracker.SetGender(1); MobileAppTracker.SetLocation(1.1, 2.2); MobileAppTracker.SetLocationWithAltitude(3.3, 4.4, 5.5); MobileAppTracker.SetUseCookieTracking(false); MobileAppTracker.SetUseCookieTracking(false); MobileAppTracker.SetAppAdTracking(true); MobileAppTracker.SetAge(23); MobileAppTracker.SetJailbroken(false); MobileAppTracker.SetAppleAdvertisingIdentifier(ASIdentifierManager.SharedManager.AdvertisingIdentifier, ASIdentifierManager.SharedManager.IsAdvertisingTrackingEnabled); MobileAppTracker.SetAppleVendorIdentifier(new NSUuid("12345678-1234-1234-1234-123456789012")); MobileAppTracker.SetFacebookUserId("tempFacebookId"); MobileAppTracker.SetGoogleUserId("tempGoogleId"); MobileAppTracker.SetTwitterUserId("tempTwitterId"); MobileAppTracker.SetEventAttribute1("attr1"); MobileAppTracker.SetEventAttribute2("attr2"); MobileAppTracker.SetEventAttribute3("attr3"); MobileAppTracker.SetEventAttribute4("attr4"); MobileAppTracker.SetEventAttribute5("attr5"); MobileAppTracker.SetEventContentType("testContentType"); MobileAppTracker.SetEventContentId("testContentId"); MobileAppTracker.SetEventDate1(NSDate.Now); MobileAppTracker.SetEventDate2(NSDate.Now.AddSeconds(60)); MobileAppTracker.SetEventLevel(3); MobileAppTracker.SetEventQuantity(2); MobileAppTracker.SetEventRating(4.5f); MobileAppTracker.SetEventSearchString("testSearchString"); MobileAppTracker.SetExistingUser(false); MobileAppTracker.SetFacebookEventLogging(true, false); MobileAppTracker.SetPayingUser(false); }; btnGetterMethods.TouchUpInside += delegate { Console.WriteLine("MatId = " + MobileAppTracker.MatId); Console.WriteLine("OpenLogId = " + MobileAppTracker.OpenLogId); Console.WriteLine("IsPayingUser = " + MobileAppTracker.IsPayingUser); }; }
private static extern void trackActionWithEventItem(string action, bool isId, MATEventItem[] items, int eventItemCount, string refId, double revenue, string currency, int transactionState);