public MainPage() { Location = new YandexMetrica.Location(); InitializeComponent(); Loaded += (sender, args) => YandexMetrica.ReportEvent("Hello!"); Unloaded += (sender, args) => YandexMetrica.ReportEvent("Bye!"); LocationButton.Click += (sender, args) => YandexMetricaConfig.SetCustomLocation(Location); EventButton.Click += (sender, args) => YandexMetrica.ReportEvent(EventNameTextBox.Text); CrashButton.Click += (sender, args) => { throw new Exception(); }; ErrorButton.Click += (sender, args) => { try { throw new ArgumentException("Throw exception and catch it"); } catch (Exception exception) { YandexMetrica.ReportError(ErrorNameTextBox.Text, exception); } }; ResetButton.Click += (sender, args) => { YandexMetricaConfig.OfflineMode = false; YandexMetricaConfig.CrashTracking = true; YandexMetricaConfig.LocationTracking = true; YandexMetricaConfig.CustomAppVersion = null; YandexMetricaConfig.SetCustomLocation(null); }; JsonButton.Click += (sender, args) => YandexMetrica.ReportEvent("abc", JsonData.GetObject()); JsonButton.Click += (sender, args) => YandexMetrica.ReportEvent("abc", JsonData.GetDictionary()); }
public void SetCustomLocation(YandexMetrica.Location location) { ReportMessage.Location location1; if (location != null) { location1 = new ReportMessage.Location() { lat = location.Lat, lon = location.Lon, speed = new uint?(location.Speed), altitude = new int?(location.Altitude), direction = new uint?(location.Direction), precision = new uint?(location.Precision), timestamp = new ulong?(location.Timestamp) } } ; else { location1 = (ReportMessage.Location)null; } this.CustomLocation = location1; }