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

feat: Add Analytics events #258

Merged
merged 14 commits into from
Mar 27, 2024
Merged

Conversation

omerhabib26
Copy link
Contributor

@omerhabib26 omerhabib26 commented Mar 12, 2024

Description

  • Add analytics for the following modules
  • AppReview, Profile, WhatsNew, Course, Discussion, Logistration, MainDashboard, Discovery, Core
  • Restructure the analytics implementation to module level
  • Update the event names accordingly
  • Update the test cases accordingly

fix: LEARNER-9876

@omerhabib26 omerhabib26 changed the title feat: Add Analytics events [WIP]feat: Add Analytics events Mar 13, 2024
@omerhabib26 omerhabib26 changed the title [WIP]feat: Add Analytics events feat: Add Analytics events Mar 15, 2024
Copy link
Contributor

@k1rill k1rill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the very accurate job! Just minor nits

k1rill
k1rill previously approved these changes Mar 18, 2024
Copy link
Contributor

@k1rill k1rill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@HamzaIsrar12 HamzaIsrar12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some things to look into:

  • Discovery Events are implemented for Native experience only.
  • CalendarSynnc Action Events is triggering for all cases.
  • Please follow a similar convention in Analytics Screen & Keys enum names.

app/src/main/java/org/openedx/app/AnalyticsManager.kt Outdated Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The currentVideoTime is always returning 0 in evens.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can create a bug ticket to tackle currentVideoTime as according to current implementation it is hard to trace why its not working

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay but Please create and attach the bug ticket here. 👍🏻

Copy link
Contributor

@HamzaIsrar12 HamzaIsrar12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Discovery Events are implemented for Native experience only.
  • WhatsNew:Close event is not implemented

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay but Please create and attach the bug ticket here. 👍🏻

app/src/main/java/org/openedx/app/MainFragment.kt Outdated Show resolved Hide resolved
- Add analytics for following modules
- AppReview, Profile, WhatsNew, Course, Discussion, Logistration, MainDashboard, Discovery
- Restructure the analytics implementation to module level
- Update the event names accordingly

fix: LEARNER-9876
fix: LEARNER-9876
fix: LEARNER-9876
fix: LEARNER-9876
Copy link
Contributor

@HamzaIsrar12 HamzaIsrar12 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, Moin, great work !! 🏎️

@omerhabib26 omerhabib26 merged commit 2da3666 into openedx:develop Mar 27, 2024
3 checks passed
@omerhabib26 omerhabib26 deleted the omer/LEARNER-9876 branch March 27, 2024 18:45
Comment on lines 3 to 5
fun userLoginEvent(method: String)
fun signUpClickedEvent()
fun createAccountClickedEvent(provider: String)
fun registrationSuccessEvent(provider: String)
fun forgotPasswordClickedEvent()
fun resetPasswordClickedEvent(success: Boolean)
fun setUserIdForSession(userId: Long)
} No newline at end of file
fun logEvent(event: String, params: Map<String, Any?>)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of removing these methods?
I see a similar approach in a few other interfaces, but that leads to inconsistency with CourseAnalytics, DashboardAnalytics, DiscoveryAnalytics, DiscussionAnalytics, etc.
We should select one approach and follow it for all modules.
My +1 for keeping methods in interfaces: They help quickly understand what this interface does, same to table of contents in books;
abstract method logEvent cannot provide this information.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of removing these methods?

  • We're moving methods to ViewModels for better organization and maintenance. Each ViewModel handles its own analytics, making future changes easier without affecting other code. This promotes code reuse and reduces the risk of errors.

I see a similar approach in a few other interfaces, but that leads to inconsistency with CourseAnalytics, DashboardAnalytics, DiscoveryAnalytics, DiscussionAnalytics, etc.

  • Some methods may still exist from a previous approach, but lack proper event details. These can be addressed in an improvement ticket, ensuring that any remaining methods are properly handled and documented for clarity and future maintenance.

We should select one approach and follow it for all modules.
My +1 for keeping methods in interfaces: They help quickly understand what this interface does, same to table of contents in books;
abstract method logEvent cannot provide this information.

  • In some cases, we use default logEvent instead custom method which can be improved in a separate ticket for better understanding and readability.

If you have any alternative solutions in mind, we're open to considering them as well.

viewModel.preloadCourseStructure()
advanceUntilIdle()

coVerify(exactly = 1) { interactor.preloadCourseStructure(any()) }
verify(exactly = 1) { analytics.logEvent(any(), any()) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should check specific value, not any

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @volodymyr-chekyrta,
As per the current implementation, we are not verifying the method with a specific value.
i.e, coVerify(exactly = 1) { interactor.preloadCourseStructure(any()) }

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the case of interactor.preloadCourseStructure(any()), it's not important what value is passed as an argument, but in the case of analytics.logEvent, we need to check what event we logged.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have create a new PR for these changes Please have a look

viewModel.preloadCourseStructure()
advanceUntilIdle()

coVerify(exactly = 1) { interactor.preloadCourseStructure(any()) }
verify(exactly = 1) { analytics.logEvent(any(), any()) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should check specific value, not any

advanceUntilIdle()

coVerify(exactly = 1) { interactor.enrollInACourse(any()) }
verify(exactly = 1) { analytics.courseEnrollClickedEvent(any(), any()) }
verify(exactly = 0) { analytics.courseEnrollSuccessEvent(any(), any()) }
verify(exactly = 1) { analytics.logEvent(any(), any()) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should check specific value, not any

viewModel.preloadCourseStructure()
advanceUntilIdle()

coVerify(exactly = 1) { interactor.preloadCourseStructure(any()) }
verify(exactly = 1) { analytics.logEvent(any(), any()) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should check specific value, not any

downloadDao,
workerController
)

viewModel.saveDownloadModels("", "")
advanceUntilIdle()
verify(exactly = 1) { coreAnalytics.logEvent(any(), any()) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should check specific value, not any

@@ -70,6 +76,7 @@ class VideoUnitViewModelTest {
any()
)
}
verify(exactly = 1) { courseAnalytics.logEvent(any(), any()) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should check specific value, not any

@@ -96,6 +105,7 @@ class VideoUnitViewModelTest {
any()
)
}
verify(exactly = 1) { courseAnalytics.logEvent(any(), any()) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should check specific value, not any

@@ -67,18 +72,21 @@ class VideoViewModelTest {
any()
)
}
verify(exactly = 1) { courseAnalytics.logEvent(any(), any()) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should check specific value, not any

@@ -87,6 +95,7 @@ class VideoViewModelTest {
any()
)
}
verify(exactly = 1) { courseAnalytics.logEvent(any(), any()) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should check specific value, not any

@omerhabib26 omerhabib26 restored the omer/LEARNER-9876 branch March 28, 2024 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants