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" ;
@@ -71,15 +74,24 @@ - (void)dispatchEvent:(NSDictionary *)params
71
74
72
75
@end
73
76
74
- static NSString * const kHTTPRequestMethodPost = @" POST" ;
75
- static NSString * const kHTTPHeaderFieldContentType = @" Content-Type" ;
76
- static NSString * const kHTTPHeaderFieldValueApplicationJSON = @" application/json" ;
77
-
78
77
@implementation OPTLYEventDispatcherBasic
79
78
79
+ - (void )dispatchImpressionEvent : (nonnull NSDictionary *)params
80
+ callback : (nullable void (^)(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error))callback {
81
+ NSURL *url = [NSURL URLWithString: kEventDispatcherImpressionEventURL ];
82
+ [self dispatchEvent: params toURL: url completionHandler: callback];
83
+ }
84
+
85
+ - (void )dispatchConversionEvent : (nonnull NSDictionary *)params
86
+ callback : (nullable void (^)(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error))callback {
87
+
88
+ NSURL *url = [NSURL URLWithString: kEventDispatcherConversionEventURL ];
89
+ [self dispatchEvent: params toURL: url completionHandler: callback];
90
+ }
91
+
80
92
- (void )dispatchEvent : (NSDictionary *)params
81
93
toURL : (NSURL *)url
82
- completionHandler : (void (^)(NSURLResponse *response, NSError *error))completion
94
+ completionHandler : (void (^)(NSData *data, NSURLResponse *response, NSError *error))completion
83
95
{
84
96
NSURLSession *ephemeralSession = [NSURLSession sessionWithConfiguration: [NSURLSessionConfiguration ephemeralSessionConfiguration ]];
85
97
NSMutableURLRequest *request = [[NSMutableURLRequest alloc ] initWithURL: url];
@@ -97,14 +109,16 @@ - (void)dispatchEvent:(NSDictionary *)params
97
109
fromData: data
98
110
completionHandler: ^(NSData *data,NSURLResponse *response,NSError *error) {
99
111
if (completion) {
100
- completion (response, error);
112
+ completion (data, response, error);
101
113
}
102
114
}];
103
115
104
116
[uploadTask resume ];
105
117
}
106
118
}
107
119
120
+
121
+
108
122
@end
109
123
110
124
@implementation OPTLYEventDispatcherNoOp
0 commit comments