Skip to content

Commit 198cf64

Browse files
authored
Fixes to missing or stale dimensions in DevTools analytics (#9624)
1 parent 04b74a8 commit 198cf64

1 file changed

Lines changed: 18 additions & 17 deletions

File tree

packages/devtools_app/lib/src/shared/analytics/_analytics_web.dart

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -746,16 +746,10 @@ set flutterClientId(String newFlutterClientId) {
746746
_flutterClientId = newFlutterClientId;
747747
}
748748

749-
bool _computingDimensions = false;
750-
bool _analyticsComputed = false;
751-
752-
bool _computingUserApplicationDimensions = false;
753-
bool _userApplicationDimensionsComputed = false;
749+
Completer<void>? _computingDimensionsCompleter;
754750

755751
// Computes the running application.
756752
void _computeUserApplicationCustomGTagData() {
757-
if (_userApplicationDimensionsComputed) return;
758-
759753
final connectedApp = serviceConnection.serviceManager.connectedApp!;
760754
assert(connectedApp.isFlutterAppNow != null);
761755
assert(connectedApp.isDartWebAppNow != null);
@@ -779,8 +773,6 @@ void _computeUserApplicationCustomGTagData() {
779773
userBuildType = connectedApp.isProfileBuildNow!
780774
? buildTypeProfile
781775
: buildTypeDebug;
782-
783-
_analyticsComputed = true;
784776
}
785777

786778
@JS('getDevToolsPropertyID')
@@ -837,22 +829,31 @@ Future<void> computeFlutterClientId() async {
837829
}
838830

839831
Future<void> setupDimensions() async {
840-
if (!_analyticsComputed && !_computingDimensions) {
841-
_computingDimensions = true;
832+
if (_computingDimensionsCompleter != null) {
833+
return _computingDimensionsCompleter!.future;
834+
}
835+
836+
_computingDimensionsCompleter = Completer<void>();
837+
try {
842838
computeDevToolsCustomGTagsData();
843839
computeDevToolsQueryParams();
844840
await computeFlutterClientId();
845-
_analyticsComputed = true;
841+
} catch (e, st) {
842+
_log.warning('Failed to compute dimensions', e, st);
843+
} finally {
844+
_computingDimensionsCompleter!.complete();
846845
}
847846
}
848847

849848
void setupUserApplicationDimensions() {
850-
if (serviceConnection.serviceManager.connectedApp != null &&
851-
!_userApplicationDimensionsComputed &&
852-
!_computingUserApplicationDimensions) {
853-
_computingUserApplicationDimensions = true;
849+
if (serviceConnection.serviceManager.connectedApp == null) {
850+
return;
851+
}
852+
853+
try {
854854
_computeUserApplicationCustomGTagData();
855-
_userApplicationDimensionsComputed = true;
855+
} catch (e, st) {
856+
_log.warning('Failed to compute user application dimensions', e, st);
856857
}
857858
}
858859

0 commit comments

Comments
 (0)