com.amanotes.gdk 0.2.8 → 0.2.9

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,15 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.9 - 2023-06-15]
4
+ ### Show total init time
5
+ ### Show adapter version + status at init time
6
+ ### Remove AmaGDK version in debug log
7
+ ### Remove "Params" in analytics debug log
8
+ ### Check "event_name" early
9
+ ### Fix null exception in AmaGDKInstaller
10
+ ### Add csc.rsp to enable AMAGDK_DEV
11
+ ### Update Ads module
12
+
3
13
  ## [0.2.8 - 2023-06-12]
4
14
  ### Mute Appsflyer's init log on Editor
5
15
  ### Clear analytics log in adapters
Binary file
Binary file
Binary file
Binary file
@@ -134,8 +134,10 @@ namespace Amanotes.Core
134
134
  _adapter?.rewardVideo.StartLoadAd();
135
135
  }
136
136
 
137
- public static bool HasInterstitial => _adapter.interstitial.hasAd;
138
- public static bool HasRewardedVideo => _adapter.rewardVideo.hasAd;
137
+ public static bool hasInterstitial => _adapter.interstitial.hasAd;
138
+ public static bool hasRewardedVideo => _adapter.rewardVideo.hasAd;
139
+ public static bool showingBanner => _showingBanner;
140
+ public static bool showingAd => context != null;
139
141
 
140
142
  public static IAdCallback ShowInterstitial(string placementName = null, Dictionary<string, object> userData = null)
141
143
  {
@@ -272,13 +274,14 @@ namespace Amanotes.Core.Internal
272
274
  this.userData = userData;
273
275
  this.placementName = placementName;
274
276
  adCallback = AdCallback.None;
275
- showCallAt = Time.time;
277
+ showCallAt = Time.realtimeSinceStartup;
276
278
  showFinishAt = 0;
277
279
  }
278
280
 
279
281
  public bool hasError => (adCallback & (AdCallback.Fail | AdCallback.Cancel)) != 0;
280
- public bool hasCompleted => (adCallback & (AdCallback.Close | AdCallback.Reward | AdCallback.Cancel)) != 0;
282
+ public bool potentiallyCompleted => (adCallback & (AdCallback.Close | AdCallback.Reward | AdCallback.Cancel)) != 0;
281
283
  public bool hasReward => (adCallback & AdCallback.Reward) != 0;
284
+ public bool hasClosed => (adCallback & AdCallback.Close) != 0;
282
285
  public bool hasCancel => (adCallback & AdCallback.Cancel) != 0;
283
286
  public bool hasClicked => (adCallback & AdCallback.Click) != 0;
284
287
  }
@@ -374,7 +377,7 @@ namespace Amanotes.Core.Internal
374
377
  internal ShowAdsState _showState = ShowAdsState.None;
375
378
  private Coroutine _showAdRoutine;
376
379
  private bool _isRequesting;
377
- internal bool isInterstitial => Ads.context.adType == AdType.Interstitial;
380
+ private bool _isInterstitial => adType == AdType.Interstitial;
378
381
 
379
382
  public void StartShowAd()
380
383
  {
@@ -429,7 +432,9 @@ namespace Amanotes.Core.Internal
429
432
 
430
433
  if (!isAdReady)
431
434
  {
435
+ Ads.Events.OnShowTimeout?.Invoke();
432
436
  _showState = ShowAdsState.ShowFail;
437
+ ShowAdRoutineCompleted(false);
433
438
  yield break;
434
439
  }
435
440
  }
@@ -443,7 +448,8 @@ namespace Amanotes.Core.Internal
443
448
  }
444
449
 
445
450
  var context = Ads.context;
446
- while (!context.hasCompleted)
451
+
452
+ while (!context.potentiallyCompleted)
447
453
  {
448
454
  yield return wait1Sec;
449
455
  }
@@ -451,31 +457,49 @@ namespace Amanotes.Core.Internal
451
457
  if (adType == AdType.Interstitial)
