Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Unified Diff: packages/usage/readme.md

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « packages/usage/pubspec.yaml ('k') | packages/usage/test/all.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/usage/readme.md
diff --git a/packages/usage/readme.md b/packages/usage/readme.md
index 63a365a6f7489cf603c9431a6bd914b93f2d96ea..931f91f678f08686d874e88e0743b05f4cdddf36 100644
--- a/packages/usage/readme.md
+++ b/packages/usage/readme.md
@@ -1,8 +1,8 @@
# usage
-`usage` is a wrapper around Google Analytics for both command-line apps and web
-apps.
+`usage` is a wrapper around Google Analytics for command-line, web, and Flutter apps.
+[![pub package](https://img.shields.io/pub/v/usage.svg)](https://pub.dartlang.org/packages/usage)
[![Build Status](https://travis-ci.org/dart-lang/usage.svg)](https://travis-ci.org/dart-lang/usage)
[![Coverage Status](https://img.shields.io/coveralls/dart-lang/usage.svg)](https://coveralls.io/r/dart-lang/usage?branch=master)
@@ -11,6 +11,28 @@ apps.
To use this library as a web app, import the `usage_html.dart` library and
instantiate the `AnalyticsHtml` class.
+When you are creating a new property at [google analytics](https://www.google.com/analytics/)
+make sure to select the **mobile app** option, not the website option.
+
+## For Flutter apps
+
+Flutter applications can use the `AnalyticsIO` version of this library. They will need
+to specify the documents directory in the constructor in order to tell the library where
+to save the analytics preferences:
+
+```dart
+import 'package:flutter/services.dart';
+import 'package:usage/usage_io.dart';
+
+void main() {
+ final String UA = ...;
+
+ Analytics ga = new AnalyticsIO(UA, 'ga_test', '3.0',
+ documentsDirectory: PathProvider.getApplicationDocumentsDirectory());
+ ...
+}
+```
+
## For command-line apps
To use this library as a command-line app, import the `usage_io.dart` library
@@ -30,9 +52,15 @@ have completed, or until the specified duration has elapsed. So, CLI apps can do
something like:
```dart
-analytics.waitForLastPing(timeout: new Duration(milliseconds: 500)).then((_) {
- exit(0);
-});
+await analytics.waitForLastPing(timeout: new Duration(milliseconds: 200));
+analytics.close();
+```
+
+or:
+
+```dart
+await analytics.waitForLastPing(timeout: new Duration(milliseconds: 200));
+exit(0);
```
## Using the API
@@ -48,7 +76,7 @@ And call some analytics code:
```dart
final String UA = ...;
-Analytics ga = new AnalyticsIO(UA, 'ga_test', '1.0');
+Analytics ga = new AnalyticsIO(UA, 'ga_test', '3.0');
ga.optIn = true;
ga.sendScreenView('home');
@@ -61,21 +89,17 @@ ga.sendTiming('readTime', 20);
## When do we send analytics data?
-We use an opt-in method for sending analytics information. There are essentially
-three states for when we send information:
-
-*Sending screen views* If the user has not opted in, the library will only send
-information about screen views. This allows tools to do things like version
-checks, but does not send any additional information.
+You can use this library in an opt-in manner or an opt-out one. It defaults to
+opt-out - data will be sent to Google Analytics unless the user explicitly
+opts-out. The mode can be adjusted by changing the value of the
+`Analytics.analyticsOpt` field.
-*Opt-in* If the user opts-in to analytics collection the library sends all
-requested analytics info. This includes screen views, events, timing
-information, and exceptions.
+*Opt-out* In opt-out mode, if the user does not explicitly opt-out of collecting
+analytics (`Analytics.enabled = false`), the usage library will send usage data.
-*Opt-ing out* In order to not send analytics information, either do not call the
-analytics methods, or create and use the `AnalyticsMock` class. This provides
-an instance you can use in place of a real analytics object but each analytics
-method is a no-op.
+*Opt-in* In opt-in mode, no data will be sent until the user explicitly opt-in
+to collection (`Analytics.enabled = true`). This includes screen views, events,
+timing information, and exceptions.
## Other info
@@ -92,6 +116,10 @@ mobile app style tracking IDs (as opposed to the web site style tracking IDs).
For more information, please see the Google Analytics Measurement Protocol
[Policy](https://developers.google.com/analytics/devguides/collection/protocol/policy).
+## Contributing
+
+Tests can be run using `pub run test`.
+
## Issues and bugs
Please file reports on the
« no previous file with comments | « packages/usage/pubspec.yaml ('k') | packages/usage/test/all.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698