Skip to content

Commit db612de

Browse files
authored
task(config): add MaxReportedThreads for android (#523)
* task(config): add MaxReportedThreads for android
1 parent 398bec0 commit db612de

File tree

8 files changed

+27
-1
lines changed

8 files changed

+27
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
* Added event, session and device id persistence for Windows and WebGL builds [#512](https://github.com/bugsnag/bugsnag-unity/pull/512) [#509](https://github.com/bugsnag/bugsnag-unity/pull/509) [#514](https://github.com/bugsnag/bugsnag-unity/pull/514)
88

9+
* Add `Configuration.MaxReportedThreads` config option to set the [native Android option](https://docs.bugsnag.com/platforms/android/configuration-options/#maxreportedthreads) [523](https://github.com/bugsnag/bugsnag-unity/pull/523)
10+
911
* Update bugsnag-android to v5.20.0
1012
* The number of threads reported can now be limited using `Configuration.setMaxReportedThreads` (defaulting to 200)
1113
[bugsnag-android#1607](https://github.com/bugsnag/bugsnag-android/pull/1607)

features/android/android_custom_configs.feature

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,11 @@ Feature: Android custom config setting
1313
When I run the "Custom App Type" mobile scenario
1414
Then I wait to receive an error
1515
And the event "app.type" equals "test"
16+
17+
Scenario: Max Reported Threads
18+
When I run the "Max Reported Threads" mobile scenario
19+
And I wait for 8 seconds
20+
And I relaunch the Unity mobile app
21+
When I run the "Start SDK" mobile scenario
22+
Then I wait to receive an error
23+
And the error payload field "events.0.threads" is an array with 3 elements

features/fixtures/maze_runner/Assets/Scripts/MobileScenarioRunner.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public class MobileScenarioRunner : MonoBehaviour {
5656
{ "39", "Feature Flags After Init Clear All" },
5757
{ "40", "Feature Flags In Callback" },
5858
{ "41", "Clear Feature Flags In Callback" },
59+
{ "42", "Max Reported Threads" },
5960

6061

6162

@@ -142,6 +143,9 @@ private Configuration PreapareConfigForScenario(string scenarioName)
142143

143144
switch (scenarioName)
144145
{
146+
case "Max Reported Threads":
147+
config.MaxReportedThreads = 2;
148+
break;
145149
case "Clear Feature Flags In Callback":
146150
config.AddOnSendError((@event) => {
147151
@event.AddFeatureFlag("testName3", "testVariant3");
@@ -427,6 +431,11 @@ public void DoTestAction(string scenarioName)
427431
MobileNative.TriggerBackgroundJavaCrash();
428432
#elif UNITY_IOS
429433
NativeException();
434+
#endif
435+
break;
436+
case "Max Reported Threads":
437+
#if UNITY_ANDROID
438+
MobileNative.TriggerBackgroundJavaCrash();
430439
#endif
431440
break;
432441
case "Set User After Init Csharp Error":

features/steps/unity_steps.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def dial_number_for(name)
6464
"Feature Flags After Init Clear All" => 39,
6565
"Feature Flags In Callback" => 40,
6666
"Clear Feature Flags In Callback" => 41,
67-
67+
"Max Reported Threads" => 42,
6868

6969

7070
# Commands

src/Assets/Bugsnag/Editor/BugsnagEditor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ private void DrawAdvancedSettings(SerializedObject so, BugsnagSettingsObject set
166166
settings.MaximumBreadcrumbs = EditorGUILayout.IntField("Max Breadcrumbs", settings.MaximumBreadcrumbs);
167167
EditorGUILayout.PropertyField(so.FindProperty("MaxPersistedEvents"));
168168
EditorGUILayout.PropertyField(so.FindProperty("MaxPersistedSessions"));
169+
settings.MaxReportedThreads = EditorGUILayout.IntField(new GUIContent("Max Reported Threads ⓘ", "Android devices only"), settings.MaxReportedThreads);
169170
EditorGUILayout.PropertyField(so.FindProperty("NotifyLogLevel"));
170171
EditorGUILayout.PropertyField(so.FindProperty("PersistUser"));
171172
EditorGUILayout.PropertyField(so.FindProperty("RedactedKeys"));

src/Assets/Bugsnag/Scripts/BugsnagSettingsObject.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class BugsnagSettingsObject : ScriptableObject
2727
public int MaximumBreadcrumbs = 50;
2828
public int MaxPersistedEvents = 32;
2929
public int MaxPersistedSessions = 128;
30+
public int MaxReportedThreads = 200;
3031
public string NotifyEndpoint = "https://notify.bugsnag.com";
3132
public EditorLogLevel NotifyLogLevel = EditorLogLevel.Exception;
3233
public bool PersistUser = true;
@@ -81,6 +82,7 @@ public Configuration GetConfig()
8182
config.MaximumBreadcrumbs = MaximumBreadcrumbs;
8283
config.MaxPersistedEvents = MaxPersistedEvents;
8384
config.MaxPersistedSessions = MaxPersistedSessions;
85+
config.MaxReportedThreads = MaxReportedThreads;
8486
config.NotifyLogLevel = GetLogTypeFromLogLevel( NotifyLogLevel );
8587
config.SendThreads = SendThreads;
8688
if (!string.IsNullOrEmpty(NotifyEndpoint) && !string.IsNullOrEmpty(SessionEndpoint))

src/BugsnagUnity/Configuration.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ public int MaximumBreadcrumbs
113113
}
114114
}
115115

116+
public int MaxReportedThreads = 200;
117+
116118
public string ReleaseStage = "production";
117119

118120
public string[] EnabledReleaseStages;

src/BugsnagUnity/Native/Android/NativeInterface.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ AndroidJavaObject CreateNativeConfig(Configuration config)
279279
obj.Call("setPersistUser", config.PersistUser);
280280
obj.Call("setLaunchDurationMillis", config.LaunchDurationMillis);
281281
obj.Call("setSendLaunchCrashesSynchronously", config.SendLaunchCrashesSynchronously);
282+
obj.Call("setMaxReportedThreads", config.MaxReportedThreads);
283+
282284

283285
if (config.GetUser() != null)
284286
{

0 commit comments

Comments
 (0)