Skip to content

Commit af04ddf

Browse files
Initialize analytics metrics before framework initialization (#9092)
1 parent fb3986f commit af04ddf

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

packages/devtools_app/lib/initialization.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file or at https://developers.google.com/open-source/licenses/bsd.
44

5+
import 'dart:async';
6+
57
import 'package:devtools_app_shared/utils.dart';
68
import 'package:flutter/material.dart';
79
import 'package:flutter_web_plugins/url_strategy.dart';

packages/devtools_app/lib/src/app.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ import 'screens/provider/provider_screen.dart';
4545
import 'screens/vm_developer/vm_developer_tools_controller.dart';
4646
import 'screens/vm_developer/vm_developer_tools_screen.dart';
4747
import 'service/service_extension_widgets.dart';
48-
import 'shared/analytics/analytics.dart' as ga;
4948
import 'shared/analytics/analytics_controller.dart';
5049
import 'shared/feature_flags.dart';
5150
import 'shared/framework/framework_controller.dart';
@@ -168,8 +167,6 @@ class DevToolsAppState extends State<DevToolsApp> with AutoDisposeMixin {
168167
// unawaited(BrowserContextMenu.disableContextMenu());
169168
// }
170169

171-
unawaited(ga.setupDimensions());
172-
173170
void clearRoutesAndSetState() {
174171
setState(() {
175172
_clearCachedRoutes();

packages/devtools_app/lib/src/framework/framework_core.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import '../extensions/extension_service.dart';
2020
import '../screens/debugger/breakpoint_manager.dart';
2121
import '../service/service_manager.dart';
2222
import '../service/vm_service_wrapper.dart';
23+
import '../shared/analytics/analytics.dart' as ga;
2324
import '../shared/config_specific/framework_initialize/framework_initialize.dart';
2425
import '../shared/console/eval/eval_service.dart';
2526
import '../shared/feature_flags.dart';
@@ -56,6 +57,17 @@ abstract class FrameworkCore {
5657

5758
await initializePlatform();
5859

60+
// Initialize analytics metrics before initializing the rest of the
61+
// framework. It is important that this method call is here, after the
62+
// `storage` global variable has been set by the `initializePlatform` call,
63+
// since the analytics dimensions reference the `storage` global. We
64+
// initialize this now so that any analytics events sent from here on our
65+
// include the expected metadata.
66+
// TODO(kenz): consider making the dimensions that need initialization
67+
// `late` so that they can be initialized on first access rather than
68+
// manually.
69+
await ga.setupDimensions();
70+
5971
// Print DevTools info at startup.
6072
_log.info(
6173
'Version: $devToolsVersion, Renderer: ${kIsWasm ? 'skwasm' : 'canvaskit'}',

0 commit comments

Comments
 (0)