com.amanotes.gdk 0.2.28 → 0.2.30

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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.30 - 2023-11-06]
4
+ - [Fix] GDK should base on realtime instead of game time (which may be pause due to timescale)
5
+
6
+ ## [0.2.29 - 2023-11-03]
7
+ - Fix accumulated_count
8
+ - Fix missing IDFA
9
+
3
10
  ## [0.2.28 - 2023-11-01]
4
11
  - Ads: Set timescale to 0 after save
5
12
 
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -369,7 +369,7 @@ namespace Amanotes.Core.Internal
369
369
 
370
370
  public abstract class AdLogic
371
371
  {
372
- private static readonly WaitForSeconds wait1Sec = new WaitForSeconds(1f);
372
+ private static readonly WaitForSecondsRealtime wait1Sec = new WaitForSecondsRealtime(1f);
373
373
 
374
374
  internal LoadAdsState _loadState = LoadAdsState.None;
375
375
  internal bool hasAd
@@ -230,28 +230,7 @@ namespace Amanotes.Core
230
230
  config.NeverSend = eventNames;
231
231
  }
232
232
  }
233
-
234
- public static void OnlySendAtCount(string eventName, List<int> listCount, bool withinSession = false, bool appendCountToEventName = false, string numberFormat = "00")
235
- {
236
- var config = new EventConfig
237
- {
238
- listCount = listCount,
239
- withinSession = withinSession,
240
- appendCountToEventName = appendCountToEventName,
241
- numberFormat = numberFormat
242
- };
243
-
244
- if (sendAtCount.ContainsKey(eventName))
245
- {
246
- LogWarning($"{eventName} has already been set list of count number to log.");
247
- sendAtCount[eventName] = config;
248
- }
249
- else
250
- {
251
- sendAtCount.Add(eventName, config);
252
- }
253
- }
254
- }
233
+ }
255
234
 
256
235
  //INTERNAL
257
236
  public static partial class Analytics
@@ -271,11 +250,14 @@ namespace Amanotes.Core
271
250
  internal static readonly List<AdapterContext> listAdapters = new List<AdapterContext>();
272
251
  internal static readonly AnalyticsData localData = new AnalyticsData().LoadJsonFromFile();
273
252
  internal static readonly SessionStat sessionStat = new SessionStat();
253
+ internal static AdapterContext primaryAdapter;
274
254
 
275
255
  internal static void Init()
