com.amanotes.gdk 0.1.10 → 0.1.12

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 (37) hide show
  1. package/CHANGELOG.md +15 -2
  2. package/Editor/AmaGDKEditor.cs +61 -75
  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 +212 -0
  9. package/Editor/Utils/AmaGDKEditor.ExtractVersion.cs.meta +11 -0
  10. package/Editor/Utils/AmaGDKEditor.GUI.cs +182 -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.Ads.cs +2 -2
  22. package/Runtime/AmaGDK.Analytics.cs +88 -17
  23. package/Runtime/AmaGDK.Config.cs +2 -2
  24. package/Runtime/AmaGDK.Internal.SemVer.cs +117 -0
  25. package/Runtime/AmaGDK.Internal.SemVer.cs.meta +11 -0
  26. package/Runtime/AmaGDK.Internal.cs +25 -1
  27. package/Runtime/AmaGDK.UserProfile.cs +1 -1
  28. package/Runtime/AmaGDK.cs +5 -13
  29. package/Samples~/Example/AmaGDKExample.cs +87 -0
  30. package/Samples~/Example/AmaGDKExample.cs.meta +11 -0
  31. package/Samples~/Example/AmaGDKExample.unity +3114 -0
  32. package/Samples~/Example/AmaGDKExample.unity.meta +7 -0
  33. package/Sample~/Example/AmaGDKExample.cs +87 -0
  34. package/Sample~/Example/AmaGDKExample.cs.meta +11 -0
  35. package/Sample~/Example/AmaGDKExample.unity +3114 -0
  36. package/Sample~/Example/AmaGDKExample.unity.meta +7 -0
  37. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,8 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.12 - 2023-03-01]
4
+ ### Release AmaGDK v0.1.12
5
+ ### Prioritize analytics instant config over the base config
6
+ ### Public common config
7
+
8
+ ## [0.1.11 - 2023-02-28]
9
+ ### Release AmaGDK v0.1.11
10
+ ### Auto start and log Appsflyer open session
11
+ ### Add analytics adapter base config
12
+ ### Analytics: count by session
13
+ ### Export example scene
14
+ ### Add AmaGDKManager
15
+ ### Refactor Adapter to support for init order configuration
16
+
3
17
  ## [0.1.10 - 2023-02-17]
4
18
  ### Release AmaGDK v0.1.10
5
- ### Support accumulated event within session
6
19
 
7
20
  ## [0.1.9 - 2023-02-15]
8
21
  ### Release AmaGDK v0.1.9
@@ -26,4 +39,4 @@
26
39
  ## [0.1.2] - 2023-02-08
27
40
  ### Release AmaGDK 0.1.2
28
41
  ### FirebaseAnalytics adapter compatible with FirebaseAnalytics SDK v9
29
- ### Appsflyer adapter compatible with Appsflyer SDK v6
42
+ ### AppsFlyer adapter compatible with AppsFlyer SDK v6
@@ -1,42 +1,29 @@
1
+ using System;
2
+
1
3
  using UnityEngine;
2
4
  using UnityEditor;
5
+
6
+ using Amanotes.Core;
3
7
  using Amanotes.Core.Internal;
4
- using System;
5
8
  using static Amanotes.Core.Internal.Logging;
9
+ using static Amanotes.Editor.AmaGUI;
10
+ using static Amanotes.Core.AmaGDK.AdapterID;
11
+ using System.Text;
6
12
 
