diff --git a/Example/Rudder/_AppDelegate.m b/Example/Rudder/_AppDelegate.m index 6b42277a..b8153ea1 100644 --- a/Example/Rudder/_AppDelegate.m +++ b/Example/Rudder/_AppDelegate.m @@ -9,7 +9,8 @@ #import "_AppDelegate.h" #import -static NSString *END_URL = @"https://89aef425.ngrok.io"; +static NSString *DATA_PLANE_URL = @"https://89aef425.ngrok.io"; +static NSString *CONTROL_PLANE_URL = @"https://api.rudderlabs.com"; static NSString *WRITE_KEY = @"1Xk22tE75wUqDqCSFvFHqeiYCdT"; @implementation _AppDelegate @@ -19,8 +20,8 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( { // Override point for customization after application launch. RudderConfigBuilder *builder = [[RudderConfigBuilder alloc] init]; - [builder withEndPointUrl:END_URL]; - [builder withConfigPlaneUrl:END_URL]; + [builder withDataPlaneUrl:DATA_PLANE_URL]; + [builder withControlPlaneUrl:CONTROL_PLANE_URL]; [builder withLoglevel:RudderLogLevelDebug]; [builder withTrackLifecycleEvens:YES]; [builder withRecordScreenViews:YES]; diff --git a/README.md b/README.md index 57a1b8ae..f40b2009 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Put this code in your ```AppDelegate.m``` file under the method ```didFinishLaun ```xcode RudderConfigBuilder *builder = [[RudderConfigBuilder alloc] init]; -[builder withEndPointUrl:]; +[builder withDataPlaneUrl:]; [RudderClient getInstance: config:[builder build]]; ``` A shared instance of ```RudderClient``` is accesible after the initialization by ```[RudderClient sharedInstance]``` @@ -57,4 +57,4 @@ Send events in Segment compatible way For more detailed documentation check [our documentation page](https://docs.rudderlabs.com/sdk-integration-guide/getting-started-with-ios-sdk) ## Contact Us -If you come across any issues while configuring or using RudderStack, please feel free to [contact us](https://rudderstack.com/contact/) or start a conversation on our [Discord](https://discordapp.com/invite/xNEdEGw) channel. We will be happy to help you. \ No newline at end of file +If you come across any issues while configuring or using RudderStack, please feel free to [contact us](https://rudderstack.com/contact/) or start a conversation on our [Discord](https://discordapp.com/invite/xNEdEGw) channel. We will be happy to help you. diff --git a/Rudder/Classes/Constants.h b/Rudder/Classes/Constants.h index 0f341592..716273ce 100644 --- a/Rudder/Classes/Constants.h +++ b/Rudder/Classes/Constants.h @@ -14,7 +14,7 @@ NS_ASSUME_NONNULL_BEGIN // how often config should be fetched from the server (in hours) (2 hrs by default) extern int const RudderConfigRefreshInterval; // default base url or rudder-backend-server -extern NSString *const RudderBaseUrl; +extern NSString *const RudderDataPlaneUrl; // default flush queue size for the events to be flushed to server extern int const RudderFlushQueueSize; // default threshold of number of events to be persisted in sqlite db @@ -24,7 +24,7 @@ extern int const RudderDBCountThreshold; // events will be flushed to server after sleepTimeOut seconds extern int const RudderSleepTimeout; // config-plane url to get the config for the writeKey -extern NSString *const RudderConfigPlaneUrl; +extern NSString *const RudderControlPlaneUrl; // whether we should trackLifecycle events extern bool const RudderTrackLifeCycleEvents; // whether we should record screen views automatically diff --git a/Rudder/Classes/Constants.m b/Rudder/Classes/Constants.m index 8c1d2437..a99361c5 100644 --- a/Rudder/Classes/Constants.m +++ b/Rudder/Classes/Constants.m @@ -10,11 +10,11 @@ @implementation Constants int const RudderConfigRefreshInterval = 2; -NSString *const RudderBaseUrl = @"https://api.rudderlabs.com"; +NSString *const RudderDataPlaneUrl = @"https://hosted.rudderlabs.com"; int const RudderFlushQueueSize = 30; int const RudderDBCountThreshold = 10000; int const RudderSleepTimeout = 10; -NSString *const RudderConfigPlaneUrl = @"https://api.rudderlabs.com"; +NSString *const RudderControlPlaneUrl = @"https://api.rudderlabs.com"; bool const RudderTrackLifeCycleEvents = YES; bool const RudderRecordScreenViews = NO; diff --git a/Rudder/Classes/EventRepository.m b/Rudder/Classes/EventRepository.m index a3b02e33..83099998 100644 --- a/Rudder/Classes/EventRepository.m +++ b/Rudder/Classes/EventRepository.m @@ -289,10 +289,10 @@ - (NSString* _Nullable) __flushEventsToServer: (NSString*) payload { dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); __block NSString *responseStr = nil; - NSString *endPointUrl = [self->config.endPointUrl stringByAppendingString:@"/v1/batch"]; - [RudderLogger logDebug:[[NSString alloc] initWithFormat:@"endPointToFlush %@", endPointUrl]]; + NSString *dataPlaneEndPoint = [self->config.dataPlaneUrl stringByAppendingString:@"/v1/batch"]; + [RudderLogger logDebug:[[NSString alloc] initWithFormat:@"endPointToFlush %@", dataPlaneEndPoint]]; - NSMutableURLRequest *urlRequest = [[NSMutableURLRequest alloc] initWithURL:[[NSURL alloc] initWithString:endPointUrl]]; + NSMutableURLRequest *urlRequest = [[NSMutableURLRequest alloc] initWithURL:[[NSURL alloc] initWithString:dataPlaneEndPoint]]; [urlRequest setHTTPMethod:@"POST"]; [urlRequest addValue:@"Application/json" forHTTPHeaderField:@"Content-Type"]; [urlRequest addValue:[[NSString alloc] initWithFormat:@"Basic %@", self->authToken] forHTTPHeaderField:@"Authorization"]; diff --git a/Rudder/Classes/RudderConfig.h b/Rudder/Classes/RudderConfig.h index f0355940..ea38a4c6 100644 --- a/Rudder/Classes/RudderConfig.h +++ b/Rudder/Classes/RudderConfig.h @@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN @interface RudderConfig : NSObject -@property (nonatomic, nonnull) NSString *endPointUrl; +@property (nonatomic, nonnull) NSString *dataPlaneUrl; @property (nonatomic) int flushQueueSize; @property (nonatomic) int dbCountThreshold; @property (nonatomic) int sleepTimeout; @@ -21,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic) int configRefreshInterval; @property (nonatomic) bool trackLifecycleEvents; @property (nonatomic) bool recordScreenViews; -@property (nonatomic, nonnull) NSString *configPlaneUrl; +@property (nonatomic, nonnull) NSString *controlPlaneUrl; @property (nonatomic, readwrite) NSMutableArray* factories; @end diff --git a/Rudder/Classes/RudderConfig.m b/Rudder/Classes/RudderConfig.m index 30aa2398..69fd16f5 100644 --- a/Rudder/Classes/RudderConfig.m +++ b/Rudder/Classes/RudderConfig.m @@ -15,7 +15,7 @@ - (instancetype)init { self = [super init]; if (self) { - _endPointUrl = RudderBaseUrl; + _dataPlaneUrl = RudderDataPlaneUrl; _flushQueueSize = RudderFlushQueueSize; _dbCountThreshold = RudderDBCountThreshold; _sleepTimeout = RudderSleepTimeout; @@ -23,13 +23,13 @@ - (instancetype)init _configRefreshInterval = RudderConfigRefreshInterval; _trackLifecycleEvents = RudderTrackLifeCycleEvents; _recordScreenViews = RudderRecordScreenViews; - _configPlaneUrl = RudderConfigPlaneUrl; + _controlPlaneUrl = RudderControlPlaneUrl; _factories = [[NSMutableArray alloc] init]; } return self; } -- (instancetype)init:(NSString *) endPointUrl +- (instancetype)init:(NSString *) dataPlaneUrl flushQueueSize: (int) flushQueueSize dbCountThreshold: (int) dbCountThreshold sleepTimeOut: (int) sleepTimeout @@ -37,11 +37,11 @@ - (instancetype)init:(NSString *) endPointUrl configRefreshInterval: (int) configRefreshInteval trackLifecycleEvents: (BOOL) trackLifecycleEvents recordScreenViews: (BOOL) recordScreenViews - configPlaneUrl: (NSString *) configPlaneUrl + controlPlaneUrl: (NSString *) controlPlaneUrl { self = [super init]; if (self) { - _endPointUrl = endPointUrl; + _dataPlaneUrl = dataPlaneUrl; _flushQueueSize = flushQueueSize; _dbCountThreshold = dbCountThreshold; _sleepTimeout = sleepTimeout; @@ -49,7 +49,7 @@ - (instancetype)init:(NSString *) endPointUrl _configRefreshInterval = configRefreshInteval; _trackLifecycleEvents = trackLifecycleEvents; _recordScreenViews = recordScreenViews; - _configPlaneUrl = configPlaneUrl; + _controlPlaneUrl = controlPlaneUrl; _factories = [[NSMutableArray alloc] init]; } return self; diff --git a/Rudder/Classes/RudderConfigBuilder.h b/Rudder/Classes/RudderConfigBuilder.h index 3bfa3ec4..f925ef3c 100644 --- a/Rudder/Classes/RudderConfigBuilder.h +++ b/Rudder/Classes/RudderConfigBuilder.h @@ -18,7 +18,8 @@ NS_ASSUME_NONNULL_BEGIN RudderConfig *config; } -- (instancetype) withEndPointUrl: (NSString*) endPointUrl; +- (instancetype) withEndPointUrl : (NSString*) endPointUrl __attribute((deprecated("Use withDataPlaneUrl instead."))); +- (instancetype) withDataPlaneUrl: (NSString*) dataPlaneUrl; - (instancetype) withFlushQueueSize: (int) flushQueueSize; - (instancetype) withDebug: (BOOL) debug; - (instancetype) withLoglevel: (int) logLevel; @@ -27,7 +28,8 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype) withConfigRefreshInteval: (int) configRefreshInterval; - (instancetype) withTrackLifecycleEvens: (BOOL) trackLifecycleEvents; - (instancetype) withRecordScreenViews: (BOOL) recordScreenViews; -- (instancetype) withConfigPlaneUrl: (NSString*) configPlaneUrl; +- (instancetype) withConfigPlaneUrl: (NSString*) configPlaneUrl __attribute((deprecated("Use withControlPlaneUrl instead."))); +- (instancetype) withControlPlaneUrl: (NSString*) controlPlaneUrl; - (instancetype) withFactory: (id _Nonnull) factory; - (RudderConfig*) build; diff --git a/Rudder/Classes/RudderConfigBuilder.m b/Rudder/Classes/RudderConfigBuilder.m index ee76b4a2..27ba2635 100644 --- a/Rudder/Classes/RudderConfigBuilder.m +++ b/Rudder/Classes/RudderConfigBuilder.m @@ -12,11 +12,19 @@ @implementation RudderConfigBuilder -- (instancetype) withEndPointUrl: (NSString*) endPointUrl { +- (instancetype) withEndPointUrl:(NSString *)endPointUrl{ if (config == nil) { config = [[RudderConfig alloc] init]; } - config.endPointUrl = endPointUrl; + config.dataPlaneUrl = endPointUrl; + return self; +} + +- (instancetype) withDataPlaneUrl: (NSString*) dataPlaneUrl { + if (config == nil) { + config = [[RudderConfig alloc] init]; + } + config.dataPlaneUrl = dataPlaneUrl; return self; } @@ -94,11 +102,19 @@ - (instancetype) withRecordScreenViews:(BOOL)recordScreenViews { return self; } -- (instancetype)withConfigPlaneUrl:(NSString *)configPlaneUrl { +-(instancetype)withConfigPlaneUrl:(NSString *)configPlaneUrl { + if (config == nil) { + config = [[RudderConfig alloc] init]; + } + config.controlPlaneUrl = configPlaneUrl; + return self; +} + +- (instancetype)withControlPlaneUrl:(NSString *)controlPlaneUrl { if (config == nil) { config = [[RudderConfig alloc] init]; } - config.configPlaneUrl = configPlaneUrl; + config.controlPlaneUrl = controlPlaneUrl; return self; } diff --git a/Rudder/Classes/RudderServerConfigManager.m b/Rudder/Classes/RudderServerConfigManager.m index eb9cb5b6..4ff5921e 100644 --- a/Rudder/Classes/RudderServerConfigManager.m +++ b/Rudder/Classes/RudderServerConfigManager.m @@ -154,9 +154,9 @@ - (NSString *)_networkRequest { dispatch_semaphore_t semaphore = dispatch_semaphore_create(0); __block NSString *responseStr = nil; - NSString *configUrl = [NSString stringWithFormat:@"%@/sourceConfig", _rudderConfig.configPlaneUrl]; - [RudderLogger logDebug:[[NSString alloc] initWithFormat:@"configUrl: %@", configUrl]]; - NSMutableURLRequest *urlRequest = [[NSMutableURLRequest alloc] initWithURL:[[NSURL alloc] initWithString:configUrl]]; + NSString *controlPlaneEndPoint = [NSString stringWithFormat:@"%@/sourceConfig", _rudderConfig.controlPlaneUrl]; + [RudderLogger logDebug:[[NSString alloc] initWithFormat:@"configUrl: %@", controlPlaneEndPoint]]; + NSMutableURLRequest *urlRequest = [[NSMutableURLRequest alloc] initWithURL:[[NSURL alloc] initWithString:controlPlaneEndPoint]]; NSData *authData = [[[NSString alloc] initWithFormat:@"%@:", _writeKey] dataUsingEncoding:NSUTF8StringEncoding]; [urlRequest addValue:[[NSString alloc] initWithFormat:@"Basic %@", [authData base64EncodedStringWithOptions:0]] forHTTPHeaderField:@"Authorization"];