evva 0.2.0 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +10 -10
  3. data/Gemfile +0 -1
  4. data/Gemfile.lock +3 -6
  5. data/README.md +3 -2
  6. data/changelog.md +18 -2
  7. data/lib/evva/{mixpanel_enum.rb → analytics_enum.rb} +2 -1
  8. data/lib/evva/analytics_event.rb +17 -0
  9. data/lib/evva/analytics_property.rb +17 -0
  10. data/lib/evva/android_generator.rb +142 -84
  11. data/lib/evva/config.rb +12 -2
  12. data/lib/evva/google_sheet.rb +43 -25
  13. data/lib/evva/swift_generator.rb +91 -81
  14. data/lib/evva/templates/kotlin/base.kt +7 -0
  15. data/lib/evva/templates/kotlin/destinations.kt +5 -0
  16. data/lib/evva/templates/kotlin/event_enum.kt +5 -0
  17. data/lib/evva/templates/kotlin/events.kt +36 -0
  18. data/lib/evva/templates/kotlin/people_properties.kt +26 -0
  19. data/lib/evva/templates/kotlin/people_properties_enum.kt +5 -0
  20. data/lib/evva/templates/kotlin/special_property_enums.kt +10 -0
  21. data/lib/evva/templates/swift/base.swift +7 -0
  22. data/lib/evva/templates/swift/destinations.swift +5 -0
  23. data/lib/evva/templates/swift/events.swift +66 -0
  24. data/lib/evva/templates/swift/people_properties.swift +50 -0
  25. data/lib/evva/templates/swift/special_property_enums.swift +10 -0
  26. data/lib/evva/version.rb +2 -2
  27. data/lib/evva.rb +14 -4
  28. data/spec/evva_spec.rb +3 -5
  29. data/spec/fixtures/sample_public_events.csv +4 -4
  30. data/spec/fixtures/sample_public_people_properties.csv +4 -3
  31. data/spec/fixtures/test.yml +5 -3
  32. data/spec/lib/evva/android_generator_spec.rb +163 -69
  33. data/spec/lib/evva/config_spec.rb +7 -3
  34. data/spec/lib/evva/google_sheet_spec.rb +25 -7
  35. data/spec/lib/evva/swift_generator_spec.rb +157 -40
  36. metadata +17 -6
  37. data/.ruby-version +0 -1
  38. data/evva_config.yml +0 -14
  39. data/lib/evva/mixpanel_event.rb +0 -13
@@ -2,75 +2,92 @@ describe Evva::AndroidGenerator do
2
2
  let(:generator) { described_class.new("com.hole19golf.hole19.analytics") }
3
3
 
4
4
  describe '#events' do
5
- subject { generator.events(events, "MixpanelAnalytics") }
5
+ subject { generator.events(events, "AnalyticsEvent", "AnalyticsEvents", "AnalyticsDestinations") }
6
6
 
7
7
  let(:events) { [
8
- Evva::MixpanelEvent.new('cp_page_view'),
9
- Evva::MixpanelEvent.new('cp_page_view_a', { course_id: 'Long', course_name: 'String' }),
10
- Evva::MixpanelEvent.new('cp_page_view_b', { course_id: 'Long', course_name: 'String', from_screen: 'CourseProfileSource' }),
11
- Evva::MixpanelEvent.new('cp_page_view_c', { course_id: 'Long', course_name: 'String', from_screen: 'CourseProfileSource?' }),
12
- Evva::MixpanelEvent.new('cp_page_view_d', { course_id: 'Long?', course_name: 'String' })
8
+ Evva::AnalyticsEvent.new('cp_page_view', {}, []),
9
+ Evva::AnalyticsEvent.new('cp_page_view_2', {}, ["firebase"]),
10
+ Evva::AnalyticsEvent.new('cp_page_view_a', { course_id: 'Long', course_name: 'String' }, ["firebase", "custom destination"]),
11
+ Evva::AnalyticsEvent.new('cp_page_view_b', { course_id: 'Long', course_name: 'String', from_screen: 'CourseProfileSource' }, ["firebase"]),
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', viewed_at: 'Date' }, []),
13
14
  ] }
