com.taptap.sdk.core 4.4.1 → 4.4.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/Editor/TapSDKCoreCompile.cs +6 -0
- package/Mobile/Editor/NativeDependencies.xml +2 -2
- package/Mobile/Runtime/TapEventMobile.cs +0 -1
- package/{Standalone/Runtime/Internal/Openlog/Bean.meta → Plugins.meta} +1 -1
- package/Resources/TapMessage.prefab +1 -1
- package/Runtime/Internal/Log/TapLog.cs +1 -1
- package/Runtime/Public/TapTapSDK.cs +11 -3
- package/Runtime/Public/TapTapSdkOptions.cs +0 -4
- package/Standalone/Plugins/macOS/libtapsdkcorecpp.dylib +0 -0
- package/Standalone/Plugins/macOS/libtapsdkcorecpp.dylib.meta +80 -0
- package/Standalone/Plugins/x86/tapsdkcore.dll +0 -0
- package/Standalone/Plugins/x86/tapsdkcore.dll.meta +63 -0
- package/Standalone/{Runtime/Internal/Utils.meta → Plugins/x86.meta} +1 -1
- package/Standalone/Plugins/x86_64/tapsdkcore.dll +0 -0
- package/Standalone/Plugins/x86_64/tapsdkcore.dll.meta +63 -0
- package/{link.xml.meta → Standalone/Plugins/x86_64.meta} +3 -2
- package/Standalone/Runtime/Internal/Http/TapHttp.cs +12 -6
- package/Standalone/Runtime/Internal/Http/TapHttpUtils.cs +22 -6
- package/Standalone/Runtime/Internal/Openlog/TapAppDurationStandalone.cs +121 -0
- package/Standalone/Runtime/Internal/Openlog/{TapOpenlogQueueBase.cs.meta → TapAppDurationStandalone.cs.meta} +1 -1
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogParamConstants.cs +1 -3
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogStandalone.cs +96 -93
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogStartParamConstants.cs +23 -0
- package/Standalone/Runtime/Internal/Openlog/{Bean/TapOpenlogStoreBean.cs.meta → TapOpenlogStartParamConstants.cs.meta} +1 -1
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogWrapper.cs +178 -0
- package/Standalone/Runtime/Internal/Openlog/{Bean/TapOpenlogLogGroup.cs.meta → TapOpenlogWrapper.cs.meta} +1 -1
- package/Standalone/Runtime/Public/TapCoreStandalone.cs +19 -3
- package/Standalone/Runtime/TapSDK.Core.Standalone.Runtime.asmdef +0 -1
- package/package.json +1 -1
- package/Standalone/Runtime/Internal/Openlog/Bean/TapOpenlogLogGroup.cs +0 -39
- package/Standalone/Runtime/Internal/Openlog/Bean/TapOpenlogStoreBean.cs +0 -33
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogHttpClient.cs +0 -153
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogHttpClient.cs.meta +0 -11
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogQueueBase.cs +0 -198
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogQueueBusiness.cs +0 -17
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogQueueBusiness.cs.meta +0 -11
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogQueueTechnology.cs +0 -15
- package/Standalone/Runtime/Internal/Openlog/TapOpenlogQueueTechnology.cs.meta +0 -11
- package/Standalone/Runtime/Internal/Utils/TapProtoBufffer.cs +0 -28
- package/Standalone/Runtime/Internal/Utils/TapProtoBufffer.cs.meta +0 -11
- package/link.xml +0 -4
|
@@ -1,33 +1,54 @@
|
|
|
1
1
|
|
|
2
2
|
using System;
|
|
3
3
|
using System.Collections.Generic;
|
|
4
|
+
using System.IO;
|
|
5
|
+
using System.Runtime.InteropServices;
|
|
4
6
|
using Newtonsoft.Json;
|
|
5
7
|
using TapSDK.Core.Internal.Log;
|
|
8
|
+
using TapSDK.Core.Standalone.Internal.Http;
|
|
6
9
|
using UnityEngine;
|
|
10
|
+
#if UNITY_STANDALONE
|
|
11
|
+
using static TapSDK.Core.Standalone.Internal.Openlog.TapOpenlogWrapper;
|
|
12
|
+
#endif
|
|
7
13
|
|
|
8
14
|
namespace TapSDK.Core.Standalone.Internal.Openlog
|
|
9
15
|
{
|
|
10
16
|
public class TapOpenlogStandalone
|
|
11
17
|
{
|
|
12
18
|
public static string openid = "";
|
|
13
|
-
|
|
14
|
-
private static Dictionary<string,
|
|
15
|
-
private
|
|
16
|
-
|
|
17
|
-
private static
|
|
18
|
-
private static
|
|
19
|
+
private static readonly Dictionary<string, string> generalParameter = new Dictionary<string, string>();
|
|
20
|
+
private static readonly Dictionary<string, System.Object> openlogStartParameter = new Dictionary<string, System.Object>();
|
|
21
|
+
private readonly string sdkProjectName;
|
|
22
|
+
private readonly string sdkProjectVersion;
|
|
23
|
+
private static readonly bool isRND = false;
|
|
24
|
+
private static readonly TapLog log = new TapLog(module: "Openlog");
|
|
25
|
+
#if UNITY_STANDALONE
|
|
26
|
+
private static readonly CommonVariablesGetter commonVariablesGetter = new CommonVariablesGetter(GetCommonVariables);
|
|
27
|
+
private static readonly FreeStringCallback freeString = new FreeStringCallback(FreeString);
|
|
19
28
|
#endif
|
|
20
|
-
private string sdkProjectName;
|
|
21
|
-
private string sdkProjectVersion;
|
|
22
|
-
|
|
23
|
-
private static TapLog log = new TapLog(module: "Openlog");
|
|
24
29
|
public static void Init()
|
|
25
30
|
{
|
|
26
|
-
#if
|
|
27
|
-
businessQueue = new TapOpenlogQueueBusiness();
|
|
28
|
-
technologyQueue = new TapOpenlogQueueTechnology();
|
|
29
|
-
#endif
|
|
31
|
+
#if UNITY_STANDALONE
|
|
30
32
|
InitGeneralParameter();
|
|
33
|
+
InitOpenlogStartParameter();
|
|
34
|
+
string openlogStartStr = JsonConvert.SerializeObject(openlogStartParameter);
|
|
35
|
+
int result = TdkOnAppStarted(openlogStartStr, commonVariablesGetter, freeString);
|
|
36
|
+
#endif
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private static IntPtr GetCommonVariables()
|
|
40
|
+
{
|
|
41
|
+
Dictionary<string, string> dynamicProperties = InflateDynamicProperties();
|
|
42
|
+
string jsonStr = JsonConvert.SerializeObject(dynamicProperties);
|
|
43
|
+
return Marshal.StringToHGlobalAnsi(jsonStr);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
private static void FreeString(IntPtr intPtr)
|
|
47
|
+
{
|
|
48
|
+
if (intPtr != IntPtr.Zero)
|
|
49
|
+
{
|
|
50
|
+
Marshal.FreeHGlobal(intPtr);
|
|
51
|
+
}
|
|
31
52
|
}
|
|
32
53
|
|
|
33
54
|
public TapOpenlogStandalone(string sdkProjectName, string sdkProjectVersion)
|
|
@@ -41,32 +62,16 @@ namespace TapSDK.Core.Standalone.Internal.Openlog
|
|
|
41
62
|
Dictionary<string, string> properties = null
|
|
42
63
|
)
|
|
43
64
|
{
|
|
44
|
-
|
|
45
|
-
string tLogId = Guid.NewGuid().ToString();
|
|
46
|
-
|
|
65
|
+
#if UNITY_STANDALONE
|
|
47
66
|
if (properties == null)
|
|
48
67
|
{
|
|
49
68
|
properties = new Dictionary<string, string>();
|
|
50
69
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
// 该条日志的唯一标识
|
|
58
|
-
props[TapOpenlogParamConstants.PARAM_T_LOG_ID] = tLogId;
|
|
59
|
-
// 客户端生成的时间戳,毫秒级
|
|
60
|
-
props[TapOpenlogParamConstants.PARAM_TIMESTAMP] = timestamp.ToString();
|
|
61
|
-
|
|
62
|
-
props["action"] = action;
|
|
63
|
-
|
|
64
|
-
TapOpenlogStoreBean bean = new TapOpenlogStoreBean(action, timestamp, tLogId, props);
|
|
65
|
-
log.Log("LogBusiness action = " + action + ", sdkProjectName = " + sdkProjectName + " , sdkProjectVersion = " + sdkProjectVersion, bean + "\n" + JsonConvert.SerializeObject(properties));
|
|
66
|
-
#if UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN
|
|
67
|
-
businessQueue.Enqueue(bean);
|
|
68
|
-
#else
|
|
69
|
-
// log.Log($"This Platform 【{Application.platform}】 is not supported for Openlog.");
|
|
70
|
+
properties[TapOpenlogParamConstants.PARAM_TAPSDK_PROJECT] = sdkProjectName;
|
|
71
|
+
properties[TapOpenlogParamConstants.PARAM_TAPSDK_VERSION] = sdkProjectVersion;
|
|
72
|
+
properties[TapOpenlogParamConstants.PARAM_ACTION] = action;
|
|
73
|
+
string propertiesStr = JsonConvert.SerializeObject(properties);
|
|
74
|
+
TdkOpenLog("tapsdk", propertiesStr);
|
|
70
75
|
#endif
|
|
71
76
|
}
|
|
72
77
|
|
|
@@ -75,36 +80,50 @@ namespace TapSDK.Core.Standalone.Internal.Openlog
|
|
|
75
80
|
Dictionary<string, string> properties = null
|
|
76
81
|
)
|
|
77
82
|
{
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if (properties == null)
|
|
83
|
+
#if UNITY_STANDALONE
|
|
84
|
+
if (TapCoreStandalone.coreOptions.region == TapTapRegionType.CN && !"TapPayment".Equals(sdkProjectName))
|
|
82
85
|
{
|
|
83
|
-
|
|
86
|
+
// 国内非支付SDK不上报技术日志
|
|
87
|
+
return;
|
|
84
88
|
}
|
|
85
|
-
Dictionary<string, string>
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
props["action"] = action;
|
|
97
|
-
|
|
98
|
-
TapOpenlogStoreBean bean = new TapOpenlogStoreBean(action, timestamp, tLogId, props);
|
|
99
|
-
|
|
100
|
-
log.Log("LogTechnology action = " + action, bean + "\n" + JsonConvert.SerializeObject(properties));
|
|
101
|
-
#if UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN
|
|
102
|
-
technologyQueue.Enqueue(bean);
|
|
103
|
-
#else
|
|
104
|
-
// log.Log($"This Platform 【{Application.platform}】 is not supported for Openlog.");
|
|
89
|
+
Dictionary<string, string> content = InflateDynamicProperties();
|
|
90
|
+
content[TapOpenlogParamConstants.PARAM_TAPSDK_PROJECT] = sdkProjectName;
|
|
91
|
+
content[TapOpenlogParamConstants.PARAM_TAPSDK_VERSION] = sdkProjectVersion;
|
|
92
|
+
content[TapOpenlogParamConstants.PARAM_ACTION] = action;
|
|
93
|
+
if (properties != null)
|
|
94
|
+
{
|
|
95
|
+
content["args"] = JsonConvert.SerializeObject(properties);
|
|
96
|
+
}
|
|
97
|
+
string propertiesStr = JsonConvert.SerializeObject(content);
|
|
98
|
+
TdkOpenLog("tapsdk-apm", propertiesStr);
|
|
105
99
|
#endif
|
|
106
100
|
}
|
|
107
101
|
|
|
102
|
+
private static void InitOpenlogStartParameter()
|
|
103
|
+
{
|
|
104
|
+
if (isRND)
|
|
105
|
+
{
|
|
106
|
+
openlogStartParameter[TapOpenlogStartParamConstants.PARAM_REGION] = 2;
|
|
107
|
+
}
|
|
108
|
+
else
|
|
109
|
+
{
|
|
110
|
+
openlogStartParameter[TapOpenlogStartParamConstants.PARAM_REGION] = TapCoreStandalone.coreOptions.region;
|
|
111
|
+
}
|
|
112
|
+
openlogStartParameter[TapOpenlogStartParamConstants.PARAM_LOG_TO_CONSOLE] = 1;
|
|
113
|
+
openlogStartParameter[TapOpenlogStartParamConstants.PARAM_LOG_LEVEL] = 1;
|
|
114
|
+
openlogStartParameter[TapOpenlogStartParamConstants.PARAM_DATA_DIR] = Path.Combine(Application.persistentDataPath, "OpenlogData");
|
|
115
|
+
openlogStartParameter[TapOpenlogStartParamConstants.PARAM_ENV] = "local";
|
|
116
|
+
openlogStartParameter[TapOpenlogStartParamConstants.PARAM_PLATFORM] = "PC";
|
|
117
|
+
openlogStartParameter[TapOpenlogStartParamConstants.PARAM_UA] = TapHttpUtils.GenerateUserAgent();
|
|
118
|
+
openlogStartParameter[TapOpenlogStartParamConstants.PARAM_CLIENT_ID] = TapCoreStandalone.coreOptions.clientId;
|
|
119
|
+
openlogStartParameter[TapOpenlogStartParamConstants.PARAM_CLIENT_TOKEN] = TapCoreStandalone.coreOptions.clientToken;
|
|
120
|
+
openlogStartParameter[TapOpenlogStartParamConstants.PARAM_COMMON] = generalParameter;
|
|
121
|
+
openlogStartParameter[TapOpenlogStartParamConstants.PARAM_APP_DURATION] = new Dictionary<string, string>()
|
|
122
|
+
{
|
|
123
|
+
{TapOpenlogParamConstants.PARAM_TAPSDK_VERSION, TapTapSDK.Version}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
108
127
|
private static void InitGeneralParameter()
|
|
109
128
|
{
|
|
110
129
|
// 应用包名
|
|
@@ -115,12 +134,8 @@ namespace TapSDK.Core.Standalone.Internal.Openlog
|
|
|
115
134
|
generalParameter[TapOpenlogParamConstants.PARAM_APP_VERSION_CODE] = "";
|
|
116
135
|
// 固定一个枚举值: TapSDK
|
|
117
136
|
generalParameter[TapOpenlogParamConstants.PARAM_PN] = "TapSDK";
|
|
118
|
-
// SDK
|
|
119
|
-
generalParameter[TapOpenlogParamConstants.
|
|
120
|
-
// SDK 运行平台
|
|
121
|
-
generalParameter[TapOpenlogParamConstants.PARAM_PLATFORM] = "PC";
|
|
122
|
-
// 埋点版本号(预留字段),当前全为1
|
|
123
|
-
generalParameter[TapOpenlogParamConstants.PARAM_TRACK_CODE] = "1";
|
|
137
|
+
// SDK生成的设备唯一标识
|
|
138
|
+
generalParameter[TapOpenlogParamConstants.PARAM_DEVICE_ID] = SystemInfo.deviceUniqueIdentifier;
|
|
124
139
|
// SDK生成的设备一次安装的唯一标识
|
|
125
140
|
generalParameter[TapOpenlogParamConstants.PARAM_INSTALL_UUID] = Identity.InstallationId;
|
|
126
141
|
// 设备品牌,eg: Xiaomi
|
|
@@ -145,46 +160,34 @@ namespace TapSDK.Core.Standalone.Internal.Openlog
|
|
|
145
160
|
generalParameter[TapOpenlogParamConstants.PARAM_TOTAL_RAM] = DeviceInfo.RAM;
|
|
146
161
|
// 芯片型号,eg:Qualcomm Technologies, Inc SM7250
|
|
147
162
|
generalParameter[TapOpenlogParamConstants.PARAM_HARDWARE] = SystemInfo.processorType;
|
|
148
|
-
// SDK
|
|
149
|
-
generalParameter[TapOpenlogParamConstants.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
private void InflateGeneralProperties(Dictionary<string, string> props)
|
|
153
|
-
{
|
|
154
|
-
if (generalParameter != null)
|
|
155
|
-
{
|
|
156
|
-
foreach (KeyValuePair<string, string> kv in generalParameter)
|
|
157
|
-
{
|
|
158
|
-
props[kv.Key] = kv.Value;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
163
|
+
// SDK设置的地区,例如 zh_CN
|
|
164
|
+
generalParameter[TapOpenlogParamConstants.PARAM_SDK_LOCALE] = Tracker.getServerLanguage();
|
|
165
|
+
// taptap的用户ID的外显ID(加密)
|
|
166
|
+
generalParameter[TapOpenlogParamConstants.PARAM_OPEN_ID] = openid;
|
|
161
167
|
}
|
|
162
168
|
|
|
163
|
-
private
|
|
169
|
+
private static Dictionary<string, string> InflateDynamicProperties()
|
|
164
170
|
{
|
|
165
|
-
|
|
171
|
+
Dictionary<string, string> props = new Dictionary<string, string>();
|
|
166
172
|
// 客户端时区,eg:Asia/Shanghai
|
|
167
173
|
props[TapOpenlogParamConstants.PARAM_TIMEZONE] = "";
|
|
168
|
-
// SDK
|
|
169
|
-
props[TapOpenlogParamConstants.
|
|
170
|
-
// SDK 模块版本号
|
|
171
|
-
props[TapOpenlogParamConstants.PARAM_TAPSDK_VERSION] = sdkProjectVersion;
|
|
172
|
-
// SDK设置的地区,例如 zh_CN
|
|
173
|
-
props[TapOpenlogParamConstants.PARAM_SDK_LOCALE] = Tracker.getServerLanguage();
|
|
174
|
+
// SDK 产物类型
|
|
175
|
+
props[TapOpenlogParamConstants.PARAM_TAPSDK_ARTIFACT] = "Unity";
|
|
174
176
|
// 游戏账号 ID(非角色 ID)
|
|
175
|
-
props[TapOpenlogParamConstants.PARAM_GAME_USER_ID] = TapCoreStandalone.User.Id;
|
|
177
|
+
props[TapOpenlogParamConstants.PARAM_GAME_USER_ID] = TapCoreStandalone.User.Id ?? "";
|
|
178
|
+
// taptap的用户ID的外显ID(加密)
|
|
179
|
+
props[TapOpenlogParamConstants.PARAM_OPEN_ID] = openid ?? "";
|
|
176
180
|
// SDK生成的设备全局唯一标识
|
|
177
181
|
props[TapOpenlogParamConstants.PARAM_GID] = "";
|
|
178
|
-
// SDK生成的设备唯一标识
|
|
179
|
-
props[TapOpenlogParamConstants.PARAM_DEVICE_ID] = SystemInfo.deviceUniqueIdentifier;
|
|
180
182
|
// 设备可用存储空间(磁盘),单位B
|
|
181
183
|
props[TapOpenlogParamConstants.PARAM_ROM] = "0";
|
|
182
184
|
// 设备可用内存,单位B
|
|
183
185
|
props[TapOpenlogParamConstants.PARAM_RAM] = "0";
|
|
184
|
-
// taptap的用户ID的外显ID(加密)
|
|
185
|
-
props[TapOpenlogParamConstants.PARAM_OPEN_ID] = openid;
|
|
186
186
|
// 网络类型,eg:wifi, mobile
|
|
187
187
|
props[TapOpenlogParamConstants.PARAM_NETWORK_TYPE] = "";
|
|
188
|
+
// SDK设置的地区,例如 zh_CN
|
|
189
|
+
props[TapOpenlogParamConstants.PARAM_SDK_LOCALE] = Tracker.getServerLanguage();
|
|
190
|
+
return props;
|
|
188
191
|
}
|
|
189
192
|
}
|
|
190
193
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
namespace TapSDK.Core.Standalone.Internal.Openlog
|
|
2
|
+
{
|
|
3
|
+
internal class TapOpenlogStartParamConstants
|
|
4
|
+
{
|
|
5
|
+
public const string PARAM_REGION = "region";
|
|
6
|
+
public const string PARAM_LOG_TO_CONSOLE = "log_to_console";
|
|
7
|
+
public const string PARAM_LOG_LEVEL = "log_level";
|
|
8
|
+
public const string PARAM_DATA_DIR = "data_dir";
|
|
9
|
+
public const string PARAM_ENV = "env";
|
|
10
|
+
public const string PARAM_PLATFORM = "platform";
|
|
11
|
+
public const string PARAM_UA = "ua";
|
|
12
|
+
public const string PARAM_CLIENT_ID = "client_id";
|
|
13
|
+
public const string PARAM_CLIENT_TOKEN = "client_token";
|
|
14
|
+
public const string PARAM_MODULES = "modules";
|
|
15
|
+
|
|
16
|
+
// Common parameters
|
|
17
|
+
public const string PARAM_COMMON = "common";
|
|
18
|
+
|
|
19
|
+
// App duration parameters
|
|
20
|
+
public const string PARAM_APP_DURATION = "app_duration";
|
|
21
|
+
public const string PARAM_TAPSDK_VERSION = "tapsdk_version";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Runtime.InteropServices;
|
|
3
|
+
|
|
4
|
+
namespace TapSDK.Core.Standalone.Internal.Openlog
|
|
5
|
+
{
|
|
6
|
+
internal class TapOpenlogWrapper
|
|
7
|
+
{
|
|
8
|
+
|
|
9
|
+
#if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
|
|
10
|
+
internal const string DllName = "tapsdkcore";
|
|
11
|
+
#elif UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX
|
|
12
|
+
internal const string DllName = "libtapsdkcorecpp";
|
|
13
|
+
#endif
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* 初始化接口,只需要调用一次。
|
|
17
|
+
*
|
|
18
|
+
* cfg 初始化配置,JSON 格式:
|
|
19
|
+
*
|
|
20
|
+
{
|
|
21
|
+
"region": 2,
|
|
22
|
+
"log_to_console": 1,
|
|
23
|
+
"log_level": 1,
|
|
24
|
+
"data_dir": "/tmp",
|
|
25
|
+
"env": "local",
|
|
26
|
+
"platform": "abc",
|
|
27
|
+
"ua": "TapSDK-Android/3.28.0",
|
|
28
|
+
"client_id": "uZ8Yy6cSXVOR6AMRPj",
|
|
29
|
+
"client_token": "AVhR1Bu9qfLR1cGbZMAdZ5rzJSxfoEiQaFf1T2P7",
|
|
30
|
+
"modules": [
|
|
31
|
+
"app_duration"
|
|
32
|
+
],
|
|
33
|
+
"common": {
|
|
34
|
+
"pn": "TapSDK",
|
|
35
|
+
"app_version_code": "123",
|
|
36
|
+
"app_version": "1.2.3",
|
|
37
|
+
"app_package_name": "",
|
|
38
|
+
"install_uuid": "",
|
|
39
|
+
"device_id": "123456",
|
|
40
|
+
"caid": "",
|
|
41
|
+
"dv": "",
|
|
42
|
+
"md": "",
|
|
43
|
+
"hardware": "",
|
|
44
|
+
"cpu": "",
|
|
45
|
+
"cpu_abis": "",
|
|
46
|
+
"os": "android",
|
|
47
|
+
"sv": "",
|
|
48
|
+
"width": "",
|
|
49
|
+
"height": "",
|
|
50
|
+
"total_rom": "",
|
|
51
|
+
"total_ram": "",
|
|
52
|
+
"open_id": "",
|
|
53
|
+
"tds_user_id": "",
|
|
54
|
+
"sdk_locale": ""
|
|
55
|
+
}
|
|
56
|
+
"app_duration": {
|
|
57
|
+
"tapsdk_version": ""
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
*
|
|
61
|
+
* - log_level 取值:1 Trace、2 Debug、3 Info、4 Warn、5 Error、6 完全不输出
|
|
62
|
+
* - region 取值:0 国内、1 海外、2 RND
|
|
63
|
+
* - modules 取值:app_duration(开启时长埋点)。如果 modules 不传,或者为空,
|
|
64
|
+
* 则仅开启 OpenLog 功能,不会上报游戏时长
|
|
65
|
+
*
|
|
66
|
+
* commonVariablesGetter 用于获取运行时会发生变化的公参
|
|
67
|
+
*
|
|
68
|
+
* 成功返回 0,失败返回 -1
|
|
69
|
+
*/
|
|
70
|
+
[DllImport(DllName, CallingConvention = CallingConvention.Cdecl)]
|
|
71
|
+
internal static extern int TdkOnAppStarted(string cfg, CommonVariablesGetter commonVariablesGetter, FreeStringCallback freeString);
|
|
72
|
+
|
|
73
|
+
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
74
|
+
internal delegate IntPtr CommonVariablesGetter();
|
|
75
|
+
|
|
76
|
+
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
|
77
|
+
internal delegate void FreeStringCallback(IntPtr intPtr);
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* App 退出时调用,只需要调用一次。
|
|
81
|
+
*/
|
|
82
|
+
[DllImport(DllName)]
|
|
83
|
+
internal static extern void TdkOnAppStopped();
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* 启用功能模块,如:app_duration
|
|
87
|
+
*
|
|
88
|
+
* modules JSON 数组,如:["app_duration"]
|
|
89
|
+
*
|
|
90
|
+
*/
|
|
91
|
+
[DllImport(DllName)]
|
|
92
|
+
internal static extern void TdkEnableModules(string modules);
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* 禁用功能模块,如:app_duration
|
|
96
|
+
*
|
|
97
|
+
* modules JSON 数组,如:["app_duration"]
|
|
98
|
+
*
|
|
99
|
+
*/
|
|
100
|
+
[DllImport(DllName)]
|
|
101
|
+
internal static extern void TdkDisableModules(string modules);
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* 需要发送埋点日志时调用。
|
|
105
|
+
* SDK 内部会整合初始化接口传入的公参、extraArgsFunc 返回的公参,以及 log 里的业务参数,
|
|
106
|
+
* 然后再发送到 OpenLog 服务端
|
|
107
|
+
*
|
|
108
|
+
* logstore 如:tapsdk、tapsdk-apm
|
|
109
|
+
* log 埋点日志,仅需传递业务参数,JSON 格式:{"action":"xxx", "open_id":"yyy","tds_user_id":"zzz"}
|
|
110
|
+
*/
|
|
111
|
+
[DllImport(DllName)]
|
|
112
|
+
internal static extern void TdkOpenLog(string logStore, string logContent);
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* 用户登录成功时调用。
|
|
116
|
+
*
|
|
117
|
+
* userInfo 用户信息,JSON 格式:{"open_id":"","tds_user_id":""}
|
|
118
|
+
*/
|
|
119
|
+
[DllImport(DllName)]
|
|
120
|
+
internal static extern void TdkOnLogin(string userInfo);
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* 用户登出时调用。
|
|
124
|
+
*/
|
|
125
|
+
[DllImport(DllName)]
|
|
126
|
+
internal static extern void TdkOnLogout();
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* 用户切到后台时调用。
|
|
130
|
+
*/
|
|
131
|
+
[DllImport(DllName)]
|
|
132
|
+
internal static extern void TdkOnForeground();
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* 游戏切回前台时调用。
|
|
136
|
+
*/
|
|
137
|
+
[DllImport(DllName)]
|
|
138
|
+
internal static extern void TdkOnBackground();
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* 设置额外的时长模块日志参数,JSON K/V 格式。每次调用这个接口时,会用最新得到的参数,替换原有参数。
|
|
142
|
+
*
|
|
143
|
+
* params 额外日志参数,JSON 格式:{"K1":"V1","K2":"V2","K3":"V3"}
|
|
144
|
+
*/
|
|
145
|
+
[DllImport(DllName)]
|
|
146
|
+
internal static extern void TdkSetExtraAppDurationParams(string paramsJson);
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* 设置日志等级
|
|
150
|
+
*/
|
|
151
|
+
[DllImport(DllName)]
|
|
152
|
+
internal static extern void TdkSetLogLevel(int logLevel, int logToConsole);
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* 代码版本,如:1.2.5
|
|
156
|
+
*/
|
|
157
|
+
[DllImport(DllName)]
|
|
158
|
+
internal static extern IntPtr TdkVersion();
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* git commit 版本,如:98f5d81a0fdcab9a755878b3e825c2cb510e5196
|
|
162
|
+
*/
|
|
163
|
+
[DllImport(DllName)]
|
|
164
|
+
internal static extern IntPtr TdkGitCommit();
|
|
165
|
+
|
|
166
|
+
// 用于返回 TdkVersion 的封装方法
|
|
167
|
+
public static string GetTdkVersion()
|
|
168
|
+
{
|
|
169
|
+
return Marshal.PtrToStringAnsi(TdkVersion());
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// 用于返回 TdkGitCommit 的封装方法
|
|
173
|
+
public static string GetTdkGitCommit()
|
|
174
|
+
{
|
|
175
|
+
return Marshal.PtrToStringAnsi(TdkGitCommit());
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
@@ -34,7 +34,6 @@ namespace TapSDK.Core.Standalone
|
|
|
34
34
|
/// </summary>
|
|
35
35
|
public TapCoreStandalone()
|
|
36
36
|
{
|
|
37
|
-
Debug.Log("TapCoStandalone constructor");
|
|
38
37
|
// Instantiate modules
|
|
39
38
|
Prefs = new Prefs();
|
|
40
39
|
Tracker = new Tracker();
|
|
@@ -64,9 +63,11 @@ namespace TapSDK.Core.Standalone
|
|
|
64
63
|
/// <param name="otherOptions">Additional TapCore SDK options.</param>
|
|
65
64
|
public void Init(TapTapSdkOptions coreOption, TapTapSdkBaseOptions[] otherOptions)
|
|
66
65
|
{
|
|
67
|
-
TapLog.Log("SDK
|
|
66
|
+
TapLog.Log("SDK Init Options : ", "coreOption : " + JsonConvert.SerializeObject(coreOption) + "\notherOptions : " + JsonConvert.SerializeObject(otherOptions));
|
|
68
67
|
coreOptions = coreOption;
|
|
69
68
|
|
|
69
|
+
TapOpenlogStandalone.Init();
|
|
70
|
+
|
|
70
71
|
var path = Path.Combine(Application.persistentDataPath, Constants.ClientSettingsFileName);
|
|
71
72
|
if (File.Exists(path))
|
|
72
73
|
{
|
|
@@ -76,6 +77,14 @@ namespace TapSDK.Core.Standalone
|
|
|
76
77
|
{
|
|
77
78
|
TapGatekeeper tapGatekeeper = JsonConvert.DeserializeObject<TapGatekeeper>(clientSettings);
|
|
78
79
|
SetAutoEvent(tapGatekeeper);
|
|
80
|
+
if (tapGatekeeper.Switch?.Heartbeat == true)
|
|
81
|
+
{
|
|
82
|
+
TapAppDurationStandalone.Enable();
|
|
83
|
+
}
|
|
84
|
+
else
|
|
85
|
+
{
|
|
86
|
+
TapAppDurationStandalone.Disable();
|
|
87
|
+
}
|
|
79
88
|
gatekeeperData = tapGatekeeper;
|
|
80
89
|
}
|
|
81
90
|
catch (System.Exception e)
|
|
@@ -86,7 +95,6 @@ namespace TapSDK.Core.Standalone
|
|
|
86
95
|
|
|
87
96
|
Tracker.Init();
|
|
88
97
|
|
|
89
|
-
TapOpenlogStandalone.Init();
|
|
90
98
|
requestClientSetting();
|
|
91
99
|
}
|
|
92
100
|
|
|
@@ -138,6 +146,14 @@ namespace TapSDK.Core.Standalone
|
|
|
138
146
|
onSuccess: (data) =>
|
|
139
147
|
{
|
|
140
148
|
SetAutoEvent(data);
|
|
149
|
+
if (data.Switch?.Heartbeat == true)
|
|
150
|
+
{
|
|
151
|
+
TapAppDurationStandalone.Enable();
|
|
152
|
+
}
|
|
153
|
+
else
|
|
154
|
+
{
|
|
155
|
+
TapAppDurationStandalone.Disable();
|
|
156
|
+
}
|
|
141
157
|
gatekeeperData = data;
|
|
142
158
|
// 把 data 存储在本地
|
|
143
159
|
saveClientSettings(data);
|
package/package.json
CHANGED
|
@@ -1,39 +0,0 @@
|
|
|
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
|
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
}
|