Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
e9beaea0
Unverified
Commit
e9beaea0
authored
Sep 12, 2023
by
Elias Yishak
Committed by
GitHub
Sep 12, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up analytics opt in/out flags (#132588)
Fixes: - #132258
parent
dc8377b1
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
29 deletions
+33
-29
runner.dart
packages/flutter_tools/lib/runner.dart
+11
-11
config.dart
packages/flutter_tools/lib/src/commands/config.dart
+5
-1
globals.dart
packages/flutter_tools/lib/src/globals.dart
+1
-1
flutter_command_runner.dart
.../flutter_tools/lib/src/runner/flutter_command_runner.dart
+10
-10
runner_test.dart
.../flutter_tools/test/general.shard/runner/runner_test.dart
+6
-6
No files found.
packages/flutter_tools/lib/runner.dart
View file @
e9beaea0
...
@@ -61,20 +61,20 @@ Future<int> run(
...
@@ -61,20 +61,20 @@ Future<int> run(
StackTrace
?
firstStackTrace
;
StackTrace
?
firstStackTrace
;
return
runZoned
<
Future
<
int
>>(()
async
{
return
runZoned
<
Future
<
int
>>(()
async
{
try
{
try
{
if
(
args
.
contains
(
'--disable-
telemetry
'
)
&&
if
(
args
.
contains
(
'--disable-
analytics
'
)
&&
args
.
contains
(
'--enable-
telemetry
'
))
{
args
.
contains
(
'--enable-
analytics
'
))
{
throwToolExit
(
throwToolExit
(
'Both enable and disable
telemetry
commands were detected '
'Both enable and disable
analytics
commands were detected '
'when only one can be supplied per invocation.'
,
'when only one can be supplied per invocation.'
,
exitCode:
1
);
exitCode:
1
);
}
}
// Disable analytics if user passes in the `--disable-
telemetry
` option
// Disable analytics if user passes in the `--disable-
analytics
` option
//
`flutter --disable-telemetry`
//
"flutter --disable-analytics"
//
//
// Same functionality as
`flutter config --no-analytics`
for disabling
// Same functionality as
"flutter config --no-analytics"
for disabling
// except with the `value` hard coded as false
// except with the `value` hard coded as false
if
(
args
.
contains
(
'--disable-
telemetry
'
))
{
if
(
args
.
contains
(
'--disable-
analytics
'
))
{
// The tool sends the analytics event *before* toggling the flag
// The tool sends the analytics event *before* toggling the flag
// intentionally to be sure that opt-out events are sent correctly.
// intentionally to be sure that opt-out events are sent correctly.
AnalyticsConfigEvent
(
enabled:
false
).
send
();
AnalyticsConfigEvent
(
enabled:
false
).
send
();
...
@@ -93,12 +93,12 @@ Future<int> run(
...
@@ -93,12 +93,12 @@ Future<int> run(
await
globals
.
analytics
.
setTelemetry
(
false
);
await
globals
.
analytics
.
setTelemetry
(
false
);
}
}
// Enable analytics if user passes in the `--enable-
telemetry
` option
// Enable analytics if user passes in the `--enable-
analytics
` option
// `flutter --enable-
telemetry
`
// `flutter --enable-
analytics
`
//
//
// Same functionality as `flutter config --analytics` for enabling
// Same functionality as `flutter config --analytics` for enabling
// except with the `value` hard coded as true
// except with the `value` hard coded as true
if
(
args
.
contains
(
'--enable-
telemetry
'
))
{
if
(
args
.
contains
(
'--enable-
analytics
'
))
{
// The tool sends the analytics event *before* toggling the flag
// The tool sends the analytics event *before* toggling the flag
// intentionally to be sure that opt-out events are sent correctly.
// intentionally to be sure that opt-out events are sent correctly.
AnalyticsConfigEvent
(
enabled:
true
).
send
();
AnalyticsConfigEvent
(
enabled:
true
).
send
();
...
@@ -315,7 +315,7 @@ Future<int> _exit(int code, {required ShutdownHooks shutdownHooks}) async {
...
@@ -315,7 +315,7 @@ Future<int> _exit(int code, {required ShutdownHooks shutdownHooks}) async {
'the flutter tool is migrating to a new analytics system. '
'the flutter tool is migrating to a new analytics system. '
'Disabling analytics collection will disable both the legacy '
'Disabling analytics collection will disable both the legacy '
'and new analytics collection systems. '
'and new analytics collection systems. '
'You can disable analytics reporting by running `flutter --disable-
telemetry
`
\n
'
);
'You can disable analytics reporting by running `flutter --disable-
analytics
`
\n
'
);
}
}
// Invoking this will onboard the flutter tool onto
// Invoking this will onboard the flutter tool onto
...
...
packages/flutter_tools/lib/src/commands/config.dart
View file @
e9beaea0
...
@@ -11,11 +11,15 @@ import '../features.dart';
...
@@ -11,11 +11,15 @@ import '../features.dart';
import
'../globals.dart'
as
globals
;
import
'../globals.dart'
as
globals
;
import
'../reporting/reporting.dart'
;
import
'../reporting/reporting.dart'
;
import
'../runner/flutter_command.dart'
;
import
'../runner/flutter_command.dart'
;
import
'../runner/flutter_command_runner.dart'
;
class
ConfigCommand
extends
FlutterCommand
{
class
ConfigCommand
extends
FlutterCommand
{
ConfigCommand
({
bool
verboseHelp
=
false
})
{
ConfigCommand
({
bool
verboseHelp
=
false
})
{
argParser
.
addFlag
(
'analytics'
,
argParser
.
addFlag
(
'analytics'
,
help:
'Enable or disable reporting anonymously tool usage statistics and crash reports.'
);
hide:
!
verboseHelp
,
help:
'Enable or disable reporting anonymously tool usage statistics and crash reports.
\n
'
'(An alias for "--
${FlutterGlobalOptions.kEnableAnalyticsFlag}
" '
'and "--
${FlutterGlobalOptions.kDisableAnalyticsFlag}
" top level flags.)'
);
argParser
.
addFlag
(
'clear-ios-signing-cert'
,
argParser
.
addFlag
(
'clear-ios-signing-cert'
,
negatable:
false
,
negatable:
false
,
help:
'Clear the saved development certificate choice used to sign apps for iOS device deployment.'
);
help:
'Clear the saved development certificate choice used to sign apps for iOS device deployment.'
);
...
...
packages/flutter_tools/lib/src/globals.dart
View file @
e9beaea0
...
@@ -88,7 +88,7 @@ final BotDetector _defaultBotDetector = BotDetector(
...
@@ -88,7 +88,7 @@ final BotDetector _defaultBotDetector = BotDetector(
);
);
Future
<
bool
>
get
isRunningOnBot
=>
botDetector
.
isRunningOnBot
;
Future
<
bool
>
get
isRunningOnBot
=>
botDetector
.
isRunningOnBot
;
// Analytics instance for package:unified_analytics for
telemetry
// Analytics instance for package:unified_analytics for
analytics
// reporting for all Flutter and Dart related tooling
// reporting for all Flutter and Dart related tooling
Analytics
get
analytics
=>
context
.
get
<
Analytics
>()!;
Analytics
get
analytics
=>
context
.
get
<
Analytics
>()!;
...
...
packages/flutter_tools/lib/src/runner/flutter_command_runner.dart
View file @
e9beaea0
...
@@ -26,8 +26,8 @@ abstract final class FlutterGlobalOptions {
...
@@ -26,8 +26,8 @@ abstract final class FlutterGlobalOptions {
static
const
String
kColorFlag
=
'color'
;
static
const
String
kColorFlag
=
'color'
;
static
const
String
kContinuousIntegrationFlag
=
'ci'
;
static
const
String
kContinuousIntegrationFlag
=
'ci'
;
static
const
String
kDeviceIdOption
=
'device-id'
;
static
const
String
kDeviceIdOption
=
'device-id'
;
static
const
String
kDisable
TelemetryFlag
=
'disable-telemetry
'
;
static
const
String
kDisable
AnalyticsFlag
=
'disable-analytics
'
;
static
const
String
kEnable
TelemetryFlag
=
'enable-telemetry
'
;
static
const
String
kEnable
AnalyticsFlag
=
'enable-analytics
'
;
static
const
String
kLocalEngineOption
=
'local-engine'
;
static
const
String
kLocalEngineOption
=
'local-engine'
;
static
const
String
kLocalEngineSrcPathOption
=
'local-engine-src-path'
;
static
const
String
kLocalEngineSrcPathOption
=
'local-engine-src-path'
;
static
const
String
kLocalEngineHostOption
=
'local-engine-host'
;
static
const
String
kLocalEngineHostOption
=
'local-engine-host'
;
...
@@ -101,17 +101,17 @@ class FlutterCommandRunner extends CommandRunner<void> {
...
@@ -101,17 +101,17 @@ class FlutterCommandRunner extends CommandRunner<void> {
defaultsTo:
true
,
defaultsTo:
true
,
hide:
!
verboseHelp
,
hide:
!
verboseHelp
,
help:
'Allow Flutter to check for updates when this command runs.'
);
help:
'Allow Flutter to check for updates when this command runs.'
);
argParser
.
addFlag
(
FlutterGlobalOptions
.
k
Suppress
AnalyticsFlag
,
argParser
.
addFlag
(
FlutterGlobalOptions
.
k
Enable
AnalyticsFlag
,
negatable:
false
,
negatable:
false
,
help:
'Suppress analytics reporting for the current CLI invocation.'
);
help:
'Enable telemetry reporting each time a flutter or dart '
argParser
.
addFlag
(
FlutterGlobalOptions
.
kDisableTelemetryFlag
,
'command runs.'
);
argParser
.
addFlag
(
FlutterGlobalOptions
.
kDisableAnalyticsFlag
,
negatable:
false
,
negatable:
false
,
help:
'Disable telemetry reporting each time a flutter or dart '
help:
'Disable telemetry reporting each time a flutter or dart '
'command runs, until it is re-enabled.'
);
'command runs, until it is re-enabled.'
);
argParser
.
addFlag
(
FlutterGlobalOptions
.
k
EnableTelemetry
Flag
,
argParser
.
addFlag
(
FlutterGlobalOptions
.
k
SuppressAnalytics
Flag
,
negatable:
false
,
negatable:
false
,
help:
'Enable telemetry reporting each time a flutter or dart '
help:
'Suppress analytics reporting for the current CLI invocation.'
);
'command runs.'
);
argParser
.
addOption
(
FlutterGlobalOptions
.
kPackagesOption
,
argParser
.
addOption
(
FlutterGlobalOptions
.
kPackagesOption
,
hide:
!
verboseHelp
,
hide:
!
verboseHelp
,
help:
'Path to your "package_config.json" file.'
);
help:
'Path to your "package_config.json" file.'
);
...
@@ -237,8 +237,8 @@ class FlutterCommandRunner extends CommandRunner<void> {
...
@@ -237,8 +237,8 @@ class FlutterCommandRunner extends CommandRunner<void> {
// If the flag for enabling or disabling telemetry is passed in,
// If the flag for enabling or disabling telemetry is passed in,
// we will return out
// we will return out
if
(
topLevelResults
.
wasParsed
(
FlutterGlobalOptions
.
kDisable
Telemetry
Flag
)
||
if
(
topLevelResults
.
wasParsed
(
FlutterGlobalOptions
.
kDisable
Analytics
Flag
)
||
topLevelResults
.
wasParsed
(
FlutterGlobalOptions
.
kEnable
Telemetry
Flag
))
{
topLevelResults
.
wasParsed
(
FlutterGlobalOptions
.
kEnable
Analytics
Flag
))
{
return
;
return
;
}
}
...
...
packages/flutter_tools/test/general.shard/runner/runner_test.dart
View file @
e9beaea0
...
@@ -326,7 +326,7 @@ void main() {
...
@@ -326,7 +326,7 @@ void main() {
expect
(
globals
.
analytics
.
shouldShowMessage
,
true
);
expect
(
globals
.
analytics
.
shouldShowMessage
,
true
);
await
runner
.
run
(
await
runner
.
run
(
<
String
>[
'--disable-
telemetry
'
],
<
String
>[
'--disable-
analytics
'
],
()
=>
<
FlutterCommand
>[],
()
=>
<
FlutterCommand
>[],
// This flutterVersion disables crash reporting.
// This flutterVersion disables crash reporting.
flutterVersion:
'[user-branch]/'
,
flutterVersion:
'[user-branch]/'
,
...
@@ -343,7 +343,7 @@ void main() {
...
@@ -343,7 +343,7 @@ void main() {
);
);
testUsingContext
(
testUsingContext
(
'runner enabling
telemetry
with flag'
,
'runner enabling
analytics
with flag'
,
()
async
{
()
async
{
io
.
setExitFunctionForTests
((
int
exitCode
)
{});
io
.
setExitFunctionForTests
((
int
exitCode
)
{});
...
@@ -351,7 +351,7 @@ void main() {
...
@@ -351,7 +351,7 @@ void main() {
expect
(
globals
.
analytics
.
shouldShowMessage
,
false
);
expect
(
globals
.
analytics
.
shouldShowMessage
,
false
);
await
runner
.
run
(
await
runner
.
run
(
<
String
>[
'--enable-
telemetry
'
],
<
String
>[
'--enable-
analytics
'
],
()
=>
<
FlutterCommand
>[],
()
=>
<
FlutterCommand
>[],
// This flutterVersion disables crash reporting.
// This flutterVersion disables crash reporting.
flutterVersion:
'[user-branch]/'
,
flutterVersion:
'[user-branch]/'
,
...
@@ -377,8 +377,8 @@ void main() {
...
@@ -377,8 +377,8 @@ void main() {
final
int
exitCode
=
await
runner
.
run
(
final
int
exitCode
=
await
runner
.
run
(
<
String
>[
<
String
>[
'--disable-
telemetry
'
,
'--disable-
analytics
'
,
'--enable-
telemetry
'
,
'--enable-
analytics
'
,
],
],
()
=>
<
FlutterCommand
>[],
()
=>
<
FlutterCommand
>[],
// This flutterVersion disables crash reporting.
// This flutterVersion disables crash reporting.
...
@@ -538,7 +538,7 @@ class WaitingCrashReporter implements CrashReporter {
...
@@ -538,7 +538,7 @@ class WaitingCrashReporter implements CrashReporter {
}
}
/// A fake [Analytics] that will be used to test
/// A fake [Analytics] that will be used to test
/// the --disable-
telemetry
flag
/// the --disable-
analytics
flag
class
FakeAnalytics
extends
Fake
implements
Analytics
{
class
FakeAnalytics
extends
Fake
implements
Analytics
{
FakeAnalytics
({
bool
fakeTelemetryStatusOverride
=
true
})
FakeAnalytics
({
bool
fakeTelemetryStatusOverride
=
true
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment