Skip to content

Commit

Permalink
fix: fixed issues with the parsing of network response
Browse files Browse the repository at this point in the history
  • Loading branch information
Desu Sai Venkat committed Dec 12, 2023
1 parent 749ba44 commit 749f16d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Sources/Classes/RSClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ + (instancetype)initiate:(NSString *)writeKey config:(RSConfig * __nullable)conf
if ([writeKey length] == 0) {
[RSLogger logError:WRITE_KEY_ERROR];
}
if (recursiveLock == nil) {
recursiveLock = [[NSRecursiveLock alloc] init];
}
[recursiveLock lock];
@try {
if (_instance == nil) {
Expand Down
4 changes: 2 additions & 2 deletions Sources/Classes/RSNetworkManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ -(RSNetworkResponse*) sendNetworkRequest: (NSString*) payload toEndpoint:(ENDPOI
weakResult.responsePayload = nil;
if(weakResult.statusCode == 404) {
weakResult.state = RESOURCE_NOT_FOUND;
} else if (weakResult.statusCode == 400) {
weakResult.state = BAD_REQUEST;
} else if (![weakResult.errorPayload isEqualToString:@""] && [[weakResult.errorPayload lowercaseString] rangeOfString:@"request neither has anonymousid nor userid"].location != NSNotFound) {
[RSLogger logError:[[NSString alloc] initWithFormat:@"RSNetworkManager: sendNetworkRequest: Request to url %@ failed with statusCode %ld due to events missing anonymousId or userId",requestEndPoint, weakResult.statusCode]];
weakResult.state = MISSING_ANONYMOUSID_AND_USERID;
} else if (![weakResult.errorPayload isEqualToString:@""] && [[weakResult.errorPayload lowercaseString] rangeOfString:@"invalid write key"].location != NSNotFound) {
[RSLogger logError:[[NSString alloc] initWithFormat:@"RSNetworkManager: sendNetworkRequest: Request to url %@ failed with statusCode %ld due to invalid write key",requestEndPoint, weakResult.statusCode ]];
weakResult.state = WRONG_WRITE_KEY;
}else if (weakResult.statusCode == 400) {
weakResult.state = BAD_REQUEST;
} else {
weakResult.state = NETWORK_ERROR;
}
Expand Down

0 comments on commit 749f16d

Please sign in to comment.