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

Side by Side Diff: packages/usage/readme.md

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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 unified diff | Download patch
« no previous file with comments | « packages/usage/pubspec.yaml ('k') | packages/usage/test/all.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # usage
2
3 `usage` is a wrapper around Google Analytics for both command-line apps and web
4 apps.
5
6 [![Build Status](https://travis-ci.org/dart-lang/usage.svg)](https://travis-ci.o rg/dart-lang/usage)
7 [![Coverage Status](https://img.shields.io/coveralls/dart-lang/usage.svg)](https ://coveralls.io/r/dart-lang/usage?branch=master)
8
9 ## For web apps
10
11 To use this library as a web app, import the `usage_html.dart` library and
12 instantiate the `AnalyticsHtml` class.
13
14 ## For command-line apps
15
16 To use this library as a command-line app, import the `usage_io.dart` library
17 and instantiate the `AnalyticsIO` class.
18
19 Note, for CLI apps, the usage library will send analytics pings asynchronously.
20 This is useful it that it doesn't block the app generally. It does have one
21 side-effect, in that outstanding asynchronous requests will block termination
22 of the VM until that request finishes. So, for short-lived CLI tools, pinging
23 Google Analytics can cause the tool to pause for several seconds before it
24 terminates. This is often undesired - gathering analytics information shouldn't
25 negatively effect the tool's UX.
26
27 One solution to this is to use the `waitForLastPing({Duration timeout})` method
28 on the analytics object. This will wait until all outstanding analytics requests
29 have completed, or until the specified duration has elapsed. So, CLI apps can do
30 something like:
31
32 ```dart
33 analytics.waitForLastPing(timeout: new Duration(milliseconds: 500)).then((_) {
34 exit(0);
35 });
36 ```
37
38 ## Using the API
39
40 Import the package (in this example we use the `dart:io` version):
41
42 ```dart
43 import 'package:usage/usage_io.dart';
44 ```
45
46 And call some analytics code:
47
48 ```dart
49 final String UA = ...;
50
51 Analytics ga = new AnalyticsIO(UA, 'ga_test', '1.0');
52 ga.optIn = true;
53
54 ga.sendScreenView('home');
55 ga.sendException('foo exception');
56
57 ga.sendScreenView('files');
58 ga.sendTiming('writeTime', 100);
59 ga.sendTiming('readTime', 20);
60 ```
61
62 ## When do we send analytics data?
63
64 We use an opt-in method for sending analytics information. There are essentially
65 three states for when we send information:
66
67 *Sending screen views* If the user has not opted in, the library will only send
68 information about screen views. This allows tools to do things like version
69 checks, but does not send any additional information.
70
71 *Opt-in* If the user opts-in to analytics collection the library sends all
72 requested analytics info. This includes screen views, events, timing
73 information, and exceptions.
74
75 *Opt-ing out* In order to not send analytics information, either do not call the
76 analytics methods, or create and use the `AnalyticsMock` class. This provides
77 an instance you can use in place of a real analytics object but each analytics
78 method is a no-op.
79
80 ## Other info
81
82 For both classes, you need to provide a Google Analytics tracking ID, the
83 application name, and the application version.
84
85 Your application should provide an opt-in option for the user. If they opt-in,
86 set the `optIn` field to `true`. This setting will persist across sessions
87 automatically.
88
89 *Note:* This library is intended for use with the Google Analytics application /
90 mobile app style tracking IDs (as opposed to the web site style tracking IDs).
91
92 For more information, please see the Google Analytics Measurement Protocol
93 [Policy](https://developers.google.com/analytics/devguides/collection/protocol/p olicy).
94
95 ## Issues and bugs
96
97 Please file reports on the
98 [GitHub Issue Tracker](https://github.com/dart-lang/usage/issues).
99
100 ## License
101
102 You can view our license
103 [here](https://github.com/dart-lang/usage/blob/master/LICENSE).
OLDNEW
« 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