Skip to content

Commit

Permalink
Fix consent message formatting (#215)
Browse files Browse the repository at this point in the history
* Update constants.dart

* Update versions

* Fix tests

* Use mustache style for consent msg template
  • Loading branch information
eliasyishak authored Dec 6, 2023
1 parent c4d515a commit ed81684
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 35 deletions.
4 changes: 4 additions & 0 deletions pkgs/unified_analytics/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 5.7.1-wip

- Fix template string for consent message

## 5.7.0

- Added the `Event.commandUsageValues` constructor
Expand Down
9 changes: 6 additions & 3 deletions pkgs/unified_analytics/lib/src/analytics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -438,11 +438,14 @@ class AnalyticsImpl implements Analytics {
@override
String get getConsentMessage {
// The command to swap in the consent message
final commandString = tool == DashTool.flutterTool ? 'flutter' : 'dart';
final commandString =
tool == DashTool.flutterTool || tool == DashTool.devtools
? 'flutter'
: 'dart';

return kToolsMessage
.replaceAll('[tool name]', tool.description)
.replaceAll('[dart|flutter]', commandString);
.replaceAll('{{ toolDescription }}', tool.description)
.replaceAll('{{ toolName }}', commandString);
}

/// Checking the [telemetryEnabled] boolean reflects what the
Expand Down
27 changes: 14 additions & 13 deletions pkgs/unified_analytics/lib/src/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const int kLogFileLength = 2500;
const String kLogFileName = 'dart-flutter-telemetry.log';

/// The current version of the package, should be in line with pubspec version.
const String kPackageVersion = '5.7.0';
const String kPackageVersion = '5.7.1-wip';

/// The minimum length for a session.
const int kSessionDurationMinutes = 30;
Expand All @@ -92,18 +92,19 @@ const String kSessionFileName = 'dart-flutter-telemetry-session.json';

/// The message that should be shown to the user.
const String kToolsMessage = '''
The [tool name] uses Google Analytics to report usage and diagnostic data
along with package dependencies, and crash reporting to send basic crash reports.
This data is used to help improve the Dart platform, Flutter framework, and related tools.
Telemetry is not sent on the very first run.
To disable reporting of telemetry, run this terminal command:
[dart|flutter] --disable-analytics.
If you opt out of telemetry, an opt-out event will be sent,
and then no further information will be sent.
This data is collected in accordance with the
Google Privacy Policy (https://policies.google.com/privacy).
The {{ toolDescription }} uses Google Analytics to report usage and diagnostic
data along with package dependencies, and crash reporting to send basic crash
reports. This data is used to help improve the Dart platform, Flutter framework,
and related tools.
Telemetry is not sent on the very first run. To disable reporting of telemetry,
run this terminal command:
{{ toolName }} --disable-analytics
If you opt out of telemetry, an opt-out event will be sent, and then no further
information will be sent. This data is collected in accordance with the Google
Privacy Policy (https://policies.google.com/privacy).
''';

/// The version number for the message below.
Expand Down
2 changes: 1 addition & 1 deletion pkgs/unified_analytics/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: >-
to Google Analytics.
# When updating this, keep the version consistent with the changelog and the
# value in lib/src/constants.dart.
version: 5.7.0
version: 5.7.1-wip
repository: https://github.com/dart-lang/tools/tree/main/pkgs/unified_analytics

environment:
Expand Down
41 changes: 23 additions & 18 deletions pkgs/unified_analytics/test/unified_analytics_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1132,17 +1132,19 @@ ${initialTool.label}=$dateStamp,$toolsMessageVersion
final consentMessage = analytics.getConsentMessage;

expect(consentMessage, equalsIgnoringWhitespace(r'''
The Flutter CLI developer tool uses Google Analytics to report usage and
diagnostic data along with package dependencies, and crash reporting to
send basic crash reports. This data is used to help improve the Dart platform,
Flutter framework, and related tools. Telemetry is not sent on the very first
run. To disable reporting of telemetry, run this terminal command:
The Flutter CLI developer tool uses Google Analytics to report usage and diagnostic
data along with package dependencies, and crash reporting to send basic crash
reports. This data is used to help improve the Dart platform, Flutter framework,
and related tools.
flutter --disable-analytics.
Telemetry is not sent on the very first run. To disable reporting of telemetry,
run this terminal command:
If you opt out of telemetry, an opt-out event will be sent, and then no
further information will be sent. This data is collected in accordance with
the Google Privacy Policy (https://policies.google.com/privacy).
flutter --disable-analytics
If you opt out of telemetry, an opt-out event will be sent, and then no further
information will be sent. This data is collected in accordance with the Google
Privacy Policy (https://policies.google.com/privacy).
'''));
});

Expand All @@ -1165,18 +1167,21 @@ the Google Privacy Policy (https://policies.google.com/privacy).

// Retrieve the consent message for flutter tools
final consentMessage = secondAnalytics.getConsentMessage;

expect(consentMessage, equalsIgnoringWhitespace(r'''
The Dart CLI developer tool uses Google Analytics to report usage and
diagnostic data along with package dependencies, and crash reporting to
send basic crash reports. This data is used to help improve the Dart platform,
Flutter framework, and related tools. Telemetry is not sent on the very first
run. To disable reporting of telemetry, run this terminal command:
The Dart CLI developer tool uses Google Analytics to report usage and diagnostic
data along with package dependencies, and crash reporting to send basic crash
reports. This data is used to help improve the Dart platform, Flutter framework,
and related tools.
Telemetry is not sent on the very first run. To disable reporting of telemetry,
run this terminal command:
dart --disable-analytics.
dart --disable-analytics
If you opt out of telemetry, an opt-out event will be sent, and then no
further information will be sent. This data is collected in accordance with
the Google Privacy Policy (https://policies.google.com/privacy).
If you opt out of telemetry, an opt-out event will be sent, and then no further
information will be sent. This data is collected in accordance with the Google
Privacy Policy (https://policies.google.com/privacy).
'''));
});

Expand Down

0 comments on commit ed81684

Please sign in to comment.