From acdc11d298253a8ffc6c64bec25a31eb9a09691b Mon Sep 17 00:00:00 2001 From: eliasyishak <42216813+eliasyishak@users.noreply.github.com> Date: Fri, 15 Sep 2023 11:33:34 -0400 Subject: [PATCH 1/4] Added getters for client id --- pkgs/unified_analytics/CHANGELOG.md | 1 + pkgs/unified_analytics/lib/src/analytics.dart | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/pkgs/unified_analytics/CHANGELOG.md b/pkgs/unified_analytics/CHANGELOG.md index 54f8183e1..fb7e4213e 100644 --- a/pkgs/unified_analytics/CHANGELOG.md +++ b/pkgs/unified_analytics/CHANGELOG.md @@ -5,6 +5,7 @@ - Added `SurveyHandler` feature to `Analytics` instance to fetch available surveys from remote endpoint to display to users along with functionality to dismiss them - Surveys will be disabled for any users that have been opted out - Shipping `FakeAnalytics` for clients of this tool that need to ensure workflows are sending events in tests +- Adding getter to `Analytics` instance to fetch the client ID being sent to GA4 ## 3.0.0 diff --git a/pkgs/unified_analytics/lib/src/analytics.dart b/pkgs/unified_analytics/lib/src/analytics.dart index cb3842dc2..474fc2f48 100644 --- a/pkgs/unified_analytics/lib/src/analytics.dart +++ b/pkgs/unified_analytics/lib/src/analytics.dart @@ -187,6 +187,10 @@ abstract class Analytics { enableAsserts: true, ); + /// The shared identifier for Flutter and Dart related tooling using + /// package:unified_analytics. + String get clientId; + /// Retrieves the consent message to prompt users with on first /// run or when the message has been updated. String get getConsentMessage; @@ -401,6 +405,9 @@ class AnalyticsImpl implements Analytics { _logHandler = LogHandler(fs: fs, homeDirectory: homeDirectory); } + @override + String get clientId => _clientId; + @override String get getConsentMessage { // The command to swap in the consent message @@ -622,7 +629,7 @@ class AnalyticsImpl implements Analytics { status: surveyButton.action, )); } - + @override void surveyShown(Survey survey) { _surveyHandler.dismiss(survey, false); @@ -709,6 +716,9 @@ class NoOpAnalytics implements Analytics { const NoOpAnalytics._(); + @override + String get clientId => 'xxxx-xxxx'; + @override void clientShowedMessage() {} @@ -735,7 +745,7 @@ class NoOpAnalytics implements Analytics { required Survey survey, required SurveyButton surveyButton, }) {} - + @override void surveyShown(Survey survey) {} } From 48d82f69f89ee382dc9a36c05f78ae7ab1048de7 Mon Sep 17 00:00:00 2001 From: eliasyishak <42216813+eliasyishak@users.noreply.github.com> Date: Fri, 15 Sep 2023 11:36:41 -0400 Subject: [PATCH 2/4] Test added for NoOp instance --- pkgs/unified_analytics/test/no_op_analytics_test.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/unified_analytics/test/no_op_analytics_test.dart b/pkgs/unified_analytics/test/no_op_analytics_test.dart index 8f86b25c4..121704a54 100644 --- a/pkgs/unified_analytics/test/no_op_analytics_test.dart +++ b/pkgs/unified_analytics/test/no_op_analytics_test.dart @@ -62,6 +62,11 @@ void main() { expect(checkDirectoryForWritePermissions(home), true); }); + + test('Fetching the client id', () { + final analytics = NoOpAnalytics(); + expect(analytics.clientId, 'xxxx-xxxx'); + }); } class FakeDirectory extends Fake implements Directory { From 0c0ccdbe3dbf5bfa425d71cd2d7dc8cf7b3728f2 Mon Sep 17 00:00:00 2001 From: eliasyishak <42216813+eliasyishak@users.noreply.github.com> Date: Mon, 18 Sep 2023 14:48:46 -0400 Subject: [PATCH 3/4] Dart format fix --- pkgs/unified_analytics/lib/src/analytics.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/unified_analytics/lib/src/analytics.dart b/pkgs/unified_analytics/lib/src/analytics.dart index 474fc2f48..3fe23efcf 100644 --- a/pkgs/unified_analytics/lib/src/analytics.dart +++ b/pkgs/unified_analytics/lib/src/analytics.dart @@ -629,7 +629,7 @@ class AnalyticsImpl implements Analytics { status: surveyButton.action, )); } - + @override void surveyShown(Survey survey) { _surveyHandler.dismiss(survey, false); @@ -745,7 +745,7 @@ class NoOpAnalytics implements Analytics { required Survey survey, required SurveyButton surveyButton, }) {} - + @override void surveyShown(Survey survey) {} } From 699035c247ea0f16c052371b8e7e0e0634a0635c Mon Sep 17 00:00:00 2001 From: eliasyishak <42216813+eliasyishak@users.noreply.github.com> Date: Mon, 18 Sep 2023 14:59:01 -0400 Subject: [PATCH 4/4] Bump version to 4.0.0 --- pkgs/unified_analytics/CHANGELOG.md | 2 +- pkgs/unified_analytics/lib/src/constants.dart | 2 +- pkgs/unified_analytics/pubspec.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/unified_analytics/CHANGELOG.md b/pkgs/unified_analytics/CHANGELOG.md index fb7e4213e..c6d361cfa 100644 --- a/pkgs/unified_analytics/CHANGELOG.md +++ b/pkgs/unified_analytics/CHANGELOG.md @@ -1,4 +1,4 @@ -## 3.1.0 +## 4.0.0 - Enhanced `LogFileStats` data to include information about flutter channel counts and tool counts - Added new method to suppress telemetry collection temporarily for current invocation via `analytics.suppressTelemetry()` diff --git a/pkgs/unified_analytics/lib/src/constants.dart b/pkgs/unified_analytics/lib/src/constants.dart index cf19b13c7..92bfe2cbc 100644 --- a/pkgs/unified_analytics/lib/src/constants.dart +++ b/pkgs/unified_analytics/lib/src/constants.dart @@ -78,7 +78,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 = '3.1.0'; +const String kPackageVersion = '4.0.0'; /// The minimum length for a session. const int kSessionDurationMinutes = 30; diff --git a/pkgs/unified_analytics/pubspec.yaml b/pkgs/unified_analytics/pubspec.yaml index fa914cd54..86dbc686b 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: 3.1.0 +version: 4.0.0 repository: https://github.com/dart-lang/tools/tree/main/pkgs/unified_analytics environment: