-
-
Notifications
You must be signed in to change notification settings - Fork 313
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
chore: Matomo refactor #3273
chore: Matomo refactor #3273
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #3273 +/- ##
===========================================
+ Coverage 10.53% 10.54% +0.01%
===========================================
Files 249 249
Lines 12248 12240 -8
===========================================
+ Hits 1290 1291 +1
+ Misses 10958 10949 -9
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @M123-dev!
Honestly I would have written things differently, in 2 major points.
I agree with the choice of reducing the number of methods. And I would even use only one method (instead of 2 for you):
static void trackEvent(
String name,
String category,
String action, {
String? barcode,
})
The other thing that troubles me is enum AnalyticsMessage<T extends String>
, which is "just in case power 2". Just in case we use classes that extend String
(spoiler alert: we won't). Just in case we use the same AnalyticsMessage
twice (which does not happen very often, does it?). In addition to that sometimes you use an AnalyticsMessage
for the name
parameter, sometimes for the category
(with a lousy .toString()
). Confusion!
I don't know actually how those values are used in Matomo itself - I guess you prefer fixed values. If you really insist in using enum
s, you should create AnalyticsName
, AnalyticsCategory
and AnalyticsAction
.
But given the low number of different values, I guess we would be better off with String
s like before.
Unless I'm missing an important point here. Am I?
I would also say that the name implies a category. Something like that:
enum AnalyticsCategory{
userManagement(tag: 'user management'),
scanning(tag: 'scanning'),
share(tag: 'share'),
couldNotFindProduct(tag: 'could not find product');
const AnalyticsCategory({required this.tag});
final String tag;
}
enum AnalyticsMessage{
scanAction(tag: 'scanned product', category: AnalyticsCategory.scanning),
shareProduct(tag: 'shared product', category: AnalyticsCategory.share),
loginAction(tag: 'logged in', category: AnalyticsCategory.userManagement),
registerAction(tag: 'register', category: AnalyticsCategory.userManagement),
logoutAction(tag: 'logged out', category: AnalyticsCategory.userManagement),
couldNotScanProduct(tag: 'could not scan product', category: AnalyticsCategory.couldNotFindProduct);
couldNotFindProduct(tag: 'could not find product', category: AnalyticsCategory.couldNotFindProduct);
const AnalyticsMessage({required this.tag, required this.category});
final String tag;
final AnalyticsCategory category;
}
And you could build from there.
Sorry for being so verbose...
Co-Authored-By: monsieurtanuki <11576431+monsieurtanuki@users.noreply.github.com>
Thanks for beeing so verbose 😄
Yeah I head some problem with the enum, I though we have to provide a type to the enum it self, but when I just used as type the constructor wouldn't work anymore. Thanks for this detailed review, is indeed way better like this 👍🏼 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @M123-dev: looks much better that way!
Feel free to ignore my comments and merge.
Thanks for your review @monsieurtanuki |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@M123-dev Perfect!
What
For: #2855
We now have a general
AnalyticsHelper.trackEvent
method and not a own method per tracked action