cz.xprees.event-logging 1.0.4 → 1.0.6
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.
|
@@ -2,6 +2,7 @@ using System;
|
|
|
2
2
|
using System.Collections.Generic;
|
|
3
3
|
using System.Threading;
|
|
4
4
|
using Cysharp.Threading.Tasks;
|
|
5
|
+
using Newtonsoft.Json;
|
|
5
6
|
using UnityEngine;
|
|
6
7
|
using UnityEngine.Networking;
|
|
7
8
|
using Xprees.EventLogging.Api.Model;
|
|
@@ -16,6 +17,7 @@ namespace Xprees.EventLogging.Api
|
|
|
16
17
|
private readonly string _baseUrl;
|
|
17
18
|
private string LogsUri => $"{_baseUrl}/logs";
|
|
18
19
|
private string LogsBatchUri => $"{_baseUrl}/logs/batch";
|
|
20
|
+
private string ScenariosUri => $"{_baseUrl}/logs/scenarios";
|
|
19
21
|
|
|
20
22
|
public EventLoggingApi(string baseUrl = DefaultEndpoint)
|
|
21
23
|
{
|
|
@@ -60,5 +62,27 @@ namespace Xprees.EventLogging.Api
|
|
|
60
62
|
await batchRequest.SendWebRequestAsync(cancellationToken);
|
|
61
63
|
return batchRequest.result == UnityWebRequest.Result.Success;
|
|
62
64
|
}
|
|
65
|
+
|
|
66
|
+
public async UniTask<string[]> GetScenarioNames(CancellationToken cancellationToken = default)
|
|
67
|
+
{
|
|
68
|
+
try
|
|
69
|
+
{
|
|
70
|
+
var downloadHandlerBuffer = new DownloadHandlerBuffer();
|
|
71
|
+
var uploadHandlerRaw = new UploadHandlerRaw(Array.Empty<byte>());
|
|
72
|
+
var request = new UnityWebRequest(ScenariosUri, UnityWebRequest.kHttpVerbGET, downloadHandlerBuffer, uploadHandlerRaw);
|
|
73
|
+
request.SetRequestHeader("Content-Type", "application/json");
|
|
74
|
+
await request.SendWebRequestAsync(cancellationToken);
|
|
75
|
+
var result = request.result;
|
|
76
|
+
if (result != UnityWebRequest.Result.Success) return Array.Empty<string>();
|
|
77
|
+
var rawString = request.downloadHandler.text;
|
|
78
|
+
|
|
79
|
+
return JsonConvert.DeserializeObject<string[]>(rawString);
|
|
80
|
+
}
|
|
81
|
+
catch (Exception e)
|
|
82
|
+
{
|
|
83
|
+
Debug.LogError($"API: {e}");
|
|
84
|
+
return Array.Empty<string>();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
63
87
|
}
|
|
64
88
|
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cz.xprees.event-logging",
|
|
3
3
|
"displayName": "Event Logging",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.6",
|
|
5
5
|
"unity": "2021.3",
|
|
6
6
|
"description": "This package provides a simple way to log events in your game.",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"category": "Core",
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"com.cysharp.unitask": "2.5.10",
|
|
11
|
-
"cz.xprees.core": "
|
|
11
|
+
"cz.xprees.core": "1.0.31"
|
|
12
12
|
},
|
|
13
13
|
"keywords": [
|
|
14
14
|
"Unity",
|