public async Task AddInternalBreadcrumb_DuplicatedIs2SecondsAhead_BreadcrumbAdded() { //Assert const string message = "message"; const string type = "type"; var data = new Dictionary <string, string> { { "key", "value" } }; var logger = Substitute.For <IDiagnosticLogger>(); var hub = Sut; var options = new SentryXamarinOptions(); options.Debug = true; options.DiagnosticLogger = logger; var breadcrumb = new Breadcrumb(message, type, data); await Task.Delay(3000); options.LastInternalBreadcrumb = breadcrumb; //Act hub.AddInternalBreadcrumb(options, message, null, type, data); //Assert logger.DidNotReceive().Log(Arg.Any <SentryLevel>(), Arg.Is <string>(IHubExtensions.DuplicatedBreadcrumbDropped), Arg.Any <Exception>(), Arg.Any <object[]>()); Assert.NotEqual(breadcrumb, options.LastInternalBreadcrumb); }
// 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")); }
public void RegisterNativeIntegrations_NativeIntegrationDisabled_NativeIntegrationNotSet() { //Arrange var xamarinOptions = new SentryXamarinOptions() { NativeIntegrationEnabled = false }; //Act var registered = xamarinOptions.RegisterNativeIntegrations(); //Assert Assert.False(registered); }
public void ConfigureSentryOptions_ReleaseNotSetIfInformed() { //Arrange var options = new SentryXamarinOptions() { Release = "[email protected]" }; //Act options.ConfigureSentryXamarinOptions(); //Assert Assert.Equal(options.Release, options.Release); }
public void AddInternalBreadcrumb_LastBreadcrumbNull_LastBreadcrumbSet() { //Assert const string expectedMessage = "message"; var hub = Sut; var options = new SentryXamarinOptions(); //Act hub.AddInternalBreadcrumb(options, expectedMessage); //Assert Assert.NotNull(options.LastInternalBreadcrumb); Assert.Equal(expectedMessage, options.LastInternalBreadcrumb.Message); }
public void RegisterNativeIntegrations_NativeIntegrationEnabled_NativeIntegrationRegistered() { //Arrange var xamarinOptions = new SentryXamarinOptions() { NativeIntegrationEnabled = true }; //Act var registered = xamarinOptions.RegisterNativeIntegrations(); //Assert Assert.True(registered); }
public void ConfigureSentryOptions_DefaultCachePathDisabled_CachePathNotSet() { //Arrange var options = new SentryXamarinOptions() { CacheDirectoryPath = null, InternalCacheEnabled = false }; //Act options.ConfigureSentryXamarinOptions(); //Assert Assert.Null(options.CacheDirectoryPath); }
public void ConfigureSentryOptions_DefaultCachePathEnabledAndCacheDirectorySet_CachePathSkipped() { //Arrange var expectedPath = "./"; var options = new SentryXamarinOptions() { CacheDirectoryPath = expectedPath, }; //Act options.ConfigureSentryXamarinOptions(); //Assert Assert.Equal(expectedPath, options.CacheDirectoryPath); }
public void ConfigureSentryOptions_DefaultCachePathEnabledAndCacheDirectoryPathNull_CachePathSet() { //Arrange var options = new SentryXamarinOptions() { CacheDirectoryPath = null }; var expectedPath = options.DefaultCacheDirectoryPath(); //Act options.ConfigureSentryXamarinOptions(); //Assert Assert.Equal(expectedPath, options.CacheDirectoryPath); Assert.NotNull(expectedPath); }
public void AddInternalBreadcrumb_NewBreadcrumbWithNullData_BreadcrumbAdded() { //Assert const string message = "message"; const string type = "type"; var logger = Substitute.For <IDiagnosticLogger>(); var breadcrumb = new Breadcrumb(message, type); var options = new SentryXamarinOptions { Debug = true, DiagnosticLogger = logger, LastInternalBreadcrumb = breadcrumb }; //Act Sut.AddInternalBreadcrumb(options, message, null, type); //Assert logger.DidNotReceive().Log(Arg.Any <SentryLevel>(), Arg.Is(IHubExtensions.DuplicatedBreadcrumbDropped), Arg.Any <Exception>(), Arg.Any <object[]>()); Assert.NotEqual(breadcrumb, options.LastInternalBreadcrumb); }
public void AddInternalBreadcrumb_NewBreadcumbEqualsPrevious_BreadcrumbDiscarded() { //Assert const string duplicatedMessage = "message"; const string duplicatedType = "type"; var duplicatedData = new Dictionary <string, string> { { "key", "value" } }; var logger = Substitute.For <IDiagnosticLogger>(); var hub = Sut; var options = new SentryXamarinOptions(); options.Debug = true; options.DiagnosticLogger = logger; options.LastInternalBreadcrumb = new Breadcrumb(duplicatedMessage, duplicatedType, duplicatedData); //Act hub.AddInternalBreadcrumb(options, duplicatedMessage, null, duplicatedType, duplicatedData); //Assert logger.Received().Log(Arg.Any <SentryLevel>(), Arg.Is <string>(IHubExtensions.DuplicatedBreadcrumbDropped), Arg.Any <Exception>(), Arg.Any <object[]>()); }
/// <summary> /// Adds an automatic breadcrumb to the current scope if the previous one wasn't the same. /// </summary> /// <param name="hub">The Hub which holds the scope stack</param> /// <param name="options">The SentryXamarinOptions that holds the last breadcrumb info.</param> /// <param name="message">The message.</param> /// <param name="category">Category.</param> /// <param name="type">Breadcrumb type.</param> /// <param name="data">Additional data.</param> /// <param name="level">Breadcrumb level.</param> internal static void AddInternalBreadcrumb( this IHub hub, SentryXamarinOptions options, string message, string?category = null, string?type = null, Dictionary <string, string>?data = null, BreadcrumbLevel level = BreadcrumbLevel.Info) { var previousBreadcrumb = options.LastInternalBreadcrumb; //Filter duplicated internal breadcrumbs if (previousBreadcrumb != null && previousBreadcrumb.Message == message && previousBreadcrumb.Category == category && previousBreadcrumb.Type == type && previousBreadcrumb.Data?.Except(data).Any() is false && DateTimeOffset.UtcNow.Subtract(previousBreadcrumb.Timestamp).TotalSeconds < options.InternalBreadcrumbDuplicationTimeSpan) { //Skip options.DiagnosticLogger?.Log(SentryLevel.Debug, DuplicatedBreadcrumbDropped); }
public void AddInternalBreadcrumb_NewBreadcumbWithDifferentMessage_BreadcrumbAdded() { //Assert const string type = "type"; var data = new Dictionary <string, string> { { "key", "value" } }; var logger = Substitute.For <IDiagnosticLogger>(); var hub = Sut; var options = new SentryXamarinOptions(); options.Debug = true; options.DiagnosticLogger = logger; var breadcrumb = new Breadcrumb("message", type, data); //Act options.LastInternalBreadcrumb = breadcrumb; hub.AddInternalBreadcrumb(options, "message2", null, type, data); //Assert logger.DidNotReceive().Log(Arg.Any <SentryLevel>(), Arg.Is <string>(IHubExtensions.DuplicatedBreadcrumbDropped), Arg.Any <Exception>(), Arg.Any <object[]>()); Assert.NotEqual(breadcrumb, options.LastInternalBreadcrumb); }
public SentryXamarinFormsIntegration(SentryXamarinOptions options) => _options = options;
public NativeExceptionProcessor(SentryXamarinOptions options) { _nativeStack = new NativeStackTraceFactory(options); }
/// <summary> /// Class that returns the current application to any listener once available. /// </summary> /// <param name="options"> The sentry Xamarin options.</param> public FormsApplicationListener(SentryXamarinOptions options) => _options = options;
public NativeStackTraceFactory(SentryXamarinOptions options) => _options = options;
internal NativeIntegration(SentryXamarinOptions options) { _xamarinOptions = options; _xamarinOptions.ProjectName = Assembly.GetEntryAssembly().GetName().Name; }
internal static void UnregisterNativeIntegration(this SentryXamarinFormsIntegration integration, SentryXamarinOptions options) { #if NATIVE_PROCESSOR integration?.Nativeintegration?.Unregister(); #endif options.NativeIntegrationEnabled = false; }
/// <summary> /// The NativeEventProcessor contructor. /// </summary> /// <param name="options">The Sentry options.</param> public XamarinEventProcessor(SentryXamarinOptions options) => _options = options;
internal NativeIntegration(SentryXamarinOptions options) => _xamarinOptions = options;