Skip to content

Commit e19b0d1

Browse files
Fixed Optimizely test after event dispatcher merge.
1 parent 67a43a9 commit e19b0d1

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

OptimizelySDKCore/OptimizelySDKCore/OPTLYEventDispatcher.m

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
#import "OPTLYEventDispatcher.h"
2020
#import "OPTLYErrorHandler.h"
2121

22+
static NSString * const kEventDispatcherImpressionEventURL = @"https://logx.optimizely.com/log/decision";
23+
static NSString * const kEventDispatcherConversionEventURL = @"https://logx.optimizely.com/log/event";
24+
2225
static NSString * const kHTTPRequestMethodPost = @"POST";
2326
static NSString * const kHTTPHeaderFieldContentType = @"Content-Type";
2427
static NSString * const kHTTPHeaderFieldValueApplicationJSON = @"application/json";
@@ -39,15 +42,24 @@ + (BOOL)conformsToOPTLYEventDispatcherProtocol:(Class)instanceClass
3942

4043
@end
4144

42-
static NSString * const kHTTPRequestMethodPost = @"POST";
43-
static NSString * const kHTTPHeaderFieldContentType = @"Content-Type";
44-
static NSString * const kHTTPHeaderFieldValueApplicationJSON = @"application/json";
45-
4645
@implementation OPTLYEventDispatcherBasic
4746

47+
- (void)dispatchImpressionEvent:(nonnull NSDictionary *)params
48+
callback:(nullable void(^)(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error))callback {
49+
NSURL *url = [NSURL URLWithString:kEventDispatcherImpressionEventURL];
50+
[self dispatchEvent:params toURL:url completionHandler:callback];
51+
}
52+
53+
- (void)dispatchConversionEvent:(nonnull NSDictionary *)params
54+
callback:(nullable void(^)(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error))callback {
55+
56+
NSURL *url = [NSURL URLWithString:kEventDispatcherConversionEventURL];
57+
[self dispatchEvent:params toURL:url completionHandler:callback];
58+
}
59+
4860
- (void)dispatchEvent:(NSDictionary *)params
4961
toURL:(NSURL *)url
50-
completionHandler:(void(^)(NSURLResponse *response, NSError *error))completion
62+
completionHandler:(void(^)(NSData *data, NSURLResponse *response, NSError *error))completion
5163
{
5264
NSURLSession *ephemeralSession = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration ephemeralSessionConfiguration]];
5365
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
@@ -65,14 +77,16 @@ - (void)dispatchEvent:(NSDictionary *)params
6577
fromData:data
6678
completionHandler:^(NSData *data,NSURLResponse *response,NSError *error) {
6779
if (completion) {
68-
completion(response, error);
80+
completion(data, response, error);
6981
}
7082
}];
7183

7284
[uploadTask resume];
7385
}
7486
}
7587

88+
89+
7690
@end
7791

7892
@implementation OPTLYEventDispatcherNoOp

OptimizelySDKCore/OptimizelySDKCore/Optimizely.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ - (double)getVariableFloat:(nonnull NSString *)variableKey
373373
}
374374

375375
return 0;
376+
}
376377

377378
// log and propagate error for a track failure
378379
- (void)handleErrorLogsForTrackEvent:(NSString *)eventKey
@@ -414,7 +415,6 @@ - (void)handleErrorLogsForActivateUser:(NSString *)userId
414415
[self.errorHandler handleError:error];
415416
[self.logger logMessage:logMessage withLevel:OptimizelyLogLevelError];
416417
}
417-
>>>>>>> alda/eventDispatcher
418418
}
419419

420420
@end

OptimizelySDKCore/OptimizelySDKCoreTests/OptimizelyTest.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ - (void)stubSuccessResponseForEventRequest {
116116
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"testGetVariableString"];
117117

118118
[OHHTTPStubs stubRequestsPassingTest:^BOOL(NSURLRequest *request) {
119-
return [request.URL.host isEqualToString:@"p13nlog.dz.optimizely.com"];
119+
return [request.URL.host isEqualToString:@"logx.optimizely.com"];
120120
} withStubResponse:^OHHTTPStubsResponse*(NSURLRequest *request) {
121121
[expectation fulfill];
122122
return [OHHTTPStubsResponse responseWithData:[[NSData alloc] init]

0 commit comments

Comments
 (0)