Skip to content

Commit

Permalink
Allow defining not supported variables (#210)
Browse files Browse the repository at this point in the history
* Allow defining not supported variables

* Unit test
  • Loading branch information
konraddysput authored Apr 29, 2024
1 parent f57bae4 commit afa3e05
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 12 deletions.
8 changes: 8 additions & 0 deletions Runtime/Attributes.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Runtime/Attributes/NotSupportedAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System;

namespace Backtrace.Unity.Attributes
{
[Obsolete("Not supported")]
public class NotSupportedAttribute : Attribute
{
}
}
11 changes: 11 additions & 0 deletions Runtime/Attributes/NotSupportedAttribute.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 31 additions & 12 deletions Runtime/Model/BacktraceConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Backtrace.Unity.Common;
using Backtrace.Unity.Attributes;
using Backtrace.Unity.Common;
using Backtrace.Unity.Model.Breadcrumbs;
using Backtrace.Unity.Services;
using Backtrace.Unity.Types;
Expand Down Expand Up @@ -125,7 +126,6 @@ public class BacktraceConfiguration : ScriptableObject
[Tooltip("Try to find game native crashes and send them on Game startup")]
public bool SendUnhandledGameCrashesOnGameStartup = true;

#if UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_WIN || UNITY_GAMECORE_XBOXSERIES
#if UNITY_ANDROID
/// <summary>
/// Capture native NDK Crashes.
Expand All @@ -136,47 +136,66 @@ public class BacktraceConfiguration : ScriptableObject
/// Capture native crashes.
/// </summary>
[Tooltip("Capture native Crashes")]
#else
/// <summary>
/// Capture native crashes.
/// </summary>
[NotSupported]
#endif

public bool CaptureNativeCrashes = true;
#if !UNITY_GAMECORE_XBOXSERIES

/// <summary>
/// Handle ANR events - Application not responding
/// </summary>
#if UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_WIN
[Tooltip("Capture ANR events - Application not responding")]
public bool HandleANR = true;
#else
[NotSupported]
#endif
public bool HandleANR = true;


/// <summary>
/// Anr watchdog timeout in ms. Time needed to detect an ANR event
/// </summary>
#if UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_WIN
[Tooltip("ANR watchdog timeout")]
#else
[NotSupported]
#endif
public int AnrWatchdogTimeout = DefaultAnrWatchdogTimeout;

#if UNITY_ANDROID || UNITY_IOS
/// <summary>
/// Send Out of memory exceptions to Backtrace.
/// </summary>
#if UNITY_ANDROID || UNITY_IOS
[Tooltip("Send Out of Memory exceptions to Backtrace")]
#else
[NotSupported]
#endif
public bool OomReports = false;

#if UNITY_2019_2_OR_NEWER
/// <summary>
/// Enable client side unwinding.
/// </summary>
#if UNITY_2019_2_OR_NEWER && (UNITY_ANDROID || UNITY_IOS)
[Tooltip("Enable client-side unwinding.")]
public bool ClientSideUnwinding = false;
#else
[NotSupported]
#endif
public bool ClientSideUnwinding = false;

#endif

#if UNITY_2019_2_OR_NEWER && UNITY_ANDROID
/// <summary>
/// Symbols upload token
/// </summary>
#if UNITY_2019_2_OR_NEWER && UNITY_ANDROID
[Tooltip("Symbols upload token required to upload symbols to Backtrace")]
public string SymbolsUploadToken = string.Empty;
#endif
#else
[NotSupported]
#endif
public string SymbolsUploadToken = string.Empty;


/// <summary>
/// Backtrace client deduplication strategy.
Expand Down
16 changes: 16 additions & 0 deletions Tests/Runtime/BacktraceClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,22 @@ public void Setup()
AfterSetup(false);
}

[UnityTest]
public IEnumerator TestClientConfigurationOptions_ValidConfigurationWithAllOptions_AllowsToUseNotSupportedOptions()
{
var clientConfiguration = GetValidClientConfiguration();
clientConfiguration.OomReports = false;
clientConfiguration.HandleANR = false;
clientConfiguration.AnrWatchdogTimeout = 0;
clientConfiguration.CaptureNativeCrashes = false;
clientConfiguration.ClientSideUnwinding = false;
clientConfiguration.SymbolsUploadToken = string.Empty;
BacktraceClient.Configuration = clientConfiguration;
BacktraceClient.Refresh();
Assert.IsTrue(BacktraceClient.Enabled);
yield return null;
}

[UnityTest]
public IEnumerator TestClientCreation_ValidBacktraceConfiguration_ValidClientCreation()
{
Expand Down

0 comments on commit afa3e05

Please sign in to comment.