Skip to content

Commit 2b866f6

Browse files
committed
Version 1.1.2
1 parent 44a6a1a commit 2b866f6

File tree

6 files changed

+49
-18
lines changed

6 files changed

+49
-18
lines changed

CHANGELOG.md

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

3+
## Version 1.1.2 - 06.06.2019
4+
- Changed a way how Unity-plugin upload attachments to Backtrace via `submit.backtrace.io`
5+
36
## Version 1.1.1 - 28.03.2019
47

58
- Detailed log information when Unity plugin cannot send data to Backtrace,

package.json

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
{
2-
"name": "Backtrace-unity",
3-
"displayName": "Backtrace-Unity",
4-
"version": "1.0.0",
5-
"unity" : "2017.1",
6-
"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.",
7-
"keywords": ["Backtrace", "Error", "Diagnostic", "Tools", "Debug" ,"Bug" ,"Bugs" ,"StackTrace"],
8-
"category": "Editor plugin + Script plugin"
9-
}
2+
"name": "Backtrace-unity",
3+
"displayName": "Backtrace-Unity",
4+
"version": "1.1.2",
5+
"unity": "2017.1",
6+
"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.",
7+
"keywords": [
8+
"Backtrace",
9+
"Error",
10+
"Diagnostic",
11+
"Tools",
12+
"Debug",
13+
"Bug",
14+
"Bugs",
15+
"StackTrace"
16+
],
17+
"category": "Editor plugin + Script plugin"
18+
}

src/Model/BacktraceCredentials.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ public string Token
3333
{
3434
get
3535
{
36-
return Encoding.UTF8.GetString(_accessToken);
36+
return _accessToken == null || _accessToken.Length == 0
37+
? string.Empty
38+
: Encoding.UTF8.GetString(_accessToken);
3739
}
3840
}
3941

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.1",
120+
["agentVersion"] = "1.1.2",
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.1";
166+
AgentVersion = "1.1.2";
167167
Classifier = Report.ExceptionTypeReport ? new[] { Report.Classifier } : null;
168168
}
169169
}

src/Model/BacktraceResult.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,22 @@ public string Object
6262
Status = BacktraceResultStatus.Ok;
6363
}
6464
}
65+
66+
private string _rxId;
6567
/// <summary>
6668
/// Backtrace APi can return _rxid instead of ObjectId.
6769
/// Use this setter to set _object field correctly for both answers
6870
/// </summary>
6971
[JsonProperty(PropertyName = "_rxid")]
7072
public string RxId
7173
{
74+
get
75+
{
76+
return _rxId;
77+
}
7278
set
7379
{
74-
_object = value;
80+
_rxId= value;
7581
Status = BacktraceResultStatus.Ok;
7682
}
7783
}

src/Services/BacktraceApi.cs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ private IEnumerator Send(string json, List<string> attachments, BacktraceReport
9999
if (attachments != null && attachments.Count > 0)
100100
{
101101
var stack = new Stack<string>(attachments);
102-
yield return SendAttachment(response.Object, stack);
102+
yield return SendAttachment(response.RxId, stack);
103103
}
104104
}
105105
else
@@ -121,31 +121,42 @@ private void PrintLog(UnityWebRequest request)
121121
$"\n Please check provided url to Backtrace service or learn more from our integration guide: https://help.backtrace.io/integration-guides/game-engines/unity-integration-guide");
122122
}
123123

124-
private IEnumerator SendAttachment(string objectId, Stack<string> attachments)
124+
private IEnumerator SendAttachment(string rxId, Stack<string> attachments)
125125
{
126126
if (attachments != null && attachments.Count > 0)
127127
{
128128
var attachment = attachments.Pop();
129129
if (System.IO.File.Exists(attachment))
130130
{
131131
string fileName = System.IO.Path.GetFileName(attachment);
132-
string serverUrl = GetAttachmentUploadUrl(objectId, fileName);
132+
string serverUrl = GetAttachmentUploadUrl(rxId, fileName);
133133
using (var request = new UnityWebRequest(serverUrl, "POST"))
134134
{
135135
byte[] bodyRaw = System.IO.File.ReadAllBytes(attachment);
136136
request.uploadHandler = (UploadHandler)new UploadHandlerRaw(bodyRaw);
137137
request.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
138138
request.SetRequestHeader("Content-Type", "application/json");
139139
yield return request.SendWebRequest();
140+
141+
if (request.responseCode == 200)
142+
{
143+
PrintLog(request);
144+
}
145+
else
146+
{
147+
PrintLog(request);
148+
}
140149
}
141150
}
142-
yield return SendAttachment(objectId, attachments);
151+
yield return SendAttachment(rxId, attachments);
143152
}
144153
}
145154

146-
private string GetAttachmentUploadUrl(string objectId, string attachmentName)
155+
private string GetAttachmentUploadUrl(string rxId, string attachmentName)
147156
{
148-
return $"{_credentials.BacktraceHostUri.AbsoluteUri}/api/post?token={_credentials.Token}&object={objectId}&attachment_name={UrlEncode(attachmentName)}";
157+
return _credentials == null || string.IsNullOrEmpty(_credentials.Token)
158+
? $"{_credentials.BacktraceHostUri.AbsoluteUri}?object={rxId}&attachment_name={UrlEncode(attachmentName)}"
159+
: $"{_credentials.BacktraceHostUri.AbsoluteUri}/api/post?token={_credentials.Token}&object={rxId}&attachment_name={UrlEncode(attachmentName)}";
149160

150161
}
151162

0 commit comments

Comments
 (0)