Add account deletion logging

This commit is contained in:
Ilya Laktyushin
2022-06-30 18:50:05 +03:00
parent c5a86a666b
commit 31e1f7328b
6 changed files with 84 additions and 16 deletions

View File

@@ -7797,6 +7797,8 @@ Sorry for the inconvenience.";
"DeleteAccount.ConfirmationAlertText" = "Deleting your account will permanently delete your data!\n\nIt is imposible to reverse this action!";
"DeleteAccount.ConfirmationAlertDelete" = "Delete My Account";
"DeleteAccount.Success" = "The account has been successfully deleted.";
"PeerInfo.GiftPremium" = "Gift Premium";
"Premium.Gift.Title" = "Gift Telegram Premium";

View File

@@ -114,7 +114,12 @@ class InviteLinkHeaderItemNode: ListViewItemNode {
return { item, params, neighbors in
let leftInset: CGFloat = 24.0 + params.leftInset
let iconSize = CGSize(width: 140.0, height: 140.0)
let iconSize: CGSize
if params.width > params.availableHeight && params.width > 320.0 {
iconSize = CGSize(width: 140.0, height: 140.0)
} else {
iconSize = CGSize(width: 124.0, height: 124.0)
}
let topInset: CGFloat = iconSize.height - 4.0
let spacing: CGFloat = 5.0

View File

@@ -15,6 +15,7 @@ import UrlHandling
import InviteLinksUI
import CountrySelectionUI
import PhoneInputNode
import UndoUI
private struct DeleteAccountDataArguments {
let context: AccountContext
@@ -289,6 +290,23 @@ func deleteAccountDataController(context: AccountContext, mode: DeleteAccountDat
peers = .single([])
}
let cancelImpl = {
dismissImpl?()
switch mode {
case .peers:
addAppLogEvent(postbox: context.account.postbox, type: "deactivate.step_cloud_cancel")
case .groups:
addAppLogEvent(postbox: context.account.postbox, type: "deactivate.step_groups_cancel")
case .messages:
addAppLogEvent(postbox: context.account.postbox, type: "deactivate.step_messages_cancel")
case .phone:
addAppLogEvent(postbox: context.account.postbox, type: "deactivate.step_phone_cancel")
case .password:
addAppLogEvent(postbox: context.account.postbox, type: "deactivate.step_2fa_cancel")
}
}
let signal = combineLatest(queue: .mainQueue(),
context.sharedContext.presentationData,
peers,
@@ -296,7 +314,7 @@ func deleteAccountDataController(context: AccountContext, mode: DeleteAccountDat
)
|> map { presentationData, peers, state -> (ItemListControllerState, (ItemListNodeState, Any)) in
let leftNavigationButton = ItemListNavigationButton(content: .text(presentationData.strings.Common_Cancel), style: .regular, enabled: true, action: {
dismissImpl?()
cancelImpl()
})
var focusItemTag: DeleteAccountEntryTag?
@@ -319,7 +337,7 @@ func deleteAccountDataController(context: AccountContext, mode: DeleteAccountDat
}
let footerItem = DeleteAccountFooterItem(theme: presentationData.theme, title: buttonTitle, secondaryTitle: presentationData.strings.DeleteAccount_Continue, action: {
dismissImpl?()
cancelImpl()
}, secondaryAction: {
proceedImpl?()
})
@@ -414,7 +432,13 @@ func deleteAccountDataController(context: AccountContext, mode: DeleteAccountDat
let controller = deleteAccountDataController(context: context, mode: nextMode, twoStepAuthData: twoStepAuthData)
replaceTopControllerImpl?(controller)
} else {
addAppLogEvent(postbox: context.account.postbox, type: "deactivate.step_confirmation_show")
presentControllerImpl?(textAlertController(context: context, title: presentationData.strings.DeleteAccount_ConfirmationAlertTitle, text: presentationData.strings.DeleteAccount_ConfirmationAlertText, actions: [TextAlertAction(type: .destructiveAction, title: presentationData.strings.DeleteAccount_ConfirmationAlertDelete, action: {
addAppLogEvent(postbox: context.account.postbox, type: "deactivate.final")
invokeAppLogEventsSynchronization(postbox: context.account.postbox)
updateState { current in
var updated = current
updated.isLoading = true
@@ -434,9 +458,17 @@ func deleteAccountDataController(context: AccountContext, mode: DeleteAccountDat
presentControllerImpl?(textAlertController(context: context, title: nil, text: presentationData.strings.Login_UnknownError, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]))
}, completed: {
dismissImpl?()
let _ = logoutFromAccount(id: accountId, accountManager: accountManager, alreadyLoggedOutRemotely: true).start()
let presentGlobalController = context.sharedContext.presentGlobalController
let _ = logoutFromAccount(id: accountId, accountManager: accountManager, alreadyLoggedOutRemotely: true).start(completed: {
Queue.mainQueue().after(0.1) {
presentGlobalController(UndoOverlayController(presentationData: presentationData, content: .info(title: nil, text: presentationData.strings.DeleteAccount_Success), elevatedLayout: false, animateInAsReplacement: false, action: { _ in return false }), nil)
}
})
})
}), TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_Cancel, action: {
addAppLogEvent(postbox: context.account.postbox, type: "deactivate.step_confirmation_cancel")
dismissImpl?()
})]))
}
@@ -517,6 +549,19 @@ func deleteAccountDataController(context: AccountContext, mode: DeleteAccountDat
}
}
switch mode {
case .peers:
addAppLogEvent(postbox: context.account.postbox, type: "deactivate.step_cloud_show")
case .groups:
addAppLogEvent(postbox: context.account.postbox, type: "deactivate.step_groups_show")
case .messages:
addAppLogEvent(postbox: context.account.postbox, type: "deactivate.step_messages_show")
case .phone:
addAppLogEvent(postbox: context.account.postbox, type: "deactivate.step_phone_show")
case .password:
addAppLogEvent(postbox: context.account.postbox, type: "deactivate.step_2fa_show")
}
return controller
}

View File

@@ -180,6 +180,8 @@ public func deleteAccountOptionsController(context: AccountContext, navigationCo
let supportPeerDisposable = MetaDisposable()
let arguments = DeleteAccountOptionsArguments(changePhoneNumber: {
addAppLogEvent(postbox: context.account.postbox, type: "deactivate.options_phone_change_tap")
let _ = (context.engine.data.get(TelegramEngine.EngineData.Item.Peer.Peer(id: context.engine.account.peerId))
|> deliverOnMainQueue).start(next: { accountPeer in
guard let accountPeer = accountPeer, case let .user(user) = accountPeer else {
@@ -192,6 +194,8 @@ public func deleteAccountOptionsController(context: AccountContext, navigationCo
dismissImpl?()
})
}, addAccount: {
addAppLogEvent(postbox: context.account.postbox, type: "deactivate.options_add_account_tap")
let _ = (activeAccountsAndPeers(context: context)
|> take(1)
|> deliverOnMainQueue
@@ -227,8 +231,12 @@ public func deleteAccountOptionsController(context: AccountContext, navigationCo
}
})
}, setupPrivacy: {
addAppLogEvent(postbox: context.account.postbox, type: "deactivate.options_privacy_tap")
replaceTopControllerImpl?(makePrivacyAndSecurityController(context: context), false)
}, setupTwoStepAuth: {
addAppLogEvent(postbox: context.account.postbox, type: "deactivate.options_2fa_tap")
if let data = twoStepAuthData {
switch data {
case .set:
@@ -252,6 +260,8 @@ public func deleteAccountOptionsController(context: AccountContext, navigationCo
let controller = twoStepVerificationUnlockSettingsController(context: context, mode: .access(intro: false, data: twoStepAuthData.flatMap({ Signal<TwoStepVerificationUnlockSettingsControllerData, NoError>.single(.access(configuration: $0)) })))
replaceTopControllerImpl?(controller, false)
}, setPasscode: {
addAppLogEvent(postbox: context.account.postbox, type: "deactivate.options_passcode_tap")
let _ = passcodeOptionsAccessController(context: context, pushController: { controller in
replaceTopControllerImpl?(controller, false)
}, completion: { _ in
@@ -263,11 +273,17 @@ public func deleteAccountOptionsController(context: AccountContext, navigationCo
})
dismissImpl?()
}, clearCache: {
addAppLogEvent(postbox: context.account.postbox, type: "deactivate.options_clear_cache_tap")
pushControllerImpl?(storageUsageController(context: context))
dismissImpl?()
}, clearSyncedContacts: {
addAppLogEvent(postbox: context.account.postbox, type: "deactivate.options_clear_contacts_tap")
replaceTopControllerImpl?(dataPrivacyController(context: context), false)
}, deleteChats: {
addAppLogEvent(postbox: context.account.postbox, type: "deactivate.options_delete_chats_tap")
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
var faqUrl = presentationData.strings.DeleteAccount_DeleteMessagesURL
@@ -298,6 +314,8 @@ public func deleteAccountOptionsController(context: AccountContext, navigationCo
openFaq(resolvedUrlPromise)
}, contactSupport: { [weak navigationController] in
addAppLogEvent(postbox: context.account.postbox, type: "deactivate.options_support_tap")
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
let supportPeer = Promise<PeerId?>()
@@ -329,7 +347,7 @@ public func deleteAccountOptionsController(context: AccountContext, navigationCo
})
}
presentControllerImpl?(textAlertController(context: context, title: nil, text: presentationData.strings.Settings_FAQ_Intro, actions: [
let alertController = textAlertController(context: context, title: nil, text: presentationData.strings.Settings_FAQ_Intro, actions: [
TextAlertAction(type: .genericAction, title: presentationData.strings.Settings_FAQ_Button, action: {
openFaq(resolvedUrlPromise)
dismissImpl?()
@@ -344,7 +362,11 @@ public func deleteAccountOptionsController(context: AccountContext, navigationCo
}
}))
})
]), nil)
])
alertController.dismissed = {
addAppLogEvent(postbox: context.account.postbox, type: "deactivate.options_support_cancel")
}
presentControllerImpl?(alertController, nil)
}, deleteAccount: {
let controller = deleteAccountDataController(context: context, mode: .peers, twoStepAuthData: twoStepAuthData)
replaceTopControllerImpl?(controller, true)
@@ -412,6 +434,8 @@ public func deleteAccountOptionsController(context: AccountContext, navigationCo
let _ = controller?.dismiss()
}
addAppLogEvent(postbox: context.account.postbox, type: "deactivate.options_show")
return controller
}

View File

@@ -201,15 +201,7 @@ class DeleteAccountPeersItemNode: ListViewItemNode, ItemListItemNode {
}
func asyncLayout() -> (_ item: DeleteAccountPeersItem, _ params: ListViewItemLayoutParams, _ neighbors: ItemListNeighbors) -> (ListViewItemNodeLayout, () -> Void) {
let currentItem = self.item
return { item, params, neighbors in
var themeUpdated = false
if currentItem?.theme !== item.theme {
themeUpdated = true
}
print(themeUpdated)
let contentSize: CGSize
var insets: UIEdgeInsets
let separatorHeight = UIScreenPixel

View File

@@ -424,7 +424,7 @@ public func themeSettingsController(context: AccountContext, focusOnItemTag: The
}
let premiumConfiguration = PremiumConfiguration.with(appConfiguration: context.currentAppConfiguration.with { $0 })
if premiumConfiguration.isPremiumDisabled {
if premiumConfiguration.isPremiumDisabled || context.account.testingEnvironment {
appIcons = appIcons.filter { !$0.isPremium }
}