Skip to content

Commit

Permalink
Upgrade to unified_analytics 6.1.3 (#8317)
Browse files Browse the repository at this point in the history
  • Loading branch information
kenzieschmoll authored Sep 10, 2024
1 parent a221e8b commit 0a01c48
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ class TraceWidgetBuildsCheckbox extends StatelessWidget {
tooltip: extension.tooltip,
onChanged: _checkboxChanged,
enabled: enabled,
gaScreenName: extension.gaScreenName,
gaScreen: extension.gaScreenName,
gaItem: extension.gaItem,
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ class _ServiceExtensionCheckboxState extends State<ServiceExtensionCheckbox>
tooltip: widget.serviceExtension.tooltip,
onChanged: _onChanged,
enabled: available,
gaScreenName: widget.serviceExtension.gaScreenName,
gaScreen: widget.serviceExtension.gaScreenName,
gaItem: widget.serviceExtension.gaItem,
),
),
Expand Down
58 changes: 48 additions & 10 deletions packages/devtools_app/lib/src/shared/analytics/_analytics_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ extension type GtagEventDevTools._(JSObject _) implements GtagEvent {
// "onDebugPrompt" - user responded to prompt when running a debug session
// "languageStatus" - launched from the language status popout
String? ide_launched_feature,
String? is_wasm, // dimension13 whether DevTools is running with WASM.

// Performance screen metrics. See [PerformanceScreenMetrics].
int? ui_duration_micros, // metric1
Expand Down Expand Up @@ -123,6 +124,7 @@ extension type GtagEventDevTools._(JSObject _) implements GtagEvent {
external String? get is_embedded;
external String? get g3_username;
external String? get ide_launched_feature;
external String? get is_wasm;

// Custom metrics:
external int? get ui_duration_micros;
Expand Down Expand Up @@ -170,6 +172,7 @@ extension type GtagExceptionDevTools._(JSObject _) implements GtagException {
// "onDebugPrompt" - user responded to prompt when running a debug session
// "languageStatus" - launched from the language status popout
String? ide_launched_feature,
String? is_wasm, // dimension13 whether DevTools is running with WASM.

// Performance screen metrics. See [PerformanceScreenMetrics].
int? ui_duration_micros, // metric1
Expand Down Expand Up @@ -203,6 +206,7 @@ extension type GtagExceptionDevTools._(JSObject _) implements GtagException {
external String? get is_embedded;
external String? get g3_username;
external String? get ide_launched_feature;
external String? get is_wasm;

// Custom metrics:
external int? get ui_duration_micros;
Expand Down Expand Up @@ -247,6 +251,7 @@ GtagEventDevTools _gtagEvent({
is_embedded: isEmbedded().toString(),
g3_username: devToolsEnvironmentParameters.username(),
ide_launched_feature: ideLaunchedFeature,
is_wasm: kIsWasm.toString(),
// [PerformanceScreenMetrics]
ui_duration_micros: screenMetrics is PerformanceScreenMetrics
? screenMetrics.uiDuration?.inMicroseconds
Expand Down Expand Up @@ -312,6 +317,7 @@ GtagExceptionDevTools _gtagException(
is_embedded: isEmbedded().toString(),
g3_username: devToolsEnvironmentParameters.username(),
ide_launched_feature: ideLaunchedFeature,
is_wasm: kIsWasm.toString(),
// [PerformanceScreenMetrics]
ui_duration_micros: screenMetrics is PerformanceScreenMetrics
? screenMetrics.uiDuration?.inMicroseconds
Expand Down Expand Up @@ -613,16 +619,13 @@ void reportError(
if (_lastGaError == errorMessage) return;
_lastGaError = errorMessage;

GTag.exception(
gaExceptionProvider: () => _gtagException(
errorMessage,
fatal: fatal,
),
final gTagException = _gtagException(
errorMessage,
fatal: fatal,
);
GTag.exception(gaExceptionProvider: () => gTagException);

// TODO(kenz): we may want to create a new event `devtoolsException` if we
// need all of our custom dimensions logged with exceptions.
final uaEvent = ua.Event.exception(exception: errorMessage);
final uaEvent = _uaEventFromGtagException(gTagException);
unawaited(dtdManager.sendAnalyticsEvent(uaEvent));
}

Expand Down Expand Up @@ -849,11 +852,11 @@ void _sendEventForScreen(String screenName, GtagEventDevTools gtagEvent) {
screenName,
gaEventProvider: () => gtagEvent,
);
final uaEvent = uaEventFromGtagEvent(gtagEvent);
final uaEvent = _uaEventFromGtagEvent(gtagEvent);
unawaited(dtdManager.sendAnalyticsEvent(uaEvent));
}

ua.Event uaEventFromGtagEvent(GtagEventDevTools gtagEvent) {
ua.Event _uaEventFromGtagEvent(GtagEventDevTools gtagEvent) {
return ua.Event.devtoolsEvent(
eventCategory: gtagEvent.event_category!,
label: gtagEvent.event_label!,
Expand All @@ -869,6 +872,7 @@ ua.Event uaEventFromGtagEvent(GtagEventDevTools gtagEvent) {
isExternalBuild: gtagEvent.is_external_build,
isEmbedded: gtagEvent.is_embedded,
ideLaunchedFeature: gtagEvent.ide_launched_feature,
isWasm: gtagEvent.is_wasm,
g3Username: gtagEvent.g3_username,
uiDurationMicros: gtagEvent.ui_duration_micros,
rasterDurationMicros: gtagEvent.raster_duration_micros,
Expand All @@ -885,3 +889,37 @@ ua.Event uaEventFromGtagEvent(GtagEventDevTools gtagEvent) {
inspectorTreeControllerId: gtagEvent.inspector_tree_controller_id,
);
}

ua.Event _uaEventFromGtagException(GtagExceptionDevTools gtagException) {
return ua.Event.exception(
exception: gtagException.description ?? 'unknown exception',
data: {
'fatal': gtagException.fatal,
'userApp': gtagException.user_app,
'userBuild': gtagException.user_build,
'userPlatform': gtagException.user_platform,
'devtoolsPlatform': gtagException.devtools_platform,
'devtoolsChrome': gtagException.devtools_chrome,
'devtoolsVersion': gtagException.devtools_version,
'ideLaunched': gtagException.ide_launched,
'isExternalBuild': gtagException.is_external_build,
'isEmbedded': gtagException.is_embedded,
'ideLaunchedFeature': gtagException.ide_launched_feature,
'isWasm': gtagException.is_wasm,
'g3Username': gtagException.g3_username,
'uiDurationMicros': gtagException.ui_duration_micros,
'rasterDurationMicros': gtagException.raster_duration_micros,
'shaderCompilationDurationMicros':
gtagException.shader_compilation_duration_micros,
'traceEventCount': gtagException.trace_event_count,
'cpuSampleCount': gtagException.cpu_sample_count,
'cpuStackDepth': gtagException.cpu_stack_depth,
'heapDiffObjectsBefore': gtagException.heap_diff_objects_before,
'heapDiffObjectsAfter': gtagException.heap_diff_objects_after,
'heapObjectsTotal': gtagException.heap_objects_total,
'rootSetCount': gtagException.root_set_count,
'rowCount': gtagException.row_count,
'inspectorTreeControllerId': gtagException.inspector_tree_controller_id,
},
);
}
10 changes: 5 additions & 5 deletions packages/devtools_app/lib/src/shared/common_widgets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1521,7 +1521,7 @@ class CheckboxSetting extends StatelessWidget {
this.tooltip,
this.onChanged,
this.enabled = true,
this.gaScreenName,
this.gaScreen,
this.gaItem,
this.checkboxKey,
});
Expand All @@ -1539,7 +1539,7 @@ class CheckboxSetting extends StatelessWidget {
/// Whether this checkbox setting should be enabled for interaction.
final bool enabled;

final String? gaScreenName;
final String? gaScreen;

final String? gaItem;

Expand All @@ -1554,10 +1554,10 @@ class CheckboxSetting extends StatelessWidget {
NotifierCheckbox(
notifier: notifier,
onChanged: (bool? value) {
final gaScreenName = this.gaScreenName;
final gaScreen = this.gaScreen;
final gaItem = this.gaItem;
if (gaScreenName != null && gaItem != null) {
ga.select(gaScreenName, gaItem);
if (gaScreen != null && gaItem != null) {
ga.select(gaScreen, gaItem);
}
final onChanged = this.onChanged;
if (onChanged != null) {
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools_app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ dependencies:
stack_trace: ^1.10.0
stream_channel: ^2.1.1
string_scanner: ^1.1.0
unified_analytics: ^6.1.0
unified_analytics: ^6.1.3
vm_service: ^14.2.5
vm_service_protos: ^1.0.0
vm_snapshot_analysis: ^0.7.6
Expand Down

0 comments on commit 0a01c48

Please sign in to comment.