Skip to content

Commit d58454f

Browse files
authored
feat: attributes (#93)
* feat: attributes * chore: update Runtime/Reporter/WebGLReporter.cs
1 parent 746db32 commit d58454f

14 files changed

+104
-64
lines changed

Runtime/BugSplat.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ public List<FileInfo> Attachments
3232
}
3333
}
3434

35+
/// <summary>
36+
/// A dictionary of key values pairs to be added every time Post is called
37+
/// </summary>
38+
public Dictionary<string, string> Attributes
39+
{
40+
get
41+
{
42+
return clientSettings.Attributes;
43+
}
44+
}
45+
3546
/// <summary>
3647
/// Upload Editor.log when Post is called
3748
/// </summary>

Runtime/Client/BugSplatOptions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ public class BugSplatOptions : ScriptableObject
4646
[Tooltip("Paths to files (relative to Application.persistentDataPath) to upload with each report")]
4747
public List<string> PersistentDataFileAttachmentPaths;
4848

49+
[Tooltip("Attributes to attach to reports")]
50+
public Dictionary<string, string> Attributes;
51+
4952
[Tooltip("OAuth2 Client ID generated on BugSplat's Integrations page")]
5053
public string SymbolUploadClientId;
5154

Runtime/Client/DotNetStandardClient.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ public Task<HttpResponseMessage> Post(FileInfo minidumpFileInfo, IReportPostOpti
4040
private ExceptionPostOptions CreateExceptionPostOptions(IReportPostOptions options)
4141
{
4242
var exceptionPostOptions = new ExceptionPostOptions();
43+
44+
foreach (var attribute in options.AdditionalAttributes)
45+
{
46+
exceptionPostOptions.Attributes.TryAdd(attribute.Key, attribute.Value);
47+
}
48+
4349
exceptionPostOptions.Attachments.AddRange(options.AdditionalAttachments);
4450
exceptionPostOptions.FormDataParams.AddRange(options.AdditionalFormDataParams);
4551
exceptionPostOptions.Description = options.Description;
@@ -54,6 +60,12 @@ private ExceptionPostOptions CreateExceptionPostOptions(IReportPostOptions optio
5460
private MinidumpPostOptions CreateMinidumpPostOptions(IReportPostOptions options)
5561
{
5662
var minidumpPostOptions = new MinidumpPostOptions();
63+
64+
foreach (var attribute in options.AdditionalAttributes)
65+
{
66+
minidumpPostOptions.Attributes.TryAdd(attribute.Key, attribute.Value);
67+
}
68+
5769
minidumpPostOptions.Attachments.AddRange(options.AdditionalAttachments);
5870
minidumpPostOptions.FormDataParams.AddRange(options.AdditionalFormDataParams);
5971
minidumpPostOptions.Description = options.Description;

Runtime/Client/WebGLExceptionClient.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ private IEnumerator PostException(string exception, IReportPostOptions options =
5252
{ "appKey", options.Key },
5353
{ "user", options.User },
5454
{ "callstack", exception },
55-
{ "crashTypeId", $"{options.CrashTypeId}" }
55+
{ "crashTypeId", $"{options.CrashTypeId}" },
56+
{ "attributes", JsonUtility.ToJson(options.AdditionalAttributes) }
5657
};
5758

5859
var request = UnityWebClient.Post(url, formData);
Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
1-
{
2-
"runtimeTarget": {
3-
"name": ".NETStandard,Version=v2.0/",
4-
"signature": ""
5-
},
6-
"compilationOptions": {},
7-
"targets": {
8-
".NETStandard,Version=v2.0": {},
9-
".NETStandard,Version=v2.0/": {
10-
"BugSplatDotNetStandard/4.0.1": {
11-
"dependencies": {
12-
"NETStandard.Library": "2.0.3"
13-
},
14-
"runtime": {
15-
"BugSplatDotNetStandard.dll": {}
16-
}
17-
},
18-
"Microsoft.NETCore.Platforms/1.1.0": {},
19-
"NETStandard.Library/2.0.3": {
20-
"dependencies": {
21-
"Microsoft.NETCore.Platforms": "1.1.0"
22-
}
23-
}
24-
}
25-
},
26-
"libraries": {
27-
"BugSplatDotNetStandard/4.0.1": {
28-
"type": "project",
29-
"serviceable": false,
30-
"sha512": ""
31-
},
32-
"Microsoft.NETCore.Platforms/1.1.0": {
33-
"type": "package",
34-
"serviceable": true,
35-
"sha512": "sha512-rASRBWOUv1uKrIcHVLJR0ztrzURgBo70Fz0ZbPnvZfMU1TJpZ0fWuiG5dtZQdpmZHSa9jxR6PgifP0TfH4/cqw==",
36-
"path": "microsoft.netcore.platforms/1.1.0",
37-
"hashPath": "microsoft.netcore.platforms.1.1.0.nupkg.sha512"
38-
},
39-
"NETStandard.Library/2.0.3": {
40-
"type": "package",
41-
"serviceable": true,
42-
"sha512": "sha512-st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==",
43-
"path": "netstandard.library/2.0.3",
44-
"hashPath": "netstandard.library.2.0.3.nupkg.sha512"
45-
}
46-
}
1+
{
2+
"runtimeTarget": {
3+
"name": ".NETStandard,Version=v2.0/",
4+
"signature": ""
5+
},
6+
"compilationOptions": {},
7+
"targets": {
8+
".NETStandard,Version=v2.0": {},
9+
".NETStandard,Version=v2.0/": {
10+
"BugSplatDotNetStandard/4.2.1.0": {
11+
"dependencies": {
12+
"NETStandard.Library": "2.0.3"
13+
},
14+
"runtime": {
15+
"BugSplatDotNetStandard.dll": {}
16+
}
17+
},
18+
"Microsoft.NETCore.Platforms/1.1.0": {},
19+
"NETStandard.Library/2.0.3": {
20+
"dependencies": {
21+
"Microsoft.NETCore.Platforms": "1.1.0"
22+
}
23+
}
24+
}
25+
},
26+
"libraries": {
27+
"BugSplatDotNetStandard/4.2.1.0": {
28+
"type": "project",
29+
"serviceable": false,
30+
"sha512": ""
31+
},
32+
"Microsoft.NETCore.Platforms/1.1.0": {
33+
"type": "package",
34+
"serviceable": true,
35+
"sha512": "sha512-kz0PEW2lhqygehI/d6XsPCQzD7ff7gUJaVGPVETX611eadGsA3A877GdSlU0LRVMCTH/+P3o2iDTak+S08V2+A==",
36+
"path": "microsoft.netcore.platforms/1.1.0",
37+
"hashPath": "microsoft.netcore.platforms.1.1.0.nupkg.sha512"
38+
},
39+
"NETStandard.Library/2.0.3": {
40+
"type": "package",
41+
"serviceable": true,
42+
"sha512": "sha512-st47PosZSHrjECdjeIzZQbzivYBJFv6P2nv4cj2ypdI204DO+vZ7l5raGMiX4eXMJ53RfOIg+/s4DHVZ54Nu2A==",
43+
"path": "netstandard.library/2.0.3",
44+
"hashPath": "netstandard.library.2.0.3.nupkg.sha512"
45+
}
46+
}
4747
}
3.5 KB
Binary file not shown.
960 Bytes
Binary file not shown.

Runtime/ReportPostOptions.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public interface IReportPostOptions
99
{
1010
List<FileInfo> AdditionalAttachments { get; }
1111
List<FormDataParam> AdditionalFormDataParams { get; }
12+
Dictionary<string, string> AdditionalAttributes { get; }
1213
string Description { get; set; }
1314
string Email { get; set; }
1415
string Key { get; set; }
@@ -28,6 +29,7 @@ public class ReportPostOptions : IReportPostOptions
2829
{
2930
public List<FileInfo> AdditionalAttachments { get; } = new List<FileInfo>();
3031
public List<FormDataParam> AdditionalFormDataParams { get; } = new List<FormDataParam>();
32+
public Dictionary<string, string> AdditionalAttributes { get; } = new Dictionary<string, string>();
3133
public string Description { get; set; }
3234
public string Email { get; set; }
3335
public string Key { get; set; }

Runtime/Reporter/WebGLReporter.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ public IEnumerator LogMessageReceived(string logMessage, string stackTrace, LogT
4040
User = clientSettings.User,
4141
CrashTypeId = (int)BugSplatDotNetStandard.BugSplat.ExceptionTypeId.UnityLegacy
4242
};
43+
44+
foreach (var attribute in clientSettings.Attributes)
45+
{
46+
options.AdditionalAttributes.TryAdd(attribute.Key, attribute.Value);
47+
}
48+
4349
stackTrace = $"{logMessage}\n{stackTrace}";
4450

4551
yield return Post(stackTrace, options, callback);

Runtime/Settings/DotNetStandardClientSettingsRepository.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ public List<FileInfo> Attachments
1616
}
1717
}
1818

19+
public Dictionary<string, string> Attributes
20+
{
21+
get
22+
{
23+
return _bugsplat.Attributes;
24+
}
25+
}
26+
1927
public bool CaptureEditorLog { get; set; } = false;
2028

2129
public bool CapturePlayerLog { get; set; } = true;

0 commit comments

Comments
 (0)