Example #1
0
        // Test
        public async Task Register_FormsNotInitialized_HooksNotInvoked()
        {
            //Assert
            var mockDiagnostic = new MockDiagnosticLogger(SentryLevel.Debug);
            var options        = new SentryXamarinOptions()
            {
                Debug                           = true,
                DiagnosticLogger                = mockDiagnostic,
                GetCurrentApplicationDelay      = 1,
                GetCurrentApplicationMaxRetries = 1
            };
            var integration = new FormsApplicationListener(options);
            var mockHub     = new MockHub();
            Action <Application> badListener = (_) => throw null;

            integration.AddListener(badListener);

            //Act
            integration.Invoke();

            await Task.Delay(options.GetCurrentApplicationDelay + 100);

            //Assert
            Assert.True(mockDiagnostic.Contains("Sentry.Xamarin.Forms timeout for tracking Application.Current. Navigation tracking is going to be disabled"));
        }
Example #2
0
        /// <summary>
        /// Add the Sentry Xamarin Forms integration to Sentry.Xamarin SDK.
        /// </summary>
        /// <param name="options">The Sentry Xamarion Options.</param>
        public static void AddXamarinFormsIntegration(this SentryXamarinOptions options)
        {
            var applicationListener = new FormsApplicationListener(options);

            var formsIntegration = new SentryXamarinFormsIntegration(options);

            options.AddIntegration(formsIntegration);
            applicationListener.AddListener(formsIntegration.RegisterRequestThemeChange);

            if (options.PageTracker is null)
            {
                var navigationIntegration = new FormsNavigationIntegration();
                options.AddPageNavigationTrackerIntegration(navigationIntegration);
                applicationListener.AddListener(navigationIntegration.ApplySentryNavigationEvents);
            }

            options.ProtocolPackageName = ProtocolPackageName;

            applicationListener.Invoke();
        }