-
-
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
fix: 3679 - reporting with a 000000000000 matomo user id #3840
fix: 3679 - reporting with a 000000000000 matomo user id #3840
Conversation
tracked with a user id of 0000000000000000
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 @sgtSeme4ki!
Please have a look at my quick review.
@@ -90,6 +89,8 @@ class AnalyticsHelper { | |||
|
|||
static String latestSearch = ''; | |||
|
|||
static bool allow = false; |
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.
static bool allow = false; | |
static bool _allow = false; |
version: '1.0.0', | ||
buildNumber: '2.2.2', |
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.
Please add a comment if those are dummy values.
await AnalyticsHelper.initMatomo(isScreenshotMode); | ||
// assert | ||
final String? matomoUserId = matomoTrackerInstance.visitor.userId; | ||
expect(matomoUserId, '0000000000000000'); |
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.
expect(matomoUserId, '0000000000000000'); | |
expect(matomoUserId, '0' * 16); |
@monsieurtanuki Thank you for the review, I tried to resolve anything as far as possible |
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 @sgtSeme4ki, and thank you for your additional commits.
Please have a look at my comments; basically your code is good but I still have pending questions.
// if user opts out then track anonymously with userId containg zeros | ||
if (!_allow) { | ||
return '0' * 16; | ||
} else if (kDebugMode) { | ||
return 'smoothie_debug--'; | ||
} else { | ||
return OpenFoodAPIConfiguration.uuid; | ||
} |
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.
// if user opts out then track anonymously with userId containg zeros | |
if (!_allow) { | |
return '0' * 16; | |
} else if (kDebugMode) { | |
return 'smoothie_debug--'; | |
} else { | |
return OpenFoodAPIConfiguration.uuid; | |
} | |
if (kDebugMode) { | |
return 'smoothie_debug--'; | |
} | |
// if user opts out then track anonymously with userId containg zeros | |
if (!_allow) { | |
return '0' * 16; | |
} | |
return OpenFoodAPIConfiguration.uuid; |
I believe we want to track "real users", not developers debugging.
That's why I would put the kDebugMode
check first.
In addition to that I don't like else
s so as we return
we can get rid of them, but it's just a matter of personal taste.
The most important here is to check kDebugMode
first.
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.
If kDebugMode is checked first, the test always fails, because tests are always run in debug mode (always returns "smoothie_debug--". Do you have an idea how to overcome this? My first thought was setting an env-variable like TEST_MODE in the test and checking for it in the "get uuid"-method, but this seems dirty to me. But honestly I can't come up with something better.
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.
I understand your point, but you seem to be more interested in the test than in the code.
The code should match our needs, and that's why I would put the kDebugMode
check first.
If there's no way to test it properly, let's not test it. Especially in that case, it's just a if
we're checking. Of course a test would be better; it's not essential.
If really you insist, perhaps you could use @visibleForTesting
. But I wouldn't put too much effort into it, and I would discard the test altogether.
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.
Thank you for your input. Am always interested in tests, because I come from a strict TDD-Household and the guys at the company I work in regard the tests as holy ;). But the most pragmatic way is to drop the test and it probably isn't worth it for like just 5 lines of code. I removed the test and the mockPackageInfo().
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.
Let's be pragmatic 😉
Co-authored-by: monsieurtanuki <fabrice_fontaine@hotmail.com>
Co-authored-by: monsieurtanuki <fabrice_fontaine@hotmail.com>
Co-authored-by: monsieurtanuki <fabrice_fontaine@hotmail.com>
Co-authored-by: monsieurtanuki <fabrice_fontaine@hotmail.com>
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.
Thank you @sgtSeme4ki and congratulations for your first contribution here!
What
Fixes bug(s)
Part of