Skip to content

Commit baa6b05

Browse files
Manually merging user profile pull request: #38
2 parents e21e98c + a60a0a5 commit baa6b05

File tree

50 files changed

+1044
-148
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1044
-148
lines changed

OptimizelySDKCore/OptimizelySDKCore.xcodeproj/project.pbxproj

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,14 @@
2222
EA064BCA1DD3FC8800DF7537 /* OPTLYQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = EA064BC61DD3FC8800DF7537 /* OPTLYQueue.m */; };
2323
EA064BCE1DD3FCD700DF7537 /* OPTLYQueueTest.m in Sources */ = {isa = PBXBuildFile; fileRef = EA064BCB1DD3FC9F00DF7537 /* OPTLYQueueTest.m */; };
2424
EA064BCF1DD3FCD800DF7537 /* OPTLYQueueTest.m in Sources */ = {isa = PBXBuildFile; fileRef = EA064BCB1DD3FC9F00DF7537 /* OPTLYQueueTest.m */; };
25+
EA2C242D1DE6A2470063ADA0 /* OPTLYProjectConfigBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = EA2C242B1DE6A2470063ADA0 /* OPTLYProjectConfigBuilder.h */; settings = {ATTRIBUTES = (Public, ); }; };
26+
EA2C242E1DE6A2470063ADA0 /* OPTLYProjectConfigBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = EA2C242B1DE6A2470063ADA0 /* OPTLYProjectConfigBuilder.h */; settings = {ATTRIBUTES = (Public, ); }; };
27+
EA2C242F1DE6A2470063ADA0 /* OPTLYProjectConfigBuilder.m in Sources */ = {isa = PBXBuildFile; fileRef = EA2C242C1DE6A2470063ADA0 /* OPTLYProjectConfigBuilder.m */; };
28+
EA2C24301DE6A2470063ADA0 /* OPTLYProjectConfigBuilder.m in Sources */ = {isa = PBXBuildFile; fileRef = EA2C242C1DE6A2470063ADA0 /* OPTLYProjectConfigBuilder.m */; };
29+
EA2C24331DE7887C0063ADA0 /* OPTLYVariationVariable.h in Headers */ = {isa = PBXBuildFile; fileRef = EA2C24311DE7887C0063ADA0 /* OPTLYVariationVariable.h */; };
30+
EA2C24341DE7887C0063ADA0 /* OPTLYVariationVariable.h in Headers */ = {isa = PBXBuildFile; fileRef = EA2C24311DE7887C0063ADA0 /* OPTLYVariationVariable.h */; };
31+
EA2C24351DE7887C0063ADA0 /* OPTLYVariationVariable.m in Sources */ = {isa = PBXBuildFile; fileRef = EA2C24321DE7887C0063ADA0 /* OPTLYVariationVariable.m */; };
32+
EA2C24361DE7887C0063ADA0 /* OPTLYVariationVariable.m in Sources */ = {isa = PBXBuildFile; fileRef = EA2C24321DE7887C0063ADA0 /* OPTLYVariationVariable.m */; };
2533
EA2FA8071DC5DBA000B1D81B /* OptimizelySDKCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA2FA7FE1DC5DBA000B1D81B /* OptimizelySDKCore.framework */; };
2634
EA2FA8271DC5DBB100B1D81B /* OptimizelySDKCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA2FA81E1DC5DBB100B1D81B /* OptimizelySDKCore.framework */; };
2735
EA2FA9771DC6F3CF00B1D81B /* murmur3.h in Headers */ = {isa = PBXBuildFile; fileRef = EA2FA9701DC6F3CF00B1D81B /* murmur3.h */; };
@@ -206,6 +214,10 @@
206214
EA5249651DC7B69A00AF6685 /* OPTLYEventDispatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = EA5249631DC7B69A00AF6685 /* OPTLYEventDispatcher.m */; };
207215
EA5249771DC7C6EF00AF6685 /* OPTLYEventDispatcher.h in Headers */ = {isa = PBXBuildFile; fileRef = EA5249621DC7B69A00AF6685 /* OPTLYEventDispatcher.h */; settings = {ATTRIBUTES = (Public, ); }; };
208216
EA5249F21DC7FACF00AF6685 /* OPTLYEventDispatcher.m in Sources */ = {isa = PBXBuildFile; fileRef = EA5249631DC7B69A00AF6685 /* OPTLYEventDispatcher.m */; };
217+
EA87A02A1DE31453002E9EF7 /* OPTLYUserProfile.h in Headers */ = {isa = PBXBuildFile; fileRef = EA87A0281DE31453002E9EF7 /* OPTLYUserProfile.h */; settings = {ATTRIBUTES = (Public, ); }; };
218+
EA87A02B1DE31453002E9EF7 /* OPTLYUserProfile.h in Headers */ = {isa = PBXBuildFile; fileRef = EA87A0281DE31453002E9EF7 /* OPTLYUserProfile.h */; settings = {ATTRIBUTES = (Public, ); }; };
219+
EA87A02C1DE31453002E9EF7 /* OPTLYUserProfile.m in Sources */ = {isa = PBXBuildFile; fileRef = EA87A0291DE31453002E9EF7 /* OPTLYUserProfile.m */; };
220+
EA87A02D1DE31453002E9EF7 /* OPTLYUserProfile.m in Sources */ = {isa = PBXBuildFile; fileRef = EA87A0291DE31453002E9EF7 /* OPTLYUserProfile.m */; };
209221
/* End PBXBuildFile section */
210222

211223
/* Begin PBXContainerItemProxy section */
@@ -252,6 +264,10 @@
252264
EA064BC51DD3FC8800DF7537 /* OPTLYQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OPTLYQueue.h; sourceTree = "<group>"; };
253265
EA064BC61DD3FC8800DF7537 /* OPTLYQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OPTLYQueue.m; sourceTree = "<group>"; };
254266
EA064BCB1DD3FC9F00DF7537 /* OPTLYQueueTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OPTLYQueueTest.m; sourceTree = "<group>"; };
267+
EA2C242B1DE6A2470063ADA0 /* OPTLYProjectConfigBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OPTLYProjectConfigBuilder.h; sourceTree = "<group>"; };
268+
EA2C242C1DE6A2470063ADA0 /* OPTLYProjectConfigBuilder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OPTLYProjectConfigBuilder.m; sourceTree = "<group>"; };
269+
EA2C24311DE7887C0063ADA0 /* OPTLYVariationVariable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OPTLYVariationVariable.h; sourceTree = "<group>"; };
270+
EA2C24321DE7887C0063ADA0 /* OPTLYVariationVariable.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OPTLYVariationVariable.m; sourceTree = "<group>"; };
255271
EA2FA7FE1DC5DBA000B1D81B /* OptimizelySDKCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OptimizelySDKCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
256272
EA2FA8061DC5DBA000B1D81B /* OptimizelySDKCoreiOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = OptimizelySDKCoreiOSTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
257273
EA2FA81E1DC5DBB100B1D81B /* OptimizelySDKCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OptimizelySDKCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -351,6 +367,8 @@
351367
EA3C68161DC1E66C00C578CA /* OptimizelySDKCoreTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "OptimizelySDKCoreTests-Info.plist"; sourceTree = "<group>"; };
352368
EA5249621DC7B69A00AF6685 /* OPTLYEventDispatcher.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OPTLYEventDispatcher.h; sourceTree = "<group>"; };
353369
EA5249631DC7B69A00AF6685 /* OPTLYEventDispatcher.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OPTLYEventDispatcher.m; sourceTree = "<group>"; };
370+
EA87A0281DE31453002E9EF7 /* OPTLYUserProfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = OPTLYUserProfile.h; path = OptimizelySDKCore/OPTLYUserProfile.h; sourceTree = "<group>"; };
371+
EA87A0291DE31453002E9EF7 /* OPTLYUserProfile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = OPTLYUserProfile.m; path = OptimizelySDKCore/OPTLYUserProfile.m; sourceTree = "<group>"; };
354372
F5B1C4BBC7682A657C92ABD3 /* Pods_OptimizelySDKCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_OptimizelySDKCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
355373
F6CC17F155793CF43AB7A3D9 /* Pods-OptimizelySDKCoreTVOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-OptimizelySDKCoreTVOS.debug.xcconfig"; path = "../Pods/Target Support Files/Pods-OptimizelySDKCoreTVOS/Pods-OptimizelySDKCoreTVOS.debug.xcconfig"; sourceTree = "<group>"; };
356374
/* End PBXFileReference section */
@@ -491,6 +509,8 @@
491509
5ECBBE671DDE6A800028FF6B /* OPTLYVariable.m */,
492510
EA2FAA821DC6F57100B1D81B /* OPTLYVariation.h */,
493511
EA2FAA831DC6F57100B1D81B /* OPTLYVariation.m */,
512+
EA2C24311DE7887C0063ADA0 /* OPTLYVariationVariable.h */,
513+
EA2C24321DE7887C0063ADA0 /* OPTLYVariationVariable.m */,
494514
);
495515
name = "Data Models";
496516
sourceTree = "<group>";
@@ -531,6 +551,8 @@
531551
children = (
532552
EA2FAB1D1DC6F58800B1D81B /* OPTLYBuilder.h */,
533553
EA2FAB1E1DC6F58800B1D81B /* OPTLYBuilder.m */,
554+
EA2C242B1DE6A2470063ADA0 /* OPTLYProjectConfigBuilder.h */,
555+
EA2C242C1DE6A2470063ADA0 /* OPTLYProjectConfigBuilder.m */,
534556
);
535557
name = Builder;
536558
sourceTree = "<group>";
@@ -608,6 +630,7 @@
608630
EA2FA8411DC5E14700B1D81B /* Error Handler */,
609631
EA2FA8421DC5E15700B1D81B /* Event Builder */,
610632
EA5249611DC7B64C00AF6685 /* EventDispatcher */,
633+
EA87A0271DE3142A002E9EF7 /* UserProfile */,
611634
EA2FA8451DC5E1A300B1D81B /* Loggers */,
612635
EA2FA83D1DC5E0E900B1D81B /* Utilities */,
613636
);
@@ -647,6 +670,16 @@
647670
name = EventDispatcher;
648671
sourceTree = "<group>";
649672
};
673+
EA87A0271DE3142A002E9EF7 /* UserProfile */ = {
674+
isa = PBXGroup;
675+
children = (
676+
EA87A0281DE31453002E9EF7 /* OPTLYUserProfile.h */,
677+
EA87A0291DE31453002E9EF7 /* OPTLYUserProfile.m */,
678+
);
679+
name = UserProfile;
680+
path = ..;
681+
sourceTree = "<group>";
682+
};
650683
/* End PBXGroup section */
651684

