Skip to content

Commit e1e6c82

Browse files
authored
Version 1.1.5
## Version 1.1.5 - 09.01.2019 - Added support to DontDestroyOnLoad property. Right now users might use this property to store `BacktraceClient`/`BacktraceDatabase` instances between all game scenes. - Added more attributes to `BacktraceReport` object, - Added scene game objects information to `BacktraceReport` annotations.
1 parent 414089b commit e1e6c82

13 files changed

+142
-39
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Backtrace Unity Release Notes
22

3+
## Version 1.1.5 - 09.01.2019
4+
- Added support to DontDestroyOnLoad property. Right now users might use this property to store `BacktraceClient`/`BacktraceDatabase` instances between all game scenes.
5+
- Added more attributes to `BacktraceReport` object,
6+
- Added scene game objects information to `BacktraceReport` annotations.
7+
38
## Version 1.1.4 - 27.08.2019
49
- Added support for servies under proxy (removed backtrace.sp conditions)
510

Editor/Menu/BacktraceClientConfigurationEditor.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ public class BacktraceClientConfigurationEditor : UnityEditor.Editor
1313
public const string LABEL_REPORT_PER_MIN = "Reports per minute";
1414
public const string LABEL_HANDLE_UNHANDLED_EXCEPTION = "Handle unhandled exceptions";
1515
public const string LABEL_IGNORE_SSL_VALIDATION = "Ignore SSL validation";
16+
public const string LABEL_DONT_DESTROY_BACKTRACE_ON_SCENE_LOAD = "Don't destroy Backtrace client on scene load";
17+
1618

1719

1820
private const string CONFIG_NAME = "backtrace_client_config";
@@ -30,6 +32,7 @@ public override void OnInspectorGUI()
3032
settings.ReportPerMin = EditorGUILayout.IntField(LABEL_REPORT_PER_MIN, settings.ReportPerMin);
3133
settings.HandleUnhandledExceptions = EditorGUILayout.Toggle(LABEL_HANDLE_UNHANDLED_EXCEPTION, settings.HandleUnhandledExceptions);
3234
settings.IgnoreSslValidation = EditorGUILayout.Toggle(LABEL_IGNORE_SSL_VALIDATION, settings.IgnoreSslValidation);
35+
settings.DestroyOnLoad = EditorGUILayout.Toggle(LABEL_DONT_DESTROY_BACKTRACE_ON_SCENE_LOAD, settings.DestroyOnLoad);
3336
}
3437
}
3538

Editor/Menu/BacktraceConfigurationEditor.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public class BacktraceConfigurationEditor : UnityEditor.Editor
1313
public const string LABEL_HANDLE_UNHANDLED_EXCEPTION = "Handle unhandled exceptions";
1414
public const string LABEL_ENABLE_DATABASE = "Enable Database";
1515
public const string LABEL_IGNORE_SSL_VALIDATION = "Ignore SSL validation";
16+
public const string LABEL_DESTROY_CLIENT_ON_SCENE_LOAD = "Destroy client on new scene load";
1617

1718
public const string LABEL_PATH = "Backtrace database path";
1819
public const string LABEL_AUTO_SEND_MODE = "Auto send mode";
@@ -43,6 +44,9 @@ public override void OnInspectorGUI()
4344
SerializedProperty sslValidation = serializedObject.FindProperty("IgnoreSslValidation");
4445
EditorGUILayout.PropertyField(sslValidation, new GUIContent(LABEL_IGNORE_SSL_VALIDATION));
4546

