Skip to content

Commit 2114514

Browse files
authored
Don't collect usage data during Fuchsia build (flutter#12780)
Previously, the usage analytics would generate a write to the user's HOME directory during the Fuchsia build. We're tightening down the environment in which we run the Fuchsia build, and these writes are now more obvious. This patch removes the usage analytics during the Fuchsia build, avoiding the write to the user's HOME directory.
1 parent 50db947 commit 2114514

File tree

4 files changed

+56
-6
lines changed

4 files changed

+56
-6
lines changed

packages/flutter_tools/bin/fuchsia_builder.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import '../lib/src/base/os.dart';
1717
import '../lib/src/base/platform.dart';
1818
import '../lib/src/base/terminal.dart';
1919
import '../lib/src/cache.dart';
20+
import '../lib/src/disabled_usage.dart';
2021
import '../lib/src/flx.dart';
2122
import '../lib/src/globals.dart';
2223
import '../lib/src/usage.dart';
@@ -54,7 +55,7 @@ Future<Null> main(List<String> args) async {
5455
context.putIfAbsent(Cache, () => new Cache());
5556
context.putIfAbsent(Config, () => new Config());
5657
context.putIfAbsent(OperatingSystemUtils, () => new OperatingSystemUtils());
57-
context.putIfAbsent(Usage, () => new Usage());
58+
context.putIfAbsent(Usage, () => new DisabledUsage());
5859
return run(args);
5960
});
6061
}

packages/flutter_tools/bin/fuchsia_tester.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import '../lib/src/base/platform.dart';
2020
import '../lib/src/base/terminal.dart';
2121
import '../lib/src/cache.dart';
2222
import '../lib/src/dart/package_map.dart';
23+
import '../lib/src/disabled_usage.dart';
2324
import '../lib/src/globals.dart';
2425
import '../lib/src/test/flutter_platform.dart' as loader;
2526
import '../lib/src/usage.dart';
@@ -50,7 +51,7 @@ Future<Null> main(List<String> args) async {
5051
context.putIfAbsent(Cache, () => new Cache());
5152
context.putIfAbsent(Config, () => new Config());
5253
context.putIfAbsent(OperatingSystemUtils, () => new OperatingSystemUtils());
53-
context.putIfAbsent(Usage, () => new Usage());
54+
context.putIfAbsent(Usage, () => new DisabledUsage());
5455
return run(args);
5556
});
5657
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright 2017 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'dart:async';
6+
7+
import 'usage.dart';
8+
9+
class DisabledUsage implements Usage {
10+
@override
11+
bool get isFirstRun => false;
12+
13+
@override
14+
bool get suppressAnalytics => true;
15+
16+
@override
17+
set suppressAnalytics(bool value) { }
18+
19+
@override
20+
bool get enabled => false;
21+
22+
@override
23+
set enabled(bool value) { }
24+
25+
@override
26+
String get clientId => null;
27+
28+
@override
29+
void sendCommand(String command, { Map<String, String> parameters }) { }
30+
31+
@override
32+
void sendEvent(String category, String parameter, { Map<String, String> parameters }) { }
33+
34+
@override
35+
void sendTiming(String category, String variableName, Duration duration, { String label }) { }
36+
37+
@override
38+
void sendException(dynamic exception, StackTrace trace) { }
39+
40+
@override
41+
Stream<Map<String, dynamic>> get onSend => null;
42+
43+
@override
44+
Future<Null> ensureAnalyticsSent() => new Future<Null>.value();
45+
46+
@override
47+
void printWelcome() { }
48+
}

packages/flutter_tools/lib/src/usage.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,15 @@ class Usage {
9595
}
9696

9797
void sendTiming(
98-
String category,
99-
String variableName,
98+
String category,
99+
String variableName,
100100
Duration duration, {
101101
String label,
102102
}) {
103103
if (!suppressAnalytics) {
104104
_analytics.sendTiming(
105-
variableName,
106-
duration.inMilliseconds,
105+
variableName,
106+
duration.inMilliseconds,
107107
category: category,
108108
label: label,
109109
);

0 commit comments

Comments
 (0)