com.taptap.sdk.core 4.4.2 → 4.5.0
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.
- package/Editor/TapSDKCoreCompile.cs +6 -0
- package/Mobile/Editor/NativeDependencies.xml +2 -3
- package/Mobile/Runtime/TapEventMobile.cs +0 -1
- package/{Standalone/Runtime/Internal/Openlog/Bean.meta → Plugins.meta} +1 -1
- package/Resources/TapMessage.prefab +1 -1
- package/Runtime/Internal/Log/TapLog.cs +1 -1
- package/Runtime/Public/TapTapSDK.cs +12 -3
- package/Runtime/Public/TapTapSdkOptions.cs +0 -4
- package/Standalone/Plugins/macOS/libtapsdkcorecpp.dylib +0 -0
- package/Standalone/Plugins/macOS/libtapsdkcorecpp.dylib.meta +80 -0
- package/Standalone/Plugins/x86/tapsdkcore.dll +0 -0
- package/Standalone/Plugins/x86/tapsdkcore.dll.meta +63 -0
- package/Standalone/{Runtime/Internal/Utils.meta → Plugins/x86.meta} +1 -1
- package/Standalone/Plugins/x86_64/tapsdkcore.dll +0 -0
- package/Standalone/Plugins/x86_64/tapsdkcore.dll.meta +63 -0
- package/{link.xml.meta → Standalone/Plugins/x86_64.meta} +3 -2
- package/Standalone/Runtime/Internal/Constants.cs +0 -17
- package/Standalone/Runtime/Internal/DeviceInfo.cs +93 -89
- package/Standalone/Runtime/Internal/EventSender.cs +2 -2
- package/Standalone/Runtime/Internal/Http/TapHttp.cs +12 -6
- package/Standalone/Runtime/Internal/Http/TapHttpUtils.cs +23 -7
- package/Standalone/Runtime/Internal/Openlog/TapAppDurationStandalone.cs +121 -0
- package/Standalone/Runtime/Internal/Openlog/{TapOpenlogQueueBase.cs.meta → TapAppDurationStandalone.cs.meta} +1 -1
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogParamConstants.cs +1 -3
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogStandalone.cs +96 -94
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogStartParamConstants.cs +23 -0
- package/Standalone/Runtime/Internal/Openlog/{Bean/TapOpenlogStoreBean.cs.meta → TapOpenlogStartParamConstants.cs.meta} +1 -1
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogWrapper.cs +178 -0
- package/Standalone/Runtime/Internal/Openlog/{Bean/TapOpenlogLogGroup.cs.meta → TapOpenlogWrapper.cs.meta} +1 -1
- package/Standalone/Runtime/Public/TapCoreStandalone.cs +20 -13
- package/Standalone/Runtime/TapSDK.Core.Standalone.Runtime.asmdef +0 -1
- package/package.json +1 -1
- package/Standalone/Runtime/Internal/Openlog/Bean/TapOpenlogLogGroup.cs +0 -39
- package/Standalone/Runtime/Internal/Openlog/Bean/TapOpenlogStoreBean.cs +0 -33
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogHttpClient.cs +0 -153
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogHttpClient.cs.meta +0 -11
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogQueueBase.cs +0 -198
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogQueueBusiness.cs +0 -17
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogQueueBusiness.cs.meta +0 -11
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogQueueTechnology.cs +0 -15
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogQueueTechnology.cs.meta +0 -11
- package/Standalone/Runtime/Internal/Utils/TapProtoBufffer.cs +0 -28
- package/Standalone/Runtime/Internal/Utils/TapProtoBufffer.cs.meta +0 -11
- package/link.xml +0 -4
|
@@ -5,8 +5,8 @@ namespace TapSDK.Core.Standalone.Internal.Http
|
|
|
5
5
|
using System;
|
|
6
6
|
using System.Collections.Generic;
|
|
7
7
|
using System.Net.Http.Headers;
|
|
8
|
+
using System.Text;
|
|
8
9
|
using System.Threading.Tasks;
|
|
9
|
-
using System.Web;
|
|
10
10
|
using Newtonsoft.Json;
|
|
11
11
|
using TapSDK.Core.Internal.Log;
|
|
12
12
|
|
|
@@ -289,15 +289,21 @@ namespace TapSDK.Core.Standalone.Internal.Http
|
|
|
289
289
|
}
|
|
290
290
|
uriBuilder = new UriBuilder(uri: $"{host}{path}");
|
|
291
291
|
}
|
|
292
|
+
|
|
292
293
|
if (allQueryParams.Count > 0)
|
|
293
294
|
{
|
|
294
|
-
var
|
|
295
|
+
var queryBuilder = new StringBuilder();
|
|
295
296
|
foreach (var param in allQueryParams)
|
|
296
297
|
{
|
|
297
|
-
|
|
298
|
+
// 使用 Uri.EscapeDataString 来编码参数的键和值
|
|
299
|
+
queryBuilder.Append($"{Uri.EscapeDataString(param.Key)}={Uri.EscapeDataString(param.Value)}&");
|
|
298
300
|
}
|
|
299
|
-
|
|
301
|
+
// 移除末尾的 '&'
|
|
302
|
+
queryBuilder.Length -= 1;
|
|
303
|
+
|
|
304
|
+
uriBuilder.Query = queryBuilder.ToString();
|
|
300
305
|
}
|
|
306
|
+
|
|
301
307
|
var requestUri = uriBuilder.Uri;
|
|
302
308
|
|
|
303
309
|
// 创建 HttpRequestMessage
|
|
@@ -356,13 +362,13 @@ namespace TapSDK.Core.Standalone.Internal.Http
|
|
|
356
362
|
{
|
|
357
363
|
if (TapTapSDK.taptapSdkOptions.enableLog)
|
|
358
364
|
{
|
|
359
|
-
TapHttpUtils.PrintRequest(client, request
|
|
365
|
+
TapHttpUtils.PrintRequest(client, request);
|
|
360
366
|
}
|
|
361
367
|
// 发送请求
|
|
362
368
|
HttpResponseMessage response = await client.SendAsync(request);
|
|
363
369
|
if (TapTapSDK.taptapSdkOptions.enableLog)
|
|
364
370
|
{
|
|
365
|
-
TapHttpUtils.PrintResponse(response
|
|
371
|
+
TapHttpUtils.PrintResponse(response);
|
|
366
372
|
}
|
|
367
373
|
// 解析响应
|
|
368
374
|
return await httpConfig.Parser.Parse<T>(response);
|
|
@@ -50,7 +50,7 @@ namespace TapSDK.Core.Standalone.Internal.Http
|
|
|
50
50
|
return new string(nonce);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
public static string GenerateUserAgent()
|
|
54
54
|
{
|
|
55
55
|
return $"TapSDK-Unity/{TapTapSDK.Version}";
|
|
56
56
|
}
|
|
@@ -102,7 +102,7 @@ namespace TapSDK.Core.Standalone.Internal.Http
|
|
|
102
102
|
return null;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
public static void PrintRequest(HttpClient client, HttpRequestMessage request
|
|
105
|
+
public static void PrintRequest(HttpClient client, HttpRequestMessage request)
|
|
106
106
|
{
|
|
107
107
|
if (TapLogger.LogDelegate == null)
|
|
108
108
|
{
|
|
@@ -136,15 +136,23 @@ namespace TapSDK.Core.Standalone.Internal.Http
|
|
|
136
136
|
sb.AppendLine($"\t{header.Key}: {string.Join(",", header.Value.ToArray())}");
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
|
-
|
|
139
|
+
string contentString = null;
|
|
140
|
+
try
|
|
141
|
+
{
|
|
142
|
+
contentString = request.Content.ReadAsStringAsync().Result;
|
|
143
|
+
}
|
|
144
|
+
catch (Exception)
|
|
145
|
+
{
|
|
146
|
+
}
|
|
147
|
+
if (!string.IsNullOrEmpty(contentString))
|
|
140
148
|
{
|
|
141
|
-
sb.AppendLine($"Content: \n{
|
|
149
|
+
sb.AppendLine($"Content: \n{contentString}");
|
|
142
150
|
}
|
|
143
151
|
sb.AppendLine("=== HTTP Request End ===");
|
|
144
152
|
tapLog.Log($"HTTP Request [{request.RequestUri.PathAndQuery}]", sb.ToString());
|
|
145
153
|
}
|
|
146
154
|
|
|
147
|
-
public static void PrintResponse(HttpResponseMessage response
|
|
155
|
+
public static void PrintResponse(HttpResponseMessage response)
|
|
148
156
|
{
|
|
149
157
|
if (TapLogger.LogDelegate == null)
|
|
150
158
|
{
|
|
@@ -154,9 +162,17 @@ namespace TapSDK.Core.Standalone.Internal.Http
|
|
|
154
162
|
sb.AppendLine("=== HTTP Response Start ===");
|
|
155
163
|
sb.AppendLine($"URL: {response.RequestMessage.RequestUri}");
|
|
156
164
|
sb.AppendLine($"Status Code: {response.StatusCode}");
|
|
157
|
-
|
|
165
|
+
string contentString = null;
|
|
166
|
+
try
|
|
167
|
+
{
|
|
168
|
+
contentString = response.Content.ReadAsStringAsync().Result;
|
|
169
|
+
}
|
|
170
|
+
catch (Exception)
|
|
171
|
+
{
|
|
172
|
+
}
|
|
173
|
+
if (!string.IsNullOrEmpty(contentString))
|
|
158
174
|
{
|
|
159
|
-
sb.AppendLine($"Content: {
|
|
175
|
+
sb.AppendLine($"Content: {contentString}");
|
|
160
176
|
}
|
|
161
177
|
sb.AppendLine("=== HTTP Response End ===");
|
|
162
178
|
tapLog.Log($"HTTP Response [{response.RequestMessage.RequestUri.PathAndQuery}]", sb.ToString());
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using Newtonsoft.Json;
|
|
4
|
+
using TapSDK.Core.Internal.Log;
|
|
5
|
+
|
|
6
|
+
namespace TapSDK.Core.Standalone.Internal.Openlog
|
|
7
|
+
{
|
|
8
|
+
public class TapAppDurationStandalone
|
|
9
|
+
{
|
|
10
|
+
private const string MODULE_NAME = "app_duration";
|
|
11
|
+
|
|
12
|
+
private static readonly TapLog log = new TapLog("AppDuration");
|
|
13
|
+
|
|
14
|
+
public static void Enable()
|
|
15
|
+
{
|
|
16
|
+
#if UNITY_STANDALONE
|
|
17
|
+
// log.Log("Enable");
|
|
18
|
+
List<string> modules = new List<string> { MODULE_NAME };
|
|
19
|
+
TapOpenlogWrapper.TdkEnableModules(JsonConvert.SerializeObject(modules));
|
|
20
|
+
#endif
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public static void Disable()
|
|
24
|
+
{
|
|
25
|
+
#if UNITY_STANDALONE
|
|
26
|
+
// log.Log("Disable");
|
|
27
|
+
List<string> modules = new List<string> { MODULE_NAME };
|
|
28
|
+
TapOpenlogWrapper.TdkDisableModules(JsonConvert.SerializeObject(modules));
|
|
29
|
+
#endif
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public static void SetExtraAppDurationParams(Dictionary<string, string> param)
|
|
33
|
+
{
|
|
34
|
+
#if UNITY_STANDALONE
|
|
35
|
+
log.Log("SetExtraAppDurationParams param: ", JsonConvert.SerializeObject(param));
|
|
36
|
+
if (param == null)
|
|
37
|
+
{
|
|
38
|
+
log.Warning("SetExtraAppDurationParams param is null");
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
TapOpenlogWrapper.TdkSetExtraAppDurationParams(JsonConvert.SerializeObject(param));
|
|
42
|
+
#endif
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public static void OnLogin(string openId)
|
|
46
|
+
{
|
|
47
|
+
#if UNITY_STANDALONE
|
|
48
|
+
log.Log("OnLogin openId: " + openId);
|
|
49
|
+
if (openId == null)
|
|
50
|
+
{
|
|
51
|
+
log.Warning("OnLogin openId is null");
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
Dictionary<string, string> userInfo = new Dictionary<string, string>
|
|
55
|
+
{
|
|
56
|
+
{TapOpenlogParamConstants.PARAM_OPEN_ID, openId}
|
|
57
|
+
};
|
|
58
|
+
TapOpenlogWrapper.TdkOnLogin(JsonConvert.SerializeObject(userInfo));
|
|
59
|
+
#endif
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public static void OnLogout()
|
|
63
|
+
{
|
|
64
|
+
#if UNITY_STANDALONE
|
|
65
|
+
log.Log("OnLogout");
|
|
66
|
+
TapOpenlogWrapper.TdkOnLogout();
|
|
67
|
+
#endif
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public static void OnForeground()
|
|
71
|
+
{
|
|
72
|
+
#if UNITY_STANDALONE
|
|
73
|
+
log.Log("OnForeground");
|
|
74
|
+
TapOpenlogWrapper.TdkOnForeground();
|
|
75
|
+
#endif
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
public static void OnBackground()
|
|
79
|
+
{
|
|
80
|
+
#if UNITY_STANDALONE
|
|
81
|
+
log.Log("OnBackground");
|
|
82
|
+
TapOpenlogWrapper.TdkOnBackground();
|
|
83
|
+
#endif
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
public static string Version()
|
|
87
|
+
{
|
|
88
|
+
|
|
89
|
+
string v = null;
|
|
90
|
+
#if UNITY_STANDALONE
|
|
91
|
+
try
|
|
92
|
+
{
|
|
93
|
+
v = TapOpenlogWrapper.GetTdkVersion();
|
|
94
|
+
}
|
|
95
|
+
catch (Exception e)
|
|
96
|
+
{
|
|
97
|
+
log.Error("GetVersion error: " + e.Message);
|
|
98
|
+
}
|
|
99
|
+
log.Log("Version: " + v);
|
|
100
|
+
#endif
|
|
101
|
+
return v;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
public static string GitCommit()
|
|
105
|
+
{
|
|
106
|
+
string v = null;
|
|
107
|
+
#if UNITY_STANDALONE
|
|
108
|
+
try
|
|
109
|
+
{
|
|
110
|
+
v = TapOpenlogWrapper.GetTdkGitCommit();
|
|
111
|
+
}
|
|
112
|
+
catch (Exception e)
|
|
113
|
+
{
|
|
114
|
+
log.Error("GitCommit error: " + e.Message);
|
|
115
|
+
}
|
|
116
|
+
log.Log("GitCommit: " + v);
|
|
117
|
+
#endif
|
|
118
|
+
return v;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -2,6 +2,7 @@ namespace TapSDK.Core.Standalone.Internal.Openlog
|
|
|
2
2
|
{
|
|
3
3
|
internal class TapOpenlogParamConstants
|
|
4
4
|
{
|
|
5
|
+
public const string PARAM_ACTION = "action";
|
|
5
6
|
// 该条日志的唯一标识 d
|
|
6
7
|
public const string PARAM_T_LOG_ID = "t_log_id";
|
|
7
8
|
|
|
@@ -35,9 +36,6 @@ namespace TapSDK.Core.Standalone.Internal.Openlog
|
|
|
35
36
|
// SDK 运行平台 g
|
|
36
37
|
public const string PARAM_PLATFORM = "platform";
|
|
37
38
|
|
|
38
|
-
// 埋点版本号(预留字段),当前全为1 g
|
|
39
|
-
public const string PARAM_TRACK_CODE = "track_code";
|
|
40
|
-
|
|
41
39
|
// SDK设置的地区,例如 zh_CN d
|
|
42
40
|
public const string PARAM_SDK_LOCALE = "sdk_locale";
|
|
43
41
|
|
|
@@ -1,33 +1,53 @@
|
|
|
1
|
-
|
|
2
1
|
using System;
|
|
3
2
|
using System.Collections.Generic;
|
|
3
|
+
using System.IO;
|
|
4
|
+
using System.Runtime.InteropServices;
|
|
4
5
|
using Newtonsoft.Json;
|
|
5
6
|
using TapSDK.Core.Internal.Log;
|
|
7
|
+
using TapSDK.Core.Standalone.Internal.Http;
|
|
6
8
|
using UnityEngine;
|
|
9
|
+
#if UNITY_STANDALONE
|
|
10
|
+
using static TapSDK.Core.Standalone.Internal.Openlog.TapOpenlogWrapper;
|
|
11
|
+
#endif
|
|
7
12
|
|
|
8
13
|
namespace TapSDK.Core.Standalone.Internal.Openlog
|
|
9
14
|
{
|
|
10
15
|
public class TapOpenlogStandalone
|
|
11
16
|
{
|
|
12
17
|
public static string openid = "";
|
|
13
|
-
|
|
14
|
-
private static Dictionary<string,
|
|
15
|
-
private
|
|
16
|
-
|
|
17
|
-
private static
|
|
18
|
-
private static
|
|
18
|
+
private static readonly Dictionary<string, string> generalParameter = new Dictionary<string, string>();
|
|
19
|
+
private static readonly Dictionary<string, System.Object> openlogStartParameter = new Dictionary<string, System.Object>();
|
|
20
|
+
private readonly string sdkProjectName;
|
|
21
|
+
private readonly string sdkProjectVersion;
|
|
22
|
+
private static readonly bool isRND = false;
|
|
23
|
+
private static readonly TapLog log = new TapLog(module: "Openlog");
|
|
24
|
+
#if UNITY_STANDALONE
|
|
25
|
+
private static readonly CommonVariablesGetter commonVariablesGetter = new CommonVariablesGetter(GetCommonVariables);
|
|
26
|
+
private static readonly FreeStringCallback freeString = new FreeStringCallback(FreeString);
|
|
19
27
|
#endif
|
|
20
|
-
private string sdkProjectName;
|
|
21
|
-
private string sdkProjectVersion;
|
|
22
|
-
|
|
23
|
-
private static TapLog log = new TapLog(module: "Openlog");
|
|
24
28
|
public static void Init()
|
|
25
29
|
{
|
|
26
|
-
#if
|
|
27
|
-
businessQueue = new TapOpenlogQueueBusiness();
|
|
28
|
-
technologyQueue = new TapOpenlogQueueTechnology();
|
|
29
|
-
#endif
|
|
30
|
+
#if UNITY_STANDALONE
|
|
30
31
|
InitGeneralParameter();
|
|
32
|
+
InitOpenlogStartParameter();
|
|
33
|
+
string openlogStartStr = JsonConvert.SerializeObject(openlogStartParameter);
|
|
34
|
+
int result = TdkOnAppStarted(openlogStartStr, commonVariablesGetter, freeString);
|
|
35
|
+
#endif
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
private static IntPtr GetCommonVariables()
|
|
39
|
+
{
|
|
40
|
+
Dictionary<string, string> dynamicProperties = InflateDynamicProperties();
|
|
41
|
+
string jsonStr = JsonConvert.SerializeObject(dynamicProperties);
|
|
42
|
+
return Marshal.StringToHGlobalAnsi(jsonStr);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private static void FreeString(IntPtr intPtr)
|
|
46
|
+
{
|
|
47
|
+
if (intPtr != IntPtr.Zero)
|
|
48
|
+
{
|
|
49
|
+
Marshal.FreeHGlobal(intPtr);
|
|
50
|
+
}
|
|
31
51
|
}
|
|
32
52
|
|
|
33
53
|
public TapOpenlogStandalone(string sdkProjectName, string sdkProjectVersion)
|
|
@@ -41,32 +61,16 @@ namespace TapSDK.Core.Standalone.Internal.Openlog
|
|
|
41
61
|
Dictionary<string, string> properties = null
|
|
42
62
|
)
|
|
43
63
|
{
|
|
44
|
-
|
|
45
|
-
string tLogId = Guid.NewGuid().ToString();
|
|
46
|
-
|
|
64
|
+
#if UNITY_STANDALONE
|
|
47
65
|
if (properties == null)
|
|
48
66
|
{
|
|
49
67
|
properties = new Dictionary<string, string>();
|
|
50
68
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
// 该条日志的唯一标识
|
|
58
|
-
props[TapOpenlogParamConstants.PARAM_T_LOG_ID] = tLogId;
|
|
59
|
-
// 客户端生成的时间戳,毫秒级
|
|
60
|
-
props[TapOpenlogParamConstants.PARAM_TIMESTAMP] = timestamp.ToString();
|
|
61
|
-
|
|
62
|
-
props["action"] = action;
|
|
63
|
-
|
|
64
|
-
TapOpenlogStoreBean bean = new TapOpenlogStoreBean(action, timestamp, tLogId, props);
|
|
65
|
-
log.Log("LogBusiness action = " + action + ", sdkProjectName = " + sdkProjectName + " , sdkProjectVersion = " + sdkProjectVersion, bean + "\n" + JsonConvert.SerializeObject(properties));
|
|
66
|
-
#if UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN
|
|
67
|
-
businessQueue.Enqueue(bean);
|
|
68
|
-
#else
|
|
69
|
-
// log.Log($"This Platform 【{Application.platform}】 is not supported for Openlog.");
|
|
69
|
+
properties[TapOpenlogParamConstants.PARAM_TAPSDK_PROJECT] = sdkProjectName;
|
|
70
|
+
properties[TapOpenlogParamConstants.PARAM_TAPSDK_VERSION] = sdkProjectVersion;
|
|
71
|
+
properties[TapOpenlogParamConstants.PARAM_ACTION] = action;
|
|
72
|
+
string propertiesStr = JsonConvert.SerializeObject(properties);
|
|
73
|
+
TdkOpenLog("tapsdk", propertiesStr);
|
|
70
74
|
#endif
|
|
71
75
|
}
|
|
72
76
|
|
|
@@ -75,36 +79,50 @@ namespace TapSDK.Core.Standalone.Internal.Openlog
|
|
|
75
79
|
Dictionary<string, string> properties = null
|
|
76
80
|
)
|
|
77
81
|
{
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (properties == null)
|
|
82
|
+
#if UNITY_STANDALONE
|
|
83
|
+
if (TapCoreStandalone.coreOptions.region == TapTapRegionType.CN && !"TapPayment".Equals(sdkProjectName))
|
|
82
84
|
{
|
|
83
|
-
|
|
85
|
+
// 国内非支付SDK不上报技术日志
|
|
86
|
+
return;
|
|
84
87
|
}
|
|
85
|
-
Dictionary<string, string>
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
props["action"] = action;
|
|
97
|
-
|
|
98
|
-
TapOpenlogStoreBean bean = new TapOpenlogStoreBean(action, timestamp, tLogId, props);
|
|
99
|
-
|
|
100
|
-
log.Log("LogTechnology action = " + action, bean + "\n" + JsonConvert.SerializeObject(properties));
|
|
101
|
-
#if UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN
|
|
102
|
-
technologyQueue.Enqueue(bean);
|
|
103
|
-
#else
|
|
104
|
-
// log.Log($"This Platform 【{Application.platform}】 is not supported for Openlog.");
|
|
88
|
+
Dictionary<string, string> content = InflateDynamicProperties();
|
|
89
|
+
content[TapOpenlogParamConstants.PARAM_TAPSDK_PROJECT] = sdkProjectName;
|
|
90
|
+
content[TapOpenlogParamConstants.PARAM_TAPSDK_VERSION] = sdkProjectVersion;
|
|
91
|
+
content[TapOpenlogParamConstants.PARAM_ACTION] = action;
|
|
92
|
+
if (properties != null)
|
|
93
|
+
{
|
|
94
|
+
content["args"] = JsonConvert.SerializeObject(properties);
|
|
95
|
+
}
|
|
96
|
+
string propertiesStr = JsonConvert.SerializeObject(content);
|
|
97
|
+
TdkOpenLog("tapsdk-apm", propertiesStr);
|
|
105
98
|
#endif
|
|
106
99
|
}
|
|
107
100
|
|
|
101
|
+
private static void InitOpenlogStartParameter()
|
|
102
|
+
{
|
|
103
|
+
if (isRND)
|
|
104
|
+
{
|
|
105
|
+
openlogStartParameter[TapOpenlogStartParamConstants.PARAM_REGION] = 2;
|
|
106
|
+
}
|
|
107
|
+
else
|
|
108
|
+
{
|
|
109
|
+
openlogStartParameter[TapOpenlogStartParamConstants.PARAM_REGION] = TapCoreStandalone.coreOptions.region;
|
|
110
|
+
}
|
|
111
|
+
openlogStartParameter[TapOpenlogStartParamConstants.PARAM_LOG_TO_CONSOLE] = 1;
|
|
112
|
+
openlogStartParameter[TapOpenlogStartParamConstants.PARAM_LOG_LEVEL] = 1;
|
|
113
|
+
openlogStartParameter[TapOpenlogStartParamConstants.PARAM_DATA_DIR] = Path.Combine(Application.persistentDataPath, "OpenlogData");
|
|
114
|
+
openlogStartParameter[TapOpenlogStartParamConstants.PARAM_ENV] = "local";
|
|
115
|
+
openlogStartParameter[TapOpenlogStartParamConstants.PARAM_PLATFORM] = "PC";
|
|
116
|
+
openlogStartParameter[TapOpenlogStartParamConstants.PARAM_UA] = TapHttpUtils.GenerateUserAgent();
|
|
117
|
+
openlogStartParameter[TapOpenlogStartParamConstants.PARAM_CLIENT_ID] = TapCoreStandalone.coreOptions.clientId;
|
|
118
|
+
openlogStartParameter[TapOpenlogStartParamConstants.PARAM_CLIENT_TOKEN] = TapCoreStandalone.coreOptions.clientToken;
|
|
119
|
+
openlogStartParameter[TapOpenlogStartParamConstants.PARAM_COMMON] = generalParameter;
|
|
120
|
+
openlogStartParameter[TapOpenlogStartParamConstants.PARAM_APP_DURATION] = new Dictionary<string, string>()
|
|
121
|
+
{
|
|
122
|
+
{TapOpenlogParamConstants.PARAM_TAPSDK_VERSION, TapTapSDK.Version}
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
108
126
|
private static void InitGeneralParameter()
|
|
109
127
|
{
|
|
110
128
|
// 应用包名
|
|
@@ -115,12 +133,8 @@ namespace TapSDK.Core.Standalone.Internal.Openlog
|
|
|
115
133
|
generalParameter[TapOpenlogParamConstants.PARAM_APP_VERSION_CODE] = "";
|
|
116
134
|
// 固定一个枚举值: TapSDK
|
|
117
135
|
generalParameter[TapOpenlogParamConstants.PARAM_PN] = "TapSDK";
|
|
118
|
-
// SDK
|
|
119
|
-
generalParameter[TapOpenlogParamConstants.
|
|
120
|
-
// SDK 运行平台
|
|
121
|
-
generalParameter[TapOpenlogParamConstants.PARAM_PLATFORM] = "PC";
|
|
122
|
-
// 埋点版本号(预留字段),当前全为1
|
|
123
|
-
generalParameter[TapOpenlogParamConstants.PARAM_TRACK_CODE] = "1";
|
|
136
|
+
// SDK生成的设备唯一标识
|
|
137
|
+
generalParameter[TapOpenlogParamConstants.PARAM_DEVICE_ID] = SystemInfo.deviceUniqueIdentifier;
|
|
124
138
|
// SDK生成的设备一次安装的唯一标识
|
|
125
139
|
generalParameter[TapOpenlogParamConstants.PARAM_INSTALL_UUID] = Identity.InstallationId;
|
|
126
140
|
// 设备品牌,eg: Xiaomi
|
|
@@ -145,46 +159,34 @@ namespace TapSDK.Core.Standalone.Internal.Openlog
|
|
|
145
159
|
generalParameter[TapOpenlogParamConstants.PARAM_TOTAL_RAM] = DeviceInfo.RAM;
|
|
146
160
|
// 芯片型号,eg:Qualcomm Technologies, Inc SM7250
|
|
147
161
|
generalParameter[TapOpenlogParamConstants.PARAM_HARDWARE] = SystemInfo.processorType;
|
|
148
|
-
// SDK
|
|
149
|
-
generalParameter[TapOpenlogParamConstants.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
private void InflateGeneralProperties(Dictionary<string, string> props)
|
|
153
|
-
{
|
|
154
|
-
if (generalParameter != null)
|
|
155
|
-
{
|
|
156
|
-
foreach (KeyValuePair<string, string> kv in generalParameter)
|
|
157
|
-
{
|
|
158
|
-
props[kv.Key] = kv.Value;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
162
|
+
// SDK设置的地区,例如 zh_CN
|
|
163
|
+
generalParameter[TapOpenlogParamConstants.PARAM_SDK_LOCALE] = Tracker.getServerLanguage();
|
|
164
|
+
// taptap的用户ID的外显ID(加密)
|
|
165
|
+
generalParameter[TapOpenlogParamConstants.PARAM_OPEN_ID] = openid;
|
|
161
166
|
}
|
|
162
167
|
|
|
163
|
-
private
|
|
168
|
+
private static Dictionary<string, string> InflateDynamicProperties()
|
|
164
169
|
{
|
|
165
|
-
|
|
170
|
+
Dictionary<string, string> props = new Dictionary<string, string>();
|
|
166
171
|
// 客户端时区,eg:Asia/Shanghai
|
|
167
172
|
props[TapOpenlogParamConstants.PARAM_TIMEZONE] = "";
|
|
168
|
-
// SDK
|
|
169
|
-
props[TapOpenlogParamConstants.
|
|
170
|
-
// SDK 模块版本号
|
|
171
|
-
props[TapOpenlogParamConstants.PARAM_TAPSDK_VERSION] = sdkProjectVersion;
|
|
172
|
-
// SDK设置的地区,例如 zh_CN
|
|
173
|
-
props[TapOpenlogParamConstants.PARAM_SDK_LOCALE] = Tracker.getServerLanguage();
|
|
173
|
+
// SDK 产物类型
|
|
174
|
+
props[TapOpenlogParamConstants.PARAM_TAPSDK_ARTIFACT] = "Unity";
|
|
174
175
|
// 游戏账号 ID(非角色 ID)
|
|
175
|
-
props[TapOpenlogParamConstants.PARAM_GAME_USER_ID] = TapCoreStandalone.User.Id;
|
|
176
|
+
props[TapOpenlogParamConstants.PARAM_GAME_USER_ID] = TapCoreStandalone.User.Id ?? "";
|
|
177
|
+
// taptap的用户ID的外显ID(加密)
|
|
178
|
+
props[TapOpenlogParamConstants.PARAM_OPEN_ID] = openid ?? "";
|
|
176
179
|
// SDK生成的设备全局唯一标识
|
|
177
180
|
props[TapOpenlogParamConstants.PARAM_GID] = "";
|
|
178
|
-
// SDK生成的设备唯一标识
|
|
179
|
-
props[TapOpenlogParamConstants.PARAM_DEVICE_ID] = SystemInfo.deviceUniqueIdentifier;
|
|
180
181
|
// 设备可用存储空间(磁盘),单位B
|
|
181
182
|
props[TapOpenlogParamConstants.PARAM_ROM] = "0";
|
|
182
183
|
// 设备可用内存,单位B
|
|
183
184
|
props[TapOpenlogParamConstants.PARAM_RAM] = "0";
|
|
184
|
-
// taptap的用户ID的外显ID(加密)
|
|
185
|
-
props[TapOpenlogParamConstants.PARAM_OPEN_ID] = openid;
|
|
186
185
|
// 网络类型,eg:wifi, mobile
|
|
187
186
|
props[TapOpenlogParamConstants.PARAM_NETWORK_TYPE] = "";
|
|
187
|
+
// SDK设置的地区,例如 zh_CN
|
|
188
|
+
props[TapOpenlogParamConstants.PARAM_SDK_LOCALE] = Tracker.getServerLanguage();
|
|
189
|
+
return props;
|
|
188
190
|
}
|
|
189
191
|
}
|
|
190
192
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
namespace TapSDK.Core.Standalone.Internal.Openlog
|
|
2
|
+
{
|
|
3
|
+
internal class TapOpenlogStartParamConstants
|
|
4
|
+
{
|
|
5
|
+
public const string PARAM_REGION = "region";
|
|
6
|
+
public const string PARAM_LOG_TO_CONSOLE = "log_to_console";
|
|
7
|
+
public const string PARAM_LOG_LEVEL = "log_level";
|
|
8
|
+
public const string PARAM_DATA_DIR = "data_dir";
|
|
9
|
+
public const string PARAM_ENV = "env";
|
|
10
|
+
public const string PARAM_PLATFORM = "platform";
|
|
11
|
+
public const string PARAM_UA = "ua";
|
|
12
|
+
public const string PARAM_CLIENT_ID = "client_id";
|
|
13
|
+
public const string PARAM_CLIENT_TOKEN = "client_token";
|
|
14
|
+
public const string PARAM_MODULES = "modules";
|
|
15
|
+
|
|
16
|
+
// Common parameters
|
|
17
|
+
public const string PARAM_COMMON = "common";
|
|
18
|
+
|
|
19
|
+
// App duration parameters
|
|
20
|
+
public const string PARAM_APP_DURATION = "app_duration";
|
|
21
|
+
public const string PARAM_TAPSDK_VERSION = "tapsdk_version";
|
|
22
|
+
}
|
|
23
|
+
}
|