コード例 #1
0
        protected override void OnExit(ExitEventArgs e)
        {
            // let counter save current state
            YandexMetrica.ReportExit();

            base.OnExit(e);
        }
コード例 #2
0
 public MainForm()
 {
     InitializeComponent();
     YandexMetricaFolder.SetCurrent("");
     YandexMetrica.Activate("eafbf946-7082-4f83-aef3-6e99c1911a62");
     AppDomain.CurrentDomain.UnhandledException += Application_ThreadException;
 }
コード例 #3
0
        public static void InsertStatistic(string appName, string plugin, string command, string version, string doc)
        {
            Task.Run(() =>
            {
                try
                {
                    var db = new PluginStatisticDbContext();
                    db.Configuration.LazyLoadingEnabled       = false;
                    db.Configuration.AutoDetectChangesEnabled = false;
                    db.Configuration.ValidateOnSaveEnabled    = false;
                    db.C_PluginStatistics.Add(new C_PluginStatistic
                    {
                        Application = appName,
                        Plugin      = plugin ?? string.Empty,
                        Command     = command ?? string.Empty,
                        Build       = version.Truncate(40) ?? string.Empty,
                        Doc         = doc.Truncate(500) ?? string.Empty,
                        UserName    = Environment.UserName,
                        DateStart   = DateTime.Now,
                        DocName     = Path.GetFileName(doc)
                    });

                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    Logger.Log.Error(ex, $"PluginStatisticsHelper Insert. appName={appName}, plugin={plugin}, command={command}, version={version}, doc={doc}, docName={Path.GetFileName(doc)}");
                }

                if (!appName.EndsWith(" Run") && !appName.EndsWith(" Update"))
                {
                    YandexMetrica.ReportEvent($"{plugin} {command}");
                }
            });
        }
コード例 #4
0
        private void App_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            try
            {
                var logService = Container.Resolve <ILogService>();
                logService.LogException(e.Exception);

#if !DEBUG
                YandexMetrica.ReportUnhandledException(e.Exception);
#endif
                var locService           = Container.Resolve <ILocService>();
                var notificationsService = Container.Resolve <IAppNotificationsService>();
                notificationsService.SendNotification(new AppNotification
                {
                    Title               = locService["AppNotifications_FatalError_Title"],
                    Content             = locService["AppNotifications_TouchToInfo_Content"],
                    Type                = AppNotificationType.Error,
                    DestinationView     = "ErrorView",
                    NavigationParameter = e.Message,
                    IsImportant         = true
                });
            }
            catch { }

            e.Handled = true;
        }
コード例 #5
0
        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());
        }
コード例 #6
0
        private void LogItem(LoggedItem item)
        {
            try
            {
                lock (Sync)
                {
                    if (!Initialized)
                    {
                        LoggedItems.Add(item);
                        return;
                    }
                }

                if (item is LoggedEvent)
                {
                    var loggedEvent = (LoggedEvent)item;
                    YandexMetrica.ReportEvent(loggedEvent.Title, loggedEvent.Values);
                }
                else if (item is LoggedException)
                {
                    var loggedException = (LoggedException)item;
                    YandexMetrica.ReportError(loggedException.Message, loggedException.Exception);
                }
            }
            catch (Exception)
            {
            }
        }
コード例 #7
0
        private void Application_ThreadException(object sender, UnhandledExceptionEventArgs e)
        {
            Exception ex = (Exception)e.ExceptionObject;

            YandexMetrica.ReportError(ex.Message, ex);
            MessageBox.Show(ex.StackTrace, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
        }
コード例 #8
0
 private static void Report(User.User user, string eventName)
 {
     YandexMetrica.ReportEvent(eventName, new Dictionary <string, string>
     {
         { "user", user.Info.UserId.ToString() },
         { "userIntent", Utils.CurrentIntent(user) }
     });
 }
コード例 #9
0
ファイル: Analytics.cs プロジェクト: punker76/meridian-uwp
        public static void TrackEvent(string eventName, Dictionary <string, object> parameters = null)
        {
            string jsonData = parameters != null?JsonConvert.SerializeObject(parameters) : null;

            YandexMetrica.ReportEvent(eventName, jsonData);

            Logger.Info("Analytics: " + eventName + " data: " + jsonData);
        }
コード例 #10
0
        static Events()
        {
            var metrika = Configuration.Config.GetSection("metrika");

            YandexMetricaFolder.SetCurrent(metrika.GetValue <string>("folder"));
            YandexMetrica.Config.CrashTracking = true;
            YandexMetrica.Activate(metrika.GetValue <string>("token"));
        }
コード例 #11
0
        public static void Log(Exception ex)
        {
            Debug.WriteLine(ex);

            _logger.Error(ex);

            YandexMetrica.ReportError("Exception", ex);
        }
コード例 #12
0
        public static void Activate(YandexMetricaConfig config)
        {
            YMMYandexMetrica.ActivateWithConfiguration(config.ToIOSAppMetricaConfig());

            YandexMetrica.RegisterImplementation(new YandexMetricaImplementation());
            YandexMetricaAttributeImplementation.Init();
            UpdateConfiguration(config);
        }
コード例 #13
0
        public static void AppStart()
        {
            //may cause problems with restoring
            YandexMetrica.Activate("2a556755-72e7-450d-9bab-c3eb179ec300");

#if DEBUG
            _logger.Info("App started");
#endif
        }
コード例 #14
0
        public static void Activate(Context context, YandexMetricaConfig config, Application app = null)
        {
            Com.Yandex.Metrica.YandexMetrica.Activate(context, config.ToAndroidMetricaConfig());
            EnableActivityAutoTracking(app);

            YandexMetrica.RegisterImplementation(new YandexMetricaImplementation());
            YandexMetricaAttributeImplementation.Init();
            UpdateConfiguration(config);
        }
コード例 #15
0
        public MainPage()
        {
            InitializeComponent();

            YandexMetrica.ReportEvent("MainPage Ctor");

            Loaded   += OnLoaded;
            Unloaded += OnUnloaded;
        }
コード例 #16
0
        public void LogException(Exception ex)
        {
#if !DEBUG
            try
            {
                YandexMetrica.ReportError(ex.Message, ex);
            }
            catch (Exception) { }
#endif
        }
コード例 #17
0
        public void LogEvent(string eventName, string json)
        {
#if !DEBUG
            try
            {
                YandexMetrica.ReportEvent(eventName, json);
            }
            catch (Exception) { }
#endif
        }
コード例 #18
0
        public static void Fatal(Exception ex, string message)
        {
            Debug.WriteLine("Fatal error: " + message + "\r\n" + ex);

            YandexMetrica.ReportUnhandledException(ex);
            Telemetry.TrackException(ex);
#if DEBUG
            _logger.Fatal(message, ex);
#endif
        }
コード例 #19
0
ファイル: Logger.cs プロジェクト: punker76/meridian-uwp
        public static void Fatal(Exception ex, string message)
        {
            Debug.WriteLine("Fatal error: " + message + "\r\n" + ex);

            YandexMetrica.ReportUnhandledException(ex);

            HockeyClient.Current.TrackException(ex);

            _logger.Fatal(message, ex);
        }
コード例 #20
0
 public static void Log(string msg)
 {
     try
     {
         YandexMetrica.ReportEvent(msg);
     }
     catch
     {
     }
 }
コード例 #21
0
        public static void Error(Exception ex, string message = null)
        {
            Debug.WriteLine(message + "\r\n" + ex);

            YandexMetrica.ReportError(message, ex);
            Telemetry.TrackException(ex);

#if DEBUG
            _logger.Error(message + ex, ex);
#endif
        }
コード例 #22
0
        static void Main()
        {
            YandexMetrica.Activate(ApiKey);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());

            // let counter save current state
            YandexMetrica.ReportExit();
        }
コード例 #23
0
 private static void YandexReport(string msg, Exception ex)
 {
     try
     {
         YandexMetrica.ReportError(msg, ex);
     }
     catch (Exception e)
     {
         AutoCAD_PIK_Manager.Log.Error(e, "YandexReport");
     }
 }
