10
10
#import " VWOSocketConnector.h"
11
11
#import " VWOLogger.h"
12
12
#import " VWOCampaign.h"
13
+ #import " VWOConstants.h"
13
14
#import " VWOURLQueue.h"
14
15
#import " VWOFile.h"
15
16
#import " VWOURL.h"
@@ -203,30 +204,62 @@ - (void)trackConversion:(NSString *)goalIdentifier withValue:(NSNumber *)value {
203
204
204
205
// Check if the goal is already marked.
205
206
for (VWOCampaign *campaign in _campaignList) {
206
- VWOGoal *matchedGoal = [campaign goalForIdentifier: goalIdentifier];
207
- if (matchedGoal) {
208
-
209
- if ([VWOUserDefaults isGoalMarked: matchedGoal inCampaign: campaign]) {
210
- VWOLogDebug (@" Goal '%@ ' already marked. Will not be marked again" , matchedGoal);
211
- return ;
207
+ NSMutableArray <VWOGoal *>*matchedGoals = [campaign goalForIdentifier: goalIdentifier];
208
+ if ([matchedGoals count ] == 0 ){
209
+ continue ;
210
+ }
211
+
212
+ for (VWOGoal *matchedGoal in matchedGoals){
213
+ if (matchedGoal) {
214
+
215
+ if ([VWOUserDefaults isGoalMarked: matchedGoal inCampaign: campaign]) {
216
+ BOOL isEventArchEnabled = [VWOUserDefaults IsEventArchEnabled ];
217
+ if (!isEventArchEnabled){
218
+ VWOLogDebug (@" Goal '%@ ' already marked and eventArch is not enabled. Will not be marked again" , matchedGoal);
219
+ return ;
220
+ }
221
+ if ([matchedGoal mca ] != -1 ){
222
+ // if mca flag != -1, then goal is not triggered multiple times.
223
+ VWOLogDebug (@" Goal '%@ ' already marked. Will not be marked again" , matchedGoal);
224
+ return ;
225
+ }
226
+ }
212
227
}
213
228
}
214
229
}
215
230
216
231
// Mark goal(Goal can be present in multiple campaigns
217
232
for (VWOCampaign *campaign in _campaignList) {
218
- VWOGoal *matchedGoal = [campaign goalForIdentifier: goalIdentifier];
219
- if (matchedGoal) {
220
- if ([VWOUserDefaults isTrackingUserForCampaign: campaign]) {
221
- [VWOUserDefaults markGoalConversion: matchedGoal inCampaign: campaign];
222
- NSURL *url = [_vwoURL forMarkingGoal: matchedGoal
223
- withValue: value
224
- campaign: campaign
225
- dateTime: NSDate .date];
226
- NSString *description = [NSString stringWithFormat: @" Goal %@ " , matchedGoal];
227
- [pendingURLQueue enqueue: url maxRetry: 10 description: description];
228
- } else {
229
- VWOLogWarning (@" Goal %@ not tracked for %@ as user is not tracked" , matchedGoal, campaign);
233
+ NSMutableArray <VWOGoal *>*matchedGoals = [campaign goalForIdentifier: goalIdentifier];
234
+ if ([matchedGoals count ] == 0 ){
235
+ continue ;
236
+ }
237
+ for (VWOGoal *matchedGoal in matchedGoals){
238
+ if (matchedGoal) {
239
+ if ([VWOUserDefaults isTrackingUserForCampaign: campaign]) {
240
+ [VWOUserDefaults markGoalConversion: matchedGoal inCampaign: campaign];
241
+
242
+ NSURL *url = NULL ;
243
+ if ((VWOUserDefaults.IsEventArchEnabled != NULL ) &&
244
+ ([VWOUserDefaults.IsEventArchEnabled isEqualToString: EventArchEnabled])){
245
+ // for Event based API calls
246
+ url = [_vwoURL forMarkingGoalEventArch: matchedGoal
247
+ withValue: value
248
+ campaign: campaign
249
+ dateTime: NSDate .date];
250
+ }else {
251
+ // for previous version support
252
+ url = [_vwoURL forMarkingGoal: matchedGoal
253
+ withValue: value
254
+ campaign: campaign
255
+ dateTime: NSDate .date];
256
+ }
257
+
258
+ NSString *description = [NSString stringWithFormat: @" Goal %@ " , matchedGoal];
259
+ [pendingURLQueue enqueue: url maxRetry: 10 description: description];
260
+ } else {
261
+ VWOLogWarning (@" Goal %@ not tracked for %@ as user is not tracked" , matchedGoal, campaign);
262
+ }
230
263
}
231
264
}
232
265
}
@@ -400,7 +433,17 @@ - (void)trackUserForCampaign:(VWOCampaign *)campaign {
400
433
401
434
// Send network request and notification only if the campaign is running
402
435
403
- NSURL *url = [_vwoURL forMakingUserPartOfCampaign: campaign dateTime: NSDate .date config: _vwoConfig];
436
+ NSURL *url = NULL ;
437
+
438
+ if ((VWOUserDefaults.IsEventArchEnabled != NULL ) &&
439
+ ([VWOUserDefaults.IsEventArchEnabled isEqualToString: EventArchEnabled])){
440
+ // for Event based API calls
441
+ url = [_vwoURL forMakingUserPartOfCampaignEventArch: campaign dateTime: NSDate .date config: _vwoConfig];
442
+ }else {
443
+ // for previous version support
444
+ url = [_vwoURL forMakingUserPartOfCampaign: campaign dateTime: NSDate .date config: _vwoConfig];
445
+ }
446
+
404
447
NSString *description = [NSString stringWithFormat: @" Track user %@ %@ " , campaign, campaign.variation];
405
448
[pendingURLQueue enqueue: url maxRetry: 10 description: description];
406
449
@@ -416,7 +459,18 @@ - (void)pushCustomDimension:(nonnull NSString *)customDimensionKey withCustomDim
416
459
return ;
417
460
}
418
461
419
- NSURL *url = [_vwoURL forPushingCustomDimension: customDimensionKey withCustomDimensionValue: customDimensionValue dateTime: NSDate .date];
462
+
463
+ NSURL *url = NULL ;
464
+
465
+ if ((VWOUserDefaults.IsEventArchEnabled != NULL ) &&
466
+ ([VWOUserDefaults.IsEventArchEnabled isEqualToString: EventArchEnabled])){
467
+ // for Event based API calls
468
+ url = [_vwoURL forPushingCustomDimensionEventArch: customDimensionKey withCustomDimensionValue: customDimensionValue dateTime: NSDate .date];
469
+ }else {
470
+ // for previous version support
471
+ url = [_vwoURL forPushingCustomDimension: customDimensionKey withCustomDimensionValue: customDimensionValue dateTime: NSDate .date];
472
+ }
473
+
420
474
NSString *description = [NSString stringWithFormat: @" Custom Dimension %@ %@ " , customDimensionKey, customDimensionValue];
421
475
[pendingURLQueue enqueue: url maxRetry: 10 description: description];
422
476
0 commit comments