Skip to content

Commit 8ca7901

Browse files
authored
Backtrace-unity update 2.0.0 (#8)
## Version 2.0.0 - Backtrace-Unity plugin will set `"Destroy object on new scene"` by default to false. - Backtrace stack trace improvements, - `BacktraceDatabase` retry method now respect correctly `BacktraceDatabase` `retryInterval` property, - New `Backtrace Configuration` won't override existing `Backtrace Configuration` in configuration directory. - Backtrace-Unity plugin tests now won't override some files in Backtrace-Database unit tests, - Backtrace-Unity plugin now allows you to setup client side deduplication rules via `Fingerprint`. By using this field you can limit reporting of an error that occurs many times over a few frames. - Backtrace report limit watcher feature now will validate limits before BacktraceReport creation. - `BacktraceClient` and `BacktraceDatabase` now expose `Reload` method. You can use this method do dynamically change `BacktraceClient`/`BacktraceDatabase` configurations.
1 parent e1e6c82 commit 8ca7901

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1554
-373
lines changed

.gitignore

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,30 @@
1-
[Ll]ibrary/
2-
[Tt]emp/
3-
[Oo]bj/
4-
[Bb]uild/
5-
[Bb]uilds/
6-
Assets/AssetStoreTools*
1+
# This .gitignore file should be placed at the root of your Unity project directory
2+
#
3+
# Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore
4+
#
5+
/[Ll]ibrary/
6+
/[Tt]emp/
7+
/[Oo]bj/
8+
/[Bb]uild/
9+
/[Bb]uilds/
10+
/[Ll]ogs/
11+
/[Mm]emoryCaptures/
12+
13+
# Asset meta data should only be ignored when the corresponding asset is also ignored
14+
!/[Aa]ssets/**/*.meta
15+
16+
# Uncomment this line if you wish to ignore the asset store tools plugin
17+
# /[Aa]ssets/AssetStoreTools*
18+
19+
# Autogenerated Jetbrains Rider plugin
20+
/[Aa]ssets/Plugins/Editor/JetBrains*
721

822
# Visual Studio cache directory
923
.vs/
1024

25+
# Gradle cache directory
26+
.gradle/
27+
1128
# Autogenerated VS/MD/Consulo solution and project files
1229
ExportedObj/
1330
.consulo/
@@ -22,15 +39,21 @@ ExportedObj/
2239
*.booproj
2340
*.svd
2441
*.pdb
42+
*.mdb
2543
*.opendb
44+
*.VC.db
2645

2746
# Unity3D generated meta files
2847
*.pidb.meta
2948
*.pdb.meta
49+
*.mdb.meta
3050

31-
# Unity3D Generated File On Crash Reports
51+
# Unity3D generated file on crash reports
3252
sysinfo.txt
3353

3454
# Builds
3555
*.apk
3656
*.unitypackage
57+
58+
# Crashlytics generated file
59+
crashlytics-build.properties

CHANGELOG.md

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

3+
## Version 2.0.0
4+
- Backtrace-Unity plugin will set `"Destroy object on new scene"` by default to false.
5+
- Backtrace stack trace improvements,
6+
- `BacktraceDatabase` retry method now respect correctly `BacktraceDatabase` `retryInterval` property,
7+
- New `Backtrace Configuration` won't override existing `Backtrace Configuration` in configuration directory.
8+
- Backtrace-Unity plugin tests now won't override some files in Backtrace-Database unit tests,
9+
- Backtrace-Unity plugin now allows you to setup client side deduplication rules via `Fingerprint`. By using this field you can limit reporting of an error that occurs many times over a few frames.
10+
- Backtrace report limit watcher feature now will validate limits before BacktraceReport creation.
11+
- `BacktraceClient` and `BacktraceDatabase` now expose `Reload` method. You can use this method do dynamically change `BacktraceClient`/`BacktraceDatabase` configurations.
12+
313
## Version 1.1.5 - 09.01.2019
414
- Added support to DontDestroyOnLoad property. Right now users might use this property to store `BacktraceClient`/`BacktraceDatabase` instances between all game scenes.
515
- Added more attributes to `BacktraceReport` object,

Editor/Menu/BacktraceClientConfigurationEditor.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#if UNITY_EDITOR
22
using Backtrace.Unity.Model;
3+
using Backtrace.Unity.Types;
34
using System.IO;
45
using UnityEditor;
56
using UnityEngine;
@@ -13,7 +14,9 @@ public class BacktraceClientConfigurationEditor : UnityEditor.Editor
1314
public const string LABEL_REPORT_PER_MIN = "Reports per minute";
1415
public const string LABEL_HANDLE_UNHANDLED_EXCEPTION = "Handle unhandled exceptions";
1516
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+
public const string LABEL_DEDUPLICATION_RULES = "Deduplication rules";
18+
public const string LABEL_DONT_DESTROY_BACKTRACE_ON_SCENE_LOAD = "Don't destroy on scene load";
19+
1720

1821

1922

@@ -29,10 +32,12 @@ public override void OnInspectorGUI()
2932
{
3033
EditorGUILayout.HelpBox("Detected different pattern of url. Please make sure its a valid Backtrace url!", MessageType.Warning);
3134
}
35+
36+
settings.DestroyOnLoad = EditorGUILayout.Toggle(LABEL_DONT_DESTROY_BACKTRACE_ON_SCENE_LOAD, settings.DestroyOnLoad);
3237
settings.ReportPerMin = EditorGUILayout.IntField(LABEL_REPORT_PER_MIN, settings.ReportPerMin);
3338
settings.HandleUnhandledExceptions = EditorGUILayout.Toggle(LABEL_HANDLE_UNHANDLED_EXCEPTION, settings.HandleUnhandledExceptions);
3439
settings.IgnoreSslValidation = EditorGUILayout.Toggle(LABEL_IGNORE_SSL_VALIDATION, settings.IgnoreSslValidation);
35-
settings.DestroyOnLoad = EditorGUILayout.Toggle(LABEL_DONT_DESTROY_BACKTRACE_ON_SCENE_LOAD, settings.DestroyOnLoad);
40+
settings.DeduplicationStrategy = (DeduplicationStrategy)EditorGUILayout.EnumPopup(LABEL_DEDUPLICATION_RULES, settings.DeduplicationStrategy);
3641
}
3742
}
3843

