com.amanotes.gdk 0.2.13 → 0.2.16

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 (30) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/Editor/EmbedRemoteConfigAssetInspector.cs +191 -0
  3. package/Editor/EmbedRemoteConfigAssetInspector.cs.meta +11 -0
  4. package/Editor/MatchSDKVersion.cs +151 -0
  5. package/Editor/MatchSDKVersion.cs.meta +11 -0
  6. package/Editor/Utils/AmaGDKEditor.ExtractVersion.cs +1 -1
  7. package/Editor/Utils/AmaGDKEditor.Utils.cs +52 -0
  8. package/Extra/AmaGDKInstaller.unitypackage +0 -0
  9. package/Extra/AmaGDKProject.unitypackage +0 -0
  10. package/Packages/AdjustAdapter_v4.33.0.unitypackage +0 -0
  11. package/Packages/AmaGDKConfig.unitypackage +0 -0
  12. package/Packages/AmaGDKExample.unitypackage +0 -0
  13. package/Packages/AmaGDKTest.unitypackage +0 -0
  14. package/Packages/AmaPassport.ATTSupport.unitypackage +0 -0
  15. package/Packages/AmaPassportAdapter_v1.0.0.unitypackage +0 -0
  16. package/Packages/AppsFlyerAdapter_v6.5.4.unitypackage +0 -0
  17. package/Packages/FirebaseAnalyticsAdapter_v9.1.0.unitypackage +0 -0
  18. package/Packages/FirebaseRemoteConfigAdapter_v9.1.0.unitypackage +0 -0
  19. package/Packages/IronsourceAdapter_v7.2.6.unitypackage +0 -0
  20. package/Runtime/AmaGDK.AmaPassport.cs +1 -0
  21. package/Runtime/AmaGDK.Analytics.cs +22 -3
  22. package/Runtime/AmaGDK.IAP.cs +423 -0
  23. package/Runtime/AmaGDK.IAP.cs.meta +11 -0
  24. package/Runtime/AmaGDK.RemoteConfig.cs +73 -43
  25. package/Runtime/AmaGDK.cs +3 -2
  26. package/Runtime/AnalyticQualityAsset.cs +218 -0
  27. package/Runtime/AnalyticQualityAsset.cs.meta +11 -0
  28. package/Runtime/EmbedRemoteConfigAsset.cs +59 -0
  29. package/Runtime/EmbedRemoteConfigAsset.cs.meta +11 -0
  30. package/package.json +2 -2
