Exemple #1
0
 private static void OnClientClosing()
 {
     ClientClosing?.Invoke();
     Options.Save(Options.CurrentOptions);
     AssistantOptions.Save();
     SentrySdk.Close();
 }
 public void TearDown()
 {
     if (SentrySdk.IsEnabled)
     {
         SentrySdk.Close();
     }
 }
        /// <summary>
        /// Initializes the Sentry environment.
        /// Sentry is an open-source application monitoring platform that help to identify issues.
        /// </summary>
        /// <returns></returns>
        private static IDisposable InitSentry()
        {
            if (!GlobalSettings.Instance.IsSentryEnabled || IsDebugBuild)
            {
                Log.Info("Sentry is disabled");
                return(null);
            }

            Log.Info("Initializing Sentry");

            IDisposable sentrySdkInstance = null;

            try
            {
                string environment = "Release";

                #if DEBUG
                environment = "Debug";
                #elif BETA
                environment = "Beta";
                #endif

                sentrySdkInstance = SentrySdk.Init(o =>
                {
                    o.Dsn            = new Dsn("https://[email protected]/1478084");
                    o.Release        = "AML@" + GetCurrentVersionString(); // prefix because releases are global per organization
                    o.Debug          = false;
                    o.Environment    = environment;
                    o.MaxBreadcrumbs = 50;
                    o.BeforeSend     = sentryEvent =>
                    {
                        sentryEvent.User.Email = null;
                        return(sentryEvent);
                    };
                });

                SentrySdk.ConfigureScope(scope =>
                {
                    scope.User = new User
                    {
                        Id        = GlobalSettings.Instance.Guid,
                        Username  = GlobalSettings.Instance.UserName,
                        IpAddress = null
                    };
                });

                Log.Info($"Sentry initialized ({GlobalSettings.Instance.Guid})");
            }
            catch (Exception ex)
            {
                // If Sentry wasn't initialized correctly we at least try to send one message to report this.
                // (this won't throw another Ex, even if Init() failed)
                Log.Error("Sentry setup failed", ex);
                SentrySdk.Close();
                Debug.WriteLine(ex.Message);
            }

            return(sentrySdkInstance);
        }
Exemple #4
0
        /// <summary>
        /// Initializes the Sentry environment.
        /// Sentry is an open-source application monitoring platform that help to identify issues.
        /// </summary>
        /// <returns></returns>
        private static IDisposable InitSentry()
        {
            if (!Properties.Settings.Default.IsSentryEnabled || IsDebugBuild)
            {
                Log.Info("Sentry is disabled");
                return(null);
            }

            Log.Info("Initializing Sentry");

            IDisposable sentrySdkInstance = null;

            try
            {
                sentrySdkInstance = SentrySdk.Init(o =>
                {
                    o.Dsn         = new Dsn(Properties.Settings.Default.SentryDsn);
                    o.Release     = "AML@" + GetCurrentVersionString(); // prefix because releases are global per organization
                    o.Debug       = false;
                    o.Environment = IsDebugBuild ? "Debug" : "Release"; // Maybe use "Beta" for Pre-Release version (new/separate build configuration)
                    o.BeforeSend  = sentryEvent =>
                    {
                        sentryEvent.User.Email = null;
                        return(sentryEvent);
                    };
                });

                SentrySdk.ConfigureScope(scope =>
                {
                    scope.User = new User
                    {
                        Id        = Properties.Settings.Default.Guid,
                        Username  = Properties.Settings.Default.Username,
                        IpAddress = null
                    };
                });

                SentrySdk.CaptureMessage("Sentry initialized");
            }
            catch (Exception ex)
            {
                Log.Error("Sentry setup failed", ex);

                // If Sentry wasn't initialized correctly we at least try to send one message to report this.
                // (this won't throw another Ex, even if Init() failed)
                SentrySdk.CaptureException(ex);
                SentrySdk.Close();
                Debug.WriteLine(ex.Message);
            }

            return(sentrySdkInstance);
        }
Exemple #5
0
    public void UseSentry_ValidDsnString_EnablesSdk()
    {
        _ = _webHostBuilder.UseSentry(DsnSamples.ValidDsnWithoutSecret)
            .Build();

        try
        {
            Assert.True(SentrySdk.IsEnabled);
        }
        finally
        {
            SentrySdk.Close();
        }
    }
Exemple #6
0
        private static void Game_UnhandledException(object sender, Stride.Games.GameUnhandledExceptionEventArgs ex)
        {
            // Is this needed? This code already exists inside Sentry's SDK on AppDomain.UnhandledException
            if (ex.ExceptionObject is Exception e)
            {
                e.Data["Sentry:Handled"]   = false;
                e.Data["Sentry:Mechanism"] = "Game.UnhandledException";
                SentrySdk.CaptureException(e);
            }

            if (ex.IsTerminating)
            {
                SentrySdk.Close(); // Flush events and close.
            }
        }
Exemple #7
0
        /// <summary>
        /// Initializes the singleton application object.  This is the first line of authored code
        /// executed, and as such is the logical equivalent of main() or WinMain().
        /// </summary>
        public App()
        {
            SentrySdk.Init("https://[email protected]/1188141");


            UnhandledException += (sender, e) =>
            {
                SentrySdk.AddBreadcrumb(e.Message, level: Sentry.Protocol.BreadcrumbLevel.Critical);
                SentrySdk.CaptureException(e.Exception);

                // If the application code is expected to handle this (set e.Handled = true) then do not close the SDK here!
                SentrySdk.Close();
            };

            this.InitializeComponent();
            this.Suspending += OnSuspending;
        }
Exemple #8
0
 public void IterationCleanup() => SentrySdk.Close();
 public void Dispose() => SentrySdk.Close();
 public void Disable()
 {
     SentrySdk.Close();
 }
Exemple #11
0
 private static void FlushSentry()
 {
     SentrySdk.Close();
 }