Skip to content

Commit 0820803

Browse files
authored
Version 2.1.2 (#18)
- `BacktraceReport` will generate report fingerprint for exceptions without stack trace. - Changed game object depth default property value. - Added Exception information to the Annotation object.
1 parent 935d67a commit 0820803

19 files changed

+175
-133
lines changed

CHANGELOG.md

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

3+
## Version 2.1.2
4+
5+
- `BacktraceReport` will generate report fingerprint for exceptions without stack trace.
6+
- Changed game object depth default property value.
7+
- Added Exception information to the Annotation object.
8+
39
## Version 2.1.1
410

511
- UPM modifications - fixed editor assembly definition,

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Watch this 1 minute silent video to see the Integration and Configuration in act
5959

6060
## Plugin best practices
6161

62-
Plugin allows you to define maximum depth of game objects. By default its disabled (Game object depth is equal to -1). If you would like to include all game objects, please select 0. If you would like to specify game object depth size to n, please insert n in Backtrace configuration text box.
62+
Plugin allows you to define maximum depth of game objects. By default its disabled (Game object depth is equal to -1). If you will use 0 as maximum depth of game object we will use default game object limit - 16. If you would like to specify game object depth size to n, please insert n in Backtrace configuration text box. If you require game obejct depth to be above 30, please contact support.
6363

6464
## Backtrace Client and Offline Database Settings
6565

Runtime/BacktraceClient.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,10 @@ public void Refresh()
201201

202202
#endif
203203

204-
Annotations.GameObjectDepth = Configuration.GameObjectDepth;
204+
// set maximum game object depth
205+
Annotations.GameObjectDepth = Configuration.GameObjectDepth == 0
206+
? 16 // default maximum game object size
207+
: Configuration.GameObjectDepth;
205208
HandleUnhandledExceptions();
206209
_reportLimitWatcher = new ReportLimitWatcher(Convert.ToUInt32(Configuration.ReportPerMin));
207210

@@ -422,7 +425,7 @@ public void HandleUnhandledExceptions()
422425
/// </summary>
423426
/// <param name="message">Log message</param>
424427
/// <param name="stackTrace">Log stack trace</param>
425-
/// <param name="type">log type</param>
428+
/// <param name="type">log type</param>
426429
private void HandleException(string message, string stackTrace, LogType type)
427430
{
428431
if ((type == LogType.Exception || type == LogType.Error)

Runtime/Common/StackFrameHelper.cs

Lines changed: 0 additions & 56 deletions
This file was deleted.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using System;
2+
using System.Linq;
3+
using System.Security.Cryptography;
4+
using System.Text;
5+
6+
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("Backtrace.Unity.Tests.Runtime")]
7+
namespace Backtrace.Unity.Extensions
8+
{
9+
internal static class StringHelper
10+
{
11+
/// <summary>
12+
/// Remove all characters from string that aren't letter.
13+
/// </summary>
14+
internal static string OnlyLetters(this string source)
15+
{
16+
if (string.IsNullOrEmpty(source))
17+
{
18+
return string.Empty;
19+
}
20+
return string.Concat(source.Where(n => char.IsLetter(n)));
21+
}
22+
23+
/// <summary>
24+
/// Create sha256 from string builder value
25+
/// </summary>
26+
/// <param name="value">string value</param>
27+
/// <returns>sha256 string</returns>
28+
internal static string GetSha(this StringBuilder source)
29+
{
30+
if (source == null)
31+
{
32+
return string.Empty;
33+
}
34+
return GetSha(source.ToString());
35+
}
36+
37+
/// <summary>
38+
/// Create sha256 from string value
39+
/// </summary>
40+
/// <param name="value">string value</param>
41+
/// <returns>sha256 string</returns>
42+
internal static string GetSha(this string source)
43+
{
44+
// generate empty sha which represents fingerprint in Backtrace
45+
// for empty string
46+
if (string.IsNullOrEmpty(source))
47+
{
48+
return "0000000000000000000000000000000000000000000000000000000000000000";
49+
}
50+
using (var sha256Hash = SHA256.Create())
51+
{
52+
var bytes = sha256Hash.ComputeHash(Encoding.ASCII.GetBytes(source));
53+
return Convert.ToBase64String(bytes);
54+
}
55+
}
56+
}
57+
}

Runtime/Common/StackFrameHelper.cs.meta renamed to Runtime/Extensions/StringExtensions.cs.meta

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Extensions/ThreadExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace Backtrace.Unity.Extensions
55
/// <summary>
66
/// All extensions available for Thread class
77
/// </summary>
8-
public static class ThreadExtensions
8+
internal static class ThreadExtensions
99
{
1010
/// <summary>
1111
/// Generate a valid thread name for passed thread

Runtime/Model/BacktraceData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ private void SetReportInformation()
194194
LangVersion = "Mono";
195195
#endif
196196

197-
AgentVersion = "2.1.1";
197+
AgentVersion = "2.1.2";
198198
Classifier = Report.ExceptionTypeReport ? new[] { Report.Classifier } : null;
199199
}
200200
}

Runtime/Model/BacktraceReport.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Backtrace.Newtonsoft;
22
using Backtrace.Newtonsoft.Linq;
33
using Backtrace.Unity.Common;
4+
using Backtrace.Unity.Extensions;
45
using System;
56
using System.Collections.Generic;
67
using System.Linq;
@@ -190,6 +191,7 @@ public BacktraceReport(
190191
if (ExceptionTypeReport)
191192
{
192193
Message = exception.Message;
194+
SetReportFingerPrintForEmptyStackTrace();
193195
}
194196
Classifier = ExceptionTypeReport ? exception.GetType().Name : string.Empty;
195197
SetStacktraceInformation();
@@ -209,6 +211,20 @@ internal void SetMinidumpPath(string minidumpPath)
209211
AttachmentPaths.Add(minidumpPath);
210212
}
211213

214+
/// <summary>
215+
/// Override default fingerprint for reports without faulting stack trace.
216+
/// </summary>
217+
internal void SetReportFingerPrintForEmptyStackTrace()
218+
{
219+
if (string.IsNullOrEmpty(Exception.StackTrace))
220+
{
221+
// set attributes instead of fingerprint to still allow our user to define customer
222+
// fingerprints for reports without stack trace and apply deduplication rules in report flow.
223+
Attributes["_mod_fingerprint"] = Exception.Message.OnlyLetters().GetSha();
224+
}
225+
226+
}
227+
212228
internal BacktraceData ToBacktraceData(Dictionary<string, object> clientAttributes)
213229
{
214230
return new BacktraceData(this, clientAttributes);

Runtime/Model/BacktraceStackTrace.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ private void Initialize()
3434
if (_exception is BacktraceUnhandledException)
3535
{
3636
var current = _exception as BacktraceUnhandledException;
37-
StackFrames.InsertRange(0,current.StackFrames);
37+
StackFrames.InsertRange(0, current.StackFrames);
3838
}
3939
else
4040
{
@@ -56,7 +56,7 @@ private void Initialize()
5656

5757
private void SetStacktraceInformation(StackFrame[] frames, bool generatedByException = false)
5858
{
59-
if (frames == null)
59+
if (frames == null || frames.Length == 0)
6060
{
6161
return;
6262
}
@@ -73,7 +73,7 @@ private void SetStacktraceInformation(StackFrame[] frames, bool generatedByExcep
7373
{
7474
continue;
7575
}
76-
var backtraceFrame = new BacktraceStackFrame(frame, generatedByException);
76+
var backtraceFrame = new BacktraceStackFrame(frame, generatedByException);
7777
StackFrames.Insert(startingIndex, backtraceFrame);
7878
startingIndex++;
7979
}

0 commit comments

Comments
 (0)