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
82a4ba40
Unverified
Commit
82a4ba40
authored
Jul 19, 2019
by
Zachary Anderson
Committed by
GitHub
Jul 19, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[flutter_tool] Send analytics command before the command runs (#36490)
parent
d1190b63
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
45 deletions
+41
-45
logs.dart
packages/flutter_tools/lib/src/commands/logs.dart
+4
-3
screenshot.dart
packages/flutter_tools/lib/src/commands/screenshot.dart
+8
-5
flutter_command.dart
packages/flutter_tools/lib/src/runner/flutter_command.dart
+21
-17
flutter_command_test.dart
...tools/test/general.shard/runner/flutter_command_test.dart
+8
-20
No files found.
packages/flutter_tools/lib/src/commands/logs.dart
View file @
82a4ba40
...
...
@@ -32,11 +32,12 @@ class LogsCommand extends FlutterCommand {
Device
device
;
@override
Future
<
FlutterCommandResult
>
verifyThenRunCommand
()
async
{
Future
<
FlutterCommandResult
>
verifyThenRunCommand
(
String
commandPath
)
async
{
device
=
await
findTargetDevice
();
if
(
device
==
null
)
if
(
device
==
null
)
{
throwToolExit
(
null
);
return
super
.
verifyThenRunCommand
();
}
return
super
.
verifyThenRunCommand
(
commandPath
);
}
@override
...
...
packages/flutter_tools/lib/src/commands/screenshot.dart
View file @
82a4ba40
...
...
@@ -64,15 +64,18 @@ class ScreenshotCommand extends FlutterCommand {
Device
device
;
@override
Future
<
FlutterCommandResult
>
verifyThenRunCommand
()
async
{
Future
<
FlutterCommandResult
>
verifyThenRunCommand
(
String
commandPath
)
async
{
device
=
await
findTargetDevice
();
if
(
device
==
null
)
if
(
device
==
null
)
{
throwToolExit
(
'Must have a connected device'
);
if
(
argResults
[
_kType
]
==
_kDeviceType
&&
!
device
.
supportsScreenshot
)
}
if
(
argResults
[
_kType
]
==
_kDeviceType
&&
!
device
.
supportsScreenshot
)
{
throwToolExit
(
'Screenshot not supported for
${device.name}
.'
);
if
(
argResults
[
_kType
]
!=
_kDeviceType
&&
argResults
[
_kObservatoryUri
]
==
null
)
}
if
(
argResults
[
_kType
]
!=
_kDeviceType
&&
argResults
[
_kObservatoryUri
]
==
null
)
{
throwToolExit
(
'Observatory URI must be specified for screenshot type
${argResults[_kType]}
'
);
return
super
.
verifyThenRunCommand
();
}
return
super
.
verifyThenRunCommand
(
commandPath
);
}
@override
...
...
packages/flutter_tools/lib/src/runner/flutter_command.dart
View file @
82a4ba40
...
...
@@ -379,9 +379,10 @@ abstract class FlutterCommand extends Command<void> {
body:
()
async
{
if
(
flutterUsage
.
isFirstRun
)
flutterUsage
.
printWelcome
();
final
String
commandPath
=
await
usagePath
;
FlutterCommandResult
commandResult
;
try
{
commandResult
=
await
verifyThenRunCommand
();
commandResult
=
await
verifyThenRunCommand
(
commandPath
);
}
on
ToolExit
{
commandResult
=
const
FlutterCommandResult
(
ExitStatus
.
fail
);
rethrow
;
...
...
@@ -389,8 +390,7 @@ abstract class FlutterCommand extends Command<void> {
final
DateTime
endTime
=
systemClock
.
now
();
printTrace
(
userMessages
.
flutterElapsedTime
(
name
,
getElapsedAsMilliseconds
(
endTime
.
difference
(
startTime
))));
printTrace
(
'"flutter
$name
" took
${getElapsedAsMilliseconds(endTime.difference(startTime))}
.'
);
await
_sendUsage
(
commandResult
,
startTime
,
endTime
);
_sendPostUsage
(
commandPath
,
commandResult
,
startTime
,
endTime
);
}
},
);
...
...
@@ -400,33 +400,28 @@ abstract class FlutterCommand extends Command<void> {
///
/// For example, the command path (e.g. `build/apk`) and the result,
/// as well as the time spent running it.
Future
<
void
>
_sendUsage
(
FlutterCommandResult
commandResult
,
DateTime
startTime
,
DateTime
endTime
)
async
{
final
String
commandPath
=
await
usagePath
;
void
_sendPostUsage
(
String
commandPath
,
FlutterCommandResult
commandResult
,
DateTime
startTime
,
DateTime
endTime
)
{
if
(
commandPath
==
null
)
{
return
;
}
// Send screen.
final
Map
<
String
,
String
>
currentUsageValues
=
await
usageValues
;
final
Map
<
String
,
String
>
additionalUsageValues
=
<
String
,
String
>{
...?
currentUsageValues
,
};
// Send command result.
String
result
=
'unspecified'
;
if
(
commandResult
!=
null
)
{
switch
(
commandResult
.
exitStatus
)
{
case
ExitStatus
.
success
:
additionalUsageValues
[
kCommandResult
]
=
'success'
;
result
=
'success'
;
break
;
case
ExitStatus
.
warning
:
additionalUsageValues
[
kCommandResult
]
=
'warning'
;
result
=
'warning'
;
break
;
case
ExitStatus
.
fail
:
additionalUsageValues
[
kCommandResult
]
=
'fail'
;
result
=
'fail'
;
break
;
}
}
additionalUsageValues
[
kCommandHasTerminal
]
=
io
.
stdout
.
hasTerminal
?
'true'
:
'false'
;
flutterUsage
.
sendCommand
(
commandPath
,
parameters:
additionalUsageValues
);
flutterUsage
.
sendEvent
(
commandPath
,
result
);
// Send timing.
final
List
<
String
>
labels
=
<
String
>[
...
...
@@ -459,7 +454,7 @@ abstract class FlutterCommand extends Command<void> {
/// then call this method to execute the command
/// rather than calling [runCommand] directly.
@mustCallSuper
Future
<
FlutterCommandResult
>
verifyThenRunCommand
()
async
{
Future
<
FlutterCommandResult
>
verifyThenRunCommand
(
String
commandPath
)
async
{
await
validateCommand
();
// Populate the cache. We call this before pub get below so that the sky_engine
...
...
@@ -476,6 +471,15 @@ abstract class FlutterCommand extends Command<void> {
setupApplicationPackages
();
if
(
commandPath
!=
null
)
{
final
Map
<
String
,
String
>
additionalUsageValues
=
<
String
,
String
>{
...?
await
usageValues
,
};
additionalUsageValues
[
kCommandHasTerminal
]
=
io
.
stdout
.
hasTerminal
?
'true'
:
'false'
;
flutterUsage
.
sendCommand
(
commandPath
,
parameters:
additionalUsageValues
);
}
return
await
runCommand
();
}
...
...
packages/flutter_tools/test/general.shard/runner/flutter_command_test.dart
View file @
82a4ba40
...
...
@@ -60,11 +60,8 @@ void main() {
);
await
flutterCommand
.
run
();
expect
(
verify
(
usage
.
sendCommand
(
captureAny
,
parameters:
captureAnyNamed
(
'parameters'
))).
captured
[
1
][
'cd26'
],
equals
(
'success'
),
);
verify
(
usage
.
sendCommand
(
captureAny
,
parameters:
captureAnyNamed
(
'parameters'
)));
verify
(
usage
.
sendEvent
(
captureAny
,
'success'
));
},
overrides:
<
Type
,
Generator
>{
SystemClock:
()
=>
clock
,
...
...
@@ -82,11 +79,8 @@ void main() {
);
await
flutterCommand
.
run
();
expect
(
verify
(
usage
.
sendCommand
(
captureAny
,
parameters:
captureAnyNamed
(
'parameters'
))).
captured
[
1
][
'cd26'
],
equals
(
'warning'
),
);
verify
(
usage
.
sendCommand
(
captureAny
,
parameters:
captureAnyNamed
(
'parameters'
)));
verify
(
usage
.
sendEvent
(
captureAny
,
'warning'
));
},
overrides:
<
Type
,
Generator
>{
SystemClock:
()
=>
clock
,
...
...
@@ -106,11 +100,8 @@ void main() {
try
{
await
flutterCommand
.
run
();
}
on
ToolExit
{
expect
(
verify
(
usage
.
sendCommand
(
captureAny
,
parameters:
captureAnyNamed
(
'parameters'
))).
captured
[
1
][
'cd26'
],
equals
(
'fail'
),
);
verify
(
usage
.
sendCommand
(
captureAny
,
parameters:
captureAnyNamed
(
'parameters'
)));
verify
(
usage
.
sendEvent
(
captureAny
,
'fail'
));
}
},
overrides:
<
Type
,
Generator
>{
...
...
@@ -133,11 +124,8 @@ void main() {
await
flutterCommand
.
run
();
fail
(
'Mock should make this fail'
);
}
on
ToolExit
{
expect
(
verify
(
usage
.
sendCommand
(
captureAny
,
parameters:
captureAnyNamed
(
'parameters'
))).
captured
[
1
][
'cd26'
],
equals
(
'fail'
),
);
verify
(
usage
.
sendCommand
(
captureAny
,
parameters:
captureAnyNamed
(
'parameters'
)));
verify
(
usage
.
sendEvent
(
captureAny
,
'fail'
));
}
},
overrides:
<
Type
,
Generator
>{
...
...
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