Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
evva (0.7.0)
evva (0.8.4)
colorize (~> 1.0)
csv (>= 3.0)
safe_yaml (~> 1.0)
Expand Down
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## [0.8.4] - 2026-06-25

- Add trailing commas to all generated Kotlin declarations

## [0.8.3] - 2026-05-27

- Add explicit `as Any` cast for optional people property values to silence Swift compiler warning
Expand Down
2 changes: 1 addition & 1 deletion lib/evva/templates/kotlin/destinations.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
enum class <%= class_name %> {
<%- destinations.each_with_index do |destination, index| -%>
<%= destination %><%= index == destinations.count - 1 ? "" : "," %>
<%= destination %>,
<%- end -%>
}
2 changes: 1 addition & 1 deletion lib/evva/templates/kotlin/event_enum.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
enum class <%= class_name %>(val key: String) {
<%- events.each_with_index do |event, index| -%>
<%= event[:name] %>("<%= event[:value] %>")<%= index == events.count - 1 ? "" : "," %>
<%= event[:name] %>("<%= event[:value] %>"),
<%- end -%>
}
10 changes: 5 additions & 5 deletions lib/evva/templates/kotlin/events.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sealed class <%= class_name %>(
event: <%= enums_class_name %>,
val properties: Map<String, Any?>? = null,
val destinations: Array<<%= destinations_class_name %>> = emptyArray()
val destinations: Array<<%= destinations_class_name %>> = emptyArray(),
) {
val name = event.key

Expand All @@ -11,24 +11,24 @@ sealed class <%= class_name %>(
<%- else -%>
data class <%= e[:class_name] %>(
<%- e[:properties].each_with_index do |p, index| -%>
<%= "val #{p[:param_name]}: #{p[:type]}" %><% if index < e[:properties].count - 1 %>,<% end %>
<%= "val #{p[:param_name]}: #{p[:type]}" %>,
<%- end -%>
) : <%= class_name %>(
<%- end -%>
event = <%= enums_class_name %>.<%= e[:event_name] %>,
<%- if e[:properties].count > 0 -%>
properties = mapOf(
<%- e[:properties].each_with_index do |p, index| -%>
"<%= p[:name] %>" to <%= p[:value_fetcher] %><% if index < e[:properties].count - 1 %>,<% end %>
"<%= p[:name] %>" to <%= p[:value_fetcher] %>,
<%- end -%>
),
<%- end -%>
<%- if e[:destinations].count > 0 -%>
destinations = arrayOf(
<%- e[:destinations].each_with_index do |d, index| -%>
<%= destinations_class_name %>.<%= d %><% if index < e[:destinations].count - 1 %>,<% end %>
<%= destinations_class_name %>.<%= d %>,
<%- end -%>
)
),
<%- end -%>
)
<%- unless index == events.count - 1 -%>
Expand Down
8 changes: 4 additions & 4 deletions lib/evva/templates/kotlin/people_properties.kt
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
sealed class <%= class_name %>(
property: <%= enums_class_name %>,
val innerValue: Any,
val destinations: Array<<%= destinations_class_name %>> = emptyArray()
val destinations: Array<<%= destinations_class_name %>> = emptyArray(),
) {
val name = property.key

<%- properties.each_with_index do |property, index| -%>
data class <%= property[:class_name] %>(
val value: <%= property[:type] %>
val value: <%= property[:type] %>,
) : <%= class_name %>(
property = <%= enums_class_name %>.<%= property[:property_name] %>,
innerValue = value<% if property[:is_special_property] %>.key<% end %>,
<%- if property[:destinations].count > 0 -%>
destinations = arrayOf(
<%- property[:destinations].each_with_index do |d, index| -%>
<%= destinations_class_name %>.<%= d %><% if index < property[:destinations].count - 1 %>,<% end %>
<%= destinations_class_name %>.<%= d %>,
<%- end -%>
)
),
<%- end -%>
)
<%- unless index == properties.count - 1 -%>
Expand Down
2 changes: 1 addition & 1 deletion lib/evva/templates/kotlin/people_properties_enum.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
enum class <%= class_name %>(val key: String) {
<%- properties.each_with_index do |property, index| -%>
<%= property[:name] %>("<%= property[:value] %>")<%= index == properties.count - 1 ? "" : "," %>
<%= property[:name] %>("<%= property[:value] %>"),
<%- end -%>
}
2 changes: 1 addition & 1 deletion lib/evva/templates/kotlin/special_property_enums.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<%- enums.each_with_index do |enum, index| -%>
enum class <%= enum[:class_name] %>(val key: String) {
<%- enum[:values].each_with_index do |v, index| -%>
<%= v[:name] %>("<%= v[:value] %>")<%= index == enum[:values].count - 1 ? "" : "," %>
<%= v[:name] %>("<%= v[:value] %>"),
<%- end -%>
}
<%- unless index == enums.count - 1 -%>
Expand Down
4 changes: 2 additions & 2 deletions lib/evva/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Evva
VERSION = "0.8.3".freeze
VERSION_UPDATED_AT = "2026-05-26".freeze
VERSION = "0.8.4".freeze
VERSION_UPDATED_AT = "2026-06-25".freeze
end
52 changes: 26 additions & 26 deletions spec/lib/evva/kotlin_generator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
sealed class AnalyticsEvent(
event: AnalyticsEvents,
val properties: Map<String, Any?>? = null,
val destinations: Array<AnalyticsDestinations> = emptyArray()
val destinations: Array<AnalyticsDestinations> = emptyArray(),
) {
val name = event.key

Expand All @@ -35,64 +35,64 @@
data object CpPageView2 : AnalyticsEvent(
event = AnalyticsEvents.CP_PAGE_VIEW_2,
destinations = arrayOf(
AnalyticsDestinations.FIREBASE
)
AnalyticsDestinations.FIREBASE,
),
)

data class CpPageViewA(
val courseId: Long,
val courseName: String
val courseName: String,
) : AnalyticsEvent(
event = AnalyticsEvents.CP_PAGE_VIEW_A,
properties = mapOf(
"course_id" to courseId,
"course_name" to courseName
"course_name" to courseName,
),
destinations = arrayOf(
AnalyticsDestinations.FIREBASE,
AnalyticsDestinations.CUSTOM_DESTINATION
)
AnalyticsDestinations.CUSTOM_DESTINATION,
),
)

