Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TracksLogWarn messages aren't logged with Cocoapods integration #263

Merged
merged 7 commits into from
Sep 1, 2023

Conversation

jaclync
Copy link
Contributor

@jaclync jaclync commented Aug 30, 2023

Fixes #262

Why

Recently, we noticed a Tracks event wasn't actually tracked due to a validation error that wasn't logged anywhere in the console p1693362956666449/1692625489.705669-slack-C039133E1M3 / woocommerce/woocommerce-ios#10574.

BOOL isValid = [tracksEvent validateObject:&error];
if (!isValid) {
TracksLogWarn(@"Error when validating TracksEvent: %@", error);

Upon inspection, TracksLoggingClass() is nil when the library is integrated with the client app via Cocoapods:

static Class<TracksLoggingConfiguration> result = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
#if SWIFT_PACKAGE
Class loggingClass = NSClassFromString(@"AutomatticTracksModel.TracksLogging");
#else
Class loggingClass = NSClassFromString(@"TracksLogging");
#endif
if ([loggingClass conformsToProtocol: @protocol(TracksLoggingConfiguration)]) {
result = loggingClass;
}
});
return result;

I'm guessing the Cocoapods path wasn't tested, and thus Tracks logging has been disabled for a while.

How

To fix the nil TracksLoggingClass(), the logging class was updated to include the module name so that the class can be loaded correctly 7dd7d5d.

For easier debugging, the event name is now included in the warning message when there is a validation error creating a Tracks event bce4ea9.

To enable the client app to log a different message on Tracks event creation error, a success boolean is returned when creating an event with custom properties a9bfbbc. The return value is default to be discardable in Objective-C.

Testing steps

Please follow the testing steps in woocommerce/woocommerce-ios#10577.


  • I have considered if this change warrants release notes and have added them to the appropriate section in the CHANGELOG.md if necessary.

@jaclync jaclync changed the title Fix TracksLogWarn messages aren't shown in console in the client app Fix TracksLogWarn messages aren't logged with Cocoapods integration Aug 30, 2023
Copy link
Member

@ThomazFB ThomazFB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested alongside woocommerce/woocommerce-ios#10577

@jaclync jaclync merged commit 6ff2e44 into trunk Sep 1, 2023
@jaclync jaclync deleted the issue/262-fix-TracksLogging branch September 1, 2023 05:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TracksLogWarn messages aren't shown in console in the client app
2 participants