Skip to content

Commit

Permalink
Merge branch 'flutter:master' into 8216-run-utility
Browse files Browse the repository at this point in the history
  • Loading branch information
mossmana authored Jan 10, 2025
2 parents 769bf78 + 07e79a4 commit 5b162b7
Show file tree
Hide file tree
Showing 23 changed files with 394 additions and 68 deletions.
2 changes: 1 addition & 1 deletion packages/devtools_app/lib/devtools.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
/// Note: a regexp in the `dt update-version' command logic matches the constant
/// declaration `const version =`. If you change the declaration you must also
/// modify the regex in the `dt update-version' command logic.
const version = '2.42.0';
const version = '2.43.0-dev.0';
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ import 'package:logging/logging.dart';
import 'package:vm_service/vm_service.dart';

import '../../service/service_extensions.dart' as extensions;
import '../../shared/analytics/analytics.dart' as ga;
import '../../shared/analytics/constants.dart' as gac;
import '../../shared/analytics/metrics.dart';
import '../../shared/console/eval/inspector_tree.dart';
import '../../shared/console/primitives/simple_items.dart';
import '../../shared/diagnostics/diagnostics_node.dart';
Expand Down Expand Up @@ -666,6 +669,13 @@ class InspectorController extends DisposableController
subtreeRoot = newSelection;

applyNewSelection(newSelection, detailsSelection, true);

