Skip to content

Commit

Permalink
Friendly assert messages
Browse files Browse the repository at this point in the history
No change in when errors thrown, simply the messages have changed to be
more descriptive.

Few notes:
* Group and alias are missing validations
* Left configuration != nil assert as is since the default message is good enough.
  • Loading branch information
f2prateek committed Jun 30, 2016
1 parent 1ddcf61 commit 0125804
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions Pod/Classes/SEGAnalytics.m
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ - (void)identify:(NSString *)userId traits:(NSDictionary *)traits

- (void)identify:(NSString *)userId traits:(NSDictionary *)traits options:(NSDictionary *)options
{
NSCParameterAssert(userId.length > 0 || traits.count > 0);
NSCAssert2(userId.length > 0 > traits.count > 0, @"either userId (%@) or traits (%@) must be provided.", userId, traits);

SEGIdentifyPayload *payload = [[SEGIdentifyPayload alloc] initWithUserId:userId
anonymousId:[options objectForKey:@"anonymousId"]
Expand Down Expand Up @@ -268,7 +268,7 @@ - (void)track:(NSString *)event properties:(NSDictionary *)properties

- (void)track:(NSString *)event properties:(NSDictionary *)properties options:(NSDictionary *)options
{
NSCParameterAssert(event.length > 0);
NSCAssert1(event.length > 0, @"event (%@) must not be empty.", event);

SEGTrackPayload *payload = [[SEGTrackPayload alloc] initWithEvent:event
properties:SEGCoerceDictionary(properties)
Expand All @@ -283,21 +283,21 @@ - (void)track:(NSString *)event properties:(NSDictionary *)properties options:(N

#pragma mark - Screen

- (void)screen:(NSString *)screenTitle
- (void)screen:(NSString *)name
{
[self screen:screenTitle properties:nil options:nil];
[self screen:name properties:nil options:nil];
}

- (void)screen:(NSString *)screenTitle properties:(NSDictionary *)properties
- (void)screen:(NSString *)name properties:(NSDictionary *)properties
{
[self screen:screenTitle properties:properties options:nil];
[self screen:name properties:properties options:nil];
}

- (void)screen:(NSString *)screenTitle properties:(NSDictionary *)properties options:(NSDictionary *)options
- (void)screen:(NSString *)name properties:(NSDictionary *)properties options:(NSDictionary *)options
{
NSCParameterAssert(screenTitle.length > 0);
NSCAssert1(name.length > 0, @"screen name (%@) must not be empty.", name);

SEGScreenPayload *payload = [[SEGScreenPayload alloc] initWithName:screenTitle
SEGScreenPayload *payload = [[SEGScreenPayload alloc] initWithName:name
properties:SEGCoerceDictionary(properties)
context:SEGCoerceDictionary([options objectForKey:@"context"])
integrations:[options objectForKey:@"integrations"]];
Expand Down Expand Up @@ -471,7 +471,7 @@ - (void)refreshSettings

+ (instancetype)sharedAnalytics
{
NSCParameterAssert(__sharedInstance != nil);
NSCAssert(__sharedInstance != nil, @"library must be initialized before calling this method.");
return __sharedInstance;
}

Expand Down

0 comments on commit 0125804

Please sign in to comment.