data class CpPageViewB(
val courseId: Long,
val courseName: String,
val fromScreen: CourseProfileSource
val fromScreen: CourseProfileSource,
) : AnalyticsEvent(
event = AnalyticsEvents.CP_PAGE_VIEW_B,
properties = mapOf(
"course_id" to courseId,
"course_name" to courseName,
"from_screen" to fromScreen.key
"from_screen" to fromScreen.key,
),
destinations = arrayOf(
AnalyticsDestinations.FIREBASE
)
AnalyticsDestinations.FIREBASE,
),
)

data class CpPageViewC(
val courseId: Long,
val courseName: String,
val fromScreen: CourseProfileSource?
val fromScreen: CourseProfileSource?,
) : AnalyticsEvent(
event = AnalyticsEvents.CP_PAGE_VIEW_C,
properties = mapOf(
"course_id" to courseId,
"course_name" to courseName,
"from_screen" to fromScreen?.key
"from_screen" to fromScreen?.key,
),
)

data class CpPageViewD(
val courseId: Long?,
val courseName: String,
val viewedAt: String
val viewedAt: String,
) : AnalyticsEvent(
event = AnalyticsEvents.CP_PAGE_VIEW_D,
properties = mapOf(
"course_id" to courseId,
"course_name" to courseName,
"viewed_at" to viewedAt
"viewed_at" to viewedAt,
),
)
}
Expand All @@ -118,12 +118,12 @@

enum class CourseProfileSource(val key: String) {
COURSE_DISCOVERY("course_discovery"),
SYNCED_COURSES("synced_courses")
SYNCED_COURSES("synced_courses"),
}

enum class PremiumFrom(val key: String) {
COURSE_PROFILE("Course Profile"),
ROUND_SETUP("Round Setup")
ROUND_SETUP("Round Setup"),
}
Kotlin
}
Expand All @@ -146,7 +146,7 @@

enum class AnalyticsEvents(val key: String) {
NAV_FEED_TAP("nav_feed_tap"),
NAV_PERFORMANCE_TAP("nav_performance_tap")
NAV_PERFORMANCE_TAP("nav_performance_tap"),
}
Kotlin
}
Expand All @@ -171,33 +171,33 @@
sealed class AnalyticsProperty(
property: AnalyticsProperties,
val innerValue: Any,
val destinations: Array<AnalyticsDestinations> = emptyArray()
val destinations: Array<AnalyticsDestinations> = emptyArray(),
) {
val name = property.key

data class RoundsWithWear(
val value: String
val value: String,
) : AnalyticsProperty(
property = AnalyticsProperties.ROUNDS_WITH_WEAR,
innerValue = value,
)

data class LastActiveAt(
val value: String
val value: String,
) : AnalyticsProperty(
property = AnalyticsProperties.LAST_ACTIVE_AT,
innerValue = value,
)

data class WearPlatform(
val value: WearableAppPlatform
val value: WearableAppPlatform,
) : AnalyticsProperty(
property = AnalyticsProperties.WEAR_PLATFORM,
innerValue = value.key,
destinations = arrayOf(
AnalyticsDestinations.FIREBASE,
AnalyticsDestinations.CUSTOM_DESTINATION
)
AnalyticsDestinations.CUSTOM_DESTINATION,
),
)
}
Kotlin
Expand All @@ -222,7 +222,7 @@

enum class AnalyticsProperties(val key: String) {
ROUNDS_WITH_WEAR("rounds_with_wear"),
WEAR_PLATFORM("wear_platform")
WEAR_PLATFORM("wear_platform"),
}
Kotlin
}
Expand All @@ -245,7 +245,7 @@

enum class AnalyticsDestinations {
FIREBASE,
WHATEVER_YOU_WANT_REALLY
WHATEVER_YOU_WANT_REALLY,
}
Kotlin
}
Expand Down
Loading