From 0125804698f5e7087ca49f79f4ad99cc78aa2437 Mon Sep 17 00:00:00 2001 From: Prateek Srivastava Date: Thu, 9 Jun 2016 12:17:14 -0600 Subject: [PATCH] Friendly assert messages 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. --- Pod/Classes/SEGAnalytics.m | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Pod/Classes/SEGAnalytics.m b/Pod/Classes/SEGAnalytics.m index cb3858fbb..1c73010dd 100644 --- a/Pod/Classes/SEGAnalytics.m +++ b/Pod/Classes/SEGAnalytics.m @@ -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"] @@ -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) @@ -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"]]; @@ -471,7 +471,7 @@ - (void)refreshSettings + (instancetype)sharedAnalytics { - NSCParameterAssert(__sharedInstance != nil); + NSCAssert(__sharedInstance != nil, @"library must be initialized before calling this method."); return __sharedInstance; }