Skip to content

Commit 70d778d

Browse files
authored
Expose the client id + hard code for NoOp instance (#163)
* Added getters for client id * Test added for NoOp instance * Dart format fix * Bump version to 4.0.0
1 parent 63d8267 commit 70d778d

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

pkgs/unified_analytics/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
## 3.1.0
1+
## 4.0.0
22

33
- Enhanced `LogFileStats` data to include information about flutter channel counts and tool counts
44
- Added new method to suppress telemetry collection temporarily for current invocation via `analytics.suppressTelemetry()`
55
- Added `SurveyHandler` feature to `Analytics` instance to fetch available surveys from remote endpoint to display to users along with functionality to dismiss them
66
- Surveys will be disabled for any users that have been opted out
77
- Shipping `FakeAnalytics` for clients of this tool that need to ensure workflows are sending events in tests
8+
- Adding getter to `Analytics` instance to fetch the client ID being sent to GA4
89

910
## 3.0.0
1011

pkgs/unified_analytics/lib/src/analytics.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ abstract class Analytics {
187187
enableAsserts: true,
188188
);
189189

190+
/// The shared identifier for Flutter and Dart related tooling using
191+
/// package:unified_analytics.
192+
String get clientId;
193+
190194
/// Retrieves the consent message to prompt users with on first
191195
/// run or when the message has been updated.
192196
String get getConsentMessage;
@@ -401,6 +405,9 @@ class AnalyticsImpl implements Analytics {
401405
_logHandler = LogHandler(fs: fs, homeDirectory: homeDirectory);
402406
}
403407

408+
@override
409+
String get clientId => _clientId;
410+
404411
@override
405412
String get getConsentMessage {
406413
// The command to swap in the consent message
@@ -713,6 +720,9 @@ class NoOpAnalytics implements Analytics {
713720

714721
const NoOpAnalytics._();
715722

723+
@override
724+
String get clientId => 'xxxx-xxxx';
725+
716726
@override
717727
void clientShowedMessage() {}
718728

pkgs/unified_analytics/lib/src/constants.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ const int kLogFileLength = 2500;
7878
const String kLogFileName = 'dart-flutter-telemetry.log';
7979

8080
/// The current version of the package, should be in line with pubspec version.
81-
const String kPackageVersion = '3.1.0';
81+
const String kPackageVersion = '4.0.0';
8282

8383
/// The minimum length for a session.
8484
const int kSessionDurationMinutes = 30;

pkgs/unified_analytics/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: >-
44
to Google Analytics.
55
# When updating this, keep the version consistent with the changelog and the
66
# value in lib/src/constants.dart.
7-
version: 3.1.0
7+
version: 4.0.0
88
repository: https://github.com/dart-lang/tools/tree/main/pkgs/unified_analytics
99

1010
environment:

pkgs/unified_analytics/test/no_op_analytics_test.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ void main() {
6262

6363
expect(checkDirectoryForWritePermissions(home), true);
6464
});
65+
66+
test('Fetching the client id', () {
67+
final analytics = NoOpAnalytics();
68+
expect(analytics.clientId, 'xxxx-xxxx');
69+
});
6570
}
6671

6772
class FakeDirectory extends Fake implements Directory {

0 commit comments

Comments
 (0)