14
15
 
15
16
  let(:expected) {
16
17
  <<-Kotlin
17
18
  package com.hole19golf.hole19.analytics
18
19
 
19
- import com.hole19golf.hole19.analytics.Event
20
- import com.hole19golf.hole19.analytics.MixpanelAnalyticsMask
21
- import org.json.JSONObject
22
-
23
20
  /**
24
21
  * This file was automatically generated by evva: https://github.com/hole19/evva
25
22
  */
26
23
 
27
- open class MixpanelAnalytics(private val mask: MixpanelAnalyticsMask) {
28
-
29
- open fun trackCpPageView() {
30
- mask.trackEvent(MixpanelEvent.CP_PAGE_VIEW)
31
- }
32
-
33
- open fun trackCpPageViewA(course_id: Long, course_name: String) {
34
- val properties = JSONObject().apply {
35
- put("course_id", course_id)
36
- put("course_name", course_name)
37
- }
38
- mask.trackEvent(MixpanelEvent.CP_PAGE_VIEW_A, properties)
39
- }
40
-
41
- open fun trackCpPageViewB(course_id: Long, course_name: String, from_screen: CourseProfileSource) {
42
- val properties = JSONObject().apply {
43
- put("course_id", course_id)
44
- put("course_name", course_name)
45
- put("from_screen", from_screen.key)
46
- }
47
- mask.trackEvent(MixpanelEvent.CP_PAGE_VIEW_B, properties)
48
- }
49
-
50
- open fun trackCpPageViewC(course_id: Long, course_name: String, from_screen: CourseProfileSource?) {
51
- val properties = JSONObject().apply {
52
- put("course_id", course_id)
53
- put("course_name", course_name)
54
- from_screen?.let { put("from_screen", it.key) }
55
- }
56
- mask.trackEvent(MixpanelEvent.CP_PAGE_VIEW_C, properties)
57
- }
58
-
59
- open fun trackCpPageViewD(course_id: Long?, course_name: String) {
60
- val properties = JSONObject().apply {
61
- course_id?.let { put("course_id", it) }
62
- put("course_name", course_name)
63
- }
64
- mask.trackEvent(MixpanelEvent.CP_PAGE_VIEW_D, properties)
65
- }
66
-
67
- open fun updateProperties(property: MixpanelProperties, value: Any) {
68
- mask.updateProperties(property.key, value)
69
- }
70
-
71
- open fun incrementCounter(property: MixpanelProperties) {
72
- mask.incrementCounter(property.key)
73
- }
24
+ sealed class AnalyticsEvent(
25
+ event: AnalyticsEvents,
26
+ val properties: Map<String, Any?>? = null,
27
+ val destinations: Array<AnalyticsDestinations> = emptyArray()
28
+ ) {
29
+ val name = event.key
30
+
31
+ object CpPageView : AnalyticsEvent(
32
+ event = AnalyticsEvents.CP_PAGE_VIEW,
33
+ )
34
+
35
+ object CpPageView2 : AnalyticsEvent(
36
+ event = AnalyticsEvents.CP_PAGE_VIEW_2,
37
+ destinations = arrayOf(
38
+ AnalyticsDestinations.FIREBASE
39
+ )
40
+ )
41
+
42
+ data class CpPageViewA(
43
+ val courseId: Long, val courseName: String
44
+ ) : AnalyticsEvent(
45
+ event = AnalyticsEvents.CP_PAGE_VIEW_A,
46
+ properties = mapOf(
47
+ "course_id" to courseId,
48
+ "course_name" to courseName
49
+ ),
50
+ destinations = arrayOf(
51
+ AnalyticsDestinations.FIREBASE,
52
+ AnalyticsDestinations.CUSTOM_DESTINATION
53
+ )
54
+ )
55
+
56
+ data class CpPageViewB(
57
+ val courseId: Long, val courseName: String, val fromScreen: CourseProfileSource
58
+ ) : AnalyticsEvent(
59
+ event = AnalyticsEvents.CP_PAGE_VIEW_B,
60
+ properties = mapOf(
61
+ "course_id" to courseId,
62
+ "course_name" to courseName,
63
+ "from_screen" to fromScreen.key
64
+ ),
65
+ destinations = arrayOf(
66
+ AnalyticsDestinations.FIREBASE
67
+ )
68
+ )
69
+
70
+ data class CpPageViewC(
71
+ val courseId: Long, val courseName: String, val fromScreen: CourseProfileSource?
72
+ ) : AnalyticsEvent(
73
+ event = AnalyticsEvents.CP_PAGE_VIEW_C,
74
+ properties = mapOf(
75
+ "course_id" to courseId,
76
+ "course_name" to courseName,
77
+ "from_screen" to fromScreen?.key
78
+ ),
79
+ )
80
+
81
+ data class CpPageViewD(
82
+ val courseId: Long?, val courseName: String, val viewedAt: String
83
+ ) : AnalyticsEvent(
84
+ event = AnalyticsEvents.CP_PAGE_VIEW_D,
85
+ properties = mapOf(
86
+ "course_id" to courseId,
87
+ "course_name" to courseName,
88
+ "viewed_at" to viewedAt
89
+ ),
90
+ )
74
91
  }
75
92
  Kotlin
76
93
  }
@@ -81,8 +98,8 @@ Kotlin
81
98
  describe '#special_property_enums' do
82
99
  subject { generator.special_property_enums(enums) }
83
100
  let(:enums) { [
84
- Evva::MixpanelEnum.new('CourseProfileSource', ['course_discovery', 'synced_courses']),
85
- Evva::MixpanelEnum.new('PremiumFrom', ['Course Profile', 'Round Setup'])
101
+ Evva::AnalyticsEnum.new('CourseProfileSource', ['course_discovery', 'synced_courses']),
102
+ Evva::AnalyticsEnum.new('PremiumFrom', ['Course Profile', 'Round Setup']),
86
103
  ] }
87
104
  let(:expected) {
88
105
  <<-Kotlin
@@ -107,22 +124,20 @@ Kotlin
107
124
  end
108
125
 
109
126
  describe '#event_enum' do
110
- subject { generator.event_enum(event_bundle, 'MixpanelEvent') }
127
+ subject { generator.event_enum(event_bundle, 'AnalyticsEvents') }
111
128
  let(:event_bundle) { [
112
- Evva::MixpanelEvent.new('nav_feed_tap', {}),
113
- Evva::MixpanelEvent.new('nav_performance_tap', {})
129
+ Evva::AnalyticsEvent.new('nav_feed_tap', {}, []),
130
+ Evva::AnalyticsEvent.new('nav_performance_tap', {}, []),
114
131
  ] }
115
132
  let(:expected) {
116
133
  <<-Kotlin
117
134
  package com.hole19golf.hole19.analytics
118
135
 
119
- import com.hole19golf.hole19.analytics.Event
120
-
121
136
  /**
122
137
  * This file was automatically generated by evva: https://github.com/hole19/evva
123
138
  */
124
139
 
125
- enum class MixpanelEvent(override val key: String) : Event {
140
+ enum class AnalyticsEvents(val key: String) {
126
141
  NAV_FEED_TAP("nav_feed_tap"),
127
142
  NAV_PERFORMANCE_TAP("nav_performance_tap");
128
143
  }
@@ -132,8 +147,64 @@ Kotlin
132
147
  end
133
148
 
134
149
  describe '#people_properties' do
135
- subject { generator.people_properties(people_bundle, 'MixpanelProperties') }
136
- let(:people_bundle) { ['rounds_with_wear', 'friends_from_facebook'] }
150
+ subject { generator.people_properties(people_bundle, 'AnalyticsProperty', 'AnalyticsProperties', 'AnalyticsDestinations') }
151
+ let(:people_bundle) { [
152
+ Evva::AnalyticsProperty.new('rounds_with_wear', 'String', []),
153
+ Evva::AnalyticsProperty.new('last_active_at', 'Date', []),
154
+ Evva::AnalyticsProperty.new('wear_platform', 'WearableAppPlatform', ["firebase", "custom destination"]),
155
+ ] }
156
+ let(:expected) {
157
+ <<-Kotlin
158
+ package com.hole19golf.hole19.analytics
159
+
160
+ /**
161
+ * This file was automatically generated by evva: https://github.com/hole19/evva
162
+ */
163
+
164
+ sealed class AnalyticsProperty(
165
+ property: AnalyticsProperties,
166
+ val innerValue: Any,
167
+ val destinations: Array<AnalyticsDestinations> = emptyArray()
168
+ ) {
169
+ val name = property.key
170
+
171
+ data class RoundsWithWear(
172
+ val value: String
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
+ )
184
+
185
+ data class WearPlatform(
186
+ val value: WearableAppPlatform
187
+ ) : AnalyticsProperty(
188
+ property = AnalyticsProperties.WEAR_PLATFORM,
189
+ innerValue = value.key,
190
+ destinations = arrayOf(
191
+ AnalyticsDestinations.FIREBASE,
192
+ AnalyticsDestinations.CUSTOM_DESTINATION
193
+ )
194
+ )
195
+ }
196
+ Kotlin
197
+ }
198
+
199
+ it { should eq expected }
200
+ end
201
+
202
+ describe '#people_properties_enum' do
203
+ subject { generator.people_properties_enum(people_bundle, 'AnalyticsProperties') }
204
+ let(:people_bundle) { [
205
+ Evva::AnalyticsProperty.new('rounds_with_wear', 'String', ["firebase"]),
206
+ Evva::AnalyticsProperty.new('wear_platform', 'WearableAppPlatform', ["firebase", "custom destination"]),
207
+ ] }
137
208
  let(:expected) {
138
209
  <<-Kotlin
139
210
  package com.hole19golf.hole19.analytics
@@ -142,9 +213,32 @@ package com.hole19golf.hole19.analytics
142
213
  * This file was automatically generated by evva: https://github.com/hole19/evva
143
214
  */
144
215
 
145
- enum class MixpanelProperties(val key: String) {
216
+ enum class AnalyticsProperties(val key: String) {
146
217
  ROUNDS_WITH_WEAR("rounds_with_wear"),
147
- FRIENDS_FROM_FACEBOOK("friends_from_facebook");
218
+ WEAR_PLATFORM("wear_platform");
219
+ }
220
+ Kotlin
221
+ }
222
+ it { should eq expected }
223
+ end
224
+
225
+ describe '#destinations' do
226
+ subject { generator.destinations(destinations_bundle, 'AnalyticsDestinations') }
227
+ let(:destinations_bundle) { [
228
+ 'firebase',
229
+ 'whatever you want really'
230
+ ] }
231
+ let(:expected) {
232
+ <<-Kotlin
233
+ package com.hole19golf.hole19.analytics
234
+
235
+ /**
236
+ * This file was automatically generated by evva: https://github.com/hole19/evva
237
+ */
238
+
239
+ enum class AnalyticsDestinations {
240
+ FIREBASE,
241
+ WHATEVER_YOU_WANT_REALLY;
148
242
  }
149
243
  Kotlin
150
244
  }
@@ -12,9 +12,11 @@ describe Evva::Config do
12
12
  },
13
13
  out_path: 'clear/path/to/event',
14
14
  event_file_name: 'event/file/name',
15
- people_file_name: 'people/file/name',
16
15
  event_enum_file_name: 'event/enum/file',
17
- package_name: 'com.package.name.analytics'
16
+ people_file_name: 'people/file/name',
17
+ people_enum_file_name: 'people/enum/file/name',
18
+ destinations_file_name: 'destinations/file/name',
19
+ package_name: 'com.package.name.analytics',
18
20
  }
19
21
  end
20
22
 
@@ -27,8 +29,10 @@ describe Evva::Config do
27
29
  its(:type) { should eq('EvvaOS') }
28
30
  its(:out_path) { should eq('clear/path/to/event') }
29
31
  its(:event_file_name) { should eq('event/file/name') }
30
- its(:people_file_name) { should eq('people/file/name') }
31
32
  its(:event_enum_file_name) { should eq 'event/enum/file' }
33
+ its(:people_file_name) { should eq('people/file/name') }
34
+ its(:people_enum_file_name) { should eq('people/enum/file/name') }
35
+ its(:destinations_file_name) { should eq 'destinations/file/name' }
32
36
  its(:package_name) { should eq 'com.package.name.analytics' }
33
37
 
34
38
  describe '#data_source' do
@@ -22,9 +22,11 @@ describe Evva::GoogleSheet do
22
22
  end
23
23
 
24
24
  it 'returns an array with the corresponding events' do
25
- expected = [Evva::MixpanelEvent.new('cp_page_view', { course_id: 'Long', course_name: 'String' }),
26
- Evva::MixpanelEvent.new('nav_feed_tap', {}),
27
- Evva::MixpanelEvent.new('cp_view_scorecard', { course_id: 'Long', course_name: 'String' })]
25
+ expected = [
26
+ Evva::AnalyticsEvent.new('cp_page_view', { course_id: 'Long', course_name: 'String' }, ['firebase', 'custom destination']),
27
+ Evva::AnalyticsEvent.new('nav_feed_tap', {}, []),
28
+ Evva::AnalyticsEvent.new('cp_view_scorecard', { course_id: 'Long', course_name: 'String' }, ['custom destination']),
29
+ ]
28
30
  expect(events).to eq(expected)
29
31
  end
30
32
 
@@ -54,8 +56,9 @@ describe Evva::GoogleSheet do
54
56
 
55
57
  it 'returns an array with the corresponding events' do
56
58
  expect(people_properties).to eq [
57
- 'rounds_with_wear',
58
- 'total_friends'
59
+ Evva::AnalyticsProperty.new('rounds_with_wear', 'String', ['firebase', 'custom destination']),
60
+ Evva::AnalyticsProperty.new('total_friends', 'Int', []),
61
+ Evva::AnalyticsProperty.new('wearable_platform', 'WearableAppPlatform', ['firebase']),
59
62
  ]
60
63
  end
61
64
  end
@@ -69,8 +72,23 @@ describe Evva::GoogleSheet do
69
72
 
70
73
  it 'returns an array with the corresponding events' do
71
74
  expect(enum_classes).to eq [
72
- Evva::MixpanelEnum.new('PageViewSourceScreen', ['course_discovery','synced_courses','nearby','deal']),
73
- Evva::MixpanelEnum.new('PremiumClickBuy', ['notes','hi_res_maps','whatever'])
75
+ Evva::AnalyticsEnum.new('PageViewSourceScreen', ['course_discovery','synced_courses','nearby','deal']),
76
+ Evva::AnalyticsEnum.new('PremiumClickBuy', ['notes','hi_res_maps','whatever'])
77
+ ]
78
+ end
79
+ end
80
+
81
+ describe '#destinations' do
82
+ subject(:destinations) { sheet.destinations }
83
+
84
+ it do
85
+ expect { destinations }.not_to raise_error
86
+ end
87
+
88
+ it 'returns an array with the corresponding events' do
89
+ expect(destinations).to eq [
90
+ 'firebase',
91
+ 'custom destination',
74
92
  ]
75
93
  end
76
94
  end
@@ -2,14 +2,14 @@ describe Evva::SwiftGenerator do
2
2
  let(:generator) { described_class.new }
3
3
 
4
4
  describe '#events' do
5
- subject { generator.events(event_bundle, "") }
5
+ subject { generator.events(event_bundle, nil, nil, nil) }
6
6
 
7
7
  let(:event_bundle) { [
8
- Evva::MixpanelEvent.new('cp_page_view'),
9
- Evva::MixpanelEvent.new('cp_page_view_a', { course_id: 'Long', course_name: 'String' }),
10
- Evva::MixpanelEvent.new('cp_page_view_b', { course_id: 'Long', course_name: 'String', from_screen: 'CourseProfileSource' }),
11
- Evva::MixpanelEvent.new('cp_page_view_c', { course_id: 'Long', course_name: 'String', from_screen: 'CourseProfileSource?' }),
12
- Evva::MixpanelEvent.new('cp_page_view_d', { course_id: 'Long?', course_name: 'String' })
8
+ Evva::AnalyticsEvent.new('cp_page_view', {}, ['firebase']),
9
+ Evva::AnalyticsEvent.new('cp_page_view_a', { course_id: 'Long', course_name: 'String' }, ['firebase', 'Custom Destination']),
10
+ Evva::AnalyticsEvent.new('cp_page_view_b', { course_id: 'Long', course_name: 'String', from_screen: 'CourseProfileSource' }, []),
11
+ Evva::AnalyticsEvent.new('cp_page_view_c', { course_id: 'Long', course_name: 'String', from_screen: 'CourseProfileSource?' }, []),
12
+ Evva::AnalyticsEvent.new('cp_page_view_d', { course_id: 'Long?', course_name: 'String' }, []),
13
13
  ] }
14
14
 
15
15
  let(:expected) {
@@ -19,6 +19,41 @@ describe Evva::SwiftGenerator do
19
19
  import Foundation
20
20
 
21
21
  extension Analytics {
22
+ struct EventData {
23
+ let name: String
24
+ var properties: [String: Any]?
25
+ let destinations: [Destination]
26
+
27
+ init(name: String, properties: [String: Any]?, destinations: [Destination]) {
28
+ self.name = name
29
+ self.properties = properties
30
+ self.destinations = destinations
31
+ }
32
+
33
+ init(type: EventType, properties: [String: Any]?) {
34
+ self.init(name: type.name, properties: properties, destinations: type.destinations)
35
+ }
36
+ }
37
+
38
+ enum EventType: String {
39
+ case cpPageView = "cp_page_view"
40
+ case cpPageViewA = "cp_page_view_a"
41
+ case cpPageViewB = "cp_page_view_b"
42
+ case cpPageViewC = "cp_page_view_c"
43
+ case cpPageViewD = "cp_page_view_d"
44
+
45
+ var name: String { return rawValue }
46
+
47
+ var destinations: [Destination] {
48
+ switch self {
49
+ case .cpPageView: return [.firebase]
50
+ case .cpPageViewA: return [.firebase, .customDestination]
51
+ case .cpPageViewB: return []
52
+ case .cpPageViewC: return []
53
+ case .cpPageViewD: return []
54
+ }
55
+ }
56
+ }
22
57
 
23
58
  enum Event {
24
59
  case cpPageView
@@ -30,33 +65,38 @@ extension Analytics {
30
65
  var data: EventData {
31
66
  switch self {
32
67
  case .cpPageView:
33
- return EventData(name: "cp_page_view")
34
-
35
- case .cpPageViewA(let course_id, let course_name):
36
- return EventData(name: "cp_page_view_a", properties: [
37
- "course_id": course_id as Any,
38
- "course_name": course_name as Any ]
39
- )
40
-
41
- case .cpPageViewB(let course_id, let course_name, let from_screen):
42
- return EventData(name: "cp_page_view_b", properties: [
43
- "course_id": course_id as Any,
44
- "course_name": course_name as Any,
45
- "from_screen": from_screen.rawValue as Any ]
46
- )
47
-
48
- case .cpPageViewC(let course_id, let course_name, let from_screen):
49
- return EventData(name: "cp_page_view_c", properties: [
50
- "course_id": course_id as Any,
51
- "course_name": course_name as Any,
52
- "from_screen": from_screen?.rawValue as Any ]
53
- )
54
-
55
- case .cpPageViewD(let course_id, let course_name):
56
- return EventData(name: "cp_page_view_d", properties: [
57
- "course_id": course_id as Any,
58
- "course_name": course_name as Any ]
59
- )
68
+ return EventData(type: .cpPageView,
69
+ properties: nil)
70
+
71
+ case let .cpPageViewA(course_id, course_name):
72
+ return EventData(type: .cpPageViewA,
73
+ properties: [
74
+ "course_id": course_id as Any,
75
+ "course_name": course_name as Any,
76
+ ])
77
+
78
+ case let .cpPageViewB(course_id, course_name, from_screen):
79
+ return EventData(type: .cpPageViewB,
80
+ properties: [
81
+ "course_id": course_id as Any,
82
+ "course_name": course_name as Any,
83
+ "from_screen": from_screen.rawValue as Any,
84
+ ])
85
+
86
+ case let .cpPageViewC(course_id, course_name, from_screen):
87
+ return EventData(type: .cpPageViewC,
88
+ properties: [
89
+ "course_id": course_id as Any,
90
+ "course_name": course_name as Any,
91
+ "from_screen": from_screen?.rawValue as Any,
92
+ ])
93
+
94
+ case let .cpPageViewD(course_id, course_name):
95
+ return EventData(type: .cpPageViewD,
96
+ properties: [
97
+ "course_id": course_id as Any,
98
+ "course_name": course_name as Any,
99
+ ])
60
100
  }
61
101
  }
62
102
  }
@@ -71,8 +111,8 @@ Swift
71
111
  subject { generator.special_property_enums(enums) }
72
112
 
73
113
  let(:enums) { [
74
- Evva::MixpanelEnum.new('CourseProfileSource', ['course_discovery', 'synced_courses']),
75
- Evva::MixpanelEnum.new('PremiumFrom', ['Course Profile', 'Round Setup'])
114
+ Evva::AnalyticsEnum.new('CourseProfileSource', ['course_discovery', 'synced_courses']),
115
+ Evva::AnalyticsEnum.new('PremiumFrom', ['Course Profile', 'Round Setup']),
76
116
  ] }
77
117
 
78
118
  let(:expected) {
@@ -82,7 +122,6 @@ Swift
82
122
  import Foundation
83
123
 
84
124
  extension Analytics {
85
-
86
125
  enum CourseProfileSource: String {
87
126
  case courseDiscovery = "course_discovery"
88
127
  case syncedCourses = "synced_courses"
@@ -100,9 +139,13 @@ Swift
100
139
  end
101
140
 
102
141
  describe "#people_properties" do
103
- subject { generator.people_properties(people_bundle, "") }
142
+ subject { generator.people_properties(people_bundle, "", "", "") }
104
143
 
105
- let(:people_bundle) { ['rounds_with_wear', 'friends_from_facebook'] }
144
+ let(:people_bundle) { [
145
+ Evva::AnalyticsProperty.new('rounds_with_wear', 'String', ["firebase"]),
146
+ Evva::AnalyticsProperty.new('wear_platform', 'WearableAppPlatform', ["firebase", "custom destination"]),
147
+ Evva::AnalyticsProperty.new('number_of_times_it_happened', 'Long', []),
148
+ ] }
106
149
 
107
150
  let(:expected) {
108
151
  <<-Swift
@@ -111,10 +154,84 @@ Swift
111
154
  import Foundation
112
155
 
113
156
  extension Analytics {
157
+ struct PropertyData {
158
+ let name: String
159
+ let value: Any
160
+ let destinations: [Destination]
161
+
162
+ init(name: String, value: Any, destinations: [Destination]) {
163
+ self.name = name
164
+ self.value = value
165
+ self.destinations = destinations
166
+ }
167
+
168
+ init(type: PropertyType, value: Any) {
169
+ self.init(name: type.name, value: value, destinations: type.destinations)
170
+ }
171
+ }
114
172
 
115
- enum Property: String {
173
+ enum PropertyType: String {
116
174
  case roundsWithWear = "rounds_with_wear"
117
- case friendsFromFacebook = "friends_from_facebook"
175
+ case wearPlatform = "wear_platform"
176
+ case numberOfTimesItHappened = "number_of_times_it_happened"
177
+
178
+ var name: String { return rawValue }
179
+
180
+ var destinations: [Destination] {
181
+ switch self {
182
+ case .roundsWithWear: return [.firebase]
183
+ case .wearPlatform: return [.firebase, .customDestination]
184
+ case .numberOfTimesItHappened: return []
185
+ }
186
+ }
187
+ }
188
+
189
+ enum Property {
190
+ case roundsWithWear(String)
191
+ case wearPlatform(WearableAppPlatform)
192
+ case numberOfTimesItHappened(Int)
193
+
194
+ var data: PropertyData {
195
+ switch self {
196
+ case let .roundsWithWear(value):
197
+ return PropertyData(type: .roundsWithWear,
198
+ value: value)
199
+
200
+ case let .wearPlatform(value):
201
+ return PropertyData(type: .wearPlatform,
202
+ value: value.rawValue)
203
+
204
+ case let .numberOfTimesItHappened(value):
205
+ return PropertyData(type: .numberOfTimesItHappened,
206
+ value: value)
207
+ }
208
+ }
209
+ }
210
+ }
211
+ Swift
212
+ }
213
+
214
+ it { should eq expected }
215
+ end
216
+
217
+ describe "#destinations" do
218
+ subject { generator.destinations(destinations, "") }
219
+
220
+ let(:destinations) { [
221
+ 'firebase',
222
+ 'whatever you want really'
223
+ ] }
224
+
225
+ let(:expected) {
226
+ <<-Swift
227
+ // This file was automatically generated by evva: https://github.com/hole19/evva
228
+
229
+ import Foundation
230
+
231
+ extension Analytics {
232
+ enum Destination {
233
+ case firebase
234
+ case whateverYouWantReally
118
235
  }
119
236
  }
120
237
  Swift
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.2.0
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: 2021-08-30 00:00:00.000000000 Z
11
+ date: 2022-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: safe_yaml
@@ -48,7 +48,6 @@ files:
48
48
  - ".gitignore"
49
49
  - ".rspec"
50
50
  - ".rubocop_todo.yml"
51
- - ".ruby-version"
52
51
  - ".travis.yml"
53
52
  - Gemfile
54
53
  - Gemfile.lock
@@ -57,17 +56,29 @@ files:
57
56
  - bin/evva
58
57
  - changelog.md
59
58
  - evva.gemspec
60
- - evva_config.yml
61
59
  - lib/evva.rb
60
+ - lib/evva/analytics_enum.rb
61
+ - lib/evva/analytics_event.rb
62
+ - lib/evva/analytics_property.rb
62
63
  - lib/evva/android_generator.rb
63
64
  - lib/evva/config.rb
64
65
  - lib/evva/file_reader.rb
65
66
  - lib/evva/google_sheet.rb
66
67
  - lib/evva/logger.rb
67
- - lib/evva/mixpanel_enum.rb
68
- - lib/evva/mixpanel_event.rb
69
68
  - lib/evva/object_extension.rb
70
69
  - lib/evva/swift_generator.rb
70
+ - lib/evva/templates/kotlin/base.kt
71
+ - lib/evva/templates/kotlin/destinations.kt
72
+ - lib/evva/templates/kotlin/event_enum.kt
73
+ - lib/evva/templates/kotlin/events.kt
74
+ - lib/evva/templates/kotlin/people_properties.kt
75
+ - lib/evva/templates/kotlin/people_properties_enum.kt
76
+ - lib/evva/templates/kotlin/special_property_enums.kt
77
+ - lib/evva/templates/swift/base.swift
78
+ - lib/evva/templates/swift/destinations.swift
79
+ - lib/evva/templates/swift/events.swift
80
+ - lib/evva/templates/swift/people_properties.swift
81
+ - lib/evva/templates/swift/special_property_enums.swift
71
82
  - lib/evva/version.rb
72
83
  - rubocop.yml
73
84
  - spec/evva_spec.rb