452
458
  {
453
459
  _showState = context.hasError ? ShowAdsState.ShowFail : ShowAdsState.ShowSuccess;
454
- ShowCompleted(_showState == ShowAdsState.ShowSuccess);
460
+ ShowAdRoutineCompleted(_showState == ShowAdsState.ShowSuccess);
461
+ yield break;
462
+ }
463
+
464
+ if (context.hasCancel)
465
+ {
466
+ yield return wait1Sec; // wait for close (1s)
467
+ _showState = ShowAdsState.ShowFail;
468
+ ShowAdRoutineCompleted(false);
469
+ yield break;
470
+ }
471
+
472
+ if (context.hasClosed)
473
+ {
474
+ while (!context.hasCancel && !context.hasReward)
475
+ {
476
+ yield return wait1Sec;
477
+ }
478
+
479
+ _showState = context.hasCancel ? ShowAdsState.ShowFail : ShowAdsState.ShowSuccess;
480
+ ShowAdRoutineCompleted(_showState == ShowAdsState.ShowSuccess);
455
481
  yield break;
456
482
  }
457
483
 
458
- // Should be rewardedVideo
459
- if (!context.hasReward && !context.hasCancel) // no reward & no cancel: wait for the delayed reward callback
484
+ while (!context.hasClosed)
460
485
  {
461
486
  yield return wait1Sec;
462
487
  }
463
488
 
464
- _showState = context.hasError ? ShowAdsState.ShowFail : ShowAdsState.ShowSuccess;
465
- ShowCompleted(_showState == ShowAdsState.ShowSuccess);
489
+ _showState = ShowAdsState.ShowSuccess;
490
+ ShowAdRoutineCompleted(true);
491
+
492
+ Ads.context = null;
493
+ _showState = ShowAdsState.None;
466
494
  }
467
495
 
468
- private void ShowCompleted(bool isSuccess)
496
+ private void ShowAdRoutineCompleted(bool isSuccess)
469
497
  {
470
- bool isInterstitial = adType == AdType.Interstitial;
471
- var adapter = Ads._adapter;
472
- if (isInterstitial)
473
- adapter.interstitial.StartLoadAd();
474
- else
475
- adapter.rewardVideo.StartLoadAd();
498
+ StartLoadAd();
499
+ Ads.context.showFinishAt = Time.realtimeSinceStartup;
476
500
 
477
501
  var localData = Ads.localData;
478
- var stat = isInterstitial ? localData.interstitial : localData.reward;
502
+ var stat = _isInterstitial ? localData.interstitial : localData.reward;
479
503
 
480
504
  if (isSuccess)
481
505
  {
@@ -490,7 +514,6 @@ namespace Amanotes.Core.Internal
490
514
  }
491
515
 
492
516
  localData.Save();
493
-
494
517
  RestoreVolume();
495
518
  }
496
519
 
@@ -505,9 +528,17 @@ namespace Amanotes.Core.Internal
505
528
  // Default implementation
506
529
  protected void OnAdClosed()