652685
/* Begin PBXHeadersBuildPhase section */
@@ -669,6 +702,8 @@
669702
EA2FAB381DC6F59D00B1D81B /* OPTLYErrorHandlerMessages.h in Headers */,
670703
EA5249641DC7B69A00AF6685 /* OPTLYEventDispatcher.h in Headers */,
671704
EA2FAB731DC6F5F400B1D81B /* OPTLYLog.h in Headers */,
705+
EA2C242D1DE6A2470063ADA0 /* OPTLYProjectConfigBuilder.h in Headers */,
706+
EA87A02A1DE31453002E9EF7 /* OPTLYUserProfile.h in Headers */,
672707
EA064BC71DD3FC8800DF7537 /* OPTLYQueue.h in Headers */,
673708
EA2FAB791DC6F5F400B1D81B /* OPTLYMacros.h in Headers */,
674709
EA2FAAF41DC6F57200B1D81B /* OPTLYEventTicket.h in Headers */,
@@ -683,6 +718,7 @@
683718
EA2FAAEE1DC6F57200B1D81B /* OPTLYEventRelatedEvent.h in Headers */,
684719
EA2FAAAC1DC6F57200B1D81B /* OPTLYEvent.h in Headers */,
685720
EA2FAAD01DC6F57200B1D81B /* OPTLYEventFeature.h in Headers */,
721+
EA2C24331DE7887C0063ADA0 /* OPTLYVariationVariable.h in Headers */,
686722
EA2FAABE1DC6F57200B1D81B /* OPTLYEventDecision.h in Headers */,
687723
EA2FAAA61DC6F57200B1D81B /* OPTLYDecisionEventTicket.h in Headers */,
688724
EA2FAAC41DC6F57200B1D81B /* OPTLYEventDecisionTicket.h in Headers */,
@@ -715,7 +751,9 @@
715751
EA2FAB391DC6F59D00B1D81B /* OPTLYErrorHandlerMessages.h in Headers */,
716752
EA5249771DC7C6EF00AF6685 /* OPTLYEventDispatcher.h in Headers */,
717753
EA2FAB741DC6F5F400B1D81B /* OPTLYLog.h in Headers */,
754+
EA87A02B1DE31453002E9EF7 /* OPTLYUserProfile.h in Headers */,
718755
EA064BC81DD3FC8800DF7537 /* OPTLYQueue.h in Headers */,
756+
EA2C242E1DE6A2470063ADA0 /* OPTLYProjectConfigBuilder.h in Headers */,
719757
EA2FAC7B1DC70EBC00B1D81B /* murmur3.h in Headers */,
720758
EA2FAB7A1DC6F5F400B1D81B /* OPTLYMacros.h in Headers */,
721759
EA2FAA951DC6F57100B1D81B /* OPTLYBaseCondition.h in Headers */,
@@ -729,6 +767,7 @@
729767
EA2FAB071DC6F57200B1D81B /* OPTLYGroup.h in Headers */,
730768
EA2FAAE91DC6F57200B1D81B /* OPTLYEventParameterKeys.h in Headers */,
731769
EA2FAAFB1DC6F57200B1D81B /* OPTLYEventView.h in Headers */,
770+
EA2C24341DE7887C0063ADA0 /* OPTLYVariationVariable.h in Headers */,
732771
EA2FAABF1DC6F57200B1D81B /* OPTLYEventDecision.h in Headers */,
733772
EA2FAAD71DC6F57200B1D81B /* OPTLYEventHeader.h in Headers */,
734773
EA2FAAD11DC6F57200B1D81B /* OPTLYEventFeature.h in Headers */,
@@ -1093,6 +1132,7 @@
10931132
EA2FAC151DC6FFC600B1D81B /* OPTLYEventHeader.m in Sources */,
10941133
EA2FAC161DC6FFC600B1D81B /* OPTLYEventLayerState.m in Sources */,
10951134
EA5249651DC7B69A00AF6685 /* OPTLYEventDispatcher.m in Sources */,
1135+
EA2C242F1DE6A2470063ADA0 /* OPTLYProjectConfigBuilder.m in Sources */,
10961136
EA2FAC171DC6FFC600B1D81B /* OPTLYEventMetric.m in Sources */,
10971137
EA2FAC181DC6FFC600B1D81B /* OPTLYEventParameterKeys.m in Sources */,
10981138
EA2FAC191DC6FFC600B1D81B /* OPTLYEventRelatedEvent.m in Sources */,
@@ -1105,12 +1145,14 @@
11051145
EA2FAC1F1DC6FFC600B1D81B /* OPTLYTrafficAllocation.m in Sources */,
11061146
EA2FAC201DC6FFC600B1D81B /* OPTLYVariation.m in Sources */,
11071147
EA2FAC211DC6FFC600B1D81B /* OPTLYErrorHandler.m in Sources */,
1148+
EA87A02C1DE31453002E9EF7 /* OPTLYUserProfile.m in Sources */,
11081149
EA2FAC221DC6FFC600B1D81B /* OPTLYErrorHandlerMessages.m in Sources */,
11091150
EA2FAC241DC6FFC600B1D81B /* OPTLYEventBuilder.m in Sources */,
11101151
EA2FAC251DC6FFC600B1D81B /* OPTLYLogger.m in Sources */,
11111152
5ECBBE691DDE6A800028FF6B /* OPTLYVariable.m in Sources */,
11121153
EA2FAC261DC6FFC600B1D81B /* OPTLYLoggerMessages.m in Sources */,
11131154
EA2FAC291DC6FFC600B1D81B /* OPTLYLog.m in Sources */,
1155+
EA2C24351DE7887C0063ADA0 /* OPTLYVariationVariable.m in Sources */,
11141156
EA2FAC2A1DC6FFC600B1D81B /* OPTLYValidator.m in Sources */,
11151157
);
11161158
runOnlyForDeploymentPostprocessing = 0;
@@ -1158,6 +1200,7 @@
11581200
EA2FABF01DC6FFA100B1D81B /* OPTLYEventHeader.m in Sources */,
11591201
EA2FABF11DC6FFA100B1D81B /* OPTLYEventLayerState.m in Sources */,
11601202
EA5249F21DC7FACF00AF6685 /* OPTLYEventDispatcher.m in Sources */,
1203+
EA2C24301DE6A2470063ADA0 /* OPTLYProjectConfigBuilder.m in Sources */,
11611204
EA2FABF21DC6FFA100B1D81B /* OPTLYEventMetric.m in Sources */,
11621205
EA2FABF31DC6FFA100B1D81B /* OPTLYEventParameterKeys.m in Sources */,
11631206
EA2FABF41DC6FFA100B1D81B /* OPTLYEventRelatedEvent.m in Sources */,
@@ -1170,12 +1213,14 @@
11701213
EA2FABFA1DC6FFA100B1D81B /* OPTLYTrafficAllocation.m in Sources */,
11711214
EA2FABFB1DC6FFA100B1D81B /* OPTLYVariation.m in Sources */,
11721215
EA2FABFC1DC6FFA100B1D81B /* OPTLYErrorHandler.m in Sources */,
1216+
EA87A02D1DE31453002E9EF7 /* OPTLYUserProfile.m in Sources */,
11731217
EA2FABFD1DC6FFA100B1D81B /* OPTLYErrorHandlerMessages.m in Sources */,
11741218
EA2FABFF1DC6FFA100B1D81B /* OPTLYEventBuilder.m in Sources */,
11751219
EA2FAC001DC6FFA100B1D81B /* OPTLYLogger.m in Sources */,
11761220
5E3C0E701DDF7A290025DB85 /* OPTLYVariable.m in Sources */,
11771221
EA2FAC011DC6FFA100B1D81B /* OPTLYLoggerMessages.m in Sources */,
11781222
EA2FAC041DC6FFA100B1D81B /* OPTLYLog.m in Sources */,
1223+
EA2C24361DE7887C0063ADA0 /* OPTLYVariationVariable.m in Sources */,
11791224
EA2FAC051DC6FFA100B1D81B /* OPTLYValidator.m in Sources */,
11801225
);
11811226
runOnlyForDeploymentPostprocessing = 0;

