From ed81684df747830de8b29e9d6e6d8f951ea6968d Mon Sep 17 00:00:00 2001 From: Elias Yishak <42216813+eliasyishak@users.noreply.github.com> Date: Wed, 6 Dec 2023 10:34:51 -0500 Subject: [PATCH] Fix consent message formatting (#215) * Update constants.dart * Update versions * Fix tests * Use mustache style for consent msg template --- pkgs/unified_analytics/CHANGELOG.md | 4 ++ pkgs/unified_analytics/lib/src/analytics.dart | 9 ++-- pkgs/unified_analytics/lib/src/constants.dart | 27 ++++++------ pkgs/unified_analytics/pubspec.yaml | 2 +- .../test/unified_analytics_test.dart | 41 +++++++++++-------- 5 files changed, 48 insertions(+), 35 deletions(-) diff --git a/pkgs/unified_analytics/CHANGELOG.md b/pkgs/unified_analytics/CHANGELOG.md index 0d1205f9f..41af61829 100644 --- a/pkgs/unified_analytics/CHANGELOG.md +++ b/pkgs/unified_analytics/CHANGELOG.md @@ -1,3 +1,7 @@ +## 5.7.1-wip + +- Fix template string for consent message + ## 5.7.0 - Added the `Event.commandUsageValues` constructor diff --git a/pkgs/unified_analytics/lib/src/analytics.dart b/pkgs/unified_analytics/lib/src/analytics.dart index b5fb0e592..23e6a87a6 100644 --- a/pkgs/unified_analytics/lib/src/analytics.dart +++ b/pkgs/unified_analytics/lib/src/analytics.dart @@ -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 diff --git a/pkgs/unified_analytics/lib/src/constants.dart b/pkgs/unified_analytics/lib/src/constants.dart index a0d44dc9f..559c3249b 100644 --- a/pkgs/unified_analytics/lib/src/constants.dart +++ b/pkgs/unified_analytics/lib/src/constants.dart @@ -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; @@ -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. diff --git a/pkgs/unified_analytics/pubspec.yaml b/pkgs/unified_analytics/pubspec.yaml index aacb2e2b3..7ce8b253e 100644 --- a/pkgs/unified_analytics/pubspec.yaml +++ b/pkgs/unified_analytics/pubspec.yaml @@ -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: diff --git a/pkgs/unified_analytics/test/unified_analytics_test.dart b/pkgs/unified_analytics/test/unified_analytics_test.dart index 22c395b0a..e672f5df2 100644 --- a/pkgs/unified_analytics/test/unified_analytics_test.dart +++ b/pkgs/unified_analytics/test/unified_analytics_test.dart @@ -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). ''')); }); @@ -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). ''')); });