-
Notifications
You must be signed in to change notification settings - Fork 33
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 logic for first run to fix shouldShowMessage
behavior
#228
Changes from all commits
a650cc6
42a7b70
a01e241
350c59f
d0245fb
ec8654f
60296fd
ab9ff60
d518ebe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,99 @@ void main() { | |
.childFile(kDismissedSurveyFileName); | ||
}); | ||
|
||
test('Confirm workflow for first run', () { | ||
final firstAnalytics = Analytics.test( | ||
tool: initialTool, | ||
homeDirectory: home, | ||
measurementId: measurementId, | ||
apiSecret: apiSecret, | ||
flutterChannel: flutterChannel, | ||
toolsMessageVersion: toolsMessageVersion, | ||
toolsMessage: toolsMessage, | ||
flutterVersion: flutterVersion, | ||
dartVersion: dartVersion, | ||
fs: fs, | ||
platform: platform, | ||
); | ||
|
||
expect(firstAnalytics.shouldShowMessage, true); | ||
expect(firstAnalytics.okToSend, false); | ||
|
||
firstAnalytics.clientShowedMessage(); | ||
expect(firstAnalytics.shouldShowMessage, false); | ||
expect(firstAnalytics.okToSend, false, | ||
reason: 'On the first run, we should not be ok ' | ||
'to send any events, even if the user accepts'); | ||
Comment on lines
+83
to
+84
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm... does this mean if the user accepts analytics collection, and then does a bunch of interactions with our tools that we will not send any events for this session? It seems like we should start sending events as soon as the user accepts, even if it is the first run. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was actually a requirement from the PDD, even for users that have opted in, analytic events will only be collected on the second time it is run. It's also listed in the consent message that was approved
|
||
}); | ||
|
||
test('Confirm workflow for updated tools message version + new tool', () { | ||
// Helper function to check the state of the instance | ||
void checkAnalyticsInstance(Analytics instance) { | ||
expect(instance.shouldShowMessage, true); | ||
expect(instance.okToSend, false); | ||
|
||
instance.clientShowedMessage(); | ||
expect(instance.shouldShowMessage, false); | ||
expect(instance.okToSend, false, | ||
reason: 'On the first run, we should not be ok ' | ||
'to send any events, even if the user accepts'); | ||
} | ||
|
||
final firstAnalytics = Analytics.test( | ||
tool: initialTool, | ||
homeDirectory: home, | ||
measurementId: measurementId, | ||
apiSecret: apiSecret, | ||
flutterChannel: flutterChannel, | ||
toolsMessageVersion: toolsMessageVersion, | ||
toolsMessage: toolsMessage, | ||
flutterVersion: flutterVersion, | ||
dartVersion: dartVersion, | ||
fs: fs, | ||
platform: platform, | ||
); | ||
|
||
checkAnalyticsInstance(firstAnalytics); | ||
|
||
// Instance where we increment the version of the message | ||
final secondAnalytics = Analytics.test( | ||
tool: initialTool, | ||
homeDirectory: home, | ||
measurementId: measurementId, | ||
apiSecret: apiSecret, | ||
flutterChannel: flutterChannel, | ||
toolsMessageVersion: toolsMessageVersion + 1, // Incrementing version | ||
toolsMessage: toolsMessage, | ||
flutterVersion: flutterVersion, | ||
dartVersion: dartVersion, | ||
fs: fs, | ||
platform: platform, | ||
); | ||
|
||
// Running the same checks for the second instance, it should | ||
// behave the same as if it was a first run | ||
checkAnalyticsInstance(secondAnalytics); | ||
|
||
// Instance for a different tool with the incremented version | ||
final thirdAnalytics = Analytics.test( | ||
tool: secondTool, // Different tool | ||
homeDirectory: home, | ||
measurementId: measurementId, | ||
apiSecret: apiSecret, | ||
flutterChannel: flutterChannel, | ||
toolsMessageVersion: toolsMessageVersion + 1, // Incrementing version | ||
toolsMessage: toolsMessage, | ||
flutterVersion: flutterVersion, | ||
dartVersion: dartVersion, | ||
fs: fs, | ||
platform: platform, | ||
); | ||
|
||
// The instance with a new tool getting onboarded should be | ||
// treated the same as the 2 previous instances | ||
checkAnalyticsInstance(thirdAnalytics); | ||
}); | ||
|
||
test('Confirm workflow for checking tools into the config file', () { | ||
final firstAnalytics = Analytics.test( | ||
tool: initialTool, | ||
|
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.
These tests are the best example for this change