47+
SerializedProperty destroyOnLoad = serializedObject.FindProperty("DestroyOnLoad");
48+
EditorGUILayout.PropertyField(destroyOnLoad, new GUIContent(LABEL_DESTROY_CLIENT_ON_SCENE_LOAD));
49+
4650
SerializedProperty enabled = serializedObject.FindProperty("Enabled");
4751
EditorGUILayout.PropertyField(enabled, new GUIContent(LABEL_ENABLE_DATABASE));
4852

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "Backtrace-unity",
33
"displayName": "Backtrace-Unity",
4-
"version": "1.1.4",
4+
"version": "1.1.5",
55
"unity": "2017.1",
66
"description": "Backtrace's integration with Unity games allows customers to capture and report handled and unhandled Unity exceptions to their Backtrace instance, instantly offering the ability to prioritize and debug software errors.",
77
"keywords": [

src/BacktraceClient.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,24 @@ public class BacktraceClient : MonoBehaviour, IBacktraceClient
1717
public BacktraceConfiguration Configuration;
1818
public bool Enabled { get; private set; }
1919

20+
/// <summary>
21+
/// Backtrace client instance.
22+
/// </summary>
23+
private static BacktraceClient _instance;
24+
25+
/// <summary>
26+
/// Backtrace client instance accessor. Please use this property to access
27+
/// BacktraceClient instance from other scene. This property will return value only
28+
/// when you mark option "DestroyOnLoad" to false.
29+
/// </summary>
30+
public static BacktraceClient Instance
31+
{
32+
get
33+
{
34+
return _instance;
35+
}
36+
}
37+
2038
/// <summary>
2139
/// Backtrace database instance that allows to manage minidump files
2240
/// </summary>
@@ -132,6 +150,7 @@ public void Refresh()
132150
Debug.LogWarning("Configuration doesn't exists or provided serverurl/token are invalid");
133151
return;
134152
}
153+
135154
Enabled = true;
136155
if (Configuration.HandleUnhandledExceptions)
137156
{
@@ -143,6 +162,12 @@ public void Refresh()
143162
ignoreSslValidation: Configuration.IgnoreSslValidation);
144163

145164
Database?.SetApi(BacktraceApi);
165+
166+
if (Configuration.DestroyOnLoad == false)
167+
{
168+
DontDestroyOnLoad(gameObject);
169+
_instance = this;
170+
}
146171
}
147172

148173
private void Awake()
@@ -223,7 +248,7 @@ public void Send(BacktraceReport report, Action<BacktraceResult> sendCallback =
223248
}
224249

225250
public void HandleUnhandledExceptions()
226-
{
251+
{
227252
Application.logMessageReceived += HandleException;
228253
}
229254

src/BacktraceDatabase.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,33 @@ public class BacktraceDatabase : MonoBehaviour, IBacktraceDatabase
2121

2222
public BacktraceConfiguration Configuration;
2323

24+
25+
/// <summary>
26+
/// Backtrace database instance.
27+
/// </summary>
28+
private static BacktraceDatabase _instance;
29+
30+
/// <summary>
31+
/// Backtrace database instance accessor. Please use this property to access
32+
/// BacktraceDatabase instance from other scene. This property will return value only
33+
/// when you mark option "DestroyOnLoad" to false.
34+
/// </summary>
35+
public static BacktraceDatabase Instance
36+
{
37+
get
38+
{
39+
return _instance;
40+
}
41+
}
42+
2443
/// <summary>
2544
/// Database settings
2645
/// </summary>
2746
private BacktraceDatabaseSettings DatabaseSettings { get; set; }
2847

2948
private float _lastConnection;
49+
50+
3051
/// <summary>
3152
/// Backtrace Api instance. Use BacktraceApi to send data to Backtrace server
3253
/// </summary>
@@ -70,6 +91,7 @@ public void Reload()
7091
Enable = false;
7192
return;
7293
}
94+
7395

7496
DatabaseSettings = new BacktraceDatabaseSettings(Configuration);
7597
if (DatabaseSettings == null)
@@ -82,10 +104,16 @@ public void Reload()
82104
{
83105
Directory.CreateDirectory(Configuration.DatabasePath);
84106
}
107+
if (Configuration.DestroyOnLoad == false)
108+
{
109+
DontDestroyOnLoad(gameObject);
110+
_instance = this;
111+
}
85112
Enable = Configuration.Enabled && BacktraceConfiguration.ValidateDatabasePath(Configuration.DatabasePath);
86113