507
530
  {
508
- Ads.context.adCallback |= AdCallback.Close;
509
- Ads.context.onClosed?.Invoke();
510
- if (isInterstitial)
531
+ if (Ads.context != null)
532
+ {
533
+ Ads.context.adCallback |= AdCallback.Close;
534
+ Ads.context.onClosed?.Invoke();
535
+ }
536
+ else
537
+ {
538
+ LogWarning("OnAdClosed() Something wrong - No AdContext");
539
+ }
540
+
541
+ if (_isInterstitial)
511
542
  Ads.Events.OnInterstitialClosed?.Invoke();
512
543
  else
513
544
  Ads.Events.OnRewardedClosed?.Invoke();
@@ -515,10 +546,17 @@ namespace Amanotes.Core.Internal
515
546
 
516
547
  protected void OnAdClicked()
517
548
  {
518
- Ads.context.adCallback |= AdCallback.Click;
519
- Ads.context.onClicked?.Invoke();
549
+ if (Ads.context != null)
550
+ {
551
+ Ads.context.adCallback |= AdCallback.Click;
552
+ Ads.context.onClicked?.Invoke();
553
+ }
554
+ else
555
+ {
556
+ LogWarning("OnAdClicked() Something wrong - No AdContext");
557
+ }
520
558
 
521
- if (isInterstitial)
559
+ if (_isInterstitial)
522
560
  Ads.Events.OnInterstitialClicked?.Invoke();
523
561
  else
524
562
  Ads.Events.OnRewardedClicked?.Invoke();
@@ -527,10 +565,17 @@ namespace Amanotes.Core.Internal
527
565
 
528
566
  protected void OnAdShowFailed()
529
567
  {
530
- Ads.context.adCallback |= AdCallback.Fail;
531
- Ads.context.onShowFailed?.Invoke();
568
+ if (Ads.context != null)
569
+ {
570
+ Ads.context.adCallback |= AdCallback.Fail;
571
+ Ads.context.onShowFailed?.Invoke();
572
+ }
573
+ else
574
+ {
575
+ LogWarning("OnAdShowFailed() Something wrong - No AdContext");
576
+ }
532
577
 
533
- if (isInterstitial)
578
+ if (_isInterstitial)
534
579
  Ads.Events.OnInterstitialShowFailed?.Invoke();
535
580
  else
536
581
  Ads.Events.OnRewardedShowFailed?.Invoke();
@@ -539,20 +584,34 @@ namespace Amanotes.Core.Internal
539
584
 
540
585
  protected void OnAdShowSucceeded()
541
586
  {
542
- Ads.context.adCallback |= AdCallback.Success;
543
- Ads.context.onShowSuccess?.Invoke();
587
+ if (Ads.context != null)
588
+ {
589
+ Ads.context.adCallback |= AdCallback.Success;
590
+ Ads.context.onShowSuccess?.Invoke();
591
+ }
592
+ else
593
+ {
594
+ LogWarning("OnAdShowSucceeded() Something wrong - No AdContext");
595
+ }
544
596
 
545
- if (isInterstitial)
597
+ if (_isInterstitial)
546
598
  Ads.Events.OnInterstitialShowSucceeded?.Invoke();
547
599
 
548
600
  }
549
601
 
550
602
  protected void OnAdOpen()
551
603
  {
552
- Ads.context.adCallback |= AdCallback.Open;
553
- Ads.context.onOpened?.Invoke();
604
+ if (Ads.context != null)
605
+ {
606
+ Ads.context.adCallback |= AdCallback.Open;
607
+ Ads.context.onOpened?.Invoke();
608
+ }
609
+ else
610
+ {
611
+ LogWarning("OnAdOpen() Something wrong - No AdContext");
612
+ }
554
613
 
555
- if (isInterstitial)
614
+ if (_isInterstitial)
556
615
  Ads.Events.OnInterstitialOpened?.Invoke();
557
616
  else
558
617
  Ads.Events.OnRewardedOpened?.Invoke();
@@ -560,10 +619,17 @@ namespace Amanotes.Core.Internal
560
619
 
561
620
  protected void OnAdReward()
562
621
  {
563
- Ads.context.adCallback |= AdCallback.Reward;
564
- Ads.context.onRewardReceived?.Invoke();
622
+ if (Ads.context != null)
623
+ {
624
+ Ads.context.adCallback |= AdCallback.Reward;
625
+ Ads.context.onRewardReceived?.Invoke();
626
+ }
627
+ else
628
+ {
629
+ LogWarning("OnAdReward() Something wrong - No AdContext");
630
+ }
565
631
 
566
- if (!isInterstitial)
632
+ if (!_isInterstitial)
567
633
  Ads.Events.OnRewardedReceived?.Invoke();
568
634
  }
569
635
 
@@ -575,13 +641,13 @@ namespace Amanotes.Core.Internal
575
641
  }
576
642
 
577
643
  _isRequesting = false;
578
- if (isInterstitial)
644
+ if (_isInterstitial)
579
645
  Ads.Events.OnInterstitialLoadSucceeded?.Invoke();
580
646
  }
581
647
 
582
648
  protected void OnAdLoadFailed(string error)
583
649
  {
584
- if (isInterstitial)
650
+ if (_isInterstitial)
585
651
  Ads.Events.OnInterstitialLoadFailed?.Invoke(error);
586
652
  }
587
653
  }
@@ -601,5 +667,7 @@ namespace Amanotes.Core.Internal
601
667
  public Action OnInterstitialClosed;
602
668
  public Action OnInterstitialLoadSucceeded;
603
669
  public Action<string> OnInterstitialLoadFailed;
670
+
671
+ public Action OnShowTimeout;
604
672
  }
