com.amanotes.gdk 0.2.51 → 0.2.53
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 +17 -11
- package/Editor/AmaGDKEditor.cs +8 -4
- package/Editor/Extra/GDKCIBuildCommand.cs +354 -0
- package/Editor/Extra/GDKCIBuildCommand.cs.meta +3 -0
- package/Editor/Extra/GDKLocalBuild.cs +3 -2
- package/Editor/Extra/GDKProjectCP.cs +58 -0
- package/Editor/Utils/AmaGDKEditor.ExtractVersion.cs +90 -19
- package/Extra/AmaGDKInstaller.unitypackage +0 -0
- package/Extra/CheckDiskSpace.unitypackage +0 -0
- package/Extra/ForceUpdate.unitypackage +0 -0
- package/Extra/{AndroidPostProcessor.unitypackage.meta → ForceUpdate.unitypackage.meta} +1 -1
- package/Extra/PostProcessor.unitypackage +0 -0
- package/Extra/PostProcessor.unitypackage.meta +7 -0
- package/Extra/SDKVersionTracking.unitypackage +0 -0
- package/Packages/AmaGDKConfig.unitypackage +0 -0
- package/Packages/AmaGDKExample.unitypackage +0 -0
- package/Packages/AmaGDKTest.unitypackage +0 -0
- package/Packages/AppsFlyerAdapter.unitypackage +0 -0
- package/Packages/FirebaseAnalyticsAdapter.unitypackage +0 -0
- package/Packages/FirebaseRemoteConfigAdapter.unitypackage +0 -0
- package/Packages/IronSourceAdapter.unitypackage +0 -0
- package/Packages/RevenueCatAdapter.unitypackage +0 -0
- package/Runtime/AmaGDK.Analytics.cs +191 -61
- package/Runtime/AmaGDK.cs +34 -11
- package/Runtime/Internal/AmaGDK.Internal.cs +33 -0
- package/Runtime/Internal/AmaGDK.Utils.cs +28 -2
- package/package.json +1 -1
- package/Extra/AndroidPostProcessor.unitypackage +0 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -17,39 +17,63 @@ namespace Amanotes.Core
|
|
|
17
17
|
public static partial class Analytics
|
|
18
18
|
{
|
|
19
19
|
public static bool HasMigrated => localData.migrationLog.count > 0;
|
|
20
|
+
|
|
21
|
+
public static bool enableAnalyticsLog
|
|
22
|
+
{
|
|
23
|
+
set => Config.analytics.showAnalyticsLog = value;
|
|
24
|
+
get => Config.analytics.showAnalyticsLog;
|
|
25
|
+
}
|
|
20
26
|
|
|
21
27
|
public interface IEventParamsBuilder { }
|
|
22
28
|
|
|
23
29
|
public class EventParams : IEventParamsBuilder
|
|
24
30
|
{
|
|
25
|
-
public
|
|
26
|
-
public Dictionary<string, object> parameters = new Dictionary<string, object>();
|
|
31
|
+
public string eventName { get; private set; }
|
|
32
|
+
public readonly Dictionary<string, object> parameters = new Dictionary<string, object>();
|
|
27
33
|
public string funnelSignature;
|
|
28
34
|
public bool accumulated;
|
|
29
35
|
public bool withinSession;
|
|
30
36
|
public bool doNotIncreaseCounter;
|
|
31
37
|
|
|
32
38
|
public bool overrideConfig;
|
|
33
|
-
public HashSet<string> ignoreAdapterIds =
|
|
34
|
-
public HashSet<string> allowAdapterIds =
|
|
39
|
+
public HashSet<string> ignoreAdapterIds = null;
|
|
40
|
+
public HashSet<string> allowAdapterIds = null;
|
|
35
41
|
|
|
36
|
-
|
|
42
|
+
private EventDetail _detail;
|
|
43
|
+
public EventDetail EventDetail
|
|
44
|
+
{
|
|
45
|
+
get
|
|
46
|
+
{
|
|
47
|
+
if (_detail != null) return _detail;
|
|
48
|
+
return _detail = localData.GetEventDetail(eventName, true);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
37
51
|
|
|
38
|
-
|
|
52
|
+
internal EventParams Init(string eventName)
|
|
39
53
|
{
|
|
40
54
|
this.eventName = eventName;
|
|
55
|
+
parameters.Clear();
|
|
56
|
+
funnelSignature = "";
|
|
57
|
+
accumulated = false;
|
|
58
|
+
withinSession = false;
|
|
59
|
+
doNotIncreaseCounter = false;
|
|
60
|
+
overrideConfig = false;
|
|
61
|
+
ignoreAdapterIds = null;
|
|
62
|
+
allowAdapterIds = null;
|
|
63
|
+
_detail = null;
|
|
64
|
+
return this;
|
|
41
65
|
}
|
|
42
66
|
|
|
43
67
|
public bool IsFunnelEvent => !string.IsNullOrEmpty(funnelSignature);
|
|
44
68
|
|
|
45
69
|
public bool IsAdapterForbidden(string adapterId)
|
|
46
70
|
{
|
|
47
|
-
if (ignoreAdapterIds.Count > 0)
|
|
71
|
+
if (ignoreAdapterIds != null && ignoreAdapterIds.Count > 0)
|
|
48
72
|
{
|
|
49
73
|
return ignoreAdapterIds.Contains(adapterId);
|
|
50
74
|
}
|
|
51
75
|
|
|
52
|
-
if (allowAdapterIds.Count > 0)
|
|
76
|
+
if (allowAdapterIds != null && allowAdapterIds.Count > 0)
|
|
53
77
|
{
|
|
54
78
|
return !allowAdapterIds.Contains(adapterId);
|
|
55
79
|
}
|
|
@@ -164,12 +188,13 @@ namespace Amanotes.Core
|
|
|
164
188
|
}
|
|
165
189
|
|
|
166
190
|
if (eventCountMap != null)
|
|
191
|
+
{
|
|
167
192
|
foreach (KeyValuePair<string, int> e in eventCountMap)
|
|
168
193
|
{
|
|
169
194
|
EventDetail eventDetail = localData.GetEventDetail(e.Key);
|
|
170
195
|
if (eventDetail == null)
|
|
171
196
|
{
|
|
172
|
-
localData.
|
|
197
|
+
localData.AddEventDetail(new EventDetail
|
|
173
198
|
{
|
|
174
199
|
eventName = e.Key,
|
|
175
200
|
totalCount = e.Value
|
|
@@ -188,6 +213,8 @@ namespace Amanotes.Core
|
|
|
188
213
|
eventDetail.totalCount += e.Value;
|
|
189
214
|
}
|
|
190
215
|
}
|
|
216
|
+
}
|
|
217
|
+
|
|
191
218
|
|
|
192
219
|
Profiler.EndSample();
|
|
193
220
|
return flag;
|
|
@@ -252,8 +279,10 @@ namespace Amanotes.Core
|
|
|
252
279
|
internal static Predicate<EventParams> logEventHook;
|
|
253
280
|
internal static readonly ConcurrentQueue<EventParams> eventQueue = new ConcurrentQueue<EventParams>();
|
|
254
281
|
internal static readonly List<AnalyticsAdapter> listAdapters = new List<AnalyticsAdapter>();
|
|
255
|
-
internal static readonly AnalyticsData localData = new AnalyticsData().LoadJsonFromFile();
|
|
256
|
-
internal static readonly SessionStat sessionStat = new SessionStat();
|
|
282
|
+
internal static readonly AnalyticsData localData = new AnalyticsData().LoadJsonFromFile().BuildCache();
|
|
283
|
+
internal static readonly SessionStat sessionStat = _config.analytics.enableEventStat ? new SessionStat() : null;
|
|
284
|
+
internal static readonly Pool<StringBuilder> sbPool = new Pool<StringBuilder>(3);
|
|
285
|
+
internal static readonly Pool<EventParams> epPool = new Pool<EventParams>(1);
|
|
257
286
|
|
|
258
287
|
internal static readonly Dictionary<string, string> reservedPrefixes = new Dictionary<string, string>()
|
|
259
288
|
{
|
|
@@ -315,7 +344,7 @@ namespace Amanotes.Core
|
|
|
315
344
|
internal static EventParams PrepareEvent(string eventName)
|
|
316
345
|
{
|
|
317
346
|
PrepareEventCheck(eventName);
|
|
318
|
-
var result =
|
|
347
|
+
var result = epPool.Get().Init(eventName);
|
|
319
348
|
PostPrepareEventProcess(result);
|
|
320
349
|
return result;
|
|
321
350
|
}
|
|
@@ -324,7 +353,7 @@ namespace Amanotes.Core
|
|
|
324
353
|
{
|
|
325
354
|
if (parameters == null) return PrepareEvent(eventName);
|
|
326
355
|
PrepareEventCheck(eventName);
|
|
327
|
-
var result =
|
|
356
|
+
var result = epPool.Get().Init(eventName);
|
|
328
357
|
result.AddParam(parameters);
|
|
329
358
|
PostPrepareEventProcess(result);
|
|
330
359
|
return result;
|
|
@@ -334,7 +363,7 @@ namespace Amanotes.Core
|
|
|
334
363
|
{
|
|
335
364
|
if (parameters == null) return PrepareEvent(eventName);
|
|
336
365
|
PrepareEventCheck(eventName);
|
|
337
|
-
var result =
|
|
366
|
+
var result = epPool.Get().Init(eventName);
|
|
338
367
|
for (var i = 0; i < parameters.Length; i++)
|
|
339
368
|
{
|
|
340
369
|
result.AddParam(parameters[i].Item1, parameters[i].Item2);
|
|
@@ -348,18 +377,18 @@ namespace Amanotes.Core
|
|
|
348
377
|
if (eventQueue.Count <= 0) return;
|
|
349
378
|
|
|
350
379
|
Profiler.BeginSample("AmaGDK.Analytics.ProcessEventQueue()");
|
|
351
|
-
|
|
352
|
-
sessionStat
|
|
380
|
+
|
|
381
|
+
sessionStat?.Clear();
|
|
353
382
|
|
|
354
383
|
while (eventQueue.TryDequeue(out var eventData))
|
|
355
384
|
{
|
|
356
385
|
var (eventNameToSend, inUseAdapterIDs) = LogEventActually(eventData);
|
|
357
|
-
|
|
358
|
-
|
|
386
|
+
sessionStat?.Add(eventNameToSend, eventData, inUseAdapterIDs);
|
|
387
|
+
epPool.Return(eventData);
|
|
359
388
|
}
|
|
360
389
|
|
|
361
390
|
localData.SaveIfDirty();
|
|
362
|
-
sessionStat
|
|
391
|
+
sessionStat?.Save();
|
|
363
392
|
Profiler.EndSample();
|
|
364
393
|
}
|
|
365
394
|
|
|
@@ -384,7 +413,7 @@ namespace Amanotes.Core
|
|
|
384
413
|
|
|
385
414
|
config.quality.CheckEventQuality(eventParams.eventName, eventParams.parameters);
|
|
386
415
|
|
|
387
|
-
var inUseAdapterIDs = new List<string>();
|
|
416
|
+
var inUseAdapterIDs = config.enableEventStat ? new List<string>(listAdapters.Count) : null;
|
|
388
417
|
foreach (AnalyticsAdapter m in listAdapters)
|
|
389
418
|
{
|
|
390
419
|
if (eventParams.overrideConfig)
|
|
@@ -400,7 +429,7 @@ namespace Amanotes.Core
|
|
|
400
429
|
if (m.IsForbidden(eventParams.eventName)) continue;
|
|
401
430
|
}
|
|
402
431
|
m.LogEvent(eventNameToSend, eventParams.parameters);
|
|
403
|
-
inUseAdapterIDs
|
|
432
|
+
inUseAdapterIDs?.Add(m.adapterId);
|
|
404
433
|
}
|
|
405
434
|
|
|
406
435
|
return (eventNameToSend, inUseAdapterIDs);
|
|
@@ -409,9 +438,9 @@ namespace Amanotes.Core
|
|
|
409
438
|
internal static void LogEventImmediately(EventParams eventParams)
|
|
410
439
|
{
|
|
411
440
|
var (eventNameToSend, inUseAdapterIDs) = LogEventActually(eventParams);
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
sessionStat
|
|
441
|
+
sessionStat?.Add(eventNameToSend, eventParams, inUseAdapterIDs);
|
|
442
|
+
epPool.Return(eventParams);
|
|
443
|
+
sessionStat?.Save();
|
|
415
444
|
localData.SaveIfDirty();
|
|
416
445
|
}
|
|
417
446
|
|
|
@@ -452,12 +481,13 @@ namespace Amanotes.Core
|
|
|
452
481
|
{
|
|
453
482
|
Profiler.BeginSample("AmaGDK.Analytics.NormalizeEventName()");
|
|
454
483
|
{
|
|
455
|
-
StringBuilder sb =
|
|
484
|
+
StringBuilder sb = sbPool.Get();
|
|
456
485
|
sb.Clear();
|
|
457
486
|
NormalizeKeyString(ref eventName, sb, dryRun);
|
|
458
487
|
if (reservedEvents.Contains(eventName))
|
|
459
488
|
sb.AppendLine($" - EventName <{eventName}> is reserved and should not be used");
|
|
460
|
-
if (sb.Length > 0 && dryRun) LogWarningOnce($"
|
|
489
|
+
if (sb.Length > 0 && dryRun) LogWarningOnce($"NormalizeEventName <{eventName}> warnings:\n{sb}\n", $"NormalizeEventName<{eventName}>");
|
|
490
|
+
sbPool.Return(sb);
|
|
461
491
|
}
|
|
462
492
|
Profiler.EndSample();
|
|
463
493
|
}
|
|
@@ -473,57 +503,103 @@ namespace Amanotes.Core
|
|
|
473
503
|
return;
|
|
474
504
|
}
|
|
475
505
|
|
|
476
|
-
var
|
|
506
|
+
var tempLog = Config.common.logLevel == LogLevel.None ? null : sbPool.Get();
|
|
507
|
+
tempLog?.Clear();
|
|
508
|
+
|
|
509
|
+
var tempKey = sbPool.Get();
|
|
510
|
+
tempKey.Clear();
|
|
477
511
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
512
|
+
var hasChanged = false;
|
|
513
|
+
var trimKey = key.Trim();
|
|
514
|
+
|
|
515
|
+
foreach (var c in trimKey)
|
|
482
516
|
{
|
|
483
|
-
|
|
517
|
+
var isLetter = IsAlphabet(c);
|
|
518
|
+
var isNumber = char.IsDigit(c);
|
|
519
|
+
|
|
520
|
+
if (c == '_' || isLetter || isNumber)
|
|
521
|
+
{
|
|
522
|
+
tempKey.Append(c);
|
|
523
|
+
continue;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
hasChanged = true;
|
|
527
|
+
if (c == ' ' || c == '-')
|
|
528
|
+
{
|
|
529
|
+
tempKey.Append('_');
|
|
530
|
+
}
|
|
484
531
|
}
|
|
485
532
|
|
|
486
|
-
|
|
487
|
-
if (!r.IsMatch(normalizedString))
|
|
533
|
+
if (hasChanged)
|
|
488
534
|
{
|
|
489
|
-
|
|
490
|
-
sb.Append(" - Name may only contain alphanumeric characters and underscores");
|
|
535
|
+
tempLog?.Append(" - Name may only contain alphanumeric characters and underscores");
|
|
491
536
|
}
|
|
492
|
-
|
|
493
|
-
if (!
|
|
537
|
+
|
|
538
|
+
if (tempKey.Length > 0 && !IsAlphabet(tempKey[0]))
|
|
494
539
|
{
|
|
495
|
-
|
|
496
|
-
|
|
540
|
+
hasChanged = true;
|
|
541
|
+
tempKey.Insert(0, 'E');
|
|
542
|
+
tempLog?.Append($" - Name must start with a letter: <{key}>");
|
|
497
543
|
}
|
|
498
|
-
|
|
544
|
+
|
|
499
545
|
foreach (var prefix in reservedPrefixes)
|
|
500
546
|
{
|
|
501
|
-
if (!
|
|
502
|
-
|
|
503
|
-
|
|
547
|
+
if (tempKey.Length < prefix.Key.Length || !StringStartsWith(tempKey, prefix.Key)) continue;
|
|
548
|
+
hasChanged = true;
|
|
549
|
+
tempKey.Remove(0, prefix.Key.Length);
|
|
550
|
+
tempKey.Insert(0, prefix.Value);
|
|
551
|
+
tempLog?.AppendLine($" - <{key}> starts with reserved prefix <{prefix}>");
|
|
504
552
|
}
|
|
505
553
|
|
|
506
|
-
if (
|
|
554
|
+
if (trimKey.Length > 40)
|
|
507
555
|
{
|
|
508
|
-
|
|
509
|
-
|
|
556
|
+
hasChanged = true;
|
|
557
|
+
tempLog?.AppendLine($" - Name is too long ({key.Length} > 40): <{key}> ");
|
|
558
|
+
tempKey.Length = 40;
|
|
510
559
|
}
|
|
511
560
|
|
|
512
561
|
if (dryRun)
|
|
513
562
|
{
|
|
514
|
-
warningLog.Append(
|
|
563
|
+
warningLog.Append(tempLog);
|
|
515
564
|
} else {
|
|
516
|
-
key =
|
|
565
|
+
if (hasChanged) key = tempKey.ToString();
|
|
517
566
|
}
|
|
567
|
+
|
|
568
|
+
if (tempLog != null) sbPool.Return(tempLog);
|
|
569
|
+
sbPool.Return(tempKey);
|
|
518
570
|
}
|
|
519
571
|
Profiler.EndSample();
|
|
520
572
|
}
|
|
573
|
+
|
|
574
|
+
private static bool StringStartsWith(StringBuilder stringBuilder, string prefix)
|
|
575
|
+
{
|
|
576
|
+
if (stringBuilder == null || prefix == null)
|
|
577
|
+
return false;
|
|
578
|
+
|
|
579
|
+
if (stringBuilder.Length < prefix.Length)
|
|
580
|
+
return false;
|
|
581
|
+
|
|
582
|
+
for (int i = 0; i < prefix.Length; i++)
|
|
583
|
+
{
|
|
584
|
+
if (stringBuilder[i] != prefix[i])
|
|
585
|
+
return false;
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
return true;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
private static bool IsAlphabet(char c)
|
|
592
|
+
{
|
|
593
|
+
if (c >= 'A' && c <= 'Z') return true;
|
|
594
|
+
if (c >= 'a' && c <= 'z') return true;
|
|
595
|
+
return false;
|
|
596
|
+
}
|
|
521
597
|
|
|
522
598
|
internal static void PrepareEventCheck(string eventName)
|
|
523
599
|
{
|
|
524
600
|
NormalizeEventName(ref eventName, true);
|
|
525
601
|
|
|
526
|
-
if (localData.GetEventDetail(eventName) == null && localData.
|
|
602
|
+
if (localData.GetEventDetail(eventName) == null && localData.totalEventDetailCount >= 500)
|
|
527
603
|
{
|
|
528
604
|
LogWarning($" - You have reported 500 types of events. New event <{eventName}> will be ignored.");
|
|
529
605
|
}
|
|
@@ -625,23 +701,63 @@ namespace Amanotes.Core
|
|
|
625
701
|
internal class AnalyticsData : IJsonFile
|
|
626
702
|
{
|
|
627
703
|
public List<string> funnelSignatures = new List<string>();
|
|
628
|
-
|
|
704
|
+
|
|
629
705
|
public MigrationLog migrationLog = new MigrationLog();
|
|
630
706
|
[NonSerialized] internal bool _dirty;
|
|
631
|
-
|
|
707
|
+
|
|
708
|
+
[SerializeField] internal List<EventDetail> eventDetails = new List<EventDetail>();
|
|
709
|
+
internal readonly Dictionary<string, EventDetail> cachedEventDetails = new Dictionary<string, EventDetail>();
|
|
710
|
+
|
|
711
|
+
public int totalEventDetailCount => eventDetails.Count;
|
|
712
|
+
public bool AddEventDetail(EventDetail ed)
|
|
713
|
+
{
|
|
714
|
+
if (cachedEventDetails.ContainsKey(ed.eventName))
|
|
715
|
+
{
|
|
716
|
+
Debug.LogWarning($"EventName <{ed.eventName}> existed!");
|
|
717
|
+
return false;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
eventDetails.Add(ed);
|
|
721
|
+
cachedEventDetails.Add(ed.eventName, ed);
|
|
722
|
+
return true;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
internal AnalyticsData BuildCache()
|
|
726
|
+
{
|
|
727
|
+
if (cachedEventDetails.Count > 0)
|
|
728
|
+
{
|
|
729
|
+
LogWarning("BuildCache should be called once!");
|
|
730
|
+
cachedEventDetails.Clear();
|
|
731
|
+
}
|
|
732
|
+
|
|
733
|
+
for (var i = 0; i < eventDetails.Count; i++)
|
|
734
|
+
{
|
|
735
|
+
var item = eventDetails[i];
|
|
736
|
+
if (cachedEventDetails.ContainsKey(item.eventName))
|
|
737
|
+
{
|
|
738
|
+
LogWarning($"Duplicated eventName <{item.eventName}> entry found in AnalyticData!");
|
|
739
|
+
continue;
|
|
740
|
+
}
|
|
741
|
+
cachedEventDetails.Add(item.eventName, item);
|
|
742
|
+
}
|
|
743
|
+
return this;
|
|
744
|
+
}
|
|
745
|
+
|
|
632
746
|
internal EventDetail GetEventDetail(string eventName, bool autoNew = false)
|
|
633
747
|
{
|
|
634
748
|
if (string.IsNullOrEmpty(eventName)) return null;
|
|
635
749
|
|
|
636
|
-
|
|
637
|
-
|
|
750
|
+
if (cachedEventDetails.TryGetValue(eventName, out var result))
|
|
751
|
+
{
|
|
752
|
+
return result;
|
|
753
|
+
}
|
|
638
754
|
if (autoNew == false) return null;
|
|
639
755
|
|
|
640
756
|
result = new EventDetail
|
|
641
757
|
{
|
|
642
758
|
eventName = eventName
|
|
643
759
|
};
|
|
644
|
-
|
|
760
|
+
AddEventDetail(result);
|
|
645
761
|
_dirty = true;
|
|
646
762
|
return result;
|
|
647
763
|
}
|
|
@@ -706,14 +822,13 @@ namespace Amanotes.Core
|
|
|
706
822
|
|
|
707
823
|
internal void Add(string eventNameToSend, EventParams eventParams, List<string> adapterIDs)
|
|
708
824
|
{
|
|
825
|
+
if (string.IsNullOrEmpty(eventNameToSend) || adapterIDs == null) return;
|
|
709
826
|
var eventStat = new EventStat(eventNameToSend, eventParams, adapterIDs);
|
|
710
827
|
lastFrameEventStats.Enqueue(eventStat);
|
|
711
828
|
}
|
|
712
829
|
|
|
713
830
|
internal void Save()
|
|
714
831
|
{
|
|
715
|
-
if (!Config.analytics.enableEventStat || lastFrameEventStats.Count == 0) return;
|
|
716
|
-
|
|
717
832
|
contents.Clear();
|
|
718
833
|
if (isFirstSave)
|
|
719
834
|
{
|
|
@@ -728,9 +843,19 @@ namespace Amanotes.Core
|
|
|
728
843
|
|
|
729
844
|
GDKFileUtils.SaveAppend(fileName, contents.ToString());
|
|
730
845
|
}
|
|
846
|
+
|
|
847
|
+
internal void Clear()
|
|
848
|
+
{
|
|
849
|
+
//Clear() is supported from .Net Standard 2.1
|
|
850
|
+
#if UNITY_2021_3_OR_NEWER
|
|
851
|
+
sessionStat?.savedEventStatsInLastFrame.Clear();
|
|
852
|
+
#else
|
|
853
|
+
while (savedEventStatsInLastFrame.TryDequeue(out var stat))
|
|
854
|
+
{
|
|
855
|
+
}
|
|
856
|
+
#endif
|
|
857
|
+
}
|
|
731
858
|
}
|
|
732
|
-
|
|
733
|
-
|
|
734
859
|
}
|
|
735
860
|
}
|
|
736
861
|
|
|
@@ -781,6 +906,8 @@ namespace Amanotes.Core
|
|
|
781
906
|
}
|
|
782
907
|
|
|
783
908
|
eventData.overrideConfig = true;
|
|
909
|
+
eventData.ignoreAdapterIds ??= new HashSet<string>();
|
|
910
|
+
|
|
784
911
|
foreach (string mId in analyticIds)
|
|
785
912
|
{
|
|
786
913
|
eventData.ignoreAdapterIds.Add(mId);
|
|
@@ -805,6 +932,8 @@ namespace Amanotes.Core
|
|
|
805
932
|
}
|
|
806
933
|
|
|
807
934
|
eventData.overrideConfig = true;
|
|
935
|
+
eventData.allowAdapterIds ??= new HashSet<string>();
|
|
936
|
+
|
|
808
937
|
foreach (string mId in analyticIds)
|
|
809
938
|
{
|
|
810
939
|
eventData.allowAdapterIds.Add(mId);
|
|
@@ -879,11 +1008,12 @@ namespace Amanotes.Core
|
|
|
879
1008
|
{
|
|
880
1009
|
string eventName = (ap as EventParams)?.eventName;
|
|
881
1010
|
|
|
882
|
-
StringBuilder sb =
|
|
1011
|
+
StringBuilder sb = sbPool.Get();
|
|
883
1012
|
sb.Clear();
|
|
884
1013
|
NormalizeKeyString(ref key, sb, AmaGDK.Config.analytics.normalizeEventName);
|
|
885
1014
|
|
|
886
1015
|
if (sb.Length > 0) LogWarningOnce($"Warning for event <{eventName}>, param <{key}>:\n{sb}", $"NormalizeParamKey <{eventName}>");
|
|
1016
|
+
sbPool.Return(sb);
|
|
887
1017
|
|
|
888
1018
|
if (string.IsNullOrWhiteSpace(key))
|
|
889
1019
|
{
|
|
@@ -918,7 +1048,7 @@ namespace Amanotes.Core.Internal
|
|
|
918
1048
|
[Serializable] public class AnalyticsConfig
|
|
919
1049
|
{
|
|
920
1050
|
// [Header("----- MODULE CONFIG -----")]
|
|
921
|
-
public bool showAnalyticsLog
|
|
1051
|
+
public bool showAnalyticsLog;
|
|
922
1052
|
public bool normalizeEventName = true;
|
|
923
1053
|
public bool checkMigrationIntegrity = true;
|
|
924
1054
|
public bool migrateAccumulatedCount = true;
|
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.
|
|
20
|
+
public const string VERSION = "0.2.53";
|
|
21
21
|
|
|
22
22
|
internal static AmaGDK _instance;
|
|
23
23
|
internal static Status _status = Status.None;
|
|
@@ -90,7 +90,7 @@ namespace Amanotes.Core
|
|
|
90
90
|
});
|
|
91
91
|
yield return new WaitUntil(() => hookCompleted);
|
|
92
92
|
float elapsed = Time.realtimeSinceStartup - stTime;
|
|
93
|
-
Log($"[Hook] {nHooks} hooks complete after "
|
|
93
|
+
Log($"[Hook] {nHooks} hooks complete after {elapsed} secs");
|
|
94
94
|
dispatcher.Dispatch(Event.GDK_HOOK_END);
|
|
95
95
|
}
|
|
96
96
|
|
|
@@ -304,10 +304,10 @@ namespace Amanotes.Core
|
|
|
304
304
|
public partial class AmaGDK // Switch dev mode
|
|
305
305
|
{
|
|
306
306
|
#if UNITY_EDITOR
|
|
307
|
-
[ContextMenu("Change Dev Mode")]
|
|
307
|
+
[ContextMenu("Change To Dev Mode")]
|
|
308
308
|
public void ChangeDevMode()
|
|
309
309
|
{
|
|
310
|
-
string variableName = "GDK_HOME";
|
|
310
|
+
const string variableName = "GDK_HOME";
|
|
311
311
|
string zshrcPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".zshrc");
|
|
312
312
|
string zshrcContent;
|
|
313
313
|
|
|
@@ -341,13 +341,19 @@ namespace Amanotes.Core
|
|
|
341
341
|
Debug.LogWarning($"{variableName} environment variable is set but has an empty value in {zshrcPath}.");
|
|
342
342
|
return;
|
|
343
343
|
}
|
|
344
|
+
|
|
345
|
+
if (!Directory.Exists(gdkHomeValue))
|
|
346
|
+
{
|
|
347
|
+
Debug.LogWarning($"{variableName} environment variable is set to <{gdkHomeValue}> but the path is not exist!");
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
344
350
|
}
|
|
345
351
|
|
|
346
352
|
string output = RunShellCommand($"source ~/.zshrc && echo file:${variableName}");
|
|
347
353
|
output = output.Trim();
|
|
348
|
-
UpdateManifest(output);
|
|
349
|
-
|
|
350
|
-
UnityEditor.AssetDatabase.Refresh();
|
|
354
|
+
UpdateManifest(output);
|
|
355
|
+
|
|
356
|
+
UnityEditor.AssetDatabase.Refresh(UnityEditor.ImportAssetOptions.ForceUpdate);
|
|
351
357
|
}
|
|
352
358
|
|
|
353
359
|
private string RunShellCommand(string command)
|
|
@@ -368,11 +374,28 @@ namespace Amanotes.Core
|
|
|
368
374
|
|
|
369
375
|
private void UpdateManifest(string strDesired)
|
|
370
376
|
{
|
|
371
|
-
|
|
372
|
-
|
|
377
|
+
try
|
|
378
|
+
{
|
|
379
|
+
const string manifestPath = "Packages/manifest.json";
|
|
380
|
+
string manifestJson = File.ReadAllText(manifestPath);
|
|
373
381
|
|
|
374
|
-
|
|
375
|
-
|
|
382
|
+
string pattern = "\"com\\.amanotes\\.gdk\": \"(.*)\"";
|
|
383
|
+
string devModeEntry = $"\"com.amanotes.gdk\": \"{strDesired}\"";
|
|
384
|
+
|
|
385
|
+
manifestJson = Regex.Replace(manifestJson, pattern, devModeEntry);
|
|
386
|
+
File.WriteAllText(manifestPath, manifestJson);
|
|
387
|
+
|
|
388
|
+
if (!File.ReadAllText(manifestPath).Contains(devModeEntry))
|
|
389
|
+
{
|
|
390
|
+
Debug.LogWarning($"AmaGDK changes to dev mode failed. The expected value is: {devModeEntry}");
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
Debug.Log("AmaGDK changes to dev mode successfully");
|
|
394
|
+
}
|
|
395
|
+
catch (Exception e)
|
|
396
|
+
{
|
|
397
|
+
Debug.LogWarning($"AmaGDK changes to dev exception: {e.Message}");
|
|
398
|
+
}
|
|
376
399
|
}
|
|
377
400
|
#endif
|
|
378
401
|
}
|