Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Fine-tune Analytics Events #292

Merged
merged 2 commits into from
Apr 24, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,7 @@ abstract class BaseDownloadViewModel(
logEvent(
CoreAnalyticsEvent.VIDEO_BULK_DOWNLOAD_TOGGLE,
buildMap {
put(
CoreAnalyticsKey.ACTION.key,
if (toggle) CoreAnalyticsKey.TRUE.key else CoreAnalyticsKey.FALSE.key
)
put(CoreAnalyticsKey.ACTION.key, toggle)
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ enum class CoreAnalyticsKey(val key: String) {
OLD_VALUE("old_value"),
COURSE_ID("course_id"),
BLOCK_ID("block_id"),
TRUE("true"),
FALSE("false"),
NUMBER_OF_VIDEOS("number_of_videos"),
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ enum class AppReviewAnalyticsKey(val key: String) {
NAME("name"),
CATEGORY("category"),
RATING("rating"),
APP_REVIEW("app_review"),
APP_REVIEWS("app_reviews"),
ACTION("action"),
DISMISSED("dismissed"),
NOT_NOW("not_now"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ open class BaseAppReviewDialogFragment : DialogFragment() {
event = AppReviewAnalyticsEvent.RATING_DIALOG.eventName,
params = buildMap {
put(AppReviewAnalyticsKey.NAME.key, AppReviewAnalyticsEvent.RATING_DIALOG.biValue)
put(AppReviewAnalyticsKey.CATEGORY.key, AppReviewAnalyticsKey.APP_REVIEW.key)
put(AppReviewAnalyticsKey.CATEGORY.key, AppReviewAnalyticsKey.APP_REVIEWS.key)
}
)
}
Expand Down Expand Up @@ -65,7 +65,7 @@ open class BaseAppReviewDialogFragment : DialogFragment() {
AppReviewAnalyticsKey.NAME.key,
AppReviewAnalyticsEvent.RATING_DIALOG_ACTION.biValue
)
put(AppReviewAnalyticsKey.CATEGORY.key, AppReviewAnalyticsKey.APP_REVIEW.key)
put(AppReviewAnalyticsKey.CATEGORY.key, AppReviewAnalyticsKey.APP_REVIEWS.key)
put(AppReviewAnalyticsKey.ACTION.key, action)
rating.nonZero()?.let { put(AppReviewAnalyticsKey.RATING.key, it) }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ enum class CourseAnalyticsEvent(val eventName: String, val biValue: String) {
"PLS:Shift Button Clicked",
"edx.bi.app.dates.pls_banner.shift_dates.clicked"
),
PLS_SHIFT_DATES(
"PLS:Shift Dates",
"edx.bi.app.dates.pls_banner.shift_dates"
PLS_SHIFT_DATES_SUCCESS(
"PLS:Shift Dates Success",
"edx.bi.app.dates.pls_banner.shift_dates.success"
),
DATES_CALENDAR_SYNC_TOGGLE(
"Dates:CalendarSync Toggle",
"Dates:CalendarSync Toggle Clicked",
"edx.bi.app.dates.calendar_sync.toggle"
),
DATES_CALENDAR_SYNC_DIALOG_ACTION(
Expand All @@ -154,7 +154,7 @@ enum class CourseAnalyticsKey(val key: String) {
OPEN_IN_BROWSER("open_in_browser_url"),
COMPONENT("component"),
VIDEO_PLAYER("video_player"),
ENROLLMENT_MODE("mode"),
ENROLLMENT_MODE("enrollment_mode"),
PACING("pacing"),
SCREEN_NAME("screen_name"),
BANNER_TYPE("banner_type"),
Expand All @@ -177,20 +177,22 @@ enum class CourseAnalyticsKey(val key: String) {
ACTION("action"),
ON("on"),
OFF("off"),
SNACKBAR("snackbar"),
SNACKBAR_TYPE("snackbar_type"),
COURSE_DATES("course_dates"),
SELF_PACED("self"),
INSTRUCTOR_PACED("instructor"),
}

enum class CalendarSyncDialog(
val dialog: String,
private val positiveAction: String,
private val negativeAction: String,
) {
PERMISSION("permission", "allow", "donot_allow"),
ADD("add", "ok", "cancel"),
REMOVE("remove", "ok", "cancel"),
UPDATE("update", "update", "remove"),
CONFIRMED("confirmed", "view_event", "done");
PERMISSION("device_permission", "allow", "donot_allow"),
ADD("add_calendar", "add", "cancel"),
REMOVE("remove_calendar", "remove", "cancel"),
UPDATE("update_calendar", "update", "remove"),
CONFIRMED("events_added", "view_event", "done");

fun getBuildMap(action: Boolean): Map<String, Any> {
return buildMap {
Expand All @@ -201,13 +203,13 @@ enum class CalendarSyncDialog(
}

enum class CalendarSyncSnackbar(private val snackbar: String) {
ADD("add"),
REMOVE("remove"),
UPDATE("update");
ADDED("added"),
REMOVED("removed"),
UPDATED("updated");

fun getBuildMap(): Map<String, Any> {
return buildMap {
put(CourseAnalyticsKey.SNACKBAR.key, snackbar)
put(CourseAnalyticsKey.SNACKBAR_TYPE.key, snackbar)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,10 @@ class CourseContainerViewModel(
updateCalendarSyncState()

if (updatedEvent) {
logCalendarSyncSnackbar(CalendarSyncSnackbar.UPDATE)
logCalendarSyncSnackbar(CalendarSyncSnackbar.UPDATED)
setUiMessage(R.string.course_snackbar_course_calendar_updated)
} else if (coursePreferences.isCalendarSyncEventsDialogShown(courseName)) {
logCalendarSyncSnackbar(CalendarSyncSnackbar.ADD)
logCalendarSyncSnackbar(CalendarSyncSnackbar.ADDED)
setUiMessage(R.string.course_snackbar_course_calendar_added)
} else {
coursePreferences.setCalendarSyncEventsDialogShown(courseName)
Expand Down Expand Up @@ -265,7 +265,7 @@ class CourseContainerViewModel(
updateCalendarSyncState()

}
logCalendarSyncSnackbar(CalendarSyncSnackbar.REMOVE)
logCalendarSyncSnackbar(CalendarSyncSnackbar.REMOVED)
setUiMessage(R.string.course_snackbar_course_calendar_removed)
}
}
Expand Down Expand Up @@ -379,7 +379,11 @@ class CourseContainerViewModel(
put(CourseAnalyticsKey.NAME.key, event.biValue)
put(CourseAnalyticsKey.COURSE_ID.key, courseId)
put(CourseAnalyticsKey.ENROLLMENT_MODE.key, enrollmentMode)
put(CourseAnalyticsKey.PACING.key, isSelfPaced)
put(
CourseAnalyticsKey.PACING.key,
if (isSelfPaced) CourseAnalyticsKey.SELF_PACED.key
else CourseAnalyticsKey.INSTRUCTOR_PACED.key
)
putAll(param)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ class CourseDatesViewModel(
}

fun logPlsShiftDates(isSuccess: Boolean) {
logPLSBannerEvent(CourseAnalyticsEvent.PLS_SHIFT_DATES, isSuccess)
logPLSBannerEvent(CourseAnalyticsEvent.PLS_SHIFT_DATES_SUCCESS, isSuccess)
}

fun logCourseComponentTapped(isSupported: Boolean, block: CourseDateBlock) {
Expand Down Expand Up @@ -261,7 +261,11 @@ class CourseDatesViewModel(
put(CourseAnalyticsKey.NAME.key, event.biValue)
put(CourseAnalyticsKey.COURSE_ID.key, courseId)
put(CourseAnalyticsKey.ENROLLMENT_MODE.key, enrollmentMode)
put(CourseAnalyticsKey.PACING.key, isSelfPaced)
put(
CourseAnalyticsKey.PACING.key,
if (isSelfPaced) CourseAnalyticsKey.SELF_PACED.key
else CourseAnalyticsKey.INSTRUCTOR_PACED.key
)
putAll(param)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ enum class ProfileAnalyticsEvent(val eventName: String, val biValue: String) {
"edx.bi.app.profile.delete_account.clicked"
),
USER_DELETE_ACCOUNT_CLICKED(
"Profile:User Delete Account Success",
"Profile:User Delete Account Clicked",
"edx.bi.app.profile.user.delete_account.clicked"
),
DELETE_ACCOUNT_SUCCESS(
Expand Down Expand Up @@ -80,6 +80,5 @@ enum class ProfileAnalyticsKey(val key: String) {
LIMITED_PROFILE("limited_profile"),
SUCCESS("success"),
FORCE("force"),
TRUE("true"),
FALSE("false"),
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ class VideoSettingsViewModel(
logProfileEvent(
ProfileAnalyticsEvent.WIFI_TOGGLE,
buildMap {
put(
ProfileAnalyticsKey.ACTION.key,
if (value) ProfileAnalyticsKey.TRUE.key else ProfileAnalyticsKey.FALSE.key
)
put(ProfileAnalyticsKey.ACTION.key, value)
}
)
}
Expand Down
Loading