Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -8,9 +8,9 @@
library;

import 'dart:async';
import 'dart:js_interop';

import 'package:flutter/foundation.dart';
import 'package:js/js.dart';
import 'package:logging/logging.dart';
import 'package:unified_analytics/unified_analytics.dart' as ua;
import 'package:web/web.dart';
Expand Down Expand Up @@ -49,9 +49,7 @@ final _log = Logger('_analytics_web');
@JS('initializeGA')
external void initializeGA();

@JS()
@anonymous
class GtagEventDevTools extends GtagEvent {
extension type GtagEventDevTools._(JSObject _) implements GtagEvent {
// TODO(kenz): try to make this accept a JSON map of extra parameters rather
// than a fixed list of fields. See
// https://github.com/flutter/devtools/pull/3281#discussion_r692376353.
Expand All @@ -62,9 +60,7 @@ class GtagEventDevTools extends GtagEvent {

int value,
bool non_interaction,
// This code is going away so not worth cleaning up to be free of dynamic.
// ignore: avoid-dynamic
dynamic custom_map,
JSObject? custom_map,

// NOTE: Do not reorder any of these. Order here must match the order in the
// Google Analytics console.
Expand Down Expand Up @@ -113,72 +109,39 @@ class GtagEventDevTools extends GtagEvent {
int? inspector_tree_controller_id, // metric12
});

@override
external String? get event_category;

@override
external String? get event_label;

@override
external String? get send_to;

@override
external int get value; // Positive number.

@override
external bool get non_interaction;

@override
external Object get custom_map;
external JSObject? get custom_map;

// Custom dimensions:
external String? get user_app;

external String? get user_build;

external String? get user_platform;

external String? get devtools_platform;

external String? get devtools_chrome;

external String? get devtools_version;

external String? get ide_launched;

external String? get flutter_client_id;

external String? get is_external_build;

external String? get is_embedded;

external String? get g3_username;

external String? get ide_launched_feature;

// Custom metrics:
external int? get ui_duration_micros;

external int? get raster_duration_micros;

external int? get shader_compilation_duration_micros;

external int? get cpu_sample_count;

external int? get cpu_stack_depth;

external int? get trace_event_count;

external int? get heap_diff_objects_before;

external int? get heap_diff_objects_after;

external int? get heap_objects_total;

external int? get root_set_count;

external int? get row_count;

external int? get inspector_tree_controller_id;
}

Expand Down Expand Up @@ -318,9 +281,7 @@ GtagExceptionDevTools _gtagException(
);
}

@JS()
@anonymous
class GtagExceptionDevTools extends GtagException {
extension type GtagExceptionDevTools._(JSObject _) implements GtagException {
external factory GtagExceptionDevTools({
String? description,
bool fatal,
Expand Down Expand Up @@ -371,59 +332,35 @@ class GtagExceptionDevTools extends GtagException {
int? inspector_tree_controller_id, // metric12
});

@override
external String? get description; // Description of the error.
@override
external bool get fatal; // Fatal error.

// Custom dimensions:
external String? get user_app;

external String? get user_build;

external String? get user_platform;

external String? get devtools_platform;

external String? get devtools_chrome;

external String? get devtools_version;

external String? get ide_launched;

external String? get flutter_client_id;

external String? get is_external_build;

external String? get is_embedded;

external String? get g3_username;

external String? get ide_launched_feature;

// Custom metrics:
external int? get ui_duration_micros;

external int? get raster_duration_micros;

external int? get shader_compilation_duration_micros;

external int? get cpu_sample_count;

external int? get cpu_stack_depth;

external int? get trace_event_count;

external int? get heap_diff_objects_before;

external int? get heap_diff_objects_after;

external int? get heap_objects_total;

external int? get root_set_count;

external int? get row_count;

external int? get inspector_tree_controller_id;
}

Expand Down
30 changes: 10 additions & 20 deletions packages/devtools_app/lib/src/shared/analytics/gtags.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
@JS()
library;

import 'dart:js_interop';

import 'package:flutter/foundation.dart';
import 'package:js/js.dart';

import '../../shared/development_helpers.dart';
import 'analytics.dart' as ga;
Expand All @@ -17,7 +18,7 @@ import 'analytics.dart' as ga;
/// For debugging install the Chrome Plugin "Google Analytics Debugger".

@JS('gtag')
external void _gTagCommandName(String command, String name, [Object? params]);
external void _gTagCommandName(String command, String name, [JSObject? params]);

// TODO(jacobr): refactor this code if we do not migrate off gtags.
// ignore: avoid_classes_with_only_static_members
Expand All @@ -44,38 +45,27 @@ class GTag {
}
}

@JS()
@anonymous
class GtagEvent {
extension type GtagEvent._(JSObject _) implements JSObject {
external factory GtagEvent({
String? event_category,
String? event_label, // Event e.g., gaScreenViewEvent, gaSelectEvent, etc.
String? send_to, // UA ID of target GA property to receive event data.

int value = 0,
bool non_interaction = false,
Object? custom_map,
int value,
bool non_interaction,
JSObject? custom_map,
});

external String? get event_category;

external String? get event_label;

external String? get send_to;

external int get value; // Positive number.
external bool get non_interaction;

external Object? get custom_map; // Custom metrics
external JSObject? get custom_map; // Custom metrics
}

@JS()
@anonymous
class GtagException {
external factory GtagException({
String? description,
bool fatal = false,
});
extension type GtagException._(JSObject _) implements JSObject {
external factory GtagException({String? description, bool fatal});

external String? get description; // Description of the error.
external bool get fatal; // Fatal error.
Expand Down