Unified analytics events for doctor validators (#136647)
Related to tracking issue: - https://github.com/flutter/flutter/issues/128251 This PR sends analytic events for each of the doctor validators. This PR below will need to land first in `dart-lang/tools` before this merges.
This commit is contained in:
@@ -16,6 +16,10 @@ import 'package:meta/meta.dart';
|
||||
import 'package:path/path.dart' as path; // flutter_ignore: package_path_import
|
||||
import 'package:test/test.dart' as test_package show test;
|
||||
import 'package:test/test.dart' hide test;
|
||||
import 'package:unified_analytics/src/enums.dart';
|
||||
import 'package:unified_analytics/unified_analytics.dart';
|
||||
|
||||
import 'fakes.dart';
|
||||
|
||||
export 'package:path/path.dart' show Context; // flutter_ignore: package_path_import
|
||||
export 'package:test/test.dart' hide isInstanceOf, test;
|
||||
@@ -305,3 +309,38 @@ class FileExceptionHandler {
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
|
||||
/// This method is required to fetch an instance of [FakeAnalytics]
|
||||
/// because there is initialization logic that is required. An initial
|
||||
/// instance will first be created and will let package:unified_analytics
|
||||
/// know that the consent message has been shown. After confirming on the first
|
||||
/// instance, then a second instance will be generated and returned. This second
|
||||
/// instance will be cleared to send events.
|
||||
FakeAnalytics getInitializedFakeAnalyticsInstance({
|
||||
required FileSystem fs,
|
||||
required FakeFlutterVersion fakeFlutterVersion,
|
||||
}) {
|
||||
final Directory homeDirectory = fs.directory('/');
|
||||
final FakeAnalytics initialAnalytics = FakeAnalytics(
|
||||
tool: DashTool.flutterTool,
|
||||
homeDirectory: homeDirectory,
|
||||
dartVersion: fakeFlutterVersion.dartSdkVersion,
|
||||
platform: DevicePlatform.linux,
|
||||
fs: fs,
|
||||
surveyHandler: SurveyHandler(homeDirectory: homeDirectory, fs: fs),
|
||||
flutterChannel: fakeFlutterVersion.channel,
|
||||
flutterVersion: fakeFlutterVersion.getVersionString(),
|
||||
);
|
||||
initialAnalytics.clientShowedMessage();
|
||||
|
||||
return FakeAnalytics(
|
||||
tool: DashTool.flutterTool,
|
||||
homeDirectory: homeDirectory,
|
||||
dartVersion: fakeFlutterVersion.dartSdkVersion,
|
||||
platform: DevicePlatform.linux,
|
||||
fs: fs,
|
||||
surveyHandler: SurveyHandler(homeDirectory: homeDirectory, fs: fs),
|
||||
flutterChannel: fakeFlutterVersion.channel,
|
||||
flutterVersion: fakeFlutterVersion.getVersionString(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import 'package:flutter_tools/src/base/process.dart';
|
||||
import 'package:flutter_tools/src/base/signals.dart';
|
||||
import 'package:flutter_tools/src/base/template.dart';
|
||||
import 'package:flutter_tools/src/base/terminal.dart';
|
||||
import 'package:flutter_tools/src/base/time.dart';
|
||||
import 'package:flutter_tools/src/base/version.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/context_runner.dart';
|
||||
@@ -291,7 +292,8 @@ class FakeAndroidLicenseValidator extends Fake implements AndroidLicenseValidato
|
||||
}
|
||||
|
||||
class FakeDoctor extends Doctor {
|
||||
FakeDoctor(Logger logger) : super(logger: logger);
|
||||
FakeDoctor(Logger logger, {super.clock = const SystemClock()})
|
||||
: super(logger: logger);
|
||||
|
||||
// True for testing.
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user