Skip to content

Commit

Permalink
ADST-476 (#672)
Browse files Browse the repository at this point in the history
* ADST-476

* Analytics

* Solved Crash
  • Loading branch information
PiplaniVinay authored May 24, 2024
1 parent f0a77e5 commit a5a667c
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 16 deletions.
7 changes: 6 additions & 1 deletion ContentApp/BusinessLayer/Analytics /AnalyticsConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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"
}
}

Expand All @@ -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"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@ 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()
if fileSize > 0 {
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

Expand Down Expand Up @@ -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)
}
Expand All @@ -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)
}
})
Expand All @@ -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)
}
})
Expand All @@ -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)
}
}
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit a5a667c

Please sign in to comment.