Skip to content

Commit

Permalink
Return a boolean in trackEventName:withCustomProperties: to allow c…
Browse files Browse the repository at this point in the history
…lient side logging.
  • Loading branch information
jaclync committed Aug 30, 2023
1 parent bce4ea9 commit a9bfbbc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
7 changes: 6 additions & 1 deletion Sources/Event Logging/TracksService.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
21 changes: 11 additions & 10 deletions Sources/Event Logging/TracksService.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a9bfbbc

Please sign in to comment.