@@ -0,0 +1,218 @@
1
+ using System;
2
+ using System.Collections.Generic;
3
+ using System.Linq;
4
+ using System.Text;
5
+ using UnityEngine;
6
+ using static Amanotes.Core.Internal.Logging;
7
+ #if UNITY_EDITOR
8
+ using UnityEditor;
9
+ #endif
10
+
11
+ namespace Amanotes.Core
12
+ {
13
+ public enum ParamType
14
+ {
15
+ String,
16
+ Integer,
17
+ RealNumber
18
+ }
19
+
20
+ [Serializable]
21
+ public class EventParam
22
+ {
23
+ public string paramName;
24
+ public ParamType type;
25
+ public bool isOptional;
26
+ }
27
+
28
+ [Serializable]
29
+ public class EventQuality
30
+ {
31
+ public string eventName;
32
+ public List<EventParam> lstParam;
33
+
34
+ private Dictionary<string, EventParam> dicParam = null;
35
+
36
+ internal Dictionary<string, EventParam> DicParam
37
+ {
38
+ get
39
+ {
40
+ if (dicParam == null) BuildCache();
41
+ return dicParam;
42
+ }
43
+ }
44
+
45
+ private void BuildCache()
46
+ {
47
+ dicParam = new Dictionary<string, EventParam>();
48
+ foreach (var param in lstParam)
49
+ {
50
+ if (dicParam.ContainsKey(param.paramName)) continue;
51
+
52
+ dicParam.Add(param.paramName, param);
53
+ }
54
+ }
55
+
56
+ private bool IsNumericType(Type type)
57
+ {
58
+ return type == typeof(int) ||
59
+ type == typeof(long) ||
60
+ type == typeof(short) ||
61
+ type == typeof(byte) ||
62
+ type == typeof(double) ||
63
+ type == typeof(float) ||
64
+ type == typeof(decimal) ||
65
+ type == typeof(uint) ||
66
+ type == typeof(ulong) ||
67
+ type == typeof(ushort) ||
68
+ type == typeof(sbyte);
69
+ }
70
+
71
+ private bool IsIntegerType(Type type)
72
+ {
73
+ return type == typeof(sbyte) ||
74
+ type == typeof(byte) ||
75
+ type == typeof(short) ||
76
+ type == typeof(ushort) ||
77
+ type == typeof(int) ||
78
+ type == typeof(uint) ||
79
+ type == typeof(long) ||
80
+ type == typeof(ulong);
81
+ }
82
+
83
+ internal void ValidateParams(string eventName, Dictionary<string, object> eventParams)
84
+ {
85
+ StringBuilder logBuilder = new StringBuilder();
86
+ logBuilder.AppendLine($"Analytics quality violation found for event <{eventName}>");
87
+ bool isValid = true;
88
+ HashSet<string> checkedParameters = new HashSet<string>();
89
+
90
+ foreach (var kvp in DicParam)
91
+ {
92
+ if (!eventParams.ContainsKey(kvp.Key))
93
+ {
94
+ if (!kvp.Value.isOptional)
95
+ {
96
+ isValid = false;
97
+ logBuilder.AppendLine($"[-] {kvp.Key}");
98
+ }
99
+ continue;
100
+ }
101
+
102
+ object paramValue = eventParams[kvp.Key];
103
+
104
+ if (!ValidateParamType(paramValue, kvp.Value.type))
105
+ {
106
+ isValid = false;
107
+ logBuilder.AppendLine($"[X] {kvp.Key}. Input type {paramValue.GetType()}, Expected type: {kvp.Value.type.ToString()}.");
108
+ }
109
+
110
+ checkedParameters.Add(kvp.Key);
111
+ }
112
+
113
+ foreach (var parameter in eventParams)
114
+ {
115
+ if (checkedParameters.Contains(parameter.Key)) continue;
116
+
117
+ isValid = false;
118
+ logBuilder.AppendLine($"[+] {parameter.Key}");
119
+ }
120
+
121
+ if (!isValid) LogWarningOnce(logBuilder.ToString());
122
+ }
123
+
124
+ private bool ValidateParamType(object paramValue, ParamType paramType)
125
+ {
126
+ bool isValidType = false;
127
+
128
+ switch (paramType)
129
+ {
130
+ case ParamType.String:
131
+ isValidType = paramValue is string;
132
+ break;
133
+ case ParamType.Integer:
134
+ isValidType = IsIntegerType(paramValue.GetType());
135
+ break;
136
+ case ParamType.RealNumber:
137
+ isValidType = IsNumericType(paramValue.GetType());
138
+ break;
139
+ default:
140
+ LogWarningOnce($"Unsupported EventParam type: + {paramType}");
141
+ break;
142
+ }
143
+
144
+ return isValidType;
145
+ }
146
+ }
147
+
148
+ [CreateAssetMenu(fileName = "AmaGDKAnalyticsQuality", menuName = "Ama GDK/Analytics Quality", order = 3)]
149
+ [Serializable]
150
+ public class AnalyticQualityAsset : ScriptableObject
151
+ {
152
+ [SerializeField] private List<EventQuality> lstEvent = new List<EventQuality>();
153
+
154
+ private Dictionary<string, EventQuality> dictEvent = null;
155
+ private void BuildCache()
156
+ {
157
+ dictEvent = new Dictionary<string, EventQuality>();
158
+ foreach (var evt in lstEvent)
159
+ {
160
+ if (dictEvent.ContainsKey(evt.eventName))
161
+ {
162
+ LogWarningOnce($"Duplicate event: {evt.eventName}");
163
+ continue;
164
+ }
165
+
166
+ dictEvent.Add(evt.eventName, evt);
167
+ }
168
+ }
169
+
170
+ private Dictionary<string, EventQuality> DictEvent
171
+ {
172
+ get
173
+ {
174
+ if (dictEvent == null) BuildCache();
175
+ return dictEvent;
176
+ }
177
+ }
178
+ #if UNITY_EDITOR
179
+ [ContextMenu("Validate Unique EventNames")]
180
+ private void ValidateUniqueEventNames()
181
+ {
182
+ HashSet<string> eventNames = new HashSet<string>();
183
+
184
+ lstEvent = lstEvent.OrderBy(evt => evt.eventName).ToList();
185
+
186
+ foreach (EventQuality eventQuality in lstEvent)
187
+ {
188
+ if (string.IsNullOrWhiteSpace(eventQuality.eventName)) Debug.LogWarning("Event name cannot be empty or whitespace.");
189
+
190
+ if (!eventNames.Add(eventQuality.eventName)) Debug.LogWarning($"Duplicate event name found: {eventQuality.eventName}. Event names must be unique.");
191
+
192
+ HashSet<string> paramNames = new HashSet<string>();
193
+
194
+ eventQuality.lstParam = eventQuality.lstParam.OrderBy(param => param.paramName).ToList();
195
+
196
+ foreach (var param in eventQuality.lstParam)
197
+ {
198
+ if (string.IsNullOrWhiteSpace(param.paramName)) Debug.LogWarning("Event parameter name cannot be empty or whitespace.");
199
+
200
+ if (!paramNames.Add(param.paramName)) Debug.LogWarning($"Duplicate parameter name found in event {eventQuality.eventName}: {param.paramName}. Parameter names must be unique within an event.");
201
+ }
202
+ }
203
+ EditorUtility.SetDirty(this);
204
+ }
205
+ #endif
206
+
207
+ public void CheckEventQuality(string eventName, Dictionary<string, object> parameters)
208
+ {
209
+ if (!DictEvent.ContainsKey(eventName))
210
+ {
211
+ LogWarningOnce($"Event not found in AnalyticQuality: {eventName}");
212
+ return;
213
+ }
214
+
215
+ DictEvent[eventName].ValidateParams(eventName, parameters);
216
+ }
217
+ }
218
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: fc7588fb4889749c8ba1469aeaf0d42d
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,59 @@
1
+ using System;
2
+ using System.Linq;
3
+ using UnityEngine;
4
+
5
+ namespace Amanotes.Core.Internal
6
+ {
7
+ [CreateAssetMenu(fileName = "AmaGDKEmbedRemoteConfig", menuName = "Ama GDK/Embed Remote Config", order = 2)]
8
+ [Serializable]
9
+ internal class EmbedRemoteConfigAsset : ScriptableObject
10
+ {
11
+ public int version = 1;
12
+ [SerializeField]
13
+ internal string activeId;
14
+ public bool overrideInEditor;
15
+ public KeyValue[] overrideConfig;
16
+ [SerializeField]
17
+ internal EmbedConfig[] configs;
18
+ private EmbedConfig activeConfig;
19
+ internal EmbedConfig ActiveConfig
20
+ {
21
+ get
22
+ {
23
+ if (activeConfig != null) return activeConfig;
24
+ activeConfig = GetConfigById(activeId);
25
+ return activeConfig;
26
+ }
27
+ }
28
+
29
+ internal EmbedConfig GetConfigById(string id)
30
+ {
31
+ var config = configs?.FirstOrDefault(a => a.id == id);
32
+ if (config == null)
33
+ Logging.LogWarningOnce($"Not found embedded config <{id}>");
34
+ return config;
35
+ }
36
+
37
+ internal void SetActiveConfig(string id)
38
+ {
39
+ activeId = id;
40
+ activeConfig = null;
41
+ }
42
+ }
43
+
44
+ [Serializable]
45
+ internal class EmbedConfig
46
+ {
47
+ public string id;
48
+ public string fetchUrl;
49
+ public KeyValue[] items;
50
+ }
51
+
52
+ [Serializable]
53
+ internal class KeyValue
54
+ {
55
+ public string key;
56
+ public string value;
57
+ }
58
+ }
59
+
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: c9b85abfe1c1641eb8627956b9ef33af
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "com.amanotes.gdk",
3
- "version": "0.2.13",
3
+ "version": "0.2.16",
4
4
  "displayName": "AmaGDK",
5
5
  "description": "Amanotes Game Development Kit",
6
- "unity": "2020.3",
6
+ "unity": "2019.4",
7
7
  "keywords": [
8
8
  "Amanotes",
9
9
  "Amanotes GDK",