From 7dd7d5dd82f512cec17cef1edef94400e15a35e4 Mon Sep 17 00:00:00 2001 From: Jaclyn Chen Date: Wed, 30 Aug 2023 11:34:04 +0800 Subject: [PATCH 1/7] Fix nil logging class using Cocoapods in WCiOS. --- Sources/Model/ObjC/Common/TracksLogging.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Model/ObjC/Common/TracksLogging.m b/Sources/Model/ObjC/Common/TracksLogging.m index ea357489..fa7e40ca 100644 --- a/Sources/Model/ObjC/Common/TracksLogging.m +++ b/Sources/Model/ObjC/Common/TracksLogging.m @@ -9,7 +9,7 @@ #if SWIFT_PACKAGE Class loggingClass = NSClassFromString(@"AutomatticTracksModel.TracksLogging"); #else - Class loggingClass = NSClassFromString(@"TracksLogging"); + Class loggingClass = NSClassFromString(@"AutomatticTracks.TracksLogging"); #endif if ([loggingClass conformsToProtocol: @protocol(TracksLoggingConfiguration)]) { result = loggingClass; From bce4ea9845abaedde23f0db7d02721b446f2a580 Mon Sep 17 00:00:00 2001 From: Jaclyn Chen Date: Wed, 30 Aug 2023 11:34:43 +0800 Subject: [PATCH 2/7] Also log event name in case of validation error in Tracks event creation. --- Sources/Event Logging/TracksEventService.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Event Logging/TracksEventService.m b/Sources/Event Logging/TracksEventService.m index 120afd2a..e075c915 100644 --- a/Sources/Event Logging/TracksEventService.m +++ b/Sources/Event Logging/TracksEventService.m @@ -58,7 +58,7 @@ - (TracksEvent *)createTracksEventWithName:(NSString *)name NSError *error; BOOL isValid = [tracksEvent validateObject:&error]; if (!isValid) { - TracksLogWarn(@"Error when validating TracksEvent: %@", error); + TracksLogWarn(@"Error when validating TracksEvent %@: %@", name, error); return nil; } From a9bfbbc02049d07cbe7f716bac2a156e7abb694f Mon Sep 17 00:00:00 2001 From: Jaclyn Chen Date: Wed, 30 Aug 2023 11:35:19 +0800 Subject: [PATCH 3/7] Return a boolean in `trackEventName:withCustomProperties:` to allow client side logging. --- Sources/Event Logging/TracksService.h | 7 ++++++- Sources/Event Logging/TracksService.m | 21 +++++++++++---------- 2 files changed, 17 insertions(+), 11 deletions(-) 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 From 710843dfcd9985d1d67a338419ca05b512ef36ca Mon Sep 17 00:00:00 2001 From: Jaclyn Chen Date: Wed, 30 Aug 2023 11:36:49 +0800 Subject: [PATCH 4/7] Bump pod version. --- Automattic-Tracks-iOS.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Automattic-Tracks-iOS.podspec b/Automattic-Tracks-iOS.podspec index e691dcd4..4a8b7945 100644 --- a/Automattic-Tracks-iOS.podspec +++ b/Automattic-Tracks-iOS.podspec @@ -2,7 +2,7 @@ Pod::Spec.new do |s| s.name = 'Automattic-Tracks-iOS' - s.version = '2.3.0' + s.version = '2.4.0' s.summary = 'Simple way to track events in an iOS app with Automattic Tracks internal service' s.description = <<-DESC From d4f2087724300cf734590129dbb759048164f7ac Mon Sep 17 00:00:00 2001 From: Jaclyn Chen Date: Wed, 30 Aug 2023 14:37:37 +0800 Subject: [PATCH 5/7] Update changelog. --- CHANGELOG.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b750c7db..88ae59f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,24 @@ _None._ --> +## 2.4.0 + +### Breaking Changes + +_None._ + +### New Features + +- `TracksService.trackEventName:withCustomProperties:` now returns a boolean that indicates whether the event creation is successful. + +### Bug Fixes + +- `TracksLogging` now works when the library is integrated with Cocoapods for internal Tracks error/warning messages. + +### Internal Changes + +_None._ + ## 2.3.0 ### Breaking Changes From 655a28d81cb50dd84ca3eda407752b5083a9fa05 Mon Sep 17 00:00:00 2001 From: Jaclyn Chen Date: Wed, 30 Aug 2023 14:39:12 +0800 Subject: [PATCH 6/7] Update `TracksLibraryVersion` from CI validation error. --- Sources/Model/ObjC/Constants/TracksConstants.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Model/ObjC/Constants/TracksConstants.m b/Sources/Model/ObjC/Constants/TracksConstants.m index 953a8f31..17e5de9c 100644 --- a/Sources/Model/ObjC/Constants/TracksConstants.m +++ b/Sources/Model/ObjC/Constants/TracksConstants.m @@ -1,4 +1,4 @@ #import "TracksConstants.h" NSString *const TracksErrorDomain = @"TracksErrorDomain"; -NSString *const TracksLibraryVersion = @"2.3.0"; +NSString *const TracksLibraryVersion = @"2.4.0"; From 5a1d29d4714e7c8012b2d845d56dc2bf5a55434c Mon Sep 17 00:00:00 2001 From: Jaclyn Chen Date: Wed, 30 Aug 2023 14:41:09 +0800 Subject: [PATCH 7/7] Update changelog for the internal change in log message. --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88ae59f6..21ae910b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,8 @@ _None._ ### Internal Changes +- `TracksService.trackEventName:withCustomProperties:` now logs the event name when there is a validation error from creating a Tracks event. + _None._ ## 2.3.0