Analytics class abstract
An interface to a Google Analytics session.
AnalyticsHtml and AnalyticsIO are concrete implementations of this interface. AnalyticsMock can be used for testing or for some variants of an opt-in workflow.
The analytics information is sent on a best-effort basis. So, failures to
send the GA information will not result in errors from the asynchronous
send
methods.
- Implementers
Constructors
Properties
- analyticsOpt ↔ AnalyticsOpt
-
Whether the Analytics instance is configured in an opt-in or opt-out
manner.
getter/setter pair
- applicationName → String?
-
The application name.
no setter
- applicationVersion → String?
-
The application version.
no setter
- clientId → String
-
Anonymous client ID in UUID v4 format.
no setter
- enabled ↔ bool
-
Will analytics data be sent.
getter/setter pair
- firstRun → bool
-
Is this the first time the tool has run?
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
-
onSend
→ Stream<
Map< String, dynamic> > -
Fires events when the usage library sends any data over the network. This
will not fire if analytics has been disabled or if the throttling
algorithm has been engaged.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- trackingId → String
-
Tracking ID / Property ID.
no setter
Methods
-
close(
) → void - Free any used resources.
-
getSessionValue(
String param) → dynamic - Gets a session variable value.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
sendEvent(
String category, String action, {String? label, int? value, Map< String, String> ? parameters}) → Future -
Sends an Event hit to Google Analytics.
label
specifies the event label.value
specifies the event value. Values must be non-negative. -
sendException(
String description, {bool? fatal}) → Future -
In order to avoid sending any personally identifying information, the
description
field must not contain the exception message. In addition, only the first 100 chars of the description will be sent. -
sendScreenView(
String viewName, {Map< String, String> ? parameters}) → Future - Sends a screen view hit to Google Analytics.
-
sendSocial(
String network, String action, String target) → Future - Sends a Social hit to Google Analytics.
-
sendTiming(
String variableName, int time, {String? category, String? label}) → Future -
Sends a Timing hit to Google Analytics.
variableName
specifies the variable name of the timing.time
specifies the user timing value (in milliseconds).category
specifies the category of the timing.label
specifies the label of the timing. -
setSessionValue(
String param, dynamic value) → void - Sets a session variable value. The value is persistent for the life of the Analytics instance. This variable will be sent in with every analytics hit. A list of valid variable names can be found here: https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters.
-
startTimer(
String variableName, {String? category, String? label}) → AnalyticsTimer - Start a timer. The time won't be calculated, and the analytics information sent, until the AnalyticsTimer.finish method is called.
-
toString(
) → String -
A string representation of this object.
inherited
-
waitForLastPing(
{Duration? timeout}) → Future -
Wait for all of the outstanding analytics pings to complete. The returned
Future
will always complete without errors. You can pass in an optionalDuration
to specify to only wait for a certain amount of time.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited