Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import 'package:devtools_app_shared/ui.dart';
import 'package:dtd/dtd.dart';
import 'package:material_ui/material_ui.dart';

import '../../shared/analytics/analytics.dart' as ga;
import '../../shared/analytics/constants.dart' as gac;
import '../../shared/development_helpers.dart';
import '../../shared/framework/screen.dart';
import '../../shared/globals.dart';
Expand All @@ -31,9 +33,20 @@ class DTDToolsScreen extends Screen {
Widget buildScreenBody(BuildContext _) => const DTDToolsScreenBody();
}

class DTDToolsScreenBody extends StatelessWidget {
class DTDToolsScreenBody extends StatefulWidget {
const DTDToolsScreenBody({super.key});

@override
State<DTDToolsScreenBody> createState() => _DTDToolsScreenBodyState();
}

class _DTDToolsScreenBodyState extends State<DTDToolsScreenBody> {
@override
void initState() {
super.initState();
ga.screen(gac.dtdTools);
}

@override
Widget build(BuildContext context) {
final controller = screenControllers.lookup<DTDToolsController>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ import 'isolate_statistics_view_controller.dart';
/// isolate.
class IsolateStatisticsView extends VMDeveloperView {
const IsolateStatisticsView()
: super(title: 'Isolates', icon: Icons.bar_chart);
: super(
title: 'Isolates',
icon: Icons.bar_chart,
gaEvent: gac.VmToolsEvents.isolateStatistics,
);

@override
bool get showIsolateSelector => true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ import 'object_viewport.dart';
/// information about objects in the Dart VM.
class ObjectInspectorView extends VMDeveloperView {
ObjectInspectorView()
: super(title: 'Objects', icon: Icons.data_object_outlined);
: super(
title: 'Objects',
icon: Icons.data_object_outlined,
gaEvent: gac.VmToolsEvents.objectInspector,
);

@override
bool get showIsolateSelector => true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ import 'process_memory_view_controller.dart';
/// process's memory footprint.
class VMProcessMemoryView extends VMDeveloperView {
const VMProcessMemoryView()
: super(title: 'Process Memory', icon: Icons.memory);
: super(
title: 'Process Memory',
icon: Icons.memory,
gaEvent: gac.VmToolsEvents.processMemory,
);

@override
Widget build(BuildContext context) => VMProcessMemoryViewBody();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,11 @@ class MicrotaskStackTraceView extends StatelessWidget {

class QueuedMicrotasksView extends VMDeveloperView {
const QueuedMicrotasksView()
: super(title: 'Queued Microtasks', icon: Icons.pending_actions);
: super(
title: 'Queued Microtasks',
icon: Icons.pending_actions,
gaEvent: gac.VmToolsEvents.queuedMicrotasks,
);

@override
bool get showIsolateSelector => true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import 'package:flutter/foundation.dart';
import 'package:material_ui/material_ui.dart';

import '../../service/vm_flags.dart' as vm_flags;
import '../../shared/analytics/analytics.dart' as ga;
import '../../shared/analytics/constants.dart' as gac;
import '../../shared/framework/screen.dart';
import '../../shared/globals.dart';
import 'isolate_statistics/isolate_statistics_view.dart';
Expand All @@ -17,13 +19,20 @@ import 'vm_developer_tools_controller.dart';
import 'vm_statistics/vm_statistics_view.dart';

abstract class VMDeveloperView {
const VMDeveloperView({required this.title, required this.icon});
const VMDeveloperView({
required this.title,
required this.icon,
required this.gaEvent,
});

/// The user-facing name of the page.
final String title;

final IconData icon;

/// The analytics id sent when this page is selected.
final gac.VmToolsEvents gaEvent;

/// Whether this view should display the isolate selector in the status
/// line.
///
Expand All @@ -46,7 +55,7 @@ class VMDeveloperToolsScreen extends Screen {
const VMDeveloperToolsScreenBody();
}

class VMDeveloperToolsScreenBody extends StatelessWidget {
class VMDeveloperToolsScreenBody extends StatefulWidget {
const VMDeveloperToolsScreenBody({super.key});

// The value of the `--profile-microtasks` VM flag cannot be modified once
Expand All @@ -66,9 +75,40 @@ class VMDeveloperToolsScreenBody extends StatelessWidget {
if (showQueuedMicrotasks) const QueuedMicrotasksView(),
];

@override
State<VMDeveloperToolsScreenBody> createState() =>
_VMDeveloperToolsScreenBodyState();
}

class _VMDeveloperToolsScreenBodyState
extends State<VMDeveloperToolsScreenBody> {
late final VMDeveloperToolsController controller;

List<VMDeveloperView> get views => VMDeveloperToolsScreenBody.views;

@override
void initState() {
super.initState();
ga.screen(gac.vmTools);
controller = screenControllers.lookup<VMDeveloperToolsController>();
// Record the view that is visible when the screen opens, as tabbed views
// do (see `AnalyticsTabbedView`).
ga.select(
gac.vmTools,
views[controller.selectedIndex.value].gaEvent.name,
nonInteraction: true,
);
}

void _selectView(int index) {
if (index != controller.selectedIndex.value) {
ga.select(gac.vmTools, views[index].gaEvent.name);
}
controller.selectIndex(index);
}

@override
Widget build(BuildContext context) {
final controller = screenControllers.lookup<VMDeveloperToolsController>();
return ValueListenableBuilder<int>(
valueListenable: controller.selectedIndex,
builder: (context, selectedIndex, _) {
Expand All @@ -78,7 +118,7 @@ class VMDeveloperToolsScreenBody extends StatelessWidget {
NavigationRail(
selectedIndex: selectedIndex,
labelType: NavigationRailLabelType.all,
onDestinationSelected: controller.selectIndex,
onDestinationSelected: _selectView,
destinations: [
for (final view in views)
NavigationRailDestination(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ import '../vm_service_private_extensions.dart';
import 'vm_statistics_view_controller.dart';

class VMStatisticsView extends VMDeveloperView {
const VMStatisticsView() : super(title: 'VM', icon: Icons.devices);
const VMStatisticsView()
: super(
title: 'VM',
icon: Icons.devices,
gaEvent: gac.VmToolsEvents.vmStatistics,
);

@override
Widget build(BuildContext context) => VMStatisticsViewBody();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ part 'constants/_memory_constants.dart';
part 'constants/_network_constants.dart';
part 'constants/_performance_constants.dart';
part 'constants/_property_editor_sidebar_constants.dart';
part 'constants/_vm_tools_constants.dart';

// Type of events (event_category):
const screenViewEvent = 'screen'; // Active screen (tab selected).
Expand All @@ -41,6 +42,7 @@ final debugger = ScreenMetaData.debugger.id;
final logging = ScreenMetaData.logging.id;
final appSize = ScreenMetaData.appSize.id;
final vmTools = ScreenMetaData.vmTools.id;
final dtdTools = ScreenMetaData.dtdTools.id;
const console = 'console';
final simple = ScreenMetaData.simple.id;
final deeplink = ScreenMetaData.deepLinks.id;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright 2026 The Flutter Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd.

part of '../constants.dart';

/// Analytics ids for the views in the VM Tools screen's navigation rail.
enum VmToolsEvents {
vmStatistics,
isolateStatistics,
objectInspector,
processMemory,
queuedMicrotasks,
}
Loading