Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down Expand Up @@ -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 |
Expand Down
4 changes: 2 additions & 2 deletions Runtime/Client/BugSplatOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> PersistentDataFileAttachmentPaths;
Expand Down
2 changes: 1 addition & 1 deletion Runtime/Settings/DotNetStandardClientSettingsRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public List<FileInfo> Attachments

public int LogFileMaxSizeMB { get; set; } = 10;

public bool PostExceptionsInEditor { get; set; } = true;
public bool PostExceptionsInEditor { get; set; } = false;

public Func<Exception, bool> ShouldPostException { get; set; } = ShouldPostExceptionImpl.DefaultShouldPostExceptionImpl;

Expand Down
2 changes: 1 addition & 1 deletion Runtime/Settings/WebGLClientSettingsRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Exception, bool> ShouldPostException { get; set; } = ShouldPostExceptionImpl.DefaultShouldPostExceptionImpl;
public string Description { get; set; }
Expand Down
18 changes: 17 additions & 1 deletion Tests/Runtime/BugSplatCreateFromOptionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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]
Expand Down
5 changes: 5 additions & 0 deletions Tests/Runtime/Reporter/ReportUploadGuardServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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;
Expand Down
Loading