com.taptap.sdk.core 4.5.1 → 4.5.3
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/Runtime/Internal/Log/TapLog.cs +1 -4
- package/Runtime/Internal/Utils/EventManager.cs +2 -0
- package/Runtime/Internal/Utils/TapVerifyInitStateUtils.cs +21 -0
- package/Runtime/Internal/Utils/TapVerifyInitStateUtils.cs.meta +11 -0
- package/Runtime/Public/TapTapSDK.cs +1 -1
- package/Standalone/Plugins/x86/tapsdkcore.dll +0 -0
- package/Standalone/Plugins/x86_64/tapsdkcore.dll +0 -0
- package/Standalone/Runtime/Internal/Http/TapHttp.cs +55 -1
- package/Standalone/Runtime/Internal/Http/TapHttpException.cs +8 -0
- package/Standalone/Runtime/Internal/Http/TapHttpParser.cs +6 -2
- package/Standalone/Runtime/Internal/Http/TapHttpResult.cs +9 -0
- package/Standalone/Runtime/Internal/Http/TapHttpSign.cs +4 -0
- package/Standalone/Runtime/Internal/Http/TapHttpUtils.cs +23 -1
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogStandalone.cs +4 -0
- package/Standalone/Runtime/Public/TapCoreStandalone.cs +34 -0
- package/Standalone/Runtime/Public/TapEventStandalone.cs +97 -17
- package/link.xml.meta +1 -1
- package/package.json +1 -1
- package/Plugins.meta +0 -8
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
<repositories>
|
|
5
5
|
<repository>https://repo.maven.apache.org/maven2</repository>
|
|
6
6
|
</repositories>
|
|
7
|
-
<androidPackage spec="com.taptap.sdk:tap-core-unity:4.5.
|
|
7
|
+
<androidPackage spec="com.taptap.sdk:tap-core-unity:4.5.3"/>
|
|
8
8
|
</androidPackages>
|
|
9
9
|
<iosPods>
|
|
10
10
|
<sources>
|
|
11
11
|
<source>https://github.com/CocoaPods/Specs.git</source>
|
|
12
12
|
</sources>
|
|
13
|
-
<iosPod name="TapTapCoreSDK" version="~> 4.5.
|
|
13
|
+
<iosPod name="TapTapCoreSDK" version="~> 4.5.3" bitcodeEnabled="false" addToAllTargets="false"/>
|
|
14
14
|
</iosPods>
|
|
15
15
|
</dependencies>
|
|
@@ -63,10 +63,7 @@ namespace TapSDK.Core.Internal.Log
|
|
|
63
63
|
// 输出带有自定义颜色和标签的错误
|
|
64
64
|
public static void Error(string message, string detail = null, string tag = TAG, string module = null)
|
|
65
65
|
{
|
|
66
|
-
|
|
67
|
-
{
|
|
68
|
-
Debug.LogError(GetFormattedMessage(message: message, detail: detail, colorHex: ErrorColor, tag: tag, module: module));
|
|
69
|
-
}
|
|
66
|
+
Debug.LogError(GetFormattedMessage(message: message, detail: detail, colorHex: ErrorColor, tag: tag, module: module));
|
|
70
67
|
}
|
|
71
68
|
|
|
72
69
|
// 格式化带有颜色和标签的消息
|
|
@@ -8,6 +8,8 @@ namespace TapSDK.Core.Internal.Utils
|
|
|
8
8
|
{
|
|
9
9
|
public const string OnApplicationPause = "OnApplicationPause";
|
|
10
10
|
public const string OnApplicationQuit = "OnApplicationQuit";
|
|
11
|
+
|
|
12
|
+
public const string OnComplianceUserChanged = "OnComplianceUserChanged";
|
|
11
13
|
private Dictionary<string, Action<object>> eventRegistries = new Dictionary<string, Action<object>>();
|
|
12
14
|
|
|
13
15
|
public static void AddListener(string eventName, Action<object> listener) {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
using TapSDK.Core.Internal.Log;
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
namespace TapSDK.Core.Internal.Utils
|
|
5
|
+
{
|
|
6
|
+
public class TapVerifyInitStateUtils
|
|
7
|
+
{
|
|
8
|
+
|
|
9
|
+
public static void ShowVerifyErrorMsg(string error, string errorMsg)
|
|
10
|
+
{
|
|
11
|
+
if (error != null || error.Length > 0)
|
|
12
|
+
{
|
|
13
|
+
TapMessage.ShowMessage(error, TapMessage.Position.bottom, TapMessage.Time.twoSecond);
|
|
14
|
+
}
|
|
15
|
+
if (errorMsg != null && errorMsg.Length > 0)
|
|
16
|
+
{
|
|
17
|
+
TapLog.Error(errorMsg);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
Binary file
|
|
Binary file
|
|
@@ -4,7 +4,9 @@ namespace TapSDK.Core.Standalone.Internal.Http
|
|
|
4
4
|
{
|
|
5
5
|
using System;
|
|
6
6
|
using System.Collections.Generic;
|
|
7
|
+
using System.Linq;
|
|
7
8
|
using System.Net.Http.Headers;
|
|
9
|
+
using System.Net.NetworkInformation;
|
|
8
10
|
using System.Text;
|
|
9
11
|
using System.Threading.Tasks;
|
|
10
12
|
using Newtonsoft.Json;
|
|
@@ -24,7 +26,10 @@ namespace TapSDK.Core.Standalone.Internal.Http
|
|
|
24
26
|
public static readonly string HOST_CN = "https://tapsdk.tapapis.cn";
|
|
25
27
|
public static readonly string HOST_IO = "https://tapsdk.tapapis.com";
|
|
26
28
|
|
|
27
|
-
private static HttpClient client = new HttpClient
|
|
29
|
+
private static HttpClient client = new HttpClient{
|
|
30
|
+
// 默认超时 10 秒
|
|
31
|
+
Timeout = TimeSpan.FromMilliseconds(CONNECT_TIMEOUT_MILLIS)
|
|
32
|
+
};
|
|
28
33
|
|
|
29
34
|
private readonly TapHttpConfig httpConfig;
|
|
30
35
|
|
|
@@ -242,6 +247,11 @@ namespace TapSDK.Core.Standalone.Internal.Http
|
|
|
242
247
|
object body = null
|
|
243
248
|
)
|
|
244
249
|
{
|
|
250
|
+
if(!CheckNetworkConnection()){
|
|
251
|
+
return TapHttpResult<T>.NetworkError(new TapHttpNetworkErrorException("network error"));
|
|
252
|
+
}else{
|
|
253
|
+
TapLog.Log("current network is connected");
|
|
254
|
+
}
|
|
245
255
|
// 处理查询参数
|
|
246
256
|
Dictionary<string, string> allQueryParams = new Dictionary<string, string>();
|
|
247
257
|
if (queryParams != null)
|
|
@@ -379,5 +389,49 @@ namespace TapSDK.Core.Standalone.Internal.Http
|
|
|
379
389
|
return TapHttpResult<T>.UnknownFailure(new TapHttpUnknownException(ex));
|
|
380
390
|
}
|
|
381
391
|
}
|
|
392
|
+
|
|
393
|
+
// 判断网络连接状态
|
|
394
|
+
private bool CheckNetworkConnection(){
|
|
395
|
+
try {
|
|
396
|
+
var networkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
|
|
397
|
+
|
|
398
|
+
foreach (var netInterface in networkInterfaces)
|
|
399
|
+
{
|
|
400
|
+
// 忽略虚拟网卡
|
|
401
|
+
if (netInterface.NetworkInterfaceType == NetworkInterfaceType.Loopback ||
|
|
402
|
+
netInterface.NetworkInterfaceType == NetworkInterfaceType.Tunnel)
|
|
403
|
+
{
|
|
404
|
+
continue;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// 检查是否有网络连接
|
|
408
|
+
if (netInterface.OperationalStatus == OperationalStatus.Up)
|
|
409
|
+
{
|
|
410
|
+
// 检查是否有有效的 IPv4 地址
|
|
411
|
+
var ipProperties = netInterface.GetIPProperties();
|
|
412
|
+
var ipv4Address = ipProperties.UnicastAddresses.FirstOrDefault(ip => ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork);
|
|
413
|
+
|
|
414
|
+
if (ipv4Address != null)
|
|
415
|
+
{
|
|
416
|
+
// 有有效的 IP 地址,则说明已连接到网络
|
|
417
|
+
if (netInterface.NetworkInterfaceType == NetworkInterfaceType.Ethernet)
|
|
418
|
+
{
|
|
419
|
+
return true; // 有线连接
|
|
420
|
+
}
|
|
421
|
+
else if (netInterface.NetworkInterfaceType == NetworkInterfaceType.Wireless80211)
|
|
422
|
+
{
|
|
423
|
+
return true; // 无线连接
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
return false; // 无连接
|
|
430
|
+
}catch(Exception e){
|
|
431
|
+
TapLog.Log("checkout network connected error = " + e);
|
|
432
|
+
// 发生异常时,当做有网处理
|
|
433
|
+
return true;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
382
436
|
}
|
|
383
437
|
}
|
|
@@ -21,6 +21,14 @@ namespace TapSDK.Core.Standalone.Internal.Http
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
public class TapHttpNetworkErrorException : AbsTapHttpException
|
|
25
|
+
{
|
|
26
|
+
public TapHttpNetworkErrorException(string msg) : base("network error")
|
|
27
|
+
{
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
24
32
|
public class TapHttpInvalidResponseException : AbsTapHttpException
|
|
25
33
|
{
|
|
26
34
|
public HttpStatusCode StatusCode { get; }
|
|
@@ -84,6 +84,10 @@ namespace TapSDK.Core.Standalone.Internal.Http
|
|
|
84
84
|
try
|
|
85
85
|
{
|
|
86
86
|
httpResponse = JsonConvert.DeserializeObject<TapHttpResponse>(content);
|
|
87
|
+
// 设置当前服务端返回的事件戳
|
|
88
|
+
if (httpResponse.Now > 0){
|
|
89
|
+
TapHttpTime.ResetLastServerTime(httpResponse.Now);
|
|
90
|
+
}
|
|
87
91
|
}
|
|
88
92
|
catch (Exception)
|
|
89
93
|
{
|
|
@@ -119,12 +123,12 @@ namespace TapSDK.Core.Standalone.Internal.Http
|
|
|
119
123
|
}
|
|
120
124
|
else
|
|
121
125
|
{
|
|
122
|
-
TapHttpErrorData httpErrorData = httpResponse.Data
|
|
126
|
+
TapHttpErrorData httpErrorData = httpResponse.Data?.ToObject<TapHttpErrorData>();
|
|
123
127
|
if (httpErrorData == null)
|
|
124
128
|
{
|
|
125
129
|
return TapHttpResult<T>.InvalidResponseFailure(new TapHttpInvalidResponseException(statusCode, "TapHttpErrorData is null"));
|
|
126
130
|
}
|
|
127
|
-
return TapHttpResult<T>.ServerFailure(new TapHttpServerException((HttpStatusCode)
|
|
131
|
+
return TapHttpResult<T>.ServerFailure(new TapHttpServerException((HttpStatusCode)statusCode, httpResponse, httpErrorData));
|
|
128
132
|
}
|
|
129
133
|
}
|
|
130
134
|
}
|
|
@@ -86,5 +86,14 @@ namespace TapSDK.Core.Standalone.Internal.Http
|
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
+
public static TapHttpResult<T> NetworkError(TapHttpNetworkErrorException httpException)
|
|
90
|
+
{
|
|
91
|
+
return new TapHttpResult<T>
|
|
92
|
+
{
|
|
93
|
+
IsSuccess = false,
|
|
94
|
+
HttpException = httpException,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
89
98
|
}
|
|
90
99
|
}
|
|
@@ -67,6 +67,10 @@ namespace TapSDK.Core.Standalone.Internal.Http
|
|
|
67
67
|
{ "X-Tap-Lang", TapHttpUtils.GenerateLanguage()},
|
|
68
68
|
{ "User-Agent", TapHttpUtils.GenerateUserAgent()},
|
|
69
69
|
};
|
|
70
|
+
string currentUserId = TapCoreStandalone.User?.Id;
|
|
71
|
+
if(currentUserId != null && currentUserId.Length > 0) {
|
|
72
|
+
headers.Add("X-Tap-SDK-Game-User-Id", currentUserId);
|
|
73
|
+
}
|
|
70
74
|
if (enableAuthorization)
|
|
71
75
|
{
|
|
72
76
|
string authorization = TapHttpUtils.GenerateAuthorization(url, method.ToString());
|
|
@@ -32,6 +32,28 @@ namespace TapSDK.Core.Standalone.Internal.Http
|
|
|
32
32
|
}
|
|
33
33
|
SetTimeOffset(time - (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds);
|
|
34
34
|
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
// 服务端同步的时间戳
|
|
38
|
+
private static long LastServerTime = 0;
|
|
39
|
+
// 设置服务端时间时,当前应用启动时间
|
|
40
|
+
private static long LastStartUpTime = 0 ;
|
|
41
|
+
internal static void ResetLastServerTime(long time){
|
|
42
|
+
LastServerTime = time;
|
|
43
|
+
LastStartUpTime = (long) Time.realtimeSinceStartup;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/// <summary>
|
|
47
|
+
/// 根据服务端时间获取当前时间戳,单位:秒
|
|
48
|
+
/// </summary>
|
|
49
|
+
/// <returns>当前时间戳,当服务端时间未设置过时,返回值为 0</returns>
|
|
50
|
+
public static long GetCurrentServerTime(){
|
|
51
|
+
if(LastServerTime == 0){
|
|
52
|
+
return 0;
|
|
53
|
+
}
|
|
54
|
+
long startUpTime = (long) Time.realtimeSinceStartup;
|
|
55
|
+
return LastServerTime + startUpTime - LastStartUpTime;
|
|
56
|
+
}
|
|
35
57
|
}
|
|
36
58
|
|
|
37
59
|
public static class TapHttpUtils
|
|
@@ -161,7 +183,7 @@ namespace TapSDK.Core.Standalone.Internal.Http
|
|
|
161
183
|
StringBuilder sb = new StringBuilder();
|
|
162
184
|
sb.AppendLine("=== HTTP Response Start ===");
|
|
163
185
|
sb.AppendLine($"URL: {response.RequestMessage.RequestUri}");
|
|
164
|
-
sb.AppendLine($"Status Code: {response.StatusCode}");
|
|
186
|
+
sb.AppendLine($"Status Code: {response.StatusCode}");
|
|
165
187
|
string contentString = null;
|
|
166
188
|
try
|
|
167
189
|
{
|
|
@@ -22,6 +22,9 @@ namespace TapSDK.Core.Standalone
|
|
|
22
22
|
internal static Tracker Tracker;
|
|
23
23
|
internal static User User;
|
|
24
24
|
internal static TapTapSdkOptions coreOptions;
|
|
25
|
+
|
|
26
|
+
// client 信息是否匹配
|
|
27
|
+
internal static bool isClientInfoMatched = true;
|
|
25
28
|
internal static bool enableAutoEvent = true;
|
|
26
29
|
|
|
27
30
|
internal static TapGatekeeper gatekeeperData = new TapGatekeeper();
|
|
@@ -56,6 +59,14 @@ namespace TapSDK.Core.Standalone
|
|
|
56
59
|
/// <param name="otherOptions">Additional TapCore SDK options.</param>
|
|
57
60
|
public void Init(TapTapSdkOptions coreOption, TapTapSdkBaseOptions[] otherOptions)
|
|
58
61
|
{
|
|
62
|
+
if (coreOption.clientId == null || coreOption.clientId.Length == 0){
|
|
63
|
+
TapVerifyInitStateUtils.ShowVerifyErrorMsg("clientId 不能为空","clientId 不能为空");
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if(coreOption.clientToken == null || coreOption.clientToken.Length == 0) {
|
|
67
|
+
TapVerifyInitStateUtils.ShowVerifyErrorMsg("clientToken 不能为空","clientToken 不能为空");
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
59
70
|
TapLog.Log("SDK Init Options : ", "coreOption : " + JsonConvert.SerializeObject(coreOption) + "\notherOptions : " + JsonConvert.SerializeObject(otherOptions));
|
|
60
71
|
coreOptions = coreOption;
|
|
61
72
|
|
|
@@ -159,6 +170,7 @@ namespace TapSDK.Core.Standalone
|
|
|
159
170
|
{
|
|
160
171
|
if (TapHttpErrorConstants.ERROR_INVALID_CLIENT.Equals(se.ErrorData.Error))
|
|
161
172
|
{
|
|
173
|
+
isClientInfoMatched = false;
|
|
162
174
|
TapLog.Error("Init Failed", se.ErrorData.ErrorDescription);
|
|
163
175
|
TapMessage.ShowMessage(se.ErrorData.Msg, TapMessage.Position.bottom, TapMessage.Time.twoSecond);
|
|
164
176
|
}
|
|
@@ -184,6 +196,28 @@ namespace TapSDK.Core.Standalone
|
|
|
184
196
|
}
|
|
185
197
|
}
|
|
186
198
|
}
|
|
199
|
+
|
|
200
|
+
public static bool CheckInitState()
|
|
201
|
+
{
|
|
202
|
+
// 未初始化
|
|
203
|
+
if (coreOptions == null || coreOptions.clientId == null || coreOptions.clientId.Length == 0
|
|
204
|
+
|| coreOptions.clientToken == null || coreOptions.clientToken.Length == 0) {
|
|
205
|
+
TapVerifyInitStateUtils.ShowVerifyErrorMsg("当前应用还未初始化","当前应用还未初始化: 请在调用 SDK 业务接口前,先调用 TapTapSDK.Init 接口");
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
// 应用信息不匹配
|
|
209
|
+
if(isClientInfoMatched == false) {
|
|
210
|
+
TapVerifyInitStateUtils.ShowVerifyErrorMsg("当前应用初始化信息错误","当前应用初始化信息错误: 请在 TapTap 开发者中心检查当前应用调用初始化接口设置的 clientId 、clientToken 是否匹配");
|
|
211
|
+
return false;
|
|
212
|
+
}
|
|
213
|
+
return true;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// 获取当前用户设置的 DB userID
|
|
217
|
+
public static string GetCurrentUserId(){
|
|
218
|
+
return User?.Id;
|
|
219
|
+
}
|
|
220
|
+
|
|
187
221
|
}
|
|
188
222
|
|
|
189
223
|
public interface IOpenIDProvider
|
|
@@ -21,6 +21,10 @@ namespace TapSDK.Core.Standalone
|
|
|
21
21
|
/// <param name="userID">The user ID to set.</param>
|
|
22
22
|
public void SetUserID(string userID)
|
|
23
23
|
{
|
|
24
|
+
if (!TapCoreStandalone.CheckInitState())
|
|
25
|
+
{
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
24
28
|
SetUserID(userID, null);
|
|
25
29
|
}
|
|
26
30
|
|
|
@@ -31,6 +35,10 @@ namespace TapSDK.Core.Standalone
|
|
|
31
35
|
/// <param name="properties">Additional properties to associate with the user.</param>
|
|
32
36
|
public void SetUserID(string userID, string properties)
|
|
33
37
|
{
|
|
38
|
+
if (!TapCoreStandalone.CheckInitState())
|
|
39
|
+
{
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
34
42
|
if (!IsValidUserID(userID))
|
|
35
43
|
{
|
|
36
44
|
TapLogger.Error("Invalid user ID, length should be 1-160 and only contains a-zA-Z0-9_+/=.,:");
|
|
@@ -46,6 +54,10 @@ namespace TapSDK.Core.Standalone
|
|
|
46
54
|
/// </summary>
|
|
47
55
|
public void ClearUser()
|
|
48
56
|
{
|
|
57
|
+
if (!TapCoreStandalone.CheckInitState())
|
|
58
|
+
{
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
49
61
|
User.Logout();
|
|
50
62
|
}
|
|
51
63
|
|
|
@@ -55,6 +67,10 @@ namespace TapSDK.Core.Standalone
|
|
|
55
67
|
/// <returns>The device ID.</returns>
|
|
56
68
|
public string GetDeviceId()
|
|
57
69
|
{
|
|
70
|
+
if (!TapCoreStandalone.CheckInitState())
|
|
71
|
+
{
|
|
72
|
+
return "";
|
|
73
|
+
}
|
|
58
74
|
return Identity.DeviceId;
|
|
59
75
|
}
|
|
60
76
|
|
|
@@ -65,8 +81,13 @@ namespace TapSDK.Core.Standalone
|
|
|
65
81
|
/// <param name="properties">Additional properties to associate with the event.</param>
|
|
66
82
|
public void LogEvent(string name, string properties)
|
|
67
83
|
{
|
|
84
|
+
if (!TapCoreStandalone.CheckInitState())
|
|
85
|
+
{
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
68
88
|
// name 长度256非空,不符合的丢事件,打log
|
|
69
|
-
if (!checkLength(name))
|
|
89
|
+
if (!checkLength(name))
|
|
90
|
+
{
|
|
70
91
|
Debug.LogError(name + " Event name length should be less than or equal to 256 characters.");
|
|
71
92
|
return;
|
|
72
93
|
}
|
|
@@ -80,6 +101,10 @@ namespace TapSDK.Core.Standalone
|
|
|
80
101
|
/// <param name="properties">Additional properties to associate with the device initialization.</param>
|
|
81
102
|
public void DeviceInitialize(string properties)
|
|
82
103
|
{
|
|
104
|
+
if (!TapCoreStandalone.CheckInitState())
|
|
105
|
+
{
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
83
108
|
Dictionary<string, object> prop = Json.Deserialize(properties) as Dictionary<string, object>;
|
|
84
109
|
Tracker.TrackDeviceProperties(Constants.PROPERTY_INITIALIZE_TYPE, filterProperties(prop));
|
|
85
110
|
}
|
|
@@ -90,6 +115,10 @@ namespace TapSDK.Core.Standalone
|
|
|
90
115
|
/// <param name="properties">Additional properties to associate with the device update.</param>
|
|
91
116
|
public void DeviceUpdate(string properties)
|
|
92
117
|
{
|
|
118
|
+
if (!TapCoreStandalone.CheckInitState())
|
|
119
|
+
{
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
93
122
|
Dictionary<string, object> prop = Json.Deserialize(properties) as Dictionary<string, object>;
|
|
94
123
|
Tracker.TrackDeviceProperties(Constants.PROPERTY_UPDATE_TYPE, filterProperties(prop));
|
|
95
124
|
}
|
|
@@ -100,6 +129,10 @@ namespace TapSDK.Core.Standalone
|
|
|
100
129
|
/// <param name="properties">Additional properties to associate with the device addition.</param>
|
|
101
130
|
public void DeviceAdd(string properties)
|
|
102
131
|
{
|
|
132
|
+
if (!TapCoreStandalone.CheckInitState())
|
|
133
|
+
{
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
103
136
|
Dictionary<string, object> prop = Json.Deserialize(properties) as Dictionary<string, object>;
|
|
104
137
|
Tracker.TrackDeviceProperties(Constants.PROPERTY_ADD_TYPE, filterProperties(prop));
|
|
105
138
|
}
|
|
@@ -110,6 +143,10 @@ namespace TapSDK.Core.Standalone
|
|
|
110
143
|
/// <param name="properties">Additional properties to associate with the user initialization.</param>
|
|
111
144
|
public void UserInitialize(string properties)
|
|
112
145
|
{
|
|
146
|
+
if (!TapCoreStandalone.CheckInitState())
|
|
147
|
+
{
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
113
150
|
Dictionary<string, object> prop = Json.Deserialize(properties) as Dictionary<string, object>;
|
|
114
151
|
Tracker.TrackUserProperties(Constants.PROPERTY_INITIALIZE_TYPE, filterProperties(prop));
|
|
115
152
|
}
|
|
@@ -120,6 +157,10 @@ namespace TapSDK.Core.Standalone
|
|
|
120
157
|
/// <param name="properties">Additional properties to associate with the user update.</param>
|
|
121
158
|
public void UserUpdate(string properties)
|
|
122
159
|
{
|
|
160
|
+
if (!TapCoreStandalone.CheckInitState())
|
|
161
|
+
{
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
123
164
|
Dictionary<string, object> prop = Json.Deserialize(properties) as Dictionary<string, object>;
|
|
124
165
|
Tracker.TrackUserProperties(Constants.PROPERTY_UPDATE_TYPE, filterProperties(prop));
|
|
125
166
|
}
|
|
@@ -130,6 +171,10 @@ namespace TapSDK.Core.Standalone
|
|
|
130
171
|
/// <param name="properties">Additional properties to associate with the user addition.</param>
|
|
131
172
|
public void UserAdd(string properties)
|
|
132
173
|
{
|
|
174
|
+
if (!TapCoreStandalone.CheckInitState())
|
|
175
|
+
{
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
133
178
|
Dictionary<string, object> prop = Json.Deserialize(properties) as Dictionary<string, object>;
|
|
134
179
|
Tracker.TrackUserProperties(Constants.PROPERTY_ADD_TYPE, filterProperties(prop));
|
|
135
180
|
}
|
|
@@ -141,11 +186,17 @@ namespace TapSDK.Core.Standalone
|
|
|
141
186
|
/// <param name="value">The value of the common property.</param>
|
|
142
187
|
public void AddCommonProperty(string key, string value)
|
|
143
188
|
{
|
|
144
|
-
if (!
|
|
189
|
+
if (!TapCoreStandalone.CheckInitState())
|
|
190
|
+
{
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (!checkLength(key))
|
|
194
|
+
{
|
|
145
195
|
Debug.LogError(key + " Property key length should be less than or equal to 256 characters.");
|
|
146
196
|
return;
|
|
147
197
|
}
|
|
148
|
-
if (!checkLength(value))
|
|
198
|
+
if (!checkLength(value))
|
|
199
|
+
{
|
|
149
200
|
Debug.LogError(value + " Property value length should be less than or equal to 256 characters.");
|
|
150
201
|
return;
|
|
151
202
|
}
|
|
@@ -158,6 +209,10 @@ namespace TapSDK.Core.Standalone
|
|
|
158
209
|
/// <param name="properties">The JSON string containing the common properties.</param>
|
|
159
210
|
public void AddCommon(string properties)
|
|
160
211
|
{
|
|
212
|
+
if (!TapCoreStandalone.CheckInitState())
|
|
213
|
+
{
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
161
216
|
Dictionary<string, object> prop = Json.Deserialize(properties) as Dictionary<string, object>;
|
|
162
217
|
Tracker.AddCommon(filterProperties(prop));
|
|
163
218
|
}
|
|
@@ -168,6 +223,10 @@ namespace TapSDK.Core.Standalone
|
|
|
168
223
|
/// <param name="key">The key of the common property to clear.</param>
|
|
169
224
|
public void ClearCommonProperty(string key)
|
|
170
225
|
{
|
|
226
|
+
if (!TapCoreStandalone.CheckInitState())
|
|
227
|
+
{
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
171
230
|
Tracker.ClearCommonProperty(key);
|
|
172
231
|
}
|
|
173
232
|
|
|
@@ -177,6 +236,10 @@ namespace TapSDK.Core.Standalone
|
|
|
177
236
|
/// <param name="keys">The keys of the common properties to clear.</param>
|
|
178
237
|
public void ClearCommonProperties(string[] keys)
|
|
179
238
|
{
|
|
239
|
+
if (!TapCoreStandalone.CheckInitState())
|
|
240
|
+
{
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
180
243
|
Tracker.ClearCommonProperties(keys);
|
|
181
244
|
}
|
|
182
245
|
|
|
@@ -185,6 +248,10 @@ namespace TapSDK.Core.Standalone
|
|
|
185
248
|
/// </summary>
|
|
186
249
|
public void ClearAllCommonProperties()
|
|
187
250
|
{
|
|
251
|
+
if (!TapCoreStandalone.CheckInitState())
|
|
252
|
+
{
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
188
255
|
Tracker.ClearAllCommonProperties();
|
|
189
256
|
}
|
|
190
257
|
|
|
@@ -199,7 +266,12 @@ namespace TapSDK.Core.Standalone
|
|
|
199
266
|
/// <param name="properties">Additional properties to associate with the charge event.</param>
|
|
200
267
|
public void LogChargeEvent(string orderID, string productName, long amount, string currencyType, string paymentMethod, string properties)
|
|
201
268
|
{
|
|
202
|
-
if (
|
|
269
|
+
if (!TapCoreStandalone.CheckInitState())
|
|
270
|
+
{
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
if (amount <= 0 || amount > 100000000000)
|
|
274
|
+
{
|
|
203
275
|
UnityEngine.Debug.LogError(amount + " is invalid, amount should be in range (0, 100000000000]");
|
|
204
276
|
return;
|
|
205
277
|
}
|
|
@@ -212,6 +284,10 @@ namespace TapSDK.Core.Standalone
|
|
|
212
284
|
/// <param name="callback">The callback function that returns a JSON string containing the dynamic properties.</param>
|
|
213
285
|
public void RegisterDynamicProperties(Func<string> callback)
|
|
214
286
|
{
|
|
287
|
+
if (!TapCoreStandalone.CheckInitState())
|
|
288
|
+
{
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
215
291
|
DynamicProperties dynamicProperties = new DynamicProperties(callback);
|
|
216
292
|
Tracker.RegisterDynamicPropsDelegate(dynamicProperties);
|
|
217
293
|
}
|
|
@@ -243,9 +319,11 @@ namespace TapSDK.Core.Standalone
|
|
|
243
319
|
}
|
|
244
320
|
}
|
|
245
321
|
|
|
246
|
-
private bool checkLength(string value)
|
|
322
|
+
private bool checkLength(string value)
|
|
323
|
+
{
|
|
247
324
|
var maxLength = 256;
|
|
248
|
-
if (value.Length <= 0 || value.Length > maxLength)
|
|
325
|
+
if (value.Length <= 0 || value.Length > maxLength)
|
|
326
|
+
{
|
|
249
327
|
return false;
|
|
250
328
|
}
|
|
251
329
|
return true;
|
|
@@ -261,19 +339,21 @@ namespace TapSDK.Core.Standalone
|
|
|
261
339
|
private Dictionary<string, object> filterProperties(Dictionary<string, object> properties)
|
|
262
340
|
{
|
|
263
341
|
Dictionary<string, object> filteredProperties = new Dictionary<string, object>();
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
if (property.Key.Length <= 0 || property.Key.Length > 256)
|
|
267
|
-
{
|
|
268
|
-
Debug.Log(property.Key + " Property key length should be more then 0 and less than or equal to 256 characters.");
|
|
269
|
-
continue;
|
|
270
|
-
}
|
|
271
|
-
if (property.Value.ToString().Length > 256)
|
|
342
|
+
if(properties != null) {
|
|
343
|
+
foreach (var property in properties)
|
|
272
344
|
{
|
|
273
|
-
|
|
274
|
-
|
|
345
|
+
if (property.Key.Length <= 0 || property.Key.Length > 256)
|
|
346
|
+
{
|
|
347
|
+
Debug.Log(property.Key + " Property key length should be more then 0 and less than or equal to 256 characters.");
|
|
348
|
+
continue;
|
|
349
|
+
}
|
|
350
|
+
if (property.Value.ToString().Length > 256)
|
|
351
|
+
{
|
|
352
|
+
Debug.Log(property.Value + " Property value length should be less than or equal to 256 characters.");
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
filteredProperties.Add(property.Key, property.Value);
|
|
275
356
|
}
|
|
276
|
-
filteredProperties.Add(property.Key, property.Value);
|
|
277
357
|
}
|
|
278
358
|
return filteredProperties;
|
|
279
359
|
}
|
package/link.xml.meta
CHANGED
package/package.json
CHANGED