Editor/Menu/BacktraceClientEditor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public override void OnInspectorGUI()
1919
false);
2020
if (component.Configuration != null)
2121
{
22-
BacktraceConfigurationEditor editor = (BacktraceConfigurationEditor)CreateEditor(component.Configuration);
22+
var editor = (BacktraceConfigurationEditor)CreateEditor(component.Configuration);
2323
editor.OnInspectorGUI();
2424
if (component.Configuration.Enabled && component.gameObject.GetComponent<BacktraceDatabase>() == null)
2525
{

Editor/Menu/BacktraceConfigurationEditor.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ 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_DEDUPLICATION_RULES = "Deduplication rules";
17+
1618
public const string LABEL_DESTROY_CLIENT_ON_SCENE_LOAD = "Destroy client on new scene load";
1719

1820
public const string LABEL_PATH = "Backtrace database path";
@@ -44,11 +46,15 @@ public override void OnInspectorGUI()
4446
SerializedProperty sslValidation = serializedObject.FindProperty("IgnoreSslValidation");
4547
EditorGUILayout.PropertyField(sslValidation, new GUIContent(LABEL_IGNORE_SSL_VALIDATION));
4648

49+
50+
SerializedProperty deduplicationStrategy = serializedObject.FindProperty("DeduplicationStrategy");
51+
EditorGUILayout.PropertyField(deduplicationStrategy, new GUIContent(LABEL_DEDUPLICATION_RULES));
52+
4753
SerializedProperty destroyOnLoad = serializedObject.FindProperty("DestroyOnLoad");
4854
EditorGUILayout.PropertyField(destroyOnLoad, new GUIContent(LABEL_DESTROY_CLIENT_ON_SCENE_LOAD));
4955

5056
SerializedProperty enabled = serializedObject.FindProperty("Enabled");
51-
EditorGUILayout.PropertyField(enabled, new GUIContent(LABEL_ENABLE_DATABASE));
57+
EditorGUILayout.PropertyField(enabled, new GUIContent(LABEL_ENABLE_DATABASE));
5258

5359
if (enabled.boolValue)
5460
{

Editor/Menu/BacktraceMenu.cs

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
#if UNITY_EDITOR
2+
using Backtrace.Unity.Model;
23
using System.IO;
4+
using System.Linq;
35
using UnityEditor;
46
using UnityEngine;
5-
using Backtrace.Unity.Model;
67

78
namespace Backtrace.Unity.Editor
89
{
910
public class BacktraceMenu : MonoBehaviour
1011
{
11-
public const string DEFAULT_CLIENT_CONFIGURATION_NAME = "Backtrace Configuration.asset";
12+
public const string DEFAULT_CONFIGURATION_NAME = "Backtrace Configuration";
13+
public const string DEFAULT_EXTENSION_NAME = ".asset";
14+
public const string DEFAULT_CLIENT_CONFIGURATION_NAME = DEFAULT_CONFIGURATION_NAME + DEFAULT_EXTENSION_NAME;
1215

1316
[MenuItem("Assets/Backtrace/Configuration", false, 1)]
1417
public static void CreateClientConfigurationFile()
@@ -19,7 +22,7 @@ public static void CreateClientConfigurationFile()
1922
private static void CreateAsset<T>(string fileName) where T : ScriptableObject
2023
{
2124
T asset = ScriptableObject.CreateInstance<T>();
22-
string currentProjectPath = AssetDatabase.GetAssetPath(Selection.activeObject);
25+
var currentProjectPath = AssetDatabase.GetAssetPath(Selection.activeObject);
2326
if (string.IsNullOrEmpty(currentProjectPath))
2427
{
2528
currentProjectPath = "Assets";
@@ -28,11 +31,32 @@ private static void CreateAsset<T>(string fileName) where T : ScriptableObject
2831
{
2932
currentProjectPath = Path.GetDirectoryName(currentProjectPath);
3033
}
31-
AssetDatabase.CreateAsset(asset, "Assets/" + fileName);
32-
AssetDatabase.SaveAssets();
33-
3434
var destinationPath = Path.Combine(currentProjectPath, fileName);
35-
AssetDatabase.MoveAsset("Assets/" + fileName, destinationPath);
35+
if (File.Exists(destinationPath))
36+
{
37+
var files = Directory.GetFiles(currentProjectPath);
38+
var lastFileIndex = files
39+
.Where(n =>
40+
Path.GetFileNameWithoutExtension(n).StartsWith(DEFAULT_CONFIGURATION_NAME) &&
41+
Path.GetExtension(n) == DEFAULT_EXTENSION_NAME)
42+
.Select(n =>
43+
{
44+
int startIndex = n.IndexOf('(') + 1;
45+
int endIndex = n.IndexOf(')');
46+
if (startIndex != 0 && endIndex != -1 && int.TryParse(n.Substring(startIndex, endIndex - startIndex), out int result))
47+
{
48+
return result;
49+
}
50+
return 0;
51+
})
52+
.DefaultIfEmpty().Max();
53+
54+
lastFileIndex++;
55+
destinationPath = Path.Combine(currentProjectPath, $"{DEFAULT_CONFIGURATION_NAME}({lastFileIndex}){DEFAULT_EXTENSION_NAME}");
56+
}
57+
Debug.Log($"Generating new Backtrace configuration file available in path: {destinationPath}");
58+
AssetDatabase.CreateAsset(asset, destinationPath);
59+
AssetDatabase.SaveAssets();
3660
Selection.activeObject = asset;
3761
}
3862
}

Editor/Tests/BacktraceBaseTest.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using UnityEngine;
2+
using System.Collections;
3+
using Backtrace.Unity;
4+
using Backtrace.Unity.Model;
5+
using NUnit.Framework;
6+
7+
public class BacktraceBaseTest : MonoBehaviour
8+
{
9+
protected GameObject GameObject;
10+
protected BacktraceClient BacktraceClient;
11+
protected void BeforeSetup()
12+
{
13+
Debug.unityLogger.logEnabled = false;
14+
GameObject = new GameObject();
15+
GameObject.SetActive(false);
16+
BacktraceClient = GameObject.AddComponent<BacktraceClient>();
17+
}
18+
19+
protected void AfterSetup(bool refresh = true)
20+
{
21+
if (refresh)
22+
{
23+
BacktraceClient.Refresh();
24+
}
25+
GameObject.SetActive(true);
26+
}
27+
28+
protected BacktraceConfiguration GetBasicConfiguration()
29+
{
30+
var configuration = ScriptableObject.CreateInstance<BacktraceConfiguration>();
31+
configuration.ServerUrl = "https://submit.backtrace.io/test/token/json";
32+
configuration.DestroyOnLoad = true;
33+
return configuration;
34+
}
35+
36+
[TearDown]
37+
public void Cleanup()
38+
{
39+
DestroyImmediate(GameObject);
40+
}
41+
}

Editor/Tests/BacktraceBaseTest.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)