Skip to content

Commit a44618e

Browse files
committed
Merge
1 parent 67e91ab commit a44618e

40 files changed

+758
-105
lines changed

.travis.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
language: objective-c
2+
osx_image: xcode8.3
3+
rvm:
4+
- 2.2
5+
before_install:
6+
- chmod a+x ./Scripts/install.sh
7+
- chmod a+x ./Scripts/build.sh
8+
install:
9+
- ./Scripts/install.sh
10+
script:
11+
- ./Scripts/build.sh

Scripts.meta

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

Scripts/build.sh

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#! /bin/sh
2+
3+
project="Backtrace-unity"
4+
5+
echo "Build project"
6+
ls /Applications/Unity/Unity.app/Contents/MacOS/
7+
8+
echo "Attempting to run tests"
9+
/Applications/Unity/Unity.app/Contents/MacOS/Unity
10+
-batchmode
11+
-nographics
12+
-silent-crashes
13+
-runTests
14+
-projectPath $(pwd)
15+
-testResults $(pwd)/test-result.log
16+
-testPlatform StandaloneWindows64
17+
-quit
18+
19+
echo "Logs from tests"
20+
cat $(pwd)/test-result.log
21+
22+
# echo "Attempting to build $project for Windows"
23+
/Applications/Unity/Unity.app/Contents/MacOS/Unity -batchmode -nographics -silent-crashes -logFile $(pwd)/unity.log -projectPath $(pwd) -buildWindowsPlayer "$(pwd)/Build/windows/$project.exe" -quit
24+
25+
# echo "Attempting to build $project for OS X"
26+
# /Applications/Unity/Unity.app/Contents/MacOS/Unity
27+
# -batchmode
28+
# -nographics
29+
# -silent-crashes
30+
# -logFile $(pwd)/unity.log
31+
# -projectPath $(pwd)
32+
# -buildOSXUniversalPlayer "$(pwd)/Build/osx/$project.app"
33+
# -quit
34+
35+
# echo "Attempting to build $project for Linux"
36+
# /Applications/Unity/Unity.app/Contents/MacOS/Unity
37+
# -batchmode
38+
# -nographics
39+
# -silent-crashes
40+
# -logFile $(pwd)/unity.log
41+
# -projectPath $(pwd)
42+
# -buildLinuxUniversalPlayer "$(pwd)/Build/linux/$project.exe"
43+
# -quit
44+
45+
# echo 'Logs from build'
46+
# cat $(pwd)/unity.log
47+
48+
49+
# echo 'Attempting to zip builds'
50+
# zip -r $(pwd)/Build/linux.zip $(pwd)/Build/linux/
51+
# zip -r $(pwd)/Build/mac.zip $(pwd)/Build/osx/
52+
# zip -r $(pwd)/Build/windows.zip $(pwd)/Build/windows/

Scripts/build.sh.meta

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

Scripts/install.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#! /bin/sh
2+
3+
BASE_URL=https://netstorage.unity3d.com/unity
4+
HASH=88d00a7498cd
5+
VERSION=5.5.1f1
6+
7+
download() {
8+
file=$1
9+
url="$BASE_URL/$HASH/$package"
10+
11+
echo "Downloading from $url: "
12+
curl -o `basename "$package"` "$url"
13+
}
14+
15+
install() {
16+
package=$1
17+
download "$package"
18+
19+
echo "Installing "`basename "$package"`
20+
sudo installer -dumplog -package `basename "$package"` -target /
21+
}
22+
23+
# See $BASE_URL/$HASH/unity-$VERSION-$PLATFORM.ini for complete list
24+
# of available packages, where PLATFORM is `osx` or `win`
25+
26+
install "MacEditorInstaller/Unity-$VERSION.pkg"
27+
install "MacEditorTargetInstaller/UnitySetup-Windows-Support-for-Editor-$VERSION.pkg"
28+
install "MacEditorTargetInstaller/UnitySetup-Mac-Support-for-Editor-$VERSION.pkg"
29+
install "MacEditorTargetInstaller/UnitySetup-Linux-Support-for-Editor-$VERSION.pkg"

Scripts/install.sh.meta

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

src/BacktraceClient.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ namespace Backtrace.Unity
1515
public class BacktraceClient : MonoBehaviour, IBacktraceClient
1616
{
1717
public BacktraceConfiguration Configuration;
18-
1918
public bool Enabled { get; private set; }
2019

2120
/// <summary>
@@ -139,7 +138,7 @@ public void Refresh()
139138
HandleUnhandledExceptions();
140139
}
141140
BacktraceApi = new BacktraceApi(
142-
credentials: new BacktraceCredentials(Configuration.GetValidServerUrl(), Configuration.Token),
141+
credentials: new BacktraceCredentials(Configuration.GetValidServerUrl()),
143142
reportPerMin: Convert.ToUInt32(Configuration.ReportPerMin));
144143

145144
Database?.SetApi(BacktraceApi);
@@ -156,7 +155,7 @@ private void Awake()
156155
/// <param name="reportPerMin">Number of reports sending per one minute. If value is equal to zero, there is no request sending to API. Value have to be greater than or equal to 0</param>
157156
public void SetClientReportLimit(uint reportPerMin)
158157
{
159-
BacktraceApi.SetClientRateLimit(reportPerMin);
158+
BacktraceApi?.SetClientRateLimit(reportPerMin);
160159
}
161160

