Skip to content

Commit

Permalink
Mobileapps 1294 (#135)
Browse files Browse the repository at this point in the history
* changed analytics name as per client feedback

* updated analytics name
  • Loading branch information
aman-alfresco authored Jul 15, 2022
1 parent b61a598 commit 1fb8ed2
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class BrowseFragment : ListFragment<BrowseViewModel, BrowseViewState>() {
if (entry.isTrashed) return

if (entry.isFolder)
AnalyticsManager().screenViewEvent(PageView.FolderName, folderName = "PageView_${entry.name}")
AnalyticsManager().screenViewEvent(PageView.PersonalFiles)

if (entry.isUpload)
entry.mimeType?.let {
Expand Down
33 changes: 15 additions & 18 deletions data/src/main/kotlin/com/alfresco/content/data/AnalyticsManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class AnalyticsManager(val session: Session = SessionManager.requireSession) {
params.putString(Parameters.FileMimeType.value, fileMimeType)
params.putString(Parameters.FileExtension.value, fileExtension)
params.putBoolean(Parameters.Success.value, success)
params.putString(Parameters.EventName.value, EventName.FilePreview.value)
repository.logEvent(EventType.ActionEvent, params)
params.putString(Parameters.EventName.value, EventName.FilePreview.value.lowercase())
repository.logEvent(EventName.FilePreview.value.lowercase(), params)
}

/**
Expand All @@ -29,8 +29,8 @@ class AnalyticsManager(val session: Session = SessionManager.requireSession) {
val params = repository.defaultParams()
params.putString(Parameters.FileMimeType.value, fileMimeType)
params.putString(Parameters.FileExtension.value, fileExtension)
params.putString(Parameters.EventName.value, eventName.value)
repository.logEvent(EventType.ActionEvent, params)
params.putString(Parameters.EventName.value, eventName.value.lowercase())
repository.logEvent(eventName.value.lowercase(), params)
}

/**
Expand All @@ -39,17 +39,17 @@ class AnalyticsManager(val session: Session = SessionManager.requireSession) {
fun theme(name: String) {
val params = repository.defaultParams()
params.putString(Parameters.ThemeName.value, name)
params.putString(Parameters.EventName.value, EventName.ChangeTheme.value)
repository.logEvent(EventType.ActionEvent, params)
params.putString(Parameters.EventName.value, EventName.ChangeTheme.value.lowercase())
repository.logEvent(EventName.ChangeTheme.value.lowercase(), params)
}

/**
* analytics for app launch
*/
fun appLaunch() {
val params = repository.defaultParams()
params.putString(Parameters.EventName.value, EventName.AppLaunched.value)
repository.logEvent(EventType.ActionEvent, params)
params.putString(Parameters.EventName.value, EventName.AppLaunched.value.lowercase())
repository.logEvent(EventName.AppLaunched.value.lowercase(), params)
}

/**
Expand All @@ -58,35 +58,32 @@ class AnalyticsManager(val session: Session = SessionManager.requireSession) {
fun searchFacets(name: String) {
val params = repository.defaultParams()
params.putString(Parameters.FacetName.value, name)
params.putString(Parameters.EventName.value, EventName.SearchFacets.value)
repository.logEvent(EventType.ActionEvent, params)
params.putString(Parameters.EventName.value, EventName.SearchFacets.value.lowercase())
repository.logEvent(EventName.SearchFacets.value.lowercase(), params)
}

/**
* analytics for multiple screen view
*/
fun screenViewEvent(pageViewName: PageView, noOfFiles: Int = -1, folderName: String = "") {
fun screenViewEvent(pageViewName: PageView, noOfFiles: Int = -1) {
val params = repository.defaultParams()

if (noOfFiles > -1)
params.putInt(Parameters.NumberOfFiles.value, noOfFiles)

if (pageViewName == PageView.FolderName)
params.putString(Parameters.EventName.value, folderName)
else
params.putString(Parameters.EventName.value, pageViewName.value)
repository.logEvent(EventType.ScreenView, params)
params.putString(Parameters.EventName.value, pageViewName.value.lowercase())
repository.logEvent(pageViewName.value.lowercase(), params)
}

/**
* analytics for API tracker
*/
fun apiTracker(apiName: APIEvent, status: Boolean = false, size: String = "") {
val params = repository.defaultParams()
params.putString(Parameters.EventName.value, apiName.value)
params.putString(Parameters.EventName.value, apiName.value.lowercase())
params.putBoolean(Parameters.Success.value, status)
if (size.isNotEmpty())
params.putString(Parameters.FileSize.value, size)
repository.logEvent(EventType.ApiTracker, params)
repository.logEvent(apiName.value.lowercase(), params)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ class AnalyticsRepository(val session: Session) {
}

private fun deviceOS() = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
"Android: ${Build.VERSION.RELEASE_OR_CODENAME}"
"android: ${Build.VERSION.RELEASE_OR_CODENAME}"
} else {
"Android: ${Build.VERSION.RELEASE}"
"android: ${Build.VERSION.RELEASE}"
}

private fun deviceNetwork(): String {
Expand All @@ -44,9 +44,9 @@ class AnalyticsRepository(val session: Session) {
val actNw = cm.getNetworkCapabilities(nw) ?: return NetworkStatus.NOT_CONNECTED.name

return when {
actNw.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> NetworkStatus.WIFI.name
actNw.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> NetworkStatus.CELLULAR.name
else -> NetworkStatus.NOT_CONNECTED.name
actNw.hasTransport(NetworkCapabilities.TRANSPORT_WIFI) -> NetworkStatus.WIFI.name.lowercase()
actNw.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) -> NetworkStatus.CELLULAR.name.lowercase()
else -> NetworkStatus.NOT_CONNECTED.name.lowercase()
}
}

Expand All @@ -73,73 +73,62 @@ class AnalyticsRepository(val session: Session) {
/**
* It will get triggered to log analytics on firebase console
*/
fun logEvent(type: EventType, params: Bundle) {

firebaseAnalytics.logEvent(type.value, params)
fun logEvent(type: String, params: Bundle) {
firebaseAnalytics.logEvent(type, params)
}
}

/**
* Marked as EventName enum
*/
enum class EventName(val value: String) {
FilePreview("Event_filePreview"),
Download("Event_download"),
AddFavorite("Event_Add to Favorites"),
RemoveFavorite("Event_Remove from Favorite"),
RenameNode("Event_Rename"),
MoveToFolder("Event_Move"),
MarkOffline("Event_Make available offline"),
RemoveOffline("Event_Remove offline"),
MoveTrash("Event_Move to Trash"),
ChangeTheme("Event_changeTheme"),
CreateFolder("Event_New folder"),
UploadMedia("Event_Upload photos or videos"),
CreateMedia("Event_Take a photo or video"),
UploadFiles("Event_Upload files"),
AppLaunched("Event_appLaunched"),
SearchFacets("Event_searchFacets"),
PermanentlyDelete("Event_Permanently Delete"),
Restore("Event_Restore"),
OpenWith("Event_Open with")
FilePreview("event_file_preview"),
Download("event_download"),
AddFavorite("event_add_to_favorites"),
RemoveFavorite("event_remove_from_favorite"),
RenameNode("event_rename"),
MoveToFolder("event_move"),
MarkOffline("event_Make_available_offline"),
RemoveOffline("event_remove_offline"),
MoveTrash("event_move_to_trash"),
ChangeTheme("event_change_theme"),
CreateFolder("event_new_folder"),
UploadMedia("event_upload_photos_or_videos"),
CreateMedia("event_take_a_photo_or_video"),
UploadFiles("event_upload_files"),
AppLaunched("event_app_launched"),
SearchFacets("event_search_facets"),
PermanentlyDelete("event_permanently_delete"),
Restore("event_restore"),
OpenWith("event_open_with")
}

/**
* Marked as PageView enum
*/
enum class PageView(val value: String) {
Recent("PageView_Recent"),
Favorites("PageView_Favorites"),
Recent("page_view_recent"),
Favorites("page_view_favorites"),
Tasks("page_view_tasks"),
Offline("PageView_Offline"),
Browse("PageView_Browse"),
PersonalFiles("PageView_Personal files"),
FolderName("PageView_FolderName"),
MyLibraries("PageView_My libraries"),
Shared("PageView_Shared"),
Trash("PageView_Trash"),
Search("PageView_Search"),
ShareExtension("PageView_ShareExtension"),
Transfers("PageView_Transfers"),
Offline("page_view_offline"),
Browse("page_view_browse"),
PersonalFiles("page_view_personal_files"),
MyLibraries("page_view_my_libraries"),
Shared("page_view_shared"),
Trash("page_view_trash"),
Search("page_view_search"),
ShareExtension("page_view_share_extension"),
Transfers("page_view_transfers"),
None("none")
}

/**
* Marked as APIEvent enum
*/
enum class APIEvent(val value: String) {
NewFolder("Event_API_NewFolder"),
UploadFiles("Event_API_UploadFiles"),
Login("Event_API_Login")
}

/**
* Marked as EventType enum
*/
enum class EventType(val value: String) {
ScreenView("screen_views"),
ActionEvent("action_event"),
ApiTracker("api_tracker")
NewFolder("event_api_new_folder"),
UploadFiles("event_api_upload_files"),
Login("event_api_login")
}

/**
Expand Down Expand Up @@ -171,11 +160,8 @@ enum class Parameters(val value: String) {
FileMimeType("file_mimetype"),
FileExtension("file_extension"),
FileSize("file_size"),
FolderName("folder_name"),
ThemeName("theme_name"),
NumberOfFiles("number_of_files"),
FacetName("facet_name"),
NumberOfAssets("number_of_assets"),
IsFile("is_file"),
Success("success")
}

0 comments on commit 1fb8ed2

Please sign in to comment.