com.taptap.sdk.core 4.3.4 → 4.3.10-alpha.4
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 +2 -2
- package/Mobile/Runtime/IOSNativeWrapper.cs +3 -3
- package/Mobile/Runtime/TapCoreMobile.cs +5 -5
- package/Runtime/Internal/Init/IInitTask.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/Internal/Platform/ITapCorePlatform.cs +2 -2
- package/Runtime/Public/TapTapEvent.cs +1 -1
- package/Runtime/Public/TapTapSDK.cs +10 -7
- package/Runtime/Public/{TapTapSDKCoreOptions.cs → TapTapSdkOptions.cs} +2 -2
- 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 +164 -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 +6 -3
- package/package.json +1 -1
- /package/Runtime/Public/{TapTapSDKCoreOptions.cs.meta → TapTapSdkOptions.cs.meta} +0 -0
|
@@ -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] = "";
|
|
116
|
+
// 固定一个枚举值: TapSDK
|
|
117
|
+
generalParameter[TapOpenlogParamConstants.PARAM_PN] = "TapSDK";
|
|
118
|
+
// SDK 产物类型
|
|
119
|
+
generalParameter[TapOpenlogParamConstants.PARAM_TAPSDK_ARTIFACT] = "Unity";
|
|
120
|
+
// SDK 运行平台
|
|
121
|
+
generalParameter[TapOpenlogParamConstants.PARAM_PLATFORM] = "PC";
|
|
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] = "";
|
|
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
|