Skip to content

Commit

Permalink
Use constant for no op client id (#168)
Browse files Browse the repository at this point in the history
* Use constant for no op client id

* Bumping version to 4.0.1

* Update constants.dart

* Clean up on change log

* Example prints out clientId

* Use static method on NoOp class instead of constant
  • Loading branch information
eliasyishak authored Sep 28, 2023
1 parent e83caee commit a51f779
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 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 @@
## 4.0.1

- Adding constant for the NoOpAnalytics instance client ID to enable clients to reference it in tests

## 4.0.0

- Enhanced `LogFileStats` data to include information about flutter channel counts and tool counts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ void main() async {
analytics.clientShowedMessage();
}

print('Current user is opted in: ${analytics.telemetryEnabled}');
print('Current user ${analytics.clientId} '
'is opted in: ${analytics.telemetryEnabled}');

// Example of long running process
await Future<void>.delayed(const Duration(milliseconds: 100));
Expand Down
5 changes: 4 additions & 1 deletion pkgs/unified_analytics/lib/src/analytics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,9 @@ class FakeAnalytics extends AnalyticsImpl {
/// This is for clients that opt to either not send analytics, or will migrate
/// to use [AnalyticsImpl] at a later time.
class NoOpAnalytics implements Analytics {
/// The hard-coded client ID value for each NoOp instance.
static String get staticClientId => 'xxxx-xxxx';

@override
final String getConsentMessage = '';

Expand All @@ -721,7 +724,7 @@ class NoOpAnalytics implements Analytics {
const NoOpAnalytics._();

@override
String get clientId => 'xxxx-xxxx';
String get clientId => staticClientId;

@override
void clientShowedMessage() {}
Expand Down
2 changes: 1 addition & 1 deletion pkgs/unified_analytics/lib/src/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '4.0.0';
const String kPackageVersion = '4.0.1';

/// The minimum length for a session.
const int kSessionDurationMinutes = 30;
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: 4.0.0
version: 4.0.1
repository: https://github.com/dart-lang/tools/tree/main/pkgs/unified_analytics

environment:
Expand Down

0 comments on commit a51f779

Please sign in to comment.