Skip to content

Commit 1efcacc

Browse files
Fixed a bug in getting the sticky bucketing values -- used wrong variation getter.
1 parent a5a17c8 commit 1efcacc

File tree

5 files changed

+5
-34
lines changed

5 files changed

+5
-34
lines changed

OptimizelySDKCore/OptimizelySDKCore/OPTLYBucketer.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ - (OPTLYVariation *)bucketExperiment:(OPTLYExperiment *)experiment
6969

7070
NSString *stickyBucketingVariationKey = [self.config.userProfile getVariationFor:userId experiment:experiment.experimentKey];
7171
if ([stickyBucketingVariationKey length] > 0) {
72-
OPTLYVariation *stickyBucketingVariation = [self.config getVariationForVariationKey:stickyBucketingVariationKey];
72+
OPTLYVariation *stickyBucketingVariation = [experiment getVariationForVariationKey:stickyBucketingVariationKey];
7373
if (stickyBucketingVariation) {
74-
7574
NSString *logMessage = [NSString stringWithFormat:OPTLYLoggerMessagesBucketerUserDataRetrieved, userId, experiment.experimentKey, stickyBucketingVariation.variationKey];
7675
[self.config.logger logMessage:logMessage withLevel:OptimizelyLogLevelDebug];
7776

OptimizelySDKCore/OptimizelySDKCore/OPTLYProjectConfig.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252

5353
/// a comprehensive list of experiments that includes experiments being whitelisted (in Groups)
5454
@property (nonatomic, strong, nullable) NSArray<OPTLYExperiment, Ignore> *allExperiments;
55-
@property (nonatomic, strong, nullable) NSArray<OPTLYVariation, Ignore> *allVariations;
5655
@property (nonatomic, strong, nullable) id<OPTLYLogger, Ignore> logger;
5756
@property (nonatomic, strong, nullable) id<OPTLYErrorHandler, Ignore> errorHandler;
5857
@property (nonatomic, strong, nullable) id<OPTLYUserProfile, Ignore> userProfile;
@@ -119,10 +118,6 @@
119118
userId:(nonnull NSString *)userId
120119
attributes:(nullable NSDictionary<NSString *,NSString *> *)attributes
121120
bucketer:(nullable id<OPTLYBucketer>)bucketer;
122-
/**
123-
* Get variation for given variation key.
124-
*/
125-
- (nullable OPTLYVariation *)getVariationForVariationKey:(nonnull NSString *)variationKey;
126121

127122
/*
128123
* Returns the client type (e.g., objective-c-sdk-core, objective-c-sdk-iOS, objective-c-sdk-tvOS)

OptimizelySDKCore/OptimizelySDKCore/OPTLYProjectConfig.m

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -223,19 +223,6 @@ - (OPTLYVariable *)getVariableForVariableKey:(NSString *)variableKey {
223223
return variable;
224224
}
225225

226-
- (OPTLYVariation *)getVariationForVariationKey:(NSString *)variationKey {
227-
NSArray *allVariations = [self allVariations];
228-
for (OPTLYVariation *variation in allVariations) {
229-
if ([variation.variationKey isEqualToString:variationKey]) {
230-
return variation;
231-
}
232-
}
233-
234-
NSString *logMessage = [NSString stringWithFormat:OPTLYLoggerMessagesVariationUnknownForVariationKey, variationKey];
235-
[self.logger logMessage:logMessage withLevel:OptimizelyLogLevelWarning];
236-
return nil;
237-
}
238-
239226
#pragma mark -- Property Getters --
240227

241228
- (NSArray *)allExperiments
@@ -252,18 +239,6 @@ - (NSArray *)allExperiments
252239
return _allExperiments;
253240
}
254241

255-
- (NSArray *)allVariations
256-
{
257-
if (!_allVariations) {
258-
NSMutableArray *all = [NSMutableArray new];
259-
for (OPTLYExperiment *experiment in [self allExperiments]) {
260-
[all addObject:experiment.variations];
261-
}
262-
_allVariations = [all copy];
263-
}
264-
return _allVariations;
265-
}
266-
267242
- (NSDictionary *)audienceIdToAudienceMap
268243
{
269244
if (!_audienceIdToAudienceMap) {

OptimizelySDKUserProfile/OptimizelySDKUserProfile/OPTLYUserProfile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
***************************************************************************/
1616

1717
#import <Foundation/Foundation.h>
18-
#import "OPTLYUserProfileBuilder.h"
1918
#import <OptimizelySDKCore/OPTLYUserProfile.h>
19+
#import "OPTLYUserProfileBuilder.h"
2020

2121
@protocol OPTLYLogger;
2222

OptimizelyiOSDemoApp/OptimizelyiOSDemoApp/AppDelegate.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
3333
var attributes = ["browser_type" : "firefox"]
3434
var eventKey = "testEventWithAudiences"
3535
var experimentKey = "testExperimentWithFirefoxAudience" // experiment ID: 6383811281
36-
let downloadDatafile = true
36+
let downloadDatafile = false
3737

3838
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
3939

@@ -107,6 +107,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
107107
optimizely = (Optimizely.initWithBuilderBlock({(builder)in
108108
builder!.datafile = jsonData
109109
builder!.eventDispatcher = eventDispatcher
110+
builder!.userProfile = OPTLYUserProfile.init()
110111
}))
111112
} catch {
112113
print("invalid json data")
@@ -135,6 +136,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
135136
let optimizely : Optimizely? = (Optimizely.initWithBuilderBlock({(builder)in
136137
builder!.datafile = data;
137138
builder!.eventDispatcher = eventDispatcher;
139+
builder!.userProfile = OPTLYUserProfile.init()
138140
}));
139141

140142
completionHandler(optimizely)

0 commit comments

Comments
 (0)