com.taptap.sdk.core 4.5.3 → 4.5.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.
@@ -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.3"/>
7
+ <androidPackage spec="com.taptap.sdk:tap-core-unity:4.5.5"/>
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.3" bitcodeEnabled="false" addToAllTargets="false"/>
13
+ <iosPod name="TapTapCoreSDK" version="~> 4.5.5" bitcodeEnabled="false" addToAllTargets="false"/>
14
14
  </iosPods>
15
15
  </dependencies>
@@ -9,8 +9,7 @@ using UnityEngine.Networking;
9
9
 
10
10
  namespace TapSDK.Core.Internal.Utils {
11
11
  public class ImageUtils {
12
- private readonly static string CacheDirName = "tap-cache";
13
-
12
+ private readonly static string OldCacheDirName = "tap-cache";
14
13
  private readonly static MD5 md5 = MD5.Create();
15
14
 
16
15
  private readonly static Dictionary<string, WeakReference<Texture>> cachedTextures = new Dictionary<string, WeakReference<Texture>>();
@@ -136,11 +135,22 @@ namespace TapSDK.Core.Internal.Utils {
136
135
 
137
136
  static string CacheDirPath {
138
137
  get {
139
- string path = Path.Combine(Application.persistentDataPath, CacheDirName);
140
- if (!Directory.Exists(path)) {
141
- Directory.CreateDirectory(path);
138
+
139
+ string newCacheDirPath = Path.Combine(Application.persistentDataPath, OldCacheDirName);
140
+ if (TapTapSDK.taptapSdkOptions != null && !string.IsNullOrEmpty(TapTapSDK.taptapSdkOptions.clientId) ){
141
+ newCacheDirPath = Path.Combine(Application.persistentDataPath, OldCacheDirName + "_" + TapTapSDK.taptapSdkOptions.clientId);
142
+ }
143
+ if(!Directory.Exists(newCacheDirPath)) {
144
+ string oldPath = Path.Combine(Application.persistentDataPath, OldCacheDirName);
145
+ if (Directory.Exists(oldPath)) {
146
+ Directory.Move(oldPath, newCacheDirPath);
147
+ }
148
+ }
149
+
150
+ if (!Directory.Exists(newCacheDirPath)) {
151
+ Directory.CreateDirectory(newCacheDirPath);
142
152
  }
143
- return path;
153
+ return newCacheDirPath;
144
154
  }
145
155
  }
146
156
  }
@@ -14,21 +14,32 @@ namespace TapSDK.Core
14
14
  private static byte[] Keys = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };
15
15
  public static void SaveString(string key, string value)
16
16
  {
17
- SaveStringToCache(key, value);
18
- PlayerPrefs.SetString(key, EncodeString(value));
17
+ string storageKey = GenerateStorageKey(key);
18
+ SaveStringToCache(storageKey, value);
19
+ PlayerPrefs.SetString(storageKey, EncodeString(value));
19
20
  }
20
21
 
21
22
  public static string LoadString(string key)
22
23
  {
23
- string value = LoadStringFromCache(key);
24
+ string storageKey = GenerateStorageKey(key);
25
+ string value = LoadStringFromCache(storageKey);
24
26
  if (!string.IsNullOrEmpty(value))
25
27
  {
26
28
  return value;
27
29
  }
28
- value = PlayerPrefs.HasKey(key) ? DecodeString(PlayerPrefs.GetString(key)) : null;
30
+ value = PlayerPrefs.HasKey(storageKey) ? DecodeString(PlayerPrefs.GetString(storageKey)) : null;
31
+ // 尝试从本地获取旧版本数据
32
+ if (value == null){
33
+ value = PlayerPrefs.HasKey(key) ? DecodeString(PlayerPrefs.GetString(key)) : null;
34
+ // 旧版本存在有效数据时,转储为新的 storageKey
35
+ if (value != null) {
36
+ PlayerPrefs.SetString(storageKey, EncodeString(value));
37
+ PlayerPrefs.DeleteKey(key);
38
+ }
39
+ }
29
40
  if (value != null)
30
41
  {
31
- SaveStringToCache(key, value);
42
+ SaveStringToCache(storageKey, value);
32
43
  }
33
44
  return value;
34
45
  }
@@ -137,5 +148,13 @@ namespace TapSDK.Core
137
148
  }
138
149
  return physicalAddress;
139
150
  }
151
+
152
+ // 生成存储在本地文件中 key
153
+ private static string GenerateStorageKey(string originKey){
154
+ if(TapTapSDK.taptapSdkOptions != null && !string.IsNullOrEmpty(TapTapSDK.taptapSdkOptions.clientId)){
155
+ return originKey + "_" + TapTapSDK.taptapSdkOptions.clientId;
156
+ }
157
+ return originKey;
158
+ }
140
159
  }
141
160
  }
@@ -12,7 +12,7 @@ using System.ComponentModel;
12
12
 
13
13
  namespace TapSDK.Core {
14
14
  public class TapTapSDK {
15
- public static readonly string Version = "4.5.3";
15
+ public static readonly string Version = "4.5.5";
16
16
 
17
17
  public static string SDKPlatform = "TapSDK-Unity";
18
18
 
@@ -13,7 +13,7 @@ namespace TapSDK.Core.Standalone.Internal {
13
13
  public readonly static string DEVICE_LOGIN = "device_login";
14
14
  public readonly static string USER_LOGIN = "user_login";
15
15
 
16
- internal static string ClientSettingsFileName = "TapSDKClientSettings.json";
16
+ internal static string ClientSettingsFileName = "TapSDKClientSettings";
17
17
  internal static string ClientSettingsEventKey = "ClientSettingsEventKey";
18
18
  }
19
19
 
@@ -16,7 +16,7 @@ namespace TapSDK.Core.Standalone.Internal
16
16
  {
17
17
  public class EventSender
18
18
  {
19
- private const string EventFilePath = "events.json";
19
+ private const string OldEventFilePath = "events.json";
20
20
 
21
21
  private readonly TapLog log = new TapLog("TapEvent");
22
22
  private string persistentDataPath = Application.persistentDataPath;
@@ -131,9 +131,25 @@ namespace TapSDK.Core.Standalone.Internal
131
131
  timer.Change(TimeSpan.FromSeconds(SendInterval), TimeSpan.FromSeconds(SendInterval));
132
132
  }
133
133
 
134
+ private string GetEventCacheFileName(){
135
+ if (TapTapSDK.taptapSdkOptions != null
136
+ && !string.IsNullOrEmpty(TapTapSDK.taptapSdkOptions.clientId)){
137
+ return "events_" + TapTapSDK.taptapSdkOptions.clientId + ".json";
138
+ }
139
+ return OldEventFilePath;
140
+ }
141
+
134
142
  private void LoadEvents()
135
- {
136
- string filePath = Path.Combine(persistentDataPath, EventFilePath);
143
+ {
144
+ string filePath = Path.Combine(persistentDataPath, GetEventCacheFileName());
145
+ if(!File.Exists(filePath)){
146
+ string oldFilePath = Path.Combine(persistentDataPath, OldEventFilePath);
147
+ // 兼容旧版本文件
148
+ if (File.Exists(oldFilePath)) {
149
+ File.Move(oldFilePath, filePath);
150
+ }
151
+ }
152
+
137
153
  if (File.Exists(filePath))
138
154
  {
139
155
  string jsonData = File.ReadAllText(filePath);
@@ -165,13 +181,13 @@ namespace TapSDK.Core.Standalone.Internal
165
181
  var eventList = eventQueue.ToList();
166
182
  string jsonData = Json.Serialize(eventList);
167
183
 
168
- if (string.IsNullOrEmpty(EventFilePath))
184
+ if (string.IsNullOrEmpty(GetEventCacheFileName()))
169
185
  {
170
186
  Debug.LogError("EventFilePath is null or empty");
171
187
  return;
172
188
  }
173
189
 
174
- string filePath = Path.Combine(persistentDataPath, EventFilePath);
190
+ string filePath = Path.Combine(persistentDataPath, GetEventCacheFileName());
175
191
 
176
192
  if (string.IsNullOrEmpty(filePath))
177
193
  {
@@ -142,7 +142,17 @@ namespace TapSDK.Core.Standalone.Internal.Openlog
142
142
  }
143
143
  openlogStartParameter[TapOpenlogStartParamConstants.PARAM_LOG_TO_CONSOLE] = 1;
144
144
  openlogStartParameter[TapOpenlogStartParamConstants.PARAM_LOG_LEVEL] = 1;
145
- openlogStartParameter[TapOpenlogStartParamConstants.PARAM_DATA_DIR] = Path.Combine(Application.persistentDataPath, "OpenlogData");
145
+ string openLogDirPath = Path.Combine(Application.persistentDataPath, "OpenlogData");
146
+ if (TapTapSDK.taptapSdkOptions != null && !string.IsNullOrEmpty(TapTapSDK.taptapSdkOptions.clientId)){
147
+ openLogDirPath = Path.Combine(Application.persistentDataPath, "OpenlogData_" + TapTapSDK.taptapSdkOptions.clientId);
148
+ if( !Directory.Exists(openLogDirPath)){
149
+ string oldPath = Path.Combine(Application.persistentDataPath, "OpenlogData");
150
+ if(Directory.Exists(oldPath)){
151
+ Directory.Move(oldPath, openLogDirPath);
152
+ }
153
+ }
154
+ }
155
+ openlogStartParameter[TapOpenlogStartParamConstants.PARAM_DATA_DIR] = openLogDirPath;
146
156
  openlogStartParameter[TapOpenlogStartParamConstants.PARAM_ENV] = "local";
147
157
  openlogStartParameter[TapOpenlogStartParamConstants.PARAM_PLATFORM] = "PC";
148
158
  openlogStartParameter[TapOpenlogStartParamConstants.PARAM_UA] = TapHttpUtils.GenerateUserAgent();
@@ -9,7 +9,7 @@ using TapSDK.Core;
9
9
 
10
10
  namespace TapSDK.Core.Standalone.Internal {
11
11
  public class Prefs {
12
- internal static readonly string PERSISTENT_FILE_NAME = "tapdb_storage_v2";
12
+ internal static readonly string OLD_PERSISTENT_FILE_NAME = "tapdb_storage_v2";
13
13
 
14
14
  private string persistentFilePath;
15
15
 
@@ -20,12 +20,23 @@ namespace TapSDK.Core.Standalone.Internal {
20
20
  private readonly AutoResetEvent persistEvent;
21
21
 
22
22
  public Prefs() {
23
- persistentFilePath = Path.Combine(Application.persistentDataPath, PERSISTENT_FILE_NAME);
23
+ string newCacheFileName = OLD_PERSISTENT_FILE_NAME;
24
+ if( TapTapSDK.taptapSdkOptions != null && !string.IsNullOrEmpty(TapTapSDK.taptapSdkOptions.clientId)) {
25
+ newCacheFileName = OLD_PERSISTENT_FILE_NAME + "_" + TapTapSDK.taptapSdkOptions.clientId;
26
+ }
27
+ persistentFilePath = Path.Combine(Application.persistentDataPath, newCacheFileName);
28
+ // 兼容旧版缓存文件
29
+ if( !File.Exists(persistentFilePath)) {
30
+ string oldPath = Path.Combine(Application.persistentDataPath, OLD_PERSISTENT_FILE_NAME);
31
+ if (File.Exists(oldPath)){
32
+ File.Move(oldPath, persistentFilePath);
33
+ }
34
+ }
24
35
  if (File.Exists(persistentFilePath)) {
25
36
  try {
26
37
  string json = File.ReadAllText(persistentFilePath);
27
38
  Dictionary<string, object> jsonData = Json.Deserialize(json) as Dictionary<string, object>;
28
- ConcurrentDictionary<string, object> data = new ConcurrentDictionary<string, object>(jsonData);
39
+ data = new ConcurrentDictionary<string, object>(jsonData);
29
40
  } catch (Exception e) {
30
41
  TapLogger.Error(e.Message);
31
42
  File.Delete(persistentFilePath);
@@ -37,7 +37,7 @@ namespace TapSDK.Core.Standalone
37
37
  public TapCoreStandalone()
38
38
  {
39
39
  // Instantiate modules
40
- Prefs = new Prefs();
40
+
41
41
  Tracker = new Tracker();
42
42
  User = new User();
43
43
  TapLoom.Initialize();
@@ -69,10 +69,19 @@ namespace TapSDK.Core.Standalone
69
69
  }
70
70
  TapLog.Log("SDK Init Options : ", "coreOption : " + JsonConvert.SerializeObject(coreOption) + "\notherOptions : " + JsonConvert.SerializeObject(otherOptions));
71
71
  coreOptions = coreOption;
72
-
72
+ if (Prefs == null) {
73
+ Prefs = new Prefs();
74
+ }
73
75
  TapOpenlogStandalone.Init();
74
76
 
75
- var path = Path.Combine(Application.persistentDataPath, Constants.ClientSettingsFileName);
77
+ var path = Path.Combine(Application.persistentDataPath, Constants.ClientSettingsFileName + "_" + coreOption.clientId + ".json");
78
+ // 兼容旧版文件
79
+ if (!File.Exists(path)) {
80
+ var oldPath = Path.Combine(Application.persistentDataPath, Constants.ClientSettingsFileName + ".json");
81
+ if(File.Exists(oldPath)){
82
+ File.Move(oldPath, path);
83
+ }
84
+ }
76
85
  if (File.Exists(path))
77
86
  {
78
87
  var clientSettings = File.ReadAllText(path);
@@ -182,7 +191,7 @@ namespace TapSDK.Core.Standalone
182
191
  private void saveClientSettings(TapGatekeeper settings)
183
192
  {
184
193
  string json = JsonConvert.SerializeObject(settings);
185
- File.WriteAllText(Path.Combine(Application.persistentDataPath, Constants.ClientSettingsFileName), json);
194
+ File.WriteAllText(Path.Combine(Application.persistentDataPath, Constants.ClientSettingsFileName + "_" + TapTapSDK.taptapSdkOptions.clientId + ".json"), json);
186
195
  }
187
196
 
188
197
  private void SetAutoEvent(TapGatekeeper gatekeeper)
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "com.taptap.sdk.core",
3
3
  "displayName": "TapTapSDK Core",
4
4
  "description": "TapTapSDK Core",
5
- "version": "4.5.3",
5
+ "version": "4.5.5",
6
6
  "unity": "2019.4",
7
7
  "license": "MIT",
8
8
  "dependencies": {