com.amanotes.gdk 0.2.47 → 0.2.48

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 (52) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/Extra/AmaGDKInstaller.unitypackage +0 -0
  3. package/Extra/AmaGDKProject.unitypackage +0 -0
  4. package/Packages/AmaGDKConfig.unitypackage +0 -0
  5. package/Packages/AmaGDKExample.unitypackage +0 -0
  6. package/Packages/AmaGDKTest.unitypackage +0 -0
  7. package/Packages/AppsFlyerAdapter.unitypackage +0 -0
  8. package/Packages/FirebaseAnalyticsAdapter.unitypackage +0 -0
  9. package/Packages/FirebaseRemoteConfigAdapter.unitypackage +0 -0
  10. package/Packages/IronSourceAdapter.unitypackage +0 -0
  11. package/Packages/RevenueCatAdapter.unitypackage +0 -0
  12. package/Runtime/AmaGDK.cs +1 -1
  13. package/Runtime/Klavar/Attributes/AccumulatedCountAttribute.cs +19 -0
  14. package/Runtime/Klavar/Attributes/AccumulatedCountAttribute.cs.meta +11 -0
  15. package/Runtime/Klavar/Attributes/ConnectionAttribute.cs +18 -0
  16. package/Runtime/Klavar/Attributes/ConnectionAttribute.cs.meta +11 -0
  17. package/Runtime/Klavar/Attributes/CountInSessionAttribute.cs +27 -0
  18. package/Runtime/Klavar/Attributes/CountInSessionAttribute.cs.meta +11 -0
  19. package/Runtime/Klavar/Attributes/DescriptionAttribute.cs +7 -0
  20. package/Runtime/Klavar/Attributes/DescriptionAttribute.cs.meta +11 -0
  21. package/Runtime/Klavar/Attributes/DynamicValidateAttribute.cs +30 -0
  22. package/Runtime/Klavar/Attributes/DynamicValidateAttribute.cs.meta +11 -0
  23. package/Runtime/Klavar/Attributes/IgnoreAttribute.cs +16 -0
  24. package/Runtime/Klavar/Attributes/IgnoreAttribute.cs.meta +11 -0
  25. package/Runtime/Klavar/Attributes/MinMaxAttribute.cs +130 -0
  26. package/Runtime/Klavar/Attributes/MinMaxAttribute.cs.meta +11 -0
  27. package/Runtime/Klavar/Attributes/MinMaxLengthAttribute.cs +88 -0
  28. package/Runtime/Klavar/Attributes/MinMaxLengthAttribute.cs.meta +11 -0
  29. package/Runtime/Klavar/Attributes/NameAttribute.cs +35 -0
  30. package/Runtime/Klavar/Attributes/NameAttribute.cs.meta +11 -0
  31. package/Runtime/Klavar/Attributes/NotNullAttribute.cs +16 -0
  32. package/Runtime/Klavar/Attributes/NotNullAttribute.cs.meta +11 -0
  33. package/Runtime/Klavar/Attributes/RegexPatternAttribute.cs +58 -0
  34. package/Runtime/Klavar/Attributes/RegexPatternAttribute.cs.meta +11 -0
  35. package/Runtime/Klavar/Attributes/TimeDiffLastFireAttribute.cs +28 -0
  36. package/Runtime/Klavar/Attributes/TimeDiffLastFireAttribute.cs.meta +11 -0
  37. package/Runtime/Klavar/Attributes/ToStringAttribute.cs +97 -0
  38. package/Runtime/Klavar/Attributes/ToStringAttribute.cs.meta +11 -0
  39. package/Runtime/Klavar/Attributes/ValueAttribute.cs +30 -0
  40. package/Runtime/Klavar/Attributes/ValueAttribute.cs.meta +11 -0
  41. package/Runtime/Klavar/Attributes.meta +12 -0
  42. package/Runtime/Klavar/KlavarEvent.cs +91 -0
  43. package/Runtime/Klavar/KlavarEvent.cs.meta +11 -0
  44. package/Runtime/Klavar/KlavarEventAttribute.cs +39 -0
  45. package/Runtime/Klavar/KlavarEventAttribute.cs.meta +11 -0
  46. package/Runtime/Klavar/KlavarEventTools.cs +92 -0
  47. package/Runtime/Klavar/KlavarEventTools.cs.meta +11 -0
  48. package/Runtime/Klavar/KlavarEventUtils.cs +58 -0
  49. package/Runtime/Klavar/KlavarEventUtils.cs.meta +11 -0
  50. package/Runtime/Klavar.meta +12 -0
  51. package/package.json +1 -1
  52. package/Runtime/Core.meta +0 -8
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.48 - 2024-01-15]
4
+ - Add GDKTest project for Unity versions 2020.3, 2021.3 and 2022.3
5
+ - Integrate Klavar library & toolset
6
+
3
7
  ## [0.2.47 - 2024-01-09]
4
8
  - Some clean up, null checks & improvements for AmaGDK Editor
