17
17
#import " OPTLYEventDispatcher.h"
18
18
19
19
// --- Event URLs ----
20
- NSString * const OPTLYEventDispatcherImpressionEventURL = @" https://logx.optimizely.com/log/decision" ; // @"https://p13nlog.dz.optimizely.com/log/decision";
21
- NSString * const OPTLYEventDispatcherConversionEventURL = @" https://logx.optimizely.com/log/event" ; // @"https://p13nlog.dz.optimizely.com/log/event";
20
+ NSString * const OPTLYEventDispatcherImpressionEventURL = @" https://logx.optimizely.com/log/decision" ;
21
+ NSString * const OPTLYEventDispatcherConversionEventURL = @" https://logx.optimizely.com/log/event" ;
22
22
23
23
// Default interval and timeout values (in ms) if not set by users
24
24
NSInteger const OPTLYEventDispatcherDefaultDispatchIntervalTime_ms = 1000 ;
27
27
@interface OPTLYEventDispatcher ()
28
28
@property (nonatomic , strong ) OPTLYDataStore *dataStore;
29
29
@property (nonatomic , strong ) NSTimer *timer;
30
- @property (nonatomic , assign ) uint64_t dispatchEventBackoffRetries ;
31
- @property (nonatomic , assign ) uint64_t dispatchEventCall ;
30
+ @property (nonatomic , assign ) uint64_t flushEventBackoffRetries ;
31
+ @property (nonatomic , assign ) uint64_t flushEventCall ;
32
32
@property (nonatomic , assign ) uint64_t maxDispatchBackoffRetries;
33
33
@end
34
34
@@ -45,8 +45,8 @@ - (instancetype)init {
45
45
- (instancetype )initWithBuilder : (OPTLYEventDispatcherBuilder *)builder {
46
46
self = [super init ];
47
47
if (self != nil ) {
48
- _dispatchEventBackoffRetries = 0 ;
49
- _dispatchEventCall = 0 ;
48
+ _flushEventBackoffRetries = 0 ;
49
+ _flushEventCall = 0 ;
50
50
_timer = nil ;
51
51
_eventHandlerDispatchInterval = OPTLYEventDispatcherDefaultDispatchIntervalTime_ms;
52
52
_eventHandlerDispatchTimeout = OPTLYEventDispatcherDefaultDispatchTimeout_ms;
@@ -203,8 +203,8 @@ - (void)dispatchEvent:(nonnull NSDictionary *)event
203
203
[strongSelf.logger logMessage: logMessage withLevel: OptimizelyLogLevelDebug];
204
204
205
205
if (![strongSelf isTimerEnabled ]) {
206
- strongSelf.dispatchEventBackoffRetries = 0 ;
207
- strongSelf.dispatchEventCall = 0 ;
206
+ strongSelf.flushEventBackoffRetries = 0 ;
207
+ strongSelf.flushEventCall = 0 ;
208
208
[strongSelf setupNetworkTimer: ^{
209
209
if (callback) {
210
210
callback (data, response, error);
@@ -263,18 +263,18 @@ - (void)flushEvents:(void(^)())callback
263
263
264
264
// setup the network timer if needed and reset all the counters
265
265
if (![strongSelf isTimerEnabled ]) {
266
- strongSelf.dispatchEventBackoffRetries = 0 ;
267
- strongSelf.dispatchEventCall = 0 ;
266
+ strongSelf.flushEventBackoffRetries = 0 ;
267
+ strongSelf.flushEventCall = 0 ;
268
268
[strongSelf setupNetworkTimer: nil ];
269
269
}
270
270
271
- strongSelf.dispatchEventCall ++;
272
- OPTLYLogDebug (@" Dispatch event call - %ld " , strongSelf.dispatchEventCall );
271
+ strongSelf.flushEventCall ++;
272
+ OPTLYLogDebug (@" Dispatch event call - %ld " , strongSelf.flushEventCall );
273
273
274
274
// exponential backoff: only dispatch at a power of two interval; o/w return
275
- if (![strongSelf isPowerOf2: strongSelf.dispatchEventCall ]) {
275
+ if (![strongSelf isPowerOf2: strongSelf.flushEventCall ]) {
276
276
277
- NSString *logMessage = [NSString stringWithFormat: OPTLYLoggerMessagesEventDispatcherFlushEventsBackoffSkipRetry, strongSelf.dispatchEventCall ];
277
+ NSString *logMessage = [NSString stringWithFormat: OPTLYLoggerMessagesEventDispatcherFlushEventsBackoffSkipRetry, strongSelf.flushEventCall ];
278
278
[strongSelf.logger logMessage: logMessage withLevel: OptimizelyLogLevelDebug];
279
279
280
280
if (callback) {
@@ -284,9 +284,9 @@ - (void)flushEvents:(void(^)())callback
284
284
}
285
285
286
286
// stop trying to flush if max retries have been exceeded
287
- if (strongSelf.dispatchEventBackoffRetries > strongSelf.maxDispatchBackoffRetries ) {
287
+ if (strongSelf.flushEventBackoffRetries > strongSelf.maxDispatchBackoffRetries ) {
288
288
289
- NSString *logMessage = [NSString stringWithFormat: OPTLYLoggerMessagesEventDispatcherFlushEventsBackoffMaxRetries, strongSelf.dispatchEventBackoffRetries ];
289
+ NSString *logMessage = [NSString stringWithFormat: OPTLYLoggerMessagesEventDispatcherFlushEventsBackoffMaxRetries, strongSelf.flushEventBackoffRetries ];
290
290
[strongSelf.logger logMessage: logMessage withLevel: OptimizelyLogLevelDebug];
291
291
292
292
[self disableNetworkTimer: ^{
@@ -297,8 +297,8 @@ - (void)flushEvents:(void(^)())callback
297
297
return ;
298
298
}
299
299
300
- strongSelf.dispatchEventBackoffRetries ++;
301
- OPTLYLogDebug (@" Backoff retry - %ld ." , strongSelf.dispatchEventBackoffRetries );
300
+ strongSelf.flushEventBackoffRetries ++;
301
+ OPTLYLogDebug (@" Backoff retry - %ld ." , strongSelf.flushEventBackoffRetries );
302
302
303
303
[strongSelf flushSavedEvents: OPTLYDataStoreEventTypeImpression cachedData: YES ];
304
304
[strongSelf flushSavedEvents: OPTLYDataStoreEventTypeConversion cachedData: YES ];
@@ -328,11 +328,7 @@ - (void)flushSavedEvent:(NSDictionary *)event
328
328
[self .logger logMessage: logMessage withLevel: OptimizelyLogLevelDebug];
329
329
330
330
if (callback) {
331
- NSDictionary *errorMessage = [NSDictionary dictionaryWithObject: logMessage forKey: NSLocalizedDescriptionKey ];
332
- NSError *error = [NSError errorWithDomain: OPTLYErrorHandlerMessagesDomain
333
- code: OPTLYErrorTypesEventDispatch
334
- userInfo: errorMessage];
335
- callback (nil , nil , error);
331
+ callback (nil , nil , nil );
336
332
}
337
333
return ;
338
334
}
0 commit comments