Unverified Commit 9a76efc8 authored by Elias Yishak's avatar Elias Yishak Committed by GitHub

Update analytics constructor to include `FLUTTER_HOST` (#138107)

Fixes issues:
- https://github.com/flutter/flutter/issues/138035

Similar to GA3, we will now record the host running the flutter tool, such as VSCode, stored in the `FLUTTER_HOST` env variable
parent 33c0f274
......@@ -93,6 +93,7 @@ Future<T> runInContext<T>(
runningOnBot: runningOnBot,
flutterVersion: globals.flutterVersion,
environment: globals.platform.environment,
clientIde: globals.platform.environment['FLUTTER_HOST'],
),
AndroidBuilder: () => AndroidGradleBuilder(
java: globals.java,
......
......@@ -19,6 +19,7 @@ Analytics getAnalytics({
required bool runningOnBot,
required FlutterVersion flutterVersion,
required Map<String, String> environment,
required String? clientIde,
bool enableAsserts = false,
FakeAnalytics? analyticsOverride,
}) {
......@@ -48,5 +49,6 @@ Analytics getAnalytics({
flutterVersion: flutterVersion.frameworkVersion,
dartVersion: flutterVersion.dartSdkVersion,
enableAsserts: enableAsserts,
clientIde: clientIde,
);
}
......@@ -8,10 +8,12 @@ import 'package:flutter_tools/src/reporting/unified_analytics.dart';
import 'package:unified_analytics/unified_analytics.dart';
import '../src/common.dart';
import '../src/context.dart';
import '../src/fakes.dart';
void main() {
const String userBranch = 'abc123';
const String clientIde = 'VSCode';
late FileSystem fs;
late FakeAnalytics analyticsOverride;
......@@ -24,6 +26,7 @@ void main() {
fakeFlutterVersion: FakeFlutterVersion(
branch: userBranch,
),
clientIde: clientIde,
);
});
......@@ -34,6 +37,7 @@ void main() {
flutterVersion: FakeFlutterVersion(),
environment: const <String, String>{},
analyticsOverride: analyticsOverride,
clientIde: clientIde,
);
expect(analytics.clientId, isNot(NoOpAnalytics.staticClientId),
......@@ -50,6 +54,7 @@ void main() {
),
environment: const <String, String>{},
analyticsOverride: analyticsOverride,
clientIde: clientIde,
);
expect(
......@@ -68,6 +73,7 @@ void main() {
),
environment: const <String, String>{},
analyticsOverride: analyticsOverride,
clientIde: clientIde,
);
expect(
......@@ -84,6 +90,7 @@ void main() {
flutterVersion: FakeFlutterVersion(),
environment: const <String, String>{},
analyticsOverride: analyticsOverride,
clientIde: clientIde,
);
expect(
......@@ -96,10 +103,11 @@ void main() {
testWithoutContext('NoOp instance when suppressing via env variable', () {
final Analytics analytics = getAnalytics(
runningOnBot: true,
runningOnBot: false,
flutterVersion: FakeFlutterVersion(),
environment: const <String, String>{'FLUTTER_SUPPRESS_ANALYTICS': 'true'},
analyticsOverride: analyticsOverride,
clientIde: clientIde,
);
expect(
......@@ -121,5 +129,18 @@ void main() {
expect(analyticsOverride.sentEvents, hasLength(1));
});
testUsingContext('Client IDE is passed and found in events', () {
final Analytics analytics = getAnalytics(
runningOnBot: false,
flutterVersion: FakeFlutterVersion(),
environment: const <String, String>{},
analyticsOverride: analyticsOverride,
clientIde: clientIde,
);
analytics as FakeAnalytics;
expect(analytics.userProperty.clientIde, 'VSCode');
});
});
}
......@@ -320,6 +320,7 @@ class FileExceptionHandler {
FakeAnalytics getInitializedFakeAnalyticsInstance({
required FileSystem fs,
required FakeFlutterVersion fakeFlutterVersion,
String? clientIde,
}) {
final Directory homeDirectory = fs.directory('/');
final FakeAnalytics initialAnalytics = FakeAnalytics(
......@@ -343,5 +344,6 @@ FakeAnalytics getInitializedFakeAnalyticsInstance({
surveyHandler: SurveyHandler(homeDirectory: homeDirectory, fs: fs),
flutterChannel: fakeFlutterVersion.channel,
flutterVersion: fakeFlutterVersion.getVersionString(),
clientIde: clientIde,
);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment