evva 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/changelog.md +6 -0
- data/lib/evva/android_generator.rb +10 -3
- data/lib/evva/templates/kotlin/events.kt +16 -14
- data/lib/evva/templates/kotlin/people_properties.kt +11 -9
- data/lib/evva/version.rb +2 -2
- data/spec/lib/evva/android_generator_spec.rb +64 -44
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b5e24a443e11f788768884a4830e8731d4f7f0cbeb02c66e613bb293809b82a
|
4
|
+
data.tar.gz: 5ccb08d43adccc135c64d3ae9bb06c19cb811c0a8a1a5b647cafdab2370fdaa0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee89843173f05753970aacb497add3a0408bbebd2ba6c4d757c41c3f3b0ba90fa00e28dcf455069e1b81e348ef8ceac1c91c01a4369a7fb903b4497ba8bc9b5c
|
7
|
+
data.tar.gz: eb3281e5f3ee84bec798731117504c2e6fdddfc035e772ed13b025a6f506111b4e81875f4126c74fe4582e0bc5fe2aa4b32be29c6f39edb72cbb291192ad424b
|
data/changelog.md
CHANGED
@@ -26,6 +26,8 @@ module Evva
|
|
26
26
|
|
27
27
|
events = bundle.map do |event|
|
28
28
|
properties = event.properties.map do |name, type|
|
29
|
+
type = native_type(type)
|
30
|
+
|
29
31
|
param_name = camelize(name.to_s, false)
|
30
32
|
value_fetcher = param_name
|
31
33
|
|
@@ -51,8 +53,7 @@ module Evva
|
|
51
53
|
class_name: camelize(event.event_name),
|
52
54
|
event_name: constantize(event.event_name),
|
53
55
|
properties: properties,
|
54
|
-
destinations: destinations
|
55
|
-
is_object: properties.count == 0 && destinations.count == 0,
|
56
|
+
destinations: destinations
|
56
57
|
}
|
57
58
|
end
|
58
59
|
|
@@ -82,10 +83,11 @@ module Evva
|
|
82
83
|
destinations_class_name = destinations_file_name
|
83
84
|
|
84
85
|
properties = people_bundle.map do |property|
|
86
|
+
type = native_type(property.type)
|
85
87
|
{
|
86
88
|
class_name: camelize(property.property_name),
|
87
89
|
property_name: constantize(property.property_name),
|
88
|
-
type:
|
90
|
+
type: type,
|
89
91
|
is_special_property: is_special_property?(property.type),
|
90
92
|
destinations: property.destinations.map { |p| constantize(p) },
|
91
93
|
}
|
@@ -175,6 +177,11 @@ module Evva
|
|
175
177
|
string.tr(' ', '_').upcase
|
176
178
|
end
|
177
179
|
|
180
|
+
def native_type(type)
|
181
|
+
type
|
182
|
+
.gsub('Date','String')
|
183
|
+
end
|
184
|
+
|
178
185
|
def is_special_property?(type)
|
179
186
|
!NATIVE_TYPES.include?(type.chomp('?'))
|
180
187
|
end
|
@@ -1,32 +1,34 @@
|
|
1
|
-
sealed class <%= class_name %>(
|
1
|
+
sealed class <%= class_name %>(
|
2
|
+
event: <%= enums_class_name %>,
|
3
|
+
val properties: Map<String, Any?>? = null,
|
4
|
+
val destinations: Array<<%= destinations_class_name %>> = emptyArray()
|
5
|
+
) {
|
2
6
|
val name = event.key
|
3
7
|
|
4
|
-
open val properties: Map<String, Any?>? = null
|
5
|
-
open val destinations: Array<<%= destinations_class_name %>> = []
|
6
|
-
|
7
8
|
<%- events.each_with_index do |e, index| -%>
|
8
|
-
<%- if e[:
|
9
|
-
object <%= e[:class_name] %> : <%= class_name %>(
|
9
|
+
<%- if e[:properties].count == 0 -%>
|
10
|
+
object <%= e[:class_name] %> : <%= class_name %>(
|
10
11
|
<%- else -%>
|
11
|
-
data class <%= e[:class_name]
|
12
|
+
data class <%= e[:class_name] %>(
|
12
13
|
<%= e[:properties].map { |p| "val #{p[:param_name]}: #{p[:type]}" }.join(", ") %>
|
13
|
-
)
|
14
|
+
) : <%= class_name %>(
|
15
|
+
<%- end -%>
|
16
|
+
event = <%= enums_class_name %>.<%= e[:event_name] %>,
|
14
17
|
<%- if e[:properties].count > 0 -%>
|
15
|
-
|
18
|
+
properties = mapOf(
|
16
19
|
<%- e[:properties].each_with_index do |p, index| -%>
|
17
20
|
"<%= p[:name] %>" to <%= p[:value_fetcher] %><% if index < e[:properties].count - 1 %>,<% end %>
|
18
21
|
<%- end -%>
|
19
|
-
)
|
22
|
+
),
|
20
23
|
<%- end -%>
|
21
24
|
<%- if e[:destinations].count > 0 -%>
|
22
|
-
|
25
|
+
destinations = arrayOf(
|
23
26
|
<%- e[:destinations].each_with_index do |d, index| -%>
|
24
27
|
<%= destinations_class_name %>.<%= d %><% if index < e[:destinations].count - 1 %>,<% end %>
|
25
28
|
<%- end -%>
|
26
|
-
|
29
|
+
)
|
27
30
|
<%- end -%>
|
28
|
-
|
29
|
-
<%- end -%>
|
31
|
+
)
|
30
32
|
<%- unless index == events.count - 1 -%>
|
31
33
|
|
32
34
|
<%- end -%>
|
@@ -1,22 +1,24 @@
|
|
1
|
-
sealed class <%= class_name %>(
|
1
|
+
sealed class <%= class_name %>(
|
2
|
+
property: <%= enums_class_name %>,
|
3
|
+
val innerValue: Any,
|
4
|
+
val destinations: Array<<%= destinations_class_name %>> = emptyArray()
|
5
|
+
) {
|
2
6
|
val name = property.key
|
3
7
|
|
4
|
-
open val value: Any = ""
|
5
|
-
open val destinations: Array<<%= destinations_class_name %>> = []
|
6
|
-
|
7
8
|
<%- properties.each_with_index do |property, index| -%>
|
8
9
|
data class <%= property[:class_name] %>(
|
9
10
|
val value: <%= property[:type] %>
|
10
|
-
) : <%= class_name %>(
|
11
|
-
|
11
|
+
) : <%= class_name %>(
|
12
|
+
property = <%= enums_class_name %>.<%= property[:property_name] %>,
|
13
|
+
innerValue = value<% if property[:is_special_property] %>.key<% end %>,
|
12
14
|
<%- if property[:destinations].count > 0 -%>
|
13
|
-
|
15
|
+
destinations = arrayOf(
|
14
16
|
<%- property[:destinations].each_with_index do |d, index| -%>
|
15
17
|
<%= destinations_class_name %>.<%= d %><% if index < property[:destinations].count - 1 %>,<% end %>
|
16
18
|
<%- end -%>
|
17
|
-
|
19
|
+
)
|
18
20
|
<%- end -%>
|
19
|
-
|
21
|
+
)
|
20
22
|
<%- unless index == properties.count - 1 -%>
|
21
23
|
|
22
24
|
<%- end -%>
|
data/lib/evva/version.rb
CHANGED
@@ -10,7 +10,7 @@ describe Evva::AndroidGenerator do
|
|
10
10
|
Evva::AnalyticsEvent.new('cp_page_view_a', { course_id: 'Long', course_name: 'String' }, ["firebase", "custom destination"]),
|
11
11
|
Evva::AnalyticsEvent.new('cp_page_view_b', { course_id: 'Long', course_name: 'String', from_screen: 'CourseProfileSource' }, ["firebase"]),
|
12
12
|
Evva::AnalyticsEvent.new('cp_page_view_c', { course_id: 'Long', course_name: 'String', from_screen: 'CourseProfileSource?' }, []),
|
13
|
-
Evva::AnalyticsEvent.new('cp_page_view_d', { course_id: 'Long?', course_name: 'String' }, []),
|
13
|
+
Evva::AnalyticsEvent.new('cp_page_view_d', { course_id: 'Long?', course_name: 'String', viewed_at: 'Date' }, []),
|
14
14
|
] }
|
15
15
|
|
16
16
|
let(:expected) {
|
@@ -21,64 +21,73 @@ package com.hole19golf.hole19.analytics
|
|
21
21
|
* This file was automatically generated by evva: https://github.com/hole19/evva
|
22
22
|
*/
|
23
23
|
|
24
|
-
sealed class AnalyticsEvent(
|
24
|
+
sealed class AnalyticsEvent(
|
25
|
+
event: AnalyticsEvents,
|
26
|
+
val properties: Map<String, Any?>? = null,
|
27
|
+
val destinations: Array<AnalyticsDestinations> = emptyArray()
|
28
|
+
) {
|
25
29
|
val name = event.key
|
26
30
|
|
27
|
-
|
28
|
-
|
31
|
+
object CpPageView : AnalyticsEvent(
|
32
|
+
event = AnalyticsEvents.CP_PAGE_VIEW,
|
33
|
+
)
|
29
34
|
|
30
|
-
object
|
31
|
-
|
32
|
-
|
33
|
-
override val destinations = [
|
35
|
+
object CpPageView2 : AnalyticsEvent(
|
36
|
+
event = AnalyticsEvents.CP_PAGE_VIEW_2,
|
37
|
+
destinations = arrayOf(
|
34
38
|
AnalyticsDestinations.FIREBASE
|
35
|
-
|
36
|
-
|
39
|
+
)
|
40
|
+
)
|
37
41
|
|
38
42
|
data class CpPageViewA(
|
39
43
|
val courseId: Long, val courseName: String
|
40
|
-
) : AnalyticsEvent(
|
41
|
-
|
44
|
+
) : AnalyticsEvent(
|
45
|
+
event = AnalyticsEvents.CP_PAGE_VIEW_A,
|
46
|
+
properties = mapOf(
|
42
47
|
"course_id" to courseId,
|
43
48
|
"course_name" to courseName
|
44
|
-
)
|
45
|
-
|
49
|
+
),
|
50
|
+
destinations = arrayOf(
|
46
51
|
AnalyticsDestinations.FIREBASE,
|
47
52
|
AnalyticsDestinations.CUSTOM_DESTINATION
|
48
|
-
|
49
|
-
|
53
|
+
)
|
54
|
+
)
|
50
55
|
|
51
56
|
data class CpPageViewB(
|
52
57
|
val courseId: Long, val courseName: String, val fromScreen: CourseProfileSource
|
53
|
-
) : AnalyticsEvent(
|
54
|
-
|
58
|
+
) : AnalyticsEvent(
|
59
|
+
event = AnalyticsEvents.CP_PAGE_VIEW_B,
|
60
|
+
properties = mapOf(
|
55
61
|
"course_id" to courseId,
|
56
62
|
"course_name" to courseName,
|
57
63
|
"from_screen" to fromScreen.key
|
58
|
-
)
|
59
|
-
|
64
|
+
),
|
65
|
+
destinations = arrayOf(
|
60
66
|
AnalyticsDestinations.FIREBASE
|
61
|
-
|
62
|
-
|
67
|
+
)
|
68
|
+
)
|
63
69
|
|
64
70
|
data class CpPageViewC(
|
65
71
|
val courseId: Long, val courseName: String, val fromScreen: CourseProfileSource?
|
66
|
-
) : AnalyticsEvent(
|
67
|
-
|
72
|
+
) : AnalyticsEvent(
|
73
|
+
event = AnalyticsEvents.CP_PAGE_VIEW_C,
|
74
|
+
properties = mapOf(
|
68
75
|
"course_id" to courseId,
|
69
76
|
"course_name" to courseName,
|
70
77
|
"from_screen" to fromScreen?.key
|
71
|
-
)
|
72
|
-
|
78
|
+
),
|
79
|
+
)
|
73
80
|
|
74
81
|
data class CpPageViewD(
|
75
|
-
val courseId: Long?, val courseName: String
|
76
|
-
) : AnalyticsEvent(
|
77
|
-
|
82
|
+
val courseId: Long?, val courseName: String, val viewedAt: String
|
83
|
+
) : AnalyticsEvent(
|
84
|
+
event = AnalyticsEvents.CP_PAGE_VIEW_D,
|
85
|
+
properties = mapOf(
|
78
86
|
"course_id" to courseId,
|
79
|
-
"course_name" to courseName
|
80
|
-
|
81
|
-
|
87
|
+
"course_name" to courseName,
|
88
|
+
"viewed_at" to viewedAt
|
89
|
+
),
|
90
|
+
)
|
82
91
|
}
|
83
92
|
Kotlin
|
84
93
|
}
|
@@ -141,6 +150,7 @@ Kotlin
|
|
141
150
|
subject { generator.people_properties(people_bundle, 'AnalyticsProperty', 'AnalyticsProperties', 'AnalyticsDestinations') }
|
142
151
|
let(:people_bundle) { [
|
143
152
|
Evva::AnalyticsProperty.new('rounds_with_wear', 'String', []),
|
153
|
+
Evva::AnalyticsProperty.new('last_active_at', 'Date', []),
|
144
154
|
Evva::AnalyticsProperty.new('wear_platform', 'WearableAppPlatform', ["firebase", "custom destination"]),
|
145
155
|
] }
|
146
156
|
let(:expected) {
|
@@ -151,27 +161,37 @@ package com.hole19golf.hole19.analytics
|
|
151
161
|
* This file was automatically generated by evva: https://github.com/hole19/evva
|
152
162
|
*/
|
153
163
|
|
154
|
-
sealed class AnalyticsProperty(
|
164
|
+
sealed class AnalyticsProperty(
|
165
|
+
property: AnalyticsProperties,
|
166
|
+
val innerValue: Any,
|
167
|
+
val destinations: Array<AnalyticsDestinations> = emptyArray()
|
168
|
+
) {
|
155
169
|
val name = property.key
|
156
170
|
|
157
|
-
open val value: Any = ""
|
158
|
-
open val destinations: Array<AnalyticsDestinations> = []
|
159
|
-
|
160
171
|
data class RoundsWithWear(
|
161
172
|
val value: String
|
162
|
-
) : AnalyticsProperty(
|
163
|
-
|
164
|
-
|
173
|
+
) : AnalyticsProperty(
|
174
|
+
property = AnalyticsProperties.ROUNDS_WITH_WEAR,
|
175
|
+
innerValue = value,
|
176
|
+
)
|
177
|
+
|
178
|
+
data class LastActiveAt(
|
179
|
+
val value: String
|
180
|
+
) : AnalyticsProperty(
|
181
|
+
property = AnalyticsProperties.LAST_ACTIVE_AT,
|
182
|
+
innerValue = value,
|
183
|
+
)
|
165
184
|
|
166
185
|
data class WearPlatform(
|
167
186
|
val value: WearableAppPlatform
|
168
|
-
) : AnalyticsProperty(
|
169
|
-
|
170
|
-
|
187
|
+
) : AnalyticsProperty(
|
188
|
+
property = AnalyticsProperties.WEAR_PLATFORM,
|
189
|
+
innerValue = value.key,
|
190
|
+
destinations = arrayOf(
|
171
191
|
AnalyticsDestinations.FIREBASE,
|
172
192
|
AnalyticsDestinations.CUSTOM_DESTINATION
|
173
|
-
|
174
|
-
|
193
|
+
)
|
194
|
+
)
|
175
195
|
}
|
176
196
|
Kotlin
|
177
197
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evva
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RicardoTrindade
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: safe_yaml
|