162161
/// <summary>
@@ -225,7 +224,6 @@ public void Send(BacktraceReport report, Action<BacktraceResult> sendCallback =
225224
public void HandleUnhandledExceptions()
226225
{
227226
Application.logMessageReceived += HandleException;
228-
Application.logMessageReceivedThreaded += HandleException;
229227
}
230228

231229
private void HandleException(string condition, string stackTrace, LogType type)
@@ -263,7 +261,7 @@ private bool ValidClientConfiguration()
263261
var invalidConfiguration = BacktraceApi == null || !Enabled;
264262
if (invalidConfiguration)
265263
{
266-
Debug.Log($"Cannot set method if configuration contain invalid url to Backtrace server or client is disabled");
264+
Debug.LogWarning($"Cannot set method if configuration contain invalid url to Backtrace server or client is disabled");
267265
}
268266
return !invalidConfiguration;
269267
}

src/BacktraceDatabase.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public void Reload()
7575
if (DatabaseSettings == null)
7676
{
7777
Enable = false;
78+
7879
return;
7980
}
8081
if (Configuration.CreateDatabase)
@@ -122,7 +123,7 @@ private void Update()
122123
private void Start()
123124
{
124125
if (!Enable)
125-
{
126+
{
126127
return;
127128
}
128129
if (DatabaseSettings.AutoSendMode)

src/Common/FormDataHelper.cs

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace Backtrace.Unity.Common
6+
{
7+
internal class FormDataHelper
8+
{
9+
private static readonly Encoding _encoding = Encoding.UTF8;
10+
11+
/// <summary>
12+
/// Get formatted string with boundary information
13+
/// </summary>
14+
/// <param name="id">Boundary - request Id</param>
15+
/// <returns>Boundary string</returns>
16+
internal static string GetBoundary(Guid id)
17+
{
18+
return string.Format("----------{0:N}", id);
19+
}
20+
/// <summary>
21+
/// Get form data content type with boundary
22+
/// </summary>
23+
/// <param name="id">Boundary - request Id</param>
24+
/// <returns>Content type with boundary</returns>
25+
internal static string GetContentTypeWithBoundary(Guid id)
26+
{
27+
return "multipart/form-data; boundary=" + GetBoundary(id);
28+
}
29+
30+
internal static string GetFileContentType(Guid boundary, string name)
31+
{
32+
return $"--{boundary}\r\nContent-Disposition: form-data;" +
33+
$" name=\"{name}\"; filename=\"{name}\"\r\n" +
34+
$"Content-Type: application/octet-stream\r\n\r\n";
35+
}
36+
37+
/// <summary>
38+
/// Get form data bytes
39+
/// </summary>
40+
/// <param name="json">Diagnostic JSON</param>
41+
/// <param name="attachments">file attachments</param>
42+
/// <param name="boundaryId">Current request id</param>
43+
/// <returns>Form data bytes</returns>
44+
//internal static byte[] GetFormData(string json, List<string> attachments, Guid boundaryId)
45+
//{
46+
// return GetFormData(json, attachments, GetBoundary(boundaryId));
47+
//}
48+
49+
///// <summary>
50+
///// Get form data bytes
51+
///// </summary>
52+
///// <param name="json">Diagnostic JSON</param>
53+
///// <param name="attachments">file attachments</param>
54+
///// <param name="boundary">Current request id</param>
55+
///// <returns>Form data bytes</returns>
56+
//internal static byte[] GetFormData(string json, List<string> attachments, string boundary)
57+
//{
58+
// Stream formDataStream = new MemoryStream();
59+
60+
// //write jsonfile to formData
61+
// Write(formDataStream, Encoding.UTF8.GetBytes(json), "upload_file", boundary, false);
62+
63+
// foreach (var attachmentPath in attachments)
64+
// {
65+
// if (!File.Exists(attachmentPath))
66+
// {
67+
// continue;
68+
// }
69+
// Write(formDataStream, File.ReadAllBytes(attachmentPath), "attachment_" + Path.GetFileName(attachmentPath), boundary);
70+
// }
71+
72+
// // Add the end of the request. Start with a newline
73+
// string footer = "\r\n--" + boundary + "--\r\n";
74+
// formDataStream.Write(_encoding.GetBytes(footer), 0, _encoding.GetByteCount(footer));
75+
76+
// // Dump the Stream into a byte[]
77+
// formDataStream.Position = 0;
78+
// byte[] formData = new byte[formDataStream.Length];
79+
// formDataStream.Read(formData, 0, formData.Length);
80+
// formDataStream.Close();
81+
// return formData;
82+
//}
83+
84+
///// <summary>
85+
///// Write file row to formData
86+
///// </summary>
87+
///// <param name="formDataStream">Current form data stream</param>
88+
///// <param name="data">data to write</param>
89+
///// <param name="name">file name</param>
90+
///// <param name="boundary">Boundary with request id</param>
91+
///// <param name="clrf">Check if clear row required</param>
92+
//private static void Write(Stream formDataStream, byte[] data, string name, string boundary, bool clrf = true)
93+
//{
94+
// // Add a CRLF to allow multiple parameters to be added.
95+
// if (clrf)
96+
// {
97+
// formDataStream.Write(_encoding.GetBytes("\r\n"), 0, _encoding.GetByteCount("\r\n"));
98+
// }
99+
// string fileHeader = $"--{boundary}\r\nContent-Disposition: form-data;" +
100+
// $" name=\"{name}\"; filename=\"{name}\"\r\n" +
101+
// $"Content-Type: application/octet-stream\r\n\r\n";
102+
103+
// formDataStream.Write(_encoding.GetBytes(fileHeader), 0, _encoding.GetByteCount(fileHeader));
104+
105+
// // Write the file data directly to the Stream, rather than serializing it to a string.
106+
// formDataStream.Write(data, 0, data.Length);
107+
//}
108+
}
109+
}

src/Common/FormDataHelper.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)