Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standard naming for endPointUrl and configPlaneUrl #16

Merged
merged 5 commits into from
Apr 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions Example/Rudder/_AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
#import "_AppDelegate.h"
#import <Rudder/Rudder.h>

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
Expand All @@ -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];
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Put this code in your ```AppDelegate.m``` file under the method ```didFinishLaun

```xcode
RudderConfigBuilder *builder = [[RudderConfigBuilder alloc] init];
[builder withEndPointUrl:<YOUR_DATA_PLANE_URL>];
[builder withDataPlaneUrl:<YOUR_DATA_PLANE_URL>];
[RudderClient getInstance:<YOUR_WRITE_KEY> config:[builder build]];
```
A shared instance of ```RudderClient``` is accesible after the initialization by ```[RudderClient sharedInstance]```
Expand Down Expand Up @@ -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.
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.
4 changes: 2 additions & 2 deletions Rudder/Classes/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Rudder/Classes/Constants.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions Rudder/Classes/EventRepository.m
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand Down
4 changes: 2 additions & 2 deletions Rudder/Classes/RudderConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ 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;
@property (nonatomic) int logLevel;
@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
Expand Down
12 changes: 6 additions & 6 deletions Rudder/Classes/RudderConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,41 @@ - (instancetype)init
{
self = [super init];
if (self) {
_endPointUrl = RudderBaseUrl;
_dataPlaneUrl = RudderDataPlaneUrl;
_flushQueueSize = RudderFlushQueueSize;
_dbCountThreshold = RudderDBCountThreshold;
_sleepTimeout = RudderSleepTimeout;
_logLevel = RudderLogLevelError;
_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
logLevel: (int) logLevel
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;
_logLevel = logLevel;
_configRefreshInterval = configRefreshInteval;
_trackLifecycleEvents = trackLifecycleEvents;
_recordScreenViews = recordScreenViews;
_configPlaneUrl = configPlaneUrl;
_controlPlaneUrl = controlPlaneUrl;
_factories = [[NSMutableArray alloc] init];
}
return self;
Expand Down
6 changes: 4 additions & 2 deletions Rudder/Classes/RudderConfigBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 <RudderIntegrationFactory> _Nonnull) factory;
- (RudderConfig*) build;

Expand Down
24 changes: 20 additions & 4 deletions Rudder/Classes/RudderConfigBuilder.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions Rudder/Classes/RudderServerConfigManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -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"];

Expand Down