// Send an event that a widget was selected on the device.
ga.select(
gac.inspector,
gac.onDeviceSelection,
screenMetricsProvider: () => InspectorScreenMetrics.legacy(),
);
} catch (error, st) {
if (selectionGroups.next == group) {
_log.shout(error, error, st);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import '../../service/service_extension_widgets.dart';
import '../../service/service_extensions.dart' as extensions;
import '../../shared/analytics/analytics.dart' as ga;
import '../../shared/analytics/constants.dart' as gac;
import '../../shared/analytics/metrics.dart';
import '../../shared/console/eval/inspector_tree.dart';
import '../../shared/globals.dart';
import '../../shared/managers/error_badge_manager.dart';
Expand Down Expand Up @@ -265,7 +266,11 @@ class InspectorScreenBodyState extends State<InspectorScreenBody>
}

void _refreshInspector() {
ga.select(gac.inspector, gac.refresh);
ga.select(
gac.inspector,
gac.refresh,
screenMetricsProvider: () => InspectorScreenMetrics.legacy(),
);
unawaited(
blockWhileInProgress(() async {
// If the user is force refreshing the inspector before the first load has
Expand All @@ -275,7 +280,11 @@ class InspectorScreenBodyState extends State<InspectorScreenBody>
// We do not want to complete this timing operation because the force
// refresh will skew the results.
ga.cancelTimingOperation(InspectorScreen.id, gac.pageReady);
ga.select(gac.inspector, gac.refreshEmptyTree);
ga.select(
gac.inspector,
gac.refreshEmptyTree,
screenMetricsProvider: () => InspectorScreenMetrics.legacy(),
);
controller.firstInspectorTreeLoadCompleted = true;
}
await controller.onForceRefresh();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,11 @@ class InspectorTreeController extends DisposableController

void onSelectNode(InspectorTreeNode? node) {
selection = node;
ga.select(gac.inspector, gac.treeNodeSelection);
ga.select(
gac.inspector,
gac.treeNodeSelection,
screenMetricsProvider: () => InspectorScreenMetrics.legacy(),
);
expandPath(node);
}

Expand Down Expand Up @@ -1002,7 +1006,14 @@ class _InspectorTreeState extends State<InspectorTree>
if (!controller.firstInspectorTreeLoadCompleted && widget.isSummaryTree) {
final screenId = widget.screenId;
if (screenId != null) {
ga.timeEnd(screenId, gac.pageReady);
ga.timeEnd(
screenId,
gac.pageReady,
screenMetricsProvider:
() => InspectorScreenMetrics.legacy(
rowCount: treeControllerLocal.numRows,
),
);
unawaited(
serviceConnection.sendDwdsEvent(
screen: screenId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class FlutterInspectorSettingsDialog extends StatelessWidget {
description:
'Disable the redesigned Flutter inspector. Please know that '
'the legacy inspector may be removed in a future release.',
gaItem: gac.inspectorV2Enabled,
gaItem: gac.inspectorV2Disabled,
),
),
const SizedBox(height: largeSpacing),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import 'package:vm_service/vm_service.dart';
import '../../service/service_extensions.dart' as extensions;
import '../../shared/analytics/analytics.dart' as ga;
import '../../shared/analytics/constants.dart' as gac;
import '../../shared/analytics/metrics.dart';
import '../../shared/console/eval/inspector_tree_v2.dart';
import '../../shared/console/primitives/simple_items.dart';
import '../../shared/diagnostics/diagnostics_node.dart';
Expand Down Expand Up @@ -392,7 +393,11 @@ class InspectorController extends DisposableController
// We do not want to complete this timing operation because the force
// refresh will skew the results.
ga.cancelTimingOperation(InspectorScreen.id, gac.pageReady);
ga.select(gac.inspector, gac.refreshEmptyTree);
ga.select(
gac.inspector,
gac.refreshEmptyTree,
screenMetricsProvider: () => InspectorScreenMetrics.v2(),
);
firstInspectorTreeLoadCompleted = true;
}
await onForceRefresh();
Expand Down Expand Up @@ -766,6 +771,13 @@ class InspectorController extends DisposableController
selectedNode: newSelection,
group: group,
);

// Send an event that a widget was selected on the device.
ga.select(
gac.inspector,
gac.onDeviceSelection,
screenMetricsProvider: () => InspectorScreenMetrics.v2(),
);
} catch (error, st) {
if (selectionGroups.next == group) {
_log.shout(error, error, st);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:flutter/material.dart';

import '../../shared/analytics/analytics.dart' as ga;
import '../../shared/analytics/constants.dart' as gac;
import '../../shared/analytics/metrics.dart';
import '../../shared/console/eval/inspector_tree_v2.dart';
import '../../shared/globals.dart';
import '../../shared/managers/banner_messages.dart';
Expand Down Expand Up @@ -219,7 +220,11 @@ class InspectorScreenBodyState extends State<InspectorScreenBody>
}

void _refreshInspector() {
ga.select(gac.inspector, gac.refresh);
ga.select(
gac.inspector,
gac.refresh,
screenMetricsProvider: () => InspectorScreenMetrics.v2(),
);
unawaited(
blockWhileInProgress(() async {
await controller.refreshInspector();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,11 @@ class InspectorTreeController extends DisposableController

void onSelectNode(InspectorTreeNode? node) {
setSelectedNode(node, notifyFlutterInspector: true);
ga.select(gac.inspector, gac.treeNodeSelection);
ga.select(
gac.inspector,
gac.treeNodeSelection,
screenMetricsProvider: () => InspectorScreenMetrics.v2(),
);
final diagnostic = node?.diagnostic;
if (diagnostic != null && diagnostic.groupIsHidden) {
diagnostic.hideableGroupLeader?.toggleHiddenGroup();
Expand Down Expand Up @@ -1136,7 +1140,12 @@ class _InspectorTreeState extends State<InspectorTree>
if (!controller.firstInspectorTreeLoadCompleted) {
final screenId = widget.screenId;
if (screenId != null) {
ga.timeEnd(screenId, gac.pageReady);
ga.timeEnd(
screenId,
gac.pageReady,
screenMetricsProvider:
() => InspectorScreenMetrics.v2(rowCount: rows.length),
);
unawaited(
serviceConnection.sendDwdsEvent(
screen: screenId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import 'dart:async';

import 'package:logging/logging.dart';
import 'package:stack_trace/stack_trace.dart' as stack_trace;

import 'analytics_common.dart';

Expand Down Expand Up @@ -94,7 +95,7 @@ void impression(

void reportError(
String errorMessage, {
List<String> stackTraceSubstrings = const <String>[],
stack_trace.Trace? stackTrace,
bool fatal = false,
}) {}

Expand Down
44 changes: 22 additions & 22 deletions packages/devtools_app/lib/src/shared/analytics/_analytics_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import 'dart:js_interop';
import 'package:devtools_app_shared/ui.dart';
import 'package:flutter/foundation.dart';
import 'package:logging/logging.dart';
import 'package:stack_trace/stack_trace.dart' as stack_trace;
import 'package:unified_analytics/unified_analytics.dart' as ua;
import 'package:web/web.dart';

import '../globals.dart';
import '../managers/dtd_manager_extensions.dart';
import '../primitives/query_parameters.dart';
import '../primitives/utils.dart';
import '../server/server.dart' as server;
import '../utils/utils.dart';
import 'analytics_common.dart';
Expand Down Expand Up @@ -67,6 +67,8 @@ extension type GtagEventDevTools._(JSObject _) implements GtagEvent {

// NOTE: Do not reorder any of these. Order here must match the order in the
// Google Analytics console.
// IMPORTANT! Only string and int values are supported. All other value
// types will be ignored in GA4.
String? user_app, // dimension1 (flutter or web)
String? user_build, // dimension2 (debug or profile)
String? user_platform, // dimension3 (android/ios/fuchsia/linux/mac/windows)
Expand Down Expand Up @@ -112,7 +114,7 @@ extension type GtagEventDevTools._(JSObject _) implements GtagEvent {
String? android_app_id, //metric13
String? ios_bundle_id, //metric14
// Inspector screen metrics. See [InspectorScreenMetrics].
bool? is_v2_inspector, // metric15
String? is_v2_inspector, // metric15
});

factory GtagEventDevTools._create({
Expand Down Expand Up @@ -207,7 +209,9 @@ extension type GtagEventDevTools._(JSObject _) implements GtagEvent {
: null,
// [InspectorScreenMetrics]
is_v2_inspector:
screenMetrics is InspectorScreenMetrics ? screenMetrics.isV2 : null,
screenMetrics is InspectorScreenMetrics
? screenMetrics.isV2.toString()
: null,
);
}

Expand Down Expand Up @@ -243,7 +247,7 @@ extension type GtagEventDevTools._(JSObject _) implements GtagEvent {
external int? get inspector_tree_controller_id;
external String? get android_app_id;
external String? get ios_bundle_id;
external bool? get is_v2_inspector;
external String? get is_v2_inspector;
}

extension type GtagExceptionDevTools._(JSObject _) implements GtagException {
Expand All @@ -254,6 +258,8 @@ extension type GtagExceptionDevTools._(JSObject _) implements GtagException {

// NOTE: Do not reorder any of these. Order here must match the order in the
// Google Analytics console.
// IMPORTANT! Only string and int values are supported. All other value
// types will be ignored in GA4.
String? user_app, // dimension1 (flutter or web)
String? user_build, // dimension2 (debug or profile)
String? user_platform, // dimension3 (android or ios)
Expand Down Expand Up @@ -298,7 +304,7 @@ extension type GtagExceptionDevTools._(JSObject _) implements GtagException {
String? android_app_id, //metric13
String? ios_bundle_id, //metric14
// Inspector screen metrics. See [InspectorScreenMetrics].
bool? is_v2_inspector, // metric15
String? is_v2_inspector, // metric15
});

factory GtagExceptionDevTools._create(
Expand Down Expand Up @@ -385,7 +391,9 @@ extension type GtagExceptionDevTools._(JSObject _) implements GtagException {
: null,
// [InspectorScreenMetrics]
is_v2_inspector:
screenMetrics is InspectorScreenMetrics ? screenMetrics.isV2 : null,
screenMetrics is InspectorScreenMetrics
? screenMetrics.isV2.toString()
: null,
);
}

Expand Down Expand Up @@ -673,7 +681,7 @@ String? _lastGaError;
/// chunks to GA4 through unified_analytics.
void reportError(
String errorMessage, {
List<String> stackTraceSubstrings = const <String>[],
stack_trace.Trace? stackTrace,
bool fatal = false,
}) {
// Don't keep recording same last error.
Expand All @@ -682,14 +690,14 @@ void reportError(

final gTagExceptionWithStackTrace = GtagExceptionDevTools._create(
// Include the stack trace in the message for legacy analytics.
'$errorMessage\n${stackTraceSubstrings.join()}',
'$errorMessage\n${stackTrace?.toString() ?? ''}',
fatal: fatal,
);
GTag.exception(gaExceptionProvider: () => gTagExceptionWithStackTrace);

final uaEvent = _uaEventFromGtagException(
GtagExceptionDevTools._create(errorMessage, fatal: fatal),
stackTraceSubstrings: stackTraceSubstrings,
stackTrace: stackTrace,
);
unawaited(dtdManager.sendAnalyticsEvent(uaEvent));
}
Expand Down Expand Up @@ -950,25 +958,17 @@ ua.Event _uaEventFromGtagEvent(GtagEventDevTools gtagEvent) {

ua.Event _uaEventFromGtagException(
GtagExceptionDevTools gtagException, {
List<String> stackTraceSubstrings = const <String>[],
stack_trace.Trace? stackTrace,
}) {
final stackTraceAsMap = createStackTraceForAnalytics(stackTrace);

// Any data entries that have a null value will be removed from the event data
// in the [ua.Event.exception] constructor.
return ua.Event.exception(
exception: gtagException.description ?? 'unknown exception',
data: {
'fatal': gtagException.fatal,
// Each stack trace substring of length [ga4ParamValueCharacterLimit]
// contains information for ~1 stack frame, so including 8 chunks should
// give us enough information to understand the source of the exception.
'stackTraceChunk0': stackTraceSubstrings.safeGet(0),
'stackTraceChunk1': stackTraceSubstrings.safeGet(1),
'stackTraceChunk2': stackTraceSubstrings.safeGet(2),
'stackTraceChunk3': stackTraceSubstrings.safeGet(3),
'stackTraceChunk4': stackTraceSubstrings.safeGet(4),
'stackTraceChunk5': stackTraceSubstrings.safeGet(5),
'stackTraceChunk6': stackTraceSubstrings.safeGet(6),
'stackTraceChunk7': stackTraceSubstrings.safeGet(7),
...stackTraceAsMap,
'userApp': gtagException.user_app,
'userBuild': gtagException.user_build,
'userPlatform': gtagException.user_platform,
Expand Down Expand Up @@ -1026,7 +1026,7 @@ final class _DevToolsEventMetrics extends ua.CustomMetrics {
final int? rootSetCount;
final int? rowCount;
final int? inspectorTreeControllerId;
final bool? isV2Inspector;
final String? isV2Inspector;

// [DeepLinkScreenMetrics]
final String? androidAppId;
Expand Down
Loading

0 comments on commit 5b162b7

Please sign in to comment.