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.
Files changed (44) hide show
  1. package/Editor/TapSDKCoreCompile.cs +6 -0
  2. package/Mobile/Editor/NativeDependencies.xml +2 -3
  3. package/Mobile/Runtime/TapEventMobile.cs +0 -1
  4. package/{Standalone/Runtime/Internal/Openlog/Bean.meta → Plugins.meta} +1 -1
  5. package/Resources/TapMessage.prefab +1 -1
  6. package/Runtime/Internal/Log/TapLog.cs +1 -1
  7. package/Runtime/Public/TapTapSDK.cs +12 -3
  8. package/Runtime/Public/TapTapSdkOptions.cs +0 -4
  9. package/Standalone/Plugins/macOS/libtapsdkcorecpp.dylib +0 -0
  10. package/Standalone/Plugins/macOS/libtapsdkcorecpp.dylib.meta +80 -0
  11. package/Standalone/Plugins/x86/tapsdkcore.dll +0 -0
  12. package/Standalone/Plugins/x86/tapsdkcore.dll.meta +63 -0
  13. package/Standalone/{Runtime/Internal/Utils.meta → Plugins/x86.meta} +1 -1
  14. package/Standalone/Plugins/x86_64/tapsdkcore.dll +0 -0
  15. package/Standalone/Plugins/x86_64/tapsdkcore.dll.meta +63 -0
  16. package/{link.xml.meta → Standalone/Plugins/x86_64.meta} +3 -2
  17. package/Standalone/Runtime/Internal/Constants.cs +0 -17
  18. package/Standalone/Runtime/Internal/DeviceInfo.cs +93 -89
  19. package/Standalone/Runtime/Internal/EventSender.cs +2 -2
  20. package/Standalone/Runtime/Internal/Http/TapHttp.cs +12 -6
  21. package/Standalone/Runtime/Internal/Http/TapHttpUtils.cs +23 -7
  22. package/Standalone/Runtime/Internal/Openlog/TapAppDurationStandalone.cs +121 -0
  23. package/Standalone/Runtime/Internal/Openlog/{TapOpenlogQueueBase.cs.meta → TapAppDurationStandalone.cs.meta} +1 -1
  24. package/Standalone/Runtime/Internal/Openlog/TapOpenlogParamConstants.cs +1 -3
  25. package/Standalone/Runtime/Internal/Openlog/TapOpenlogStandalone.cs +96 -94
  26. package/Standalone/Runtime/Internal/Openlog/TapOpenlogStartParamConstants.cs +23 -0
  27. package/Standalone/Runtime/Internal/Openlog/{Bean/TapOpenlogStoreBean.cs.meta → TapOpenlogStartParamConstants.cs.meta} +1 -1
  28. package/Standalone/Runtime/Internal/Openlog/TapOpenlogWrapper.cs +178 -0
  29. package/Standalone/Runtime/Internal/Openlog/{Bean/TapOpenlogLogGroup.cs.meta → TapOpenlogWrapper.cs.meta} +1 -1
  30. package/Standalone/Runtime/Public/TapCoreStandalone.cs +20 -13
  31. package/Standalone/Runtime/TapSDK.Core.Standalone.Runtime.asmdef +0 -1
  32. package/package.json +1 -1
  33. package/Standalone/Runtime/Internal/Openlog/Bean/TapOpenlogLogGroup.cs +0 -39
  34. package/Standalone/Runtime/Internal/Openlog/Bean/TapOpenlogStoreBean.cs +0 -33
  35. package/Standalone/Runtime/Internal/Openlog/TapOpenlogHttpClient.cs +0 -153
  36. package/Standalone/Runtime/Internal/Openlog/TapOpenlogHttpClient.cs.meta +0 -11
  37. package/Standalone/Runtime/Internal/Openlog/TapOpenlogQueueBase.cs +0 -198
  38. package/Standalone/Runtime/Internal/Openlog/TapOpenlogQueueBusiness.cs +0 -17
  39. package/Standalone/Runtime/Internal/Openlog/TapOpenlogQueueBusiness.cs.meta +0 -11
  40. package/Standalone/Runtime/Internal/Openlog/TapOpenlogQueueTechnology.cs +0 -15
  41. package/Standalone/Runtime/Internal/Openlog/TapOpenlogQueueTechnology.cs.meta +0 -11
  42. package/Standalone/Runtime/Internal/Utils/TapProtoBufffer.cs +0 -28
  43. package/Standalone/Runtime/Internal/Utils/TapProtoBufffer.cs.meta +0 -11
  44. package/link.xml +0 -4
@@ -1,198 +0,0 @@
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");
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
@@ -1,17 +0,0 @@
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
@@ -1,11 +0,0 @@
1
- fileFormatVersion: 2
2
- guid: 6b7900e0a4c624edfabc2326bdbab953
3
- MonoImporter:
4
- externalObjects: {}
5
- serializedVersion: 2
6
- defaultReferences: []
7
- executionOrder: 0
8
- icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant:
@@ -1,15 +0,0 @@
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
@@ -1,11 +0,0 @@
1
- fileFormatVersion: 2
2
- guid: c07d949d79d7d4ec893e5bda5e4c141d
3
- MonoImporter:
4
- externalObjects: {}
5
- serializedVersion: 2
6
- defaultReferences: []
7
- executionOrder: 0
8
- icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant:
@@ -1,28 +0,0 @@
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
@@ -1,11 +0,0 @@
1
- fileFormatVersion: 2
2
- guid: f7f3dd7d1657c46acb0a8bb6b62bfdf6
3
- MonoImporter:
4
- externalObjects: {}
5
- serializedVersion: 2
6
- defaultReferences: []
7
- executionOrder: 0
8
- icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant:
package/link.xml DELETED
@@ -1,4 +0,0 @@
1
- <linker>
2
- <assembly fullname="TapSDK.Core.Runtime" preserve="all" />
3
- <assembly fullname="TapSDK.Core.Mobile.Runtime" preserve="all" />
4
- </linker>