Skip to content

Commit

Permalink
feat: Public share Matomo (#1376)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrien-coye authored Jan 21, 2025
2 parents eb38f35 + ee2f193 commit 50a874a
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,9 @@ extension FileActionsFloatingPanelViewController {
onPresentViewController: { saveNavigationViewController, animated in
self.present(saveNavigationViewController, animated: animated, completion: nil)
},
onSave: {
MatomoUtils.trackAddToMyDrive()
},
onDismissViewController: { [weak self] in
guard let self else { return }
self.dismiss(animated: true)
Expand Down
2 changes: 2 additions & 0 deletions kDrive/UI/Controller/Files/PublicShareAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ struct PublicShareAction {
selectedItemsIds: [Int],
exceptItemIds: [Int],
onPresentViewController: (UIViewController, Bool) -> Void,
onSave: (() -> Void)?,
onDismissViewController: (() -> Void)?
) {
let saveNavigationViewController = SaveFileViewController.instantiateInNavigationController(
driveFileManager: currentUserDriveFileManager,
publicShareProxy: publicShareProxy,
publicShareFileIds: selectedItemsIds,
publicShareExceptIds: exceptItemIds,
onSave: onSave,
onDismissViewController: onDismissViewController
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ extension SaveFileViewController: FooterButtonDelegate {
}

Task {
defer { dismissViewController() }
defer {
onSave?()
dismissViewController()
}

try await savePublicShareToDrive(sourceDriveId: publicShareProxy.driveId,
destinationDriveId: drive.id,
destinationFolderId: directory.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class SaveFileViewController: UIViewController {
}

@MainActor var onDismissViewController: (() -> Void)?
@MainActor var onSave: (() -> Void)?

@IBOutlet var tableView: UITableView!
@IBOutlet var closeBarButtonItem: UIBarButtonItem!
Expand Down Expand Up @@ -353,13 +354,16 @@ class SaveFileViewController: UIViewController {
publicShareProxy: PublicShareProxy,
publicShareFileIds: [Int],
publicShareExceptIds: [Int],
onSave: (() -> Void)?,
onDismissViewController: (() -> Void)?)
-> TitleSizeAdjustingNavigationController {
let saveViewController = instantiate(driveFileManager: driveFileManager)

saveViewController.publicShareFileIds = publicShareFileIds
saveViewController.publicShareExceptIds = publicShareExceptIds
saveViewController.publicShareProxy = publicShareProxy
saveViewController.onSave = onSave
saveViewController.onDismissViewController = onDismissViewController

return wrapInNavigationController(saveViewController)
}
Expand Down
3 changes: 3 additions & 0 deletions kDrive/UI/Controller/Menu/Share/PublicShareViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ final class PublicShareViewModel: InMemoryFileListViewModel {
onPresentViewController: { saveNavigationViewController, animated in
onPresentViewController?(.modal, saveNavigationViewController, animated)
},
onSave: {
MatomoUtils.trackAddBulkToMykDrive()
},
onDismissViewController: { [weak self] in
guard let self else { return }
self.onDismissViewController?()
Expand Down
2 changes: 2 additions & 0 deletions kDrive/UI/View/Upsale/UpsaleViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public class UpsaleViewController: UIViewController {
configureHeader()
setupBody()
layoutStackView()

MatomoUtils.trackUpsalePresented()
}

func configureHeader() {
Expand Down
4 changes: 4 additions & 0 deletions kDriveCore/Utils/MatomoUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,8 @@ public enum MatomoUtils {
public static func trackPublicSharePasswordAction() {
track(eventWithCategory: .publicSharePasswordAction, name: "openInBrowser")
}

public static func trackUpsalePresented() {
track(eventWithCategory: .publicShareAction, name: "adBottomSheet")
}
}

0 comments on commit 50a874a

Please sign in to comment.