Skip to content

Commit

Permalink
Reverts "Migration for the sendTiming events for `package:unified_a…
Browse files Browse the repository at this point in the history
…nalytics`" (#139278)

Reverts flutter/flutter#138896
Initiated by: CaseyHillers
This change reverts the following previous change:
Original Description:
Related to tracker issue:
- flutter/flutter#128251

<img width="278" alt="image" src="https://github.com/flutter/flutter/assets/42216813/cee7b9be-48d6-48e5-8c39-de28d0a1f0de">

The image above shows all of the instances where we have `sendTiming`. All of the call sites have been updated to use the new `Event.timing` event from `package:unified_analytics`.
  • Loading branch information
auto-submit[bot] authored Nov 30, 2023
1 parent c8101b5 commit 6c4475e
Show file tree
Hide file tree
Showing 27 changed files with 274 additions and 806 deletions.
32 changes: 4 additions & 28 deletions packages/flutter_tools/lib/src/android/gradle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -490,13 +490,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
status.stop();
}

final Duration elapsedDuration = sw.elapsed;
_usage.sendTiming('build', 'gradle', elapsedDuration);
_analytics.send(Event.timing(
workflow: 'build',
variableName: 'gradle',
elapsedMilliseconds: elapsedDuration.inMilliseconds,
));
_usage.sendTiming('build', 'gradle', sw.elapsed);

if (exitCode != 0) {
if (detectedGradleError == null) {
Expand Down Expand Up @@ -763,13 +757,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
} finally {
status.stop();
}
final Duration elapsedDuration = sw.elapsed;
_usage.sendTiming('build', 'gradle-aar', elapsedDuration);
_analytics.send(Event.timing(
workflow: 'build',
variableName: 'gradle-aar',
elapsedMilliseconds: elapsedDuration.inMilliseconds,
));
_usage.sendTiming('build', 'gradle-aar', sw.elapsed);

if (result.exitCode != 0) {
_logger.printStatus(result.stdout, wrap: false);
Expand Down Expand Up @@ -804,13 +792,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
project: project,
);

final Duration elapsedDuration = sw.elapsed;
_usage.sendTiming('print', 'android build variants', elapsedDuration);
_analytics.send(Event.timing(
workflow: 'print',
variableName: 'android build variants',
elapsedMilliseconds: elapsedDuration.inMilliseconds,
));
_usage.sendTiming('print', 'android build variants', sw.elapsed);

if (result.exitCode != 0) {
_logger.printStatus(result.stdout, wrap: false);
Expand Down Expand Up @@ -846,13 +828,7 @@ class AndroidGradleBuilder implements AndroidBuilder {
options: <String>['-q', '-PoutputPath=$outputPath'],
project: project,
);
final Duration elapsedDuration = sw.elapsed;
_usage.sendTiming('outputs', 'app link settings', elapsedDuration);
_analytics.send(Event.timing(
workflow: 'outputs',
variableName: 'app link settings',
elapsedMilliseconds: elapsedDuration.inMilliseconds,
));
_usage.sendTiming('outputs', 'app link settings', sw.elapsed);

if (result.exitCode != 0) {
_logger.printStatus(result.stdout, wrap: false);
Expand Down
23 changes: 4 additions & 19 deletions packages/flutter_tools/lib/src/commands/packages.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// found in the LICENSE file.

import 'package:args/args.dart';
import 'package:unified_analytics/unified_analytics.dart';

import '../base/common.dart';
import '../base/os.dart';
Expand Down Expand Up @@ -299,7 +298,7 @@ class PackagesGetCommand extends FlutterCommand {
processManager: globals.processManager,
platform: globals.platform,
usage: globals.flutterUsage,
analytics: analytics,
analytics: globals.analytics,
projectDir: rootProject.directory,
generateDartPluginRegistry: true,
);
Expand All @@ -320,7 +319,7 @@ class PackagesGetCommand extends FlutterCommand {
processManager: globals.processManager,
platform: globals.platform,
usage: globals.flutterUsage,
analytics: analytics,
analytics: globals.analytics,
projectDir: rootProject.directory,
generateDartPluginRegistry: true,
);
Expand Down Expand Up @@ -355,24 +354,10 @@ class PackagesGetCommand extends FlutterCommand {
command: name,
touchesPackageConfig: !(isHelp || dryRun),
);
final Duration elapsedDuration = timer.elapsed;
globals.flutterUsage.sendTiming('pub', 'get', elapsedDuration, label: 'success');
analytics.send(Event.timing(
workflow: 'pub',
variableName: 'get',
elapsedMilliseconds: elapsedDuration.inMilliseconds,
label: 'success'
));
globals.flutterUsage.sendTiming('pub', 'get', timer.elapsed, label: 'success');
// Not limiting to catching Exception because the exception is rethrown.
} catch (_) { // ignore: avoid_catches_without_on_clauses
final Duration elapsedDuration = timer.elapsed;
globals.flutterUsage.sendTiming('pub', 'get', elapsedDuration, label: 'failure');
analytics.send(Event.timing(
workflow: 'pub',
variableName: 'get',
elapsedMilliseconds: elapsedDuration.inMilliseconds,
label: 'failure'
));
globals.flutterUsage.sendTiming('pub', 'get', timer.elapsed, label: 'failure');
rethrow;
}

Expand Down
8 changes: 1 addition & 7 deletions packages/flutter_tools/lib/src/ios/mac.dart
Original file line number Diff line number Diff line change
Expand Up @@ -419,13 +419,7 @@ Future<XcodeBuildResult> buildXcodeProject({
'Xcode ${xcodeBuildActionToString(buildAction)} done.'.padRight(kDefaultStatusPadding + 1)
+ getElapsedAsSeconds(sw.elapsed).padLeft(5),
);
final Duration elapsedDuration = sw.elapsed;
globals.flutterUsage.sendTiming(xcodeBuildActionToString(buildAction), 'xcode-ios', elapsedDuration);
globals.analytics.send(Event.timing(
workflow: xcodeBuildActionToString(buildAction),
variableName: 'xcode-ios',
elapsedMilliseconds: elapsedDuration.inMilliseconds,
));
globals.flutterUsage.sendTiming(xcodeBuildActionToString(buildAction), 'xcode-ios', Duration(milliseconds: sw.elapsedMilliseconds));

if (tempDir.existsSync()) {
// Display additional warning and error message from xcresult bundle.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,11 +452,6 @@ Please provide a valid TCP port (an integer between 0 and 65535, inclusive).
// Don't track restart times for dart2js builds or web-server devices.
if (debuggingOptions.buildInfo.isDebug && deviceIsDebuggable) {
_usage.sendTiming('hot', 'web-incremental-restart', elapsed);
_analytics.send(Event.timing(
workflow: 'hot',
variableName: 'web-incremental-restart',
elapsedMilliseconds: elapsed.inMilliseconds,
));
final String sdkName = await device!.device!.sdkNameAndVersion;
HotEvent(
'restart',
Expand Down
18 changes: 2 additions & 16 deletions packages/flutter_tools/lib/src/linux/build_linux.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:unified_analytics/unified_analytics.dart';

import '../artifacts.dart';
import '../base/analyze_size.dart';
import '../base/common.dart';
Expand Down Expand Up @@ -157,13 +155,7 @@ Future<void> _runCmake(String buildModeName, Directory sourceDir, Directory buil
if (result != 0) {
throwToolExit('Unable to generate build files');
}
final Duration elapsedDuration = sw.elapsed;
globals.flutterUsage.sendTiming('build', 'cmake-linux', elapsedDuration);
globals.analytics.send(Event.timing(
workflow: 'build',
variableName: 'cmake-linux',
elapsedMilliseconds: elapsedDuration.inMilliseconds,
));
globals.flutterUsage.sendTiming('build', 'cmake-linux', Duration(milliseconds: sw.elapsedMilliseconds));
}

Future<void> _runBuild(Directory buildDir) async {
Expand Down Expand Up @@ -193,11 +185,5 @@ Future<void> _runBuild(Directory buildDir) async {
if (result != 0) {
throwToolExit('Build process failed');
}
final Duration elapsedDuration = sw.elapsed;
globals.flutterUsage.sendTiming('build', 'linux-ninja', elapsedDuration);
globals.analytics.send(Event.timing(
workflow: 'build',
variableName: 'linux-ninja',
elapsedMilliseconds: elapsedDuration.inMilliseconds,
));
globals.flutterUsage.sendTiming('build', 'linux-ninja', Duration(milliseconds: sw.elapsedMilliseconds));
}
10 changes: 1 addition & 9 deletions packages/flutter_tools/lib/src/macos/build_macos.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:unified_analytics/unified_analytics.dart';

import '../base/analyze_size.dart';
import '../base/common.dart';
import '../base/file_system.dart';
Expand Down Expand Up @@ -162,13 +160,7 @@ Future<void> buildMacOS({
throwToolExit('Build process failed');
}
await _writeCodeSizeAnalysis(buildInfo, sizeAnalyzer);
final Duration elapsedDuration = sw.elapsed;
globals.flutterUsage.sendTiming('build', 'xcode-macos', elapsedDuration);
globals.analytics.send(Event.timing(
workflow: 'build',
variableName: 'xcode-macos',
elapsedMilliseconds: elapsedDuration.inMilliseconds,
));
globals.flutterUsage.sendTiming('build', 'xcode-macos', Duration(milliseconds: sw.elapsedMilliseconds));
}

/// Performs a size analysis of the AOT snapshot and writes to an analysis file, if configured.
Expand Down
13 changes: 1 addition & 12 deletions packages/flutter_tools/lib/src/run_hot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -713,13 +713,7 @@ class HotRunner extends ResidentRunner {
restartTimer.elapsed.inMilliseconds);

// Send timing analytics.
final Duration elapsedDuration = restartTimer.elapsed;
globals.flutterUsage.sendTiming('hot', 'restart', elapsedDuration);
_analytics.send(Event.timing(
workflow: 'hot',
variableName: 'restart',
elapsedMilliseconds: elapsedDuration.inMilliseconds,
));
globals.flutterUsage.sendTiming('hot', 'restart', restartTimer.elapsed);

// Toggle the main dill name after successfully uploading.
_swap =! _swap;
Expand Down Expand Up @@ -1118,11 +1112,6 @@ class HotRunner extends ResidentRunner {
// Only report timings if we reloaded a single view without any errors.
if ((reassembleResult.reassembleViews.length == 1) && !reassembleResult.failedReassemble && shouldReportReloadTime) {
globals.flutterUsage.sendTiming('hot', 'reload', reloadDuration);
_analytics.send(Event.timing(
workflow: 'hot',
variableName: 'reload',
elapsedMilliseconds: reloadDuration.inMilliseconds,
));
}
return OperationResult(
reassembleResult.failedReassemble ? 1 : OperationResult.ok.code,
Expand Down
18 changes: 4 additions & 14 deletions packages/flutter_tools/lib/src/runner/flutter_command.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1634,26 +1634,16 @@ abstract class FlutterCommand extends Command<void> {
final String label = labels
.where((String? label) => label != null && !_isBlank(label))
.join('-');

// If the command provides its own end time, use it. Otherwise report
// the duration of the entire execution.
final Duration elapsedDuration = (commandResult.endTimeOverride ?? endTime).difference(startTime);
globals.flutterUsage.sendTiming(
'flutter',
name,
elapsedDuration,
// If the command provides its own end time, use it. Otherwise report
// the duration of the entire execution.
(commandResult.endTimeOverride ?? endTime).difference(startTime),
// Report in the form of `success-[parameter1-parameter2]`, all of which
// can be null if the command doesn't provide a FlutterCommandResult.
label: label == '' ? null : label,
);
analytics.send(Event.timing(
workflow: 'flutter',
variableName: name,
elapsedMilliseconds: elapsedDuration.inMilliseconds,
// Report in the form of `success-[parameter1-parameter2]`, all of which
// can be null if the command doesn't provide a FlutterCommandResult.
label: label == '' ? null : label,
));
}

/// Perform validation then call [runCommand] to execute the command.
Expand Down Expand Up @@ -1717,7 +1707,7 @@ Run 'flutter -h' (or 'flutter <command> -h') for available flutter commands and
processManager: globals.processManager,
platform: globals.platform,
usage: globals.flutterUsage,
analytics: analytics,
analytics: globals.analytics,
projectDir: project.directory,
generateDartPluginRegistry: true,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import 'package:args/args.dart';
import 'package:args/command_runner.dart';
import 'package:completion/completion.dart';
import 'package:file/file.dart';
import 'package:unified_analytics/unified_analytics.dart';

import '../artifacts.dart';
import '../base/common.dart';
Expand Down Expand Up @@ -330,11 +329,6 @@ class FlutterCommandRunner extends CommandRunner<void> {

if ((topLevelResults[FlutterGlobalOptions.kVersionFlag] as bool?) ?? false) {
globals.flutterUsage.sendCommand(FlutterGlobalOptions.kVersionFlag);
globals.analytics.send(Event.flutterCommandResult(
commandPath: 'version',
result: 'success',
commandHasTerminal: globals.stdio.hasTerminal,
));
final FlutterVersion version = globals.flutterVersion.fetchTagsAndGetVersion(
clock: globals.systemClock,
);
Expand Down
8 changes: 1 addition & 7 deletions packages/flutter_tools/lib/src/web/compile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,11 @@ class WebBuilder {
settings: buildSettingsString,
));

final Duration elapsedDuration = sw.elapsed;
_flutterUsage.sendTiming(
'build',
compilerConfig.isWasm ? 'dart2wasm' : 'dart2js',
elapsedDuration,
Duration(milliseconds: sw.elapsedMilliseconds),
);
_analytics.send(Event.timing(
workflow: 'build',
variableName: compilerConfig.isWasm ? 'dart2wasm' : 'dart2js',
elapsedMilliseconds: elapsedDuration.inMilliseconds,
));
}
}

Expand Down
18 changes: 2 additions & 16 deletions packages/flutter_tools/lib/src/windows/build_windows.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:unified_analytics/unified_analytics.dart';

import '../artifacts.dart';
import '../base/analyze_size.dart';
import '../base/common.dart';
Expand Down Expand Up @@ -204,13 +202,7 @@ Future<void> _runCmakeGeneration({
if (result != 0) {
throwToolExit('Unable to generate build files');
}
final Duration elapsedDuration = sw.elapsed;
globals.flutterUsage.sendTiming('build', 'windows-cmake-generation', elapsedDuration);
globals.analytics.send(Event.timing(
workflow: 'build',
variableName: 'windows-cmake-generation',
elapsedMilliseconds: elapsedDuration.inMilliseconds,
));
globals.flutterUsage.sendTiming('build', 'windows-cmake-generation', Duration(milliseconds: sw.elapsedMilliseconds));
}

Future<void> _runBuild(
Expand Down Expand Up @@ -261,13 +253,7 @@ Future<void> _runBuild(
if (result != 0) {
throwToolExit('Build process failed.');
}
final Duration elapsedDuration = sw.elapsed;
globals.flutterUsage.sendTiming('build', 'windows-cmake-build', elapsedDuration);
globals.analytics.send(Event.timing(
workflow: 'build',
variableName: 'windows-cmake-build',
elapsedMilliseconds: elapsedDuration.inMilliseconds,
));
globals.flutterUsage.sendTiming('build', 'windows-cmake-build', Duration(milliseconds: sw.elapsedMilliseconds));
}

/// Writes the generated CMake file with the configuration for the given build.
Expand Down
8 changes: 4 additions & 4 deletions packages/flutter_tools/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ dependencies:
http_multi_server: 3.2.1
convert: 3.1.1
async: 2.11.0
unified_analytics: 5.6.0
unified_analytics: 5.5.0

cli_config: 0.1.2
graphs: 2.3.1
Expand All @@ -69,7 +69,7 @@ dependencies:
analyzer: 6.3.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
boolean_selector: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
built_collection: 5.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
built_value: 8.8.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
built_value: 8.7.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
clock: 1.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
csslib: 1.0.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
dap: 1.1.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
Expand All @@ -91,7 +91,7 @@ dependencies:
source_map_stack_trace: 2.1.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
source_maps: 0.10.12 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
source_span: 1.10.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
sse: 4.1.4 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
sse: 4.1.3 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
string_scanner: 1.2.0 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
sync_http: 0.3.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
term_glyph: 1.2.1 # THIS LINE IS AUTOGENERATED - TO UPDATE USE "flutter update-packages --force-upgrade"
Expand All @@ -115,4 +115,4 @@ dartdoc:
# Exclude this package from the hosted API docs.
nodoc: true

# PUBSPEC CHECKSUM: b1a1
# PUBSPEC CHECKSUM: e59e
Loading

0 comments on commit 6c4475e

Please sign in to comment.