Skip to content

Commit c31df22

Browse files
authored
Merge pull request #169 from optimizely/jae/names
change names to OptimizelyClient and start
2 parents 0d0925e + ae10210 commit c31df22

32 files changed

+209
-209
lines changed

DemoObjCApp/AppDelegate.m

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
@interface AppDelegate ()
3434
@property(nonnull, strong, nonatomic) NSString *userId;
3535
@property(nonnull, strong, nonatomic) NSDictionary *attributes;
36-
@property(nullable, strong, nonatomic) OptimizelyManager *optimizely;
36+
@property(nullable, strong, nonatomic) OptimizelyClient *optimizely;
3737
@end
3838

3939
@implementation AppDelegate
@@ -62,9 +62,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
6262
// MARK: - Initialization Examples
6363

6464
-(void)initializeOptimizelySDKAsynchronous {
65-
self.optimizely = [[OptimizelyManager alloc] initWithSdkKey:kOptimizelySdkKey];
65+
self.optimizely = [[OptimizelyClient alloc] initWithSdkKey:kOptimizelySdkKey];
6666

67-
[self.optimizely initializeSDKWithCompletion:^(NSData *data, NSError *error) {
67+
[self.optimizely startWithCompletion:^(NSData *data, NSError *error) {
6868
if (error == nil) {
6969
NSLog(@"Optimizely SDK initialized successfully!");
7070
} else {
@@ -84,7 +84,7 @@ -(void)initializeOptimizelySDKSynchronous {
8484
return;
8585
}
8686

87-
self.optimizely = [[OptimizelyManager alloc] initWithSdkKey:kOptimizelySdkKey];
87+
self.optimizely = [[OptimizelyClient alloc] initWithSdkKey:kOptimizelySdkKey];
8888

8989
NSString *datafileJSON = [NSString stringWithContentsOfFile:localDatafilePath encoding:NSUTF8StringEncoding error:nil];
9090

@@ -93,7 +93,7 @@ -(void)initializeOptimizelySDKSynchronous {
9393
self.optimizely = nil;
9494
} else {
9595
NSError *error;
96-
BOOL status = [self.optimizely initializeSDKWithDatafile:datafileJSON error:&error];
96+
BOOL status = [self.optimizely startWithDatafile:datafileJSON error:&error];
9797
if (status) {
9898
NSLog(@"Optimizely SDK initialized successfully!");
9999
} else {
@@ -113,7 +113,7 @@ -(void)initializeOptimizelySDKWithCustomization {
113113
// This should be should be much larger (default = 10 mins).
114114
NSNumber *customDownloadIntervalInSecs = @(30);
115115

116-
self.optimizely = [[OptimizelyManager alloc] initWithSdkKey:kOptimizelySdkKey
116+
self.optimizely = [[OptimizelyClient alloc] initWithSdkKey:kOptimizelySdkKey
117117
logger:customLogger
118118
eventDispatcher:nil
119119
userProfileService:nil
@@ -144,7 +144,7 @@ -(void)initializeOptimizelySDKWithCustomization {
144144
#endif
145145
}];
146146

147-
[self.optimizely initializeSDKWithCompletion:^(NSData *data, NSError *error) {
147+
[self.optimizely startWithCompletion:^(NSData *data, NSError *error) {
148148
if (error == nil) {
149149
NSLog(@"Optimizely SDK initialized successfully!");
150150
} else {

DemoObjCApp/VariationViewController.h

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

1717
#import <UIKit/UIKit.h>
1818

19-
@class OptimizelyManager;
19+
@class OptimizelyClient;
2020

2121
@interface VariationViewController : UIViewController
22-
@property(nullable, nonatomic, strong) OptimizelyManager *optimizely;
22+
@property(nullable, nonatomic, strong) OptimizelyClient *optimizely;
2323
@property(nonnull, nonatomic, strong) NSString *eventKey;
2424
@property(nonnull, nonatomic, strong) NSString *variationKey;
2525
@property(nonnull, nonatomic, strong) NSString *userId;

DemoSwiftApp/AppDelegate.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
3232
let attributes: [String : Any?] = ["browser_type": "safari", "bool_attr": false]
3333

3434
var window: UIWindow?
35-
var optimizely: OptimizelyManager!
35+
var optimizely: OptimizelyClient!
3636
var storyboard: UIStoryboard {
3737
#if os(iOS)
3838
return UIStoryboard(name: "iOSMain", bundle: nil)
@@ -61,9 +61,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
6161
// MARK: - Initialization Examples
6262

6363
func initializeOptimizelySDKAsynchronous() {
64-
optimizely = OptimizelyManager(sdkKey: sdkKey)
64+
optimizely = OptimizelyClient(sdkKey: sdkKey)
6565

66-
optimizely.initializeSDK { result in
66+
optimizely.start { result in
6767
switch result {
6868
case .failure(let error):
6969
print("Optimizely SDK initiliazation failed: \(error)")
@@ -83,11 +83,11 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
8383
fatalError("Local datafile cannot be found")
8484
}
8585

86-
optimizely = OptimizelyManager(sdkKey: sdkKey)
86+
optimizely = OptimizelyClient(sdkKey: sdkKey)
8787

8888
do {
8989
let datafileJSON = try String(contentsOfFile: localDatafilePath, encoding: .utf8)
90-
try optimizely!.initializeSDK(datafile: datafileJSON)
90+
try optimizely!.start(datafile: datafileJSON)
9191
print("Optimizely SDK initialized successfully!")
9292
} catch {
9393
print("Optimizely SDK initiliazation failed: \(error)")
@@ -105,7 +105,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
105105
// This should be should be much larger (default = 10 mins).
106106
let customDownloadIntervalInSecs = 30
107107

108-
optimizely = OptimizelyManager(sdkKey: sdkKey,
108+
optimizely = OptimizelyClient(sdkKey: sdkKey,
109109
logger: customLogger,
110110
periodicDownloadInterval: customDownloadIntervalInSecs)
111111

@@ -154,7 +154,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
154154

155155
// initialize SDK
156156

157-
optimizely!.initializeSDK { result in
157+
optimizely!.start { result in
158158
switch result {
159159
case .failure(let error):
160160
print("Optimizely SDK initiliazation failed: \(error)")

DemoSwiftApp/VariationViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class VariationViewController: UIViewController {
2222
var eventKey: String!
2323
var userId: String!
2424
var variationKey: String?
25-
var optimizely: OptimizelyManager?
25+
var optimizely: OptimizelyClient?
2626
var showCoupon: Bool = false {
2727
didSet {
2828
DispatchQueue.main.async {

OptimizelySDK/Extensions/OptimizelyManager+Extension.swift renamed to OptimizelySDK/Extensions/OptimizelyClient+Extension.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import Foundation
1818

19-
extension OptimizelyManager {
19+
extension OptimizelyClient {
2020
func registerServices(sdkKey:String,
2121
logger:OPTLogger,
2222
eventDispatcher:OPTEventDispatcher,

OptimizelySDK/Optimizely/OptimizelyManager+ObjC.swift renamed to OptimizelySDK/Optimizely/OptimizelyClient+ObjC.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import Foundation
1818

19-
extension OptimizelyManager {
19+
extension OptimizelyClient {
2020

2121

2222
@available(swift, obsoleted: 1.0)
@@ -58,16 +58,16 @@ extension OptimizelyManager {
5858
}
5959

6060
@available(swift, obsoleted: 1.0)
61-
@objc(initializeSDKWithCompletion:)
61+
@objc(startWithCompletion:)
6262
/// Start Optimizely SDK (Asynchronous)
6363
///
6464
/// If an updated datafile is available in the server, it's downloaded and the SDK is configured with
6565
/// the updated datafile.
6666
///
6767
/// - Parameters:
6868
/// - completion: callback when initialization is completed
69-
public func _objcInitializeSDK(completion: ((Data?, NSError?) -> Void)?) {
70-
initializeSDK { result in
69+
public func _objcStart(completion: ((Data?, NSError?) -> Void)?) {
70+
start { result in
7171
switch result {
7272
case .failure(let error):
7373
completion?(nil, self.convertErrorForObjc(error))
@@ -78,19 +78,19 @@ extension OptimizelyManager {
7878
}
7979

8080
@available(swift, obsoleted: 1.0)
81-
@objc(initializeSDKWithDatafile:error:)
81+
@objc(startWithDatafile:error:)
8282
/// Start Optimizely SDK (Synchronous)
8383
///
8484
/// - Parameters:
8585
/// - datafile: This datafile will be used when cached copy is not available (fresh start).
8686
/// A cached copy from previous download is used if it's available.
8787
/// The datafile will be updated from the server in the background thread.
8888
public func _objcStartWith(datafile:String) throws {
89-
try self.initializeSDK(datafile: datafile)
89+
try self.start(datafile: datafile)
9090
}
9191

9292
@available(swift, obsoleted: 1.0)
93-
@objc(initializeSDKWithDatafile:doFetchDatafileBackground:error:)
93+
@objc(startWithDatafile:doFetchDatafileBackground:error:)
9494
/// Start Optimizely SDK (Synchronous)
9595
///
9696
/// - Parameters:
@@ -101,7 +101,7 @@ extension OptimizelyManager {
101101
/// you don't want to download the datafile. In practice, you should allow the
102102
/// background thread to update the cache copy (optional)
103103
public func _objcStart(datafile: Data, doFetchDatafileBackground: Bool = true) throws {
104-
try self.initializeSDK(datafile: datafile, doFetchDatafileBackground: doFetchDatafileBackground)
104+
try self.start(datafile: datafile, doFetchDatafileBackground: doFetchDatafileBackground)
105105
}
106106

107107
@available(swift, obsoleted: 1.0)
@@ -310,7 +310,7 @@ extension OptimizelyManager {
310310

311311
// MARK: - ObjC Type Conversions
312312

313-
extension OptimizelyManager {
313+
extension OptimizelyClient {
314314

315315
/// EventDispatcher implementation for Objective-C interface support
316316
class SwiftEventDispatcher: OPTEventDispatcher {

OptimizelySDK/Optimizely/OptimizelyManager.swift renamed to OptimizelySDK/Optimizely/OptimizelyClient.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import Foundation
1919
public typealias OptimizelyAttributes = [String: Any?]
2020
public typealias OptimizelyEventTags = [String: Any]
2121

22-
open class OptimizelyManager: NSObject {
22+
open class OptimizelyClient: NSObject {
2323

2424
// MARK: - Properties
2525

@@ -98,7 +98,7 @@ open class OptimizelyManager: NSObject {
9898
/// - Parameters:
9999
/// - resourceTimeout: timeout for datafile download (optional)
100100
/// - completion: callback when initialization is completed
101-
public func initializeSDK(resourceTimeout:Double? = nil, completion: ((OptimizelyResult<Data>) -> Void)?=nil) {
101+
public func start(resourceTimeout:Double? = nil, completion: ((OptimizelyResult<Data>) -> Void)?=nil) {
102102
fetchDatafileBackground(resourceTimeout:resourceTimeout) { result in
103103
switch result {
104104
case .failure:
@@ -124,12 +124,12 @@ open class OptimizelyManager: NSObject {
124124
/// - datafile: This datafile will be used when cached copy is not available (fresh start).
125125
/// A cached copy from previous download is used if it's available.
126126
/// The datafile will be updated from the server in the background thread.
127-
public func initializeSDK(datafile: String) throws {
127+
public func start(datafile: String) throws {
128128
guard let datafileData = datafile.data(using: .utf8) else {
129129
throw OptimizelyError.dataFileInvalid
130130
}
131131

132-
try initializeSDK(datafile: datafileData)
132+
try start(datafile: datafileData)
133133
}
134134

135135
/// Start Optimizely SDK (Synchronous)
@@ -141,7 +141,7 @@ open class OptimizelyManager: NSObject {
141141
/// - doFetchDatafileBackground: This is for debugging purposes when
142142
/// you don't want to download the datafile. In practice, you should allow the
143143
/// background thread to update the cache copy (optional)
144-
public func initializeSDK(datafile: Data, doFetchDatafileBackground: Bool = true) throws {
144+
public func start(datafile: Data, doFetchDatafileBackground: Bool = true) throws {
145145
let cachedDatafile = self.datafileHandler.loadSavedDatafile(sdkKey: self.sdkKey)
146146

147147
let selectedDatafile = cachedDatafile ?? datafile
@@ -645,7 +645,7 @@ open class OptimizelyManager: NSObject {
645645

646646
}
647647

648-
extension OptimizelyManager {
648+
extension OptimizelyClient {
649649

650650
func sendImpressionEvent(experiment: Experiment,
651651
variation:Variation,

0 commit comments

Comments
 (0)