7
- namespace Amanotes.Core
13
+ namespace Amanotes.Editor
8
14
  {
9
- internal class EditorContext
10
- {
11
- [MenuItem("GameObject/AmaGDK/Add AmaGDK Prefab", false, 10)]
12
- private static void AddPrefab_AmaGDK()
13
- {
14
- GameObject prefab = AssetDatabase.LoadAssetAtPath<GameObject>(Res.AMAGDK_PREFAB);
15
- if (prefab == null)
16
- {
17
- Debug.LogWarning($"Prefab [AmaGDK] not found at: {Res.AMAGDK_PREFAB}");
18
- return;
19
- }
20
-
21
- GameObject newPrefab = PrefabUtility.InstantiatePrefab(prefab) as GameObject;
22
- newPrefab.name = "AmaGDK";
23
- Selection.activeObject = newPrefab;
24
- Selection.activeObject = null;
25
- Selection.activeObject = newPrefab;
26
- }
27
- }
28
-
29
15
  [CustomEditor(typeof(AmaGDK))]
30
- public class AmaGDKEditor : Editor
16
+ public class AmaGDKEditor : UnityEditor.Editor
31
17
  {
32
18
  static Color BLUE = new Color32(0x34, 0xFF, 0xF7, 0xFF);
33
19
 
34
20
  static AmaGDK sdk;
35
21
  static ConfigAsset configAsset;
36
- static Editor editor;
22
+ static UnityEditor.Editor editor;
37
23
 
38
24
  static bool showConfigDetail;
39
25
  static bool showAdapterInstaller;
26
+ static bool showExampleDetail;
40
27
 
41
28
  public void OnEnable()
42
29
  {
@@ -66,7 +53,7 @@ namespace Amanotes.Core
66
53
 
67
54
  GUILayout.BeginHorizontal();
68
55
  {
69
- if (GUIButton("CREATE", 40f, BLUE))
56
+ if (BigButton("CREATE", 40f, BLUE))
70
57
  {
71
58
  try
72
59
  {
@@ -93,12 +80,12 @@ namespace Amanotes.Core
93
80
  {
94
81
  if (sdk.autoInit)
95
82
  {
96
- GUIToggle("Auto Init", ref sdk.autoInit);
83
+ Toggle("Auto Init", ref sdk.autoInit);
97
84
  return;
98
85
  }
99
86
 
100
87
  EditorGUILayout.HelpBox("You disabled AmaGDK AutoInit\nMake sure to call AmaGDK.Init() manually!", MessageType.Warning);
101
- if (GUIButton("Enable AutoInit", 40f, BLUE))
88
+ if (BigButton("Enable AutoInit", 40f, BLUE))
102
89
  {
103
90
  sdk.autoInit = true;
104
91
  EditorUtility.SetDirty(sdk);
@@ -131,6 +118,16 @@ namespace Amanotes.Core
131
118
  }
132
119
  }
133
120
 
121
+ void DrawGUI_ExampleScene()
122
+ {
123
+ var examplePackageName = "AmaGDKExample";
124
+ if (GUILayout.Button(ObjectNames.NicifyVariableName(examplePackageName)))
125
+ {
126
+ var package = $"{Res.PACKAGE_PATH}{examplePackageName}.unitypackage";
127
+ AssetDatabase.ImportPackage(package, false);
128
+ }
129
+ }
130
+
134
131
  static public Color btnColor;
135
132
  static public float btnLerp;
136
133
  void DrawGUI_ColorPicker()
@@ -142,72 +139,61 @@ namespace Amanotes.Core
142
139
  }
143
140
  GUILayout.EndHorizontal();
144
141
  }
142
+
143
+ private static readonly string[] SDK_IDS = new string[]{
144
+ FIREBASE_ANALYTICS,
145
+ FIREBASE_REMOTE_CONFIG,
146
+ APPSFLYER,
147
+ IRONSOURCE,
148
+ REVENUECAT
149
+ };
145
150
 
146
151
  public override void OnInspectorGUI()
147
152
  {
148
153
  if (sdk == null) return;
149
154
 
150
155
  // DrawGUI_ColorPicker();
151
-
152
- if (configAsset == null)
156
+ SectionLabel($"<b>AmaGDK</b> <size=12><color=gray>v{AmaGDK.VERSION}</color></size>");
157
+ EditorGUILayout.Space();
158
+
159
+ for (var i =0 ;i < SDK_IDS.Length; i++)
153
160
  {
154
- DrawGUI_ConfigMissing();
155
- return;
161
+ AmaGUI.DrawSDKStatus(SDK_IDS[i]);
156
162
  }
163
+ EditorGUILayout.Space();
157
164
 
158
- DrawGUI_AutoInit();
159
- GUIToggleGroup("Config", ref showConfigDetail, DrawGUI_ConfigDetail, DrawGUI_ConfigAsset);
160
- GUIToggleGroup("Adapters", ref showAdapterInstaller, DrawGUI_AdapterList);
161
- }
162
-
165
+ if (GUILayout.Button("version_info.tsv -> Clipboard")){
166
+ var sb = new StringBuilder();
167
+ sb.AppendLine("ID\tSDK VERSION\tADAPTER VERSION");
168
+ for (var i =0 ;i < SDK_IDS.Length; i++)
169
+ {
170
+ sb.AppendLine(SDKStatus.Get(SDK_IDS[i]).ToTSVString());
171
+ }
163
172
 
173
+ var tsv = sb.ToString();
174
+ EditorGUIUtility.systemCopyBuffer = tsv;
175
+ Debug.Log($"Content of version_info.tsv copied to clipboard!\n\n{tsv}\n\n");
176
+ };
164
177
 
165
- private static bool GUIButton(string label, float height = 16f, Color? color = null, float colorMod = 0.5f)
166
- {
167
- var bgColor = GUI.backgroundColor;
168
178
 
169
- bool result;
170
- if (color != null)
171
- {
172
- var c = (colorMod < 0f) ? Color.Lerp(color.Value, Color.black, -colorMod)
173
- : (colorMod > 0f) ? Color.Lerp(color.Value, Color.white, colorMod) : color.Value;
174
- GUI.backgroundColor = c;
175
- }
179
+ if (configAsset == null)
176
180
  {
177
- result = GUILayout.Button(label, GUILayout.Height(height));
181
+ DrawGUI_ConfigMissing();
182
+ return;
178
183
  }
179
- if (color != null) GUI.backgroundColor = bgColor;
180
- return result;
181
- }
182
-
183
- private static bool GUIToggle(string label, ref bool value)
184
- {
185
- var newValue = EditorGUILayout.Toggle(label, value);
186
- if (newValue == value) return false;
187
184
 
188
- value = newValue;
189
- EditorUtility.SetDirty(sdk);
190
- return true;
185
+ DrawGUI_AutoInit();
186
+ ToggleGroup("Config", ref showConfigDetail, DrawGUI_ConfigDetail, DrawGUI_ConfigAsset);
187
+ ToggleGroup("Adapters", ref showAdapterInstaller, DrawGUI_AdapterList);
188
+ ToggleGroup("Example", ref showExampleDetail, DrawGUI_ExampleScene);
191
189
  }
192
190
 
193
- private static bool GUIToggleGroup(string label, ref bool isOpen, Action drawFunc, Action titleFunc = null){
194
- GUILayout.BeginHorizontal();
195
- var newValue = EditorGUILayout.Foldout(isOpen, label);
196
- var changed = newValue != isOpen;
197
- titleFunc?.Invoke();
198
- GUILayout.EndHorizontal();
199
-
200
- if (isOpen)
191
+ private static void DrawVersion(string label, string version){
192
+ EditorGUI.BeginDisabledGroup(true);
201
193
  {
202
- EditorGUI.indentLevel++;
203
- drawFunc();
204
- EditorGUI.indentLevel--;
194
+ GUILayout.Label($"{label} v{version}", EditorStyles.largeLabel);
205
195
  }
206
-
207
- if (!changed) return false;
208
-
209
- isOpen = newValue;
210
- return true;
211
- }
196
+ EditorGUI.EndDisabledGroup();
197
+ }
212
198
  }
213
199
  }
@@ -0,0 +1,236 @@
1
+ using System;
2
+ using System.Collections;
3
+ using System.Collections.Generic;
4
+ using System.Linq;
5
+ using Amanotes.Core;
6
+ using UnityEditor;
7
+ using UnityEngine;
8
+ using UnityEngine.Networking;
9
+
10
+ namespace Amanotes.Editor
11
+ {
12
+ [Serializable]
13
+ public class GDKModule
14
+ {
15
+ public string id;
16
+ public string name;
17
+ public string adapter;
18
+ public string currentVersion;
19
+ public int selectIndex;
20
+ public string[] versions;
21
+ public string infoURL;
22
+ }
23
+
24
+ [Serializable]
25
+ public class BucketInfo
26
+ {
27
+ public PackageInfo[] packages;
28
+ }
29
+
30
+ [Serializable]
31
+ public class PackageInfo
32
+ {
33
+ public string version;
34
+ }
35
+
36
+ public class VersionHelper
37
+ {
38
+ public const string PACKAGE_NAME = "com.amanotes.gdk";
39
+
40
+ public static T[] FromJsonToArray<T>(string json)
41
+ {
42
+ if (!json.StartsWith("{\"items\":"))
43
+ {
44
+ json = $"{{\"items\":{json}}}";
45
+ }
46
+ Wrapper<T> wrapper = JsonUtility.FromJson<Wrapper<T>>(json);
47
+ return wrapper.items;
48
+ }
49
+
50
+ [Serializable]
51
+ private class Wrapper<T>
52
+ {
53
+ public T[] items;
54
+ }
55
+
56
+ public static List<GDKModule> LoadLocalModuleInfo()
57
+ {
58
+ List<GDKModule> dicModule = new List<GDKModule>();
59
+ string jsonServices = Resources.Load<TextAsset>("amasdk-modules").text;
60
+ if (!string.IsNullOrEmpty(jsonServices))
61
+ {
62
+ GDKModule[] configs = FromJsonToArray<GDKModule>(jsonServices);
63
+
64
+ foreach (var config in configs)
65
+ {
66
+ GDKModule module = new GDKModule();
67
+ module.infoURL = config.infoURL;
68
+ module.name = config.name;
69
+ module.adapter = config.adapter;
70
+ module.id = config.id;
71
+ module.currentVersion = ExtractVersion.GDKAdapter(module.adapter);
72
+ dicModule.Add(module);
73
+ }
74
+ }
75
+ return dicModule;
76
+ }
77
+
78
+ public static void UpdateListVersions(GDKModule module)
79
+ {
80
+ LoadModuleInfo($"{module.infoURL}/package.json",
81
+ bucketInfo =>
82
+ {
83
+ if (bucketInfo != null)
84
+ {
85
+ module.versions = bucketInfo.packages.Select(p => p.version).ToArray();
86
+ }
87
+ }).StartEditorCoroutine();
88
+ }
89
+
90
+ private static IEnumerator LoadModuleInfo(string url, Action<BucketInfo> callback)
91
+ {
92
+ BucketInfo bucketInfo = null;
93
+
94
+ using (UnityWebRequest www = UnityWebRequest.Get(url))
95
+ {
96
+ yield return www.SendWebRequest();
97
+
98
+ while (www.isDone == false)
99
+ yield return null;
100
+
101
+ bucketInfo = JsonUtility.FromJson<BucketInfo>(www.downloadHandler.text);
102
+ }
103
+ callback(bucketInfo);
104
+ }
105
+ }
106
+
107
+ public class AmaGDKManager : EditorWindow
108
+ {
109
+ private static AmaGDKManager window;
110
+ private Dictionary<string, string> dicThirdparty;
111
+ private List<GDKModule> listModule;
112
+ private GUIStyle headerStyle;
113
+
114
+ #if AMAGDK_DEV
115
+
116
+ [MenuItem("AmaGDK/AmaGDK Manager", priority = 1)]
117
+ private static void ShowAmaSDKNotificationEditor()
118
+ {
119
+ if(window)
120
+ {
121
+ window.Show();
122
+ return;
123
+ }
124
+ window = GetWindow<AmaGDKManager>();
125
+ window.titleContent = new GUIContent("AmaGDK Manager");
126
+ window.minSize = new Vector2(600, 600);
127
+ window.Show();
128
+ }
129
+ #endif
130
+
131
+ private void OnEnable()
132
+ {
133
+ headerStyle = new GUIStyle();
134
+ headerStyle.normal.textColor = Color.green;
135
+ dicThirdparty = new Dictionary<string, string>();
136
+ listModule = VersionHelper.LoadLocalModuleInfo();
137
+ foreach (GDKModule module in listModule)
138
+ {
139
+ VersionHelper.UpdateListVersions(module);
140
+ dicThirdparty.Add(module.id, ExtractVersion.ThirdParty(module.id));
141
+ }
142
+ }
143
+
144
+ private void DrawUILine(int thickness = 2, int padding = 10)
145
+ {
146
+ Rect r = EditorGUILayout.GetControlRect(GUILayout.Height(padding + thickness));
147
+ r.height = thickness;
148
+ r.y += padding / 2;
149
+ r.x -= 2;
150
+ r.width += 6;
151
+ EditorGUI.DrawRect(r, EditorGUIUtility.isProSkin ? Color.black : Color.gray);
152
+ }
153
+
154
+ private void ModuleInformation()
155
+ {
156
+ foreach (GDKModule module in listModule)
157
+ {
158
+ var currentVersion = module.currentVersion;
159
+ string[] versions = module.versions;
160
+ DrawUILine();
161
+ GUILayout.Label(module.name, headerStyle);
162
+ GUILayout.BeginVertical();
163
+ {
164
+ GUILayout.Space(10);
165
+ GUILayout.BeginHorizontal(GUILayout.Width(450));
166
+ {
167
+ GUILayout.BeginVertical();
168
+ {
169
+ GUILayout.Label($"- Adapter version: {(string.IsNullOrEmpty(currentVersion) ? "None" : currentVersion)}");
170
+ if (dicThirdparty != null && dicThirdparty.ContainsKey(module.id))
171
+ {
172
+ GUILayout.Label($"- Thirdparty version: {dicThirdparty[module.id]}");
173
+ }
174
+ else
175
+ {
176
+ GUILayout.Label("- Thirdparty version: None");
177
+ }
178
+ }
179
+ GUILayout.EndVertical();
180
+
181
+ GUILayout.BeginVertical();
182
+ {
183
+ if (versions != null && versions.Length > 0)
184
+ {
185
+ module.selectIndex = EditorGUILayout.Popup("Adapter all version:", module.selectIndex, versions);
186
+ if (GUILayout.Button(!string.IsNullOrEmpty(currentVersion) ? "Update" : "Install"))
187
+ {
188
+ // Install or update module
189
+ }
190
+ }
191
+ }
192
+ GUILayout.EndVertical();
193
+ }
194
+ GUILayout.EndHorizontal();
195
+ }
196
+ GUILayout.EndVertical();
197
+ }
198
+ }
199
+
200
+ private void AmaGDKCoreInformation()
201
+ {
202
+ GUILayout.Space(10);
203
+ GUILayout.Label("AmaGDK Core", headerStyle);
204
+ GUILayout.Label(string.Format("version: {0}", AmaGDK.VERSION));
205
+ if (GUILayout.Button("Check Update", GUILayout.MaxWidth(100)))
206
+ {
207
+ UnityEditor.PackageManager.UI.Window.Open(VersionHelper.PACKAGE_NAME);
208
+ }
209
+ }
210
+
211
+ private void OnGUI()
212
+ {
213
+ GUILayout.BeginVertical();
214
+ {
215
+ GUILayout.BeginHorizontal();
216
+ {
217
+ GUILayout.Space(10);
218
+
219
+ GUILayout.BeginVertical(GUILayout.MaxWidth(150));
220
+ {
221
+ AmaGDKCoreInformation();
222
+ }
223
+ GUILayout.EndVertical();
224
+
225
+ GUILayout.BeginVertical();
226
+ {
227
+ ModuleInformation();
228
+ }
229
+ GUILayout.EndVertical();
230
+ }
231
+ GUILayout.EndHorizontal();
232
+ }
233
+ GUILayout.EndVertical();
234
+ }
235
+ }
236
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 44c77ba58d5d742d68829b3d5b04a3bf
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,31 @@
1
+ [
2
+ {
3
+ "id": "FirebaseAnalytics",
4
+ "name": "Firebase Analytics",
5
+ "adapter": "FirebaseAnalyticsAdapter",
6
+ "infoURL": "https://d29y8yeuyaq8nk.cloudfront.net/firebase-analytics"
7
+ },
8
+ {
9
+ "id": "FirebaseRemoteConfig",
10
+ "name": "Firebase Remote Config",
11
+ "adapter": "",
12
+ "infoURL": "https://d29y8yeuyaq8nk.cloudfront.net/firebase-remote-config"
13
+ },
14
+ {
15
+ "id": "AppsFlyer",
16
+ "name": "AppsFlyer",
17
+ "adapter": "AppsFlyerAdapter",
18
+ "infoURL": "https://d29y8yeuyaq8nk.cloudfront.net/appsflyer"
19
+ },
20
+ {
21
+ "id": "IronSource",
22
+ "name": "Ironsource",
23
+ "infoURL": "https://d29y8yeuyaq8nk.cloudfront.net/ama-ironsource"
24
+ },
25
+ {
26
+ "id": "RevenueCat",
27
+ "name": "Revenuecat",
28
+ "adapter": "",
29
+ "infoURL": "https://d29y8yeuyaq8nk.cloudfront.net/ama-revenuecat"
30
+ }
31
+ ]
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: 4ea137f13e3884de083707626db8fb45
3
+ TextScriptImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
@@ -0,0 +1,8 @@
1
+ fileFormatVersion: 2
2
+ guid: aa56aa5c6656f415ebac7089cf7cf7dc
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant: