com.amanotes.gdk 0.1.10 → 0.1.11

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.
Files changed (32) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/Editor/AmaGDKEditor.cs +32 -77
  3. package/Editor/AmaGDKManager.cs +236 -0
  4. package/Editor/AmaGDKManager.cs.meta +11 -0
  5. package/Editor/Resources/amasdk-modules.json +31 -0
  6. package/Editor/Resources/amasdk-modules.json.meta +7 -0
  7. package/Editor/Resources.meta +8 -0
  8. package/Editor/Utils/AmaGDKEditor.ExtractVersion.cs +171 -0
  9. package/Editor/Utils/AmaGDKEditor.ExtractVersion.cs.meta +11 -0
  10. package/Editor/Utils/AmaGDKEditor.GUI.cs +82 -0
  11. package/Editor/Utils/AmaGDKEditor.GUI.cs.meta +11 -0
  12. package/Editor/Utils/AmaGDKEditor.Utils.cs +35 -0
  13. package/Editor/Utils/AmaGDKEditor.Utils.cs.meta +11 -0
  14. package/Editor/Utils.meta +8 -0
  15. package/Packages/AmaGDKConfig.unitypackage +0 -0
  16. package/Packages/AmaGDKExample.unitypackage +0 -0
  17. package/Packages/AmaGDKExample.unitypackage.meta +7 -0
  18. package/Packages/AppsflyerAdapter_v6.5.4.unitypackage +0 -0
  19. package/Packages/AppsflyerAdapter_v6.5.4.unitypackage.meta +7 -0
  20. package/Packages/FirebaseAnalyticsAdapter_v9.1.0.unitypackage +0 -0
  21. package/Runtime/AmaGDK.Analytics.cs +39 -5
  22. package/Runtime/AmaGDK.Internal.cs +25 -1
  23. package/Runtime/AmaGDK.cs +2 -2
  24. package/Samples~/Example/AmaGDKExample.cs +87 -0
  25. package/Samples~/Example/AmaGDKExample.cs.meta +11 -0
  26. package/Samples~/Example/AmaGDKExample.unity +3114 -0
  27. package/Samples~/Example/AmaGDKExample.unity.meta +7 -0
  28. package/Sample~/Example/AmaGDKExample.cs +87 -0
  29. package/Sample~/Example/AmaGDKExample.cs.meta +11 -0
  30. package/Sample~/Example/AmaGDKExample.unity +3114 -0
  31. package/Sample~/Example/AmaGDKExample.unity.meta +7 -0
  32. package/package.json +1 -1
@@ -0,0 +1,82 @@
1
+ using System;
2
+ using System.Collections;
3
+ using System.Collections.Generic;
4
+ using UnityEditor;
5
+ using UnityEngine;
6
+
7
+ namespace Amanotes.Editor
8
+ {
9
+ public static class GUI
10
+ {
11
+ static Color LIGHT_BLUE = new Color(0.25f, 0.5f, 1f);
12
+
13
+ static GUIStyle BIG_LABEL = null;
14
+
15
+ public static void SectionLabel(string text)
16
+ {
17
+ if (BIG_LABEL == null)
18
+ {
19
+ BIG_LABEL = new GUIStyle(UnityEngine.GUI.skin.label)
20
+ {
21
+ fontSize = 18,
22
+ alignment = TextAnchor.MiddleCenter,
23
+ richText = true
24
+ };
25
+
26
+ BIG_LABEL.normal.textColor = Color.white;
27
+ }
28
+
29
+ Rect rect = GUILayoutUtility.GetRect(Screen.width, 32);
30
+ rect.xMin -= 16f;
31
+ EditorGUI.DrawRect(rect, LIGHT_BLUE);
32
+ EditorGUI.LabelField(rect, text, BIG_LABEL);
33
+ }
34
+
35
+ public static bool BigButton(string label, float height = 16f, Color? color = null, float colorMod = 0.5f)
36
+ {
37
+ var bgColor = UnityEngine.GUI.backgroundColor;
38
+
39
+ bool result;
40
+ if (color != null)
41
+ {
42
+ var c = (colorMod < 0f) ? Color.Lerp(color.Value, Color.black, -colorMod)
43
+ : (colorMod > 0f) ? Color.Lerp(color.Value, Color.white, colorMod) : color.Value;
44
+ UnityEngine.GUI.backgroundColor = c;
45
+ }
46
+ {
47
+ result = GUILayout.Button(label, GUILayout.Height(height));
48
+ }
49
+ if (color != null) UnityEngine.GUI.backgroundColor = bgColor;
50
+ return result;
51
+ }
52
+
53
+ public static bool Toggle(string label, ref bool value)
54
+ {
55
+ var newValue = EditorGUILayout.Toggle(label, value);
56
+ if (newValue == value) return false;
57
+
58
+ value = newValue;
59
+ return true;
60
+ }
61
+
62
+ public static bool ToggleGroup(string label, ref bool isOpen, Action drawFunc, Action titleFunc = null){
63
+ GUILayout.BeginHorizontal();
64
+ var newValue = EditorGUILayout.Foldout(isOpen, label);
65
+ var changed = newValue != isOpen;
66
+ titleFunc?.Invoke();
67
+ GUILayout.EndHorizontal();
68
+
69
+ if (isOpen)
70
+ {
71
+ EditorGUI.indentLevel++;
72
+ drawFunc();
73
+ EditorGUI.indentLevel--;
74
+ }
75
+
76
+ if (!changed) return false;
77
+
78
+ isOpen = newValue;
79
+ return true;
80
+ }
81
+ }
82
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 3e22cadf10a36442f9c330cd96560105
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,35 @@
1
+ using System;
2
+ using System.Collections;
3
+ using UnityEditor;
4
+ using UnityEngine;
5
+
6
+ namespace Amanotes.Editor
7
+ {
8
+ public static class Utils
9
+ {
10
+ public static void StartEditorCoroutine(this IEnumerator update, Action end = null)
11
+ {
12
+ EditorApplication.CallbackFunction closureCallback = null;
13
+
14
+ closureCallback = () =>
15
+ {
16
+ try
17
+ {
18
+ if (update.MoveNext() == false)
19
+ {
20
+ end?.Invoke();
21
+ EditorApplication.update -= closureCallback;
22
+ }
23
+ }
24
+ catch (Exception ex)
25
+ {
26
+ end?.Invoke();
27
+ Debug.LogException(ex);
28
+ EditorApplication.update -= closureCallback;
29
+ }
30
+ };
31
+
32
+ EditorApplication.update += closureCallback;
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: f9a4ffdedf54b4782bb27923c4096eaa
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,8 @@
1
+ fileFormatVersion: 2
2
+ guid: 61beaa5df6bc4435b9a397f7bdd79ab7
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
Binary file
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: 6d185dbf1f37b42ac94953317558aca6
3
+ DefaultImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: ab7f4809a233742778d8686d6d64cc7f
3
+ DefaultImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
@@ -8,7 +8,22 @@ using IEventParamsBuilder = Amanotes.Core.AmaGDK.Analytics.IEventParamsBuilder;
8
8
  using EventParams = Amanotes.Core.AmaGDK.Analytics.EventParams;
9
9
 
10
10
  namespace Amanotes.Core
11
- {
11
+ {
12
+ [Serializable]
13
+ public class AnalyticsAdapterBaseConfig
14
+ {
15
+ public bool SendEventByDefault;
16
+ public List<string> NeverSend;
17
+ public List<string> AlwaysSend;
18
+
19
+ public bool AllowSend(string eventName)
20
+ {
21
+ return SendEventByDefault
22
+ ? !NeverSend.Contains(eventName)
23
+ : AlwaysSend.Contains(eventName);
24
+ }
25
+ }
26
+
12
27
  partial class AmaGDK
13
28
  {
14
29
  //PUBLIC APIS
@@ -224,6 +239,8 @@ namespace Amanotes.Core
224
239
 
225
240
  foreach (var m in listAdapters)
226
241
  {
242
+ if (!eventData.allowAnalyticIds.Contains(m.id))
243
+ continue;
227
244
  if (eventData.ignoreAnalyticIds.Contains(m.id))
228
245
  continue;
229
246
  m.GetAdapterApi<IAnalyticAdapter>().LogEvent(eventData);
@@ -288,10 +305,10 @@ namespace Amanotes.Core
288
305
  [Serializable]
289
306
  public class EventDetail
290
307
  {
291
- public string eventName;
292
- public int totalCount;
308
+ public string eventName;
293
309
  [NonSerialized]
294
310
  public int countInSession;
311
+ public int totalCount;
295
312
  }
296
313
 
297
314
  [Flags]
@@ -360,8 +377,8 @@ namespace Amanotes.Core
360
377
  internal (int countInSession, int totalCount) IncreaseCounter(string eventName)
361
378
  {
362
379
  var result = GetEventDetail(eventName, true);
363
- result.totalCount++;
364
380
  result.countInSession++;
381
+ result.totalCount++;
365
382
  _dirty = true;
366
383
  return (result.countInSession, result.totalCount);
367
384
  }
@@ -417,7 +434,7 @@ namespace Amanotes.Core
417
434
 
418
435
  EventParams data = ap as EventParams;
419
436
  data.accumulated = true;
420
- if (withinSession) data.withinSession = true;
437
+ data.withinSession = withinSession;
421
438
  return ap;
422
439
  }
423
440
 
@@ -480,6 +497,23 @@ namespace Amanotes.Core
480
497
  return ap;
481
498
  }
482
499
 
500
+ public static IEventParamsBuilder AddParam(this IEventParamsBuilder ap, params (string key, object value)[] parameters)
501
+ {
502
+ if (ap == null) return null;
503
+ if (parameters.Length == 0)
504
+ {
505
+ LogWarning($"Param tuple is null. Event name: {(ap as EventParams).eventName}!");
506
+ return ap;
507
+ }
508
+
509
+ foreach (var kvp in parameters)
510
+ {
511
+ if (IsValidKeyValue(ap, kvp.key, kvp.value))
512
+ ap.AddParam(kvp.key, kvp.value);
513
+ }
514
+ return ap;
515
+ }
516
+
483
517
  static bool IsValidKeyValue(IEventParamsBuilder ap, string key, object value)
484
518
  {
485
519
  string eventName = (ap as EventParams).eventName;
@@ -5,6 +5,10 @@ using System.Collections.Generic;
5
5
  using UnityEngine;
6
6
  using UnityObject = UnityEngine.Object;
7
7
 
8
+ #if UNITY_EDITOR
9
+ using UnityEditor;
10
+ #endif
11
+
8
12
  namespace Amanotes.Core.Internal
9
13
  {
10
14
  public enum Status
@@ -38,9 +42,29 @@ namespace Amanotes.Core.Internal
38
42
  public static readonly string[] AMAGDK_ADAPTERS = new string[]
39
43
  {
40
44
  "FirebaseAnalyticsAdapter_v9.1.0",
41
- //"AppsflyerAdapter_v6.5.4",
45
+ "AppsflyerAdapter_v6.5.4",
42
46
  // "IronsourceAdapter_v7.2.6",
43
47
  };
48
+
49
+ #if UNITY_EDITOR
50
+
51
+ [MenuItem("GameObject/AmaGDK/Add AmaGDK Prefab", false, 10)]
52
+ private static void AddAmaGDKPrefab()
53
+ {
54
+ GameObject prefab = AssetDatabase.LoadAssetAtPath<GameObject>(AMAGDK_PREFAB);
55
+ if (prefab == null)
56
+ {
57
+ Debug.LogWarning($"Prefab [AmaGDK] not found at: {AMAGDK_PREFAB}");
58
+ return;
59
+ }
60
+
61
+ GameObject newPrefab = PrefabUtility.InstantiatePrefab(prefab) as GameObject;
62
+ newPrefab.name = "AmaGDK";
63
+ newPrefab.transform.SetAsLastSibling();
64
+ Selection.activeObject = null;
65
+ Selection.activeObject = newPrefab;
66
+ }
67
+ #endif
44
68
  }
45
69
 
46
70
 
package/Runtime/AmaGDK.cs CHANGED
@@ -12,7 +12,7 @@ namespace Amanotes.Core
12
12
  {
13
13
  public partial class AmaGDK : MonoBehaviour
14
14
  {
15
- public const string VERSION = "0.1.10";
15
+ public const string VERSION = "0.1.11";
16
16
 
17
17
  internal static AmaGDK _instance;
18
18
  internal static event Action _frameUpdate;
@@ -177,7 +177,7 @@ namespace Amanotes.Core
177
177
  public const string FIREBASE_ANALYTICS = "FirebaseAnalytics";
178
178
  public const string FIREBASE_REMOTE_CONFIG = "FirebaseRemoteConfig";
179
179
  public const string APPSFLYER = "Appsflyer";
180
- public const string IRONSOURCE = "ironSource";
180
+ public const string IRONSOURCE = "IronSource";
181
181
  public const string REVENUECAT = "RevenueCat";
182
182
  }
183
183
  }
@@ -0,0 +1,87 @@
1
+ using System.Collections;
2
+ using System.Collections.Generic;
3
+ using UnityEngine;
4
+ using Amanotes.Core;
5
+
6
+ public class AmaGDKExample : MonoBehaviour
7
+ {
8
+ private void Start()
9
+ {
10
+ //Config: log at even count
11
+ AmaGDK.Analytics.SetLogEventCondition((eventDetail) =>
12
+ {
13
+ if (eventDetail.eventName == "even_count")
14
+ {
15
+ return eventDetail.count % 2 == 0;
16
+ }
17
+
18
+ return true;
19
+ });
20
+ }
21
+
22
+ public void OnInitSDKClick()
23
+ {
24
+ AmaGDK.Init();
25
+ }
26
+
27
+ public void OnLogEventClick()
28
+ {
29
+ Debug.Log("Log test event");
30
+ AmaGDK.Analytics.LogEvent("TestEvent");
31
+ }
32
+
33
+ public void SaveUser()
34
+ {
35
+ var user = AmaGDK.User;
36
+ user.amaId = "3";
37
+ user.amaDeviceId = "4";
38
+ Debug.Log($"[Save] ama_id: {user.amaId},\nama_device_id: {user.amaDeviceId}");
39
+ AmaGDK.User.Save();
40
+ }
41
+
42
+ public void LoadUser()
43
+ {
44
+ var user = AmaGDK.User;
45
+ Debug.Log($"[Load] ama_id: {user.amaId},\nama_device_id: {user.amaDeviceId}");
46
+ }
47
+
48
+ public void LogFunnelWithSignature()
49
+ {
50
+ AmaGDK.Analytics.LogFunnelEvent("funnel", "TestFunnel1");
51
+ }
52
+
53
+ public void LogFunnelWithoutSignature()
54
+ {
55
+ AmaGDK.Analytics.LogFunnelEvent("funnel");
56
+ }
57
+
58
+ public void LogAccumulatedEvent()
59
+ {
60
+ AmaGDK.Analytics.LogEvent("accu").SetAsAccumulated();
61
+ }
62
+
63
+ public void LogWithEven()
64
+ {
65
+ AmaGDK.Analytics.LogEvent("even_count");
66
+ }
67
+
68
+ public void ShowBanner()
69
+ {
70
+ AmaGDK.Ads.ShowBanner();
71
+ }
72
+
73
+ public void HideBanner()
74
+ {
75
+ AmaGDK.Ads.HideBanner();
76
+ }
77
+
78
+ public void ShowInterstitial()
79
+ {
80
+ AmaGDK.Ads.ShowInterstitial();
81
+ }
82
+
83
+ public void ShowReward()
84
+ {
85
+ AmaGDK.Ads.ShowRewardedVideo();
86
+ }
87
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 289f046fd8a0c46b790440a86ed22453
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant: