Delete files
diff --git a/packages/flutter_tools/lib/src/reporting/custom_dimensions.dart b/packages/flutter_tools/lib/src/reporting/custom_dimensions.dart deleted file mode 100644 index d6a67de..0000000 --- a/packages/flutter_tools/lib/src/reporting/custom_dimensions.dart +++ /dev/null
@@ -1,525 +0,0 @@ -// Copyright 2014 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -part of 'reporting.dart'; - -/// The collection of custom dimensions understood by the analytics backend. -/// When adding to this list, first ensure that the custom dimension is -/// defined in the backend, or will be defined shortly after the relevant PR -/// lands. -@immutable -class CustomDimensions { - const CustomDimensions({ - this.sessionHostOsDetails, - this.sessionChannelName, - this.commandRunIsEmulator, - this.commandRunTargetName, - this.hotEventReason, - this.hotEventFinalLibraryCount, - this.hotEventSyncedLibraryCount, - this.hotEventSyncedClassesCount, - this.hotEventSyncedProceduresCount, - this.hotEventSyncedBytes, - this.hotEventInvalidatedSourcesCount, - this.hotEventTransferTimeInMs, - this.hotEventOverallTimeInMs, - this.commandRunProjectType, - this.commandRunProjectHostLanguage, - this.commandCreateAndroidLanguage, - this.commandCreateIosLanguage, - this.commandRunProjectModule, - this.commandCreateProjectType, - this.commandPackagesNumberPlugins, - this.commandPackagesProjectModule, - this.commandRunTargetOsVersion, - this.commandRunModeName, - this.commandBuildBundleTargetPlatform, - this.commandBuildBundleIsModule, - this.commandResult, - this.hotEventTargetPlatform, - this.hotEventSdkName, - this.hotEventEmulator, - this.hotEventFullRestart, - this.commandHasTerminal, - this.enabledFlutterFeatures, - this.localTime, - this.commandBuildAarTargetPlatform, - this.commandBuildAarProjectType, - this.buildEventCommand, - this.buildEventSettings, - this.commandBuildApkTargetPlatform, - this.commandBuildApkBuildMode, - this.commandBuildApkSplitPerAbi, - this.commandBuildAppBundleTargetPlatform, - this.commandBuildAppBundleBuildMode, - this.buildEventError, - this.commandResultEventMaxRss, - this.commandRunAndroidEmbeddingVersion, - this.commandPackagesAndroidEmbeddingVersion, - this.hotEventCompileTimeInMs, - this.hotEventFindInvalidatedTimeInMs, - this.hotEventScannedSourcesCount, - this.hotEventReassembleTimeInMs, - this.hotEventReloadVMTimeInMs, - this.commandRunEnableImpeller, - this.commandRunIOSInterfaceType, - this.commandRunIsTest, - }); - - final String? sessionHostOsDetails; // cd1 - final String? sessionChannelName; // cd2 - final bool? commandRunIsEmulator; // cd3 - final String? commandRunTargetName; // cd4 - final String? hotEventReason; // cd5 - final int? hotEventFinalLibraryCount; // cd6 - final int? hotEventSyncedLibraryCount; // cd7 - final int? hotEventSyncedClassesCount; // cd8 - final int? hotEventSyncedProceduresCount; // cd9 - final int? hotEventSyncedBytes; // cd10 - final int? hotEventInvalidatedSourcesCount; // cd11 - final int? hotEventTransferTimeInMs; // cd12 - final int? hotEventOverallTimeInMs; // cd13 - final String? commandRunProjectType; // cd14 - final String? commandRunProjectHostLanguage; // cd15 - final String? commandCreateAndroidLanguage; // cd16 - final String? commandCreateIosLanguage; // cd17 - final bool? commandRunProjectModule; // cd18 - final String? commandCreateProjectType; // cd19 - final int? commandPackagesNumberPlugins; // cd20 - final bool? commandPackagesProjectModule; // cd21 - final String? commandRunTargetOsVersion; // cd22 - final String? commandRunModeName; // cd23 - final String? commandBuildBundleTargetPlatform; // cd24 - final bool? commandBuildBundleIsModule; // cd25 - final String? commandResult; // cd26 - final String? hotEventTargetPlatform; // cd27 - final String? hotEventSdkName; // cd28 - final bool? hotEventEmulator; // cd29 - final bool? hotEventFullRestart; // cd30 - final bool? commandHasTerminal; // cd31 - final String? enabledFlutterFeatures; // cd32 - final String? localTime; // cd33 - final String? commandBuildAarTargetPlatform; // cd34 - final String? commandBuildAarProjectType; // cd35 - final String? buildEventCommand; // cd36 - final String? buildEventSettings; // cd37 - final String? commandBuildApkTargetPlatform; // cd38 - final String? commandBuildApkBuildMode; // cd39 - final bool? commandBuildApkSplitPerAbi; // cd40 - final String? commandBuildAppBundleTargetPlatform; // cd41 - final String? commandBuildAppBundleBuildMode; // cd42 - final String? buildEventError; // cd43 - final int? commandResultEventMaxRss; // cd44 - final String? commandRunAndroidEmbeddingVersion; // cd45 - final String? commandPackagesAndroidEmbeddingVersion; // cd46 - // cd48 was fastReassemble but that feature was removed - final int? hotEventCompileTimeInMs; // cd51 - final int? hotEventFindInvalidatedTimeInMs; // cd52 - final int? hotEventScannedSourcesCount; // cd53 - final int? hotEventReassembleTimeInMs; // cd54 - final int? hotEventReloadVMTimeInMs; // cd55 - final bool? commandRunEnableImpeller; // cd56 - final String? commandRunIOSInterfaceType; // cd57 - final bool? commandRunIsTest; // cd58 - - /// Convert to a map that will be used to upload to the analytics backend. - Map<String, String> toMap() => <String, String>{ - if (sessionHostOsDetails != null) - CustomDimensionsEnum.sessionHostOsDetails.cdKey: sessionHostOsDetails.toString(), - if (sessionChannelName != null) - CustomDimensionsEnum.sessionChannelName.cdKey: sessionChannelName.toString(), - if (commandRunIsEmulator != null) - CustomDimensionsEnum.commandRunIsEmulator.cdKey: commandRunIsEmulator.toString(), - if (commandRunTargetName != null) - CustomDimensionsEnum.commandRunTargetName.cdKey: commandRunTargetName.toString(), - if (hotEventReason != null) - CustomDimensionsEnum.hotEventReason.cdKey: hotEventReason.toString(), - if (hotEventFinalLibraryCount != null) - CustomDimensionsEnum.hotEventFinalLibraryCount.cdKey: hotEventFinalLibraryCount.toString(), - if (hotEventSyncedLibraryCount != null) - CustomDimensionsEnum.hotEventSyncedLibraryCount.cdKey: hotEventSyncedLibraryCount.toString(), - if (hotEventSyncedClassesCount != null) - CustomDimensionsEnum.hotEventSyncedClassesCount.cdKey: hotEventSyncedClassesCount.toString(), - if (hotEventSyncedProceduresCount != null) - CustomDimensionsEnum.hotEventSyncedProceduresCount.cdKey: hotEventSyncedProceduresCount - .toString(), - if (hotEventSyncedBytes != null) - CustomDimensionsEnum.hotEventSyncedBytes.cdKey: hotEventSyncedBytes.toString(), - if (hotEventInvalidatedSourcesCount != null) - CustomDimensionsEnum.hotEventInvalidatedSourcesCount.cdKey: hotEventInvalidatedSourcesCount - .toString(), - if (hotEventTransferTimeInMs != null) - CustomDimensionsEnum.hotEventTransferTimeInMs.cdKey: hotEventTransferTimeInMs.toString(), - if (hotEventOverallTimeInMs != null) - CustomDimensionsEnum.hotEventOverallTimeInMs.cdKey: hotEventOverallTimeInMs.toString(), - if (commandRunProjectType != null) - CustomDimensionsEnum.commandRunProjectType.cdKey: commandRunProjectType.toString(), - if (commandRunProjectHostLanguage != null) - CustomDimensionsEnum.commandRunProjectHostLanguage.cdKey: commandRunProjectHostLanguage - .toString(), - if (commandCreateAndroidLanguage != null) - CustomDimensionsEnum.commandCreateAndroidLanguage.cdKey: commandCreateAndroidLanguage - .toString(), - if (commandCreateIosLanguage != null) - CustomDimensionsEnum.commandCreateIosLanguage.cdKey: commandCreateIosLanguage.toString(), - if (commandRunProjectModule != null) - CustomDimensionsEnum.commandRunProjectModule.cdKey: commandRunProjectModule.toString(), - if (commandCreateProjectType != null) - CustomDimensionsEnum.commandCreateProjectType.cdKey: commandCreateProjectType.toString(), - if (commandPackagesNumberPlugins != null) - CustomDimensionsEnum.commandPackagesNumberPlugins.cdKey: commandPackagesNumberPlugins - .toString(), - if (commandPackagesProjectModule != null) - CustomDimensionsEnum.commandPackagesProjectModule.cdKey: commandPackagesProjectModule - .toString(), - if (commandRunTargetOsVersion != null) - CustomDimensionsEnum.commandRunTargetOsVersion.cdKey: commandRunTargetOsVersion.toString(), - if (commandRunModeName != null) - CustomDimensionsEnum.commandRunModeName.cdKey: commandRunModeName.toString(), - if (commandBuildBundleTargetPlatform != null) - CustomDimensionsEnum.commandBuildBundleTargetPlatform.cdKey: commandBuildBundleTargetPlatform - .toString(), - if (commandBuildBundleIsModule != null) - CustomDimensionsEnum.commandBuildBundleIsModule.cdKey: commandBuildBundleIsModule.toString(), - if (commandResult != null) CustomDimensionsEnum.commandResult.cdKey: commandResult.toString(), - if (hotEventTargetPlatform != null) - CustomDimensionsEnum.hotEventTargetPlatform.cdKey: hotEventTargetPlatform.toString(), - if (hotEventSdkName != null) - CustomDimensionsEnum.hotEventSdkName.cdKey: hotEventSdkName.toString(), - if (hotEventEmulator != null) - CustomDimensionsEnum.hotEventEmulator.cdKey: hotEventEmulator.toString(), - if (hotEventFullRestart != null) - CustomDimensionsEnum.hotEventFullRestart.cdKey: hotEventFullRestart.toString(), - if (commandHasTerminal != null) - CustomDimensionsEnum.commandHasTerminal.cdKey: commandHasTerminal.toString(), - if (enabledFlutterFeatures != null) - CustomDimensionsEnum.enabledFlutterFeatures.cdKey: enabledFlutterFeatures.toString(), - if (localTime != null) CustomDimensionsEnum.localTime.cdKey: localTime.toString(), - if (commandBuildAarTargetPlatform != null) - CustomDimensionsEnum.commandBuildAarTargetPlatform.cdKey: commandBuildAarTargetPlatform - .toString(), - if (commandBuildAarProjectType != null) - CustomDimensionsEnum.commandBuildAarProjectType.cdKey: commandBuildAarProjectType.toString(), - if (buildEventCommand != null) - CustomDimensionsEnum.buildEventCommand.cdKey: buildEventCommand.toString(), - if (buildEventSettings != null) - CustomDimensionsEnum.buildEventSettings.cdKey: buildEventSettings.toString(), - if (commandBuildApkTargetPlatform != null) - CustomDimensionsEnum.commandBuildApkTargetPlatform.cdKey: commandBuildApkTargetPlatform - .toString(), - if (commandBuildApkBuildMode != null) - CustomDimensionsEnum.commandBuildApkBuildMode.cdKey: commandBuildApkBuildMode.toString(), - if (commandBuildApkSplitPerAbi != null) - CustomDimensionsEnum.commandBuildApkSplitPerAbi.cdKey: commandBuildApkSplitPerAbi.toString(), - if (commandBuildAppBundleTargetPlatform != null) - CustomDimensionsEnum.commandBuildAppBundleTargetPlatform.cdKey: - commandBuildAppBundleTargetPlatform.toString(), - if (commandBuildAppBundleBuildMode != null) - CustomDimensionsEnum.commandBuildAppBundleBuildMode.cdKey: commandBuildAppBundleBuildMode - .toString(), - if (buildEventError != null) - CustomDimensionsEnum.buildEventError.cdKey: buildEventError.toString(), - if (commandResultEventMaxRss != null) - CustomDimensionsEnum.commandResultEventMaxRss.cdKey: commandResultEventMaxRss.toString(), - if (commandRunAndroidEmbeddingVersion != null) - CustomDimensionsEnum.commandRunAndroidEmbeddingVersion.cdKey: - commandRunAndroidEmbeddingVersion.toString(), - if (commandPackagesAndroidEmbeddingVersion != null) - CustomDimensionsEnum.commandPackagesAndroidEmbeddingVersion.cdKey: - commandPackagesAndroidEmbeddingVersion.toString(), - if (hotEventCompileTimeInMs != null) - CustomDimensionsEnum.hotEventCompileTimeInMs.cdKey: hotEventCompileTimeInMs.toString(), - if (hotEventFindInvalidatedTimeInMs != null) - CustomDimensionsEnum.hotEventFindInvalidatedTimeInMs.cdKey: hotEventFindInvalidatedTimeInMs - .toString(), - if (hotEventScannedSourcesCount != null) - CustomDimensionsEnum.hotEventScannedSourcesCount.cdKey: hotEventScannedSourcesCount - .toString(), - if (hotEventReassembleTimeInMs != null) - CustomDimensionsEnum.hotEventReassembleTimeInMs.cdKey: hotEventReassembleTimeInMs.toString(), - if (hotEventReloadVMTimeInMs != null) - CustomDimensionsEnum.hotEventReloadVMTimeInMs.cdKey: hotEventReloadVMTimeInMs.toString(), - if (commandRunEnableImpeller != null) - CustomDimensionsEnum.commandRunEnableImpeller.cdKey: commandRunEnableImpeller.toString(), - if (commandRunIOSInterfaceType != null) - CustomDimensionsEnum.commandRunIOSInterfaceType.cdKey: commandRunIOSInterfaceType.toString(), - if (commandRunIsTest != null) - CustomDimensionsEnum.commandRunIsTest.cdKey: commandRunIsTest.toString(), - }; - - /// Merge the values of two [CustomDimensions] into one. If a value is defined - /// in both instances, the value in [other] will override the value in this. - CustomDimensions merge(CustomDimensions? other) { - if (other == null) { - return this; - } - - return CustomDimensions( - sessionHostOsDetails: other.sessionHostOsDetails ?? sessionHostOsDetails, - sessionChannelName: other.sessionChannelName ?? sessionChannelName, - commandRunIsEmulator: other.commandRunIsEmulator ?? commandRunIsEmulator, - commandRunTargetName: other.commandRunTargetName ?? commandRunTargetName, - hotEventReason: other.hotEventReason ?? hotEventReason, - hotEventFinalLibraryCount: other.hotEventFinalLibraryCount ?? hotEventFinalLibraryCount, - hotEventSyncedLibraryCount: other.hotEventSyncedLibraryCount ?? hotEventSyncedLibraryCount, - hotEventSyncedClassesCount: other.hotEventSyncedClassesCount ?? hotEventSyncedClassesCount, - hotEventSyncedProceduresCount: - other.hotEventSyncedProceduresCount ?? hotEventSyncedProceduresCount, - hotEventSyncedBytes: other.hotEventSyncedBytes ?? hotEventSyncedBytes, - hotEventInvalidatedSourcesCount: - other.hotEventInvalidatedSourcesCount ?? hotEventInvalidatedSourcesCount, - hotEventTransferTimeInMs: other.hotEventTransferTimeInMs ?? hotEventTransferTimeInMs, - hotEventOverallTimeInMs: other.hotEventOverallTimeInMs ?? hotEventOverallTimeInMs, - commandRunProjectType: other.commandRunProjectType ?? commandRunProjectType, - commandRunProjectHostLanguage: - other.commandRunProjectHostLanguage ?? commandRunProjectHostLanguage, - commandCreateAndroidLanguage: - other.commandCreateAndroidLanguage ?? commandCreateAndroidLanguage, - commandCreateIosLanguage: other.commandCreateIosLanguage ?? commandCreateIosLanguage, - commandRunProjectModule: other.commandRunProjectModule ?? commandRunProjectModule, - commandCreateProjectType: other.commandCreateProjectType ?? commandCreateProjectType, - commandPackagesNumberPlugins: - other.commandPackagesNumberPlugins ?? commandPackagesNumberPlugins, - commandPackagesProjectModule: - other.commandPackagesProjectModule ?? commandPackagesProjectModule, - commandRunTargetOsVersion: other.commandRunTargetOsVersion ?? commandRunTargetOsVersion, - commandRunModeName: other.commandRunModeName ?? commandRunModeName, - commandBuildBundleTargetPlatform: - other.commandBuildBundleTargetPlatform ?? commandBuildBundleTargetPlatform, - commandBuildBundleIsModule: other.commandBuildBundleIsModule ?? commandBuildBundleIsModule, - commandResult: other.commandResult ?? commandResult, - hotEventTargetPlatform: other.hotEventTargetPlatform ?? hotEventTargetPlatform, - hotEventSdkName: other.hotEventSdkName ?? hotEventSdkName, - hotEventEmulator: other.hotEventEmulator ?? hotEventEmulator, - hotEventFullRestart: other.hotEventFullRestart ?? hotEventFullRestart, - commandHasTerminal: other.commandHasTerminal ?? commandHasTerminal, - enabledFlutterFeatures: other.enabledFlutterFeatures ?? enabledFlutterFeatures, - localTime: other.localTime ?? localTime, - commandBuildAarTargetPlatform: - other.commandBuildAarTargetPlatform ?? commandBuildAarTargetPlatform, - commandBuildAarProjectType: other.commandBuildAarProjectType ?? commandBuildAarProjectType, - buildEventCommand: other.buildEventCommand ?? buildEventCommand, - buildEventSettings: other.buildEventSettings ?? buildEventSettings, - commandBuildApkTargetPlatform: - other.commandBuildApkTargetPlatform ?? commandBuildApkTargetPlatform, - commandBuildApkBuildMode: other.commandBuildApkBuildMode ?? commandBuildApkBuildMode, - commandBuildApkSplitPerAbi: other.commandBuildApkSplitPerAbi ?? commandBuildApkSplitPerAbi, - commandBuildAppBundleTargetPlatform: - other.commandBuildAppBundleTargetPlatform ?? commandBuildAppBundleTargetPlatform, - commandBuildAppBundleBuildMode: - other.commandBuildAppBundleBuildMode ?? commandBuildAppBundleBuildMode, - buildEventError: other.buildEventError ?? buildEventError, - commandResultEventMaxRss: other.commandResultEventMaxRss ?? commandResultEventMaxRss, - commandRunAndroidEmbeddingVersion: - other.commandRunAndroidEmbeddingVersion ?? commandRunAndroidEmbeddingVersion, - commandPackagesAndroidEmbeddingVersion: - other.commandPackagesAndroidEmbeddingVersion ?? commandPackagesAndroidEmbeddingVersion, - hotEventCompileTimeInMs: other.hotEventCompileTimeInMs ?? hotEventCompileTimeInMs, - hotEventFindInvalidatedTimeInMs: - other.hotEventFindInvalidatedTimeInMs ?? hotEventFindInvalidatedTimeInMs, - hotEventScannedSourcesCount: other.hotEventScannedSourcesCount ?? hotEventScannedSourcesCount, - hotEventReassembleTimeInMs: other.hotEventReassembleTimeInMs ?? hotEventReassembleTimeInMs, - hotEventReloadVMTimeInMs: other.hotEventReloadVMTimeInMs ?? hotEventReloadVMTimeInMs, - commandRunEnableImpeller: other.commandRunEnableImpeller ?? commandRunEnableImpeller, - commandRunIOSInterfaceType: other.commandRunIOSInterfaceType ?? commandRunIOSInterfaceType, - commandRunIsTest: other.commandRunIsTest ?? commandRunIsTest, - ); - } - - static CustomDimensions fromMap(Map<String, String> map) => CustomDimensions( - sessionHostOsDetails: _extractString(map, CustomDimensionsEnum.sessionHostOsDetails), - sessionChannelName: _extractString(map, CustomDimensionsEnum.sessionChannelName), - commandRunIsEmulator: _extractBool(map, CustomDimensionsEnum.commandRunIsEmulator), - commandRunTargetName: _extractString(map, CustomDimensionsEnum.commandRunTargetName), - hotEventReason: _extractString(map, CustomDimensionsEnum.hotEventReason), - hotEventFinalLibraryCount: _extractInt(map, CustomDimensionsEnum.hotEventFinalLibraryCount), - hotEventSyncedLibraryCount: _extractInt(map, CustomDimensionsEnum.hotEventSyncedLibraryCount), - hotEventSyncedClassesCount: _extractInt(map, CustomDimensionsEnum.hotEventSyncedClassesCount), - hotEventSyncedProceduresCount: _extractInt( - map, - CustomDimensionsEnum.hotEventSyncedProceduresCount, - ), - hotEventSyncedBytes: _extractInt(map, CustomDimensionsEnum.hotEventSyncedBytes), - hotEventInvalidatedSourcesCount: _extractInt( - map, - CustomDimensionsEnum.hotEventInvalidatedSourcesCount, - ), - hotEventTransferTimeInMs: _extractInt(map, CustomDimensionsEnum.hotEventTransferTimeInMs), - hotEventOverallTimeInMs: _extractInt(map, CustomDimensionsEnum.hotEventOverallTimeInMs), - commandRunProjectType: _extractString(map, CustomDimensionsEnum.commandRunProjectType), - commandRunProjectHostLanguage: _extractString( - map, - CustomDimensionsEnum.commandRunProjectHostLanguage, - ), - commandCreateAndroidLanguage: _extractString( - map, - CustomDimensionsEnum.commandCreateAndroidLanguage, - ), - commandCreateIosLanguage: _extractString(map, CustomDimensionsEnum.commandCreateIosLanguage), - commandRunProjectModule: _extractBool(map, CustomDimensionsEnum.commandRunProjectModule), - commandCreateProjectType: _extractString(map, CustomDimensionsEnum.commandCreateProjectType), - commandPackagesNumberPlugins: _extractInt( - map, - CustomDimensionsEnum.commandPackagesNumberPlugins, - ), - commandPackagesProjectModule: _extractBool( - map, - CustomDimensionsEnum.commandPackagesProjectModule, - ), - commandRunTargetOsVersion: _extractString(map, CustomDimensionsEnum.commandRunTargetOsVersion), - commandRunModeName: _extractString(map, CustomDimensionsEnum.commandRunModeName), - commandBuildBundleTargetPlatform: _extractString( - map, - CustomDimensionsEnum.commandBuildBundleTargetPlatform, - ), - commandBuildBundleIsModule: _extractBool(map, CustomDimensionsEnum.commandBuildBundleIsModule), - commandResult: _extractString(map, CustomDimensionsEnum.commandResult), - hotEventTargetPlatform: _extractString(map, CustomDimensionsEnum.hotEventTargetPlatform), - hotEventSdkName: _extractString(map, CustomDimensionsEnum.hotEventSdkName), - hotEventEmulator: _extractBool(map, CustomDimensionsEnum.hotEventEmulator), - hotEventFullRestart: _extractBool(map, CustomDimensionsEnum.hotEventFullRestart), - commandHasTerminal: _extractBool(map, CustomDimensionsEnum.commandHasTerminal), - enabledFlutterFeatures: _extractString(map, CustomDimensionsEnum.enabledFlutterFeatures), - localTime: _extractString(map, CustomDimensionsEnum.localTime), - commandBuildAarTargetPlatform: _extractString( - map, - CustomDimensionsEnum.commandBuildAarTargetPlatform, - ), - commandBuildAarProjectType: _extractString( - map, - CustomDimensionsEnum.commandBuildAarProjectType, - ), - buildEventCommand: _extractString(map, CustomDimensionsEnum.buildEventCommand), - buildEventSettings: _extractString(map, CustomDimensionsEnum.buildEventSettings), - commandBuildApkTargetPlatform: _extractString( - map, - CustomDimensionsEnum.commandBuildApkTargetPlatform, - ), - commandBuildApkBuildMode: _extractString(map, CustomDimensionsEnum.commandBuildApkBuildMode), - commandBuildApkSplitPerAbi: _extractBool(map, CustomDimensionsEnum.commandBuildApkSplitPerAbi), - commandBuildAppBundleTargetPlatform: _extractString( - map, - CustomDimensionsEnum.commandBuildAppBundleTargetPlatform, - ), - commandBuildAppBundleBuildMode: _extractString( - map, - CustomDimensionsEnum.commandBuildAppBundleBuildMode, - ), - buildEventError: _extractString(map, CustomDimensionsEnum.buildEventError), - commandResultEventMaxRss: _extractInt(map, CustomDimensionsEnum.commandResultEventMaxRss), - commandRunAndroidEmbeddingVersion: _extractString( - map, - CustomDimensionsEnum.commandRunAndroidEmbeddingVersion, - ), - commandPackagesAndroidEmbeddingVersion: _extractString( - map, - CustomDimensionsEnum.commandPackagesAndroidEmbeddingVersion, - ), - hotEventCompileTimeInMs: _extractInt(map, CustomDimensionsEnum.hotEventCompileTimeInMs), - hotEventFindInvalidatedTimeInMs: _extractInt( - map, - CustomDimensionsEnum.hotEventFindInvalidatedTimeInMs, - ), - hotEventScannedSourcesCount: _extractInt(map, CustomDimensionsEnum.hotEventScannedSourcesCount), - hotEventReassembleTimeInMs: _extractInt(map, CustomDimensionsEnum.hotEventReassembleTimeInMs), - hotEventReloadVMTimeInMs: _extractInt(map, CustomDimensionsEnum.hotEventReloadVMTimeInMs), - commandRunEnableImpeller: _extractBool(map, CustomDimensionsEnum.commandRunEnableImpeller), - commandRunIOSInterfaceType: _extractString( - map, - CustomDimensionsEnum.commandRunIOSInterfaceType, - ), - commandRunIsTest: _extractBool(map, CustomDimensionsEnum.commandRunIsTest), - ); - - static bool? _extractBool(Map<String, String> map, CustomDimensionsEnum field) => - map.containsKey(field.cdKey) ? map[field.cdKey] == 'true' : null; - - static String? _extractString(Map<String, String> map, CustomDimensionsEnum field) => - map.containsKey(field.cdKey) ? map[field.cdKey] : null; - - static int? _extractInt(Map<String, String> map, CustomDimensionsEnum field) => - map.containsKey(field.cdKey) ? int.parse(map[field.cdKey]!) : null; - - @override - String toString() => toMap().toString(); - - @override - bool operator ==(Object other) { - return other is CustomDimensions && _mapsEqual(other.toMap(), toMap()); - } - - @override - int get hashCode => Object.hashAll(toMap().values); -} - -/// List of all fields used in CustomDimensions. -/// -/// The index of this enum is used to calculate the key of the fields. Always -/// append to this list when adding new fields, and do not remove or reorder -/// any elements. -enum CustomDimensionsEnum { - sessionHostOsDetails, // cd1 - sessionChannelName, // cd2 - commandRunIsEmulator, // cd3 - commandRunTargetName, // cd4 - hotEventReason, // cd5 - hotEventFinalLibraryCount, // cd6 - hotEventSyncedLibraryCount, // cd7 - hotEventSyncedClassesCount, // cd8 - hotEventSyncedProceduresCount, // cd9 - hotEventSyncedBytes, // cd10 - hotEventInvalidatedSourcesCount, // cd11 - hotEventTransferTimeInMs, // cd12 - hotEventOverallTimeInMs, // cd13 - commandRunProjectType, // cd14 - commandRunProjectHostLanguage, // cd15 - commandCreateAndroidLanguage, // cd16 - commandCreateIosLanguage, // cd17 - commandRunProjectModule, // cd18 - commandCreateProjectType, // cd19 - commandPackagesNumberPlugins, // cd20 - commandPackagesProjectModule, // cd21 - commandRunTargetOsVersion, // cd22 - commandRunModeName, // cd23 - commandBuildBundleTargetPlatform, // cd24 - commandBuildBundleIsModule, // cd25 - commandResult, // cd26 - hotEventTargetPlatform, // cd27 - hotEventSdkName, // cd28 - hotEventEmulator, // cd29 - hotEventFullRestart, // cd30 - commandHasTerminal, // cd31 - enabledFlutterFeatures, // cd32 - localTime, // cd33 - commandBuildAarTargetPlatform, // cd34 - commandBuildAarProjectType, // cd35 - buildEventCommand, // cd36 - buildEventSettings, // cd37 - commandBuildApkTargetPlatform, // cd38 - commandBuildApkBuildMode, // cd39 - commandBuildApkSplitPerAbi, // cd40 - commandBuildAppBundleTargetPlatform, // cd41 - commandBuildAppBundleBuildMode, // cd42 - buildEventError, // cd43 - commandResultEventMaxRss, // cd44 - commandRunAndroidEmbeddingVersion, // cd45 - commandPackagesAndroidEmbeddingVersion, // cd46 - // ignore: unused_field - _nullSafetyDeprecatedDoNotUse, // cd47 - obsolete1, // cd48 (was fastReassemble) - // ignore: unused_field - _nullSafeMigratedLibrariesDoNotUse, // cd49 - // ignore: unused_field - _nullSafeTotalLibrariesDoNotUse, // cd50 - hotEventCompileTimeInMs, // cd51 - hotEventFindInvalidatedTimeInMs, // cd52 - hotEventScannedSourcesCount, // cd53 - hotEventReassembleTimeInMs, // cd54 - hotEventReloadVMTimeInMs, // cd55 - commandRunEnableImpeller, // cd56 - commandRunIOSInterfaceType, // cd57 - commandRunIsTest; // cd58 - - String get cdKey => 'cd${index + 1}'; -}
diff --git a/packages/flutter_tools/lib/src/reporting/usage.dart b/packages/flutter_tools/lib/src/reporting/usage.dart deleted file mode 100644 index 1d037e9..0000000 --- a/packages/flutter_tools/lib/src/reporting/usage.dart +++ /dev/null
@@ -1,562 +0,0 @@ -// Copyright 2014 The Flutter Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -part of 'reporting.dart'; - -const String _kFlutterUA = 'UA-67589403-6'; - -abstract class Usage { - /// Create a new Usage instance; [versionOverride], [configDirOverride], and - /// [logFile] are used for testing. - factory Usage({ - String settingsName = 'flutter', - String? versionOverride, - String? configDirOverride, - String? logFile, - AnalyticsFactory? analyticsIOFactory, - FirstRunMessenger? firstRunMessenger, - required bool runningOnBot, - }) => _DefaultUsage.initialize( - settingsName: settingsName, - versionOverride: versionOverride, - configDirOverride: configDirOverride, - logFile: logFile, - analyticsIOFactory: analyticsIOFactory, - runningOnBot: runningOnBot, - firstRunMessenger: firstRunMessenger, - ); - - /// Uses the global [Usage] instance to send a 'command' to analytics. - static void command(String command, {CustomDimensions? parameters}) => - globals.flutterUsage.sendCommand(command, parameters: parameters); - - /// Whether analytics reporting should be suppressed. - bool get suppressAnalytics; - - /// Suppress analytics for this session. - set suppressAnalytics(bool value); - - /// Whether analytics reporting is enabled. - bool get enabled; - - /// Enable or disable reporting analytics. - set enabled(bool value); - - /// A stable randomly generated UUID used to deduplicate multiple identical - /// reports coming from the same computer. - String get clientId; - - /// Sends a 'command' to the underlying analytics implementation. - /// - /// Using [command] above is preferred to ensure that the parameter - /// keys are well-defined in [CustomDimensions] above. - void sendCommand(String command, {CustomDimensions? parameters}); - - /// Sends an 'event' to the underlying analytics implementation. - /// - /// This method should not be used directly, instead see the - /// event types defined in this directory in `events.dart`. - @visibleForOverriding - @visibleForTesting - void sendEvent( - String category, - String parameter, { - String? label, - int? value, - CustomDimensions? parameters, - }); - - /// Sends timing information to the underlying analytics implementation. - void sendTiming(String category, String variableName, Duration duration, {String? label}); - - /// Sends an exception to the underlying analytics implementation. - void sendException(dynamic exception); - - /// Fires whenever analytics data is sent over the network. - @visibleForTesting - Stream<Map<String, dynamic>> get onSend; - - /// Returns when the last analytics event has been sent, or after a fixed - /// (short) delay, whichever is less. - Future<void> ensureAnalyticsSent(); - - /// Prints a welcome message that informs the tool user about the collection - /// of anonymous usage information. - void printWelcome(); -} - -typedef AnalyticsFactory = - Analytics Function( - String trackingId, - String applicationName, - String applicationVersion, { - String analyticsUrl, - Directory? documentDirectory, - }); - -Analytics _defaultAnalyticsIOFactory( - String trackingId, - String applicationName, - String applicationVersion, { - String? analyticsUrl, - Directory? documentDirectory, -}) { - return AnalyticsIO( - trackingId, - applicationName, - applicationVersion, - analyticsUrl: analyticsUrl, - documentDirectory: documentDirectory, - ); -} - -class _DefaultUsage implements Usage { - _DefaultUsage._({ - required bool suppressAnalytics, - required Analytics analytics, - required this.firstRunMessenger, - required SystemClock clock, - }) : _suppressAnalytics = suppressAnalytics, - _analytics = analytics, - _clock = clock; - - static _DefaultUsage initialize({ - String settingsName = 'flutter', - String? versionOverride, - String? configDirOverride, - String? logFile, - AnalyticsFactory? analyticsIOFactory, - required FirstRunMessenger? firstRunMessenger, - required bool runningOnBot, - }) { - final FlutterVersion flutterVersion = globals.flutterVersion; - final String version = - versionOverride ?? flutterVersion.getVersionString(redactUnknownBranches: true); - final bool suppressEnvFlag = - globals.platform.environment['FLUTTER_SUPPRESS_ANALYTICS'] == 'true'; - final String? logFilePath = - logFile ?? globals.platform.environment['FLUTTER_ANALYTICS_LOG_FILE']; - final bool usingLogFile = logFilePath != null && logFilePath.isNotEmpty; - - final AnalyticsFactory analyticsFactory = analyticsIOFactory ?? _defaultAnalyticsIOFactory; - bool suppressAnalytics = false; - bool skipAnalyticsSessionSetup = false; - Analytics? setupAnalytics; - if ( // To support testing, only allow other signals to suppress analytics - // when analytics are not being shunted to a file. - !usingLogFile && - ( // Ignore local user branches. - version.startsWith('[user-branch]') || - // Many CI systems don't do a full git checkout. - version.endsWith('/unknown') || - // Ignore bots. - runningOnBot || - // Ignore when suppressed by FLUTTER_SUPPRESS_ANALYTICS. - suppressEnvFlag)) { - // If we think we're running on a CI system, suppress sending analytics. - suppressAnalytics = true; - setupAnalytics = AnalyticsMock(); - skipAnalyticsSessionSetup = true; - } - if (usingLogFile) { - setupAnalytics ??= LogToFileAnalytics(logFilePath); - } else { - try { - ErrorHandlingFileSystem.noExitOnFailure(() { - setupAnalytics = analyticsFactory( - _kFlutterUA, - settingsName, - version, - documentDirectory: configDirOverride != null - ? globals.fs.directory(configDirOverride) - : null, - ); - }); - } on Exception catch (e) { - globals.printTrace('Failed to initialize analytics reporting: $e'); - suppressAnalytics = true; - setupAnalytics ??= AnalyticsMock(); - skipAnalyticsSessionSetup = true; - } - } - - final Analytics analytics = setupAnalytics!; - if (!skipAnalyticsSessionSetup) { - // Report a more detailed OS version string than package:usage does by default. - analytics.setSessionValue(CustomDimensionsEnum.sessionHostOsDetails.cdKey, globals.os.name); - // Send the branch name as the "channel". - analytics.setSessionValue( - CustomDimensionsEnum.sessionChannelName.cdKey, - flutterVersion.getBranchName(redactUnknownBranches: true), - ); - // For each flutter experimental feature, record a session value in a comma - // separated list. - final String enabledFeatures = featureFlags.allFeatures - .where((Feature feature) { - final String? configSetting = feature.configSetting; - return configSetting != null && globals.config.getValue(configSetting) == true; - }) - .map((Feature feature) => feature.configSetting) - .join(','); - analytics.setSessionValue(CustomDimensionsEnum.enabledFlutterFeatures.cdKey, enabledFeatures); - - // Record the host as the application installer ID - the context that flutter_tools is running in. - if (globals.platform.environment.containsKey('FLUTTER_HOST')) { - analytics.setSessionValue('aiid', globals.platform.environment['FLUTTER_HOST']); - } - analytics.analyticsOpt = AnalyticsOpt.optOut; - } - - return _DefaultUsage._( - suppressAnalytics: suppressAnalytics, - analytics: analytics, - firstRunMessenger: firstRunMessenger, - clock: globals.systemClock, - ); - } - - final Analytics _analytics; - final FirstRunMessenger? firstRunMessenger; - - bool _printedWelcome = false; - bool _suppressAnalytics = false; - final SystemClock _clock; - - @override - bool get suppressAnalytics => _suppressAnalytics || _analytics.firstRun; - - @override - set suppressAnalytics(bool value) { - _suppressAnalytics = value; - } - - @override - bool get enabled => _analytics.enabled; - - @override - set enabled(bool value) { - _analytics.enabled = value; - } - - @override - String get clientId => _analytics.clientId; - - @override - void sendCommand(String command, {CustomDimensions? parameters}) { - if (suppressAnalytics) { - return; - } - - _analytics.sendScreenView( - command, - parameters: CustomDimensions( - localTime: formatDateTime(_clock.now()), - ).merge(parameters).toMap(), - ); - } - - @override - void sendEvent( - String category, - String parameter, { - String? label, - int? value, - CustomDimensions? parameters, - }) { - if (suppressAnalytics) { - return; - } - - _analytics.sendEvent( - category, - parameter, - label: label, - value: value, - parameters: CustomDimensions( - localTime: formatDateTime(_clock.now()), - ).merge(parameters).toMap(), - ); - } - - @override - void sendTiming(String category, String variableName, Duration duration, {String? label}) { - if (suppressAnalytics) { - return; - } - _analytics.sendTiming(variableName, duration.inMilliseconds, category: category, label: label); - } - - @override - void sendException(dynamic exception) { - if (suppressAnalytics) { - return; - } - _analytics.sendException(exception.runtimeType.toString()); - } - - @override - Stream<Map<String, dynamic>> get onSend => _analytics.onSend; - - @override - Future<void> ensureAnalyticsSent() async { - // TODO(devoncarew): This may delay tool exit and could cause some analytics - // events to not be reported. Perhaps we could send the analytics pings - // out-of-process from flutter_tools? - await _analytics.waitForLastPing(timeout: const Duration(milliseconds: 250)); - } - - @override - void printWelcome() { - // Only print once per run. - if (_printedWelcome) { - return; - } - // Display the welcome message if this is the first run of the tool or if - // the license terms have changed since it was last displayed. - final FirstRunMessenger? messenger = firstRunMessenger; - if (messenger != null && messenger.shouldDisplayLicenseTerms()) { - globals.printStatus(''); - globals.printStatus(messenger.licenseTerms, emphasis: true); - _printedWelcome = true; - messenger.confirmLicenseTermsDisplayed(); - } - } -} - -// An Analytics mock that logs to file. Unimplemented methods goes to stdout. -// But stdout can't be used for testing since wrapper scripts like -// xcode_backend.sh etc manipulates them. -class LogToFileAnalytics extends AnalyticsMock { - LogToFileAnalytics(String logFilePath) - : logFile = globals.fs.file(logFilePath)..createSync(recursive: true), - super(true); - - final File logFile; - final Map<String, String> _sessionValues = <String, String>{}; - - final StreamController<Map<String, dynamic>> _sendController = - StreamController<Map<String, dynamic>>.broadcast(sync: true); - - @override - Stream<Map<String, dynamic>> get onSend => _sendController.stream; - - @override - Future<void> sendScreenView(String viewName, {Map<String, String>? parameters}) { - if (!enabled) { - return Future<void>.value(); - } - parameters ??= <String, String>{}; - parameters['viewName'] = viewName; - parameters.addAll(_sessionValues); - _sendController.add(parameters); - logFile.writeAsStringSync('screenView $parameters\n', mode: FileMode.append); - return Future<void>.value(); - } - - @override - Future<void> sendEvent( - String category, - String action, { - String? label, - int? value, - Map<String, String>? parameters, - }) { - if (!enabled) { - return Future<void>.value(); - } - parameters ??= <String, String>{}; - parameters['category'] = category; - parameters['action'] = action; - _sendController.add(parameters); - logFile.writeAsStringSync('event $parameters\n', mode: FileMode.append); - return Future<void>.value(); - } - - @override - Future<void> sendTiming(String variableName, int time, {String? category, String? label}) { - if (!enabled) { - return Future<void>.value(); - } - final Map<String, String> parameters = <String, String>{ - 'variableName': variableName, - 'time': '$time', - if (category != null) 'category': category, - if (label != null) 'label': label, - }; - _sendController.add(parameters); - logFile.writeAsStringSync('timing $parameters\n', mode: FileMode.append); - return Future<void>.value(); - } - - @override - void setSessionValue(String param, dynamic value) { - _sessionValues[param] = value.toString(); - } -} - -/// Create a testing Usage instance. -/// -/// All sent events, exceptions, timings, and pages are -/// buffered on the object and can be inspected later. -@visibleForTesting -class TestUsage implements Usage { - final List<TestUsageCommand> commands = <TestUsageCommand>[]; - final List<TestUsageEvent> events = <TestUsageEvent>[]; - final List<dynamic> exceptions = <dynamic>[]; - final List<TestTimingEvent> timings = <TestTimingEvent>[]; - int ensureAnalyticsSentCalls = 0; - bool _printedWelcome = false; - - @override - bool enabled = true; - - @override - bool suppressAnalytics = false; - - @override - String get clientId => 'test-client'; - - /// Confirms if the [printWelcome] method was invoked. - bool get printedWelcome => _printedWelcome; - - @override - Future<void> ensureAnalyticsSent() async { - ensureAnalyticsSentCalls++; - } - - @override - Stream<Map<String, dynamic>> get onSend => throw UnimplementedError(); - - @override - void printWelcome() { - _printedWelcome = true; - } - - @override - void sendCommand(String command, {CustomDimensions? parameters}) { - commands.add(TestUsageCommand(command, parameters: parameters)); - } - - @override - void sendEvent( - String category, - String parameter, { - String? label, - int? value, - CustomDimensions? parameters, - }) { - events.add( - TestUsageEvent(category, parameter, label: label, value: value, parameters: parameters), - ); - } - - @override - void sendException(dynamic exception) { - exceptions.add(exception); - } - - @override - void sendTiming(String category, String variableName, Duration duration, {String? label}) { - timings.add(TestTimingEvent(category, variableName, duration, label: label)); - } -} - -@visibleForTesting -@immutable -class TestUsageCommand { - const TestUsageCommand(this.command, {this.parameters}); - - final String command; - final CustomDimensions? parameters; - - @override - bool operator ==(Object other) { - return other is TestUsageCommand && other.command == command && other.parameters == parameters; - } - - @override - int get hashCode => Object.hash(command, parameters); - - @override - String toString() => 'TestUsageCommand($command, parameters:$parameters)'; -} - -@visibleForTesting -@immutable -class TestUsageEvent { - const TestUsageEvent(this.category, this.parameter, {this.label, this.value, this.parameters}); - - final String category; - final String parameter; - final String? label; - final int? value; - final CustomDimensions? parameters; - - @override - bool operator ==(Object other) { - return other is TestUsageEvent && - other.category == category && - other.parameter == parameter && - other.label == label && - other.value == value && - other.parameters == parameters; - } - - @override - int get hashCode => Object.hash(category, parameter, label, value, parameters); - - @override - String toString() => - 'TestUsageEvent($category, $parameter, label:$label, value:$value, parameters:$parameters)'; -} - -@visibleForTesting -@immutable -class TestTimingEvent { - const TestTimingEvent(this.category, this.variableName, this.duration, {this.label}); - - final String category; - final String variableName; - final Duration duration; - final String? label; - - @override - bool operator ==(Object other) { - return other is TestTimingEvent && - other.category == category && - other.variableName == variableName && - other.duration == duration && - other.label == label; - } - - @override - int get hashCode => Object.hash(category, variableName, duration, label); - - @override - String toString() => 'TestTimingEvent($category, $variableName, $duration, label:$label)'; -} - -bool _mapsEqual(Map<dynamic, dynamic>? a, Map<dynamic, dynamic>? b) { - if (a == b) { - return true; - } - if (a == null || b == null) { - return false; - } - if (a.length != b.length) { - return false; - } - - for (final dynamic k in a.keys) { - final dynamic bValue = b[k]; - if (bValue == null && !b.containsKey(k)) { - return false; - } - if (bValue != a[k]) { - return false; - } - } - - return true; -}