コード例 #24
0
 private void OnError(object sender, RoutedEventArgs e)
 {
     try
     {
         throw new ArgumentException("Throw exception and catch it'");
     }
     catch (Exception ex)
     {
         YandexMetrica.ReportError("Main button error", ex);
     }
 }
コード例 #25
0
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            //TODO: Add code to perform your task in background

            //TODO: https://tech.yandex.com/metrica-mobile-sdk/doc/mobile-sdk-dg/tasks/winphone-quickstart-docpage/-->
            YandexMetrica.Config.LocationTracking = false;
            YandexMetrica.Activate("Yours Api Key");
            YandexMetrica.ReportEvent("Hello from background!");
            YandexMetrica.Snapshot();
            NotifyComplete();
        }
コード例 #26
0
        public void Run(IBackgroundTaskInstance taskInstance)
        {
            var deferral = taskInstance.GetDeferral();

            YandexMetrica.Config.LocationTracking = false;
            //TODO: https://tech.yandex.com/metrica-mobile-sdk/doc/mobile-sdk-dg/tasks/winphone-quickstart-docpage/
            YandexMetrica.Activate("Yours Api Key");
            YandexMetrica.ReportEvent("Hello from background!");
            YandexMetrica.Snapshot();
            deferral.Complete();
        }
コード例 #27
0
        private void App_OnExit(object sender, ExitEventArgs e)
        {
            RemoveTrayIcon();

            AudioService.Save();
            AudioService.Dispose();

            if (Settings.Instance.SendStats)
            {
                YandexMetrica.ReportExit();
            }
        }
コード例 #28
0
 private static void Report(User.User user, string eventName, IEnumerable <KeyValuePair <string, string> > dict)
 {
     Logger.Debug($"Sending Yandex event: {eventName}");
     YandexMetrica.ReportEvent(eventName, dict
                               .Concat(new[]
     {
         new KeyValuePair <string, string>("user", user.Info.UserId.ToString()),
         new KeyValuePair <string, string>("intent", Utils.CurrentIntent(user))
     })
                               .ToDictionary(kv => kv.Key, kv => kv.Value)
                               );
 }
コード例 #29
0
 static Logger()
 {
     Log = new LoggAddinExt();
     try
     {
         YandexMetricaFolder.SetCurrent(Path.GetTempPath());
         YandexMetrica.Activate("4a039a94-ea44-43b7-9025-59a856dd7120");
         YandexMetrica.Config.CustomAppVersion = Commands.AcadLibVersion;
     }
     catch (Exception ex)
     {
         AutoCAD_PIK_Manager.Log.Error(ex, "YandexMetrica Activate error");
     }
 }
コード例 #30
0
        private async Task ReportDmp()
        {
            string pathToDmps = $@"{Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)}\My Games\Skyrim Special Edition\SKSE\Crashdumps\";

            if (!Directory.Exists(pathToDmps))
            {
                return;
            }
            try
            {
                DateTime dt       = ModVersion.LastDmpReported;
                string   fileName = "";
                foreach (FileSystemInfo fileSI in new DirectoryInfo(pathToDmps).GetFileSystemInfos())
                {
                    if (fileSI.Extension == ".dmp")
                    {
                        if (dt < Convert.ToDateTime(fileSI.CreationTime))
                        {
                            dt       = Convert.ToDateTime(fileSI.CreationTime);
                            fileName = fileSI.Name;
                        }
                    }
                }
                if (!string.IsNullOrEmpty(fileName))
                {
                    if (await Net.ReportDmp(pathToDmps + fileName))
                    {
                        YandexMetrica.ReportEvent("CrashReported");
                    }
                    else
                    {
                        YandexMetrica.ReportEvent("CantReport");
                    }
                    ModVersion.LastDmpReported = dt;
                    ModVersion.Save();

                    await Task.Delay(3000);

                    File.Delete(pathToDmps + fileName);
                }
            }
            catch (Exception e)
            {
                if (!(e is WebException) && (e is SocketException))
                {
                    Logger.Error("ReportDmp", e);
                }
            }
        }