605
673
  }
@@ -80,12 +80,7 @@ namespace Amanotes.Core
80
80
 
81
81
  public static IEventParamsBuilder LogEvent(string eventName)
82
82
  {
83
- if (string.IsNullOrWhiteSpace(eventName))
84
- {
85
- LogWarningOnce($"Invalid EventName: <{eventName}> ");
86
- return null;
87
- }
88
-
83
+ NormalizeEventName(ref eventName, true);
89
84
  var result = new EventParams(eventName);
90
85
  eventQueue.Enqueue(result);
91
86
  return result;
@@ -318,10 +313,9 @@ namespace Amanotes.Core
318
313
  }
319
314
 
320
315
  string eventNameToSend = GetEventNameToSend(eventData.eventName, countInSession, totalCount);
321
- NormalizeEventName(ref eventNameToSend);
316
+ if (Config.common.normalizeEventName) NormalizeEventName(ref eventNameToSend);
322
317
 
323
- if (showAnalyticsLog) Debug.Log($"AmaGDK v{AmaGDK.VERSION} | Event <{eventNameToSend}> (in session: {countInSession}, total: {totalCount})\n" +
324
- $"Params:\n{JsonUtils.DictionaryToJson(eventData.parameters, true)}");
318
+ if (showAnalyticsLog) Debug.Log($"AmaGDK v{AmaGDK.VERSION} | Event <{eventNameToSend}> (in session: {countInSession}, total: {totalCount})\n{JsonUtils.DictionaryToJson(eventData.parameters, true)}");
325
319
 
326
320
  var inUseAdapterIDs = new List<string>();
327
321
  foreach (AdapterContext m in listAdapters)
@@ -360,7 +354,7 @@ namespace Amanotes.Core
360
354
  return $"{eventName}_{(config.withinSession ? countInSession : totalCount).ToString(config.numberFormat)}";
361
355
  }
362
356
 
363
- internal static void NormalizeEventName(ref string eventName)
357
+ internal static void NormalizeEventName(ref string eventName, bool dryRun = false)
364
358
  {
365
359
  StringBuilder sb = tmpWarningSB;
366
360
  sb.Clear();
@@ -377,7 +371,7 @@ namespace Amanotes.Core
377
371
 
378
372
  if (eventName != normalizedEventName)
379
373
  {
380
- if (Config.common.normalizeEventName)
374
+ if (!dryRun)
381
375
  {
382
376
  eventName = normalizedEventName;
383
377
  }
@@ -389,7 +383,7 @@ namespace Amanotes.Core
389
383
 
390
384
  if (!char.IsLetter(eventName[0])) sb.AppendLine($" - EventName must start with a letter: <{eventName}> ");
391
385
  if (eventName.Length > 40) sb.AppendLine($" - EventName is too long ({eventName.Length} > 40): <{eventName}> ");
392
- if (sb.Length > 0) LogWarningOnce(sb.ToString(), $"NormalizeEventName<{eventName}>");
386
+ if (sb.Length > 0 && dryRun) LogWarningOnce(sb.ToString(), $"NormalizeEventName<{eventName}>");
393
387
  }
394
388
 
395
389
  internal static bool ShouldSendEvent(EventParams eventData)
@@ -22,7 +22,7 @@ namespace Amanotes.Core.Internal
22
22
 
23
23
  public static class Messsage
24
24
  {
25
- public const string READY = "init success!";
25
+ public const string READY = "init success";
26
26
  public const string SDK_INIT_CALLED = "init has been called!";
27
27
  public const string MULTIPLE_INSTANCE = "multiple instance found!";
28
28
  public const string CONFIG_NOT_FOUND = "AmaGDKConfig not found in Resources!";
@@ -79,19 +79,19 @@ namespace Amanotes.Core.Internal
79
79
  if (string.IsNullOrEmpty(key)) key = message;
80
80
  if (logWarningDict.Contains(key)) return;
81
81
  logWarningDict.Add(key);
82
- Debug.LogWarning($"AmaGDK v{VERSION} | {message}");
82
+ Debug.LogWarning($"AmaGDK {message}");
83
83
  }
84
84
  public static void LogWarning(string message)
85
85
  {
86
- Debug.LogWarning($"AmaGDK v{VERSION} | {message}");
86
+ Debug.LogWarning($"AmaGDK {message}");
87
87
  }
88
88
  public static void LogError(string message)
89
89
  {
90
- Debug.LogError($"AmaGDK v{VERSION} | {message}");
90
+ Debug.LogError($"AmaGDK {message}");
91
91
  }
92
92
  public static void Log(string message)
93
93
  {
94
- if (AmaGDK.Config.common.verboseLog) Debug.Log($"AmaGDK v{VERSION} | {message}");
94
+ if (AmaGDK.Config.common.verboseLog) Debug.Log($"AmaGDK {message}");
95
95
  }
96
96
  }