5
9
  - Add GDKTest project for Unity versions 2020.3, 2021.3 and 2022.3
@@ -261,4 +265,4 @@ Update Ads module:
261
265
  ## [0.1.2] - 2023-02-08
262
266
  - Release AmaGDK 0.1.2
263
267
  - FirebaseAnalytics adapter compatible with FirebaseAnalytics SDK v9
264
- - AppsFlyer adapter compatible with AppsFlyer SDK v6
268
+ - AppsFlyer adapter compatible with AppsFlyer SDK v6
Binary file
Binary file
Binary file
Binary file
Binary file
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.47";
20
+ public const string VERSION = "0.2.48";
21
21
 
22
22
  internal static AmaGDK _instance;
23
23
  internal static Status _status = Status.None;
@@ -0,0 +1,19 @@
1
+ using System;
2
+ using System.Reflection;
3
+
4
+ namespace Amanotes.Core
5
+ {
6
+ /// <summary>
7
+ /// Accumulated Count Attribute
8
+ /// </summary>
9
+ ///
10
+ public class AccumulatedCountAttribute : ConverterLogEventAttribute
11
+ {
12
+ public override object Convert(object parent, FieldInfo fieldInfo, object param)
13
+ {
14
+ var classType = parent.GetType();
15
+ var attr = (EventNameAttribute) GetCustomAttribute(classType, typeof(EventNameAttribute));
16
+ return AmaGDK.Analytics.GetAccumulatedCount(attr.name) + 1;
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 4676ec6aa5eac4473b464688797b7e74
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,18 @@
1
+ using System.Collections.Generic;
2
+ using System.Reflection;
3
+ using UnityEngine;
4
+
5
+ namespace Amanotes.Core
6
+ {
7
+ /// <summary>
8
+ /// Get Connection Attribute
9
+ /// </summary>
10
+ public class ConnectionAttribute : ConverterLogEventAttribute
11
+ {
12
+ public override object Convert(object parent, FieldInfo fieldInfo, object param)
13
+ {
14
+ return Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork ?
15
+ "online" : "offline";
16
+ }
17
+ }
18
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 4a5ccb72b88f14dfd830e677754f07df
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,27 @@
1
+ using System.Collections.Generic;
2
+ using System.Reflection;
3
+ using UnityEngine;
4
+
5
+ namespace Amanotes.Core
6
+ {
7
+ /// <summary>
8
+ /// Get Connection Attribute
9
+ /// </summary>
10
+ public class CountInSessionAttribute : ConverterLogEventAttribute
11
+ {
12
+ static readonly Dictionary<string, int> countInSessions = new Dictionary<string, int>();
13
+
14
+ public override object Convert(object parent, FieldInfo fieldInfo, object param)
15
+ {
16
+ // return AmaGDK.Ads.InterstitialShowCalledInSession;
17
+ string name = parent.GetType().FullName;
18
+ if (!countInSessions.TryGetValue(name, out var count))
19
+ {
20
+ count = countInSessions[name] = 1;
21
+ return 1;
22
+ }
23
+ count = countInSessions[name] = count + 1;
24
+ return count;
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: c775bcc69b77340e7a160f75ce5a249f
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,7 @@
1
+ namespace Amanotes.Core
2
+ {
3
+ public class DescriptionAttribute : KlavarEventAttribute
4
+ {
5
+ public DescriptionAttribute(string description) { }
6
+ }
7
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 3ab249f3648b84b6db12944cea37b8d0
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,30 @@
1
+ using System;
2
+ using System.Reflection;
3
+
4
+ namespace Amanotes.Core
5
+ {
6
+ /// <summary>
7
+ /// Dynamic validate param by Function
8
+ /// </summary>
9
+ public class DynamicValidateAttribute : ValidateLogEventAttribute
10
+ {
11
+ readonly string functioName;
12
+ public DynamicValidateAttribute(string functionName)
13
+ {
14
+ this.functioName = functionName;
15
+ }
16
+
17
+ public override void Validate(object parent, FieldInfo fieldInfo, object param)
18
+ {
19
+ var function = param.GetType().GetMethod(functioName);
20
+ try
21
+ {
22
+ function?.Invoke(parent, new object[] { param });
23
+ }
24
+ catch (Exception e)
25
+ {
26
+ throw new ArgumentException($"Field {fieldInfo.Name} is in-valid with error {e.Message}");
27
+ }
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 40accc99a6f324666902522f4305acd3
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,16 @@
1
+ namespace Amanotes.Core
2
+ {
3
+ /// <summary>
4
+ /// Ignore this param
5
+ /// </summary>
6
+ public class IgnoreAttribute : KlavarEventAttribute
7
+ {
8
+ }
9
+ }
10
+
11
+
12
+
13
+
14
+
15
+
16
+
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 4959d05652b9c461c8d8c3ddba63d934
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,130 @@
1
+ using System;
2
+ using System.Reflection;
3
+
4
+ namespace Amanotes.Core
5
+ {
6
+ /// <summary>
7
+ /// Min, Max validate param
8
+ /// </summary>
9
+ public class MinMaxAttribute : ValidateLogEventAttribute
10
+ {
11
+
12
+ public readonly double min;
13
+
14
+ public readonly double max;
15
+
16
+ public MinMaxAttribute(double min, double max)
17
+ {
18
+ this.min = min;
19
+ this.max = max;
20
+ }
21
+
22
+
23
+ public override void Validate(object parent, FieldInfo fieldInfo, object param)
24
+ {
25
+ if (!(param is int) && !(param is float) && !(param is double))
26
+ throw new ArgumentException($"type of `{fieldInfo.Name}` is must be int, float or double");
27
+
28
+ double val = Convert.ToDouble(param);
29
+ if (val < min) throw new ArgumentException($"Field `{fieldInfo.Name}` must be in range [{min}, {max}]. Current value: {param}");
30
+ if (val > max) throw new ArgumentException($"Field `{fieldInfo.Name}` must be in range [{min}, {max}]. Current value: {param}");
31
+ }
32
+ }
33
+
34
+
35
+ public class MinimumAttribute : ValidateLogEventAttribute
36
+ {
37
+
38
+ public readonly double min;
39
+
40
+
41
+ public MinimumAttribute(double min)
42
+ {
43
+ this.min = min;
44
+ }
45
+
46
+
47
+ public override void Validate(object parent, FieldInfo fieldInfo, object param)
48
+ {
49
+ if (!(param is int) && !(param is float) && !(param is double))
50
+ throw new ArgumentException($"type of `{fieldInfo.Name}` is must be int, float or double");
51
+
52
+ double val = Convert.ToDouble(param);
53
+ if (val < min) throw new ArgumentException($"Field `{fieldInfo.Name}` must be greater or equal to {min}. Current value: {param}");
54
+ }
55
+ }
56
+
57
+
58
+ public class ExclusiveMinimumAttribute : ValidateLogEventAttribute
59
+ {
60
+
61
+ public readonly double min;
62
+
63
+
64
+ public ExclusiveMinimumAttribute(double min)
65
+ {
66
+ this.min = min;
67
+ }
68
+
69
+
70
+ public override void Validate(object parent, FieldInfo fieldInfo, object param)
71
+ {
72
+ if (!(param is int) && !(param is float) && !(param is double))
73
+ throw new ArgumentException($"type of `{fieldInfo.Name}` is must be int, float or double");
74
+
75
+ double val = Convert.ToDouble(param);
76
+ if (val <= min) throw new ArgumentException($"Field `{fieldInfo.Name}` must be greater {min}. Current value: {param}");
77
+ }
78
+ }
79
+
80
+
81
+
82
+
83
+
84
+ public class MaximumAttribute : ValidateLogEventAttribute
85
+ {
86
+
87
+ public readonly double max;
88
+
89
+
90
+ public MaximumAttribute(double max)
91
+ {
92
+ this.max = max;
93
+ }
94
+
95
+
96
+ public override void Validate(object parent, FieldInfo fieldInfo, object param)
97
+ {
98
+ if (!(param is int) && !(param is float) && !(param is double))
99
+ throw new ArgumentException($"type of `{fieldInfo.Name}` is must be int, float or double");
100
+
101
+ double val = Convert.ToDouble(param);
102
+ if (val > max) throw new ArgumentException($"Field `{fieldInfo.Name}` must be smaller or equal to {max}. Current value: {param}");
103
+ }
104
+ }
105
+
106
+
107
+ public class ExclusiveMaximumAttribute : ValidateLogEventAttribute
108
+ {
109
+
110
+ public readonly double max;
111
+
112
+
113
+ public ExclusiveMaximumAttribute(double max)
114
+ {
115
+ this.max = max;
116
+ }
117
+
118
+
119
+ public override void Validate(object parent, FieldInfo fieldInfo, object param)
120
+ {
121
+ if (!(param is int) && !(param is float) && !(param is double))
122
+ throw new ArgumentException($"type of `{fieldInfo.Name}` is must be int, float or double");
123
+
124
+ double val = Convert.ToDouble(param);
125
+ if (val >= max) throw new ArgumentException($"Field `{fieldInfo.Name}` must be smaller to {max}. Current value: {param}");
126
+ }
127
+ }
128
+ }
129
+
130
+
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: c773f7760fee54649bbd4adc39fc2c5b
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,88 @@
1
+ using System;
2
+ using System.Reflection;
3
+
4
+ namespace Amanotes.Core
5
+ {
6
+ /// <summary>
7
+ /// Min, Max length valudate validate param. (Just apply for string only)
8
+ /// </summary>
9
+ public class MinMaxLengthAttribute : ValidateLogEventAttribute
10
+ {
11
+ public readonly int min;
12
+ public readonly int max;
13
+
14
+ public MinMaxLengthAttribute(int min, int max)
15
+ {
16
+ this.min = min;
17
+ this.max = max;
18
+ }
19
+
20
+
21
+ public override void Validate(object parent, FieldInfo fieldInfo, object param)
22
+ {
23
+ if (!(param is string text)) throw new ArgumentException($"Field {fieldInfo.Name} must be string.");
24
+ if (param is null) throw new ArgumentException($"Field {fieldInfo.Name} must not be null.");
25
+ if (text.Length < min) throw new ArgumentException($"The length of string field `{fieldInfo.Name}` must be in range [{min}, {max}]. Current length: {text.Length}");
26
+ if (text.Length > max) throw new ArgumentException($"The length of string field `{fieldInfo.Name}` must be in range [{min}, {max}]. Current length: {text.Length}");
27
+ }
28
+ }
29
+
30
+
31
+ public class MinLengthAttribute : ValidateLogEventAttribute
32
+ {
33
+ public readonly int min;
34
+
35
+ public MinLengthAttribute(int min)
36
+ {
37
+ this.min = min;
38
+ }
39
+
40
+
41
+ public override void Validate(object parent, FieldInfo fieldInfo, object param)
42
+ {
43
+ if (!(param is string text)) throw new ArgumentException($"Field {fieldInfo.Name} must be string.");
44
+ if (param is null) throw new ArgumentException($"Field {fieldInfo.Name} must not be null.");
45
+ if (text.Length < min) throw new ArgumentException($"The length of string field `{fieldInfo.Name}` must be greater or equal to {min}. Current length: {text.Length}");
46
+ }
47
+ }
48
+
49
+
50
+ public class MaxLengthAttribute : ValidateLogEventAttribute
51
+ {
52
+ public readonly int max;
53
+
54
+ public MaxLengthAttribute(int max)
55
+ {
56
+ this.max = max;
57
+ }
58
+
59
+
60
+ public override void Validate(object parent, FieldInfo fieldInfo, object param)
61
+ {
62
+ if (!(param is string text)) throw new ArgumentException($"Field {fieldInfo.Name} must be string.");
63
+ if (param is null) throw new ArgumentException($"Field {fieldInfo.Name} must not be null.");
64
+ if (text.Length > max) throw new ArgumentException($"The length of string field `{fieldInfo.Name}` must be smaller or equal to {max}. Current length: {text.Length}");
65
+ }
66
+ }
67
+
68
+
69
+ public class FixedLengthAttribute : ValidateLogEventAttribute
70
+ {
71
+ public readonly int length;
72
+
73
+ public FixedLengthAttribute(int length)
74
+ {
75
+ this.length = length;
76
+ }
77
+
78
+ public override void Validate(object parent, FieldInfo fieldInfo, object param)
79
+ {
80
+ if (!(param is string text)) throw new ArgumentException($"Field {fieldInfo.Name} must be string.");
81
+ if (param is null) throw new ArgumentException($"Field {fieldInfo.Name} must not be null.");
82
+ if (text.Length != length)
83
+ throw new ArgumentException($"The length of string field `{fieldInfo.Name}` must be equal to {length}. Current length: {text.Length}");
84
+ }
85
+ }
86
+ }
87
+
88
+
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 6b927e38cacb34a7195b04f17f90c2f3
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
+
2
+ using System.Reflection;
3
+
4
+ namespace Amanotes.Core
5
+ {
6
+
7
+ /// <summary>
8
+ /// Change the Name of param
9
+ /// </summary>
10
+ public class NameAttribute : NamingLogEventAttribute
11
+ {
12
+ public readonly string name;
13
+
14
+ public NameAttribute(string name)
15
+ {
16
+ this.name = name;
17
+ }
18
+ public override string GetName(object parent, FieldInfo fieldInfo) => name;
19
+ }
20
+
21
+
22
+
23
+ /// <summary>
24
+ /// Set the event name
25
+ /// </summary>
26
+ public class EventNameAttribute : KlavarEventAttribute
27
+ {
28
+ public readonly string name;
29
+
30
+ public EventNameAttribute(string name)
31
+ {
32
+ this.name = name;
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 47031184d3e984c99abbca06a5c51fe0
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,16 @@
1
+ using System;
2
+ using System.Reflection;
3
+
4
+ namespace Amanotes.Core
5
+ {
6
+ /// <summary>
7
+ /// Not null validate param
8
+ /// </summary>
9
+ public class NotNullAttribute : ValidateLogEventAttribute
10
+ {
11
+ public override void Validate(object parent, FieldInfo fieldInfo, object param)
12
+ {
13
+ if (param is null) throw new ArgumentException($"Field `{fieldInfo.Name}` must not be null");
14
+ }
15
+ }
16
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: a9edce640cd3545c6a026d6590a1f50d
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,58 @@
1
+ using System;
2
+ using System.Reflection;
3
+ using System.Text.RegularExpressions;
4
+
5
+ namespace Amanotes.Core
6
+ {
7
+ #pragma warning disable CS3015
8
+
9
+ /// <summary>
10
+ /// Apply Regex Validation for param
11
+ /// </summary>
12
+ public class RegexPatternAttribute : ValidateLogEventAttribute
13
+ {
14
+ public readonly string[] regexes;
15
+
16
+
17
+ public RegexPatternAttribute(string regex)
18
+ {
19
+ this.regexes = new string[] { regex };
20
+ }
21
+
22
+
23
+ public RegexPatternAttribute(string[] regexes)
24
+ {
25
+ this.regexes = regexes;
26
+ }
27
+
28
+
29
+ public override void Validate(object parent, FieldInfo fieldInfo, object param)
30
+ {
31
+ if (param is null) throw new ArgumentException($"Field `{fieldInfo.Name}` must not be null");
32
+ foreach (var regex in regexes)
33
+ {
34
+ var match = Regex.Match(param.ToString(), regex);
35
+ if (match != null && match.Success) return;
36
+ }
37
+ throw new ArgumentException($"Field `{fieldInfo.Name}` is not match as {this.GetType().Name.Replace("Attribute", "")}");
38
+ }
39
+ }
40
+
41
+ #pragma warning restore CA2200
42
+
43
+ /// <summary>
44
+ /// Is Email validate Param
45
+ /// </summary>
46
+ public class IsEmailAddressAttribute : RegexPatternAttribute
47
+ {
48
+ public IsEmailAddressAttribute() : base(@"^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$") { }
49
+ }
50
+
51
+ /// <summary>
52
+ /// Is ObjectID validate param
53
+ /// </summary>
54
+ public class IsObjectIDAttribute : RegexPatternAttribute
55
+ {
56
+ public IsObjectIDAttribute() : base(@"^(?=[a-f\d]{24}$)(\d+[a-f]|[a-f]+\d)") { }
57
+ }
58
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: b25602076710f4965a41f41a5d1afb46
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,28 @@
1
+ using System.Collections.Generic;
2
+ using System.Reflection;
3
+ using UnityEngine;
4
+
5
+ namespace Amanotes.Core
6
+ {
7
+ public class TimeDiffLastFireAttribute : ConverterLogEventAttribute
8
+ {
9
+ static readonly Dictionary<string, float> lastFireInSessions = new Dictionary<string, float>();
10
+
11
+ public override object Convert(object parent, FieldInfo fieldInfo, object param)
12
+ {
13
+ // return AmaGDK.Ads.InterstitialShowCalledInSession;
14
+ string name = parent.GetType().FullName;
15
+ if (!lastFireInSessions.TryGetValue(name, out var lastFire))
16
+ {
17
+ lastFireInSessions[name] = Time.realtimeSinceStartup;
18
+ return 0;
19
+ }
20
+
21
+ var current = Time.realtimeSinceStartup;
22
+ var diff = Mathf.RoundToInt(current - lastFire);
23
+ lastFireInSessions[name] = current;
24
+ return diff;
25
+ }
26
+ }
27
+
28
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: e93b0c22875584b17840d4a5c8e30424
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,97 @@
1
+ using System;
2
+ using System.Collections.Generic;
3
+ using System.Reflection;
4
+
5
+ namespace Amanotes.Core
6
+ {
7
+ #pragma warning disable CS3005
8
+
9
+ /// <summary>
10
+ /// Convert param to string
11
+ /// </summary>
12
+ public class ToStringAttribute : ConverterLogEventAttribute
13
+ {
14
+ public enum Converter
15
+ {
16
+ NoThing,
17
+
18
+ ToLowerCase,
19
+ ToUpperCase,
20
+
21
+ ToSnakeCase,
22
+ ToCamelCase,
23
+ ToPascalCase,
24
+ ToKebabCase
25
+ }
26
+
27
+ static readonly Dictionary<Converter, Func<string, string>> convertMethods = new Dictionary<Converter, Func<string, string>>()
28
+ {
29
+ {Converter.NoThing, val=>val},
30
+ {Converter.ToLowerCase, KlavarEventUtils.ToLowerCase},
31
+ {Converter.ToUpperCase, KlavarEventUtils.ToUpperCase},
32
+ {Converter.ToSnakeCase, KlavarEventUtils.ToSnakeCase},
33
+ {Converter.ToCamelCase, KlavarEventUtils.ToCamelCase},
34
+ {Converter.ToPascalCase, KlavarEventUtils.ToPascalCase},
35
+ {Converter.ToKebabCase, KlavarEventUtils.ToKebabCase},
36
+ };
37
+
38
+ public readonly Converter converter;
39
+
40
+ public ToStringAttribute() { converter = Converter.NoThing; }
41
+
42
+ public ToStringAttribute(Converter converter)
43
+ {
44
+ this.converter = converter;
45
+ }
46
+
47
+ private string GetValueAsString(object enumVal)
48
+ {
49
+ // get the field
50
+ var field = enumVal.GetType().GetField(enumVal.ToString());
51
+ var attr = field.GetCustomAttribute<ValueAttribute>();
52
+
53
+ return attr != null ? convertMethods[converter](attr.sValue) : convertMethods[converter](enumVal.ToString());
54
+ }
55
+
56
+ public override object Convert(object parent, FieldInfo fieldInfo, object param)
57
+ {
58
+ return GetValueAsString(param);
59
+ }
60
+ }
61
+
62
+
63
+ public class ToStringLowerCase : ToStringAttribute
64
+ {
65
+ public ToStringLowerCase() : base(ToStringAttribute.Converter.ToLowerCase) { }
66
+ }
67
+
68
+
69
+ public class ToStringUpperCase : ToStringAttribute
70
+ {
71
+ public ToStringUpperCase() : base(ToStringAttribute.Converter.ToUpperCase) { }
72
+ }
73
+
74
+
75
+ public class ToStringToSnakeCase : ToStringAttribute
76
+ {
77
+ public ToStringToSnakeCase() : base(ToStringAttribute.Converter.ToSnakeCase) { }
78
+ }
79
+
80
+ public class ToStringCamelCase : ToStringAttribute
81
+ {
82
+ public ToStringCamelCase() : base(ToStringAttribute.Converter.ToCamelCase) { }
83
+ }
84
+
85
+ public class ToStringPascalCase : ToStringAttribute
86
+ {
87
+ public ToStringPascalCase() : base(ToStringAttribute.Converter.ToPascalCase) { }
88
+ }
89
+
90
+
91
+ public class ToStringKebabCase : ToStringAttribute
92
+ {
93
+ public ToStringKebabCase() : base(ToStringAttribute.Converter.ToKebabCase) { }
94
+ }
95
+
96
+ #pragma warning restore CS3005
97
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 68cd1a5ce6bfe432d8fceab8620a0d0f
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,30 @@
1
+ namespace Amanotes.Core
2
+ {
3
+ /// <summary>
4
+ /// Change the value of param to new value in the attribute
5
+ /// </summary>
6
+ public class ValueAttribute : KlavarEventAttribute
7
+ {
8
+ public readonly int iValue;
9
+ public readonly string sValue;
10
+ public readonly float fValue;
11
+ public readonly double dValue;
12
+ public ValueAttribute(int value)
13
+ {
14
+ this.iValue = value;
15
+ }
16
+ public ValueAttribute(string value)
17
+ {
18
+ this.sValue = value;
19
+ }
20
+ public ValueAttribute(float value)
21
+ {
22
+ this.fValue = value;
23
+ }
24
+
25
+ public ValueAttribute(double value)
26
+ {
27
+ this.dValue = value;
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: a4ddd16b5626545308d6e9948917f0a4
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,12 @@
1
+ fileFormatVersion: 2
2
+ <<<<<<<< HEAD:GDK/AmaGDKCore/Runtime/Klavar/Attributes.meta
3
+ guid: 74f302749097e44ff889ed117ec82dd3
4
+ ========
5
+ guid: 2fdae68db26424f679091198f471cf00
6
+ >>>>>>>> fafdc57 ([Release] 0.2.47):GDKTest/GDK-Unity2020.3/Assets/AmaGDKTest.meta
7
+ folderAsset: yes
8
+ DefaultImporter:
9
+ externalObjects: {}
10
+ userData:
11
+ assetBundleName:
12
+ assetBundleVariant:
@@ -0,0 +1,91 @@
1
+ using System;
2
+ using System.Collections.Generic;
3
+ using System.Linq;
4
+ using System.Reflection;
5
+
6
+
7
+ namespace Amanotes.Core
8
+ {
9
+ /// <summary>
10
+ /// LogEvent parameters Schema
11
+ /// </summary>
12
+ public abstract class KlavarEvent
13
+ {
14
+ /// <summary>
15
+ /// LogEvent
16
+ /// </summary>
17
+ /// <exception cref="ArgumentException"></exception>
18
+ public void LogEvent()
19
+ {
20
+ var type = this.GetType();
21
+ var eventNameAttr = (EventNameAttribute)Attribute.GetCustomAttribute(type, typeof(EventNameAttribute));
22
+
23
+ if (eventNameAttr == null)
24
+ throw new ArgumentException($"Add `EventName` attribute to class {type.FullName}");
25
+
26
+ var @params = this.ToDict();
27
+ var eventName = eventNameAttr.name;
28
+ AmaGDK.Analytics.LogEvent(eventName, @params);
29
+ }
30
+
31
+
32
+ /// <summary>
33
+ /// throw exception from attribute if field is invalid.
34
+ /// </summary>
35
+ /// <param name="field"></param>
36
+ /// <returns></returns>
37
+ /// <exception cref="ArgumentException">when field go wrong.</exception>
38
+ private FieldInfo Validate(FieldInfo field)
39
+ {
40
+ var param = field.GetValue(this);
41
+ var attrs = field.GetCustomAttributes<ValidateLogEventAttribute>(true);
42
+ foreach (var attr in attrs) attr.Validate(this, field, param);
43
+
44
+ return field;
45
+ }
46
+
47
+ /// <summary>
48
+ /// Apply converter attribute in field.
49
+ /// </summary>
50
+ /// <param name="field"></param>
51
+ /// <returns></returns>
52
+ private object Convert(FieldInfo field)
53
+ {
54
+ var attrs = field.GetCustomAttributes<ConverterLogEventAttribute>(true);
55
+ var param = field.GetValue(this);
56
+ foreach (var attr in attrs) param = attr.Convert(this, field, param);
57
+ return param;
58
+ }
59
+
60
+
61
+ /// <summary>
62
+ /// Convert the name in field to new name by attribute.
63
+ /// </summary>
64
+ /// <param name="field"></param>
65
+ /// <returns>the new param name</returns>
66
+ private string GetName(FieldInfo field)
67
+ {
68
+ var attr = field.GetCustomAttribute<NamingLogEventAttribute>(true);
69
+ var param = field.GetValue(this);
70
+ return attr?.GetName(this, field) ?? field.Name;
71
+ }
72
+
73
+
74
+ /// <summary>
75
+ /// Convert all params to dict by field name.
76
+ /// </summary>
77
+ /// <returns>dictionary of params</returns>
78
+ public Dictionary<string, object> ToDict()
79
+ {
80
+ return this
81
+ .GetType()
82
+ .GetFields()
83
+ .Where(field => field.GetCustomAttribute<IgnoreAttribute>() == null)
84
+ .Select(field => Validate(field))
85
+ .ToDictionary(
86
+ field => GetName(field),
87
+ field => Convert(field)
88
+ );
89
+ }
90
+ }
91
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 3d37423ab39204191b9b7c3d3ea832b2
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,39 @@
1
+ using System;
2
+ using System.Reflection;
3
+
4
+
5
+ namespace Amanotes.Core
6
+ {
7
+ /// <summary>
8
+ /// Pretty Log Event Attribute
9
+ /// </summary>
10
+ public abstract class KlavarEventAttribute : Attribute
11
+ {
12
+ }
13
+
14
+ /// <summary>
15
+ /// Validate Property Attribute
16
+ /// </summary>
17
+ public abstract class ValidateLogEventAttribute : KlavarEventAttribute
18
+ {
19
+ public abstract void Validate(object parent, FieldInfo fieldInfo, object param);
20
+ }
21
+
22
+ /// <summary>
23
+ /// Converter Value of Property Attribute
24
+ /// </summary>
25
+ public abstract class ConverterLogEventAttribute : KlavarEventAttribute
26
+ {
27
+ public abstract object Convert(object parent, FieldInfo fieldInfo, object param);
28
+ }
29
+
30
+
31
+ /// <summary>
32
+ /// Nameing Property Attribute
33
+ /// </summary>
34
+ public abstract class NamingLogEventAttribute : KlavarEventAttribute
35
+ {
36
+ public abstract string GetName(object parent, FieldInfo fieldInfo);
37
+ }
38
+ }
39
+
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 2c3072fee96b44e089d862bfd938f252
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,92 @@
1
+ //
2
+ // #if UNITY_EDITOR
3
+ //
4
+ // using System.Linq;
5
+ // using System.Collections;
6
+ // using UnityEditor;
7
+ // using UnityEngine;
8
+ //
9
+ // using System.IO;
10
+ // using System.Collections.Generic;
11
+ // using System;
12
+ //
13
+ // namespace Amanotes.Core
14
+ // {
15
+ // /// <summary>
16
+ // /// Prety Log Event Tools
17
+ // /// </summary>
18
+ // public class KlavarEventTools
19
+ // {
20
+ // public class KlavarEventLine
21
+ // {
22
+ // public string No;
23
+ // public string EventName;
24
+ // public string EventParameterName;
25
+ //
26
+ // public string ValueType;
27
+ //
28
+ // public string ParameterValue;
29
+ //
30
+ // public bool IsInvalid()
31
+ // {
32
+ // return string.IsNullOrWhiteSpace(No)
33
+ // && string.IsNullOrWhiteSpace(EventName)
34
+ // && string.IsNullOrWhiteSpace(EventParameterName)
35
+ // && string.IsNullOrWhiteSpace(ValueType)
36
+ // && string.IsNullOrWhiteSpace(ParameterValue);
37
+ // }
38
+ // }
39
+ //
40
+ // static private IEnumerable<T[]> Chunk<T>(IEnumerable<T> colection, Func<T, bool> splitter)
41
+ // {
42
+ //
43
+ // IEnumerator<T> iter = colection.GetEnumerator();
44
+ // var running = iter.MoveNext();
45
+ //
46
+ // IEnumerable<T> OneChunk()
47
+ // {
48
+ // yield return iter.Current;
49
+ // while (running = iter.MoveNext())
50
+ // {
51
+ // var val = iter.Current;
52
+ // if (splitter(val)) break;
53
+ // yield return val;
54
+ // }
55
+ // }
56
+ //
57
+ // while (running)
58
+ // {
59
+ // var chunk = OneChunk().ToArray();
60
+ // if (chunk.Length > 0) yield return chunk;
61
+ // }
62
+ // }
63
+ //
64
+ //
65
+ // static void ConvertFromCSV()
66
+ // {
67
+ //
68
+ // // string path = EditorUtility.OpenFilePanel("Overwrite with png", ".", "tsv");
69
+ //
70
+ // var path = "/Users/nam.dn/Downloads/Test Pretty Event - Ad Mon.tsv";
71
+ // if (string.IsNullOrEmpty(path)) return;
72
+ //
73
+ //
74
+ // Debug.Log(path);
75
+ // string text = File.ReadAllText(path);
76
+ // var lines = Amanotes.Klavar.TSVParser
77
+ // .Parse<KlavarEventLine>(text)
78
+ // .Where(line => !line.IsInvalid());
79
+ //
80
+ // var linesEvents = Chunk(lines, line => !string.IsNullOrEmpty(line.No));
81
+ // foreach (var linesEvent in linesEvents)
82
+ // {
83
+ // Debug.Log(linesEvent[0]);
84
+ // Debug.Log(linesEvent.Length);
85
+ //
86
+ // var linesParams = Chunk(lines, line => !string.IsNullOrEmpty(line.EventParameterName));
87
+ //
88
+ // }
89
+ // }
90
+ // }
91
+ // }
92
+ // #endif
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 4dc125edcd6594383a73b65b72442585
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,58 @@
1
+ using System;
2
+ using System.Linq;
3
+ using System.Text.RegularExpressions;
4
+
5
+
6
+ namespace Amanotes.Core
7
+ {
8
+ /// <summary>
9
+ /// Convert string to some famous case
10
+ /// https://dev.to/ankitmalikg/difference-among-casings-snake-case-vs-camel-case-vs-pascal-case-vs-kebab-case-2m8b#:~:text=Pascal%20Case%20is%20similar%20to,C%23%2C%20Java%2C%20and%20TypeScript.
11
+ /// </summary>
12
+ internal class KlavarEventUtils
13
+ {
14
+ private static readonly char[] delimiters = { '-', '_', ' ' };
15
+ // private static readonly string delimiters = "_- ";
16
+ public static string[] ToTokens(string text)
17
+ {
18
+ text = Regex.Replace(text, "([A-Z])", " $1");
19
+ var tokens = text.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
20
+ return tokens;
21
+ }
22
+
23
+
24
+ public static string ToLowerCase(string text) => text.ToLower();
25
+
26
+ public static string ToUpperCase(string text) => text.ToUpper();
27
+
28
+ /// <summary>
29
+ /// Convert string to SnakeCase
30
+ /// </summary>
31
+ /// <param name="text"></param>
32
+ /// <returns></returns>
33
+ public static string ToSnakeCase(string text)
34
+ {
35
+ var tokens = ToTokens(text);
36
+ return string.Join("_", tokens.Select(t => t.ToLower()));
37
+ }
38
+
39
+ public static string ToCamelCase(string text)
40
+ {
41
+ var tokens = ToTokens(text);
42
+ return string.Join("", tokens.Select(t => Char.ToUpper(t[0]) + t.Substring(1).ToLower()));
43
+ }
44
+
45
+ public static string ToPascalCase(string text)
46
+ {
47
+ var tokens = ToTokens(text);
48
+ return string.Join("", tokens.Select((t, i) =>
49
+ (i == 0 ? Char.ToLower(t[0]) : Char.ToUpper(t[0])) + t.Substring(1).ToLower()));
50
+ }
51
+
52
+ public static string ToKebabCase(string text)
53
+ {
54
+ var tokens = ToTokens(text);
55
+ return string.Join("-", tokens.Select(t => t.ToLower()));
56
+ }
57
+ }
58
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: f0ef1f5f6bb274056b4b47df1a473529
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,12 @@
1
+ fileFormatVersion: 2
2
+ <<<<<<<< HEAD:GDK/AmaGDKCore/Runtime/Klavar.meta
3
+ guid: 5b981038cfa6f4ec2a7dd96f58fde6cd
4
+ ========
5
+ guid: 74f302749097e44ff889ed117ec82dd3
6
+ >>>>>>>> fafdc57 ([Release] 0.2.47):GDK/AmaGDKCore/Runtime/Klavar/Attributes.meta
7
+ folderAsset: yes
8
+ DefaultImporter:
9
+ externalObjects: {}
10
+ userData:
11
+ assetBundleName:
12
+ assetBundleVariant:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.amanotes.gdk",
3
- "version": "0.2.47",
3
+ "version": "0.2.48",
4
4
  "displayName": "AmaGDK",
5
5
  "description": "Amanotes Game Development Kit",
6
6
  "unity": "2019.4",
package/Runtime/Core.meta DELETED
@@ -1,8 +0,0 @@
1
- fileFormatVersion: 2
2
- guid: 5c409fb968e8e4ed0a49083934f184d6
3
- folderAsset: yes
4
- DefaultImporter:
5
- externalObjects: {}
6
- userData:
7
- assetBundleName:
8
- assetBundleVariant: