com.amanotes.gdk 0.2.50 → 0.2.52

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.
@@ -200,14 +200,14 @@ namespace Amanotes.Core
200
200
  #elif UNITY_IOS
201
201
  IDFV = SystemInfo.deviceUniqueIdentifier;
202
202
  #endif
203
-
204
- // Always get the latest advertising id
205
- GetAdvertisingId();
203
+ GetAmaDeviceId();
204
+ UpdateUserId();
206
205
  }
207
206
 
208
207
  internal void StartModule()
209
208
  {
210
- UpdateUserId();
209
+ // Always get the latest advertising id
210
+ GetAdvertisingId();
211
211
  Logging.Log($"[UserProfile] user_id: {_userId}");
212
212
  }
213
213
 
@@ -231,39 +231,43 @@ namespace Amanotes.Core
231
231
  GDKUtils.DelayCall(0, () =>
232
232
  {
233
233
  SetAdvertisingID(advertisingId);
234
- switch (Application.platform)
235
- {
236
- case RuntimePlatform.IPhonePlayer:
237
- string v = KeyChain.GetKeyChain(AMA_DEVICE_ID_KEY);
238
- if (string.IsNullOrEmpty(v))
239
- {
240
- v = Guid.NewGuid().ToString();
241
- KeyChain.SetKeyChain(AMA_DEVICE_ID_KEY, v);
242
- }
243
- AmaDeviceId = v;
244
- break;
245
-
246
- case RuntimePlatform.Android:
247
- string cachedAmaDeviceId = PlayerPrefs.GetString(AMA_DEVICE_ID_KEY);
248
- if (string.IsNullOrEmpty(cachedAmaDeviceId))
249
- {
250
- cachedAmaDeviceId = SystemInfo.deviceUniqueIdentifier;
251
- PlayerPrefs.SetString(AMA_DEVICE_ID_KEY, cachedAmaDeviceId);
252
- }
253
- AmaDeviceId = cachedAmaDeviceId;
254
- break;
255
-
256
- default:
257
- AmaDeviceId = SystemInfo.deviceUniqueIdentifier;
258
- break;
259
- }
260
-
261
- Logging.Log($"[UserProfile] ama_device_id: {_amaDeviceId}");
262
234
  Save();
263
235
  });
264
236
  });
265
237
  }
266
238
 
239
+ private void GetAmaDeviceId()
240
+ {
241
+ if (!string.IsNullOrEmpty(AmaDeviceId)) return;
242
+ switch (Application.platform)
243
+ {
244
+ case RuntimePlatform.IPhonePlayer:
245
+ string v = KeyChain.GetKeyChain(AMA_DEVICE_ID_KEY);
246
+ if (string.IsNullOrEmpty(v))
247
+ {
248
+ v = Guid.NewGuid().ToString();
249
+ KeyChain.SetKeyChain(AMA_DEVICE_ID_KEY, v);
250
+ }
251
+ AmaDeviceId = v;
252
+ break;
253
+
254
+ case RuntimePlatform.Android:
255
+ string cachedAmaDeviceId = PlayerPrefs.GetString(AMA_DEVICE_ID_KEY);
256
+ if (string.IsNullOrEmpty(cachedAmaDeviceId))
257
+ {
258
+ cachedAmaDeviceId = SystemInfo.deviceUniqueIdentifier;
259
+ }
260
+ AmaDeviceId = cachedAmaDeviceId;
261
+ break;
262
+
263
+ default:
264
+ AmaDeviceId = SystemInfo.deviceUniqueIdentifier;
265
+ break;
266
+ }
267
+ Logging.Log($"[UserProfile] Generate ama_device_id: {_amaDeviceId}");
268
+ Save();
269
+ }
270
+
267
271
  private string ValidateId (string id, string pattern)
