diff --git a/browse/src/main/kotlin/com/alfresco/content/browse/BrowseFragment.kt b/browse/src/main/kotlin/com/alfresco/content/browse/BrowseFragment.kt index 902d18777..1bca0eae2 100644 --- a/browse/src/main/kotlin/com/alfresco/content/browse/BrowseFragment.kt +++ b/browse/src/main/kotlin/com/alfresco/content/browse/BrowseFragment.kt @@ -170,7 +170,7 @@ class BrowseFragment : ListFragment() { 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 { diff --git a/data/src/main/kotlin/com/alfresco/content/data/AnalyticsManager.kt b/data/src/main/kotlin/com/alfresco/content/data/AnalyticsManager.kt index 329c5b3bf..decd94479 100644 --- a/data/src/main/kotlin/com/alfresco/content/data/AnalyticsManager.kt +++ b/data/src/main/kotlin/com/alfresco/content/data/AnalyticsManager.kt @@ -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) } /** @@ -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) } /** @@ -39,8 +39,8 @@ 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) } /** @@ -48,8 +48,8 @@ class AnalyticsManager(val session: Session = SessionManager.requireSession) { */ 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) } /** @@ -58,24 +58,21 @@ 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) } /** @@ -83,10 +80,10 @@ class AnalyticsManager(val session: Session = SessionManager.requireSession) { */ 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) } } diff --git a/data/src/main/kotlin/com/alfresco/content/data/AnalyticsRepository.kt b/data/src/main/kotlin/com/alfresco/content/data/AnalyticsRepository.kt index 126b904be..f84e84c85 100644 --- a/data/src/main/kotlin/com/alfresco/content/data/AnalyticsRepository.kt +++ b/data/src/main/kotlin/com/alfresco/content/data/AnalyticsRepository.kt @@ -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 { @@ -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() } } @@ -73,9 +73,8 @@ 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) } } @@ -83,44 +82,43 @@ class AnalyticsRepository(val session: Session) { * 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") } @@ -128,18 +126,9 @@ enum class PageView(val value: String) { * 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") } /** @@ -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") }