87114
if (!Enable)
88115
{
116+
89117
return;
90118
}
91119

src/Model/BacktraceClientConfiguration.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ public class BacktraceClientConfiguration : ScriptableObject
1010
public int ReportPerMin;
1111
public bool HandleUnhandledExceptions = true;
1212
public bool IgnoreSslValidation = false;
13-
13+
public bool DestroyOnLoad = true;
14+
1415
public void UpdateServerUrl()
1516
{
1617
if (string.IsNullOrEmpty(ServerUrl))
@@ -41,8 +42,7 @@ public bool ValidateServerUrl()
4142
return false;
4243
}
4344

44-
Uri serverUri;
45-
var result = Uri.TryCreate(ServerUrl, UriKind.RelativeOrAbsolute, out serverUri);
45+
var result = Uri.TryCreate(ServerUrl, UriKind.RelativeOrAbsolute, out Uri serverUri);
4646
try
4747
{
4848
new UriBuilder(ServerUrl) { Scheme = Uri.UriSchemeHttps, Port = 6098 }.Uri.ToString();

src/Model/BacktraceConfiguration.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ public class BacktraceConfiguration : ScriptableObject
7272
/// </summary>
7373
public int RetryLimit = 3;
7474

75+
/// <summary>
76+
/// Destroy Backtrace instances on new scene load.
77+
/// </summary>
78+
public bool DestroyOnLoad = true;
79+
7580
/// <summary>
7681
/// Retry order
7782
/// </summary>

src/Model/BacktraceData.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public string ToJson()
117117
["lang"] = "csharp",
118118
["langVersion"] = "Unity",
119119
["agent"] = "backtrace-unity",
120-
["agentVersion"] = "1.1.4",
120+
["agentVersion"] = "1.1.5",
121121
["mainThread"] = MainThread,
122122
["classifiers"] = new JArray(Classifier),
123123
["attributes"] = Attributes.ToJson(),
@@ -163,7 +163,7 @@ private void SetReportInformation()
163163
Uuid = Report.Uuid;
164164
Timestamp = Report.Timestamp;
165165
LangVersion = "Mono/IL2CPP";
166-
AgentVersion = "1.1.4";
166+
AgentVersion = "1.1.5";
167167
Classifier = Report.ExceptionTypeReport ? new[] { Report.Classifier } : null;
168168
}
169169
}

src/Model/BacktraceStackFrame.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ public BacktraceJObject ToJson()
6565
["il"] = Il,
6666
["metadata_token"] = MemberInfo,
6767
["column"] = Column,
68-
["address"] = ILOffset
68+
["address"] = ILOffset,
69+
["library"] = Library
6970
};
70-
7171
//todo: source code information
7272

7373
return stackFrame;
@@ -103,6 +103,7 @@ internal static BacktraceStackFrame Deserialize(BacktraceJObject frame)
103103
Il = frame.Value<int?>("il"),
104104
MemberInfo = frame.Value<int?>("metadata_token"),
105105
Column = frame.Value<int>("column"),
106+
Library = frame.Value<string>("library"),
106107
ILOffset = frame.Value<int?>("address"),
107108
};
108109
}
@@ -116,11 +117,13 @@ public BacktraceStackFrame(StackFrame frame, bool generatedByException)
116117
{
117118
return;
118119
}
120+
SourceCodeFullPath = frame.GetFileName();
119121
FunctionName = GetMethodName(frame);
120122
Line = frame.GetFileLineNumber();
121123
Il = frame.GetILOffset();
122124
ILOffset = Il;
123-
SourceCodeFullPath = frame.GetFileName();
125+
126+
Library = SourceCodeFullPath;
124127

125128
SourceCode = generatedByException
126129
? Guid.NewGuid().ToString()
@@ -136,7 +139,7 @@ public BacktraceStackFrame(StackFrame frame, bool generatedByException)
136139
}
137140
}
138141

139-
142+
140143

141144
/// <summary>
142145
/// Generate valid name for current stack frame.

0 commit comments

Comments
 (0)