diff --git a/iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj b/iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj index ffe36526f5..81d4aaceac 100644 --- a/iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj +++ b/iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj @@ -274,6 +274,7 @@ 3CF11E3D2C6D6155002856F5 /* UserExecutorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CF11E3C2C6D6155002856F5 /* UserExecutorTests.swift */; }; 354E0C59BA9B18437C36215B /* UserExecutorRetryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6C310B6C569E96C204F8CD68 /* UserExecutorRetryTests.swift */; }; B5481A0100000000000000AA /* ExecutorRetryBackoffTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5481A0100000000000000A9 /* ExecutorRetryBackoffTests.swift */; }; + B5537A0100000000000000AA /* RequestFailureLogLevelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5537A0100000000000000A9 /* RequestFailureLogLevelTests.swift */; }; 3CF11E402C6E6DE2002856F5 /* MockNewRecordsState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CF11E3F2C6E6DE2002856F5 /* MockNewRecordsState.swift */; }; 3CF1A5632C669EA40056B3AA /* OSNewRecordsState.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CF1A5622C669EA40056B3AA /* OSNewRecordsState.swift */; }; B5481A0100000000000000A4 /* OSRequestRetryBackoff.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5481A0100000000000000A3 /* OSRequestRetryBackoff.swift */; }; @@ -1570,6 +1571,7 @@ 3CF11E3C2C6D6155002856F5 /* UserExecutorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserExecutorTests.swift; sourceTree = ""; }; 6C310B6C569E96C204F8CD68 /* UserExecutorRetryTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserExecutorRetryTests.swift; sourceTree = ""; }; B5481A0100000000000000A9 /* ExecutorRetryBackoffTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExecutorRetryBackoffTests.swift; sourceTree = ""; }; + B5537A0100000000000000A9 /* RequestFailureLogLevelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestFailureLogLevelTests.swift; sourceTree = ""; }; 3CF11E3F2C6E6DE2002856F5 /* MockNewRecordsState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MockNewRecordsState.swift; sourceTree = ""; }; 3CF1A5622C669EA40056B3AA /* OSNewRecordsState.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSNewRecordsState.swift; sourceTree = ""; }; B5481A0100000000000000A3 /* OSRequestRetryBackoff.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSRequestRetryBackoff.swift; sourceTree = ""; }; @@ -2643,6 +2645,7 @@ 3CF11E3C2C6D6155002856F5 /* UserExecutorTests.swift */, 6C310B6C569E96C204F8CD68 /* UserExecutorRetryTests.swift */, B5481A0100000000000000A9 /* ExecutorRetryBackoffTests.swift */, + B5537A0100000000000000A9 /* RequestFailureLogLevelTests.swift */, 3CA93BC3300AEFFA000724B3 /* SubscriptionUpdateRaceTests.swift */, C95B2AD05FFF9FC12C9D5878 /* ExecutorReadYourWriteTests.swift */, 3C5181A1B2C3D4E5F6A7B801 /* SubscriptionCreateResponseTests.swift */, @@ -4832,6 +4835,7 @@ 3CF11E3D2C6D6155002856F5 /* UserExecutorTests.swift in Sources */, 354E0C59BA9B18437C36215B /* UserExecutorRetryTests.swift in Sources */, B5481A0100000000000000AA /* ExecutorRetryBackoffTests.swift in Sources */, + B5537A0100000000000000AA /* RequestFailureLogLevelTests.swift in Sources */, 3C67F77A2BEB2B710085A0F0 /* SwitchUserIntegrationTests.swift in Sources */, 3CC063EE2B6D7FE8002BB07F /* OneSignalUserTests.swift in Sources */, A5426001A1B2C3D4E5F60006 /* InputGuardUserTests.swift in Sources */, diff --git a/iOS_SDK/OneSignalSDK/OneSignalCore/Source/API/OneSignalClient.m b/iOS_SDK/OneSignalSDK/OneSignalCore/Source/API/OneSignalClient.m index 5cfee3305d..a712949dae 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalCore/Source/API/OneSignalClient.m +++ b/iOS_SDK/OneSignalSDK/OneSignalCore/Source/API/OneSignalClient.m @@ -76,9 +76,10 @@ - (OneSignalClientError *)privacyConsentErrorWithRequestType:(NSString *)type { - (void)executeRequest:(OneSignalRequest *)request onSuccess:(OSResultSuccessBlock)successBlock onFailure:(OSClientFailureBlock)failureBlock { // If privacy consent is required but not yet given, any non-GET request should be blocked. if (request.method != GET && [OSPrivacyConsentController shouldLogMissingPrivacyConsentErrorWithMethodName:nil]) { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"Attempted to perform an HTTP request (%@) before the user provided privacy consent."]; + OneSignalClientError *consentError = [self privacyConsentErrorWithRequestType:NSStringFromClass(request.class)]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:consentError.message]; if (failureBlock) { - failureBlock([self privacyConsentErrorWithRequestType:NSStringFromClass(request.class)]); + failureBlock(consentError); } return; @@ -224,6 +225,9 @@ - (void)handleJSONNSURLResponse:(NSURLResponse*)response data:(NSData*)data erro [OneSignalLog onesignalLog:ONE_S_LL_VERBOSE message:[NSString stringWithFormat:@"network response (%@) with URL %@: %@", NSStringFromClass([request class]), request.urlRequest.URL.absoluteString, innerJson]]; if (jsonError) { + if (statusCode >= 200 && statusCode < 300) { + [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"Response to %@ with status %ld is not valid JSON: %@", NSStringFromClass([request class]), (long)statusCode, jsonError]]; + } if (failureBlock != nil) failureBlock([[OneSignalClientError alloc] initWithCode:statusCode message:@"Error parsing JSON" responseHeaders:headers response:nil underlyingError:jsonError]); return; diff --git a/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OSPrivacyConsentController.m b/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OSPrivacyConsentController.m index a91b7af51f..4896da3309 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OSPrivacyConsentController.m +++ b/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OSPrivacyConsentController.m @@ -66,7 +66,7 @@ + (void)setRequiresPrivacyConsent:(BOOL)required { return; if ([self requiresUserPrivacyConsent] && !required) { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"Cannot change setConsentRequired() from TRUE to FALSE"]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"Cannot change setConsentRequired() from TRUE to FALSE"]; return; } [OneSignalUserDefaults.initShared saveBoolForKey:OSUD_REQUIRES_USER_PRIVACY_CONSENT withValue:required]; diff --git a/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OSStubInAppMessages.m b/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OSStubInAppMessages.m index b15fc8ab2e..8fe21ec336 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OSStubInAppMessages.m +++ b/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OSStubInAppMessages.m @@ -36,48 +36,48 @@ @implementation OSStubInAppMessages } + (void)addClickListener:(NSObject * _Nullable)listener { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."]; } + (void)addLifecycleListener:(NSObject * _Nullable)listener { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."]; } + (void)addTrigger:(NSString * _Nonnull)key withValue:(NSString * _Nonnull)value { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."]; } + (void)addTriggers:(NSDictionary * _Nonnull)triggers { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."]; } + (void)clearTriggers { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."]; } + (BOOL)paused { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."]; return true; } + (void)paused:(BOOL)pause { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."]; } + (void)removeClickListener:(NSObject * _Nullable)listener { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."]; } + (void)removeLifecycleListener:(NSObject * _Nullable)listener { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."]; } + (void)removeTrigger:(NSString * _Nonnull)key { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."]; } + (void)removeTriggers:(NSArray * _Nonnull)keys { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."]; } @end diff --git a/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OSStubLocation.m b/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OSStubLocation.m index e04faf84ec..35b74286a4 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OSStubLocation.m +++ b/iOS_SDK/OneSignalSDK/OneSignalCore/Source/OSStubLocation.m @@ -36,16 +36,16 @@ @implementation OSStubLocation } + (BOOL)isShared { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OneSignalLocation not found. In order to use OneSignal's location features the OneSignalLocation module must be added."]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"OneSignalLocation not found. In order to use OneSignal's location features the OneSignalLocation module must be added."]; return false; } + (void)requestPermission { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OneSignalLocation not found. In order to use OneSignal's location features the OneSignalLocation module must be added."]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"OneSignalLocation not found. In order to use OneSignal's location features the OneSignalLocation module must be added."]; } + (void)setShared:(BOOL)enable { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OneSignalLocation not found. In order to use OneSignal's location features the OneSignalLocation module must be added."]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"OneSignalLocation not found. In order to use OneSignal's location features the OneSignalLocation module must be added."]; } @end diff --git a/iOS_SDK/OneSignalSDK/OneSignalExtension/OneSignalAttachmentHandler.m b/iOS_SDK/OneSignalSDK/OneSignalExtension/OneSignalAttachmentHandler.m index c3209c6bb4..15ac446a97 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalExtension/OneSignalAttachmentHandler.m +++ b/iOS_SDK/OneSignalSDK/OneSignalExtension/OneSignalAttachmentHandler.m @@ -49,7 +49,7 @@ @implementation DirectDownloadDelegate -(void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask didReceiveData:(NSData *)data { NSError *fileHandleError; if (![outputHandle writeData:data error:&fileHandleError]) { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"OneSignal Error encountered while downloading attachment: %@", fileHandleError]]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:[NSString stringWithFormat:@"OneSignal Error encountered while downloading attachment: %@", fileHandleError]]; } } @@ -271,7 +271,7 @@ + (NSString *)downloadMediaAndSaveInBundle:(NSString *)urlString { let mimeType = [NSURLSession downloadItemAtURL:url toFile:filePath error:&error]; if (error) { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"Encountered an error while attempting to download file with URL: %@", error]]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:[NSString stringWithFormat:@"Encountered an error while attempting to download file with URL: %@", error]]; return nil; } @@ -286,7 +286,7 @@ + (NSString *)downloadMediaAndSaveInBundle:(NSString *)urlString { [[NSFileManager defaultManager] moveItemAtPath:filePath toPath:newPath error:&error]; if (error) { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"Encountered an error while attempting to download file with URL: %@", error]]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:[NSString stringWithFormat:@"Encountered an error while attempting to download file with URL: %@", error]]; return nil; } @@ -304,7 +304,7 @@ + (NSString *)downloadMediaAndSaveInBundle:(NSString *)urlString { [standardUserDefaults saveObjectForKey:OSUD_TEMP_CACHED_NOTIFICATION_MEDIA withValue:appendedCache]; return name; } @catch (NSException *exception) { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"OneSignal encountered an exception while downloading file (%@), exception: %@", url, exception.description]]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:[NSString stringWithFormat:@"OneSignal encountered an exception while downloading file (%@), exception: %@", url, exception.description]]; return nil; } diff --git a/iOS_SDK/OneSignalSDK/OneSignalExtension/OneSignalNotificationServiceExtensionHandler.m b/iOS_SDK/OneSignalSDK/OneSignalExtension/OneSignalNotificationServiceExtensionHandler.m index 3815453408..3309e27f29 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalExtension/OneSignalNotificationServiceExtensionHandler.m +++ b/iOS_SDK/OneSignalSDK/OneSignalExtension/OneSignalNotificationServiceExtensionHandler.m @@ -153,7 +153,10 @@ + (void)onNotificationReceived:(NSString *)receivedNotificationId withBlockingTa dispatch_semaphore_signal(semaphore); } } failureBlock:^(NSError *error) { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"OneSignal onNotificationReceived sendReceiveReceipt Failed for playerId: %@ error: %@", playerId, error]]; + // The error is nil when no receipt was attempted, such as when receipts are disabled. + if (error) { + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:[NSString stringWithFormat:@"OneSignal onNotificationReceived sendReceiveReceipt Failed for playerId: %@ error: %@", playerId, error]]; + } if (semaphore) { dispatch_semaphore_signal(semaphore); } diff --git a/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/Controller/OSMessagingController.m b/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/Controller/OSMessagingController.m index 52039366a5..67834062ad 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/Controller/OSMessagingController.m +++ b/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/Controller/OSMessagingController.m @@ -657,7 +657,7 @@ - (void)resetRedisplayMessagesBySession { - (void)deleteInactiveMessage:(OSInAppMessageInternal *)message { let deleteMessage = [NSString stringWithFormat:@"Deleting inactive in-app message from cache: %@", message.messageId]; - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:deleteMessage]; + [OneSignalLog onesignalLog:ONE_S_LL_DEBUG message:deleteMessage]; NSMutableArray *newMessagesArray = [NSMutableArray arrayWithArray:self.messages]; [newMessagesArray removeObject: message]; self.messages = newMessagesArray; @@ -872,7 +872,7 @@ - (void)messageViewPageImpressionRequest:(OSInAppMessageInternal *)message withP } onFailure:^(OneSignalClientError *error) { NSString *errorMessage = [NSString stringWithFormat:@"In App Message with message id: %@ and page id: %@, failed POST page impression update with error: %@", message.messageId, pageId, error.message]; - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:errorMessage]; + [OneSignalLog onesignalLog:ONE_S_LL_INFO message:errorMessage]; if (message) { [self.viewedPageIDs removeObject:messagePrefixedPageId]; } @@ -912,7 +912,7 @@ - (void)messageViewImpressionRequest:(OSInAppMessageInternal *)message { } onFailure:^(OneSignalClientError *error) { NSString *errorMessage = [NSString stringWithFormat:@"In App Message with id: %@, failed POST impression update with error: %@", message.messageId, error.message]; - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:errorMessage]; + [OneSignalLog onesignalLog:ONE_S_LL_INFO message:errorMessage]; // If the post failed, remove the messageId from the impressionedInAppMessages set [self.impressionedInAppMessages removeObject:message.messageId]; @@ -1333,7 +1333,7 @@ - (void)sendClickRESTCall:(OSInAppMessageInternal *)message withAction:(OSInAppM } onFailure:^(OneSignalClientError *error) { NSString *errorMessage = [NSString stringWithFormat:@"In App Message with id: %@, failed POST click update for click id: %@, with error: %@", message.messageId, action.clickId, error.message]; - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:errorMessage]; + [OneSignalLog onesignalLog:ONE_S_LL_INFO message:errorMessage]; // Remove clickId from local clickedClickIds since click was not tracked [self.clickedClickIds removeObject:action.clickId]; @@ -1359,7 +1359,7 @@ - (void)sendOutcomes:(NSArray*)outcomes forMessageId:(N - (void)sendClickActionOutcomes:(NSArray *)outcomes { if (![OSOutcomes sharedController]) { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"Make sure OneSignal init is called first"]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"Make sure OneSignal init is called first"]; return; } diff --git a/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/Model/OSInAppMessageLocationPrompt.m b/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/Model/OSInAppMessageLocationPrompt.m index b5d0e8d60c..e6af50dc86 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/Model/OSInAppMessageLocationPrompt.m +++ b/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/Model/OSInAppMessageLocationPrompt.m @@ -63,7 +63,7 @@ - (void)handlePrompt:(void (^)(PromptActionResult result))completionHandler { [invocation setArgument: &completionHandler atIndex: 3]; [invocation invoke]; } else { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OneSignalLocation not found. In order to use OneSignal's location features the OneSignalLocation module must be added."]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"OneSignalLocation not found. In order to use OneSignal's location features the OneSignalLocation module must be added."]; } } diff --git a/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/UI/OSInAppMessageView.m b/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/UI/OSInAppMessageView.m index 3929b5b43b..3fd6585df2 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/UI/OSInAppMessageView.m +++ b/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/UI/OSInAppMessageView.m @@ -212,7 +212,7 @@ - (void)resetWebViewToMaxBoundsAndResizeHeight:(void (^) (NSNumber * _Nullable n [self.webView evaluateJavaScript:OS_JS_GET_PAGE_META_DATA_METHOD completionHandler:^(NSDictionary *result, NSError *error) { if (error) { NSString *errorMessage = [NSString stringWithFormat:@"Javascript Method: %@ Evaluated with Error: %@", OS_JS_GET_PAGE_META_DATA_METHOD, error]; - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:errorMessage]; + [OneSignalLog onesignalLog:ONE_S_LL_INFO message:errorMessage]; // Still complete so a rotation or fold re-shows the message at its previous height [self setupWebViewConstraints]; completion(nil); @@ -236,7 +236,7 @@ - (void)updateSafeAreaInsets:(UIEdgeInsets)insets { [self.webView evaluateJavaScript:setInsetsString completionHandler:^(NSDictionary *result, NSError * _Nullable error) { if (error) { NSString *errorMessage = [NSString stringWithFormat:@"Javascript Method: %@ Evaluated with Error: %@", OS_SET_SAFE_AREA_INSETS_METHOD, error]; - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:errorMessage]; + [OneSignalLog onesignalLog:ONE_S_LL_INFO message:errorMessage]; return; } NSString *successMessage = [NSString stringWithFormat:@"Javascript Method: %@ Evaluated with Success: %@", OS_SET_SAFE_AREA_INSETS_METHOD, result]; diff --git a/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/UI/OSInAppMessageViewController.m b/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/UI/OSInAppMessageViewController.m index ce7a2196b5..d6ae92e3f9 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/UI/OSInAppMessageViewController.m +++ b/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/UI/OSInAppMessageViewController.m @@ -396,7 +396,7 @@ - (void)encounteredErrorLoadingMessageContent:(NSError * _Nullable)error { if (error.code == 410 || error.code == 404) { [self.delegate messageIsNotActive:self.message]; } - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:message]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:message]; } - (void)viewDidLayoutSubviews { diff --git a/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/UI/OneSignalWebView.m b/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/UI/OneSignalWebView.m index 06910b334a..22ba8b6b7e 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/UI/OneSignalWebView.m +++ b/iOS_SDK/OneSignalSDK/OneSignalInAppMessages/UI/OneSignalWebView.m @@ -91,7 +91,7 @@ -(void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigati } -(void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"webView: An error occurred during navigation: %@", error]]; + [OneSignalLog onesignalLog:ONE_S_LL_INFO message:[NSString stringWithFormat:@"webView: An error occurred during navigation: %@", error]]; } - (void)pinSubviewToMarginsWithSubview:(UIView *)subview withSuperview:(UIView *)superview { diff --git a/iOS_SDK/OneSignalSDK/OneSignalLocation/OneSignalLocationManager.m b/iOS_SDK/OneSignalSDK/OneSignalLocation/OneSignalLocationManager.m index 9fc2403aa5..b20566d8fe 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalLocation/OneSignalLocationManager.m +++ b/iOS_SDK/OneSignalSDK/OneSignalLocation/OneSignalLocationManager.m @@ -309,7 +309,7 @@ + (void)internalGetLocation:(bool)prompt fallbackToSettings:(BOOL)fallback { } else { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"Include a privacy NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription in your info.plist to request location permissions."]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"Include a privacy NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription in your info.plist to request location permissions."]; [self sendAndClearLocationListener:LOCATION_PERMISSIONS_MISSING_INFO_PLIST]; } @@ -406,7 +406,7 @@ - (void)locationManager:(id)manager didUpdateLocations:(NSArray *)locations { } - (void)locationManager:(id)manager didFailWithError:(NSError *)error { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"CLLocationManager did fail with error: %@", error]]; + [OneSignalLog onesignalLog:ONE_S_LL_INFO message:[NSString stringWithFormat:@"CLLocationManager did fail with error: %@", error]]; [OneSignalLocationManager sendAndClearLocationListener:ERROR]; if ([OneSignalLocationManager backgroundTaskIsActive]) { [OneSignalLocationManager endTask]; diff --git a/iOS_SDK/OneSignalSDK/OneSignalNotifications/OSNotification+OneSignal.m b/iOS_SDK/OneSignalSDK/OneSignalNotifications/OSNotification+OneSignal.m index b2f9cefb11..41f5aefddd 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalNotifications/OSNotification+OneSignal.m +++ b/iOS_SDK/OneSignalSDK/OneSignalNotifications/OSNotification+OneSignal.m @@ -64,7 +64,7 @@ - (void)setCompletionBlock:(OSNotificationDisplayResponse)completion { - (void)display { if (!_completion) { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OSNotificationWillDisplayEvent.notification.display cannot be called due to timing out or notification was already displayed."]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"OSNotificationWillDisplayEvent.notification.display cannot be called due to timing out or notification was already displayed."]; } [self complete:self]; } diff --git a/iOS_SDK/OneSignalSDK/OneSignalNotifications/OSNotificationsManager.m b/iOS_SDK/OneSignalSDK/OneSignalNotifications/OSNotificationsManager.m index 790eb988ed..3f068a08da 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalNotifications/OSNotificationsManager.m +++ b/iOS_SDK/OneSignalSDK/OneSignalNotifications/OSNotificationsManager.m @@ -394,7 +394,7 @@ + (void)presentAppSettings { if ([[UIApplication sharedApplication] canOpenURL:url]) { [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil]; } else { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"Unable to open settings for this application"]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"Unable to open settings for this application"]; } } @@ -472,15 +472,15 @@ + (void)processFailedRemoteNotificationsRegistration:(NSError*)err { if (err.code == 3000) { [self setSubscriptionErrorStatus:ERROR_PUSH_CAPABLILITY_DISABLED]; - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"ERROR! 'Push Notifications' capability missing! Add the capability in Xcode under 'Target' -> '' -> 'Signing & Capabilities' then click the '+ Capability' button."]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"ERROR! 'Push Notifications' capability missing! Add the capability in Xcode under 'Target' -> '' -> 'Signing & Capabilities' then click the '+ Capability' button."]; } else if (err.code == 3010) { [self setSubscriptionErrorStatus:ERROR_PUSH_SIMULATOR_NOT_SUPPORTED]; - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"Error! iOS Simulator does not support push! Please test on a real iOS device. Error: %@", err]]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:[NSString stringWithFormat:@"Error! iOS Simulator does not support push! Please test on a real iOS device. Error: %@", err]]; } else { [self setSubscriptionErrorStatus:ERROR_PUSH_UNKNOWN_APNS_ERROR]; - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"Error registering for Apple push notifications! Error: %@", err]]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:[NSString stringWithFormat:@"Error registering for Apple push notifications! Error: %@", err]]; } } @@ -1050,7 +1050,7 @@ + (void)setBadgeCount:(NSInteger)badgeCount { if (@available(iOS 16.0, *)) { [[UNUserNotificationCenter currentNotificationCenter] setBadgeCount:badgeCount withCompletionHandler:^(NSError * _Nullable error) { if (error) { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:[NSString stringWithFormat:@"setBadgeCount encountered error setting badge count: %@", error]]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:[NSString stringWithFormat:@"setBadgeCount encountered error setting badge count: %@", error]]; } }]; } else { diff --git a/iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/OSInputGuard.swift b/iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/OSInputGuard.swift index 20a2efa34c..0c1e97f494 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/OSInputGuard.swift +++ b/iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/OSInputGuard.swift @@ -34,13 +34,13 @@ public final class OSInputGuard: NSObject { public static func isMissing(_ value: String?, _ api: String) -> Bool { // A NUL cannot be stored in a text column, so it is never a usable value. if let value, value.contains("\u{0000}") { - OneSignalLog.onesignalLog(.LL_ERROR, message: "\(api) contains a null byte") + OneSignalLog.onesignalLog(.LL_WARN, message: "\(api) contains a null byte") return true } if let value, !value.isEmpty { return false } - OneSignalLog.onesignalLog(.LL_ERROR, message: "\(api) is required") + OneSignalLog.onesignalLog(.LL_WARN, message: "\(api) is required") return true } diff --git a/iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/OSModelStore.swift b/iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/OSModelStore.swift index b35978a846..8e8e1aaaed 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/OSModelStore.swift +++ b/iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/OSModelStore.swift @@ -151,7 +151,7 @@ open class OSModelStore: NSObject { // persist the models (with removed model) to storage OneSignalUserDefaults.initShared().saveCodeableData(forKey: self.storeKey, withValue: self.models) } else { - OneSignalLog.onesignalLog(.LL_ERROR, message: "OSModelStore cannot remove \(id) because it doesn't exist in the store.") + OneSignalLog.onesignalLog(.LL_WARN, message: "OSModelStore cannot remove \(id) because it doesn't exist in the store.") return } } diff --git a/iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/OSStubLiveActivities.swift b/iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/OSStubLiveActivities.swift index 6360b564fc..4e5426a3cb 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/OSStubLiveActivities.swift +++ b/iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/OSStubLiveActivities.swift @@ -39,6 +39,6 @@ public class OSStubLiveActivities: NSObject, OSLiveActivities { private static func logUnavailable() { let message = "OneSignalLiveActivities not found. In order to use OneSignal's " + "LiveActivities features the OneSignalLiveActivities module must be added." - OneSignalLog.onesignalLog(.LL_ERROR, message: message) + OneSignalLog.onesignalLog(.LL_WARN, message: message) } } diff --git a/iOS_SDK/OneSignalSDK/OneSignalOutcomes/OSOutcomes.m b/iOS_SDK/OneSignalSDK/OneSignalOutcomes/OSOutcomes.m index 88df80b148..264b3dfe7b 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalOutcomes/OSOutcomes.m +++ b/iOS_SDK/OneSignalSDK/OneSignalOutcomes/OSOutcomes.m @@ -96,7 +96,7 @@ + (void)addOutcome:(NSString * _Nonnull)name { return; } if (!_sharedController) { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"Attempted to call OneSignal.Session before init. Make sure OneSignal init is called first."]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"Attempted to call OneSignal.Session before init. Make sure OneSignal init is called first."]; return; } @@ -108,7 +108,7 @@ + (void)addOutcomeWithValue:(NSString * _Nonnull)name value:(NSNumber * _Nonnull return; } if (!_sharedController) { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"Attempted to call OneSignal.Session before init. Make sure OneSignal init is called first."]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"Attempted to call OneSignal.Session before init. Make sure OneSignal init is called first."]; return; } @@ -120,7 +120,7 @@ + (void)addUniqueOutcome:(NSString * _Nonnull)name { return; } if (!_sharedController) { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"Attempted to call OneSignal.Session before init. Make sure OneSignal init is called first."]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"Attempted to call OneSignal.Session before init. Make sure OneSignal init is called first."]; return; } diff --git a/iOS_SDK/OneSignalSDK/OneSignalOutcomes/Source/OutcomeEvents/OneSignalOutcomeEventsController.m b/iOS_SDK/OneSignalSDK/OneSignalOutcomes/Source/OutcomeEvents/OneSignalOutcomeEventsController.m index d792ae8cc3..6ad9489238 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalOutcomes/Source/OutcomeEvents/OneSignalOutcomeEventsController.m +++ b/iOS_SDK/OneSignalSDK/OneSignalOutcomes/Source/OutcomeEvents/OneSignalOutcomeEventsController.m @@ -123,7 +123,7 @@ - (void)sendSessionEndOutcomes:(NSNumber * _Nonnull)timeElapsed successBlock(result); } } onFailure:^(OneSignalClientError *error) { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OneSignalOutcomeEventsController:sendSessionEndOutcomes failed"]; + [OneSignalLog onesignalLog:ONE_S_LL_DEBUG message:@"OneSignalOutcomeEventsController:sendSessionEndOutcomes failed"]; if (failureBlock) { failureBlock(error.underlyingError); } @@ -361,7 +361,7 @@ - (void)addUniqueOutcome:(NSString * _Nonnull)name { - (BOOL)isValidOutcomeEntry:(NSString * _Nonnull)name { if (!name || [name length] == 0) { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"Outcome name must not be null or empty"]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"Outcome name must not be null or empty"]; return false; } @@ -370,7 +370,7 @@ - (BOOL)isValidOutcomeEntry:(NSString * _Nonnull)name { - (BOOL)isValidOutcomeValue:(NSNumber *)value { if (!value || value.intValue <= 0) { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"Outcome value must not be null or 0"]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"Outcome value must not be null or 0"]; return false; } diff --git a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSCustomEventsExecutor.swift b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSCustomEventsExecutor.swift index 185ded8a3e..08fcdeecff 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSCustomEventsExecutor.swift +++ b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSCustomEventsExecutor.swift @@ -352,16 +352,19 @@ class OSCustomEventsExecutor: OSOperationExecutor { } } } onFailure: { error in - OneSignalLog.onesignalLog(.LL_ERROR, message: "OSCustomEventsExecutor request failed with error: \(error.debugDescription)") + let message = "OSCustomEventsExecutor request failed with error: \(error.debugDescription)" self.dispatchQueue.async { let responseType = OSNetworkingUtils.getResponseStatusType(error.code) if responseType == .unauthorized, self.auth.handleUnauthorized(request) { + OneSignalLog.onesignalLog(.LL_INFO, message: message) OneSignalLog.onesignalLog(.LL_DEBUG, message: "OSCustomEventsExecutor holding \(request) for a new token") } else if responseType != .retryable { + OneSignalLog.onesignalLog(.LL_WARN, message: message) // Fail, no retry, remove from cache and queue self.requestQueue.removeAll(where: { $0 == request}) OneSignalUserDefaults.initShared().saveCodeableData(forKey: OS_CUSTOM_EVENTS_EXECUTOR_REQUEST_QUEUE_KEY, withValue: self.requestQueue) } else { + OneSignalLog.onesignalLog(.LL_INFO, message: message) self.retryBackoff.recordFailure(request, error: error) request.sentToClient = false } diff --git a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSIdentityOperationExecutor.swift b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSIdentityOperationExecutor.swift index 4c85052b79..2de9cb32fa 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSIdentityOperationExecutor.swift +++ b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSIdentityOperationExecutor.swift @@ -67,7 +67,7 @@ class OSIdentityOperationExecutor: OSOperationExecutor { delta.model = modelInStore } else { // The model does not exist, drop this Delta - OneSignalLog.onesignalLog(.LL_ERROR, message: "OSIdentityOperationExecutor.init dropped \(delta)") + OneSignalLog.onesignalLog(.LL_WARN, message: "OSIdentityOperationExecutor.init dropped \(delta)") deltaQueue.remove(at: index) } } @@ -92,7 +92,7 @@ class OSIdentityOperationExecutor: OSOperationExecutor { OneSignalUserManagerImpl.sharedInstance.addIdentityModelToRepo(request.identityModel) } else { // 3. The model do not exist AND this request cannot be sent, drop this Request - OneSignalLog.onesignalLog(.LL_ERROR, message: "OSIdentityOperationExecutor.init dropped \(request)") + OneSignalLog.onesignalLog(.LL_WARN, message: "OSIdentityOperationExecutor.init dropped \(request)") addRequestQueue.remove(at: index) } } @@ -117,7 +117,7 @@ class OSIdentityOperationExecutor: OSOperationExecutor { OneSignalUserManagerImpl.sharedInstance.addIdentityModelToRepo(request.identityModel) } else { // 3. The model does not exist AND this request cannot be sent, drop this Request - OneSignalLog.onesignalLog(.LL_ERROR, message: "OSIdentityOperationExecutor.init dropped \(request)") + OneSignalLog.onesignalLog(.LL_WARN, message: "OSIdentityOperationExecutor.init dropped \(request)") removeRequestQueue.remove(at: index) } } @@ -273,10 +273,11 @@ class OSIdentityOperationExecutor: OSOperationExecutor { } } } onFailure: { error in - OneSignalLog.onesignalLog(.LL_ERROR, message: "OSIdentityOperationExecutor add aliases request failed with error: \(error.debugDescription)") + let message = "OSIdentityOperationExecutor add aliases request failed with error: \(error.debugDescription)" self.dispatchQueue.async { let responseType = OSNetworkingUtils.getResponseStatusType(error.code) if responseType == .missing { + OneSignalLog.onesignalLog(.LL_WARN, message: message) // Remove from cache and queue self.addRequestQueue.removeAll(where: { $0 == request}) OneSignalUserDefaults.initShared().saveCodeableData(forKey: OS_IDENTITY_EXECUTOR_ADD_REQUEST_QUEUE_KEY, withValue: self.addRequestQueue) @@ -292,12 +293,15 @@ class OSIdentityOperationExecutor: OSOperationExecutor { OneSignalUserManagerImpl.sharedInstance.pushSubscriptionModel?.subscriptionId = nil OneSignalUserManagerImpl.sharedInstance._logout() } else if responseType == .unauthorized, self.auth.handleUnauthorized(request) { + OneSignalLog.onesignalLog(.LL_INFO, message: message) OneSignalLog.onesignalLog(.LL_DEBUG, message: "OSIdentityOperationExecutor holding \(request) for a new token") } else if responseType != .retryable { + OneSignalLog.onesignalLog(.LL_WARN, message: message) // Fail, no retry, remove from cache and queue self.addRequestQueue.removeAll(where: { $0 == request}) OneSignalUserDefaults.initShared().saveCodeableData(forKey: OS_IDENTITY_EXECUTOR_ADD_REQUEST_QUEUE_KEY, withValue: self.addRequestQueue) } else { + OneSignalLog.onesignalLog(.LL_INFO, message: message) self.retryBackoff.recordFailure(request, error: error) request.sentToClient = false } @@ -335,17 +339,20 @@ class OSIdentityOperationExecutor: OSOperationExecutor { } } } onFailure: { error in - OneSignalLog.onesignalLog(.LL_ERROR, message: "OSIdentityOperationExecutor remove alias request failed with error: \(error.debugDescription)") + let message = "OSIdentityOperationExecutor remove alias request failed with error: \(error.debugDescription)" self.dispatchQueue.async { let responseType = OSNetworkingUtils.getResponseStatusType(error.code) if responseType == .unauthorized, self.auth.handleUnauthorized(request) { + OneSignalLog.onesignalLog(.LL_INFO, message: message) OneSignalLog.onesignalLog(.LL_DEBUG, message: "OSIdentityOperationExecutor holding \(request) for a new token") } else if responseType != .retryable { // Fail, no retry, remove from cache and queue // A response of .missing could mean the alias doesn't exist on this user OR this user has been deleted + OneSignalLog.onesignalLog(responseType == .missing ? .LL_INFO : .LL_WARN, message: message) self.removeRequestQueue.removeAll(where: { $0 == request}) OneSignalUserDefaults.initShared().saveCodeableData(forKey: OS_IDENTITY_EXECUTOR_REMOVE_REQUEST_QUEUE_KEY, withValue: self.removeRequestQueue) } else { + OneSignalLog.onesignalLog(.LL_INFO, message: message) self.retryBackoff.recordFailure(request, error: error) request.sentToClient = false } diff --git a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSPropertyOperationExecutor.swift b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSPropertyOperationExecutor.swift index aef7f8676b..b45a66a27f 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSPropertyOperationExecutor.swift +++ b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSPropertyOperationExecutor.swift @@ -183,7 +183,7 @@ class OSPropertyOperationExecutor: OSOperationExecutor { for delta in self.deltaQueue { guard let identityModel = OneSignalUserManagerImpl.sharedInstance.getIdentityModel(delta.identityModelId) else { - OneSignalLog.onesignalLog(.LL_ERROR, message: "OSPropertyOperationExecutor.processDeltaQueue dropped: \(delta)") + OneSignalLog.onesignalLog(.LL_WARN, message: "OSPropertyOperationExecutor.processDeltaQueue dropped: \(delta)") continue } let combinedSoFar: OSCombinedProperties? = combinedProperties[identityModel.modelId] @@ -326,10 +326,11 @@ class OSPropertyOperationExecutor: OSOperationExecutor { OSConsistencyManager.shared.setRywTokenAndDelay(id: onesignalId, key: OSIamFetchOffsetKey.userUpdate, value: rywData) } } onFailure: { error in - OneSignalLog.onesignalLog(.LL_ERROR, message: "OSPropertyOperationExecutor update properties request failed with error: \(error.debugDescription)") + let message = "OSPropertyOperationExecutor update properties request failed with error: \(error.debugDescription)" self.dispatchQueue.async { let responseType = OSNetworkingUtils.getResponseStatusType(error.code) if responseType == .missing { + OneSignalLog.onesignalLog(.LL_WARN, message: message) // remove from cache and queue self.updateRequestQueue.removeAll(where: { $0 == request}) OneSignalUserDefaults.initShared().saveCodeableData(forKey: OS_PROPERTIES_EXECUTOR_UPDATE_REQUEST_QUEUE_KEY, withValue: self.updateRequestQueue) @@ -345,12 +346,15 @@ class OSPropertyOperationExecutor: OSOperationExecutor { OneSignalUserManagerImpl.sharedInstance.pushSubscriptionModel?.subscriptionId = nil OneSignalUserManagerImpl.sharedInstance._logout() } else if responseType == .unauthorized, self.auth.handleUnauthorized(request) { + OneSignalLog.onesignalLog(.LL_INFO, message: message) OneSignalLog.onesignalLog(.LL_DEBUG, message: "OSPropertyOperationExecutor holding \(request) for a new token") } else if responseType != .retryable { + OneSignalLog.onesignalLog(.LL_WARN, message: message) // Fail, no retry, remove from cache and queue self.updateRequestQueue.removeAll(where: { $0 == request}) OneSignalUserDefaults.initShared().saveCodeableData(forKey: OS_PROPERTIES_EXECUTOR_UPDATE_REQUEST_QUEUE_KEY, withValue: self.updateRequestQueue) } else { + OneSignalLog.onesignalLog(.LL_INFO, message: message) self.retryBackoff.recordFailure(request, error: error) request.sentToClient = false } diff --git a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSSessionOperationExecutor.swift b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSSessionOperationExecutor.swift index 68e4c9c68f..9ff0aa3e18 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSSessionOperationExecutor.swift +++ b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSSessionOperationExecutor.swift @@ -502,16 +502,18 @@ private extension OSSessionOperationExecutor { } func handleFailure(_ request: OSSessionRequest, error: OneSignalClientError) { - OneSignalLog.onesignalLog(.LL_ERROR, message: "OSSessionOperationExecutor \(request) failed with status \(error.code)") + let message = "OSSessionOperationExecutor \(request) failed with status \(error.code)" let code = error.code if (200..<300).contains(code) { // `OneSignalClient` reports a 2xx whose body failed to parse as a failure. handleSuccess(request, response: nil) } else if code == 0 || code == 408 || code == 429 || code >= 500 { // 0 means no HTTP response: no network or a timeout. + OneSignalLog.onesignalLog(.LL_INFO, message: message) retry(request, error: error) } else if code == 404 && isInMissingRetryWindow(request) { // The backend may not have the just-created record yet. + OneSignalLog.onesignalLog(.LL_INFO, message: message) retry(request, error: error) } else { // Any other 4xx, or a missing app ID, which the client reports as a negative code. diff --git a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSSubscriptionOperationExecutor.swift b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSSubscriptionOperationExecutor.swift index 538859c837..2f3923a345 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSSubscriptionOperationExecutor.swift +++ b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSSubscriptionOperationExecutor.swift @@ -67,7 +67,7 @@ class OSSubscriptionOperationExecutor: OSOperationExecutor { delta.model = modelInStore } else { // The model does not exist, drop this Delta - OneSignalLog.onesignalLog(.LL_ERROR, message: "OSSubscriptionOperationExecutor.init dropped \(delta)") + OneSignalLog.onesignalLog(.LL_WARN, message: "OSSubscriptionOperationExecutor.init dropped \(delta)") deltaQueue.remove(at: index) } } @@ -129,7 +129,7 @@ class OSSubscriptionOperationExecutor: OSOperationExecutor { } else if !auth.keepUncachedOwned(request), !request.prepareForExecution(newRecordsState: newRecordsState, auth: auth) { // 3. The model does not exist AND no token can arrive to make this sendable, drop it - OneSignalLog.onesignalLog(.LL_ERROR, message: "OSSubscriptionOperationExecutor.init dropped \(request)") + OneSignalLog.onesignalLog(.LL_WARN, message: "OSSubscriptionOperationExecutor.init dropped \(request)") removeRequestQueue.remove(at: index) continue } @@ -153,7 +153,7 @@ class OSSubscriptionOperationExecutor: OSOperationExecutor { request.subscriptionModel = subscriptionModel } else if !request.prepareForExecution(newRecordsState: newRecordsState, auth: auth) { // 3. The models do not exist AND this request cannot be sent, drop this Request - OneSignalLog.onesignalLog(.LL_ERROR, message: "OSSubscriptionOperationExecutor.init dropped \(request)") + OneSignalLog.onesignalLog(.LL_WARN, message: "OSSubscriptionOperationExecutor.init dropped \(request)") updateRequestQueue.remove(at: index) continue } @@ -265,7 +265,7 @@ class OSSubscriptionOperationExecutor: OSOperationExecutor { ) self.addRequestQueue.append(request) } else { - OneSignalLog.onesignalLog(.LL_ERROR, message: "OSSubscriptionOperationExecutor.processDeltaQueue dropped \(delta)") + OneSignalLog.onesignalLog(.LL_WARN, message: "OSSubscriptionOperationExecutor.processDeltaQueue dropped \(delta)") } case OS_REMOVE_SUBSCRIPTION_DELTA: let request = OSRequestDeleteSubscription( @@ -389,10 +389,11 @@ extension OSSubscriptionOperationExecutor { } } } onFailure: { error in - OneSignalLog.onesignalLog(.LL_ERROR, message: "OSSubscriptionOperationExecutor create subscription request failed with error: \(error.debugDescription)") + let message = "OSSubscriptionOperationExecutor create subscription request failed with error: \(error.debugDescription)" self.dispatchQueue.async { let responseType = OSNetworkingUtils.getResponseStatusType(error.code) if responseType == .missing { + OneSignalLog.onesignalLog(.LL_WARN, message: message) self.addRequestQueue.removeAll(where: { $0 == request}) OneSignalUserDefaults.initShared().saveCodeableData(forKey: OS_SUBSCRIPTION_EXECUTOR_ADD_REQUEST_QUEUE_KEY, withValue: self.addRequestQueue) // Logout only if this request's user is still current, so a concurrent login can't log out the wrong user. @@ -407,12 +408,15 @@ extension OSSubscriptionOperationExecutor { OneSignalUserManagerImpl.sharedInstance.pushSubscriptionModel?.subscriptionId = nil OneSignalUserManagerImpl.sharedInstance._logout() } else if responseType == .unauthorized, self.auth.handleUnauthorized(request) { + OneSignalLog.onesignalLog(.LL_INFO, message: message) OneSignalLog.onesignalLog(.LL_DEBUG, message: "OSSubscriptionOperationExecutor holding \(request) for a new token") } else if responseType != .retryable { + OneSignalLog.onesignalLog(.LL_WARN, message: message) // Fail, no retry, remove from cache and queue self.addRequestQueue.removeAll(where: { $0 == request}) OneSignalUserDefaults.initShared().saveCodeableData(forKey: OS_SUBSCRIPTION_EXECUTOR_ADD_REQUEST_QUEUE_KEY, withValue: self.addRequestQueue) } else { + OneSignalLog.onesignalLog(.LL_INFO, message: message) self.retryBackoff.recordFailure(request, error: error) request.sentToClient = false } @@ -450,16 +454,18 @@ extension OSSubscriptionOperationExecutor { } } } onFailure: { error in - OneSignalLog.onesignalLog(.LL_ERROR, message: "OSSubscriptionOperationExecutor delete subscription request failed with error: \(error.debugDescription)") + let message = "OSSubscriptionOperationExecutor delete subscription request failed with error: \(error.debugDescription)" self.dispatchQueue.async { let responseType = OSNetworkingUtils.getResponseStatusType(error.code) // No token handling: the delete is never signed, so a 401 here is not about the user's JWT. if responseType != .retryable { // Fail, no retry, remove from cache and queue // If this request returns a missing status, that is ok as this is a delete request + OneSignalLog.onesignalLog(responseType == .missing ? .LL_INFO : .LL_WARN, message: message) self.removeRequestQueue.removeAll(where: { $0 == request}) OneSignalUserDefaults.initShared().saveCodeableData(forKey: OS_SUBSCRIPTION_EXECUTOR_REMOVE_REQUEST_QUEUE_KEY, withValue: self.removeRequestQueue) } else { + OneSignalLog.onesignalLog(.LL_INFO, message: message) self.retryBackoff.recordFailure(request, error: error) request.sentToClient = false } @@ -513,15 +519,17 @@ extension OSSubscriptionOperationExecutor { } } } onFailure: { error in - OneSignalLog.onesignalLog(.LL_ERROR, message: "OSSubscriptionOperationExecutor update subscription request failed with error: \(error.debugDescription)") + let message = "OSSubscriptionOperationExecutor update subscription request failed with error: \(error.debugDescription)" self.dispatchQueue.async { let responseType = OSNetworkingUtils.getResponseStatusType(error.code) if responseType != .retryable { + OneSignalLog.onesignalLog(.LL_WARN, message: message) // Fail, no retry, remove from cache and queue self.updateRequestQueue.removeAll(where: { $0 == request}) OneSignalUserDefaults.initShared().saveCodeableData(forKey: OS_SUBSCRIPTION_EXECUTOR_UPDATE_REQUEST_QUEUE_KEY, withValue: self.updateRequestQueue) self.executeNextPendingUpdateSubscription(for: modelId, inBackground: inBackground) } else { + OneSignalLog.onesignalLog(.LL_INFO, message: message) self.retryBackoff.recordFailure(request, error: error) request.sentToClient = false } diff --git a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSUserExecutor.swift b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSUserExecutor.swift index 80b500fced..0e7f932feb 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSUserExecutor.swift +++ b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSUserExecutor.swift @@ -233,7 +233,7 @@ class OSUserExecutor { } userRequestQueue.append(req) } else { - OneSignalLog.onesignalLog(.LL_ERROR, message: "OSUserExecutor.start() dropped: \(request)") + OneSignalLog.onesignalLog(.LL_WARN, message: "OSUserExecutor.start() dropped: \(request)") } } } @@ -537,9 +537,10 @@ extension OSUserExecutor { } OneSignalUserManagerImpl.sharedInstance.operationRepo.paused = false } onFailure: { error in - OneSignalLog.onesignalLog(.LL_ERROR, message: "OSUserExecutor create user request failed with error: \(error.debugDescription)") + let message = "OSUserExecutor create user request failed with error: \(error.debugDescription)" let responseType = OSNetworkingUtils.getResponseStatusType(error.code) if responseType == .unauthorized, self.auth.handleUnauthorized(request) { + OneSignalLog.onesignalLog(.LL_INFO, message: message) // Held rather than paused: `updateUserJwt` resumes work by flushing, which a paused Repo drops. // Ordering does not need the pause — every Request for this user waits on an `onesignal_id`. OneSignalLog.onesignalLog(.LL_DEBUG, message: "OSUserExecutor holding \(request) for a new token") @@ -547,6 +548,7 @@ extension OSUserExecutor { // re-enter so that token is used now rather than waiting on another wake. self.executePendingRequests() } else if responseType != .retryable { + OneSignalLog.onesignalLog(.LL_ERROR, message: message) // A failed create user request would leave the SDK in a bad state // Don't remove the request from cache and pause the operation repo // We will retry this request on a new session. Stays marked as sent until then, so other @@ -564,6 +566,7 @@ extension OSUserExecutor { } } } else { + OneSignalLog.onesignalLog(.LL_INFO, message: message) self.retryLater(request, error: error) } } @@ -612,13 +615,15 @@ extension OSUserExecutor { self.removeFromQueue(request) } } onFailure: { error in - OneSignalLog.onesignalLog(.LL_ERROR, message: "OSUserExecutor executeFetchIdentityBySubscriptionRequest failed with error: \(error.debugDescription)") + let message = "OSUserExecutor executeFetchIdentityBySubscriptionRequest failed with error: \(error.debugDescription)" let responseType = OSNetworkingUtils.getResponseStatusType(error.code) if responseType != .retryable { + OneSignalLog.onesignalLog(.LL_WARN, message: message) // Fail, no retry, remove the subscription_id but keep the same push subscription model OneSignalUserManagerImpl.sharedInstance.pushSubscriptionModel?.subscriptionId = nil self.removeFromQueue(request) } else { + OneSignalLog.onesignalLog(.LL_INFO, message: message) self.retryLater(request, error: error) } self.executePendingRequests() @@ -753,7 +758,7 @@ extension OSUserExecutor { if !subscriptionExists { // This subscription probably has been deleted - OneSignalLog.onesignalLog(.LL_ERROR, message: "OSUserExecutor.executeFetchUserRequest found this device's push subscription gone, now send the push subscription to server.") + OneSignalLog.onesignalLog(.LL_WARN, message: "OSUserExecutor.executeFetchUserRequest found this device's push subscription gone, now send the push subscription to server.") OneSignalUserManagerImpl.sharedInstance.pushSubscriptionModel?.subscriptionId = nil OneSignalUserManagerImpl.sharedInstance.createPushSubscriptionRequest() } @@ -761,24 +766,29 @@ extension OSUserExecutor { } self.executePendingRequests() } onFailure: { error in - OneSignalLog.onesignalLog(.LL_ERROR, message: "OSUserExecutor executeFetchUserRequest failed with error: \(error.debugDescription)") + let message = "OSUserExecutor executeFetchUserRequest failed with error: \(error.debugDescription)" let responseType = OSNetworkingUtils.getResponseStatusType(error.code) if responseType == .missing { self.removeFromQueue(request) // Logout only if this request's user is still current, so a concurrent login can't log out the wrong user. guard OneSignalUserManagerImpl.sharedInstance.currentUser(matching: request.identityModel.modelId) != nil else { + OneSignalLog.onesignalLog(.LL_INFO, message: message) return } + OneSignalLog.onesignalLog(.LL_WARN, message: message) // The subscription has been deleted along with the user, so remove the subscription_id but keep the same push subscription model OneSignalUserManagerImpl.sharedInstance.pushSubscriptionModel?.subscriptionId = nil OneSignalUserManagerImpl.sharedInstance._logout() } else if responseType == .unauthorized, self.auth.handleUnauthorized(request) { + OneSignalLog.onesignalLog(.LL_INFO, message: message) OneSignalLog.onesignalLog(.LL_DEBUG, message: "OSUserExecutor holding \(request) for a new token") } else if responseType != .retryable { + OneSignalLog.onesignalLog(.LL_WARN, message: message) // If the error is not retryable, remove from cache and queue self.removeFromQueue(request) } else { + OneSignalLog.onesignalLog(.LL_INFO, message: message) self.retryLater(request, error: error) } self.executePendingRequests() diff --git a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSIdentityModelRepo.swift b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSIdentityModelRepo.swift index c1468632e7..c310322b8b 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSIdentityModelRepo.swift +++ b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSIdentityModelRepo.swift @@ -71,7 +71,7 @@ class OSIdentityModelRepo { func updateJwtToken(externalId: String, token: String) -> Bool { let matchingModels = modelsMatching(externalId: externalId) guard !matchingModels.isEmpty else { - OneSignalLog.onesignalLog(.LL_ERROR, message: "OSIdentityModelRepo.updateJwtToken called for unknown external ID \(externalId)") + OneSignalLog.onesignalLog(.LL_WARN, message: "OSIdentityModelRepo.updateJwtToken called for unknown external ID \(externalId)") return false } for model in matchingModels { @@ -97,7 +97,7 @@ class OSIdentityModelRepo { func invalidateJwtToken(externalId: String, rejectedToken: String) -> Bool { let matchingModels = modelsMatching(externalId: externalId) guard !matchingModels.isEmpty else { - OneSignalLog.onesignalLog(.LL_ERROR, message: "OSIdentityModelRepo.invalidateJwtToken called for unknown external ID \(externalId)") + OneSignalLog.onesignalLog(.LL_WARN, message: "OSIdentityModelRepo.invalidateJwtToken called for unknown external ID \(externalId)") return false } for model in matchingModels { diff --git a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSPropertiesModelStoreListener.swift b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSPropertiesModelStoreListener.swift index ec4d5da5b3..7807346f90 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSPropertiesModelStoreListener.swift +++ b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSPropertiesModelStoreListener.swift @@ -52,7 +52,7 @@ class OSPropertiesModelStoreListener: OSModelStoreListener { let userInstance = OneSignalUserManagerImpl.sharedInstance._user, userInstance.propertiesModel.modelId == args.model.modelId else { - OneSignalLog.onesignalLog(.LL_ERROR, message: "OSPropertiesModelStoreListener.getUpdateModelDelta encountered unsupported property: \(args.property), no user instance, or a properties model that is not the current user's") + OneSignalLog.onesignalLog(.LL_WARN, message: "OSPropertiesModelStoreListener.getUpdateModelDelta encountered unsupported property: \(args.property), no user instance, or a properties model that is not the current user's") return nil } let identityModel = userInstance.identityModel diff --git a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSSubscriptionModelStoreListener.swift b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSSubscriptionModelStoreListener.swift index 4d82244422..962bac0f7a 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSSubscriptionModelStoreListener.swift +++ b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSSubscriptionModelStoreListener.swift @@ -43,7 +43,7 @@ class OSSubscriptionModelStoreListener: OSModelStoreListener { guard let userInstance = OneSignalUserManagerImpl.sharedInstance._user, store.getModel(modelId: model.modelId) != nil else { - OneSignalLog.onesignalLog(.LL_ERROR, message: "OSSubscriptionModelStoreListener.getAddModelDelta has no user instance or the model is not in the current store") + OneSignalLog.onesignalLog(.LL_WARN, message: "OSSubscriptionModelStoreListener.getAddModelDelta has no user instance or the model is not in the current store") return nil } let identityModel = userInstance.identityModel @@ -63,7 +63,7 @@ class OSSubscriptionModelStoreListener: OSModelStoreListener { */ func getRemoveModelDelta(_ model: OSSubscriptionModel) -> OSDelta? { guard let userInstance = OneSignalUserManagerImpl.sharedInstance._user else { - OneSignalLog.onesignalLog(.LL_ERROR, message: "OSSubscriptionModelStoreListener.getRemoveModelDelta has no user instance") + OneSignalLog.onesignalLog(.LL_WARN, message: "OSSubscriptionModelStoreListener.getRemoveModelDelta has no user instance") return nil } let identityModel = userInstance.identityModel @@ -85,7 +85,7 @@ class OSSubscriptionModelStoreListener: OSModelStoreListener { // something like the app_version. If the app_version hasn't changed since the last session, there // wouldn't be an update needed (among other system-level properties). guard let userInstance = OneSignalUserManagerImpl.sharedInstance._user else { - OneSignalLog.onesignalLog(.LL_ERROR, message: "OSSubscriptionModelStoreListener.getUpdateModelDelta has no user instance") + OneSignalLog.onesignalLog(.LL_WARN, message: "OSSubscriptionModelStoreListener.getUpdateModelDelta has no user instance") return nil } let identityModel = userInstance.identityModel diff --git a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSUserInternalImpl.swift b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSUserInternalImpl.swift index ff705640ba..f98d4b2446 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSUserInternalImpl.swift +++ b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSUserInternalImpl.swift @@ -92,7 +92,7 @@ class OSUserInternalImpl: NSObject, OSUserInternal { !aliases.values.contains("") else { // log error - OneSignalLog.onesignalLog(.LL_ERROR, message: "OneSignal.User addAliases error: Cannot use \(OS_ONESIGNAL_ID) or \(OS_EXTERNAL_ID) as a alias label. Or, cannot use empty string as an alias ID.") + OneSignalLog.onesignalLog(.LL_WARN, message: "OneSignal.User addAliases error: Cannot use \(OS_ONESIGNAL_ID) or \(OS_EXTERNAL_ID) as a alias label. Or, cannot use empty string as an alias ID.") return } identityModel.addAliases(aliases) @@ -107,7 +107,7 @@ class OSUserInternalImpl: NSObject, OSUserInternal { !labels.contains(OS_EXTERNAL_ID) else { // log error - OneSignalLog.onesignalLog(.LL_ERROR, message: "OneSignal.User removeAliases error: Cannot use \(OS_ONESIGNAL_ID) or \(OS_EXTERNAL_ID) as a alias label.") + OneSignalLog.onesignalLog(.LL_WARN, message: "OneSignal.User removeAliases error: Cannot use \(OS_ONESIGNAL_ID) or \(OS_EXTERNAL_ID) as a alias label.") return } identityModel.removeAliases(labels) diff --git a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSUserJwtRepo.swift b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSUserJwtRepo.swift index db22f24ac4..48a587a123 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSUserJwtRepo.swift +++ b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OSUserJwtRepo.swift @@ -86,7 +86,7 @@ final class OSUserJwtRepo: OSUserJwtProviding { @discardableResult func updateJwt(externalId: String, token: String) -> Bool { guard !token.isEmpty, token != OS_JWT_TOKEN_INVALID else { - OneSignalLog.onesignalLog(.LL_ERROR, message: "OSUserJwtRepo.updateJwt ignored an unusable token for \(externalId)") + OneSignalLog.onesignalLog(.LL_WARN, message: "OSUserJwtRepo.updateJwt ignored an unusable token for \(externalId)") return false } guard identityModelRepo.updateJwtToken(externalId: externalId, token: token) else { diff --git a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OneSignalUserManagerImpl+Jwt.swift b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OneSignalUserManagerImpl+Jwt.swift index 078e2835f7..5579d3b4ab 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OneSignalUserManagerImpl+Jwt.swift +++ b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OneSignalUserManagerImpl+Jwt.swift @@ -150,7 +150,7 @@ extension OneSignalUserManagerImpl { return } guard !externalId.isEmpty, !token.isEmpty, token != OS_JWT_TOKEN_INVALID else { - OneSignalLog.onesignalLog(.LL_ERROR, message: "OneSignal.updateUserJwt called with empty externalId or an unusable token. This is not allowed.") + OneSignalLog.onesignalLog(.LL_WARN, message: "OneSignal.updateUserJwt called with empty externalId or an unusable token. This is not allowed.") return } OneSignalLog.onesignalLog( diff --git a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OneSignalUserManagerImpl.swift b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OneSignalUserManagerImpl.swift index 3c745e308a..da38b6537e 100644 --- a/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OneSignalUserManagerImpl.swift +++ b/iOS_SDK/OneSignalSDK/OneSignalUser/Source/OneSignalUserManagerImpl.swift @@ -946,7 +946,7 @@ extension OneSignalUserManagerImpl: OSUser { // Make sure the properties are serializable as JSON object guard JSONSerialization.isValidJSONObject(processedProperties) else { - OneSignalLog.onesignalLog(.LL_ERROR, message: "trackEvent called with invalid properties \(processedProperties), dropping this event.") + OneSignalLog.onesignalLog(.LL_WARN, message: "trackEvent called with invalid properties \(processedProperties), dropping this event.") return } diff --git a/iOS_SDK/OneSignalSDK/OneSignalUserTests/Executors/RequestFailureLogLevelTests.swift b/iOS_SDK/OneSignalSDK/OneSignalUserTests/Executors/RequestFailureLogLevelTests.swift new file mode 100644 index 0000000000..0a2d851a84 --- /dev/null +++ b/iOS_SDK/OneSignalSDK/OneSignalUserTests/Executors/RequestFailureLogLevelTests.swift @@ -0,0 +1,167 @@ +/* + Modified MIT License + + Copyright 2026 OneSignal + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + 1. The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + 2. All copies of substantial portions of the Software may only be used in connection + with services provided by OneSignal. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + */ + +import XCTest +import OneSignalCore +import OneSignalCoreMocks +import OneSignalOSCoreMocks +import OneSignalUserMocks +@testable import OneSignalOSCore +@testable import OneSignalUser + +/// Listeners hear every line logged in the process, so a test reads back only the lines it is about. +private final class LogCapture: NSObject, OSLogListener { + private let lock = NSLock() + private var entries: [(level: ONE_S_LOG_LEVEL, entry: String)] = [] + + func onLogEvent(_ event: OneSignalLogEvent) { + lock.withLock { entries.append((event.level, event.entry)) } + } + + func levels(mentioning text: String) -> [ONE_S_LOG_LEVEL] { + return lock.withLock { entries.filter { $0.entry.contains(text) }.map { $0.level } } + } +} + +/// A failed Request logs at the level of what the executor does with it: INFO when it is held or +/// retried, WARN when it is dropped, ERROR when it stops the queue. +final class RequestFailureLogLevelTests: XCTestCase { + private let addAliasesFailure = "add aliases request failed" + private let fetchUserFailure = "executeFetchUserRequest failed" + private let createUserFailure = "create user request failed" + + private var client = MockOneSignalClient() + private var log = LogCapture() + + override func setUpWithError() throws { + OneSignalCoreMocks.clearUserDefaults() + OneSignalUserMocks.reset() + OneSignalIdentifiers.currentAppId = "test-app-id" + + client = MockOneSignalClient() + OneSignalCoreImpl.setSharedClient(client) + + log = LogCapture() + OneSignalLog.debug().__add(log) + } + + override func tearDownWithError() throws { + OneSignalCoreMocks.waitUntil("A Request was still in flight at teardown") { + self.client.completedRequests.count == self.client.startedRequests.count + } + OneSignalLog.debug().__remove(log) + OneSignalUserManagerImpl.sharedInstance.operationRepo.paused = false + OneSignalCoreMocks.clearUserDefaults() + } + + private func error(_ code: Int) -> OneSignalClientError { + return OneSignalClientError(code: code, message: "not-important", responseHeaders: nil, response: nil, underlyingError: nil) + } + + /// Sends one cached Add Aliases for user A that the server answers with `code`, signed with `token` if given. + private func sendAddAliases(failingWith code: Int, signedWith token: String? = nil) { + let identityModel = OneSignalUserMocks.setUserManagerInternalUser(externalId: userA_EUID, onesignalId: userA_OSID).identityModel + if let token { + XCTAssertTrue(OneSignalUserManagerImpl.sharedInstance.userJwtRepo.updateJwt(externalId: userA_EUID, token: token)) + } + let request = OSRequestAddAliases(aliases: ["test_alias_label": "test-alias-id"], identityModel: identityModel, ownerExternalId: userA_EUID) + OneSignalUserDefaults.initShared().saveCodeableData(forKey: OS_IDENTITY_EXECUTOR_ADD_REQUEST_QUEUE_KEY, withValue: [request]) + client.setMockFailureResponseForRequest(request: request.description, error: error(code)) + + let executor = OSIdentityOperationExecutor(newRecordsState: MockNewRecordsState(), auth: OneSignalUserManagerImpl.sharedInstance.requestAuth) + executor.processDeltaQueue(inBackground: false) + } + + private func loggedLevels(mentioning text: String) -> [ONE_S_LOG_LEVEL] { + OneSignalCoreMocks.waitUntil("Nothing was logged about: \(text)") { + !self.log.levels(mentioning: text).isEmpty + } + return log.levels(mentioning: text) + } + + func testARequestHeldForANewTokenLogsInfo() { + OSCoreMocks.hydrateSharedJwtConfig(requiresUserAuth: true) + + sendAddAliases(failingWith: 401, signedWith: "token-a") + + XCTAssertEqual(loggedLevels(mentioning: addAliasesFailure), [.LL_INFO]) + XCTAssertNil(OneSignalUserManagerImpl.sharedInstance.userJwtRepo.validJwt(externalId: userA_EUID), "the 401 was handled as a rejected token") + } + + func testARetryableFailureLogsInfo() { + sendAddAliases(failingWith: 500) + + XCTAssertEqual(loggedLevels(mentioning: addAliasesFailure), [.LL_INFO]) + } + + func testADroppedRequestLogsWarn() { + sendAddAliases(failingWith: 400) + + XCTAssertEqual(loggedLevels(mentioning: addAliasesFailure), [.LL_WARN]) + } + + func testAFetchForAUserTheServerNoLongerHasLogsInfo() { + _ = OneSignalUserMocks.setUserManagerInternalUser(externalId: userB_EUID, onesignalId: userB_OSID) + let staleIdentityModel = OSIdentityModel(aliases: [OS_ONESIGNAL_ID: userA_OSID], changeNotifier: OSEventProducer()) + client.setMockFailureResponseForRequest(request: "", error: error(404)) + let executor = OSUserExecutor( + newRecordsState: MockNewRecordsState(), + identityVerificationService: OneSignalUserManagerImpl.sharedInstance.identityVerificationService, + auth: OneSignalUserManagerImpl.sharedInstance.requestAuth + ) + + executor.fetchUser(aliasLabel: OS_ONESIGNAL_ID, aliasId: userA_OSID, identityModel: staleIdentityModel, onNewSession: false) + + XCTAssertEqual(loggedLevels(mentioning: fetchUserFailure), [.LL_INFO]) + } + + func testAFetchThatLogsOutTheCurrentUserLogsWarn() { + let identityModel = OneSignalUserMocks.setUserManagerInternalUser(externalId: userA_EUID, onesignalId: userA_OSID).identityModel + client.setMockFailureResponseForRequest(request: "", error: error(404)) + let executor = OSUserExecutor( + newRecordsState: MockNewRecordsState(), + identityVerificationService: OneSignalUserManagerImpl.sharedInstance.identityVerificationService, + auth: OneSignalUserManagerImpl.sharedInstance.requestAuth + ) + + executor.fetchUser(aliasLabel: OS_ONESIGNAL_ID, aliasId: userA_OSID, identityModel: identityModel, onNewSession: false) + + XCTAssertEqual(loggedLevels(mentioning: fetchUserFailure), [.LL_WARN]) + } + + func testACreateUserFailureThatPausesTheRepoLogsError() { + OSCoreMocks.hydrateSharedJwtConfig(requiresUserAuth: true) + client.setMockFailureResponseForRequest(request: "", error: error(400)) + + OneSignalUserManagerImpl.sharedInstance.login(externalId: userA_EUID, token: "token-a") + + XCTAssertEqual(loggedLevels(mentioning: createUserFailure), [.LL_ERROR]) + OneSignalCoreMocks.waitUntil("The failure did not pause the Repo") { + OneSignalUserManagerImpl.sharedInstance.operationRepo.paused + } + } +} diff --git a/iOS_SDK/OneSignalSDK/Source/OSAttributedFocusTimeProcessor.m b/iOS_SDK/OneSignalSDK/Source/OSAttributedFocusTimeProcessor.m index 649d2468bd..93168d9b99 100644 --- a/iOS_SDK/OneSignalSDK/Source/OSAttributedFocusTimeProcessor.m +++ b/iOS_SDK/OneSignalSDK/Source/OSAttributedFocusTimeProcessor.m @@ -111,7 +111,7 @@ - (void)sendBackgroundAttributedSessionTimeWithParams:(OSFocusCallParams *)param [super saveUnsentActiveTime:0]; [OSBackgroundTaskManager endBackgroundTask:SESSION_OUTCOMES_TASK]; } onFailure:^(NSError *error) { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"sendBackgroundAttributed failed, will retry on next open"]; + [OneSignalLog onesignalLog:ONE_S_LL_INFO message:@"sendBackgroundAttributed failed, will retry on next open"]; [OSBackgroundTaskManager endBackgroundTask:SESSION_OUTCOMES_TASK]; }]; }); diff --git a/iOS_SDK/OneSignalSDK/Source/OSUnattributedFocusTimeProcessor.m b/iOS_SDK/OneSignalSDK/Source/OSUnattributedFocusTimeProcessor.m index 714631131c..46579315c8 100644 --- a/iOS_SDK/OneSignalSDK/Source/OSUnattributedFocusTimeProcessor.m +++ b/iOS_SDK/OneSignalSDK/Source/OSUnattributedFocusTimeProcessor.m @@ -110,7 +110,7 @@ - (void)sendBackgroundUnattributedSessionTimeWithParams:(OSFocusCallParams *)par [super saveUnsentActiveTime:0]; [OSBackgroundTaskManager endBackgroundTask:SESSION_OUTCOMES_TASK]; } onFailure:^(NSError *error) { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"sendUnattributed session end outcomes failed, will retry on next open"]; + [OneSignalLog onesignalLog:ONE_S_LL_INFO message:@"sendUnattributed session end outcomes failed, will retry on next open"]; [OSBackgroundTaskManager endBackgroundTask:SESSION_OUTCOMES_TASK]; }]; }); diff --git a/iOS_SDK/OneSignalSDK/Source/OneSignal.m b/iOS_SDK/OneSignalSDK/Source/OneSignal.m index 09c2d3b341..3318ce4cc0 100755 --- a/iOS_SDK/OneSignalSDK/Source/OneSignal.m +++ b/iOS_SDK/OneSignalSDK/Source/OneSignal.m @@ -226,7 +226,7 @@ + (void)logout { if (oneSignalInAppMessages != nil && [oneSignalInAppMessages respondsToSelector:@selector(InAppMessages)]) { return [oneSignalInAppMessages performSelector:@selector(InAppMessages)]; } else { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"OneSignalInAppMessages not found. In order to use OneSignal's In App Messaging features the OneSignalInAppMessages module must be added."]; return [OSStubInAppMessages InAppMessages]; } } @@ -239,7 +239,7 @@ + (void)logout { if (oneSignalLiveActivities != nil && [oneSignalLiveActivities respondsToSelector:@selector(liveActivities)]) { return [oneSignalLiveActivities performSelector:@selector(liveActivities)]; } else { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"oneSignalLiveActivities not found. In order to use OneSignal's LiveActivities features the OneSignalLiveActivities module must be added."]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"oneSignalLiveActivities not found. In order to use OneSignal's LiveActivities features the OneSignalLiveActivities module must be added."]; return [OSStubLiveActivities liveActivities]; } #endif @@ -492,7 +492,7 @@ + (void)startLiveActivitiesManager { if (oneSignalLiveActivities != nil && [oneSignalLiveActivities respondsToSelector:@selector(start)]) { [oneSignalLiveActivities performSelector:@selector(start)]; } else { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"oneSignalLiveActivities not found. In order to use OneSignal's LiveActivities features the OneSignalLiveActivities module must be added."]; + [OneSignalLog onesignalLog:ONE_S_LL_INFO message:@"OneSignalLiveActivities module not found, Live Activities will not start. Add the module to use OneSignal's LiveActivities features."]; } #endif } @@ -947,7 +947,7 @@ + (UNMutableNotificationContent*)serviceExtensionTimeWillExpireRequest:(UNNotifi + (void)sendSessionEndOutcomes:(NSNumber*)totalTimeActive params:(OSFocusCallParams *)params onSuccess:(OSResultSuccessBlock _Nonnull)successBlock onFailure:(OSFailureBlock _Nonnull)failureBlock { if (![OSOutcomes sharedController]) { - [OneSignalLog onesignalLog:ONE_S_LL_ERROR message:@"Make sure OneSignal init is called first"]; + [OneSignalLog onesignalLog:ONE_S_LL_WARN message:@"Make sure OneSignal init is called first"]; if (failureBlock) { failureBlock([NSError errorWithDomain:@"onesignal" code:0 userInfo:@{@"error" : @"Missing outcomes controller."}]); }