OptimizelySDKCore/OptimizelySDKCore/OPTLYBucketer.m

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#import "murmur3.h"
2222
#import "OPTLYLogger.h"
2323
#import "OPTLYErrorHandler.h"
24+
#import "OPTLYUserProfile.h"
2425

2526
NSString *const OPTLYBucketerMutexPolicy = @"random";
2627
NSString *const OPTLYBucketerOverlappingPolicy = @"overlapping";
@@ -66,6 +67,17 @@ - (OPTLYVariation *)bucketExperiment:(OPTLYExperiment *)experiment
6667
return whitelistedVariation;
6768
}
6869

70+
NSString *stickyBucketingVariationKey = [self.config.userProfile getVariationFor:userId experiment:experiment.experimentKey];
71+
if ([stickyBucketingVariationKey length] > 0) {
72+
OPTLYVariation *stickyBucketingVariation = [experiment getVariationForVariationKey:stickyBucketingVariationKey];
73+
if (stickyBucketingVariation) {
74+
NSString *logMessage = [NSString stringWithFormat:OPTLYLoggerMessagesBucketerUserDataRetrieved, userId, experiment.experimentKey, stickyBucketingVariation.variationKey];
75+
[self.config.logger logMessage:logMessage withLevel:OptimizelyLogLevelDebug];
76+
77+
return stickyBucketingVariation;
78+
}
79+
}
80+
6981
// check for mutex
7082
NSString *groupId = experiment.groupId;
7183
if (groupId != nil) {
@@ -89,7 +101,14 @@ - (OPTLYVariation *)bucketExperiment:(OPTLYExperiment *)experiment
89101

90102
// bucket to variation only if experiment passes Mutex check
91103
if (experiment != nil) {
92-
return [self bucketToVariation:experiment withUserId:userId];
104+
OPTLYVariation *variation = [self bucketToVariation:experiment withUserId:userId];
105+
if (variation) {
106+
[self.config.userProfile save:userId experiment:experiment.experimentKey variation:variation.variationKey];
107+
108+
NSString *logMessage = [NSString stringWithFormat:OPTLYLoggerMessagesBucketerSavingUserData, userId, experiment.experimentKey, variation.variationKey];
109+
[self.config.logger logMessage:logMessage withLevel:OptimizelyLogLevelDebug];
110+
}
111+
return variation;
93112
}
94113
else {
95114
// log message if the user is mutually excluded

OptimizelySDKCore/OptimizelySDKCore/OPTLYBuilder.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
#import <Foundation/Foundation.h>
1818

19-
@class OPTLYProjectConfig, OPTLYBucketer, OPTLYEventBuilder, OPTLYEventBuilderDefault;
20-
@protocol OPTLYErrorHandler, OPTLYEventBuilder, OPTLYEventDispatcher, OPTLYLogger;
19+
@class OPTLYBucketer, OPTLYEventBuilder, OPTLYEventBuilderDefault, OPTLYProjectConfig;
20+
@protocol OPTLYErrorHandler, OPTLYEventBuilder, OPTLYEventDispatcher, OPTLYLogger, OPTLYProjectConfig, OPTLYUserProfile;
2121

2222
/**
2323
* This class contains the information on how your Optimizely instance will be built.
@@ -44,6 +44,8 @@ typedef void (^OPTLYBuilderBlock)(OPTLYBuilder * _Nullable builder);
4444
@property (nonatomic, readwrite, strong, nullable) id<OPTLYEventDispatcher> eventDispatcher;
4545
/// The logger is by default set to one that is created by Optimizely. This default logger can be overridden by any object that conforms to the OPTLYLogger protocol.
4646
@property (nonatomic, readwrite, strong, nullable) id<OPTLYLogger> logger;
47+
/// User profile stores user-specific data, like bucketing.
48+
@property (nonatomic, readwrite, strong, nullable) id<OPTLYUserProfile> userProfile;
4749

4850
/// Create an Optimizely Builder object.
4951
+ (nullable instancetype)builderWithBlock:(nonnull OPTLYBuilderBlock)block;

OptimizelySDKCore/OptimizelySDKCore/OPTLYBuilder.m

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#import "OPTLYEventDispatcher.h"
2222
#import "OPTLYLogger.h"
2323
#import "OPTLYProjectConfig.h"
24+
#import "OPTLYUserProfile.h"
2425

2526
@implementation OPTLYBuilder
2627

@@ -47,7 +48,13 @@ - (id)initWithBlock:(OPTLYBuilderBlock)block {
4748
if (_datafile == nil) {
4849
return nil;
4950
}
50-
_config = [[OPTLYProjectConfig alloc] initWithDatafile:_datafile withLogger:_logger withErrorHandler:_errorHandler];
51+
52+
_config = [OPTLYProjectConfig initWithBuilderBlock:^(OPTLYProjectConfigBuilder * _Nullable builder) {
53+
builder.datafile = _datafile;
54+
builder.userProfile = _userProfile;
55+
builder.logger = _logger;
56+
builder.errorHandler = _errorHandler;
57+
}];
5158

5259
if (_config == nil) {
5360
NSError *error = [NSError errorWithDomain:OPTLYErrorHandlerMessagesDomain
@@ -99,4 +106,12 @@ - (NSData *)datafile {
99106
return _logger;
100107
}
101108

109+
- (id<OPTLYUserProfile>)userProfile {
110+
if (!_userProfile) {
111+
_userProfile = [[OPTLYUserProfileNoOp alloc] init];
112+
}
113+
return _userProfile;
114+
}
115+
116+
102117
@end

OptimizelySDKCore/OptimizelySDKCore/OPTLYDatafileKeys.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ extern NSString * const OPTLYDatafileKeysVariableId;
7474
extern NSString * const OPTLYDatafileKeysVariableKey;
7575
extern NSString * const OPTLYDatafileKeysVariableType;
7676
extern NSString * const OPTLYDatafileKeysVariableValue;
77+
// Variation Live Variable
78+
extern NSString * const OPTLYDatafileKeysVariationVariableId;
79+
extern NSString * const OPTLYDatafileKeysVariationVariableValue;
7780

7881
@interface OPTLYDatafileKeys : NSObject
7982

OptimizelySDKCore/OptimizelySDKCore/OPTLYDatafileKeys.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@
7070
NSString * const OPTLYDatafileKeysVariableKey = @"key";
7171
NSString * const OPTLYDatafileKeysVariableType = @"type";
7272
NSString * const OPTLYDatafileKeysVariableValue = @"value";
73+
// Variation Live Variable
74+
NSString * const OPTLYDatafileKeysVariationVariableId = @"id";
75+
NSString * const OPTLYDatafileKeysVariationVariableValue = @"value";
7376

7477
@implementation OPTLYDatafileKeys
7578
@end

OptimizelySDKCore/OptimizelySDKCore/OPTLYErrorHandler.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,9 @@
5454
@interface OPTLYErrorHandlerDefault : NSObject <OPTLYErrorHandler>
5555
@end
5656

57+
/**
58+
* OPTLYErrorHandlerNoOp comforms to the OPTLYErrorHandler protocol,
59+
* but all methods perform a no op.
60+
*/
5761
@interface OPTLYErrorHandlerNoOp : NSObject <OPTLYErrorHandler>
5862
@end

OptimizelySDKCore/OptimizelySDKCore/OPTLYErrorHandler.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ @implementation OPTLYErrorHandler
2121
+ (BOOL)conformsToOPTLYErrorHandlerProtocol:(Class)instanceClass
2222
{
2323
// compile-time check
24-
BOOL validProtocolDeclaration = [instanceClass conformsToProtocol:@protocol(OPTLYErrorHandler)];
24+
BOOL isValidProtocolDeclaration = [instanceClass conformsToProtocol:@protocol(OPTLYErrorHandler)];
2525

2626
// runtime checks
2727
BOOL implementsHandleErrorMethod = [instanceClass instancesRespondToSelector:@selector(handleError:)];
2828
BOOL implementsHandleExceptionMethod = [instanceClass instancesRespondToSelector:@selector(handleException:)];
2929

30-
return validProtocolDeclaration && implementsHandleErrorMethod && implementsHandleExceptionMethod;
30+
return isValidProtocolDeclaration && implementsHandleErrorMethod && implementsHandleExceptionMethod;
3131

3232
}
3333

0 commit comments

Comments
 (0)