usage 0.0.2 copy "usage: ^0.0.2" to clipboard
usage: ^0.0.2 copied to clipboard

discontinued
outdatedDart 1 only

A Google Analytics wrapper for both command-line and web apps.

usage #

usage is a wrapper around Google Analytics for both command-line apps and web apps.

Build Status

For web apps #

In order to use this library as a web app, import the usage_html.dart library and instantiate the AnalyticsHtml class.

For command-line apps #

In order to use this library as a command-line app, import the usage_io.dart library and instantiate the AnalyticsIO class.

Note, for CLI apps, the usage library will send analytics pings asynchronously. This is useful it that it doesn't block the app generally. It does have one side-effect, in that outstanding asynchronous requests will block termination of the VM until that request finishes. So, for short-lived CLI tools, pinging Google Analytics can cause the tool to pause for several seconds before it terminates. This is often undesired - gathering analytics information shouldn't negatively effect the tool's UX.

One solution to this is to gather up all the Future's that the send() analytics methods return, and wait on them with a timeout. So, send analytics pings on a best effort basis, but prefer to let the tool exit reasonably quickly. Something like:

void _exitApp([Future someAnalyticsFuture]) {
  Future f = someAnalyticsFuture == null ? new Future.value() : someAnalyticsFuture;
  f.timeout(new Duration(milliseconds: 500), onTimeout: () => null).then((_) {
    io.exit(0);
  };
}

In the future, in order to make this easier to do for CLI clients, we may roll some of this functionality into the library. I.e., provide something like a waitForLastPing(Duration timeout) method on the CLI client.

Other info #

For both classes, you need to provide a Google Analytics tracking ID, the application name, and the application version.

Your application should provide an opt-in option for the user. If they opt-in, set the [optIn] field to true. This setting will persist across sessions automatically.

For more information, please see the Google Analytics Measurement Protocol Policy.

72
likes
0
pub points
99%
popularity

Publisher

verified publishertools.dart.cn

A Google Analytics wrapper for both command-line and web apps.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

crypto, uuid

More

Packages that depend on usage