com.taptap.sdk.core 4.3.0-aplha.5
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/BuildTargetUtils.cs +14 -0
- package/Editor/BuildTargetUtils.cs.meta +11 -0
- package/Editor/LinkXMLGenerator.cs +70 -0
- package/Editor/LinkXMLGenerator.cs.meta +11 -0
- package/Editor/Plist.cs +954 -0
- package/Editor/Plist.cs.meta +3 -0
- package/Editor/SDKLinkProcessBuild.cs +119 -0
- package/Editor/SDKLinkProcessBuild.cs.meta +11 -0
- package/Editor/TapFileHelper.cs +168 -0
- package/Editor/TapFileHelper.cs.meta +3 -0
- package/Editor/TapSDK.Core.Editor.asmdef +15 -0
- package/Editor/TapSDK.Core.Editor.asmdef.meta +7 -0
- package/Editor/TapSDKCoreCompile.cs +284 -0
- package/Editor/TapSDKCoreCompile.cs.meta +3 -0
- package/Editor/TapSDKCoreIOSProcessor.cs +74 -0
- package/Editor/TapSDKCoreIOSProcessor.cs.meta +3 -0
- package/Editor/UI/ScrollViewEditor.cs +267 -0
- package/Editor/UI/ScrollViewEditor.cs.meta +12 -0
- package/Editor/UI/ScrollViewExEditor.cs +34 -0
- package/Editor/UI/ScrollViewExEditor.cs.meta +12 -0
- package/Editor/UI/TapSDK.UI.Editor.asmdef +17 -0
- package/Editor/UI/TapSDK.UI.Editor.asmdef.meta +7 -0
- package/Editor/UI.meta +9 -0
- package/Editor.meta +8 -0
- package/Mobile/Editor/NativeDependencies.xml +22 -0
- package/Mobile/Editor/NativeDependencies.xml.meta +7 -0
- package/Mobile/Editor/TapCommonMobileProcessBuild.cs +20 -0
- package/Mobile/Editor/TapCommonMobileProcessBuild.cs.meta +11 -0
- package/Mobile/Editor/TapSDK.Core.Mobile.Editor.asmdef +17 -0
- package/Mobile/Editor/TapSDK.Core.Mobile.Editor.asmdef.meta +7 -0
- package/Mobile/Editor.meta +8 -0
- package/Mobile/Runtime/AndroidNativeWrapper.cs +50 -0
- package/Mobile/Runtime/AndroidNativeWrapper.cs.meta +11 -0
- package/Mobile/Runtime/Bridge.cs +84 -0
- package/Mobile/Runtime/Bridge.cs.meta +11 -0
- package/Mobile/Runtime/BridgeAndroid.cs +73 -0
- package/Mobile/Runtime/BridgeAndroid.cs.meta +11 -0
- package/Mobile/Runtime/BridgeCallback.cs +35 -0
- package/Mobile/Runtime/BridgeCallback.cs.meta +11 -0
- package/Mobile/Runtime/BridgeIOS.cs +113 -0
- package/Mobile/Runtime/BridgeIOS.cs.meta +11 -0
- package/Mobile/Runtime/Command.cs +119 -0
- package/Mobile/Runtime/Command.cs.meta +11 -0
- package/Mobile/Runtime/Constants.cs +9 -0
- package/Mobile/Runtime/Constants.cs.meta +11 -0
- package/Mobile/Runtime/EngineBridgeInitializer.cs +33 -0
- package/Mobile/Runtime/EngineBridgeInitializer.cs.meta +11 -0
- package/Mobile/Runtime/IBridge.cs +15 -0
- package/Mobile/Runtime/IBridge.cs.meta +11 -0
- package/Mobile/Runtime/IOSNativeWrapper.cs +273 -0
- package/Mobile/Runtime/IOSNativeWrapper.cs.meta +11 -0
- package/Mobile/Runtime/Result.cs +37 -0
- package/Mobile/Runtime/Result.cs.meta +11 -0
- package/Mobile/Runtime/TapCoreMobile.cs +71 -0
- package/Mobile/Runtime/TapCoreMobile.cs.meta +11 -0
- package/Mobile/Runtime/TapEventMobile.cs +265 -0
- package/Mobile/Runtime/TapEventMobile.cs.meta +11 -0
- package/Mobile/Runtime/TapSDK.Core.Mobile.Runtime.asmdef +18 -0
- package/Mobile/Runtime/TapSDK.Core.Mobile.Runtime.asmdef.meta +7 -0
- package/Mobile/Runtime/TapUUID.cs +9 -0
- package/Mobile/Runtime/TapUUID.cs.meta +11 -0
- package/Mobile/Runtime.meta +8 -0
- package/Mobile.meta +8 -0
- package/Plugins/iOS.meta +8 -0
- package/Plugins.meta +8 -0
- package/Resources/Fonts/taptap-sdk-bold.ttf +0 -0
- package/Resources/Fonts/taptap-sdk-bold.ttf.meta +22 -0
- package/Resources/Fonts/taptap-sdk.ttf +0 -0
- package/Resources/Fonts/taptap-sdk.ttf.meta +21 -0
- package/Resources/Fonts.meta +8 -0
- package/Resources/Loading.prefab +260 -0
- package/Resources/Loading.prefab.meta +7 -0
- package/Resources/TapCommonTip.prefab +194 -0
- package/Resources/TapCommonTip.prefab.meta +7 -0
- package/Resources/TapCommonToastBlack.prefab +528 -0
- package/Resources/TapCommonToastBlack.prefab.meta +7 -0
- package/Resources/TapCommonToastWhite.prefab +411 -0
- package/Resources/TapCommonToastWhite.prefab.meta +7 -0
- package/Resources/TapSDKCommonTapIcon-v2.png +0 -0
- package/Resources/TapSDKCommonTapIcon-v2.png.meta +128 -0
- package/Resources/TapSDKCommonTapIcon.png +0 -0
- package/Resources/TapSDKCommonTapIcon.png.meta +128 -0
- package/Resources/TapSDKCommonToastBg.png +0 -0
- package/Resources/TapSDKCommonToastBg.png.meta +128 -0
- package/Resources/TapSDKConstantUIRoot.prefab +100 -0
- package/Resources/TapSDKConstantUIRoot.prefab.meta +7 -0
- package/Resources/TapSDKUIRoot.prefab +100 -0
- package/Resources/TapSDKUIRoot.prefab.meta +7 -0
- package/Resources/TapTapBtn_White.png +0 -0
- package/Resources/TapTapBtn_White.png.meta +128 -0
- package/Resources/TapTapBtn_White_2.png +0 -0
- package/Resources/TapTapBtn_White_2.png.meta +128 -0
- package/Resources/ToastBackground.png +0 -0
- package/Resources/ToastBackground.png.meta +128 -0
- package/Resources/detail_bg.png +0 -0
- package/Resources/detail_bg.png.meta +92 -0
- package/Resources/success.png +0 -0
- package/Resources/success.png.meta +128 -0
- package/Resources/taptap-bg.png +0 -0
- package/Resources/taptap-bg.png.meta +140 -0
- package/Resources/taptap-close.png +0 -0
- package/Resources/taptap-close.png.meta +146 -0
- package/Resources/taptap-router-v2.png +0 -0
- package/Resources/taptap-router-v2.png.meta +128 -0
- package/Resources/taptap-router.png +0 -0
- package/Resources/taptap-router.png.meta +146 -0
- package/Resources/taptap-sdk-refresh 1.png +0 -0
- package/Resources/taptap-sdk-refresh 1.png.meta +128 -0
- package/Resources/taptap-toast-error.png +0 -0
- package/Resources/taptap-toast-error.png.meta +128 -0
- package/Resources/taptap-toast-info.png +0 -0
- package/Resources/taptap-toast-info.png.meta +128 -0
- package/Resources/taptap-toast-success.png +0 -0
- package/Resources/taptap-toast-success.png.meta +128 -0
- package/Resources/taptap-toast-warning.png +0 -0
- package/Resources/taptap-toast-warning.png.meta +128 -0
- package/Resources.meta +8 -0
- package/Runtime/Internal/Http/TapHttpClient.cs +176 -0
- package/Runtime/Internal/Http/TapHttpClient.cs.meta +11 -0
- package/Runtime/Internal/Http/TapHttpUtils.cs +83 -0
- package/Runtime/Internal/Http/TapHttpUtils.cs.meta +11 -0
- package/Runtime/Internal/Http.meta +8 -0
- package/Runtime/Internal/Init/IInitTask.cs +18 -0
- package/Runtime/Internal/Init/IInitTask.cs.meta +11 -0
- package/Runtime/Internal/Init.meta +8 -0
- package/Runtime/Internal/Json/TapJsonConverter.cs +40 -0
- package/Runtime/Internal/Json/TapJsonConverter.cs.meta +11 -0
- package/Runtime/Internal/Json.meta +8 -0
- package/Runtime/Internal/Platform/ITapCorePlatform.cs +12 -0
- package/Runtime/Internal/Platform/ITapCorePlatform.cs.meta +11 -0
- package/Runtime/Internal/Platform/ITapEventPlatform.cs +37 -0
- package/Runtime/Internal/Platform/ITapEventPlatform.cs.meta +11 -0
- package/Runtime/Internal/Platform/PlatformTypeUtils.cs +46 -0
- package/Runtime/Internal/Platform/PlatformTypeUtils.cs.meta +11 -0
- package/Runtime/Internal/Platform.meta +8 -0
- package/Runtime/Internal/UI/Base/Const.cs +27 -0
- package/Runtime/Internal/UI/Base/Const.cs.meta +11 -0
- package/Runtime/Internal/UI/Base/GraphicRaycasterBugFixed.cs +240 -0
- package/Runtime/Internal/UI/Base/GraphicRaycasterBugFixed.cs.meta +3 -0
- package/Runtime/Internal/UI/Base/LoadingPanelController.cs +29 -0
- package/Runtime/Internal/UI/Base/LoadingPanelController.cs.meta +11 -0
- package/Runtime/Internal/UI/Base/MonoSingleton.cs +102 -0
- package/Runtime/Internal/UI/Base/MonoSingleton.cs.meta +11 -0
- package/Runtime/Internal/UI/Base/Singleton.cs +29 -0
- package/Runtime/Internal/UI/Base/Singleton.cs.meta +11 -0
- package/Runtime/Internal/UI/Base/TipPanelController.cs +45 -0
- package/Runtime/Internal/UI/Base/TipPanelController.cs.meta +3 -0
- package/Runtime/Internal/UI/Base/ToastBlackPanelController.cs +95 -0
- package/Runtime/Internal/UI/Base/ToastBlackPanelController.cs.meta +11 -0
- package/Runtime/Internal/UI/Base/ToastWhitePanelController.cs +79 -0
- package/Runtime/Internal/UI/Base/ToastWhitePanelController.cs.meta +3 -0
- package/Runtime/Internal/UI/Base/UIManager.cs +724 -0
- package/Runtime/Internal/UI/Base/UIManager.cs.meta +11 -0
- package/Runtime/Internal/UI/Base.meta +8 -0
- package/Runtime/Internal/UI/BasePanel/BasePanelController.cs +385 -0
- package/Runtime/Internal/UI/BasePanel/BasePanelController.cs.meta +11 -0
- package/Runtime/Internal/UI/BasePanel.meta +8 -0
- package/Runtime/Internal/UI/Params/BasePanelConfig.cs +18 -0
- package/Runtime/Internal/UI/Params/BasePanelConfig.cs.meta +11 -0
- package/Runtime/Internal/UI/Params/IOpenPanelParameter.cs +7 -0
- package/Runtime/Internal/UI/Params/IOpenPanelParameter.cs.meta +11 -0
- package/Runtime/Internal/UI/Params.meta +8 -0
- package/Runtime/Internal/UI/ScrollViewEx/ObjPool/SimpleObjPool.cs +76 -0
- package/Runtime/Internal/UI/ScrollViewEx/ObjPool/SimpleObjPool.cs.meta +12 -0
- package/Runtime/Internal/UI/ScrollViewEx/ObjPool.meta +9 -0
- package/Runtime/Internal/UI/ScrollViewEx/ScrollView/ScrollView.cs +828 -0
- package/Runtime/Internal/UI/ScrollViewEx/ScrollView/ScrollView.cs.meta +12 -0
- package/Runtime/Internal/UI/ScrollViewEx/ScrollView/ScrollViewEx.cs +245 -0
- package/Runtime/Internal/UI/ScrollViewEx/ScrollView/ScrollViewEx.cs.meta +12 -0
- package/Runtime/Internal/UI/ScrollViewEx/ScrollView.meta +9 -0
- package/Runtime/Internal/UI/ScrollViewEx.meta +8 -0
- package/Runtime/Internal/UI.meta +8 -0
- package/Runtime/Internal/Utils/BridgeUtils.cs +29 -0
- package/Runtime/Internal/Utils/BridgeUtils.cs.meta +11 -0
- package/Runtime/Internal/Utils/ImageUtils.cs +147 -0
- package/Runtime/Internal/Utils/ImageUtils.cs.meta +11 -0
- package/Runtime/Internal/Utils/TapLoom.cs +155 -0
- package/Runtime/Internal/Utils/TapLoom.cs.meta +11 -0
- package/Runtime/Internal/Utils/UrlUtils.cs +34 -0
- package/Runtime/Internal/Utils/UrlUtils.cs.meta +11 -0
- package/Runtime/Internal/Utils.meta +8 -0
- package/Runtime/Internal.meta +8 -0
- package/Runtime/Public/DataStorage.cs +141 -0
- package/Runtime/Public/DataStorage.cs.meta +11 -0
- package/Runtime/Public/ITapPropertiesProxy.cs +6 -0
- package/Runtime/Public/ITapPropertiesProxy.cs.meta +11 -0
- package/Runtime/Public/Json.cs +636 -0
- package/Runtime/Public/Json.cs.meta +11 -0
- package/Runtime/Public/Log/TapLogLevel.cs +7 -0
- package/Runtime/Public/Log/TapLogLevel.cs.meta +11 -0
- package/Runtime/Public/Log/TapLogger.cs +48 -0
- package/Runtime/Public/Log/TapLogger.cs.meta +11 -0
- package/Runtime/Public/Log.meta +8 -0
- package/Runtime/Public/Platform.cs +27 -0
- package/Runtime/Public/Platform.cs.meta +11 -0
- package/Runtime/Public/RegionType.cs +8 -0
- package/Runtime/Public/RegionType.cs.meta +11 -0
- package/Runtime/Public/SafeDictionary.cs +27 -0
- package/Runtime/Public/SafeDictionary.cs.meta +11 -0
- package/Runtime/Public/TapError.cs +62 -0
- package/Runtime/Public/TapError.cs.meta +11 -0
- package/Runtime/Public/TapErrorCode.cs +44 -0
- package/Runtime/Public/TapErrorCode.cs.meta +11 -0
- package/Runtime/Public/TapException.cs +24 -0
- package/Runtime/Public/TapException.cs.meta +11 -0
- package/Runtime/Public/TapLanguage.cs +21 -0
- package/Runtime/Public/TapLanguage.cs.meta +11 -0
- package/Runtime/Public/TapLocalizeManager.cs +128 -0
- package/Runtime/Public/TapLocalizeManager.cs.meta +11 -0
- package/Runtime/Public/TapTapEvent.cs +93 -0
- package/Runtime/Public/TapTapEvent.cs.meta +11 -0
- package/Runtime/Public/TapTapSDK.cs +96 -0
- package/Runtime/Public/TapTapSDK.cs.meta +11 -0
- package/Runtime/Public/TapTapSDKCoreOptions.cs +104 -0
- package/Runtime/Public/TapTapSDKCoreOptions.cs.meta +11 -0
- package/Runtime/Public.meta +8 -0
- package/Runtime/TapSDK.Core.Runtime.asmdef +3 -0
- package/Runtime/TapSDK.Core.Runtime.asmdef.meta +7 -0
- package/Runtime.meta +8 -0
- package/Standalone/Editor/TapCoreStandaloneProcessBuild.cs +20 -0
- package/Standalone/Editor/TapCoreStandaloneProcessBuild.cs.meta +11 -0
- package/Standalone/Editor/TapSDK.Core.Standalone.Editor.asmdef +17 -0
- package/Standalone/Editor/TapSDK.Core.Standalone.Editor.asmdef.meta +7 -0
- package/Standalone/Editor.meta +8 -0
- package/Standalone/Plugins/macOS/TapDBDeviceInfo.bundle/Contents/Info.plist +46 -0
- package/Standalone/Plugins/macOS/TapDBDeviceInfo.bundle/Contents/Info.plist.meta +7 -0
- package/Standalone/Plugins/macOS/TapDBDeviceInfo.bundle/Contents/MacOS/TapDBDeviceInfo +0 -0
- package/Standalone/Plugins/macOS/TapDBDeviceInfo.bundle/Contents/MacOS/TapDBDeviceInfo.meta +7 -0
- package/Standalone/Plugins/macOS/TapDBDeviceInfo.bundle/Contents/MacOS.meta +8 -0
- package/Standalone/Plugins/macOS/TapDBDeviceInfo.bundle/Contents/_CodeSignature/CodeResources +115 -0
- package/Standalone/Plugins/macOS/TapDBDeviceInfo.bundle/Contents/_CodeSignature/CodeResources.meta +7 -0
- package/Standalone/Plugins/macOS/TapDBDeviceInfo.bundle/Contents/_CodeSignature.meta +8 -0
- package/Standalone/Plugins/macOS/TapDBDeviceInfo.bundle/Contents.meta +8 -0
- package/Standalone/Plugins/macOS/TapDBDeviceInfo.bundle.meta +33 -0
- package/Standalone/Plugins/macOS.meta +8 -0
- package/Standalone/Plugins.meta +8 -0
- package/Standalone/Runtime/Internal/Constants.cs +37 -0
- package/Standalone/Runtime/Internal/Constants.cs.meta +11 -0
- package/Standalone/Runtime/Internal/DeviceInfo.cs +152 -0
- package/Standalone/Runtime/Internal/DeviceInfo.cs.meta +11 -0
- package/Standalone/Runtime/Internal/EventSender.cs +239 -0
- package/Standalone/Runtime/Internal/EventSender.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Http/HttpClient.cs +211 -0
- package/Standalone/Runtime/Internal/Http/HttpClient.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Http/NetUtils.cs +48 -0
- package/Standalone/Runtime/Internal/Http/NetUtils.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Http/TimeUtil.cs +30 -0
- package/Standalone/Runtime/Internal/Http/TimeUtil.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Http.meta +8 -0
- package/Standalone/Runtime/Internal/Identity.cs +43 -0
- package/Standalone/Runtime/Internal/Identity.cs.meta +11 -0
- package/Standalone/Runtime/Internal/PlayRecorder.cs +53 -0
- package/Standalone/Runtime/Internal/PlayRecorder.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Prefs.cs +85 -0
- package/Standalone/Runtime/Internal/Prefs.cs.meta +11 -0
- package/Standalone/Runtime/Internal/Tracker.cs +318 -0
- package/Standalone/Runtime/Internal/Tracker.cs.meta +11 -0
- package/Standalone/Runtime/Internal/User.cs +51 -0
- package/Standalone/Runtime/Internal/User.cs.meta +11 -0
- package/Standalone/Runtime/Internal.meta +8 -0
- package/Standalone/Runtime/Public/EventManager.cs +41 -0
- package/Standalone/Runtime/Public/EventManager.cs.meta +11 -0
- package/Standalone/Runtime/Public/TapCoreStandalone.cs +197 -0
- package/Standalone/Runtime/Public/TapCoreStandalone.cs.meta +11 -0
- package/Standalone/Runtime/Public/TapEventStandalone.cs +281 -0
- package/Standalone/Runtime/Public/TapEventStandalone.cs.meta +11 -0
- package/Standalone/Runtime/Public.meta +8 -0
- package/Standalone/Runtime/TapSDK.Core.Standalone.Runtime.asmdef +21 -0
- package/Standalone/Runtime/TapSDK.Core.Standalone.Runtime.asmdef.meta +7 -0
- package/Standalone/Runtime.meta +8 -0
- package/Standalone.meta +8 -0
- package/package.json +8 -0
- package/package.json.meta +7 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
|
|
4
|
+
namespace TapSDK.Core.Standalone.Internal {
|
|
5
|
+
|
|
6
|
+
public static class TimeUtil
|
|
7
|
+
{
|
|
8
|
+
private static int timeOffset = 0;
|
|
9
|
+
|
|
10
|
+
private static void SetTimeOffset(int offset)
|
|
11
|
+
{
|
|
12
|
+
timeOffset = offset;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// 获取当前时间的秒级时间戳
|
|
16
|
+
public static int GetCurrentTime()
|
|
17
|
+
{
|
|
18
|
+
DateTime epochStart = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
|
|
19
|
+
TimeSpan timeSpan = DateTime.UtcNow - epochStart;
|
|
20
|
+
return (int)timeSpan.TotalSeconds + timeOffset;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public static void FixTime(int time)
|
|
24
|
+
{
|
|
25
|
+
Debug.Log("FixTime called with time: " + time);
|
|
26
|
+
SetTimeOffset(time - (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using UnityEngine;
|
|
3
|
+
|
|
4
|
+
namespace TapSDK.Core.Standalone.Internal {
|
|
5
|
+
public class Identity {
|
|
6
|
+
public static readonly string DEVICE_ID_KEY = "tapdb_unique_id";
|
|
7
|
+
public static readonly string PERSISTENT_ID_KEY = "tapdb_persist_id";
|
|
8
|
+
public static readonly string INSTALLATION_ID_KEY = "tapdb_install_id";
|
|
9
|
+
|
|
10
|
+
public static string DeviceId {
|
|
11
|
+
get {
|
|
12
|
+
string deviceId = TapCoreStandalone.Prefs.Get<string>(DEVICE_ID_KEY);
|
|
13
|
+
if (string.IsNullOrWhiteSpace(deviceId)) {
|
|
14
|
+
deviceId = SystemInfo.deviceUniqueIdentifier;
|
|
15
|
+
TapCoreStandalone.Prefs.Set(DEVICE_ID_KEY, deviceId);
|
|
16
|
+
}
|
|
17
|
+
return deviceId;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public static string PersistentId {
|
|
22
|
+
get {
|
|
23
|
+
string persistentId = TapCoreStandalone.Prefs.Get<string>(PERSISTENT_ID_KEY);
|
|
24
|
+
if (string.IsNullOrWhiteSpace(persistentId)) {
|
|
25
|
+
persistentId = Guid.NewGuid().ToString();
|
|
26
|
+
TapCoreStandalone.Prefs.Set(PERSISTENT_ID_KEY, persistentId);
|
|
27
|
+
}
|
|
28
|
+
return persistentId;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public static string InstallationId {
|
|
33
|
+
get {
|
|
34
|
+
string installationId = TapCoreStandalone.Prefs.Get<string>(INSTALLATION_ID_KEY);
|
|
35
|
+
if (string.IsNullOrWhiteSpace(installationId)) {
|
|
36
|
+
installationId = Guid.NewGuid().ToString();
|
|
37
|
+
TapCoreStandalone.Prefs.Set(INSTALLATION_ID_KEY, installationId);
|
|
38
|
+
}
|
|
39
|
+
return installationId;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
using System.Threading;
|
|
2
|
+
using System.Threading.Tasks;
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
using UnityEngine;
|
|
5
|
+
|
|
6
|
+
namespace TapSDK.Core.Standalone.Internal {
|
|
7
|
+
public class PlayRecorder {
|
|
8
|
+
internal static readonly string PLAYED_DURATION_KEY = "tapdb_played_duration";
|
|
9
|
+
|
|
10
|
+
/// <summary>
|
|
11
|
+
/// 记录间隔
|
|
12
|
+
/// </summary>
|
|
13
|
+
private const int RECORD_INTERVAL = 2 * 1000;
|
|
14
|
+
|
|
15
|
+
private CancellationTokenSource cts;
|
|
16
|
+
|
|
17
|
+
/// <summary>
|
|
18
|
+
/// 启动记录
|
|
19
|
+
/// </summary>
|
|
20
|
+
public async void Start() {
|
|
21
|
+
if (cts != null && !cts.IsCancellationRequested) {
|
|
22
|
+
cts.Cancel();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
cts = new CancellationTokenSource();
|
|
26
|
+
while (Application.isPlaying) {
|
|
27
|
+
try {
|
|
28
|
+
await Task.Delay(RECORD_INTERVAL, cts.Token);
|
|
29
|
+
} catch (TaskCanceledException) {
|
|
30
|
+
break;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// 保存用户游玩时长
|
|
34
|
+
TapCoreStandalone.Prefs.AddOrUpdate(PLAYED_DURATION_KEY,
|
|
35
|
+
2L,
|
|
36
|
+
(k, v) => (long)v + 2);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/// <summary>
|
|
41
|
+
/// 结束记录并上报
|
|
42
|
+
/// </summary>
|
|
43
|
+
public void Stop() {
|
|
44
|
+
cts?.Cancel();
|
|
45
|
+
if (TapCoreStandalone.Prefs.TryRemove(PLAYED_DURATION_KEY, out long duration)) {
|
|
46
|
+
Dictionary<string, object> props = new Dictionary<string, object> {
|
|
47
|
+
{ "duration", duration }
|
|
48
|
+
};
|
|
49
|
+
TapCoreStandalone.Tracker.TrackEvent("play_game", props, true);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using System.Collections.Concurrent;
|
|
4
|
+
using System.Threading;
|
|
5
|
+
using System.Linq;
|
|
6
|
+
using System.IO;
|
|
7
|
+
using UnityEngine;
|
|
8
|
+
using TapSDK.Core;
|
|
9
|
+
|
|
10
|
+
namespace TapSDK.Core.Standalone.Internal {
|
|
11
|
+
public class Prefs {
|
|
12
|
+
internal static readonly string PERSISTENT_FILE_NAME = "tapdb_storage_v2";
|
|
13
|
+
|
|
14
|
+
private string persistentFilePath;
|
|
15
|
+
|
|
16
|
+
private readonly ConcurrentDictionary<string, object> data;
|
|
17
|
+
|
|
18
|
+
private readonly Thread persistThread;
|
|
19
|
+
|
|
20
|
+
private readonly AutoResetEvent persistEvent;
|
|
21
|
+
|
|
22
|
+
public Prefs() {
|
|
23
|
+
persistentFilePath = Path.Combine(Application.persistentDataPath, PERSISTENT_FILE_NAME);
|
|
24
|
+
if (File.Exists(persistentFilePath)) {
|
|
25
|
+
try {
|
|
26
|
+
string json = File.ReadAllText(persistentFilePath);
|
|
27
|
+
Dictionary<string, object> jsonData = Json.Deserialize(json) as Dictionary<string, object>;
|
|
28
|
+
ConcurrentDictionary<string, object> data = new ConcurrentDictionary<string, object>(jsonData);
|
|
29
|
+
} catch (Exception e) {
|
|
30
|
+
TapLogger.Error(e.Message);
|
|
31
|
+
File.Delete(persistentFilePath);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (data == null) {
|
|
35
|
+
data = new ConcurrentDictionary<string, object>();
|
|
36
|
+
}
|
|
37
|
+
persistEvent = new AutoResetEvent(false);
|
|
38
|
+
persistThread = new Thread(PersistProc) {
|
|
39
|
+
IsBackground = true
|
|
40
|
+
};
|
|
41
|
+
persistThread.Start();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public T Get<T>(string key) {
|
|
45
|
+
if (data.TryGetValue(key, out object val)) {
|
|
46
|
+
return (T)val;
|
|
47
|
+
}
|
|
48
|
+
return default;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public void Set<T>(string key, T value) {
|
|
52
|
+
data[key] = value;
|
|
53
|
+
persistEvent.Set();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public bool TryRemove<T>(string key, out T val) {
|
|
57
|
+
if (data.TryRemove(key, out object v)) {
|
|
58
|
+
val = (T)v;
|
|
59
|
+
persistEvent.Set();
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
val = default;
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public void AddOrUpdate(string key, object addValue, Func<string, object, object> updateValueFactory) {
|
|
67
|
+
data.AddOrUpdate(key, addValue, updateValueFactory);
|
|
68
|
+
persistEvent.Set();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
private void PersistProc() {
|
|
72
|
+
while (true) {
|
|
73
|
+
persistEvent.WaitOne();
|
|
74
|
+
try {
|
|
75
|
+
Dictionary<string, object> dict = data.ToArray()
|
|
76
|
+
.ToDictionary(kv => kv.Key, kv => kv.Value);
|
|
77
|
+
string json = Json.Serialize(dict);
|
|
78
|
+
File.WriteAllText(persistentFilePath, json);
|
|
79
|
+
} catch (Exception e) {
|
|
80
|
+
TapLogger.Error(e.Message);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Generic;
|
|
3
|
+
using TapSDK.Core.Standalone;
|
|
4
|
+
using System.Threading.Tasks;
|
|
5
|
+
using UnityEngine;
|
|
6
|
+
using TapSDK.Core.Internal.Utils;
|
|
7
|
+
|
|
8
|
+
namespace TapSDK.Core.Standalone.Internal {
|
|
9
|
+
public class Tracker {
|
|
10
|
+
|
|
11
|
+
private Dictionary<string, object> customProps;
|
|
12
|
+
|
|
13
|
+
private Dictionary<string, object> basicProps;
|
|
14
|
+
private Dictionary<string, object> commonProps;
|
|
15
|
+
|
|
16
|
+
private EventSender sender;
|
|
17
|
+
private IDynamicProperties dynamicPropsDelegate;
|
|
18
|
+
|
|
19
|
+
private static string session_uuid = generateUUID();
|
|
20
|
+
|
|
21
|
+
public void Init() {
|
|
22
|
+
basicProps = new Dictionary<string, object>();
|
|
23
|
+
commonProps = new Dictionary<string, object>();
|
|
24
|
+
|
|
25
|
+
var coreOptions = TapCoreStandalone.coreOptions;
|
|
26
|
+
customProps = Json.Deserialize(coreOptions.propertiesJson) as Dictionary<string, object>;
|
|
27
|
+
sender = new EventSender();
|
|
28
|
+
|
|
29
|
+
InitBasicProps();
|
|
30
|
+
if (TapCoreStandalone.enableAutoEvent) {
|
|
31
|
+
Dictionary<string, object> props = new Dictionary<string, object>(basicProps);
|
|
32
|
+
TrackEvent(Constants.DEVICE_LOGIN, props, true);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public void AddCommonProperty(string key, object value) {
|
|
37
|
+
commonProps[key] = value;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public void AddCommon(Dictionary<string, object> properties) {
|
|
41
|
+
foreach (KeyValuePair<string, object> kv in properties) {
|
|
42
|
+
commonProps[kv.Key] = kv.Value;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
public void ClearCommonProperty(string key) {
|
|
46
|
+
commonProps.Remove(key);
|
|
47
|
+
}
|
|
48
|
+
public void ClearCommonProperties(string[] keys) {
|
|
49
|
+
foreach (string key in keys) {
|
|
50
|
+
commonProps.Remove(key);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
public void ClearAllCommonProperties() {
|
|
54
|
+
commonProps.Clear();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
public void RegisterDynamicPropsDelegate(IDynamicProperties dynamicPropsDelegate) {
|
|
58
|
+
this.dynamicPropsDelegate = dynamicPropsDelegate;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public void LogPurchasedEvent(string orderID, string productName, Int64 amount, string currencyType, string paymentMethod, string properties){
|
|
62
|
+
var prop = Json.Deserialize(properties) as Dictionary<string, object>;
|
|
63
|
+
|
|
64
|
+
var data = new Dictionary<string, object> {
|
|
65
|
+
{ "order_id", orderID },
|
|
66
|
+
{ "product", productName },
|
|
67
|
+
{ "amount", amount },
|
|
68
|
+
{ "currency_type", currencyType },
|
|
69
|
+
{ "payment", paymentMethod }
|
|
70
|
+
};
|
|
71
|
+
if (prop != null) {
|
|
72
|
+
foreach (KeyValuePair<string, object> kv in prop) {
|
|
73
|
+
data[kv.Key] = kv.Value;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
TrackEvent("charge", data);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/// <summary>
|
|
80
|
+
/// 上报事件
|
|
81
|
+
/// </summary>
|
|
82
|
+
/// <param name="name"></param>
|
|
83
|
+
/// <param name="properties"></param>
|
|
84
|
+
/// <param name="isAutomationlly">是否为自动事件</param>
|
|
85
|
+
public void TrackEvent(string name, Dictionary<string, object> properties = null, bool isAutomationlly = false) {
|
|
86
|
+
|
|
87
|
+
Dictionary<string, object> props = new Dictionary<string, object>(basicProps);
|
|
88
|
+
|
|
89
|
+
if (commonProps != null) {
|
|
90
|
+
foreach (KeyValuePair<string, object> kv in commonProps) {
|
|
91
|
+
props[kv.Key] = kv.Value;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
Dictionary<string, object> dynamicProps = dynamicPropsDelegate?.GetDynamicProperties();
|
|
96
|
+
TapLogger.Debug("dynamicProps: " + dynamicProps);
|
|
97
|
+
if (dynamicProps != null) {
|
|
98
|
+
foreach (KeyValuePair<string, object> kv in dynamicProps) {
|
|
99
|
+
props[kv.Key] = kv.Value;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (name == Constants.DEVICE_LOGIN) { // Device login 事件带上初始化时的自定义属性
|
|
104
|
+
TapLogger.Debug("customProps: " + customProps);
|
|
105
|
+
if (customProps != null) {
|
|
106
|
+
foreach (KeyValuePair<string, object> kv in customProps) {
|
|
107
|
+
props[kv.Key] = kv.Value;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
props["t_log_id"] = generateUUID();
|
|
113
|
+
// 时间戳,毫秒级
|
|
114
|
+
props["timestamp"] = DateTimeOffset.Now.ToUnixTimeMilliseconds();
|
|
115
|
+
var open_id = OpenID;
|
|
116
|
+
if (!string.IsNullOrWhiteSpace(open_id)) {
|
|
117
|
+
props["open_id"] = open_id;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
TapLogger.Debug("properties: " + properties);
|
|
121
|
+
if (properties != null) {
|
|
122
|
+
foreach (KeyValuePair<string, object> kv in properties) {
|
|
123
|
+
props[kv.Key] = kv.Value;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
props["is_automatically_log"] = isAutomationlly ? "true" : "false";
|
|
128
|
+
|
|
129
|
+
var language = getServerLanguage();
|
|
130
|
+
props["sdk_locale"] = language;
|
|
131
|
+
props["lang_system"] = DeviceInfo.GetLanguage();
|
|
132
|
+
|
|
133
|
+
Dictionary<string, object> data = new Dictionary<string, object> {
|
|
134
|
+
{ "client_id", TapCoreStandalone.coreOptions.clientId },
|
|
135
|
+
{ "type", "track" },
|
|
136
|
+
{ "name", name },
|
|
137
|
+
{ "device_id", Identity.DeviceId },
|
|
138
|
+
{ "properties", props },
|
|
139
|
+
};
|
|
140
|
+
if (!string.IsNullOrWhiteSpace(TapCoreStandalone.User.Id)) {
|
|
141
|
+
data["user_id"] = TapCoreStandalone.User.Id;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
sender.Send(data);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/// <summary>
|
|
148
|
+
/// 上报设备属性变化
|
|
149
|
+
/// </summary>
|
|
150
|
+
/// <param name="type"></param>
|
|
151
|
+
/// <param name="properties"></param>
|
|
152
|
+
public void TrackDeviceProperties(string type, Dictionary<string, object> properties) {
|
|
153
|
+
if (string.IsNullOrWhiteSpace(Identity.DeviceId)) {
|
|
154
|
+
TapLogger.Error("DeviceId is NULL.");
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
Dictionary<string, object> baseProps = new Dictionary<string, object> {
|
|
159
|
+
{ "device_id", Identity.DeviceId }
|
|
160
|
+
};
|
|
161
|
+
_ = TrackPropertiesAsync(type, baseProps, properties);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/// <summary>
|
|
165
|
+
/// 上报玩家属性变化
|
|
166
|
+
/// </summary>
|
|
167
|
+
public void TrackUserProperties(string type, Dictionary<string, object> properties) {
|
|
168
|
+
string userId = TapCoreStandalone.User.Id;
|
|
169
|
+
if (string.IsNullOrWhiteSpace(userId)) {
|
|
170
|
+
TapLogger.Error("UserId is NULL.");
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
Dictionary<string, object> baseProps = new Dictionary<string, object> {
|
|
175
|
+
{ "user_id", userId }
|
|
176
|
+
};
|
|
177
|
+
_ = TrackPropertiesAsync(type, baseProps, properties);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
private Task TrackPropertiesAsync(string type,
|
|
181
|
+
Dictionary<string, object> basicProps, Dictionary<string, object> properties)
|
|
182
|
+
{
|
|
183
|
+
if (!IsInitialized) {
|
|
184
|
+
return Task.CompletedTask;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (properties == null) {
|
|
188
|
+
properties = new Dictionary<string, object>();
|
|
189
|
+
}
|
|
190
|
+
properties["sdk_version"] = TapTapSDK.SDKVersion;
|
|
191
|
+
|
|
192
|
+
Dictionary<string, object> data = new Dictionary<string, object>(basicProps) {
|
|
193
|
+
{ "client_id", TapCoreStandalone.coreOptions.clientId },
|
|
194
|
+
{ "type", type },
|
|
195
|
+
{ "properties", properties }
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
sender.Send(data);
|
|
199
|
+
return Task.CompletedTask;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
private void InitBasicProps() {
|
|
203
|
+
DeviceInfo.GetMacAddress(out string macList, out string firstMac);
|
|
204
|
+
basicProps = new Dictionary<string, object> {
|
|
205
|
+
{ "os", OS },
|
|
206
|
+
{ "md", SystemInfo.deviceModel },
|
|
207
|
+
{ "sv", SystemInfo.operatingSystem },
|
|
208
|
+
{ "pn", "TapSDK" },
|
|
209
|
+
{ "tapsdk_project", "TapSDKCore" },
|
|
210
|
+
{ "session_uuid", session_uuid },
|
|
211
|
+
{ "install_uuid", Identity.InstallationId },
|
|
212
|
+
{ "persist_uuid", Identity.PersistentId },
|
|
213
|
+
{ "ram", DeviceInfo.RAM },
|
|
214
|
+
{ "rom", DeviceInfo.ROM },
|
|
215
|
+
{ "width", Screen.currentResolution.width },
|
|
216
|
+
{ "height", Screen.currentResolution.height },
|
|
217
|
+
{ "provider", "unknown" },
|
|
218
|
+
{ "app_version", TapCoreStandalone.coreOptions.gameVersion ?? Application.version },
|
|
219
|
+
{ "sdk_version", TapTapSDK.SDKVersion },
|
|
220
|
+
{ "network_type", Network },
|
|
221
|
+
{ "channel", TapCoreStandalone.coreOptions.channel },
|
|
222
|
+
{ "mac_list", macList },
|
|
223
|
+
{ "first_mac", firstMac },
|
|
224
|
+
{ "device_id5", DeviceInfo.GetLaunchUniqueID() }
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
private string OS {
|
|
228
|
+
get {
|
|
229
|
+
switch (SystemInfo.operatingSystemFamily) {
|
|
230
|
+
case OperatingSystemFamily.Windows:
|
|
231
|
+
return "Windows";
|
|
232
|
+
case OperatingSystemFamily.MacOSX:
|
|
233
|
+
return "Mac";
|
|
234
|
+
case OperatingSystemFamily.Linux:
|
|
235
|
+
return "Linux";
|
|
236
|
+
default:
|
|
237
|
+
return "Unknown";
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
public static string getServerLanguage() {
|
|
243
|
+
// 将 TapCoreStandalone.coreOptions.preferredLanguage 转成 zh_TW/en/zh_CN/en_GB/jp/fil 等格式
|
|
244
|
+
switch (TapCoreStandalone.coreOptions.preferredLanguage) {
|
|
245
|
+
case TapTapLanguageType.zh_Hans:
|
|
246
|
+
return "zh_CN";
|
|
247
|
+
case TapTapLanguageType.zh_Hant:
|
|
248
|
+
return "zh_TW";
|
|
249
|
+
case TapTapLanguageType.en:
|
|
250
|
+
return "en_US";
|
|
251
|
+
case TapTapLanguageType.ja:
|
|
252
|
+
return "ja_JP";
|
|
253
|
+
case TapTapLanguageType.ko:
|
|
254
|
+
return "ko_KR";
|
|
255
|
+
case TapTapLanguageType.th:
|
|
256
|
+
return "th_TH";
|
|
257
|
+
case TapTapLanguageType.id:
|
|
258
|
+
return "id_ID";
|
|
259
|
+
case TapTapLanguageType.de:
|
|
260
|
+
return "de";
|
|
261
|
+
case TapTapLanguageType.es:
|
|
262
|
+
return "es_ES";
|
|
263
|
+
case TapTapLanguageType.fr:
|
|
264
|
+
return "fr";
|
|
265
|
+
case TapTapLanguageType.pt:
|
|
266
|
+
return "pt_PT";
|
|
267
|
+
case TapTapLanguageType.ru:
|
|
268
|
+
return "ru";
|
|
269
|
+
case TapTapLanguageType.tr:
|
|
270
|
+
return "tr";
|
|
271
|
+
case TapTapLanguageType.vi:
|
|
272
|
+
return "vi_VN";
|
|
273
|
+
default:
|
|
274
|
+
// 默认cn返回简体中文,Overseas返回英文
|
|
275
|
+
return TapCoreStandalone.coreOptions.region == TapTapRegionType.CN ? "zh_CN" : "en_US";
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
private string Network {
|
|
280
|
+
get {
|
|
281
|
+
switch (Application.internetReachability) {
|
|
282
|
+
case NetworkReachability.ReachableViaCarrierDataNetwork:
|
|
283
|
+
return "3";
|
|
284
|
+
case NetworkReachability.ReachableViaLocalAreaNetwork:
|
|
285
|
+
return "2";
|
|
286
|
+
default:
|
|
287
|
+
return "Unknown";
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
private bool IsInitialized {
|
|
293
|
+
get {
|
|
294
|
+
if (string.IsNullOrWhiteSpace(TapCoreStandalone.coreOptions.clientId)) {
|
|
295
|
+
TapLogger.Error("MUST be initialized.");
|
|
296
|
+
return false;
|
|
297
|
+
}
|
|
298
|
+
return true;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
private static string generateUUID() {
|
|
303
|
+
return Guid.NewGuid().ToString();
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
private static string OpenID {
|
|
307
|
+
get {
|
|
308
|
+
IOpenIDProvider provider = BridgeUtils.CreateBridgeImplementation(typeof(IOpenIDProvider),
|
|
309
|
+
"TapSDK.Login") as IOpenIDProvider;
|
|
310
|
+
return provider?.GetOpenID();
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
public interface IDynamicProperties {
|
|
315
|
+
Dictionary<string, object> GetDynamicProperties();
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
using System.Collections.Generic;
|
|
2
|
+
|
|
3
|
+
namespace TapSDK.Core.Standalone.Internal {
|
|
4
|
+
public class User {
|
|
5
|
+
internal static readonly string USER_ID_KEY = "tapdb_played_duration_user_id";
|
|
6
|
+
|
|
7
|
+
internal string Id {
|
|
8
|
+
get => id;
|
|
9
|
+
set {
|
|
10
|
+
id = value;
|
|
11
|
+
TapCoreStandalone.Prefs.Set(USER_ID_KEY, id);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
private string id;
|
|
16
|
+
|
|
17
|
+
private readonly PlayRecorder playRecorder;
|
|
18
|
+
|
|
19
|
+
public User() {
|
|
20
|
+
playRecorder = new PlayRecorder();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public void Login(string userId, Dictionary<string, object> props = null) {
|
|
24
|
+
// 先执行旧用户登出逻辑
|
|
25
|
+
Id = TapCoreStandalone.Prefs.Get<string>(USER_ID_KEY);
|
|
26
|
+
if (!string.IsNullOrWhiteSpace(Id)) {
|
|
27
|
+
Logout();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// 再执行新用户登录逻辑
|
|
31
|
+
Id = userId;
|
|
32
|
+
|
|
33
|
+
if (TapCoreStandalone.enableAutoEvent) {
|
|
34
|
+
TapCoreStandalone.Tracker.TrackEvent(Constants.USER_LOGIN, props, true);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
Dictionary<string, object> updateProps = new Dictionary<string, object> {
|
|
38
|
+
{ "has_user", true },
|
|
39
|
+
};
|
|
40
|
+
TapCoreStandalone.Tracker.TrackDeviceProperties(Constants.PROPERTY_UPDATE_TYPE, updateProps);
|
|
41
|
+
|
|
42
|
+
playRecorder.Start();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public void Logout() {
|
|
46
|
+
playRecorder.Stop();
|
|
47
|
+
|
|
48
|
+
Id = null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|