276
256
  {
277
257
  listAdapters.Clear();
278
258
  listAdapters.AddRange(Adapter.FindAll<IAnalyticAdapter>());
259
+ if (listAdapters.Count != 0)
260
+ primaryAdapter = listAdapters.Find(a => a.adapterId == AdapterID.FIREBASE_ANALYTICS) ?? listAdapters[0];
279
261
 
280
262
  onFrameUpdate -= ProcessEventQueue;
281
263
  onFrameUpdate += ProcessEventQueue;
@@ -294,10 +276,9 @@ namespace Amanotes.Core
294
276
  while (eventQueue.Count > 0)
295
277
  {
296
278
  var eventData = eventQueue.Dequeue();
297
- var (countInSession, totalCount) = localData.IncreaseCounter(eventData.eventName);
298
-
299
279
  if (!ShouldSendEvent(eventData)) continue;
300
-
280
+
281
+ var (countInSession, totalCount) = localData.IncreaseCounter(eventData);
301
282
  if (eventData.accumulated)
302
283
  {
303
284
  eventData.AddParam("accumulated_count", eventData.withinSession ? countInSession : totalCount);
@@ -315,22 +296,9 @@ namespace Amanotes.Core
315
296
  var inUseAdapterIDs = new List<string>();
316
297
  foreach (AdapterContext m in listAdapters)
317
298
  {
299
+ if (IsAdapterForbidden(m, eventData)) continue;
300
+
318
301
  var api = m.GetAdapterApi<IAnalyticAdapter>();
319
- var config = m.GetAdapterConfig<AnalyticsAdapterConfig>();
320
-
321
- if (eventData.overrideConfig)
322
- {
323
- // IMPORTANT NOTE:
324
- //
325
- // Once set overrideConfig, we should skip the adapter config completely!!!
326
- //
327
- if (eventData.IsAdapterForbidden(m.adapterId)) continue;
328
- }
329
- else // Do not remove else
330
- {
331
- if (config.IsForbidden(eventData.eventName)) continue;
332
- }
333
-
334
302
  api.LogEvent(eventNameToSend, eventData.parameters);
335
303
  inUseAdapterIDs.Add(m.adapterId);
336
304
  }
@@ -341,6 +309,27 @@ namespace Amanotes.Core
341
309
  sessionStat.Save();
342
310
  }
343
311
 
312
+ internal static bool IsAdapterForbidden(AdapterContext adapterContext, EventParams eventData)
313
+ {
314
+ if (adapterContext == null) return false;
315
+ var config = adapterContext.GetAdapterConfig<AnalyticsAdapterConfig>();
316
+
317
+ if (eventData.overrideConfig)
318
+ {
319
+ // IMPORTANT NOTE:
320
+ //
321
+ // Once set overrideConfig, we should skip the adapter config completely!!!
322
+ //
323
+ if (eventData.IsAdapterForbidden(adapterContext.adapterId)) return true;
324
+ }
325
+ else // Do not remove else
326
+ {
327
+ if (config.IsForbidden(eventData.eventName)) return true;
328
+ }
329
+
330
+ return false;
331
+ }
332
+
344
333
  internal static string GetEventNameToSend(string eventName, int countInSession, int totalCount)
345
334
  {
346
335
  if (!sendAtCount.TryGetValue(eventName, out var config)) return eventName;
@@ -529,9 +518,11 @@ namespace Amanotes.Core
529
518
  return true;
530
519
  }
531
520
 
532
- internal (int countInSession, int totalCount) IncreaseCounter(string eventName)
521
+ internal (int countInSession, int totalCount) IncreaseCounter(EventParams eventParams)
533
522
  {
534
- EventDetail result = GetEventDetail(eventName, true);
523
+ EventDetail result = GetEventDetail(eventParams.eventName, true);
524
+ if (IsAdapterForbidden(primaryAdapter, eventParams))
525
+ return (result.countInSession, result.totalCount);
535
526
  result.countInSession++;
536
527
  result.totalCount++;
537
528
  _dirty = true;
@@ -52,13 +52,11 @@ namespace Amanotes.Core
52
52
  private const string AMA_DEVICE_ID_KEY = "ama_device_id";
53
53
  private const float TIME_OUT = 5f;
54
54
  private const float WAIT_TIME = 0.5f;
55
- private WaitForSeconds waitForDuration = new WaitForSeconds(WAIT_TIME);
55
+ private WaitForSecondsRealtime waitForDuration = new WaitForSecondsRealtime(WAIT_TIME);
56
56
 
57
57
  internal IEnumerator Init()
58
58
  {
59
59
  User.LoadJsonFromFile();
60
- if (IsAmaDeviceIdExist()) yield break;
61
-
62
60
  GetAdvertisingId();
63
61
 
64
62
  float time = 0;
@@ -76,7 +74,7 @@ namespace Amanotes.Core
76
74
  {
77
75
  if (!string.IsNullOrEmpty(amaDeviceId))
78
76
  {
79
- Logging.Log($"AmaDeviceId is already exist: {amaDeviceId}");
77
+ Logging.Log($"AmaDeviceId is already existed: {amaDeviceId}");
80
78
  return true;
81
79
  }
82
80
  return false;
@@ -9,7 +9,7 @@ using static Amanotes.Core.Internal.Logging;
9
9
 
10
10
  namespace Amanotes.Core.Internal
11
11
  {
12
- public class GDKUtils
12
+ public static class GDKUtils
13
13
  {
14
14
  public static void DelayCall(float seconds, Action action)
15
15
  {
@@ -18,14 +18,13 @@ namespace Amanotes.Core.Internal
18
18
 
19
19
  private static IEnumerator DelayCallRoutine(float seconds, Action callback)
20
20
  {
21
- yield return new WaitForSeconds(seconds);
21
+ yield return new WaitForSecondsRealtime(seconds);
22
22
  callback();
23
23
  }
24
24
  }
25
25
 
26
- internal class GDKFileUtils
26
+ internal static class GDKFileUtils
27
27
  {
28
-
29
28
  private static string _basePath;
30
29
  private static string basePath
31
30
  {
@@ -83,7 +82,7 @@ namespace Amanotes.Core.Internal
83
82
  LogWarningOnce("File name must be not null or empty");
84
83
  return;
85
84
  }
86
-
85
+
87
86
  if (contents == null || !contents.GetEnumerator().MoveNext())
88
87
  {
89
88
  LogWarningOnce($"Content for {fileName} is empty");
package/Runtime/AmaGDK.cs CHANGED
@@ -14,7 +14,7 @@ namespace Amanotes.Core
14
14
  {
15
15
  public partial class AmaGDK : MonoBehaviour
16
16
  {
17
- public const string VERSION = "0.2.28";
17
+ public const string VERSION = "0.2.30";
18
18
 
19
19
  internal static AmaGDK _instance;
20
20
  internal static Status _status = Status.None;
@@ -114,7 +114,7 @@ namespace Amanotes.Core
114
114
  }
115
115
 
116
116
  var adapterInfo = new AdapterInfo(adapter.adapterId, adapter.adapterVersion, adapter.IsReady);
117
- _adapters.Add(adapter.adapterId, adapterInfo);
117
+ _adapters[adapter.adapterId] = adapterInfo;
118
118
  _onAdapterReadyCallback?.Invoke(adapterInfo);
119
119
  adapterAnnounce.AppendLine(string.Format("[{0}] {1} (adapter v{2})", adapter.IsReady ? "OK" : "FAIL",
120
120
  adapter.adapterId, adapter.adapterVersion));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.amanotes.gdk",
3
- "version": "0.2.28",
3
+ "version": "0.2.30",
4
4
  "displayName": "AmaGDK",
5
5
  "description": "Amanotes Game Development Kit",
6
6
  "unity": "2019.4",