AnalyticsMock class
A no-op implementation of the Analytics class. This can be used as a stand-in for that will never ping the GA server, or as a mock in test code.
- Implemented types
Constructors
- AnalyticsMock.new([bool logCalls = false])
-
Create a new AnalyticsMock. If
logCalls
is true, all calls will be logged to stdout.
Properties
- analyticsOpt ↔ AnalyticsOpt
-
Whether the Analytics instance is configured in an opt-in or opt-out
manner.
getter/setter pairoverride
- applicationName → String
-
The application name.
no setteroverride
- applicationVersion → String
-
The application version.
no setteroverride
- clientId → String
-
Anonymous client ID in UUID v4 format.
no setteroverride
- enabled ↔ bool
-
Will analytics data be sent.
getter/setter pairoverride
- firstRun → bool
-
Is this the first time the tool has run?
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
- logCalls → bool
-
final
-
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 setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- trackingId → String
-
Tracking ID / Property ID.
no setteroverride
Methods
-
close(
) → void -
Free any used resources.
override
-
getSessionValue(
String param) → dynamic -
Gets a session variable value.
override
-
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<void> -
Sends an Event hit to Google Analytics.
label
specifies the event label.value
specifies the event value. Values must be non-negative.override -
sendException(
String description, {bool? fatal}) → Future< void> -
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.override -
sendScreenView(
String viewName, {Map< String, String> ? parameters}) → Future<void> -
Sends a screen view hit to Google Analytics.
override
-
sendSocial(
String network, String action, String target) → Future< void> -
Sends a Social hit to Google Analytics.
override
-
sendTiming(
String variableName, int time, {String? category, String? label}) → Future< void> -
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.override -
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.
override
-
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.
override
-
toString(
) → String -
A string representation of this object.
inherited
-
waitForLastPing(
{Duration? timeout}) → Future< void> -
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.override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited