Skip to content

Commit cbe6d01

Browse files
committed
add log message if stored variation is no longer in datafile
1 parent beb358d commit cbe6d01

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

OptimizelySDKCore/OptimizelySDKCore/OPTLYLoggerMessages.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ extern NSString *const OPTLYLoggerMessagesDataStoreDatabaseGetNumberEventsTVOSWa
122122
extern NSString *const OPTLYLoggerMessagesDataStoreDatabaseRemoveTVOSWarning;
123123

124124
// ---- User Profile ----
125+
// warning
126+
extern NSString *const OPTLYLoggerMessagesUserProfileVariationNoLongerInDatafile;
125127
// Debug
126128
extern NSString *const OPTLYLoggerMessagesUserProfileVariation;
127129
extern NSString *const OPTLYLoggerMessagesUserProfileNoVariation;

OptimizelySDKCore/OptimizelySDKCore/OPTLYLoggerMessages.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@
122122
NSString *const OPTLYLoggerMessagesDataStoreDatabaseRemoveTVOSWarning = @"[DATABASE] tvOS can only remove data from cache> Number of events: %ld, eventType: %ld.";
123123

124124
// ---- User Profile ----
125+
//warning
126+
NSString *const OPTLYLoggerMessagesUserProfileVariationNoLongerInDatafile = @"Variation %@ for experiment %@ no longer found in datafile.";
125127
// Debug
126128
NSString *const OPTLYLoggerMessagesUserProfileVariation = @"Variation %@ for user %@, experiment %@ found.";
127129
NSString *const OPTLYLoggerMessagesUserProfileNoVariation = @"Variation for user %@, experiment %@ not found.";

OptimizelySDKCore/OptimizelySDKCore/Optimizely.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ - (OPTLYVariation *)getVariationForExperiment:(NSString *)experimentKey
150150
if (storedVariation != nil) {
151151
return storedVariation;
152152
}
153+
else { // stored variation is no longer in datafile
154+
[self.userProfile removeUser:userId experiment:experimentKey];
155+
[self.logger logMessage:[NSString stringWithFormat:OPTLYLoggerMessagesUserProfileVariationNoLongerInDatafile, storedVariationKey, experimentKey]
156+
withLevel:OptimizelyLogLevelWarning];
157+
}
153158
}
154159
}
155160
OPTLYVariation *bucketedVariation = nil;

0 commit comments

Comments
 (0)