Skip to content

Commit 9ab2316

Browse files
devoncarewCommit Queue
authored andcommitted
refactor dartdev deps
Change-Id: I6bf49395abd39bea20acd8bc1c39c8db4fdabaaf Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403621 Reviewed-by: Ben Konyi <[email protected]> Commit-Queue: Devon Carew <[email protected]>
1 parent 2b1f956 commit 9ab2316

File tree

5 files changed

+75
-79
lines changed

5 files changed

+75
-79
lines changed

pkg/dartdev/lib/src/unified_analytics.dart

Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@
55
import 'dart:io';
66

77
import 'package:path/path.dart' as path;
8-
import 'package:telemetry/telemetry.dart' as telemetry show isRunningOnBot;
98
import 'package:unified_analytics/unified_analytics.dart';
109

1110
import 'sdk.dart';
1211

1312
const String _dartDirectoryName = '.dart';
1413

15-
const String analyticsDisabledNoticeMessage =
16-
'Analytics reporting disabled. In order to enable it, run: dart --enable-analytics';
14+
const String analyticsDisabledNoticeMessage = 'Analytics reporting disabled. '
15+
'In order to enable it, run: dart --enable-analytics';
1716

1817
/// Create the `Analytics` instance to be used to report analytics.
1918
Analytics createUnifiedAnalytics({bool disableAnalytics = false}) {
@@ -56,7 +55,7 @@ Directory? getDartStorageDirectory() {
5655

5756
/// The method used by dartdev to determine if this machine is a bot such as a
5857
/// CI machine.
59-
bool isBot() => telemetry.isRunningOnBot();
58+
bool isBot() => _isRunningOnBot();
6059

6160
// Matches file:/, non-ws, /, non-ws, .dart
6261
final RegExp _pathRegex = RegExp(r'file:/\S+/(\S+\.dart)');
@@ -91,3 +90,70 @@ String sanitizeStacktrace(dynamic st, {bool shorten = true}) {
9190

9291
return str;
9392
}
93+
94+
/// Detect whether we're running on a bot / a continuous testing environment.
95+
///
96+
/// We should periodically keep this code up to date with:
97+
/// https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/base/bot_detector.dart#L30
98+
/// and
99+
/// https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/reporting/usage.dart#L200.
100+
bool _isRunningOnBot() {
101+
final Map<String, String> env = Platform.environment;
102+
103+
if (
104+
// Explicitly stated to not be a bot.
105+
env['BOT'] == 'false'
106+
// Set by the IDEs to the IDE name, so a strong signal that this is
107+
// not a bot.
108+
||
109+
env.containsKey('FLUTTER_HOST')
110+
// When set, GA logs to a local file (normally for tests) so we don't
111+
// need to filter.
112+
||
113+
env.containsKey('FLUTTER_ANALYTICS_LOG_FILE')) {
114+
return false;
115+
}
116+
117+
// TODO(jwren): Azure detection -- each call for this detection requires an
118+
// http connection, the flutter cli tool captures the result on the first run,
119+
// we should consider the same caching here.
120+
121+
return env.containsKey('BOT')
122+
// https://docs.travis-ci.com/user/environment-variables/
123+
// Example .travis.yml file:
124+
// https://github.com/flutter/devtools/blob/master/.travis.yml
125+
||
126+
env['TRAVIS'] == 'true' ||
127+
env['CONTINUOUS_INTEGRATION'] == 'true' ||
128+
env.containsKey('CI') // Travis and AppVeyor
129+
130+
// https://www.appveyor.com/docs/environment-variables/
131+
||
132+
env.containsKey('APPVEYOR')
133+
134+
// https://cirrus-ci.org/guide/writing-tasks/#environment-variables
135+
||
136+
env.containsKey('CIRRUS_CI')
137+
138+
// https://docs.aws.amazon.com/codebuild/latest/userguide/build-env-ref-env-vars.html
139+
||
140+
(env.containsKey('AWS_REGION') && env.containsKey('CODEBUILD_INITIATOR'))
141+
142+
// https://wiki.jenkins.io/display/JENKINS/Building+a+software+project#Buildingasoftwareproject-belowJenkinsSetEnvironmentVariables
143+
||
144+
env.containsKey('JENKINS_URL')
145+
146+
// https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables#default-environment-variables
147+
||
148+
env.containsKey('GITHUB_ACTIONS')
149+
150+
// Properties on Flutter's Chrome Infra bots.
151+
||
152+
env['CHROME_HEADLESS'] == '1' ||
153+
env.containsKey('BUILDBOT_BUILDERNAME') ||
154+
env.containsKey('SWARMING_TASK_ID')
155+
156+
// Property when running on borg.
157+
||
158+
env.containsKey('BORG_ALLOC_DIR');
159+
}

pkg/dartdev/pubspec.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ dependencies:
3131
native_assets_cli: any
3232
path: any
3333
pub: any
34-
telemetry: any
3534
unified_analytics: any
3635
vm: any
3736
vm_service: any

pkg/telemetry/lib/crash_reporting.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import 'dart:math' as math;
99
import 'package:http/http.dart' as http;
1010
import 'package:meta/meta.dart';
1111
import 'package:stack_trace/stack_trace.dart';
12-
import 'package:telemetry/src/pii_regexp.dart';
1312

13+
import 'src/pii_regexp.dart';
1414
import 'src/utils.dart';
1515

1616
/// Tells crash backend that this is a Dart error (as opposed to, say, Java).
@@ -58,8 +58,8 @@ class CrashReportSender {
5858
http.Client? httpClient,
5959
String endpointPath = _crashEndpointPathStaging,
6060
}) : _httpClient = httpClient ?? http.Client(),
61-
_baseUri = Uri(
62-
scheme: 'https', host: _crashServerHost, path: endpointPath);
61+
_baseUri =
62+
Uri(scheme: 'https', host: _crashServerHost, path: endpointPath);
6363

6464
/// Create a new [CrashReportSender] connected to the staging endpoint.
6565
CrashReportSender.staging(
@@ -195,7 +195,7 @@ class CrashReportAttachment {
195195
CrashReportAttachment.string({
196196
required String field,
197197
required String value,
198-
}) : _field = field,
198+
}) : _field = field,
199199
_value = value;
200200
}
201201

pkg/telemetry/lib/telemetry.dart

Lines changed: 0 additions & 70 deletions
This file was deleted.

pkg/telemetry/pubspec.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ dependencies:
1414

1515
# Use 'any' constraints here; we get our versions from the DEPS file.
1616
dev_dependencies:
17+
lints: any
1718
test: any

0 commit comments

Comments
 (0)