97
97
 
package/Runtime/AmaGDK.cs CHANGED
@@ -1,5 +1,6 @@
1
1
  using System;
2
2
  using System.Collections;
3
+ using System.Text;
3
4
  using Amanotes.Core.Internal;
4
5
  using UnityEngine;
5
6
  using static Amanotes.Core.Internal.Logging;
@@ -9,7 +10,7 @@ namespace Amanotes.Core
9
10
  {
10
11
  public partial class AmaGDK : MonoBehaviour
11
12
  {
12
- public const string VERSION = "0.2.8";
13
+ public const string VERSION = "0.2.9";
13
14
 
14
15
  internal static AmaGDK _instance;
15
16
  internal static Status _status = Status.None;
@@ -75,6 +76,8 @@ namespace Amanotes.Core
75
76
  }
76
77
 
77
78
  _status = Status.Initialize;
79
+ float startTime = Time.realtimeSinceStartup;
80
+ StringBuilder adapterInfo = new StringBuilder();
78
81
 
79
82
  // sort on priority
80
83
  Adapter.listAdapters.Sort((a1, a2) => a1.initOrder.CompareTo(a2.initOrder));
@@ -94,8 +97,8 @@ namespace Amanotes.Core
94
97
  LogWarning($"{adapter.adapterId} init time out: {timeout}");
95
98
  break;
96
99
  }
97
-
98
- Log($"Adapter {adapter.adapterId} {(adapter.IsReady ? "initiated!" : "is not ready!")}");
100
+
101
+ adapterInfo.AppendLine(string.Format("[{0}] {1} (adapter v{2})", adapter.IsReady ? "OK" : "FAIL", adapter.adapterId, adapter.adapterVersion));
99
102
  }
100
103
 
101
104
  // Init modules (Adapter managers)
@@ -106,7 +109,7 @@ namespace Amanotes.Core
106
109
  _status = Status.Ready;
107
110
  _onReadyCallback?.Invoke();
108
111
  _onReadyCallback = null;
109
- Debug.Log($"AmaGDK v{VERSION} | {READY}");
112
+ Debug.Log($"AmaGDK v{VERSION} | {READY} in {Time.realtimeSinceStartup - startTime}s\n\n{adapterInfo.ToString()}");
110
113
  }
111
114
 
112
115
  void RegisterUnityCallback(AdapterContext adapter)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.amanotes.gdk",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
4
4
  "displayName": "AmaGDK",
5
5
  "description": "Amanotes Game Development Kit",
6
6
  "unity": "2020.3",