diff --git a/Sources/Event Logging/TracksService.h b/Sources/Event Logging/TracksService.h index cc3c4bd7..9d572434 100644 --- a/Sources/Event Logging/TracksService.h +++ b/Sources/Event Logging/TracksService.h @@ -35,7 +35,12 @@ extern NSString *const TrackServiceDidSendQueuedEventsNotification; - (void)switchToAnonymousUserWithAnonymousID:(NSString *)anonymousID; - (void)trackEventName:(NSString *)eventName; -- (void)trackEventName:(NSString *)eventName withCustomProperties:(NSDictionary *)customProperties; + +/// Tracks an event with custom properties and returns a boolean that indicates whether the creation is successful. +/// - Parameters: +/// - eventName: Name of the event. +/// - customProperties: Custom event properties whose property name should only have alpha characters and underscores. +- (BOOL)trackEventName:(NSString *)eventName withCustomProperties:(NSDictionary *)customProperties; - (void)sendQueuedEvents; - (void)clearQueuedEvents; diff --git a/Sources/Event Logging/TracksService.m b/Sources/Event Logging/TracksService.m index 46cb668f..b94dd586 100644 --- a/Sources/Event Logging/TracksService.m +++ b/Sources/Event Logging/TracksService.m @@ -134,19 +134,20 @@ - (void)trackEventName:(NSString *)eventName } -- (void)trackEventName:(NSString *)eventName withCustomProperties:(NSDictionary *)customProperties +- (BOOL)trackEventName:(NSString *)eventName withCustomProperties:(NSDictionary *)customProperties { eventName = [NSString stringWithFormat:@"%@_%@", self.eventNamePrefix, eventName]; - [self.tracksEventService createTracksEventWithName:eventName - username:self.username - userID:self.userID - userAgent:self.userAgent - userType:self.isAnonymous ? TracksEventUserTypeAnonymous : TracksEventUserTypeAuthenticated - eventDate:[NSDate date] - customProperties:customProperties - deviceProperties:[self mutableDeviceProperties] - userProperties:self.userProperties]; + TracksEvent * _Nullable event = [self.tracksEventService createTracksEventWithName:eventName + username:self.username + userID:self.userID + userAgent:self.userAgent + userType:self.isAnonymous ? TracksEventUserTypeAnonymous : TracksEventUserTypeAuthenticated + eventDate:[NSDate date] + customProperties:customProperties + deviceProperties:[self mutableDeviceProperties] + userProperties:self.userProperties]; + return event != nil; } - (NSUInteger)queuedEventCount