com.amanotes.gdk 0.2.81-a4 → 0.2.81-alpha.5

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 (33) hide show
  1. package/CHANGELOG.md +0 -9
  2. package/Editor/Extra/GDKCIBuildCommand.cs +57 -55
  3. package/Extra/AmaGDKInstaller.unitypackage +0 -0
  4. package/Extra/AutoEventQC.unitypackage +0 -0
  5. package/Extra/CheckDiskSpace.unitypackage +0 -0
  6. package/Extra/Consent.unitypackage +0 -0
  7. package/Extra/CrashlyticHook.unitypackage +0 -0
  8. package/Extra/ForceUpdate.unitypackage +0 -0
  9. package/Extra/LegacyGDKUpdateHelper.unitypackage +0 -0
  10. package/Extra/PostProcessor.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/AppsFlyerAdapter.PurchaseConnector.unitypackage +0 -0
  15. package/Packages/AppsFlyerAdapter.unitypackage +0 -0
  16. package/Packages/FirebaseAnalyticsAdapter.unitypackage +0 -0
  17. package/Packages/FirebaseRemoteConfigAdapter.unitypackage +0 -0
  18. package/Packages/IronSourceAdapter.AdQuality.unitypackage +0 -0
  19. package/Packages/IronSourceAdapter.unitypackage +0 -0
  20. package/Packages/MaxAdNetworkAdapter.unitypackage +0 -0
  21. package/Packages/RevenueCatAdapter.unitypackage +0 -0
  22. package/Packages/SqliteAnalyticsAdapter.unitypackage +0 -0
  23. package/Runtime/Ad/AmaGDK.Ads.cs +1 -1
  24. package/Runtime/AmaGDK.Analytics.cs +3 -9
  25. package/Runtime/AmaGDK.Consent.cs +2 -2
  26. package/Runtime/AmaGDK.IAP.cs +1 -1
  27. package/Runtime/AmaGDK.UserProfile.cs +2 -2
  28. package/Runtime/AmaGDK.cs +1 -1
  29. package/Runtime/Core/GDKDebug.cs +13 -4
  30. package/Runtime/Internal/AmaGDK.Utils.cs +1 -1
  31. package/Runtime/Internal/ForceQuitMonitor.cs +1 -1
  32. package/Runtime/Utils/GDKFileUtils.cs +1 -1
  33. package/package.json +4 -4
package/CHANGELOG.md CHANGED
@@ -1,14 +1,5 @@
1
1
  # Changelog
2
2
 
3
- ## [0.2.81-a4] - 2024-11-21
4
- - [Dev] Add GDKPostBuild for iOS
5
- - [Dev] Improve GDK editor experience before config asset imported
6
- - [Dev] Analytics save file in async
7
- - [Dev] Move GDKFileUtils to a separated file
8
- - [Dev] Update game ops model
9
- - [Dev] Add ABLab
10
- - [Dev] Move imported GDK Adapter from RawData to Modules
11
-
12
3
  ## [0.2.80] - 2024-11-13
13
4
  - [Dev] Don't use obsolete functions
14
5
  - [Dev] Add CrashlyticHook
@@ -17,22 +17,27 @@ namespace Amanotes.Core
17
17
  private const string KEY_ALIAS_NAME = "KEY_ALIAS_NAME";
18
18
  private const string KEYSTORE = "keystore.keystore";
19
19
  private const string BUILD_OPTIONS_ENV_VAR = "BuildOptions";
20
- private const string ANDROID_BUNDLE_VERSION_CODE = "VERSION_BUILD_VAR";
21
20
  private const string ANDROID_APP_BUNDLE = "BUILD_APP_BUNDLE";
22
21
  private const string SCRIPTING_BACKEND_ENV_VAR = "SCRIPTING_BACKEND";
23
22
  private const string EXPORT_ANDROID_PROJECT = "EXPORT_ANDROID_PROJECT";
24
23
  private const string VERSION_NUMBER_VAR = "VERSION_NUMBER_VAR";
25
- private const string VERSION_iOS = "VERSION_BUILD_VAR";
24
+ private const string VERSION_BUILD_VAR = "VERSION_BUILD_VAR";
26
25
 
27
26
  public static void InstallPod(EventHandler processExit, string buildPath = null)
28
27
  {
29
28
  try
30
29
  {
31
- var arguments = $"-c \"/usr/local/bin/pod install --project-directory={buildPath}\"";
30
+ string arguments = "";
32
31
  if (Application.isBatchMode && TryGetEnv("CI_SCRIPT_DIR", out string scriptDir))
33
32
  {
34
33
  arguments = $"{scriptDir}/utils.sh pod-install";
35
34
  }
35
+ else if (!Application.isBatchMode)
36
+ {
37
+ string podPath = "/usr/local/bin/pod";
38
+ if (!File.Exists(podPath)) podPath = "/opt/homebrew/bin/pod";
39
+ arguments = $"-c \"{podPath} install --project-directory={buildPath}\"";
40
+ }
36
41
 
37
42
  // Configure process start info
38
43
  var startInfo = new ProcessStartInfo
@@ -57,12 +62,6 @@ namespace Amanotes.Core
57
62
  if (args.Data == null) return; // End of the stream
58
63
  Debug.Log(args.Data);
59
64
  };
60
-
61
- // proc.ErrorDataReceived += (sender, args) =>
62
- // {
63
- // if (args.Data == null) return; // End of the stream
64
- // Debug.LogError(args.Data);
65
- // };
66
65
 
67
66
  proc.Exited += processExit;
68
67
 
@@ -71,9 +70,6 @@ namespace Amanotes.Core
71
70
  proc.BeginOutputReadLine();
72
71
  proc.BeginErrorReadLine();
73
72
  proc.WaitForExit();
74
-
75
- // Log exit code
76
- // Debug.LogWarning("Process exited with code: " + proc.ExitCode);
77
73
  }
78
74
  catch (Exception e)
79
75
  {
@@ -245,20 +241,16 @@ namespace Amanotes.Core
245
241
  var buildTarget = GetBuildTarget();
246
242
 
247
243
  Console.WriteLine(":: Performing build");
248
- if (TryGetEnv(VERSION_NUMBER_VAR, out var bundleVersionNumber))
244
+ if (TryGetEnv(VERSION_NUMBER_VAR, out string bundleVersionNumber))
249
245
  {
250
- if (buildTarget == BuildTarget.iOS)
251
- {
252
- bundleVersionNumber = GetIosVersion();
253
- }
254
246
  Console.WriteLine($":: Setting bundleVersionNumber to '{bundleVersionNumber}' (Length: {bundleVersionNumber.Length})");
255
247
  PlayerSettings.bundleVersion = bundleVersionNumber;
256
248
  }
249
+ HandleBuildNumber(buildTarget);
257
250
 
258
251
  if (buildTarget == BuildTarget.Android)
259
252
  {
260
253
  HandleAndroidAppBundle();
261
- HandleAndroidBundleVersionCode();
262
254
  HandleAndroidKeystore();
263
255
  HandleDebugSymbols();
264
256
  HandleExportAndroidProject();
@@ -276,6 +268,7 @@ namespace Amanotes.Core
276
268
  if (buildReport.summary.result != UnityEditor.Build.Reporting.BuildResult.Succeeded)
277
269
  throw new Exception($"Build ended with {buildReport.summary.result} status");
278
270
 
271
+ BuildMetadata.Save(buildPath, buildTarget);
279
272
  Console.WriteLine(":: Done with build");
280
273
  }
281
274
 
@@ -299,18 +292,24 @@ namespace Amanotes.Core
299
292
  }
300
293
  }
301
294
 
302
- private static void HandleAndroidBundleVersionCode()
295
+ private static void HandleBuildNumber(BuildTarget buildTarget)
303
296
  {
304
- if (TryGetEnv(ANDROID_BUNDLE_VERSION_CODE, out string value))
297
+ if (!TryGetEnv(VERSION_BUILD_VAR, out string value)) return;
298
+ if (int.TryParse(value, out int version))
305
299
  {
306
- if (int.TryParse(value, out int version))
300
+ if (buildTarget == BuildTarget.Android)
307
301
  {
308
- PlayerSettings.Android.bundleVersionCode = version;
309
- Console.WriteLine($":: {ANDROID_BUNDLE_VERSION_CODE} env var detected, set the bundle version code to {value}.");
302
+ PlayerSettings.Android.bundleVersionCode = version;
310
303
  }
311
- else
312
- Console.WriteLine($":: {ANDROID_BUNDLE_VERSION_CODE} env var detected but the version value \"{value}\" is not an integer.");
304
+ else if (buildTarget == BuildTarget.iOS)
305
+ {
306
+ PlayerSettings.iOS.buildNumber = version.ToString();
307
+ }
308
+
309
+ Console.WriteLine($":: {VERSION_BUILD_VAR} env var detected, set the bundle version code to {value}.");
313
310
  }
311
+ else
312
+ Console.WriteLine($":: {VERSION_BUILD_VAR} env var detected but the version value \"{value}\" is not an integer.");
314
313
  }
315
314
 
316
315
  private static void HandleExportAndroidProject()
@@ -323,22 +322,6 @@ namespace Amanotes.Core
323
322
  }
324
323
  }
325
324
 
326
- private static string GetIosVersion()
327
- {
328
- if (TryGetEnv(VERSION_iOS, out string value))
329
- {
330
- if (int.TryParse(value, out int version))
331
- {
332
- Console.WriteLine($":: {VERSION_iOS} env var detected, set the version to {value}.");
333
- return version.ToString();
334
- }
335
- else
336
- Console.WriteLine($":: {VERSION_iOS} env var detected but the version value \"{value}\" is not an integer.");
337
- }
338
-
339
- throw new ArgumentNullException(nameof(value), $":: Error finding {VERSION_iOS} env var");
340
- }
341
-
342
325
  private static void HandleAndroidKeystore()
343
326
  {
344
327
  #if UNITY_2019_1_OR_NEWER
@@ -394,6 +377,31 @@ namespace Amanotes.Core
394
377
  }
395
378
  }
396
379
 
380
+ [Serializable]
381
+ public class BuildMetadata
382
+ {
383
+ public string appVersion;
384
+ public string buildNumber;
385
+ public string buildTarget;
386
+
387
+ public static void Save(string buildPath, BuildTarget buildTarget)
388
+ {
389
+ string outputFile = Path.Combine(buildPath, "build_info.json");
390
+
391
+ var metadata = new BuildMetadata
392
+ {
393
+ appVersion = PlayerSettings.bundleVersion,
394
+ buildNumber = buildTarget == BuildTarget.Android ? PlayerSettings.Android.bundleVersionCode.ToString() : PlayerSettings.iOS.buildNumber,
395
+ buildTarget = buildTarget.ToString()
396
+ };
397
+
398
+ string json = JsonUtility.ToJson(metadata, prettyPrint: true);
399
+ File.WriteAllText(outputFile, json);
400
+
401
+ Console.WriteLine($":: Build information saved to {outputFile}");
402
+ }
403
+ }
404
+
397
405
  public class GDKPreProcessBuild: IPreprocessBuildWithReport
398
406
  {
399
407
  public int callbackOrder
@@ -402,20 +410,14 @@ namespace Amanotes.Core
402
410
  }
403
411
  public void OnPreprocessBuild(BuildReport report)
404
412
  {
405
- if (report.summary.platform == BuildTarget.Android)
406
- {
407
- // Change Gradle path when running in headless mode (CI Machine)
408
- if (Application.isBatchMode)
409
- {
410
- if (GDKCIBuildCommand.TryGetEnv("GRADLE_PATH", out string envGradlePath))
411
- {
412
- EditorPrefs.SetBool("GradleUseEmbedded", false);
413
- EditorPrefs.SetString("GradlePath", envGradlePath);
414
- Debug.Log("Update gradle path to: " + envGradlePath);
415
- }
416
- }
417
- }
418
-
413
+ if (report.summary.platform != BuildTarget.Android) return;
414
+ // Change Gradle path when running in headless mode (CI Machine)
415
+ if (!Application.isBatchMode) return;
416
+ if (!GDKCIBuildCommand.TryGetEnv("GRADLE_PATH", out string envGradlePath)) return;
417
+ EditorPrefs.SetBool("GradleUseEmbedded", false);
418
+ EditorPrefs.SetString("GradlePath", envGradlePath);
419
+ Debug.Log("Update gradle path to: " + envGradlePath);
420
+
419
421
  }
420
422
  }
421
423
  }
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -93,7 +93,7 @@ namespace Amanotes.Core
93
93
 
94
94
  internal void Save()
95
95
  {
96
- this.SaveJsonToFile(false);
96
+ this.SaveJsonToFile();
97
97
  }
98
98
  }
99
99
 
@@ -135,7 +135,7 @@ namespace Amanotes.Core
135
135
 
136
136
  if (!localData._dirty) return;
137
137
  localData._dirty = false;
138
- localData.SaveJsonToFile(true); // immediately = true
138
+ localData.SaveJsonToFile();
139
139
  }
140
140
 
141
141
  public static IEventParamsBuilder LogFunnelEvent(string eventName, string signature = "")
@@ -314,7 +314,7 @@ namespace Amanotes.Core
314
314
  internal static readonly GDKPool.Pool<EventParams> epPool = new GDKPool.Pool<EventParams>(1);
315
315
 
316
316
  private static readonly Lazy<AnalyticsData> _localData = new Lazy<AnalyticsData>(
317
- () => new AnalyticsData().ReloadDataFromLocal());
317
+ () => new AnalyticsData().LoadJsonFromFile().BuildCache());
318
318
  internal static AnalyticsData localData => _localData.Value;
319
319
 
320
320
  internal static readonly Dictionary<string, string> reservedPrefixes = new Dictionary<string, string>()
@@ -800,12 +800,6 @@ namespace Amanotes.Core
800
800
  return this;
801
801
  }
802
802
 
803
- public AnalyticsData ReloadDataFromLocal()
804
- {
805
- this.LoadJsonFromFile().BuildCache();
806
- return this;
807
- }
808
-
809
803
  internal EventDetail GetEventDetail(string eventName, bool autoNew = false)
810
804
  {
811
805
  if (string.IsNullOrEmpty(eventName)) return null;
@@ -849,7 +843,7 @@ namespace Amanotes.Core
849
843
  if (!Config.analytics.autoFlushEventDetail) return;
850
844
  if (!_dirty) return;
851
845
  _dirty = false;
852
- this.SaveJsonToFile(false);
846
+ this.SaveJsonToFile();
853
847
  }
854
848
 
855
849
  internal void UpdateMigrationLog()
@@ -66,7 +66,7 @@ namespace Amanotes.Core
66
66
  ConsentHook.ATTRequest(isAllowed =>
67
67
  {
68
68
  data.att = isAllowed ? Status.Allowed : Status.NotAllowed;
69
- data.SaveJsonToFile(false);
69
+ data.SaveJsonToFile();
70
70
  onComplete?.Invoke(allowedATT);
71
71
  });
72
72
  }
@@ -107,7 +107,7 @@ namespace Amanotes.Core
107
107
  if (successful)
108
108
  {
109
109
  data.cmp = !IsRequired ? Status.NotRequired : Status.Allowed;
110
- data.SaveJsonToFile(false);
110
+ data.SaveJsonToFile();
111
111
  }
112
112
  onComplete?.Invoke(checkedCMP);
113
113
  });
@@ -306,7 +306,7 @@ namespace Amanotes.Core
306
306
  subscriptionExpiredDate = _subscriptionExpiredDate?.ToString(DATE_FORMAT);
307
307
  _unsubscribedDate = Adapter.GetUnsubscribedDate();
308
308
  unsubscribedDate = _unsubscribedDate?.ToString(DATE_FORMAT);
309
- this.SaveJsonToFile(false);
309
+ this.SaveJsonToFile();
310
310
  }
311
311
  }
312
312
  }
@@ -33,14 +33,14 @@ namespace Amanotes.Core
33
33
  private bool _dirty = false;
34
34
  private void Save()
35
35
  {
36
- this.SaveJsonToFile(false);
36
+ this.SaveJsonToFile();
37
37
  }
38
38
 
39
39
  private void SaveIfDirty()
40
40
  {
41
41
  if (!_dirty) return;
42
42
  _dirty = false;
43
- this.SaveJsonToFile(false);
43
+ this.SaveJsonToFile();
44
44
  }
45
45
  }
46
46
 
