19
19
#import " OPTLYEventDispatcher.h"
20
20
#import " OPTLYErrorHandler.h"
21
21
22
+ static NSString * const kEventDispatcherImpressionEventURL = @" https://logx.optimizely.com/log/decision" ;
23
+ static NSString * const kEventDispatcherConversionEventURL = @" https://logx.optimizely.com/log/event" ;
24
+
22
25
static NSString * const kHTTPRequestMethodPost = @" POST" ;
23
26
static NSString * const kHTTPHeaderFieldContentType = @" Content-Type" ;
24
27
static NSString * const kHTTPHeaderFieldValueApplicationJSON = @" application/json" ;
@@ -39,15 +42,24 @@ + (BOOL)conformsToOPTLYEventDispatcherProtocol:(Class)instanceClass
39
42
40
43
@end
41
44
42
- static NSString * const kHTTPRequestMethodPost = @" POST" ;
43
- static NSString * const kHTTPHeaderFieldContentType = @" Content-Type" ;
44
- static NSString * const kHTTPHeaderFieldValueApplicationJSON = @" application/json" ;
45
-
46
45
@implementation OPTLYEventDispatcherBasic
47
46
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
+
48
60
- (void )dispatchEvent : (NSDictionary *)params
49
61
toURL : (NSURL *)url
50
- completionHandler : (void (^)(NSURLResponse *response, NSError *error))completion
62
+ completionHandler : (void (^)(NSData *data, NSURLResponse *response, NSError *error))completion
51
63
{
52
64
NSURLSession *ephemeralSession = [NSURLSession sessionWithConfiguration: [NSURLSessionConfiguration ephemeralSessionConfiguration ]];
53
65
NSMutableURLRequest *request = [[NSMutableURLRequest alloc ] initWithURL: url];
@@ -65,14 +77,16 @@ - (void)dispatchEvent:(NSDictionary *)params
65
77
fromData: data
66
78
completionHandler: ^(NSData *data,NSURLResponse *response,NSError *error) {
67
79
if (completion) {
68
- completion (response, error);
80
+ completion (data, response, error);
69
81
}
70
82
}];
71
83
72
84
[uploadTask resume ];
73
85
}
74
86
}
75
87
88
+
89
+
76
90
@end
77
91
78
92
@implementation OPTLYEventDispatcherNoOp
0 commit comments