|
1 | 1 | /****************************************************************************
|
2 |
| - * Copyright 2017-2018, Optimizely, Inc. and contributors * |
| 2 | + * Copyright 2017-2019, Optimizely, Inc. and contributors * |
3 | 3 | * *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); *
|
5 | 5 | * you may not use this file except in compliance with the License. *
|
@@ -447,17 +447,8 @@ - (void)track:(NSString *)eventKey
|
447 | 447 | return;
|
448 | 448 | }
|
449 | 449 |
|
450 |
| - NSArray *decisions = [self decisionsFor:event userId:userId attributes:attributes]; |
451 |
| - |
452 |
| - if ([decisions getValidArray] == nil) { |
453 |
| - NSString *logMessage = [NSString stringWithFormat:OPTLYLoggerMessagesConversionFailure, eventKey]; |
454 |
| - [self handleErrorLogsForTrack:logMessage ofLevel:OptimizelyLogLevelInfo]; |
455 |
| - return; |
456 |
| - } |
457 |
| - |
458 | 450 | NSDictionary *conversionEventParams = [self.eventBuilder buildConversionEventForUser:userId
|
459 | 451 | event:event
|
460 |
| - decisions:decisions |
461 | 452 | eventTags:eventTags
|
462 | 453 | attributes:attributes];
|
463 | 454 | if ([conversionEventParams getValidDictionary] == nil) {
|
@@ -909,57 +900,6 @@ - (OPTLYVariation *)sendImpressionEventFor:(OPTLYExperiment *)experiment
|
909 | 900 | return variation;
|
910 | 901 | }
|
911 | 902 |
|
912 |
| -/** |
913 |
| - Helper method to retrieve decisions for the user from the provided event. |
914 |
| -
|
915 |
| - @param event The event which needs to be recorded. |
916 |
| - @param userId Id for user. |
917 |
| - @param attributes The user's attributes. |
918 |
| - @return Array of dictionaries containing valid experiment Ids, variation Ids and layer Ids into which the user is bucketed. |
919 |
| - */ |
920 |
| -- (NSArray<NSDictionary *> *)decisionsFor:(OPTLYEvent *)event |
921 |
| - userId:(NSString *)userId |
922 |
| - attributes:(NSDictionary<NSString *, NSObject *> *)attributes { |
923 |
| - |
924 |
| - NSArray *experimentIds = event.experimentIds; |
925 |
| - |
926 |
| - if ([experimentIds count] == 0) { |
927 |
| - NSString *logMessage = [NSString stringWithFormat:OPTLYLoggerMessagesTrackEventNoAssociation, event.eventKey]; |
928 |
| - [self handleErrorLogsForTrack:logMessage ofLevel:OptimizelyLogLevelDebug]; |
929 |
| - return nil; |
930 |
| - } |
931 |
| - |
932 |
| - NSMutableArray *decisions = [NSMutableArray new]; |
933 |
| - |
934 |
| - for (NSString *experimentId in experimentIds) { |
935 |
| - OPTLYExperiment *experiment = [self.config getExperimentForId:experimentId]; |
936 |
| - |
937 |
| - // if the experiment is nil, then it is not part of the project's list of experiments |
938 |
| - if (!experiment) { |
939 |
| - NSString *logMessage = [NSString stringWithFormat:OPTLYLoggerMessagesTrackExperimentNoAssociation, experiment.experimentKey, event.eventKey]; |
940 |
| - [self handleErrorLogsForTrack:logMessage ofLevel:OptimizelyLogLevelDebug]; |
941 |
| - continue; |
942 |
| - } |
943 |
| - |
944 |
| - // bucket user into a variation |
945 |
| - OPTLYVariation *variation = [self variation:experiment.experimentKey userId:userId attributes:attributes]; |
946 |
| - |
947 |
| - // if the variation is nil, then experiment should not be tracked |
948 |
| - if (!variation) { |
949 |
| - NSString *logMessage = [NSString stringWithFormat:OPTLYLoggerMessagesTrackExperimentNotTracked, userId, experiment.experimentKey]; |
950 |
| - [self handleErrorLogsForTrack:logMessage ofLevel:OptimizelyLogLevelDebug]; |
951 |
| - continue; |
952 |
| - } |
953 |
| - |
954 |
| - NSMutableDictionary *decision = [NSMutableDictionary new]; |
955 |
| - decision[OPTLYEventParameterKeysDecisionCampaignId] = [experiment.layerId getStringOrEmpty]; |
956 |
| - decision[OPTLYEventParameterKeysDecisionExperimentId] = experiment.experimentId; |
957 |
| - decision[OPTLYEventParameterKeysDecisionVariationId] = variation.variationId; |
958 |
| - [decisions addObject:decision]; |
959 |
| - } |
960 |
| - return decisions; |
961 |
| -} |
962 |
| - |
963 | 903 | + (BOOL)isEmptyArray:(NSObject*)array {
|
964 | 904 | return (!array
|
965 | 905 | || ![array isKindOfClass:[NSArray class]]
|
|
0 commit comments