package/Runtime/AmaGDK.cs CHANGED
@@ -27,7 +27,7 @@ namespace Amanotes.Core
27
27
  {
28
28
  public partial class AmaGDK : MonoBehaviour
29
29
  {
30
- public const string VERSION = "0.2.81-a4";
30
+ public const string VERSION = "0.2.80";
31
31
 
32
32
  internal static Status _status = Status.None;
33
33
  internal static ConfigAsset _config = null;
@@ -38,13 +38,16 @@ namespace Amanotes.Core
38
38
  {
39
39
  public static Action<string> logNonfatalErrorHook = null;
40
40
  private static readonly HashSet<string> nonFatalDict = new HashSet<string>();
41
- public static readonly HashSet<string> logWarningDict = new HashSet<string>();
41
+ private static readonly HashSet<string> logWarningDict = new HashSet<string>();
42
42
 
43
43
  public static void LogWarningOnce(string message, string key = null)
44
44
  {
45
45
  if (AmaGDK.logLevel < LogLevel.Warning) return;
46
46
  if (string.IsNullOrEmpty(key)) key = message;
47
- if (!logWarningDict.Add(key)) return;
47
+ lock (logWarningDict)
48
+ {
49
+ if (!logWarningDict.Add(key)) return;
50
+ }
48
51
 
49
52
  using (NoStackTrace.Warning)
50
53
  {
@@ -71,14 +74,20 @@ namespace Amanotes.Core
71
74
 
72
75
  if (GDKUtils.isOnMainThread) // Most of the time
73
76
  {
74
- if (!nonFatalDict.Add(message)) return;
77
+ lock (nonFatalDict)
78
+ {
79
+ if (!nonFatalDict.Add(message)) return;
80
+ }
75
81
  logNonfatalErrorHook(message);
76
82
  return;
77
83
  }
78
84
 
79
85
  GDKUtils.DoOnMainThread(() =>
80
86
  {
81
- if (!nonFatalDict.Add(message)) return; // LogOnce
87
+ lock (nonFatalDict)
88
+ {
89
+ if (!nonFatalDict.Add(message)) return; // LogOnce
90
+ }
82
91
  logNonfatalErrorHook(message);
83
92
  });
84
93
  }
@@ -200,7 +200,7 @@ namespace Amanotes.Core.Internal
200
200
  return GDKFileUtils.LoadJsonFromFile(instance);
201
201
  }
202
202
 
203
- internal static void SaveJsonToFile<T>(this T instance, bool immediately) where T: IJsonFile
203
+ internal static void SaveJsonToFile<T>(this T instance, bool immediately = true) where T: IJsonFile
204
204
  {
205
205
  GDKFileUtils.SaveJsonToFile(instance, immediately);
206
206
  }
@@ -34,7 +34,7 @@ namespace Amanotes.Core.Internal
34
34
  internal void SaveIfDirty(bool forceSave = false)
35
35
  {
36
36
  if (!isDirty && !forceSave) return;
37
- this.SaveJsonToFile(true);
37
+ this.SaveJsonToFile();
38
38
  isDirty = false;
39
39
  }
40
40
  }
@@ -236,7 +236,7 @@ namespace Amanotes.Core.Internal
236
236
  return instance;
237
237
  }
238
238
 
239
- public static void SaveJsonToFile<T>(T instance, bool immediately)
239
+ public static void SaveJsonToFile<T>(T instance, bool immediately = true)
240
240
  {
241
241
  string fileName = instance.GetType().Name;
242
242
  string json = JsonUtility.ToJson(instance);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.amanotes.gdk",
3
- "version": "0.2.81-a4",
3
+ "version": "0.2.81-alpha.5",
4
4
  "displayName": "AmaGDK",
5
5
  "description": "Amanotes Game Development Kit",
6
6
  "unity": "2019.4",
@@ -8,7 +8,7 @@
8
8
  "Amanotes",
9
9
  "Amanotes GDK",
10
10
  "vh-name:AmaGDK"
11
- ],
11
+ ],
12
12
  "author": {
13
13
  "name": "Amanotes",
14
14
  "email": "tech.support@amanotes.com",
@@ -16,5 +16,5 @@
16
16
  },
17
17
  "changelogUrl": "https://amagdk.notion.site/Change-Log-6dfd4b67d64f496bbd9eb04ccb4ef95a",
18
18
  "documentationUrl": "https://amagdk.notion.site/amagdk/Ama-GDK-a73596617ab247b6a43c8f12a1581415",
19
- "license": "MIT"
20
- }
19
+ "license": "MIT"
20
+ }