Skip to content

Commit b8e6384

Browse files
Updated ad blocker log warnings to errors (#1417)
* Updated warnings to errors * Created new Branch errors
1 parent 806a138 commit b8e6384

File tree

5 files changed

+17
-7
lines changed

5 files changed

+17
-7
lines changed

Sources/BranchSDK/BNCServerInterface.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,11 @@ - (void)genericHTTPRequest:(NSURLRequest *)request retryNumber:(NSInteger)retryN
125125
} else {
126126
if (status != 200) {
127127
if ([NSError branchDNSBlockingError:underlyingError]) {
128-
[[BranchLogger shared] logWarning:[NSString stringWithFormat:@"Possible DNS Ad Blocker. Giving up on request with HTTP status code %ld", (long)status] error:underlyingError];
128+
NSError *error = [NSError branchErrorWithCode:BNCDNSAdBlockerError];
129+
[[BranchLogger shared] logError:[NSString stringWithFormat:@"Possible DNS Ad Blocker. Giving up on request with HTTP status code %ld. Underlying error: %@", (long)status, underlyingError] error:error];
129130
} else if ([NSError branchVPNBlockingError:underlyingError]) {
130-
[[BranchLogger shared] logWarning:[NSString stringWithFormat:@"Possible VPN Ad Blocker. Giving up on request with HTTP status code %ld", (long)status] error:underlyingError];
131+
NSError *error = [NSError branchErrorWithCode:BNCVPNAdBlockerError];
132+
[[BranchLogger shared] logError:[NSString stringWithFormat:@"Possible VPN Ad Blocker. Giving up on request with HTTP status code %ld. Underlying error: %@", (long)status, underlyingError] error:error];
131133
} else {
132134
[[BranchLogger shared] logWarning: [NSString stringWithFormat:@"Giving up on request with HTTP status code %ld", (long)status] error:underlyingError];
133135
}

Sources/BranchSDK/BNCURLFilter.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,13 @@ - (BOOL)foundUpdatedURLList:(id<BNCNetworkOperationProtocol>)operation {
130130
if (statusCode == 404) {
131131
[[BranchLogger shared] logDebug:@"No update for URL ignore list found." error:nil];
132132
return NO;
133-
} else if (statusCode != 200 || error != nil || jsonString == nil) {
133+
} else if (statusCode != 200 || error != nil || jsonString == nil) {
134134
if ([NSError branchDNSBlockingError:error]) {
135-
[[BranchLogger shared] logWarning:@"Possible DNS Ad Blocker" error:error];
135+
NSError *dnsError = [NSError branchErrorWithCode:BNCDNSAdBlockerError];
136+
[[BranchLogger shared] logError:[NSString stringWithFormat:@"Possible DNS Ad Blocker. Giving up on request with HTTP status code %ld. Underlying error: %@", (long)statusCode, error] error:dnsError];
136137
} else if ([NSError branchVPNBlockingError:error]) {
137-
[[BranchLogger shared] logWarning:@"Possible VPN Ad Blocker" error:error];
138+
NSError *vpnError = [NSError branchErrorWithCode:BNCVPNAdBlockerError];
139+
[[BranchLogger shared] logError:[NSString stringWithFormat:@"Possible VPN Ad Blocker. Giving up on request with HTTP status code %ld. Underlying error: %@", (long)statusCode, error] error:vpnError];
138140
} else {
139141
[[BranchLogger shared] logWarning:@"Failed to update URL ignore list" error:operation.error];
140142
}

Sources/BranchSDK/BranchQRCode.m

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,11 @@ - (void)callQRCodeAPI:(nullable NSDictionary *)params
144144

145145
if (error) {
146146
if ([NSError branchDNSBlockingError:error]) {
147-
[[BranchLogger shared] logWarning:@"Possible DNS Ad Blocker" error:error];
147+
NSError *dnsError = [NSError branchErrorWithCode:BNCDNSAdBlockerError];
148+
[[BranchLogger shared] logError:[NSString stringWithFormat:@"Possible DNS Ad Blocker. Giving up on QR code request. Underlying error: %@", error] error:dnsError];
148149
} else if ([NSError branchVPNBlockingError:error]) {
149-
[[BranchLogger shared] logWarning:@"Possible VPN Ad Blocker" error:error];
150+
NSError *vpnError = [NSError branchErrorWithCode:BNCVPNAdBlockerError];
151+
[[BranchLogger shared] logError:[NSString stringWithFormat:@"Possible VPN Ad Blocker. Giving up on QR code request. Underlying error: %@", error] error:vpnError];
150152
} else {
151153
[[BranchLogger shared] logError:@"QR Code request failed" error:error];
152154
completion(nil, error);

Sources/BranchSDK/NSError+Branch.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ + (NSString *)messageForCode:(BNCErrorCode)code {
4040
[messages setObject:@"The Spotlight identifier is required to remove indexing from spotlight." forKey:@(BNCSpotlightIdentifierError)];
4141
[messages setObject:@"Spotlight cannot remove publicly indexed content." forKey:@(BNCSpotlightPublicIndexError)];
4242
[messages setObject:@"User tracking is disabled and the request is not allowed" forKey:@(BNCTrackingDisabledError)];
43+
[messages setObject:@"Possible DNS Ad Blocker. Giving up on request." forKey:@(BNCDNSAdBlockerError)];
44+
[messages setObject:@"Possible VPN Ad Blocker. Giving up on request." forKey:@(BNCVPNAdBlockerError)];
4345
});
4446

4547
NSString *errorMessage = [messages objectForKey:@(code)];

Sources/BranchSDK/Private/NSError+Branch.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ typedef NS_ENUM(NSInteger, BNCErrorCode) {
3232
BNCSpotlightPublicIndexError = 1014,
3333
BNCTrackingDisabledError = 1015,
3434
BNCGeneralError = 1016, // General Branch SDK Error
35+
BNCDNSAdBlockerError = 1017,
36+
BNCVPNAdBlockerError = 1018,
3537
BNCHighestError
3638
};
3739

0 commit comments

Comments
 (0)