com.xd.sdk.report 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/Editor/XD.SDK.Report.Editor.asmdef +18 -0
  2. package/Editor/XD.SDK.Report.Editor.asmdef.meta +7 -0
  3. package/Editor/XDReportProcessBuild.cs +19 -0
  4. package/Editor/XDReportProcessBuild.cs.meta +3 -0
  5. package/Editor.meta +3 -0
  6. package/Runtime/Internal/EvidenceInfo.cs +21 -0
  7. package/Runtime/Internal/EvidenceInfo.cs.meta +3 -0
  8. package/Runtime/Internal/IReport.cs +9 -0
  9. package/Runtime/Internal/IReport.cs.meta +3 -0
  10. package/Runtime/Internal/ReportParamsInternal.cs +45 -0
  11. package/Runtime/Internal/ReportParamsInternal.cs.meta +3 -0
  12. package/Runtime/Internal/ReportSubmitResult.cs +16 -0
  13. package/Runtime/Internal/ReportSubmitResult.cs.meta +3 -0
  14. package/Runtime/Internal/SignedUrlResponse.cs +16 -0
  15. package/Runtime/Internal/SignedUrlResponse.cs.meta +3 -0
  16. package/Runtime/Internal/UploadEvidenceResponse.cs +9 -0
  17. package/Runtime/Internal/UploadEvidenceResponse.cs.meta +3 -0
  18. package/Runtime/Internal.meta +3 -0
  19. package/Runtime/Public/ReportParams.cs +131 -0
  20. package/Runtime/Public/ReportParams.cs.meta +3 -0
  21. package/Runtime/Public/ReportResult.cs +24 -0
  22. package/Runtime/Public/ReportResult.cs.meta +3 -0
  23. package/Runtime/Public/XDGReport.cs +12 -0
  24. package/Runtime/Public/XDGReport.cs.meta +3 -0
  25. package/Runtime/Public/XDReportImpl.cs +254 -0
  26. package/Runtime/Public/XDReportImpl.cs.meta +3 -0
  27. package/Runtime/Public.meta +3 -0
  28. package/Runtime/XD.SDK.Report.asmdef +18 -0
  29. package/Runtime/XD.SDK.Report.asmdef.meta +7 -0
  30. package/Runtime.meta +3 -0
  31. package/package.json +11 -0
  32. package/package.json.meta +3 -0
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "XD.SDK.Report.Editor",
3
+ "references": [
4
+ "GUID:616cea76def2d4f059b94440fc8cc03d",
5
+ "GUID:747e53b1749584bae9386571797e5eb5"
6
+ ],
7
+ "includePlatforms": [
8
+ "Editor"
9
+ ],
10
+ "excludePlatforms": [],
11
+ "allowUnsafeCode": false,
12
+ "overrideReferences": false,
13
+ "precompiledReferences": [],
14
+ "autoReferenced": true,
15
+ "defineConstraints": [],
16
+ "versionDefines": [],
17
+ "noEngineReferences": false
18
+ }
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: eeec22ce273654fd3a76e1135ab8647b
3
+ AssemblyDefinitionImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
@@ -0,0 +1,19 @@
1
+ using System;
2
+ using TapTap.Common.Editor;
3
+ using UnityEditor.Build.Reporting;
4
+
5
+ namespace XD.SDK.Report.Editor
6
+ {
7
+ public class XDReportProcessBuild : SDKLinkProcessBuild
8
+ {
9
+ public override int callbackOrder => 9;
10
+ public override string LinkPath => "XDSDK/Gen/Report/link.xml";
11
+
12
+ public override LinkedAssembly[] LinkedAssemblies => new LinkedAssembly[]
13
+ {
14
+ new LinkedAssembly { Fullname = "XD.SDK.Report" }
15
+ };
16
+
17
+ public override Func<BuildReport, bool> IsTargetPlatform => (report) => true;
18
+ }
19
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: fe95b03b21994758b60af59e1159592a
3
+ timeCreated: 1715590618
package/Editor.meta ADDED
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 1699939c34e140d89ef4ef277899ba35
3
+ timeCreated: 1715590554
@@ -0,0 +1,21 @@
1
+ using LC.Newtonsoft.Json;
2
+
3
+ namespace XD.SDK.Report.Internal
4
+ {
5
+ public class EvidenceInfo
6
+ {
7
+ [JsonProperty("name")]
8
+ public string Name { get; }
9
+ [JsonProperty("uri")]
10
+ public string Uri { get; }
11
+ [JsonProperty("size")]
12
+ public long Size { get; }
13
+
14
+ public EvidenceInfo(string name, string uri, long size)
15
+ {
16
+ Name = name;
17
+ Uri = uri;
18
+ Size = size;
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 31caaf981ad3439a8319e6f31bd9ffa6
3
+ timeCreated: 1716176408
@@ -0,0 +1,9 @@
1
+ using System;
2
+
3
+ namespace XD.SDK.Report.Internal
4
+ {
5
+ public interface IReport
6
+ {
7
+ void Report(Action<bool> resultAction);
8
+ }
9
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: d32421600e0c4193bd75c6b02cfae53c
3
+ timeCreated: 1715592228
@@ -0,0 +1,45 @@
1
+ using System.Collections.Generic;
2
+ using LC.Newtonsoft.Json;
3
+
4
+ namespace XD.SDK.Report.Internal
5
+ {
6
+ public class ReportParamsInternal
7
+ {
8
+ [JsonProperty("reporter")]
9
+ public UserInfo Reporter;
10
+ [JsonProperty("reportee")]
11
+ public UserInfo Reportee;
12
+ [JsonProperty("reasons")]
13
+ public List<ReasonParam> ReasonParams;
14
+ [JsonProperty("user_description", NullValueHandling = NullValueHandling.Ignore)]
15
+ public string UserDescription;
16
+ [JsonProperty("evidence", NullValueHandling = NullValueHandling.Ignore)]
17
+ public List<EvidenceInfo> Evidence;
18
+ [JsonProperty("extras", NullValueHandling = NullValueHandling.Ignore)]
19
+ public string Extras;
20
+
21
+ public class UserInfo
22
+ {
23
+ [JsonProperty("xdid")]
24
+ public string XdId { get; }
25
+ [JsonProperty("extras", NullValueHandling = NullValueHandling.Ignore)]
26
+ public string Extras { get; }
27
+
28
+ public UserInfo(string xdId, string extras)
29
+ {
30
+ XdId = xdId;
31
+ Extras = extras;
32
+ }
33
+ }
34
+
35
+ public class ReasonParam
36
+ {
37
+ [JsonProperty("id")]
38
+ public long ID;
39
+ [JsonProperty("title", NullValueHandling = NullValueHandling.Ignore)]
40
+ public string Title;
41
+ [JsonProperty("extras", NullValueHandling = NullValueHandling.Ignore)]
42
+ public string Extras;
43
+ }
44
+ }
45
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: b967b5d16e0840ed883df2be72237487
3
+ timeCreated: 1716177475
@@ -0,0 +1,16 @@
1
+ using LC.Newtonsoft.Json;
2
+ using XD.SDK.Common.Internal;
3
+
4
+ namespace XD.SDK.Report.Internal
5
+ {
6
+ public class ReportSubmitResult : BaseResponse
7
+ {
8
+ [JsonProperty("data")]
9
+ public ReportSubmitBean ReportSubmitData;
10
+
11
+ public class ReportSubmitBean
12
+ {
13
+ [JsonProperty("success")] public bool Success { get; set; }
14
+ }
15
+ }
16
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: cbad667fef1547d9a8cebb44ff733ff7
3
+ timeCreated: 1715652010
@@ -0,0 +1,16 @@
1
+ using LC.Newtonsoft.Json;
2
+ using XD.SDK.Common.Internal;
3
+
4
+ namespace XD.SDK.Report.Internal
5
+ {
6
+ public class SignedUrlResponse : BaseResponse
7
+ {
8
+ [JsonProperty("data")] public SignedUrlBean SignedUrlData { get; set; }
9
+
10
+ public class SignedUrlBean
11
+ {
12
+ [JsonProperty("signedUrl")] public string SignedUrl { get; set; }
13
+ [JsonProperty("timeOutSec")] public int TimeOutSec { get; set; }
14
+ }
15
+ }
16
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: aded07794dfa4b669cc0c01c021014c3
3
+ timeCreated: 1715649927
@@ -0,0 +1,9 @@
1
+ using XD.SDK.Common.Internal;
2
+
3
+ namespace XD.SDK.Report.Internal
4
+ {
5
+ public class UploadEvidenceResponse: BaseResponse
6
+ {
7
+
8
+ }
9
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 8d84456af1d34b96b1e37e7d3c0a6f5e
3
+ timeCreated: 1715739257
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 70c800d9be714ee682adff2e338f0194
3
+ timeCreated: 1715590590
@@ -0,0 +1,131 @@
1
+ using System.Collections.Generic;
2
+
3
+ namespace XD.SDK.Report
4
+ {
5
+ public class ReportParams
6
+ {
7
+ public ReporterInfo Reporter { get; } // 举报人
8
+ public ReporteeInfo Reportee { get; } // 被举报人
9
+ public List<ReasonInfo> Reasons { get; } // 举报原因
10
+ public string UserDescription { get; } // 玩家描述
11
+ public List<string> EvidenceList { get; } // 玩家添加的附件
12
+ public Dictionary<string, object> Extras { get; } // 附加信息补充玩家信息,透传给使用方
13
+
14
+
15
+ private ReportParams(ReporterInfo reporter, ReporteeInfo reportee, List<ReasonInfo> reasons, string userDescription, List<string> evidenceList, Dictionary<string, object> extras)
16
+ {
17
+ Reporter = reporter;
18
+ Reportee = reportee;
19
+ Reasons = reasons;
20
+ UserDescription = userDescription;
21
+ EvidenceList = evidenceList;
22
+ Extras = extras;
23
+ }
24
+
25
+ public class ReporterInfo
26
+ {
27
+ public Dictionary<string, object> Extras { get; }
28
+
29
+ public ReporterInfo(Dictionary<string, object> extras)
30
+ {
31
+ Extras = extras;
32
+ }
33
+
34
+ public override string ToString()
35
+ {
36
+ return $"ReporterInfo: Extras={string.Join(",", Extras)}";
37
+ }
38
+ }
39
+
40
+ public class ReporteeInfo
41
+ {
42
+ public string XdId { get; }
43
+ public Dictionary<string, object> Extras { get; }
44
+
45
+ public ReporteeInfo(string xdId, Dictionary<string, object> extras)
46
+ {
47
+ XdId = xdId;
48
+ Extras = extras;
49
+ }
50
+
51
+ public override string ToString()
52
+ {
53
+ return $"ReporteeInfo: XdId={XdId}, Extras={string.Join(",", Extras)}";
54
+ }
55
+ }
56
+
57
+ public class ReasonInfo
58
+ {
59
+ public long ID { get; } // 举报原因 ID,后台配置
60
+ public string Title { get; } // 原因名称
61
+ public Dictionary<string, object> Extras { get; } // 附加信息补充玩家信息,透传给使用方
62
+
63
+ public ReasonInfo(long id, string title, Dictionary<string, object> extras)
64
+ {
65
+ ID = id;
66
+ Title = title;
67
+ Extras = extras;
68
+ }
69
+
70
+ public override string ToString()
71
+ {
72
+ return $"ReasonInfo: ID={ID}, Title={Title}, Extras={string.Join(",", Extras)}";
73
+ }
74
+ }
75
+
76
+ public class Builder
77
+ {
78
+ private ReporterInfo _reporter;
79
+ private ReporteeInfo _reportee;
80
+ private List<ReasonInfo> _reasons;
81
+ private string _userDescription;
82
+ private List<string> _evidenceList;
83
+ private Dictionary<string, object> _extras;
84
+ public Builder SetReporter(ReporterInfo reporter)
85
+ {
86
+ _reporter = reporter;
87
+ return this;
88
+ }
89
+
90
+ public Builder SetReportee(ReporteeInfo reportee)
91
+ {
92
+ _reportee = reportee;
93
+ return this;
94
+ }
95
+
96
+ public Builder SetReasons(List<ReasonInfo> reasons)
97
+ {
98
+ _reasons = reasons;
99
+ return this;
100
+ }
101
+
102
+ public Builder SetUserDescription(string userDescription)
103
+ {
104
+ _userDescription = userDescription;
105
+ return this;
106
+ }
107
+
108
+ public Builder SetEvidenceList(List<string> evidenceList)
109
+ {
110
+ _evidenceList = evidenceList;
111
+ return this;
112
+ }
113
+
114
+ public Builder SetExtras(Dictionary<string, object> extras)
115
+ {
116
+ _extras = extras;
117
+ return this;
118
+ }
119
+
120
+ public ReportParams Build()
121
+ {
122
+ return new ReportParams(_reporter, _reportee, _reasons, _userDescription, _evidenceList, _extras);
123
+ }
124
+ }
125
+
126
+ public override string ToString()
127
+ {
128
+ return $"ReportParams: {Reporter}, {Reportee}, {Reasons}, UserDescription={UserDescription}, EvidenceList={string.Join(",", EvidenceList)}, Extras={string.Join(",", Extras)}";
129
+ }
130
+ }
131
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 938fb21d03044ea38c0ecca51e84da87
3
+ timeCreated: 1715652473
@@ -0,0 +1,24 @@
1
+ using XD.SDK.Common.Internal;
2
+
3
+ namespace XD.SDK.Report
4
+ {
5
+ public class ReportResult
6
+ {
7
+ public const int CodeParamInvalid = -1; // 无效参数
8
+ public const int CodeUserNotLoggedIn = -2; // 用户未登录
9
+ public const int CodeFileNotExist = -3; // 文件不存在
10
+ public bool Success { get; }
11
+ public XDException XdException { get; }
12
+
13
+ public ReportResult(bool success, XDException exception)
14
+ {
15
+ Success = success;
16
+ XdException = exception;
17
+ }
18
+
19
+ public override string ToString()
20
+ {
21
+ return $"ReportResult: Success={Success} XdException={XdException}";
22
+ }
23
+ }
24
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 0162e2273cd1465990acdb00e76979ce
3
+ timeCreated: 1716186590
@@ -0,0 +1,12 @@
1
+ using System;
2
+
3
+ namespace XD.SDK.Report
4
+ {
5
+ public class XDGReport
6
+ {
7
+ public static void Report(ReportParams reportParams, Action<ReportResult> resultCallback)
8
+ {
9
+ XDReportImpl.GetInstance().Report(reportParams, resultCallback);
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: a22be58d53464c9ea695c10e9a015a7e
3
+ timeCreated: 1715590796
@@ -0,0 +1,254 @@
1
+ using System;
2
+ using System.Collections.Generic;
3
+ using System.IO;
4
+ using System.Linq;
5
+ using System.Net;
6
+ using System.Net.Http;
7
+ using System.Threading;
8
+ using System.Threading.Tasks;
9
+ using LC.Newtonsoft.Json;
10
+ using XD.SDK.Account;
11
+ using XD.SDK.Common;
12
+ using XD.SDK.Common.Internal;
13
+ using XD.SDK.Report.Internal;
14
+ using XDException = XD.SDK.Common.Internal.XDException;
15
+
16
+ namespace XD.SDK.Report
17
+ {
18
+ public class XDReportImpl
19
+ {
20
+ private const string ReportEndpoint = "reporting/v1/player/report";
21
+ private const string GetSignedUrlEndpoint = "reporting/v1/upload/oss_sign_url";
22
+ private const int DefaultTimeoutSec = 5 * 60;
23
+
24
+ private static volatile XDReportImpl _instance;
25
+ private static readonly object Locker = new object();
26
+
27
+ private XDReportImpl()
28
+ {
29
+ }
30
+
31
+ public static XDReportImpl GetInstance()
32
+ {
33
+ if (_instance != null) return _instance;
34
+ lock (Locker)
35
+ {
36
+ if (_instance == null)
37
+ {
38
+ _instance = new XDReportImpl();
39
+ }
40
+ }
41
+
42
+ return _instance;
43
+ }
44
+
45
+ public void Report(ReportParams reportParams, Action<ReportResult> resultCallback)
46
+ {
47
+ var currentUserId = UserManager.GetCurrentUser()?.userId;
48
+ if (string.IsNullOrEmpty(currentUserId))
49
+ {
50
+ resultCallback.Invoke(new ReportResult(false,
51
+ new XDException(ReportResult.CodeUserNotLoggedIn, "user is null, please login first!")));
52
+ return;
53
+ }
54
+ if (reportParams.Reportee == null || reportParams.Reportee.XdId.Length <= 0
55
+ || reportParams.Reasons == null || reportParams.Reasons.Count <= 0)
56
+ {
57
+ resultCallback.Invoke(new ReportResult(false,
58
+ new XDException(ReportResult.CodeParamInvalid, "invalid report params , please check.")));
59
+ return;
60
+ }
61
+
62
+ ReportAsync(currentUserId, reportParams, resultCallback).ConfigureAwait(false);
63
+ }
64
+
65
+ private static async Task ReportAsync(string currentUserId, ReportParams reportParams, Action<ReportResult> resultCallback)
66
+ {
67
+ var requestParams = new ReportParamsInternal
68
+ {
69
+ Reporter = new ReportParamsInternal.UserInfo(currentUserId,
70
+ reportParams.Reporter?.Extras == null
71
+ ? null
72
+ : JsonConvert.SerializeObject(reportParams.Reporter.Extras)),
73
+ Reportee = new ReportParamsInternal.UserInfo(reportParams.Reportee.XdId,
74
+ reportParams.Reportee.Extras == null
75
+ ? null
76
+ : JsonConvert.SerializeObject(reportParams.Reportee.Extras)),
77
+ ReasonParams = reportParams.Reasons.Select((reasonInfo) => new ReportParamsInternal.ReasonParam
78
+ {
79
+ ID = reasonInfo.ID,
80
+ Title = reasonInfo.Title,
81
+ Extras = reasonInfo.Extras == null ? null : JsonConvert.SerializeObject(reasonInfo.Extras)
82
+ }).ToList(),
83
+ UserDescription = reportParams.UserDescription,
84
+ Extras = reportParams.Extras == null ? null : JsonConvert.SerializeObject(reportParams.Extras)
85
+ };
86
+
87
+ var cts = new CancellationTokenSource();
88
+ var token = CancellationTokenSource.CreateLinkedTokenSource(cts.Token).Token;
89
+
90
+ if (reportParams.EvidenceList != null && reportParams.EvidenceList.Count > 0)
91
+ {
92
+ try
93
+ {
94
+ var uploadEvidenceTasks = reportParams.EvidenceList
95
+ .Select(filePath => UploadEvidence(filePath, cts, token))
96
+ .ToList();
97
+
98
+ var results = await Task.WhenAll(uploadEvidenceTasks);
99
+ var evidenceList = results.ToList();
100
+
101
+ requestParams.Evidence = evidenceList;
102
+ }
103
+ catch (XDException ex)
104
+ {
105
+ XDGLogger.Error("Report failed, upload evidence error:" + ex);
106
+ cts.Cancel();
107
+ resultCallback.Invoke(new ReportResult(false, ex));
108
+ return;
109
+ }
110
+ catch (OperationCanceledException ex)
111
+ {
112
+ XDGLogger.Warn("upload evidence canceled:" + ex.Message);
113
+ return;
114
+ }
115
+ catch (Exception e)
116
+ {
117
+ XDGLogger.Error("Report failed, upload evidence Unexpected exception:" + e.Message);
118
+ cts.Cancel();
119
+ resultCallback.Invoke(new ReportResult(false,
120
+ new XDException(XDException.DEFAULT_CODE, e.Message)));
121
+ return;
122
+ }
123
+ }
124
+
125
+ try
126
+ {
127
+ var reportSubmitResult = await XDHttpClientFactory.GetDefaultXdHttpClient()
128
+ .Post<ReportSubmitResult>(ReportEndpoint, data: requestParams);
129
+ resultCallback.Invoke(new ReportResult(reportSubmitResult.ReportSubmitData.Success,
130
+ new XDException(reportSubmitResult.Code, reportSubmitResult.Message)));
131
+ }
132
+ catch (XDException e)
133
+ {
134
+ XDGLogger.Error("Report failed: " + e);
135
+ resultCallback.Invoke(new ReportResult(false, e));
136
+ }
137
+ catch (Exception e)
138
+ {
139
+ XDGLogger.Error("Report failed: Unexpected exception:" + e.Message);
140
+ resultCallback.Invoke(new ReportResult(false, new XDException(XDException.DEFAULT_CODE, e.Message)));
141
+ }
142
+ }
143
+
144
+ private static async Task<EvidenceInfo> UploadEvidence(string filePath,
145
+ CancellationTokenSource cancellationTokenSource, CancellationToken token)
146
+ {
147
+ if (!File.Exists(filePath))
148
+ {
149
+ XDGLogger.Error($"report failed, file: {filePath} dose not exist");
150
+ throw new XDException(ReportResult.CodeFileNotExist, $"file: {filePath} does not exist");
151
+ }
152
+
153
+ var fileInfo = new FileInfo(filePath);
154
+ var queryParams = new Dictionary<string, object>
155
+ {
156
+ ["file_name"] = fileInfo.Name,
157
+ ["file_size"] = fileInfo.Length
158
+ };
159
+
160
+ SignedUrlResponse signedUrlResponse;
161
+ try
162
+ {
163
+ signedUrlResponse = await XDHttpClientFactory.GetDefaultXdHttpClient()
164
+ .Get<SignedUrlResponse>(GetSignedUrlEndpoint, queryParams: queryParams);
165
+ }
166
+ catch (OperationCanceledException ex)
167
+ {
168
+ XDGLogger.Warn("UploadEvidenceBySignedOssUrl upload evidence canceled:" + ex.Message);
169
+ throw;
170
+ }
171
+ catch (Exception e)
172
+ {
173
+ XDGLogger.Error("Get Signed Url error: " + e);
174
+ cancellationTokenSource.Cancel();
175
+ throw;
176
+ }
177
+
178
+ var fullUrl = signedUrlResponse?.SignedUrlData?.SignedUrl;
179
+ if (string.IsNullOrEmpty(fullUrl))
180
+ {
181
+ XDGLogger.Error("upload evidence error: couldn't get signed url.");
182
+ cancellationTokenSource.Cancel();
183
+ throw new XDException(XDException.DEFAULT_CODE, "Couldn't get signed url");
184
+ }
185
+
186
+ try
187
+ {
188
+ var timeOutSec = signedUrlResponse.SignedUrlData.TimeOutSec;
189
+ if (timeOutSec <= 0)
190
+ {
191
+ timeOutSec = DefaultTimeoutSec;
192
+ }
193
+
194
+ var uploadEvidenceResponse =
195
+ await UploadEvidenceBySignedOssUrl(signedUrlResponse.SignedUrlData.SignedUrl, timeOutSec,
196
+ filePath, token);
197
+ if (uploadEvidenceResponse.StatusCode == HttpStatusCode.OK)
198
+ {
199
+ var uri = new Uri(fullUrl);
200
+ var evidenceInfo = new EvidenceInfo(fileInfo.Name,
201
+ new Uri(uri.GetLeftPart(UriPartial.Path)).ToString(), fileInfo.Length);
202
+ return evidenceInfo;
203
+ }
204
+
205
+ var errorContent = await uploadEvidenceResponse.Content.ReadAsStringAsync();
206
+ var ex = new XDException((int)uploadEvidenceResponse.StatusCode, errorContent);
207
+ XDGLogger.Error("Report upload evidences failed: " + ex);
208
+ throw ex;
209
+ }
210
+ catch (OperationCanceledException ex)
211
+ {
212
+ XDGLogger.Warn("UploadEvidence upload evidence canceled:" + ex.Message);
213
+ throw;
214
+ }
215
+ catch (Exception e)
216
+ {
217
+ XDGLogger.Error("Report upload evidences catch an error: " + e);
218
+ cancellationTokenSource.Cancel();
219
+ throw;
220
+ }
221
+ }
222
+
223
+ private static async Task<HttpResponseMessage> UploadEvidenceBySignedOssUrl(string signedOssUrl, int timeOutSec,
224
+ string filePath, CancellationToken token)
225
+ {
226
+ using (var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
227
+ {
228
+ try
229
+ {
230
+ var content = new StreamContent(fileStream);
231
+ var ossClient = new HttpClient(new XdDelegatingHandler(new HttpClientHandler()));
232
+ ossClient.Timeout = TimeSpan.FromSeconds(timeOutSec);
233
+ var response = await ossClient.PutAsync($"{signedOssUrl}", content, token);
234
+ return response;
235
+ }
236
+ catch (OperationCanceledException ex)
237
+ {
238
+ XDGLogger.Warn("UploadEvidenceBySignedOssUrl upload evidence canceled:" + ex);
239
+ if (!token.IsCancellationRequested)
240
+ {
241
+ throw new TimeoutException("UploadEvidenceBySignedOssUrl upload evidence timeout");
242
+ }
243
+
244
+ throw;
245
+ }
246
+ catch (Exception e)
247
+ {
248
+ XDGLogger.Error("signedOssUrl: " + signedOssUrl + ", ------> " + e);
249
+ throw;
250
+ }
251
+ }
252
+ }
253
+ }
254
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: e7861bf22d7b447ba07dbe03870edbd3
3
+ timeCreated: 1715592452
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 75fec9f95a0645f8af57bd8228b3df0f
3
+ timeCreated: 1715590596
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "XD.SDK.Report",
3
+ "rootNamespace": "",
4
+ "references": [
5
+ "GUID:271a06ab0780d4a5ea46c9c3be2ab5dc",
6
+ "GUID:8b2e8a99ce9ab457da469f8744959bc2",
7
+ "GUID:c72576b1c89c54ea0a0d748ee92b35c2"
8
+ ],
9
+ "includePlatforms": [],
10
+ "excludePlatforms": [],
11
+ "allowUnsafeCode": false,
12
+ "overrideReferences": false,
13
+ "precompiledReferences": [],
14
+ "autoReferenced": true,
15
+ "defineConstraints": [],
16
+ "versionDefines": [],
17
+ "noEngineReferences": false
18
+ }
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: df292eb1ae1fe42fb908e90459182fd1
3
+ AssemblyDefinitionImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
package/Runtime.meta ADDED
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 861f533b37904f6ba0281f90334240e5
3
+ timeCreated: 1715590568
package/package.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "com.xd.sdk.report",
3
+ "version": "0.0.1",
4
+ "description": "XDSDK",
5
+ "unity": "2018.3",
6
+ "license": "MIT",
7
+ "dependencies": {
8
+ "com.xd.sdk.common": "0.0.1",
9
+ "com.xd.tds.common": "3.27.1-xd.1"
10
+ }
11
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 9085c62777ce4df387fa9add5c2f8ac1
3
+ timeCreated: 1716287109