com.taptap.sdk.core 4.3.4 → 4.3.8-alpha.2
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/Mobile/Editor/NativeDependencies.xml +3 -3
- package/Mobile/Runtime/TapCoreMobile.cs +2 -2
- package/Runtime/Internal/Log/TapLog.cs +117 -0
- package/Runtime/Internal/Log/TapLog.cs.meta +11 -0
- package/Runtime/Internal/Log.meta +8 -0
- package/Runtime/Public/TapTapEvent.cs +1 -1
- package/Runtime/Public/TapTapSDK.cs +4 -1
- package/Standalone/Runtime/Internal/EventSender.cs +1 -1
- package/Standalone/Runtime/Internal/Http/NetUtils.cs +2 -2
- package/Standalone/Runtime/Internal/Openlog/Bean/TapOpenlogLogGroup.cs +39 -0
- package/Standalone/Runtime/Internal/Openlog/Bean/TapOpenlogLogGroup.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Openlog/Bean/TapOpenlogStoreBean.cs +33 -0
- package/Standalone/Runtime/Internal/Openlog/Bean/TapOpenlogStoreBean.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Openlog/Bean.meta +8 -0
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogHttpClient.cs +163 -0
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogHttpClient.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogParamConstants.cs +104 -0
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogParamConstants.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogQueueBase.cs +198 -0
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogQueueBase.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogQueueBusiness.cs +17 -0
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogQueueBusiness.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogQueueTechnology.cs +15 -0
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogQueueTechnology.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogStandalone.cs +190 -0
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogStandalone.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Openlog.meta +8 -0
- package/Standalone/Runtime/Internal/Tracker.cs +2 -2
- package/Standalone/Runtime/Internal/Utils/TapProtoBufffer.cs +28 -0
- package/Standalone/Runtime/Internal/Utils/TapProtoBufffer.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Utils.meta +8 -0
- package/Standalone/Runtime/Public/TapCoreStandalone.cs +3 -0
- package/link.xml +4 -0
- package/link.xml.meta +7 -0
- package/package.json +1 -1
|
@@ -5,17 +5,17 @@
|
|
|
5
5
|
<repositories>
|
|
6
6
|
<repository>https://repo.maven.apache.org/maven2</repository>
|
|
7
7
|
</repositories>
|
|
8
|
-
<androidPackage spec="com.taptap.sdk:tap-core-unity:4.3.
|
|
8
|
+
<androidPackage spec="com.taptap.sdk:tap-core-unity:4.3.8-alpha.11"/>
|
|
9
9
|
</androidPackages>
|
|
10
10
|
|
|
11
11
|
<!-- iOS Cocoapod dependencies can be specified by each iosPod element. -->
|
|
12
12
|
<iosPods>
|
|
13
13
|
<sources>
|
|
14
|
-
<source>
|
|
14
|
+
<source>git@git.gametaptap.com:ios/international/TapSDK4-iOS-podspecs.git</source>
|
|
15
15
|
</sources>
|
|
16
16
|
|
|
17
17
|
<iosPod name="Protobuf" version="~> 3.0" bitcodeEnabled="false" addToAllTargets="false"/>
|
|
18
|
-
<iosPod name="TapTapCoreSDK" version="~> 4.3.
|
|
18
|
+
<iosPod name="TapTapCoreSDK" version="~> 4.3.8-alpha.1" bitcodeEnabled="false" addToAllTargets="false"/>
|
|
19
19
|
|
|
20
20
|
</iosPods>
|
|
21
21
|
|
|
@@ -24,7 +24,7 @@ namespace TapSDK.Core.Mobile
|
|
|
24
24
|
public void Init(TapTapSDKCoreOptions coreOption, TapTapSDKBaseOption[] otherOptions)
|
|
25
25
|
{
|
|
26
26
|
Debug.Log("TapCoreMobile SDK inited");
|
|
27
|
-
SetPlatformAndVersion(TapTapSDK.SDKPlatform, TapTapSDK.
|
|
27
|
+
SetPlatformAndVersion(TapTapSDK.SDKPlatform, TapTapSDK.Version);
|
|
28
28
|
string coreOptionsJson = JsonUtility.ToJson(coreOption);
|
|
29
29
|
string[] otherOptionsJson = otherOptions.Select(option => JsonConvert.SerializeObject(option)).ToArray();
|
|
30
30
|
Bridge.CallHandler(EngineBridgeInitializer.GetBridgeServer()
|
|
@@ -40,7 +40,7 @@ namespace TapSDK.Core.Mobile
|
|
|
40
40
|
Bridge.CallHandler(EngineBridgeInitializer.GetBridgeServer()
|
|
41
41
|
.Method("setPlatformAndVersion")
|
|
42
42
|
.Args("platform", TapTapSDK.SDKPlatform)
|
|
43
|
-
.Args("version", TapTapSDK.
|
|
43
|
+
.Args("version", TapTapSDK.Version)
|
|
44
44
|
.CommandBuilder());
|
|
45
45
|
SetSDKArtifact("Unity");
|
|
46
46
|
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
using UnityEngine;
|
|
2
|
+
|
|
3
|
+
namespace TapSDK.Core.Internal.Log
|
|
4
|
+
{
|
|
5
|
+
public class TapLog
|
|
6
|
+
{
|
|
7
|
+
private const string TAG = "TapSDKUnity";
|
|
8
|
+
// 颜色常量
|
|
9
|
+
private const string InfoColor = "#FFFFFF"; // 白色
|
|
10
|
+
private const string WarningColor = "#FFFF00"; // 黄色
|
|
11
|
+
private const string ErrorColor = "#FF0000"; // 红色
|
|
12
|
+
private const string MainThreadColor = "#00FF00"; // 绿色
|
|
13
|
+
private const string IOThreadColor = "#FF00FF"; // 紫色
|
|
14
|
+
private const string TagColor = "#00FFFF"; // 青色
|
|
15
|
+
|
|
16
|
+
// 开关变量,控制是否启用日志输出
|
|
17
|
+
public static bool Enabled = false;
|
|
18
|
+
|
|
19
|
+
private string module;
|
|
20
|
+
private string tag;
|
|
21
|
+
|
|
22
|
+
public TapLog(string module, string tag = TAG)
|
|
23
|
+
{
|
|
24
|
+
this.tag = tag;
|
|
25
|
+
this.module = module;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public void Log(string message, string detail = null)
|
|
29
|
+
{
|
|
30
|
+
TapLog.Log(message, detail, tag, module);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// 输出带有自定义颜色和标签的警告
|
|
34
|
+
public void Warning(string message, string detail = null)
|
|
35
|
+
{
|
|
36
|
+
TapLog.Warning(message, detail, tag, module);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// 输出带有自定义颜色和标签的错误
|
|
40
|
+
public void Error(string message, string detail = null)
|
|
41
|
+
{
|
|
42
|
+
TapLog.Error(message, detail, tag, module);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// 输出带有自定义颜色和标签的普通日志
|
|
46
|
+
public static void Log(string message, string detail = null, string tag = TAG, string module = null)
|
|
47
|
+
{
|
|
48
|
+
if (Enabled)
|
|
49
|
+
{
|
|
50
|
+
Debug.Log(GetFormattedMessage(message: message, detail: detail, colorHex: InfoColor, tag: tag, module: module));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// 输出带有自定义颜色和标签的警告
|
|
55
|
+
public static void Warning(string message, string detail = null, string tag = TAG, string module = null)
|
|
56
|
+
{
|
|
57
|
+
if (Enabled)
|
|
58
|
+
{
|
|
59
|
+
Debug.LogWarning(GetFormattedMessage(message: message, detail: detail, colorHex: WarningColor, tag: tag, module: module));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// 输出带有自定义颜色和标签的错误
|
|
64
|
+
public static void Error(string message, string detail = null, string tag = TAG, string module = null)
|
|
65
|
+
{
|
|
66
|
+
if (Enabled)
|
|
67
|
+
{
|
|
68
|
+
Debug.LogError(GetFormattedMessage(message: message, detail: detail, colorHex: ErrorColor, tag: tag, module: module));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// 格式化带有颜色和标签的消息
|
|
73
|
+
private static string GetFormattedMessage(string message, string detail, string colorHex, string tag, string module)
|
|
74
|
+
{
|
|
75
|
+
string threadInfo = GetThreadInfo();
|
|
76
|
+
string tagColor = TagColor;
|
|
77
|
+
if (module != null && module != "")
|
|
78
|
+
{
|
|
79
|
+
tag = $"{tag}.{module}";
|
|
80
|
+
}
|
|
81
|
+
if (IsMobilePlatform())
|
|
82
|
+
{
|
|
83
|
+
return $"[{tag}] {threadInfo} {message}\n{detail}";
|
|
84
|
+
}
|
|
85
|
+
else
|
|
86
|
+
{
|
|
87
|
+
return $"<color={tagColor}>[{tag}]</color> {threadInfo} <color={colorHex}>{message}</color>\n{detail}\n";
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// 获取当前线程信息
|
|
93
|
+
private static string GetThreadInfo()
|
|
94
|
+
{
|
|
95
|
+
bool isMainThread = System.Threading.Thread.CurrentThread.IsAlive && System.Threading.Thread.CurrentThread.ManagedThreadId == 1;
|
|
96
|
+
string threadInfo = isMainThread ? "Main Thread" : $"IO Thread {System.Threading.Thread.CurrentThread.ManagedThreadId}";
|
|
97
|
+
|
|
98
|
+
if (IsMobilePlatform())
|
|
99
|
+
{
|
|
100
|
+
// 移动平台的线程信息不使用颜色
|
|
101
|
+
return $"({threadInfo})";
|
|
102
|
+
}
|
|
103
|
+
else
|
|
104
|
+
{
|
|
105
|
+
// 其他平台的线程信息使用颜色
|
|
106
|
+
string color = isMainThread ? MainThreadColor : IOThreadColor;
|
|
107
|
+
return $"<color={color}>({threadInfo})</color>";
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// 检查是否是移动平台
|
|
112
|
+
private static bool IsMobilePlatform()
|
|
113
|
+
{
|
|
114
|
+
return Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -81,7 +81,7 @@ namespace TapSDK.Core {
|
|
|
81
81
|
public static void ClearAllCommonProperties(){
|
|
82
82
|
platformWrapper?.ClearAllCommonProperties();
|
|
83
83
|
}
|
|
84
|
-
public static void
|
|
84
|
+
public static void LogPurchasedEvent(string orderID, string productName, long amount, string currencyType, string paymentMethod, string properties){
|
|
85
85
|
platformWrapper?.LogChargeEvent(orderID, productName, amount, currencyType, paymentMethod, properties);
|
|
86
86
|
}
|
|
87
87
|
|
|
@@ -7,10 +7,11 @@ using System.Collections.Generic;
|
|
|
7
7
|
using UnityEngine;
|
|
8
8
|
using System.Reflection;
|
|
9
9
|
using TapSDK.Core.Internal.Init;
|
|
10
|
+
using TapSDK.Core.Internal.Log;
|
|
10
11
|
|
|
11
12
|
namespace TapSDK.Core {
|
|
12
13
|
public class TapTapSDK {
|
|
13
|
-
public static readonly string
|
|
14
|
+
public static readonly string Version = "4.3.4";
|
|
14
15
|
public static readonly int SDKVersionCode = 32900001;
|
|
15
16
|
public static string SDKPlatform = "TapSDK-Unity";
|
|
16
17
|
|
|
@@ -37,6 +38,7 @@ namespace TapSDK.Core {
|
|
|
37
38
|
if (string.IsNullOrEmpty(coreOption.clientId))
|
|
38
39
|
throw new ArgumentException("[TapSDK] clientID is null or empty!");
|
|
39
40
|
TapTapSDK.tapTapSDKCoreOptions = coreOption;
|
|
41
|
+
TapLog.Enabled = coreOption.enableLog;
|
|
40
42
|
platformWrapper?.Init(coreOption);
|
|
41
43
|
// 初始化各个模块
|
|
42
44
|
|
|
@@ -61,6 +63,7 @@ namespace TapSDK.Core {
|
|
|
61
63
|
throw new ArgumentException("[TapSDK] clientID is null or empty!");
|
|
62
64
|
|
|
63
65
|
TapTapSDK.tapTapSDKCoreOptions = coreOption;
|
|
66
|
+
TapLog.Enabled = coreOption.enableLog;
|
|
64
67
|
platformWrapper?.Init(coreOption,otherOptions);
|
|
65
68
|
|
|
66
69
|
Type[] initTaskTypes = GetInitTypeList();
|
|
@@ -35,7 +35,7 @@ namespace TapSDK.Core.Standalone.Internal {
|
|
|
35
35
|
// 初始化 HttpClient
|
|
36
36
|
var header = new Dictionary<string, string>
|
|
37
37
|
{
|
|
38
|
-
{ "User-Agent", $"{TapTapSDK.SDKPlatform}/{TapTapSDK.
|
|
38
|
+
{ "User-Agent", $"{TapTapSDK.SDKPlatform}/{TapTapSDK.Version}" }
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
var coreOptions = TapCoreStandalone.coreOptions;
|
|
@@ -25,7 +25,7 @@ namespace TapSDK.Core.Standalone.Internal
|
|
|
25
25
|
public static Dictionary<string, string> commonHeaders {
|
|
26
26
|
get {
|
|
27
27
|
var headers = new Dictionary<string, string> {
|
|
28
|
-
{ "User-Agent", $"{TapTapSDK.SDKPlatform}/{TapTapSDK.
|
|
28
|
+
{ "User-Agent", $"{TapTapSDK.SDKPlatform}/{TapTapSDK.Version}" },
|
|
29
29
|
{ "X-Tap-Ts", TimeUtil.GetCurrentTime().ToString() },
|
|
30
30
|
{ "X-Tap-Nonce", NetUtils.GenerateNonce() },
|
|
31
31
|
{ "X-Tap-PN", "TapSDK" },
|
|
@@ -33,7 +33,7 @@ namespace TapSDK.Core.Standalone.Internal
|
|
|
33
33
|
{ "X-Tap-Device-Id", Identity.DeviceId },
|
|
34
34
|
{ "X-Tap-Platform", "PC" },
|
|
35
35
|
{ "X-Tap-SDK-Module", "TapSDKCore" },
|
|
36
|
-
{ "X-Tap-SDK-Module-Version", TapTapSDK.
|
|
36
|
+
{ "X-Tap-SDK-Module-Version", TapTapSDK.Version },
|
|
37
37
|
{ "X-Tap-SDK-Artifact", "Unity" }
|
|
38
38
|
};
|
|
39
39
|
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#if UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN
|
|
2
|
+
using Newtonsoft.Json;
|
|
3
|
+
using ProtoBuf;
|
|
4
|
+
using System.Collections.Generic;
|
|
5
|
+
|
|
6
|
+
namespace TapSDK.Core.Standalone.Internal
|
|
7
|
+
{
|
|
8
|
+
[ProtoContract]
|
|
9
|
+
public class LogContent
|
|
10
|
+
{
|
|
11
|
+
[JsonProperty("Key")]
|
|
12
|
+
[ProtoMember(1)]
|
|
13
|
+
public string Key { get; set; }
|
|
14
|
+
|
|
15
|
+
[JsonProperty("Value")]
|
|
16
|
+
[ProtoMember(2)]
|
|
17
|
+
public string Value { get; set; }
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
[ProtoContract]
|
|
21
|
+
public class Log
|
|
22
|
+
{
|
|
23
|
+
[JsonProperty("Value")]
|
|
24
|
+
[ProtoMember(1)]
|
|
25
|
+
public uint Time { get; set; }
|
|
26
|
+
[JsonProperty("Contents")]
|
|
27
|
+
[ProtoMember(2)]
|
|
28
|
+
public List<LogContent> Contents { get; set; }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
[ProtoContract]
|
|
32
|
+
public class LogGroup
|
|
33
|
+
{
|
|
34
|
+
[JsonProperty("Logs")]
|
|
35
|
+
[ProtoMember(1)]
|
|
36
|
+
public List<Log> Logs { get; set; }
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
#endif
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
using System.Collections.Generic;
|
|
2
|
+
using Newtonsoft.Json;
|
|
3
|
+
|
|
4
|
+
namespace TapSDK.Core.Standalone.Internal.Openlog
|
|
5
|
+
{
|
|
6
|
+
public class TapOpenlogStoreBean
|
|
7
|
+
{
|
|
8
|
+
[JsonProperty("action")]
|
|
9
|
+
public string action;
|
|
10
|
+
|
|
11
|
+
[JsonProperty("timestamp")]
|
|
12
|
+
public long timestamp;
|
|
13
|
+
|
|
14
|
+
[JsonProperty("t_log_id")]
|
|
15
|
+
public string tLogId;
|
|
16
|
+
|
|
17
|
+
[JsonProperty("props")]
|
|
18
|
+
public readonly Dictionary<string, string> props;
|
|
19
|
+
|
|
20
|
+
public TapOpenlogStoreBean(string action, long timestamp, string tLogId, Dictionary<string, string> props)
|
|
21
|
+
{
|
|
22
|
+
this.action = action;
|
|
23
|
+
this.timestamp = timestamp;
|
|
24
|
+
this.tLogId = tLogId;
|
|
25
|
+
this.props = props;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public override string ToString()
|
|
29
|
+
{
|
|
30
|
+
return $"TapOpenlogStoreBean(action: {action} , tLogId: {tLogId} , timestamp: {timestamp})";
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
#if UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN
|
|
2
|
+
using System;
|
|
3
|
+
using System.Threading.Tasks;
|
|
4
|
+
using System.Net;
|
|
5
|
+
using System.Net.Http;
|
|
6
|
+
using System.Net.Http.Headers;
|
|
7
|
+
using System.Linq;
|
|
8
|
+
using System.Security.Cryptography;
|
|
9
|
+
using System.Text;
|
|
10
|
+
using TapSDK.Core.Internal.Log;
|
|
11
|
+
using K4os.Compression.LZ4;
|
|
12
|
+
|
|
13
|
+
namespace TapSDK.Core.Standalone.Internal
|
|
14
|
+
{
|
|
15
|
+
public class TapOpenlogHttpClient
|
|
16
|
+
{
|
|
17
|
+
|
|
18
|
+
private const string HOST_CN = "openlog.xdrnd.cn";
|
|
19
|
+
private const string HOST_IO = "openlog.xdrnd.cn";
|
|
20
|
+
|
|
21
|
+
private string GetHost()
|
|
22
|
+
{
|
|
23
|
+
if (TapCoreStandalone.coreOptions.region == TapTapRegionType.CN)
|
|
24
|
+
{
|
|
25
|
+
return HOST_CN;
|
|
26
|
+
}
|
|
27
|
+
else if (TapCoreStandalone.coreOptions.region == TapTapRegionType.Overseas)
|
|
28
|
+
{
|
|
29
|
+
return HOST_IO;
|
|
30
|
+
}
|
|
31
|
+
else
|
|
32
|
+
{
|
|
33
|
+
return HOST_CN;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private static TapLog log = new TapLog(module: "Openlog.HttpClient");
|
|
38
|
+
|
|
39
|
+
private static System.Net.Http.HttpClient client;
|
|
40
|
+
|
|
41
|
+
public TapOpenlogHttpClient()
|
|
42
|
+
{
|
|
43
|
+
var ip = "http://172.26.200.194:8888";
|
|
44
|
+
ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) =>
|
|
45
|
+
{
|
|
46
|
+
return true;
|
|
47
|
+
};
|
|
48
|
+
HttpClientHandler clientHandler = new HttpClientHandler
|
|
49
|
+
{
|
|
50
|
+
Proxy = new WebProxy(ip)
|
|
51
|
+
};
|
|
52
|
+
client = new System.Net.Http.HttpClient(clientHandler);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public async Task<bool> Post(string path, byte[] content)
|
|
56
|
+
{
|
|
57
|
+
string url = BuildUrl(path);
|
|
58
|
+
var request = new HttpRequestMessage(HttpMethod.Post, url);
|
|
59
|
+
|
|
60
|
+
request.Headers.Add("User-Agent", "TapSDK-Unity/" + TapTapSDK.Version);
|
|
61
|
+
request.Headers.Add("Accept", "*/*");
|
|
62
|
+
request.Headers.Add("x-log-apiversion", "0.6.0");
|
|
63
|
+
request.Headers.Add("x-log-compresstype", "lz4");
|
|
64
|
+
request.Headers.Add("x-log-signaturemethod", "hmac-sha1");
|
|
65
|
+
request.Headers.Add("x-log-timestamp", DateTimeOffset.UtcNow.ToUnixTimeMilliseconds().ToString());
|
|
66
|
+
request.Headers.Add("x-log-bodyrawsize", content.Length.ToString());
|
|
67
|
+
|
|
68
|
+
byte[] compressContent = LZ4Compress(content);
|
|
69
|
+
// byte[] compressContent = content;
|
|
70
|
+
|
|
71
|
+
var contentMD5 = EncryptString(compressContent);
|
|
72
|
+
request.Headers.Add("x-content-md5", contentMD5);
|
|
73
|
+
|
|
74
|
+
string methodPart = request.Method.Method;
|
|
75
|
+
string urlPath = request.RequestUri.LocalPath;
|
|
76
|
+
string headersPart = GetHeadersPart(request.Headers);
|
|
77
|
+
string signParts = methodPart + "\n" + contentMD5 + "\n" + "application/x-protobuf" + "\n" + headersPart + "\n" + urlPath;
|
|
78
|
+
string sign;
|
|
79
|
+
using (var hmac = new HMACSHA1(Encoding.UTF8.GetBytes(TapCoreStandalone.coreOptions.clientToken)))
|
|
80
|
+
{
|
|
81
|
+
byte[] hash = hmac.ComputeHash(Encoding.UTF8.GetBytes(signParts));
|
|
82
|
+
sign = Convert.ToBase64String(hash);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
request.Headers.Add("Authorization", "LOG " + TapCoreStandalone.coreOptions.clientId + ":" + sign);
|
|
86
|
+
|
|
87
|
+
ByteArrayContent requestContent = new ByteArrayContent(compressContent);
|
|
88
|
+
requestContent.Headers.ContentType = new MediaTypeHeaderValue("application/x-protobuf");
|
|
89
|
+
request.Content = requestContent;
|
|
90
|
+
|
|
91
|
+
return await SendRequest(request);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
private static string EncryptString(byte[] str)
|
|
95
|
+
{
|
|
96
|
+
var md5 = MD5.Create();
|
|
97
|
+
byte[] byteOld = str;
|
|
98
|
+
byte[] byteNew = md5.ComputeHash(byteOld);
|
|
99
|
+
var sb = new StringBuilder();
|
|
100
|
+
foreach (byte b in byteNew)
|
|
101
|
+
{
|
|
102
|
+
sb.Append(b.ToString("X2"));
|
|
103
|
+
}
|
|
104
|
+
return sb.ToString();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
private static byte[] LZ4Compress(byte[] data)
|
|
108
|
+
{
|
|
109
|
+
int maxCompressedLength = LZ4Codec.MaximumOutputSize(data.Length);
|
|
110
|
+
byte[] compressedData = new byte[maxCompressedLength];
|
|
111
|
+
int compressedLength = LZ4Codec.Encode(data, 0, data.Length, compressedData, 0, compressedData.Length);
|
|
112
|
+
|
|
113
|
+
byte[] result = new byte[compressedLength];
|
|
114
|
+
Array.Copy(compressedData, result, compressedLength);
|
|
115
|
+
return result;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
private static string GetHeadersPart(HttpRequestHeaders headers)
|
|
119
|
+
{
|
|
120
|
+
var headerKeys = headers
|
|
121
|
+
.Where(h => h.Key.StartsWith("x-log-", StringComparison.OrdinalIgnoreCase))
|
|
122
|
+
.OrderBy(h => h.Key.ToLowerInvariant())
|
|
123
|
+
.Select(h => $"{h.Key.ToLowerInvariant()}:{string.Join(",", h.Value)}")
|
|
124
|
+
.ToList();
|
|
125
|
+
|
|
126
|
+
return string.Join("\n", headerKeys);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
private async Task<bool> SendRequest(HttpRequestMessage request)
|
|
130
|
+
{
|
|
131
|
+
HttpResponseMessage response;
|
|
132
|
+
try
|
|
133
|
+
{
|
|
134
|
+
response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);
|
|
135
|
+
request.Dispose();
|
|
136
|
+
}
|
|
137
|
+
catch (HttpRequestException e)
|
|
138
|
+
{
|
|
139
|
+
log.Warning($"Request error", e.ToString());
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (response.IsSuccessStatusCode || (response.StatusCode >= HttpStatusCode.BadRequest && response.StatusCode < HttpStatusCode.InternalServerError))
|
|
144
|
+
{
|
|
145
|
+
response.Dispose();
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
else
|
|
149
|
+
{
|
|
150
|
+
log.Warning($"SendOpenlog failed", response.StatusCode.ToString());
|
|
151
|
+
response.Dispose();
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
private string BuildUrl(string path)
|
|
157
|
+
{
|
|
158
|
+
string url = $"https://{GetHost()}/{path}?client_id={TapCoreStandalone.coreOptions.clientId}";
|
|
159
|
+
return url;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
#endif
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
namespace TapSDK.Core.Standalone.Internal.Openlog
|
|
2
|
+
{
|
|
3
|
+
internal class TapOpenlogParamConstants
|
|
4
|
+
{
|
|
5
|
+
// 该条日志的唯一标识 d
|
|
6
|
+
public const string PARAM_T_LOG_ID = "t_log_id";
|
|
7
|
+
|
|
8
|
+
// 客户端时区,eg:Asia/Shanghai d
|
|
9
|
+
public const string PARAM_TIMEZONE = "timezone";
|
|
10
|
+
|
|
11
|
+
// 客户端生成的时间戳,毫秒级 d
|
|
12
|
+
public const string PARAM_TIMESTAMP = "timestamp";
|
|
13
|
+
|
|
14
|
+
// 应用包名 g
|
|
15
|
+
public const string PARAM_APP_PACKAGE_NAME = "app_package_name";
|
|
16
|
+
|
|
17
|
+
// 应用版本字符串 g
|
|
18
|
+
public const string PARAM_APP_VERSION = "app_version";
|
|
19
|
+
|
|
20
|
+
// 应用版本(数字) g
|
|
21
|
+
public const string PARAM_APP_VERSION_CODE = "app_version_code";
|
|
22
|
+
|
|
23
|
+
// 固定一个枚举值: TapSDK g
|
|
24
|
+
public const string PARAM_PN = "pn";
|
|
25
|
+
|
|
26
|
+
// SDK接入项目具体模块枚举值 d
|
|
27
|
+
public const string PARAM_TAPSDK_PROJECT = "tapsdk_project";
|
|
28
|
+
|
|
29
|
+
// SDK 模块版本号 d
|
|
30
|
+
public const string PARAM_TAPSDK_VERSION = "tapsdk_version";
|
|
31
|
+
|
|
32
|
+
// SDK 产物类型 d
|
|
33
|
+
public const string PARAM_TAPSDK_ARTIFACT = "tapsdk_artifact";
|
|
34
|
+
|
|
35
|
+
// SDK 运行平台 g
|
|
36
|
+
public const string PARAM_PLATFORM = "platform";
|
|
37
|
+
|
|
38
|
+
// 埋点版本号(预留字段),当前全为1 g
|
|
39
|
+
public const string PARAM_TRACK_CODE = "track_code";
|
|
40
|
+
|
|
41
|
+
// SDK设置的地区,例如 zh_CN d
|
|
42
|
+
public const string PARAM_SDK_LOCALE = "sdk_locale";
|
|
43
|
+
|
|
44
|
+
// 游戏账号 ID(非角色 ID)d
|
|
45
|
+
public const string PARAM_GAME_USER_ID = "game_user_id";
|
|
46
|
+
|
|
47
|
+
// SDK生成的设备全局唯一标识 d
|
|
48
|
+
public const string PARAM_GID = "gid";
|
|
49
|
+
|
|
50
|
+
// SDK生成的设备唯一标识 d
|
|
51
|
+
public const string PARAM_DEVICE_ID = "device_id";
|
|
52
|
+
|
|
53
|
+
// SDK生成的设备一次安装的唯一标识 d
|
|
54
|
+
public const string PARAM_INSTALL_UUID = "install_uuid";
|
|
55
|
+
|
|
56
|
+
// 设备品牌,eg: Xiaomi d
|
|
57
|
+
public const string PARAM_DV = "dv";
|
|
58
|
+
|
|
59
|
+
// 设备品牌型号,eg:21051182C d
|
|
60
|
+
public const string PARAM_MD = "md";
|
|
61
|
+
|
|
62
|
+
// 设备CPU型号,eg:arm64-v8a d
|
|
63
|
+
public const string PARAM_CPU = "cpu";
|
|
64
|
+
|
|
65
|
+
// 支持 CPU 架构,eg:arm64-v8a d
|
|
66
|
+
public const string PARAM_CPU_ABIS = "cpu_abis";
|
|
67
|
+
|
|
68
|
+
// 设备操作系统 d
|
|
69
|
+
public const string PARAM_OS = "os";
|
|
70
|
+
|
|
71
|
+
// 设备操作系统版本 d
|
|
72
|
+
public const string PARAM_SV = "sv";
|
|
73
|
+
|
|
74
|
+
// 物理设备真实屏幕分辨率宽 g
|
|
75
|
+
public const string PARAM_WIDTH = "width";
|
|
76
|
+
|
|
77
|
+
// 物理设备真实屏幕分辨率高 g
|
|
78
|
+
public const string PARAM_HEIGHT = "height";
|
|
79
|
+
|
|
80
|
+
// 设备可用存储空间(磁盘),单位B d
|
|
81
|
+
public const string PARAM_ROM = "rom";
|
|
82
|
+
|
|
83
|
+
// 设备可用内存,单位B d
|
|
84
|
+
public const string PARAM_RAM = "ram";
|
|
85
|
+
|
|
86
|
+
// 设备总存储空间(磁盘),单位B g
|
|
87
|
+
public const string PARAM_TOTAL_ROM = "total_rom";
|
|
88
|
+
|
|
89
|
+
// 设备总内存,单位B g
|
|
90
|
+
public const string PARAM_TOTAL_RAM = "total_ram";
|
|
91
|
+
|
|
92
|
+
// 芯片型号,eg:Qualcomm Technologies, Inc SM7250 g
|
|
93
|
+
public const string PARAM_HARDWARE = "hardware";
|
|
94
|
+
|
|
95
|
+
// taptap的用户ID的外显ID(加密)d
|
|
96
|
+
public const string PARAM_OPEN_ID = "open_id";
|
|
97
|
+
|
|
98
|
+
// 网络类型,eg:wifi, mobile
|
|
99
|
+
public const string PARAM_NETWORK_TYPE = "network_type";
|
|
100
|
+
|
|
101
|
+
// SDK进程粒度的本地日志 session_id
|
|
102
|
+
public const string PARAM_P_SESSION_ID = "p_session_id";
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
|
|
2
|
+
#if UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN
|
|
3
|
+
using System;
|
|
4
|
+
using System.Collections.Generic;
|
|
5
|
+
using System.IO;
|
|
6
|
+
using System.Linq;
|
|
7
|
+
using System.Threading;
|
|
8
|
+
using TapSDK.Core.Internal.Log;
|
|
9
|
+
using UnityEngine;
|
|
10
|
+
using Newtonsoft.Json;
|
|
11
|
+
using TapSDK.Core.Standalone.Internal.Openlog;
|
|
12
|
+
using ProtoBuf;
|
|
13
|
+
|
|
14
|
+
namespace TapSDK.Core.Standalone.Internal
|
|
15
|
+
{
|
|
16
|
+
public abstract class TapOpenlogQueueBase
|
|
17
|
+
{
|
|
18
|
+
private TapLog log;
|
|
19
|
+
private string module;
|
|
20
|
+
private string persistentDataPath = Application.persistentDataPath;
|
|
21
|
+
private Queue<TapOpenlogStoreBean> queue = new Queue<TapOpenlogStoreBean>();
|
|
22
|
+
private TapOpenlogHttpClient httpClient = new TapOpenlogHttpClient();
|
|
23
|
+
private const int MaxEvents = 50;
|
|
24
|
+
private const int MaxBatchSize = 200;
|
|
25
|
+
private const float SendInterval = 15;
|
|
26
|
+
private Timer timer;
|
|
27
|
+
private int queueCount => queue.Count;
|
|
28
|
+
|
|
29
|
+
protected abstract string GetUrlPath();
|
|
30
|
+
protected abstract string GetEventFilePath();
|
|
31
|
+
|
|
32
|
+
public TapOpenlogQueueBase(string module)
|
|
33
|
+
{
|
|
34
|
+
this.module = module;
|
|
35
|
+
log = new TapLog(module: "Openlog." + module);
|
|
36
|
+
// 加载未发送的事件
|
|
37
|
+
LoadStorageLogs();
|
|
38
|
+
SendEventsAsync();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public void Enqueue(TapOpenlogStoreBean bean)
|
|
42
|
+
{
|
|
43
|
+
// 将事件添加到队列
|
|
44
|
+
queue.Enqueue(bean);
|
|
45
|
+
SaveEvents();
|
|
46
|
+
|
|
47
|
+
// 检查队列大小
|
|
48
|
+
if (queueCount >= MaxEvents)
|
|
49
|
+
{
|
|
50
|
+
log.Log("队列大小超过最大值 = " + queueCount);
|
|
51
|
+
SendEventsAsync();
|
|
52
|
+
log.Log("队列大小超过最大值 end");
|
|
53
|
+
}
|
|
54
|
+
else
|
|
55
|
+
{
|
|
56
|
+
ResetTimer();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public async void SendEventsAsync()
|
|
61
|
+
{
|
|
62
|
+
if (queueCount == 0)
|
|
63
|
+
{
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
var eventsToSend = new List<TapOpenlogStoreBean>();
|
|
67
|
+
LogGroup logGroup = new LogGroup();
|
|
68
|
+
logGroup.Logs = new List<Log>();
|
|
69
|
+
for (int i = 0; i < MaxBatchSize && queueCount > 0; i++)
|
|
70
|
+
{
|
|
71
|
+
TapOpenlogStoreBean bean = queue.Dequeue();
|
|
72
|
+
eventsToSend.Add(bean);
|
|
73
|
+
|
|
74
|
+
Log log = new Log();
|
|
75
|
+
log.Time = (uint)(bean.timestamp / 1000);
|
|
76
|
+
log.Contents = new List<LogContent>();
|
|
77
|
+
foreach (var kvp in bean.props)
|
|
78
|
+
{
|
|
79
|
+
LogContent logContent = new LogContent
|
|
80
|
+
{
|
|
81
|
+
Key = kvp.Key ?? "",
|
|
82
|
+
Value = kvp.Value ?? ""
|
|
83
|
+
};
|
|
84
|
+
log.Contents.Add(logContent);
|
|
85
|
+
}
|
|
86
|
+
logGroup.Logs.Add(log);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
byte[] bytes;
|
|
90
|
+
using (var stream = new MemoryStream())
|
|
91
|
+
{
|
|
92
|
+
Serializer.Serialize(stream, logGroup);
|
|
93
|
+
bytes = stream.ToArray();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
var result = await httpClient.Post(GetUrlPath(), content: bytes);
|
|
97
|
+
if (!result)
|
|
98
|
+
{
|
|
99
|
+
foreach (var eventParams in eventsToSend)
|
|
100
|
+
{
|
|
101
|
+
queue.Enqueue(eventParams);
|
|
102
|
+
}
|
|
103
|
+
SaveEvents();
|
|
104
|
+
}
|
|
105
|
+
else
|
|
106
|
+
{
|
|
107
|
+
log.Log("SendEvents success", JsonConvert.SerializeObject(logGroup));
|
|
108
|
+
SaveEvents();
|
|
109
|
+
if (queueCount > MaxEvents)
|
|
110
|
+
{
|
|
111
|
+
SendEventsAsync();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
private void OnTimerElapsed(object state)
|
|
118
|
+
{
|
|
119
|
+
timer.Dispose();
|
|
120
|
+
timer = null;
|
|
121
|
+
SendEventsAsync();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
private void ResetTimer()
|
|
125
|
+
{
|
|
126
|
+
if (timer == null)
|
|
127
|
+
{
|
|
128
|
+
// 设置计时器,15秒后触发一次
|
|
129
|
+
timer = new Timer(OnTimerElapsed, null, TimeSpan.FromSeconds(SendInterval), Timeout.InfiniteTimeSpan);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
private void LoadStorageLogs()
|
|
134
|
+
{
|
|
135
|
+
string filePath = Path.Combine(persistentDataPath, GetEventFilePath());
|
|
136
|
+
if (File.Exists(filePath))
|
|
137
|
+
{
|
|
138
|
+
string jsonData = File.ReadAllText(filePath);
|
|
139
|
+
if (string.IsNullOrEmpty(jsonData))
|
|
140
|
+
{
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
List<TapOpenlogStoreBean> deserializedData;
|
|
144
|
+
try
|
|
145
|
+
{
|
|
146
|
+
deserializedData = JsonConvert.DeserializeObject<List<TapOpenlogStoreBean>>(jsonData);
|
|
147
|
+
}
|
|
148
|
+
catch (Exception ex)
|
|
149
|
+
{
|
|
150
|
+
log.Warning($"LoadLogs( FileName : {GetEventFilePath()} ) Exception", ex.ToString());
|
|
151
|
+
File.Delete(filePath);
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (deserializedData != null && deserializedData.Count > 0)
|
|
155
|
+
{
|
|
156
|
+
foreach (var item in deserializedData)
|
|
157
|
+
{
|
|
158
|
+
queue.Enqueue(item);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
log.Log("LoadStorageLogs end, count = " + queue.Count, JsonConvert.SerializeObject(queue.ToList()));
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
private void SaveEvents()
|
|
166
|
+
{
|
|
167
|
+
try
|
|
168
|
+
{
|
|
169
|
+
if (queue == null)
|
|
170
|
+
{
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
var eventList = queue.ToList();
|
|
175
|
+
string jsonData = JsonConvert.SerializeObject(eventList);
|
|
176
|
+
|
|
177
|
+
if (string.IsNullOrEmpty(GetEventFilePath()))
|
|
178
|
+
{
|
|
179
|
+
log.Log("EventFilePath is null or empty");
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
string filePath = Path.Combine(persistentDataPath, GetEventFilePath());
|
|
184
|
+
if (string.IsNullOrEmpty(filePath))
|
|
185
|
+
{
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
File.WriteAllText(filePath, jsonData);
|
|
190
|
+
}
|
|
191
|
+
catch (Exception ex)
|
|
192
|
+
{
|
|
193
|
+
log.Warning("SaveEvents Exception" + ex.Message);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
#endif
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#if UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN
|
|
2
|
+
namespace TapSDK.Core.Standalone.Internal
|
|
3
|
+
{
|
|
4
|
+
public class TapOpenlogQueueBusiness : TapOpenlogQueueBase
|
|
5
|
+
{
|
|
6
|
+
private const string eventFilePath = "TapLogBusiness";
|
|
7
|
+
private const string urlPath = "putrecords/tds/tapsdk";
|
|
8
|
+
|
|
9
|
+
public TapOpenlogQueueBusiness() : base("Business")
|
|
10
|
+
{
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
protected override string GetEventFilePath() => eventFilePath;
|
|
14
|
+
protected override string GetUrlPath() => urlPath;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
#endif
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#if UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN
|
|
2
|
+
namespace TapSDK.Core.Standalone.Internal
|
|
3
|
+
{
|
|
4
|
+
public class TapOpenlogQueueTechnology : TapOpenlogQueueBase
|
|
5
|
+
{
|
|
6
|
+
private const string eventFilePath = "TapLogTechnology";
|
|
7
|
+
private const string urlPath = "putrecords/tds/tapsdk-apm";
|
|
8
|
+
public TapOpenlogQueueTechnology() : base("Technology")
|
|
9
|
+
{
|
|
10
|
+
}
|
|
11
|
+
protected override string GetEventFilePath() => eventFilePath;
|
|
12
|
+
protected override string GetUrlPath() => urlPath;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
#endif
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
|
|
2
|
+
using System;
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
using Newtonsoft.Json;
|
|
5
|
+
using TapSDK.Core.Internal.Log;
|
|
6
|
+
using UnityEngine;
|
|
7
|
+
|
|
8
|
+
namespace TapSDK.Core.Standalone.Internal.Openlog
|
|
9
|
+
{
|
|
10
|
+
public class TapOpenlogStandalone
|
|
11
|
+
{
|
|
12
|
+
public static string openid = "";
|
|
13
|
+
|
|
14
|
+
private static Dictionary<string, string> generalParameter = new Dictionary<string, string>();
|
|
15
|
+
private static string sessionID = Guid.NewGuid().ToString();
|
|
16
|
+
#if UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN
|
|
17
|
+
private static TapOpenlogQueueBusiness businessQueue;
|
|
18
|
+
private static TapOpenlogQueueTechnology technologyQueue;
|
|
19
|
+
#endif
|
|
20
|
+
private string sdkProjectName;
|
|
21
|
+
private string sdkProjectVersion;
|
|
22
|
+
|
|
23
|
+
private static TapLog log = new TapLog(module: "Openlog");
|
|
24
|
+
public static void Init()
|
|
25
|
+
{
|
|
26
|
+
#if UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN
|
|
27
|
+
businessQueue = new TapOpenlogQueueBusiness();
|
|
28
|
+
technologyQueue = new TapOpenlogQueueTechnology();
|
|
29
|
+
#endif
|
|
30
|
+
InitGeneralParameter();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public TapOpenlogStandalone(string sdkProjectName, string sdkProjectVersion)
|
|
34
|
+
{
|
|
35
|
+
this.sdkProjectName = sdkProjectName;
|
|
36
|
+
this.sdkProjectVersion = sdkProjectVersion;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public void LogBusiness(
|
|
40
|
+
string action,
|
|
41
|
+
Dictionary<string, string> properties = null
|
|
42
|
+
)
|
|
43
|
+
{
|
|
44
|
+
long timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
45
|
+
string tLogId = Guid.NewGuid().ToString();
|
|
46
|
+
|
|
47
|
+
if (properties == null)
|
|
48
|
+
{
|
|
49
|
+
properties = new Dictionary<string, string>();
|
|
50
|
+
}
|
|
51
|
+
Dictionary<string, string> props = new Dictionary<string, string>(properties);
|
|
52
|
+
// generalProperties
|
|
53
|
+
InflateGeneralProperties(props);
|
|
54
|
+
// dynamicProperties
|
|
55
|
+
InflateDynamicProperties(props);
|
|
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.");
|
|
70
|
+
#endif
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public void LogTechnology(
|
|
74
|
+
string action,
|
|
75
|
+
Dictionary<string, string> properties = null
|
|
76
|
+
)
|
|
77
|
+
{
|
|
78
|
+
long timestamp = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
79
|
+
string tLogId = Guid.NewGuid().ToString();
|
|
80
|
+
|
|
81
|
+
if (properties == null)
|
|
82
|
+
{
|
|
83
|
+
properties = new Dictionary<string, string>();
|
|
84
|
+
}
|
|
85
|
+
Dictionary<string, string> props = new Dictionary<string, string>(properties);
|
|
86
|
+
// generalProperties
|
|
87
|
+
InflateGeneralProperties(props);
|
|
88
|
+
// dynamicProperties
|
|
89
|
+
InflateDynamicProperties(props);
|
|
90
|
+
|
|
91
|
+
// 该条日志的唯一标识
|
|
92
|
+
props[TapOpenlogParamConstants.PARAM_T_LOG_ID] = tLogId;
|
|
93
|
+
// 客户端生成的时间戳,毫秒级
|
|
94
|
+
props[TapOpenlogParamConstants.PARAM_TIMESTAMP] = timestamp.ToString();
|
|
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.");
|
|
105
|
+
#endif
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
private static void InitGeneralParameter()
|
|
109
|
+
{
|
|
110
|
+
// 应用包名
|
|
111
|
+
generalParameter[TapOpenlogParamConstants.PARAM_APP_PACKAGE_NAME] = Application.identifier;
|
|
112
|
+
// 应用版本字符串
|
|
113
|
+
generalParameter[TapOpenlogParamConstants.PARAM_APP_VERSION] = Application.version;
|
|
114
|
+
// 应用版本(数字)
|
|
115
|
+
generalParameter[TapOpenlogParamConstants.PARAM_APP_VERSION_CODE] = Application.buildGUID.ToString();
|
|
116
|
+
// 固定一个枚举值: TapSDK
|
|
117
|
+
generalParameter[TapOpenlogParamConstants.PARAM_PN] = "TapSDK";
|
|
118
|
+
// SDK 产物类型
|
|
119
|
+
generalParameter[TapOpenlogParamConstants.PARAM_TAPSDK_ARTIFACT] = "Unity";
|
|
120
|
+
// SDK 运行平台
|
|
121
|
+
generalParameter[TapOpenlogParamConstants.PARAM_PLATFORM] = Application.platform.ToString();
|
|
122
|
+
// 埋点版本号(预留字段),当前全为1
|
|
123
|
+
generalParameter[TapOpenlogParamConstants.PARAM_TRACK_CODE] = "1";
|
|
124
|
+
// SDK生成的设备一次安装的唯一标识
|
|
125
|
+
generalParameter[TapOpenlogParamConstants.PARAM_INSTALL_UUID] = Identity.InstallationId;
|
|
126
|
+
// 设备品牌,eg: Xiaomi
|
|
127
|
+
generalParameter[TapOpenlogParamConstants.PARAM_DV] = "";
|
|
128
|
+
// 设备品牌型号,eg:21051182C
|
|
129
|
+
generalParameter[TapOpenlogParamConstants.PARAM_MD] = SystemInfo.deviceModel;
|
|
130
|
+
// 设备CPU型号,eg:arm64-v8a
|
|
131
|
+
generalParameter[TapOpenlogParamConstants.PARAM_CPU] = "";
|
|
132
|
+
// 支持 CPU 架构,eg:arm64-v8a
|
|
133
|
+
generalParameter[TapOpenlogParamConstants.PARAM_CPU_ABIS] = "";
|
|
134
|
+
// 设备操作系统
|
|
135
|
+
generalParameter[TapOpenlogParamConstants.PARAM_OS] = SystemInfo.operatingSystemFamily.ToString();
|
|
136
|
+
// 设备操作系统版本
|
|
137
|
+
generalParameter[TapOpenlogParamConstants.PARAM_SV] = SystemInfo.operatingSystem;
|
|
138
|
+
// 物理设备真实屏幕分辨率宽
|
|
139
|
+
generalParameter[TapOpenlogParamConstants.PARAM_WIDTH] = Screen.currentResolution.width.ToString();
|
|
140
|
+
// 物理设备真实屏幕分辨率高
|
|
141
|
+
generalParameter[TapOpenlogParamConstants.PARAM_HEIGHT] = Screen.currentResolution.height.ToString();
|
|
142
|
+
// 设备总存储空间(磁盘),单位B
|
|
143
|
+
generalParameter[TapOpenlogParamConstants.PARAM_TOTAL_ROM] = "";
|
|
144
|
+
// 设备总内存,单位B
|
|
145
|
+
generalParameter[TapOpenlogParamConstants.PARAM_TOTAL_RAM] = DeviceInfo.RAM;
|
|
146
|
+
// 芯片型号,eg:Qualcomm Technologies, Inc SM7250
|
|
147
|
+
generalParameter[TapOpenlogParamConstants.PARAM_HARDWARE] = SystemInfo.processorType;
|
|
148
|
+
// SDK进程粒度的本地日志 session_id
|
|
149
|
+
generalParameter[TapOpenlogParamConstants.PARAM_P_SESSION_ID] = sessionID;
|
|
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
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
private void InflateDynamicProperties(Dictionary<string, string> props)
|
|
164
|
+
{
|
|
165
|
+
|
|
166
|
+
// 客户端时区,eg:Asia/Shanghai
|
|
167
|
+
props[TapOpenlogParamConstants.PARAM_TIMEZONE] = TimeZoneInfo.Local.Id;
|
|
168
|
+
// SDK接入项目具体模块枚举值
|
|
169
|
+
props[TapOpenlogParamConstants.PARAM_TAPSDK_PROJECT] = sdkProjectName;
|
|
170
|
+
// SDK 模块版本号
|
|
171
|
+
props[TapOpenlogParamConstants.PARAM_TAPSDK_VERSION] = sdkProjectVersion;
|
|
172
|
+
// SDK设置的地区,例如 zh_CN
|
|
173
|
+
props[TapOpenlogParamConstants.PARAM_SDK_LOCALE] = Tracker.getServerLanguage();
|
|
174
|
+
// 游戏账号 ID(非角色 ID)
|
|
175
|
+
props[TapOpenlogParamConstants.PARAM_GAME_USER_ID] = TapCoreStandalone.User.Id;
|
|
176
|
+
// SDK生成的设备全局唯一标识
|
|
177
|
+
props[TapOpenlogParamConstants.PARAM_GID] = "";
|
|
178
|
+
// SDK生成的设备唯一标识
|
|
179
|
+
props[TapOpenlogParamConstants.PARAM_DEVICE_ID] = SystemInfo.deviceUniqueIdentifier;
|
|
180
|
+
// 设备可用存储空间(磁盘),单位B
|
|
181
|
+
props[TapOpenlogParamConstants.PARAM_ROM] = "0";
|
|
182
|
+
// 设备可用内存,单位B
|
|
183
|
+
props[TapOpenlogParamConstants.PARAM_RAM] = "0";
|
|
184
|
+
// taptap的用户ID的外显ID(加密)
|
|
185
|
+
props[TapOpenlogParamConstants.PARAM_OPEN_ID] = openid;
|
|
186
|
+
// 网络类型,eg:wifi, mobile
|
|
187
|
+
props[TapOpenlogParamConstants.PARAM_NETWORK_TYPE] = "";
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
@@ -187,7 +187,7 @@ namespace TapSDK.Core.Standalone.Internal {
|
|
|
187
187
|
if (properties == null) {
|
|
188
188
|
properties = new Dictionary<string, object>();
|
|
189
189
|
}
|
|
190
|
-
properties["sdk_version"] = TapTapSDK.
|
|
190
|
+
properties["sdk_version"] = TapTapSDK.Version;
|
|
191
191
|
|
|
192
192
|
Dictionary<string, object> data = new Dictionary<string, object>(basicProps) {
|
|
193
193
|
{ "client_id", TapCoreStandalone.coreOptions.clientId },
|
|
@@ -216,7 +216,7 @@ namespace TapSDK.Core.Standalone.Internal {
|
|
|
216
216
|
{ "height", Screen.currentResolution.height },
|
|
217
217
|
{ "provider", "unknown" },
|
|
218
218
|
{ "app_version", TapCoreStandalone.coreOptions.gameVersion ?? Application.version },
|
|
219
|
-
{ "sdk_version", TapTapSDK.
|
|
219
|
+
{ "sdk_version", TapTapSDK.Version },
|
|
220
220
|
{ "network_type", Network },
|
|
221
221
|
{ "channel", TapCoreStandalone.coreOptions.channel },
|
|
222
222
|
{ "mac_list", macList },
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// #if UNITY_EDITOR || (!UNITY_ANDROID && !UNITY_IOS)
|
|
2
|
+
// using Google.Protobuf;
|
|
3
|
+
|
|
4
|
+
// namespace TapSDK.Core.Standalone.Internal.Utils
|
|
5
|
+
// {
|
|
6
|
+
|
|
7
|
+
// public class TapProtoBufffer
|
|
8
|
+
// {
|
|
9
|
+
// public static byte[] Serialize(IMessage message)
|
|
10
|
+
// {
|
|
11
|
+
// return message.ToByteArray();
|
|
12
|
+
// }
|
|
13
|
+
|
|
14
|
+
// public static T DeSerialize<T>(byte[] packet) where T : IMessage, new()
|
|
15
|
+
// {
|
|
16
|
+
// IMessage message = new T();
|
|
17
|
+
// try
|
|
18
|
+
// {
|
|
19
|
+
// return (T)message.Descriptor.Parser.ParseFrom(packet);
|
|
20
|
+
// }
|
|
21
|
+
// catch (System.Exception e)
|
|
22
|
+
// {
|
|
23
|
+
// throw;
|
|
24
|
+
// }
|
|
25
|
+
// }
|
|
26
|
+
// }
|
|
27
|
+
// }
|
|
28
|
+
// #endif
|
|
@@ -5,6 +5,7 @@ using System.Collections.Generic;
|
|
|
5
5
|
using UnityEditor;
|
|
6
6
|
using System.IO;
|
|
7
7
|
using TapSDK.Core.Internal.Utils;
|
|
8
|
+
using TapSDK.Core.Standalone.Internal.Openlog;
|
|
8
9
|
|
|
9
10
|
namespace TapSDK.Core.Standalone
|
|
10
11
|
{
|
|
@@ -79,6 +80,8 @@ namespace TapSDK.Core.Standalone
|
|
|
79
80
|
|
|
80
81
|
Tracker.Init();
|
|
81
82
|
|
|
83
|
+
TapOpenlogStandalone.Init();
|
|
84
|
+
|
|
82
85
|
requestClientSetting();
|
|
83
86
|
}
|
|
84
87
|
|
package/link.xml
ADDED
package/link.xml.meta
ADDED