From a5a667c812da66cfbbeb9be602880981edb41b61 Mon Sep 17 00:00:00 2001 From: PiplaniVinay <92846583+PiplaniVinay@users.noreply.github.com> Date: Fri, 24 May 2024 08:14:48 +0530 Subject: [PATCH] ADST-476 (#672) * ADST-476 * Analytics * Solved Crash --- .../Analytics /AnalyticsConstants.swift | 7 ++++++- .../AnalyticsManager+APITracker.swift | 5 ++++- .../Localization/de.lproj/Localizable.strings | 2 +- .../Localization/es.lproj/Localizable.strings | 2 +- .../Localization/fr.lproj/Localizable.strings | 2 +- .../Localization/it.lproj/Localizable.strings | 2 +- .../Localization/nl.lproj/Localizable.strings | 2 +- .../ListComponent/ListComponent+Actions.swift | 6 +++++- .../ComplexFormViewController.swift | 21 +++++++++++++------ .../StartWorkflowViewController.swift | 2 +- .../SingleLineTextTableCellViewModel.swift | 2 +- 11 files changed, 37 insertions(+), 16 deletions(-) diff --git a/ContentApp/BusinessLayer/Analytics /AnalyticsConstants.swift b/ContentApp/BusinessLayer/Analytics /AnalyticsConstants.swift index fdd3447af..5939b73bd 100644 --- a/ContentApp/BusinessLayer/Analytics /AnalyticsConstants.swift +++ b/ContentApp/BusinessLayer/Analytics /AnalyticsConstants.swift @@ -73,6 +73,8 @@ enum Event { case apiAssignUser = "event_api_assign_user" case apiSearchUser = "event_api_search_user" case apiUploadWorkflowAttachment = "event_api_upload_workflow_attachment" + case apiStartWorkflow = "event_api_start_workflow" + case apiEventOutcomes = "event_api_outcomes" } enum Page: String { @@ -92,10 +94,12 @@ enum Event { case taskCommentsScreen = "page_view_task_comments" case taskAttachmentsScreen = "page_view_attached_files" case workflowTab = "page_view_workflows" - case startWorkflowScreen = "page_view_start_workflow" + case taskFormScreen = "page_view_task_form" case workflowAttachmentsScreen = "page_view_workflow_attached_files" case workflowTaskDetailScreen = "page_view_workflow_task_view" case workflowTaskStatusScreen = "page_view_workflow_task_status" + case workflowView = "page_view_workflow_view" + case startFormScreen = "page_view_start_form" } } @@ -120,5 +124,6 @@ struct AnalyticsConstants { static let facet = "facet_name" static let assetsCount = "numberOfAssets" static let fileSize = "file_size" + static let actionOutcome = "action_outcome" } } diff --git a/ContentApp/BusinessLayer/Analytics /AnalyticsManager+APITracker.swift b/ContentApp/BusinessLayer/Analytics /AnalyticsManager+APITracker.swift index 526ac5db7..988828677 100644 --- a/ContentApp/BusinessLayer/Analytics /AnalyticsManager+APITracker.swift +++ b/ContentApp/BusinessLayer/Analytics /AnalyticsManager+APITracker.swift @@ -21,7 +21,7 @@ import UIKit // MARK: - API Tracker Events extension AnalyticsManager { - func apiTracker(name: String?, fileSize: Double, success: Bool) { + func apiTracker(name: String?, fileSize: Double = 0, success: Bool, outcome: String = "") { if let name = name { let eventName = name + (success ? "_success" : "_fail") var parameters = self.commonParameters() @@ -29,6 +29,9 @@ extension AnalyticsManager { let size = "\(fileSize) MB" parameters[AnalyticsConstants.Parameters.fileSize] = size } + if !outcome.isEmpty { + parameters[AnalyticsConstants.Parameters.actionOutcome] = outcome + } parameters[AnalyticsConstants.Parameters.previewSuccess] = success parameters[AnalyticsConstants.Parameters.eventName] = eventName self.logEvent(name: eventName, parameters: parameters) diff --git a/ContentApp/BusinessLayer/Localization/de.lproj/Localizable.strings b/ContentApp/BusinessLayer/Localization/de.lproj/Localizable.strings index 7aa69cc40..29d504316 100755 --- a/ContentApp/BusinessLayer/Localization/de.lproj/Localizable.strings +++ b/ContentApp/BusinessLayer/Localization/de.lproj/Localizable.strings @@ -464,4 +464,4 @@ "dialog-multi-delete-message" = "%d Elemente werden permanent gelöscht."; "multiple-selected-items-count" = "%d Ausgewählt"; "check-box-multi-select" = "Kontrollkästchen"; -"maximum-items-selection-message" = "Es können maximal %d Elemente ausgewählt werden"; +"maximum-items-selection-message" = "Wählen Sie maximal %d Elemente"; diff --git a/ContentApp/BusinessLayer/Localization/es.lproj/Localizable.strings b/ContentApp/BusinessLayer/Localization/es.lproj/Localizable.strings index f76ad6849..0e521a3e7 100755 --- a/ContentApp/BusinessLayer/Localization/es.lproj/Localizable.strings +++ b/ContentApp/BusinessLayer/Localization/es.lproj/Localizable.strings @@ -464,4 +464,4 @@ "dialog-multi-delete-message" = "%d elementos serán eliminados permanentemente."; "multiple-selected-items-count" = "%d Seleccionado"; "check-box-multi-select" = "Casilla de verificación"; -"maximum-items-selection-message" = "Solo se puede seleccionar un máximo de %d elementos"; +"maximum-items-selection-message" = "Seleccione un máximo de %d elementos"; diff --git a/ContentApp/BusinessLayer/Localization/fr.lproj/Localizable.strings b/ContentApp/BusinessLayer/Localization/fr.lproj/Localizable.strings index da6c6e922..e5bef8494 100755 --- a/ContentApp/BusinessLayer/Localization/fr.lproj/Localizable.strings +++ b/ContentApp/BusinessLayer/Localization/fr.lproj/Localizable.strings @@ -464,4 +464,4 @@ "dialog-multi-delete-message" = "%d éléments seront définitivement supprimés."; "multiple-selected-items-count" = "%d Sélectionné"; "check-box-multi-select" = "Case à cocher"; -"maximum-items-selection-message" = "%d éléments maximum peuvent être sélectionnés"; +"maximum-items-selection-message" = "Sélectionner un maximum de %d éléments"; diff --git a/ContentApp/BusinessLayer/Localization/it.lproj/Localizable.strings b/ContentApp/BusinessLayer/Localization/it.lproj/Localizable.strings index ae8834336..9476783c4 100755 --- a/ContentApp/BusinessLayer/Localization/it.lproj/Localizable.strings +++ b/ContentApp/BusinessLayer/Localization/it.lproj/Localizable.strings @@ -464,4 +464,4 @@ "dialog-multi-delete-message" = "%d elementi verranno eliminati definitivamente."; "multiple-selected-items-count" = "%d Selezionato"; "check-box-multi-select" = "Casella di controllo"; -"maximum-items-selection-message" = "Possono essere selezionati massimo %d elementi"; +"maximum-items-selection-message" = "Selezionare un massimo di %d elementi"; diff --git a/ContentApp/BusinessLayer/Localization/nl.lproj/Localizable.strings b/ContentApp/BusinessLayer/Localization/nl.lproj/Localizable.strings index e4c786eda..dd4917a1c 100755 --- a/ContentApp/BusinessLayer/Localization/nl.lproj/Localizable.strings +++ b/ContentApp/BusinessLayer/Localization/nl.lproj/Localizable.strings @@ -464,4 +464,4 @@ "dialog-multi-delete-message" = "%d items worden permanent verwijderd."; "multiple-selected-items-count" = "%d Geselecteerd"; "check-box-multi-select" = "Selectievakje"; -"maximum-items-selection-message" = "Er kunnen maximaal %d items worden geselecteerd"; +"maximum-items-selection-message" = "Selecteer een maximum van %d items"; diff --git a/ContentApp/PresentationLayer/Components/ListComponent/ListComponent+Actions.swift b/ContentApp/PresentationLayer/Components/ListComponent/ListComponent+Actions.swift index 9a8e2ba83..872868315 100644 --- a/ContentApp/PresentationLayer/Components/ListComponent/ListComponent+Actions.swift +++ b/ContentApp/PresentationLayer/Components/ListComponent/ListComponent+Actions.swift @@ -125,12 +125,16 @@ extension ListComponentViewController: NodeActionsViewModelDelegate, snackBarMessage = String(format: LocalizationConstants.Approved.movedFileFolderSuccess, node.truncateTailTitle()) } - self.perform(#selector(triggerMoveNotifyService), with: nil, afterDelay: 1.0) + self.perform(#selector(triggerMove), with: nil, afterDelay: 1.0) default: break } displaySnackbar(with: snackBarMessage, type: .approve) } + @objc func triggerMove() { + self.triggerMoveNotifyService(folderId: "", folderName: "") + } + @objc func triggerMoveNotifyService(folderId: String, folderName: String) { let notificationName = Notification.Name(rawValue: KeyConstants.Notification.moveFileFolderFinished) let notification = Notification(name: notificationName, object: nil, userInfo: ["id": folderId, "name": folderName]) diff --git a/ContentApp/PresentationLayer/Tasks/Task List/Controller/Complex Forms/ComplexFormViewController.swift b/ContentApp/PresentationLayer/Tasks/Task List/Controller/Complex Forms/ComplexFormViewController.swift index 24d19f50e..9d6cdef9b 100644 --- a/ContentApp/PresentationLayer/Tasks/Task List/Controller/Complex Forms/ComplexFormViewController.swift +++ b/ContentApp/PresentationLayer/Tasks/Task List/Controller/Complex Forms/ComplexFormViewController.swift @@ -46,7 +46,7 @@ class ComplexFormViewController: SystemSearchViewController { private var saveId = 1045 private var completeId = 1046 private var releaseId = 1047 - private var completeString = "Complete" + private let completeString = "Complete" var multilineTVIndexPath: IndexPath? // MARK: - View did load @@ -69,10 +69,11 @@ class ComplexFormViewController: SystemSearchViewController { setupBindings() applyLocalization() getWorkflowDetails() - AnalyticsManager.shared.pageViewEvent(for: Event.Page.startWorkflowScreen) if viewModel.isDetailWorkflow { + AnalyticsManager.shared.pageViewEvent(for: Event.Page.taskFormScreen) infoButton() } else { + AnalyticsManager.shared.pageViewEvent(for: Event.Page.startFormScreen) ProfileService.getAPSSource() // to get APS Source } @@ -167,7 +168,7 @@ class ComplexFormViewController: SystemSearchViewController { if name == LocalizationConstants.General.save && id == saveId { saveWorkflowAction() } else if id == releaseId { - claimAndReleasewrkFlowAction(isClaim: false) + claimAndReleasewrkFlowAction(isClaim: false, name: name) } else { taskFormWorkflowAction(outcome: name) } @@ -177,9 +178,11 @@ class ComplexFormViewController: SystemSearchViewController { self.complexFormViewModel.startWorkflowProcess(for: self.viewModel.formFields, name: name, processDefinitionId: processDefinitionId, completionHandler: { [weak self] isError in guard let sSelf = self else { return } if !isError { + AnalyticsManager.shared.apiTracker(name: Event.API.apiStartWorkflow.rawValue, success: true) sSelf.updateWorkflowsList() sSelf.backButtonAction() } else { + AnalyticsManager.shared.apiTracker(name: Event.API.apiStartWorkflow.rawValue, success: false) sSelf.displaySnackbar(with: LocalizationConstants.Errors.errorGeneric, type: .error) } }) @@ -192,7 +195,9 @@ class ComplexFormViewController: SystemSearchViewController { if !isError { sSelf.updateTaskList() sSelf.backButtonAction() + AnalyticsManager.shared.apiTracker(name: Event.API.apiEventOutcomes.rawValue, success: true, outcome: outcome) } else { + AnalyticsManager.shared.apiTracker(name: Event.API.apiEventOutcomes.rawValue, success: false, outcome: outcome) sSelf.displaySnackbar(with: LocalizationConstants.Errors.errorGeneric, type: .error) } }) @@ -205,20 +210,24 @@ class ComplexFormViewController: SystemSearchViewController { if !isError { sSelf.updateTaskList() sSelf.backButtonAction() + AnalyticsManager.shared.apiTracker(name: Event.API.apiEventOutcomes.rawValue, success: true, outcome: LocalizationConstants.General.save) } else { + AnalyticsManager.shared.apiTracker(name: Event.API.apiEventOutcomes.rawValue, success: false, outcome: LocalizationConstants.General.save) sSelf.displaySnackbar(with: LocalizationConstants.Errors.errorGeneric, type: .error) } }) } - private func claimAndReleasewrkFlowAction(isClaim: Bool) { + private func claimAndReleasewrkFlowAction(isClaim: Bool, name: String) { let taskId = self.viewModel.taskId self.viewModel.claimOrUnclaimTask(taskId: taskId, isClaimTask: isClaim) {[weak self] error in guard let sSelf = self else { return } if error == nil { + AnalyticsManager.shared.apiTracker(name: Event.API.apiEventOutcomes.rawValue, success: true, outcome: name) sSelf.updateTaskList() sSelf.backButtonAction() } else { + AnalyticsManager.shared.apiTracker(name: Event.API.apiEventOutcomes.rawValue, success: false, outcome: name) sSelf.displaySnackbar(with: LocalizationConstants.Errors.errorGeneric, type: .error) } } @@ -460,7 +469,7 @@ class ComplexFormViewController: SystemSearchViewController { // MARK: - Save Button Action @IBAction func saveButtonAction(_ sender: UIButton) { if viewModel.isClaimProcess { - claimAndReleasewrkFlowAction(isClaim: true) + claimAndReleasewrkFlowAction(isClaim: true, name: LocalizationConstants.Workflows.claimTitle) } else { self.startWorkflowAPIIntegration(name: sender.titleLabel?.text ?? "", id: saveId) } @@ -1004,7 +1013,7 @@ extension ComplexFormViewController { } } } else { - let errorString = String(format: "%@ %@", localViewModel.name ?? "", LocalizationConstants.Workflows.hasInvalidUrl) + let errorString = String(format: LocalizationConstants.Workflows.hasInvalidUrl, localViewModel.name ?? "") displaySnackbar(with: errorString, type: .error) } } diff --git a/ContentApp/PresentationLayer/Tasks/Task List/Controller/Start Workflow/StartWorkflowViewController.swift b/ContentApp/PresentationLayer/Tasks/Task List/Controller/Start Workflow/StartWorkflowViewController.swift index 998620563..8a6c2aee8 100644 --- a/ContentApp/PresentationLayer/Tasks/Task List/Controller/Start Workflow/StartWorkflowViewController.swift +++ b/ContentApp/PresentationLayer/Tasks/Task List/Controller/Start Workflow/StartWorkflowViewController.swift @@ -51,7 +51,7 @@ class StartWorkflowViewController: SystemSearchViewController { setupBindings() getWorkflowDetails() linkContent() - AnalyticsManager.shared.pageViewEvent(for: Event.Page.startWorkflowScreen) + AnalyticsManager.shared.pageViewEvent(for: Event.Page.workflowView) self.dialogTransitionController = MDCDialogTransitionController() controller.registerEvents() if !viewModel.isDetailWorkflow { diff --git a/ContentApp/PresentationLayer/Tasks/Views/Table Cells/Complex Forms/Single Line Text/SingleLineTextTableCellViewModel.swift b/ContentApp/PresentationLayer/Tasks/Views/Table Cells/Complex Forms/Single Line Text/SingleLineTextTableCellViewModel.swift index 7969a808e..76aef126f 100644 --- a/ContentApp/PresentationLayer/Tasks/Views/Table Cells/Complex Forms/Single Line Text/SingleLineTextTableCellViewModel.swift +++ b/ContentApp/PresentationLayer/Tasks/Views/Table Cells/Complex Forms/Single Line Text/SingleLineTextTableCellViewModel.swift @@ -217,7 +217,7 @@ class SingleLineTextTableCellViewModel: RowViewModel { } } - if enableFractions && !text.isEmpty && errorMessage == nil { + if enableFractions && !text.isEmpty { let textArray = text.components(separatedBy: ".") let count = textArray.count - 1 if count > 1 {