268
272
  {
269
273
  if (string.IsNullOrWhiteSpace(id)) return null;
package/Runtime/AmaGDK.cs CHANGED
@@ -17,7 +17,7 @@ namespace Amanotes.Core
17
17
  {
18
18
  public partial class AmaGDK : MonoBehaviour
19
19
  {
20
- public const string VERSION = "0.2.50";
20
+ public const string VERSION = "0.2.52";
21
21
 
22
22
  internal static AmaGDK _instance;
23
23
  internal static Status _status = Status.None;
@@ -182,12 +182,12 @@ namespace Amanotes.Core
182
182
  }
183
183
 
184
184
  float startTime = Time.realtimeSinceStartup;
185
- yield return InitHook();
186
185
 
187
186
  dispatcher.Dispatch(Event.GDK_INIT_START);
188
187
  var sb = new StringBuilder();
189
188
  InitModules();
190
189
 
190
+ yield return InitHook();
191
191
  yield return WaitForManualInit();
192
192
  yield return InitAdapters(sb);
193
193
 
@@ -93,6 +93,27 @@ namespace Amanotes.Core.Internal
93
93
 
94
94
  public static class Forbidden
95
95
  {
96
+ private static bool presetShowAnalyticsLog;
97
+ private static bool presetEnableEventStat;
98
+ private static LogLevel presetLogLevel = LogLevel.Warning;
99
+
100
+ public static void PresetConfig()
101
+ {
102
+ presetLogLevel = Config.common.logLevel;
103
+ Config.common.logLevel = LogLevel.Warning;
104
+ presetShowAnalyticsLog = Config.analytics.showAnalyticsLog;
105
+ Config.analytics.showAnalyticsLog = true;
106
+ presetEnableEventStat = Config.analytics.enableEventStat;
107
+ Config.analytics.enableEventStat = true;
108
+ }
109
+
110
+ public static void ReloadConfig()
111
+ {
112
+ Config.analytics.showAnalyticsLog = presetShowAnalyticsLog;
113
+ Config.analytics.enableEventStat = presetEnableEventStat;
114
+ Config.common.logLevel = presetLogLevel;
115
+ }
116
+
96
117
  public static void DestroyAndReset()
97
118
  {
98
119
  if (_instance != null)
@@ -139,9 +160,12 @@ namespace Amanotes.Core.Internal
139
160
  public static void ClearAnalyticsData()
140
161
  {
141
162
  AnalyticsData analyticsData = localData;
163
+ analyticsData._dirty = true;
142
164
  analyticsData.funnelSignatures.Clear();
143
165
  analyticsData.eventDetails.Clear();
166
+ analyticsData.cachedEventDetails.Clear();
144
167
  analyticsData.migrationLog = new MigrationLog();
168
+ analyticsData.SaveIfDirty();
145
169
  }
146
170
  }
147
171
 
@@ -1,5 +1,6 @@
1
1
  using System;
2
2
  using System.Collections;
3
+ using System.Collections.Concurrent;
3
4
  using System.Collections.Generic;
4
5
  using System.IO;
5
6
  using System.Reflection;
@@ -391,7 +392,6 @@ namespace Amanotes.Core.Internal
391
392
 
392
393
  internal interface IJsonFile { }
393
394
 
394
-
395
395
  internal static class JsonFileExtension
396
396
  {
397
397
  public static T LoadJsonFromFile<T>(this T instance) where T : IJsonFile, new()
@@ -569,4 +569,30 @@ namespace Amanotes.Core.Internal
569
569
  // public T[] items;
570
570
  //}
571
571
  }
572
+
573
+ internal class Pool<T> where T : new()
574
+ {
575
+ private readonly ConcurrentQueue<T> _pool;
576
+
577
+ public Pool(int initialCapacity)
578
+ {
579
+ _pool = new ConcurrentQueue<T>();
580
+ for (int i = 0; i < initialCapacity; i++)
581
+ {
582
+ _pool.Enqueue(new T());
583
+ }
584
+ }
585
+
586
+ public T Get()
587
+ {
588
+ return _pool.TryDequeue(out var obj) ? obj : new T();
589
+ }
590
+
591
+ public void Return(T obj)
592
+ {
593
+ _pool.Enqueue(obj);
594
+ }
595
+
596
+ public int Count => _pool.Count;
597
+ }
572
598
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.amanotes.gdk",
3
- "version": "0.2.50",
3
+ "version": "0.2.52",
4
4
  "displayName": "AmaGDK",
5
5
  "description": "Amanotes Game Development Kit",
6
6
  "unity": "2019.4",