diff --git a/README.md b/README.md index b5cca21..97ead5d 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,8 @@ BugSplat's Unity integration is flexible and can be used in various ways. The ea Configure fields as appropriate. Note that if Application or Version are left empty, `BugSplat` will default these values to `Application.productName` and `Application.version`, respectively. +Exceptions thrown in the editor are not uploaded by default, so play mode errors never reach the database you ship with. Check **PostExceptionsInEditor** on the options asset (or set `bugsplat.PostExceptionsInEditor = true` in code) while you verify your integration. + ![BugSplat Options](https://github.com/BugSplat-Git/bugsplat-unity/assets/2646053/be7ee217-9170-48b4-b780-fcb47e221f77) Finally, provide a valid `BugSplatOptions` to `BugSplatManager`. @@ -424,7 +426,7 @@ The following API methods are available to help you customize BugSplat to fit yo | CaptureEditorLog| Should BugSplat upload Editor.log when Post is called| | CapturePlayerLog| Should BugSplat upload Player.log when Post is called | | CaptureScreenshots | Should BugSplat a screenshot and upload it when Post is called | -| PostExceptionsInEditor | Should BugSplat upload exceptions when in editor | +| PostExceptionsInEditor | Should BugSplat upload exceptions when in editor. Defaults to false so play mode exceptions stay out of your database | | PersistentDataFileAttachmentPaths | Paths to files (relative to Application.persistentDataPath) to upload with each report | | ShouldPostException | Settable guard function that is called before each BugSplat report is posted | | UseNativeCrashReportingForWindows | Use native crash reporting library (bugsplat-windows) for Windows builds. Works with both Mono and IL2CPP | diff --git a/Runtime/Client/BugSplatOptions.cs b/Runtime/Client/BugSplatOptions.cs index b71c402..7229c12 100644 --- a/Runtime/Client/BugSplatOptions.cs +++ b/Runtime/Client/BugSplatOptions.cs @@ -55,8 +55,8 @@ public class BugSplatOptions : ScriptableObject [Tooltip("Take a screenshot and upload it when Post is called")] public bool CaptureScreenshots; - [Tooltip("Should BugSplat upload exceptions when in editor")] - public bool PostExceptionsInEditor = true; + [Tooltip("Should BugSplat upload exceptions when in editor. Off by default so play mode exceptions stay out of your database.")] + public bool PostExceptionsInEditor; [Tooltip("Paths to files (relative to Application.persistentDataPath) to upload with each report")] public List PersistentDataFileAttachmentPaths; diff --git a/Runtime/Settings/DotNetStandardClientSettingsRepository.cs b/Runtime/Settings/DotNetStandardClientSettingsRepository.cs index fb6db4d..e1deb54 100644 --- a/Runtime/Settings/DotNetStandardClientSettingsRepository.cs +++ b/Runtime/Settings/DotNetStandardClientSettingsRepository.cs @@ -27,7 +27,7 @@ public List Attachments public int LogFileMaxSizeMB { get; set; } = 10; - public bool PostExceptionsInEditor { get; set; } = true; + public bool PostExceptionsInEditor { get; set; } = false; public Func ShouldPostException { get; set; } = ShouldPostExceptionImpl.DefaultShouldPostExceptionImpl; diff --git a/Runtime/Settings/WebGLClientSettingsRepository.cs b/Runtime/Settings/WebGLClientSettingsRepository.cs index ddb79bc..660924d 100644 --- a/Runtime/Settings/WebGLClientSettingsRepository.cs +++ b/Runtime/Settings/WebGLClientSettingsRepository.cs @@ -14,7 +14,7 @@ internal class WebGLClientSettingsRepository : IClientSettingsRepository public bool CaptureEditorLog { get; set; } = false; public bool CapturePlayerLog { get; set; } = false; public bool CaptureScreenshots { get; set; } = false; - public bool PostExceptionsInEditor { get; set; } = true; + public bool PostExceptionsInEditor { get; set; } = false; public int LogFileMaxSizeMB { get; set; } = 10; public Func ShouldPostException { get; set; } = ShouldPostExceptionImpl.DefaultShouldPostExceptionImpl; public string Description { get; set; } diff --git a/Tests/Runtime/BugSplatCreateFromOptionsTests.cs b/Tests/Runtime/BugSplatCreateFromOptionsTests.cs index 93f8544..978f600 100644 --- a/Tests/Runtime/BugSplatCreateFromOptionsTests.cs +++ b/Tests/Runtime/BugSplatCreateFromOptionsTests.cs @@ -38,7 +38,7 @@ public void CreateFromOptions_ShouldCopyEveryConfiguredValue() options.CapturePlayerLog = true; options.CaptureScreenshots = true; options.LogFileMaxSizeMB = 42; - options.PostExceptionsInEditor = false; + options.PostExceptionsInEditor = true; var sut = BugSplat.CreateFromOptions(options); @@ -51,9 +51,25 @@ public void CreateFromOptions_ShouldCopyEveryConfiguredValue() Assert.True(sut.CapturePlayerLog, nameof(options.CapturePlayerLog)); Assert.True(sut.CaptureScreenshots, nameof(options.CaptureScreenshots)); Assert.AreEqual(42, sut.LogFileMaxSizeMB, nameof(options.LogFileMaxSizeMB)); + Assert.True(sut.PostExceptionsInEditor, nameof(options.PostExceptionsInEditor)); + } + + [Test] + public void CreateFromOptions_WhenPostExceptionsInEditorNotSet_ShouldNotPostExceptionsInEditor() + { + var sut = BugSplat.CreateFromOptions(options); + Assert.False(sut.PostExceptionsInEditor, nameof(options.PostExceptionsInEditor)); } + [Test] + public void NewBugSplat_ShouldNotPostExceptionsInEditor() + { + var sut = new BugSplat("database", "application", "version", false, false); + + Assert.False(sut.PostExceptionsInEditor, nameof(BugSplat.PostExceptionsInEditor)); + } + // The constructor throws on an empty application, so completing at all is what proves the // fallback ran. [Test] diff --git a/Tests/Runtime/Reporter/ReportUploadGuardServiceTests.cs b/Tests/Runtime/Reporter/ReportUploadGuardServiceTests.cs index ee57c61..8496acc 100644 --- a/Tests/Runtime/Reporter/ReportUploadGuardServiceTests.cs +++ b/Tests/Runtime/Reporter/ReportUploadGuardServiceTests.cs @@ -36,6 +36,7 @@ public void ShouldPostException_WhenPostExceptionsInEditorTrue_WhenInEditor_Shou public void ShouldPostException_WhenClientSettingsRepositoryShouldPostExceptionFalse_ShouldReturnFalse() { var clientSettings = new WebGLClientSettingsRepository(); + clientSettings.PostExceptionsInEditor = true; clientSettings.ShouldPostException = (Exception ex) => false; var rugs = new ReportUploadGuardService(clientSettings); var exception = new Exception(); @@ -47,6 +48,7 @@ public void ShouldPostException_WhenClientSettingsRepositoryShouldPostExceptionF public void ShouldPostException_WhenClientSettingsRepositoryShouldPostExceptionTrue_ShouldReturnTrue() { var clientSettings = new WebGLClientSettingsRepository(); + clientSettings.PostExceptionsInEditor = true; clientSettings.ShouldPostException = (Exception ex) => true; var rugs = new ReportUploadGuardService(clientSettings); var exception = new Exception(); @@ -78,6 +80,7 @@ public void ShouldPostException_WhenPostExceptionsInEditorFalse_WhenInEditor_Sho public void ShouldPostLogMessage_WhenLogTypeNotException_ShouldReturnFalse() { var clientSettings = new WebGLClientSettingsRepository(); + clientSettings.PostExceptionsInEditor = true; clientSettings.ShouldPostException = (Exception ex) => true; var rugs = new ReportUploadGuardService(clientSettings); var exception = new Exception(); @@ -90,6 +93,7 @@ public void ShouldPostLogMessage_WhenLogTypeNotException_ShouldReturnFalse() public void ShouldPostLogMessage_WhenLogTypeException_ShouldReturnTrue() { var clientSettings = new WebGLClientSettingsRepository(); + clientSettings.PostExceptionsInEditor = true; clientSettings.ShouldPostException = (Exception ex) => true; var rugs = new ReportUploadGuardService(clientSettings); var exception = new Exception(); @@ -102,6 +106,7 @@ public void ShouldPostLogMessage_WhenLogTypeException_ShouldReturnTrue() public void ShouldPostLogMessage_WhenLogTypeNotException_ShouldNotCallClientSettingsRepositoryShouldPostException() { var clientSettings = new WebGLClientSettingsRepository(); + clientSettings.PostExceptionsInEditor = true; var rugs = new ReportUploadGuardService(clientSettings); var exception = new Exception(); var logType = LogType.Error;