diff --git a/Signal/src/AppDelegate.m b/Signal/src/AppDelegate.m index 9d49b498c..8b4d46fa8 100644 --- a/Signal/src/AppDelegate.m +++ b/Signal/src/AppDelegate.m @@ -263,7 +263,7 @@ static NSString *const kURLHostVerifyPrefix = @"verify"; - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { - OWSProdError(@"app_delegate_error_failed_to_register_for_remote_notifications"); + OWSProdError([OWSAnalyticsEvents appDelegateErrorFailedToRegisterForRemoteNotifications]); #ifdef DEBUG DDLogWarn(@"%@ We're in debug mode. Faking success for remote registration with a fake push identifier", self.tag); [PushManager.sharedManager.pushNotificationFutureSource trySetResult:[[NSMutableData dataWithLength:32] copy]]; diff --git a/Signal/src/ViewControllers/CodeVerificationViewController.m b/Signal/src/ViewControllers/CodeVerificationViewController.m index a12a0770b..0fa0ecae6 100644 --- a/Signal/src/ViewControllers/CodeVerificationViewController.m +++ b/Signal/src/ViewControllers/CodeVerificationViewController.m @@ -261,10 +261,10 @@ NS_ASSUME_NONNULL_BEGIN - (void)verifyChallengeAction:(nullable id)sender { [self startActivityIndicator]; - OWSProdInfo(@"registration_registering_code"); + OWSProdInfo([OWSAnalyticsEvents registrationRegisteringCode]); [self.accountManager registerWithVerificationCode:[self validationCodeFromTextField]] .then(^{ - OWSProdInfo(@"registration_registering_submitted_code"); + OWSProdInfo([OWSAnalyticsEvents registrationRegisteringSubmittedCode]); DDLogInfo(@"%@ Successfully registered Signal account.", self.tag); dispatch_async(dispatch_get_main_queue(), ^{ @@ -280,7 +280,7 @@ NS_ASSUME_NONNULL_BEGIN }); }) .catch(^(NSError *_Nonnull error) { - OWSProdInfo(@"registration_registration_failed"); + OWSProdInfo([OWSAnalyticsEvents registrationRegistrationFailed]); DDLogError(@"%@ error verifying challenge: %@", self.tag, error); dispatch_async(dispatch_get_main_queue(), ^{ [self stopActivityIndicator]; @@ -324,7 +324,7 @@ NS_ASSUME_NONNULL_BEGIN #pragma mark - Send codes again - (void)sendCodeViaSMSAction:(id)sender { - OWSProdInfo(@"registration_registering_requested_new_code_by_sms"); + OWSProdInfo([OWSAnalyticsEvents registrationRegisteringRequestedNewCodeBySms]); [self enableServerActions:NO]; @@ -343,7 +343,7 @@ NS_ASSUME_NONNULL_BEGIN } - (void)sendCodeViaVoiceAction:(id)sender { - OWSProdInfo(@"registration_registering_requested_new_code_by_voice"); + OWSProdInfo([OWSAnalyticsEvents registrationRegisteringRequestedNewCodeByVoice]); [self enableServerActions:NO]; @@ -374,7 +374,7 @@ NS_ASSUME_NONNULL_BEGIN } - (void)backButtonPressed:(id)sender { - OWSProdInfo(@"registration_verification_back"); + OWSProdInfo([OWSAnalyticsEvents registrationVerificationBack]); [self.navigationController popViewControllerAnimated:YES]; } diff --git a/Signal/src/ViewControllers/RegistrationViewController.m b/Signal/src/ViewControllers/RegistrationViewController.m index 807501abe..3258522e9 100644 --- a/Signal/src/ViewControllers/RegistrationViewController.m +++ b/Signal/src/ViewControllers/RegistrationViewController.m @@ -54,8 +54,8 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi - (void)viewDidLoad { [super viewDidLoad]; - - OWSProdInfo(@"registration_began"); + + OWSProdInfo([OWSAnalyticsEvents registrationBegan]); } - (void)createViews @@ -341,7 +341,7 @@ NSString *const kKeychainKey_LastRegisteredPhoneNumber = @"kKeychainKey_LastRegi __weak RegistrationViewController *weakSelf = self; [TSAccountManager registerWithPhoneNumber:parsedPhoneNumber success:^{ - OWSProdInfo(@"registration_registered_phone_number"); + OWSProdInfo([OWSAnalyticsEvents registrationRegisteredPhoneNumber]); [weakSelf.spinnerView stopAnimating]; diff --git a/Signal/src/environment/Migrations/OWS103EnableVideoCalling.m b/Signal/src/environment/Migrations/OWS103EnableVideoCalling.m index ef2859f95..6dcb54f92 100644 --- a/Signal/src/environment/Migrations/OWS103EnableVideoCalling.m +++ b/Signal/src/environment/Migrations/OWS103EnableVideoCalling.m @@ -35,7 +35,8 @@ static NSString *const OWS103EnableVideoCallingMigrationId = @"103"; } failure:^(NSURLSessionDataTask *task, NSError *error) { if (!IsNSErrorNetworkFailure(error)) { - OWSProdError(@"error_enable_video_calling_request_failed"); + OWSProdError([OWSAnalyticsEvents + errorEnableVideoCallingRequestFailed]); } DDLogError(@"%@ failed with error: %@", self.tag, error); }]; diff --git a/Signal/src/environment/VersionMigrations.m b/Signal/src/environment/VersionMigrations.m index 1e3a20a2e..0265f84cc 100644 --- a/Signal/src/environment/VersionMigrations.m +++ b/Signal/src/environment/VersionMigrations.m @@ -151,7 +151,7 @@ } failure:^(NSURLSessionDataTask *task, NSError *error) { if (!IsNSErrorNetworkFailure(error)) { - OWSProdError(@"error_update_attributes_request_failed"); + OWSProdError([OWSAnalyticsEvents errorUpdateAttributesRequestFailed]); } success = NO; DDLogError(@"Updating attributess failed with error: %@", error.description); diff --git a/SignalServiceKit/src/Account/TSAccountManager.m b/SignalServiceKit/src/Account/TSAccountManager.m index ab0831f20..894e492ff 100644 --- a/SignalServiceKit/src/Account/TSAccountManager.m +++ b/SignalServiceKit/src/Account/TSAccountManager.m @@ -160,7 +160,7 @@ NSString *const kNSNotificationName_LocalNumberDidChange = @"kNSNotificationName remainingRetries:remainingRetries - 1]; } else { if (!IsNSErrorNetworkFailure(error)) { - OWSProdError(@"accounts_error_register_push_tokens_failed"); + OWSProdError([OWSAnalyticsEvents accountsErrorRegisterPushTokensFailed]); } failureHandler(error); } @@ -197,7 +197,7 @@ NSString *const kNSNotificationName_LocalNumberDidChange = @"kNSNotificationName } failure:^(NSURLSessionDataTask *task, NSError *error) { if (!IsNSErrorNetworkFailure(error)) { - OWSProdError(@"accounts_error_verification_code_request_failed"); + OWSProdError([OWSAnalyticsEvents accountsErrorVerificationCodeRequestFailed]); } DDLogError(@"%@ Failed to request verification code request with error:%@", self.tag, error); failureBlock(error); @@ -270,7 +270,7 @@ NSString *const kNSNotificationName_LocalNumberDidChange = @"kNSNotificationName } failure:^(NSURLSessionDataTask *task, NSError *error) { if (!IsNSErrorNetworkFailure(error)) { - OWSProdError(@"accounts_error_verify_account_request_failed"); + OWSProdError([OWSAnalyticsEvents accountsErrorVerifyAccountRequestFailed]); } DDLogWarn(@"%@ Error verifying code: %@", self.tag, error.debugDescription); switch (error.code) { @@ -326,7 +326,7 @@ NSString *const kNSNotificationName_LocalNumberDidChange = @"kNSNotificationName } failure:^(NSURLSessionDataTask *task, NSError *error) { if (!IsNSErrorNetworkFailure(error)) { - OWSProdError(@"accounts_error_unregister_account_request_failed"); + OWSProdError([OWSAnalyticsEvents accountsErrorUnregisterAccountRequestFailed]); } DDLogError(@"%@ Failed to unregister with error: %@", self.tag, error); failureBlock(error); diff --git a/SignalServiceKit/src/Account/TSPreKeyManager.m b/SignalServiceKit/src/Account/TSPreKeyManager.m index 6a926ef2f..8dd9a218e 100644 --- a/SignalServiceKit/src/Account/TSPreKeyManager.m +++ b/SignalServiceKit/src/Account/TSPreKeyManager.m @@ -183,9 +183,9 @@ static const NSTimeInterval kSignedPreKeyUpdateFailureMaxFailureDuration = 10 * failure:^(NSURLSessionDataTask *task, NSError *error) { if (!IsNSErrorNetworkFailure(error)) { if (modeCopy == RefreshPreKeysMode_SignedAndOneTime) { - OWSProdError(@"error_prekeys_update_failed_signed_and_onetime"); + OWSProdError([OWSAnalyticsEvents errorPrekeysUpdateFailedSignedAndOnetime]); } else { - OWSProdError(@"error_prekeys_update_failed_just_signed"); + OWSProdError([OWSAnalyticsEvents errorPrekeysUpdateFailedJustSigned]); } } @@ -305,7 +305,7 @@ static const NSTimeInterval kSignedPreKeyUpdateFailureMaxFailureDuration = 10 * } failure:^(NSURLSessionDataTask *task, NSError *error) { if (!IsNSErrorNetworkFailure(error)) { - OWSProdError(@"error_prekeys_current_signed_prekey_request_failed"); + OWSProdError([OWSAnalyticsEvents errorPrekeysCurrentSignedPrekeyRequestFailed]); } DDLogWarn(@"%@ Could not retrieve current signed key from the service.", self.tag); @@ -316,7 +316,7 @@ static const NSTimeInterval kSignedPreKeyUpdateFailureMaxFailureDuration = 10 * } failure:^(NSURLSessionDataTask *task, NSError *error) { if (!IsNSErrorNetworkFailure(error)) { - OWSProdError(@"error_prekeys_available_prekeys_request_failed"); + OWSProdError([OWSAnalyticsEvents errorPrekeysAvailablePrekeysRequestFailed]); } DDLogError(@"%@ Failed to retrieve the number of available prekeys.", self.tag); @@ -402,9 +402,9 @@ static const NSTimeInterval kSignedPreKeyUpdateFailureMaxFailureDuration = 10 * } if (signedPrekey.wasAcceptedByService) { - OWSProdInfo(@"prekeys_deleted_old_accepted_signed_prekey"); + OWSProdInfo([OWSAnalyticsEvents prekeysDeletedOldAcceptedSignedPrekey]); } else { - OWSProdInfo(@"prekeys_deleted_old_unaccepted_signed_prekey"); + OWSProdInfo([OWSAnalyticsEvents prekeysDeletedOldUnacceptedSignedPrekey]); } oldSignedPreKeyCount--; diff --git a/SignalServiceKit/src/Contacts/ContactsUpdater.m b/SignalServiceKit/src/Contacts/ContactsUpdater.m index 2d68dae6d..646612ffa 100644 --- a/SignalServiceKit/src/Contacts/ContactsUpdater.m +++ b/SignalServiceKit/src/Contacts/ContactsUpdater.m @@ -206,7 +206,7 @@ NS_ASSUME_NONNULL_BEGIN } failure:^(NSURLSessionDataTask *task, NSError *error) { if (!IsNSErrorNetworkFailure(error)) { - OWSProdError(@"contacts_error_contacts_intersection_failed"); + OWSProdError([OWSAnalyticsEvents contactsErrorContactsIntersectionFailed]); } NSHTTPURLResponse *response = (NSHTTPURLResponse *)task.response; diff --git a/SignalServiceKit/src/Messages/Attachments/OWSAttachmentsProcessor.m b/SignalServiceKit/src/Messages/Attachments/OWSAttachmentsProcessor.m index d799b4f0c..68e1e6f7b 100644 --- a/SignalServiceKit/src/Messages/Attachments/OWSAttachmentsProcessor.m +++ b/SignalServiceKit/src/Messages/Attachments/OWSAttachmentsProcessor.m @@ -187,7 +187,7 @@ static const CGFloat kAttachmentDownloadProgressTheta = 0.001f; } failure:^(NSURLSessionDataTask *task, NSError *error) { if (!IsNSErrorNetworkFailure(error)) { - OWSProdError(@"error_attachment_request_failed"); + OWSProdError([OWSAnalyticsEvents errorAttachmentRequestFailed]); } DDLogError(@"Failed retrieval of attachment with error: %@", error); if (attachment.serverId < 100) { diff --git a/SignalServiceKit/src/Messages/OWSMessageReceiver.m b/SignalServiceKit/src/Messages/OWSMessageReceiver.m index 8904fc843..d144fb981 100644 --- a/SignalServiceKit/src/Messages/OWSMessageReceiver.m +++ b/SignalServiceKit/src/Messages/OWSMessageReceiver.m @@ -336,7 +336,7 @@ NSString *const OWSMessageProcessingJobFinderExtensionGroup = @"OWSMessageProces // Drop any too-large messages on the floor. Well behaving clients should never send them. NSUInteger kMaxEnvelopeByteCount = 250 * 1024; if (envelope.serializedSize > kMaxEnvelopeByteCount) { - OWSProdError(@"message_receiver_error_oversize_message"); + OWSProdError([OWSAnalyticsEvents messageReceiverErrorOversizeMessage]); return; } @@ -344,7 +344,7 @@ NSString *const OWSMessageProcessingJobFinderExtensionGroup = @"OWSMessageProces // This likely indicates a misbehaving sending client. NSUInteger kLargeEnvelopeWarningByteCount = 25 * 1024; if (envelope.serializedSize > kLargeEnvelopeWarningByteCount) { - OWSProdError(@"message_receiver_error_large_message"); + OWSProdError([OWSAnalyticsEvents messageReceiverErrorLargeMessage]); } [self.processingQueue enqueueEnvelopeForProcessing:envelope]; diff --git a/SignalServiceKit/src/Messages/OWSMessageSender.m b/SignalServiceKit/src/Messages/OWSMessageSender.m index 1d50095ec..c7734f546 100644 --- a/SignalServiceKit/src/Messages/OWSMessageSender.m +++ b/SignalServiceKit/src/Messages/OWSMessageSender.m @@ -186,7 +186,7 @@ NSUInteger const OWSSendMessageOperationMaxRetries = 4; _successHandler = ^{ typeof(self) strongSelf = weakSelf; if (!strongSelf) { - OWSProdCFail(@"message_sender_error_send_operation_did_not_complete"); + OWSProdCFail([OWSAnalyticsEvents messageSenderErrorSendOperationDidNotComplete]); return; } @@ -200,7 +200,7 @@ NSUInteger const OWSSendMessageOperationMaxRetries = 4; _failureHandler = ^(NSError *_Nonnull error) { typeof(self) strongSelf = weakSelf; if (!strongSelf) { - OWSProdCFail(@"message_sender_error_send_operation_did_not_complete"); + OWSProdCFail([OWSAnalyticsEvents messageSenderErrorSendOperationDidNotComplete]); return; } @@ -474,7 +474,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException"; [TSAttachmentStream fetchObjectWithUniqueID:message.attachmentIds.firstObject]; if (!attachmentStream) { - OWSProdError(@"message_sender_error_could_not_load_attachment"); + OWSProdError([OWSAnalyticsEvents messageSenderErrorCouldNotLoadAttachment]); NSError *error = OWSErrorMakeFailedToSendOutgoingMessageError(); // Not finding local attachment is a terminal failure. [error setIsRetryable:NO]; @@ -539,7 +539,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException"; NSError *error; [attachmentStream writeData:dataCopy error:&error]; if (error) { - OWSProdError(@"message_sender_error_could_not_write_attachment"); + OWSProdError([OWSAnalyticsEvents messageSenderErrorCouldNotWriteAttachment]); return failureHandler(error); } @@ -575,7 +575,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException"; if (recipients.count == 0 && !*error) { // error should be set in contactsUpater, but just in case. - OWSProdError(@"message_sender_error_could_not_find_contacts_1"); + OWSProdError([OWSAnalyticsEvents messageSenderErrorCouldNotFindContacts1]); *error = OWSErrorMakeFailedToSendOutgoingMessageError(); } @@ -598,7 +598,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException"; if (recipients.count == 0) { if (!error) { - OWSProdError(@"message_sender_error_could_not_find_contacts_2"); + OWSProdError([OWSAnalyticsEvents messageSenderErrorCouldNotFindContacts2]); error = OWSErrorMakeFailedToSendOutgoingMessageError(); } // If no recipients were found, there's no reason to retry. It will just fail again. @@ -652,7 +652,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException"; [self unregisteredRecipient:recipient message:message thread:thread]; } - OWSProdError(@"message_sender_error_could_not_find_contacts_3"); + OWSProdError([OWSAnalyticsEvents messageSenderErrorCouldNotFindContacts3]); // No need to repeat trying to find a failure. Apart from repeatedly failing, it would also cause us // to print redundant error messages. [error setIsRetryable:NO]; @@ -834,7 +834,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException"; AssertIsOnSendingQueue(); if ([TSPreKeyManager isAppLockedDueToPreKeyUpdateFailures]) { - OWSProdError(@"message_send_error_failed_due_to_prekey_update_failures"); + OWSProdError([OWSAnalyticsEvents messageSendErrorFailedDueToPrekeyUpdateFailures]); // Retry prekey update every time user tries to send a message while app // is disabled due to prekey update failures. @@ -856,7 +856,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException"; if (remainingAttempts <= 0) { // We should always fail with a specific error. - OWSProdFail(@"message_sender_error_generic_send_failure"); + OWSProdFail([OWSAnalyticsEvents messageSenderErrorGenericSendFailure]); NSError *error = OWSErrorMakeFailedToSendOutgoingMessageError(); [error setIsRetryable:YES]; @@ -874,7 +874,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException"; // We expect it to happen whenever Bob reinstalls, and Alice messages Bob before // she can pull down his latest identity. // If it's happening a lot, we should rethink our profile fetching strategy. - OWSProdInfo(@"message_send_error_failed_due_to_untrusted_key"); + OWSProdInfo([OWSAnalyticsEvents messageSendErrorFailedDueToUntrustedKey]); NSString *localizedErrorDescriptionFormat = NSLocalizedString(@"FAILED_SENDING_BECAUSE_UNTRUSTED_IDENTITY_KEY", @@ -893,7 +893,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException"; PreKeyBundle *newKeyBundle = exception.userInfo[TSInvalidPreKeyBundleKey]; if (![newKeyBundle isKindOfClass:[PreKeyBundle class]]) { - OWSProdFail(@"message_sender_error_unexpected_key_bundle"); + OWSProdFail([OWSAnalyticsEvents messageSenderErrorUnexpectedKeyBundle]); failureHandler(error); return; } @@ -901,14 +901,14 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException"; NSData *newIdentityKeyWithVersion = newKeyBundle.identityKey; if (![newIdentityKeyWithVersion isKindOfClass:[NSData class]]) { - OWSProdFail(@"message_sender_error_invalid_identity_key_type"); + OWSProdFail([OWSAnalyticsEvents messageSenderErrorInvalidIdentityKeyType]); failureHandler(error); return; } // TODO migrate to storing the full 33 byte representation of the identity key. if (newIdentityKeyWithVersion.length != kIdentityKeyLength) { - OWSProdFail(@"message_sender_error_invalid_identity_key_length"); + OWSProdFail([OWSAnalyticsEvents messageSenderErrorInvalidIdentityKeyLength]); failureHandler(error); return; } @@ -1013,7 +1013,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException"; NSDictionary *serializedResponse = [NSJSONSerialization JSONObjectWithData:responseData options:0 error:&error]; if (error) { - OWSProdError(@"message_sender_error_could_not_parse_mismatched_devices_json"); + OWSProdError([OWSAnalyticsEvents messageSenderErrorCouldNotParseMismatchedDevicesJson]); [error setIsRetryable:YES]; return failureHandler(error); } @@ -1053,7 +1053,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException"; dispatch_async([OWSDispatch sessionStoreQueue], ^{ if (extraDevices.count < 1 && missingDevices.count < 1) { - OWSProdFail(@"message_sender_error_no_missing_or_extra_devices"); + OWSProdFail([OWSAnalyticsEvents messageSenderErrorNoMissingOrExtraDevices]); } if (extraDevices && extraDevices.count > 0) { @@ -1217,7 +1217,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException"; } failure:^(NSURLSessionDataTask *task, NSError *error) { if (!IsNSErrorNetworkFailure(error)) { - OWSProdError(@"message_sender_error_recipient_prekey_request_failed"); + OWSProdError([OWSAnalyticsEvents messageSenderErrorRecipientPrekeyRequestFailed]); } DDLogError(@"Server replied to PreKeyBundle request with error: %@", error); NSHTTPURLResponse *response = (NSHTTPURLResponse *)task.response; @@ -1290,7 +1290,7 @@ NSString *const OWSMessageSenderRateLimitedException = @"RateLimitedException"; NSDictionary *jsonDict = [MTLJSONAdapter JSONDictionaryFromModel:messageParams error:&error]; if (error) { - OWSProdError(@"message_send_error_could_not_serialize_message_json"); + OWSProdError([OWSAnalyticsEvents messageSendErrorCouldNotSerializeMessageJson]); return nil; } diff --git a/SignalServiceKit/src/Messages/TSMessagesManager.m b/SignalServiceKit/src/Messages/TSMessagesManager.m index 3b787cea9..1b48a95cd 100644 --- a/SignalServiceKit/src/Messages/TSMessagesManager.m +++ b/SignalServiceKit/src/Messages/TSMessagesManager.m @@ -158,19 +158,19 @@ NS_ASSUME_NONNULL_BEGIN return @"DeliveryReceipt"; case OWSSignalServiceProtosEnvelopeTypeUnknown: // Shouldn't happen - OWSProdFail(@"message_manager_error_envelope_type_unknown"); + OWSProdFail([OWSAnalyticsEvents messageManagerErrorEnvelopeTypeUnknown]); return @"Unknown"; case OWSSignalServiceProtosEnvelopeTypeCiphertext: return @"SignalEncryptedMessage"; case OWSSignalServiceProtosEnvelopeTypeKeyExchange: // Unsupported - OWSProdFail(@"message_manager_error_envelope_type_key_exchange"); + OWSProdFail([OWSAnalyticsEvents messageManagerErrorEnvelopeTypeKeyExchange]); return @"KeyExchange"; case OWSSignalServiceProtosEnvelopeTypePrekeyBundle: return @"PreKeyEncryptedMessage"; default: // Shouldn't happen - OWSProdFail(@"message_manager_error_envelope_type_other"); + OWSProdFail([OWSAnalyticsEvents messageManagerErrorEnvelopeTypeOther]); return @"Other"; } } @@ -312,7 +312,8 @@ NS_ASSUME_NONNULL_BEGIN envelope.source, (unsigned int)envelope.sourceDevice, error); - OWSProdError(@"message_manager_error_could_not_handle_secure_message"); + OWSProdError( + [OWSAnalyticsEvents messageManagerErrorCouldNotHandleSecureMessage]); } completion(); }]; @@ -330,7 +331,8 @@ NS_ASSUME_NONNULL_BEGIN envelope.source, (unsigned int)envelope.sourceDevice, error); - OWSProdError(@"message_manager_error_could_not_handle_prekey_bundle"); + OWSProdError( + [OWSAnalyticsEvents messageManagerErrorCouldNotHandlePrekeyBundle]); } completion(); }]; @@ -355,7 +357,7 @@ NS_ASSUME_NONNULL_BEGIN } } @catch (NSException *exception) { DDLogError(@"Received an incorrectly formatted protocol buffer: %@", exception.debugDescription); - OWSProdFail(@"message_manager_error_invalid_protocol_message"); + OWSProdFail([OWSAnalyticsEvents messageManagerErrorInvalidProtocolMessage]); } completion(); @@ -387,7 +389,7 @@ NS_ASSUME_NONNULL_BEGIN NSData *encryptedData = messageEnvelope.hasContent ? messageEnvelope.content : messageEnvelope.legacyMessage; if (!encryptedData) { - OWSProdFail(@"message_manager_error_message_envelope_has_no_content"); + OWSProdFail([OWSAnalyticsEvents messageManagerErrorMessageEnvelopeHasNoContent]); completion(nil); return; } @@ -436,7 +438,7 @@ NS_ASSUME_NONNULL_BEGIN // DEPRECATED - Remove after all clients have been upgraded. NSData *encryptedData = preKeyEnvelope.hasContent ? preKeyEnvelope.content : preKeyEnvelope.legacyMessage; if (!encryptedData) { - OWSProdFail(@"message_manager_error_prekey_bundle_envelope_has_no_content"); + OWSProdFail([OWSAnalyticsEvents messageManagerErrorPrekeyBundleEnvelopeHasNoContent]); completion(nil); return; } diff --git a/SignalServiceKit/src/Network/API/OWSDeviceProvisioningCodeService.m b/SignalServiceKit/src/Network/API/OWSDeviceProvisioningCodeService.m index 1baebe043..0cf12020a 100644 --- a/SignalServiceKit/src/Network/API/OWSDeviceProvisioningCodeService.m +++ b/SignalServiceKit/src/Network/API/OWSDeviceProvisioningCodeService.m @@ -51,7 +51,7 @@ NSString *const OWSDeviceProvisioningCodeServiceProvisioningCodeKey = @"verifica } failure:^(NSURLSessionDataTask *task, NSError *error) { if (!IsNSErrorNetworkFailure(error)) { - OWSProdError(@"error_provisioning_code_request_failed"); + OWSProdError([OWSAnalyticsEvents errorProvisioningCodeRequestFailed]); } DDLogVerbose(@"ProvisioningCode request failed with error: %@", error); failureCallback(error); diff --git a/SignalServiceKit/src/Network/API/OWSDeviceProvisioningService.m b/SignalServiceKit/src/Network/API/OWSDeviceProvisioningService.m index 9af433813..8b835cd02 100644 --- a/SignalServiceKit/src/Network/API/OWSDeviceProvisioningService.m +++ b/SignalServiceKit/src/Network/API/OWSDeviceProvisioningService.m @@ -48,7 +48,7 @@ NS_ASSUME_NONNULL_BEGIN } failure:^(NSURLSessionDataTask *task, NSError *error) { if (!IsNSErrorNetworkFailure(error)) { - OWSProdError(@"error_provisioning_request_failed"); + OWSProdError([OWSAnalyticsEvents errorProvisioningRequestFailed]); } DDLogVerbose(@"Provisioning request failed with error: %@", error); failureCallback(error); diff --git a/SignalServiceKit/src/Network/API/OWSDevicesService.m b/SignalServiceKit/src/Network/API/OWSDevicesService.m index 93d3293da..57b461eee 100644 --- a/SignalServiceKit/src/Network/API/OWSDevicesService.m +++ b/SignalServiceKit/src/Network/API/OWSDevicesService.m @@ -33,7 +33,7 @@ NS_ASSUME_NONNULL_BEGIN } failure:^(NSURLSessionDataTask *task, NSError *error) { if (!IsNSErrorNetworkFailure(error)) { - OWSProdError(@"error_get_devices_failed"); + OWSProdError([OWSAnalyticsEvents errorGetDevicesFailed]); } DDLogVerbose(@"Get devices request failed with error: %@", error); failureCallback(error); @@ -53,7 +53,7 @@ NS_ASSUME_NONNULL_BEGIN } failure:^(NSURLSessionDataTask *task, NSError *error) { if (!IsNSErrorNetworkFailure(error)) { - OWSProdError(@"error_unlink_device_failed"); + OWSProdError([OWSAnalyticsEvents errorUnlinkDeviceFailed]); } DDLogVerbose(@"Get devices request failed with error: %@", error); failureCallback(error); diff --git a/SignalServiceKit/src/Storage/TSStorageManager.m b/SignalServiceKit/src/Storage/TSStorageManager.m index e77595a78..18e4ef8e2 100644 --- a/SignalServiceKit/src/Storage/TSStorageManager.m +++ b/SignalServiceKit/src/Storage/TSStorageManager.m @@ -86,7 +86,7 @@ static NSString *keychainDBPassAccount = @"TSDatabasePass"; - (nullable Class)unarchiver:(NSKeyedUnarchiver *)unarchiver cannotDecodeObjectOfClassName:(NSString *)name originalClasses:(NSArray *)classNames { - OWSProdError(@"storage_error_could_not_decode_class"); + OWSProdError([OWSAnalyticsEvents storageErrorCouldNotDecodeClass]); return [OWSUnknownObject class]; } @@ -117,14 +117,14 @@ static NSString *keychainDBPassAccount = @"TSDatabasePass"; // // The best we can try to do is to discard the current database // and behave like a clean install. - OWSProdCritical(@"storage_error_could_not_load_database"); + OWSProdCritical([OWSAnalyticsEvents storageErrorCouldNotLoadDatabase]); // Try to reset app by deleting database. // Disabled resetting storage until we have better data on why this happens. // [self resetSignalStorage]; if (![self tryToLoadDatabase]) { - OWSProdCritical(@"storage_error_could_not_load_database_second_attempt"); + OWSProdCritical([OWSAnalyticsEvents storageErrorCouldNotLoadDatabaseSecondAttempt]); // Sleep to give analytics events time to be delivered. [NSThread sleepForTimeInterval:15.0f]; @@ -183,7 +183,7 @@ static NSString *keychainDBPassAccount = @"TSDatabasePass"; return [unarchiver decodeObjectForKey:@"root"]; } @catch (NSException *exception) { // Sync log in case we bail. - OWSProdError(@"storage_error_deserialization"); + OWSProdError([OWSAnalyticsEvents storageErrorDeserialization]); @throw exception; } }; @@ -253,7 +253,7 @@ static NSString *keychainDBPassAccount = @"TSDatabasePass"; BOOL success = [ressourceURL setResourceValues:resourcesAttrs error:&error]; if (error || !success) { - OWSProdCritical(@"storage_error_file_protection"); + OWSProdCritical([OWSAnalyticsEvents storageErrorFileProtection]); } } @@ -353,7 +353,7 @@ static NSString *keychainDBPassAccount = @"TSDatabasePass"; BOOL shouldHavePassword = [NSFileManager.defaultManager fileExistsAtPath:[self dbPath]]; if (shouldHavePassword) { - OWSProdCritical(@"storage_error_could_not_load_database_second_attempt"); + OWSProdCritical([OWSAnalyticsEvents storageErrorCouldNotLoadDatabaseSecondAttempt]); } // Try to reset app by deleting database. @@ -372,7 +372,7 @@ static NSString *keychainDBPassAccount = @"TSDatabasePass"; NSError *keySetError; [SAMKeychain setPassword:newDBPassword forService:keychainService account:keychainDBPassAccount error:&keySetError]; if (keySetError) { - OWSProdCritical(@"storage_error_could_not_store_database_password"); + OWSProdCritical([OWSAnalyticsEvents storageErrorCouldNotStoreDatabasePassword]); [self deletePasswordFromKeychain]; diff --git a/SignalServiceKit/src/Util/OWSAnalytics.m b/SignalServiceKit/src/Util/OWSAnalytics.m index 185504407..c2af8d6c6 100755 --- a/SignalServiceKit/src/Util/OWSAnalytics.m +++ b/SignalServiceKit/src/Util/OWSAnalytics.m @@ -411,7 +411,7 @@ NSString *NSStringForOWSAnalyticsSeverity(OWSAnalyticsSeverity severity) - (void)appLaunchDidBegin { - OWSProdInfo(@"app_launch"); + OWSProdInfo([OWSAnalyticsEvents appLaunch]); } #pragma mark - Logging diff --git a/SignalServiceKit/src/Util/OWSAnalyticsEvents.h b/SignalServiceKit/src/Util/OWSAnalyticsEvents.h index af550aff7..c77b84293 100755 --- a/SignalServiceKit/src/Util/OWSAnalyticsEvents.h +++ b/SignalServiceKit/src/Util/OWSAnalyticsEvents.h @@ -22,28 +22,6 @@ NS_ASSUME_NONNULL_BEGIN + (NSString *)appLaunch; -+ (NSString *)appLaunchComplete; - -+ (NSString *)callServiceCallAlreadySet; - -+ (NSString *)callServiceCallIdMismatch; - -+ (NSString *)callServiceCallMismatch; - -+ (NSString *)callServiceCallMissing; - -+ (NSString *)callServiceCallUnexpectedlyIdle; - -+ (NSString *)callServiceCouldNotCreatePeerConnectionClientPromise; - -+ (NSString *)callServiceCouldNotCreateReadyToSendIceUpdatesPromise; - -+ (NSString *)callServiceMissingFulfillReadyToSendIceUpdatesPromise; - -+ (NSString *)callServicePeerConnectionAlreadySet; - -+ (NSString *)callServicePeerConnectionMissing; - + (NSString *)contactsErrorContactsIntersectionFailed; + (NSString *)errorAttachmentRequestFailed; @@ -82,10 +60,12 @@ NS_ASSUME_NONNULL_BEGIN + (NSString *)messageManagerErrorMessageEnvelopeHasNoContent; -+ (NSString *)messageManagerErrorOversizeMessage; - + (NSString *)messageManagerErrorPrekeyBundleEnvelopeHasNoContent; ++ (NSString *)messageReceiverErrorLargeMessage; + ++ (NSString *)messageReceiverErrorOversizeMessage; + + (NSString *)messageSendErrorCouldNotSerializeMessageJson; + (NSString *)messageSendErrorFailedDueToPrekeyUpdateFailures; @@ -118,7 +98,25 @@ NS_ASSUME_NONNULL_BEGIN + (NSString *)messageSenderErrorUnexpectedKeyBundle; -+ (NSString *)prekeysDeletedOldSignedPrekey; ++ (NSString *)prekeysDeletedOldAcceptedSignedPrekey; + ++ (NSString *)prekeysDeletedOldUnacceptedSignedPrekey; + ++ (NSString *)registrationBegan; + ++ (NSString *)registrationRegisteredPhoneNumber; + ++ (NSString *)registrationRegisteringCode; + ++ (NSString *)registrationRegisteringRequestedNewCodeBySms; + ++ (NSString *)registrationRegisteringRequestedNewCodeByVoice; + ++ (NSString *)registrationRegisteringSubmittedCode; + ++ (NSString *)registrationRegistrationFailed; + ++ (NSString *)registrationVerificationBack; + (NSString *)storageErrorCouldNotDecodeClass; diff --git a/SignalServiceKit/src/Util/OWSAnalyticsEvents.m b/SignalServiceKit/src/Util/OWSAnalyticsEvents.m index a9d1fd068..68823887a 100755 --- a/SignalServiceKit/src/Util/OWSAnalyticsEvents.m +++ b/SignalServiceKit/src/Util/OWSAnalyticsEvents.m @@ -200,6 +200,16 @@ NS_ASSUME_NONNULL_BEGIN return @"message_manager_error_prekey_bundle_envelope_has_no_content"; } ++ (NSString *)messageReceiverErrorLargeMessage +{ + return @"message_receiver_error_large_message"; +} + ++ (NSString *)messageReceiverErrorOversizeMessage +{ + return @"message_receiver_error_oversize_message"; +} + + (NSString *)messageSendErrorCouldNotSerializeMessageJson { return @"message_send_error_could_not_serialize_message_json"; @@ -280,11 +290,61 @@ NS_ASSUME_NONNULL_BEGIN return @"message_sender_error_unexpected_key_bundle"; } ++ (NSString *)prekeysDeletedOldAcceptedSignedPrekey +{ + return @"prekeys_deleted_old_accepted_signed_prekey"; +} + + (NSString *)prekeysDeletedOldSignedPrekey { return @"prekeys_deleted_old_signed_prekey"; } ++ (NSString *)prekeysDeletedOldUnacceptedSignedPrekey +{ + return @"prekeys_deleted_old_unaccepted_signed_prekey"; +} + ++ (NSString *)registrationBegan +{ + return @"registration_began"; +} + ++ (NSString *)registrationRegisteredPhoneNumber +{ + return @"registration_registered_phone_number"; +} + ++ (NSString *)registrationRegisteringCode +{ + return @"registration_registering_code"; +} + ++ (NSString *)registrationRegisteringRequestedNewCodeBySms +{ + return @"registration_registering_requested_new_code_by_sms"; +} + ++ (NSString *)registrationRegisteringRequestedNewCodeByVoice +{ + return @"registration_registering_requested_new_code_by_voice"; +} + ++ (NSString *)registrationRegisteringSubmittedCode +{ + return @"registration_registering_submitted_code"; +} + ++ (NSString *)registrationRegistrationFailed +{ + return @"registration_registration_failed"; +} + ++ (NSString *)registrationVerificationBack +{ + return @"registration_verification_back"; +} + + (NSString *)storageErrorCouldNotDecodeClass { return @"storage_error_could_not_decode_class";