Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
|
ahe
2014/09/02 13:44:24
Add line between copyright and library declaration
lukechurch
2014/09/03 11:27:16
Done.
| |
| 4 library microlytics; | |
| 5 | |
| 6 import 'channels.dart'; | |
| 7 import 'io_channels.dart'; | |
| 8 | |
| 9 /// Very limited implementation of an API to report usage to Google Analytics. | |
| 10 /// No Personally Identifiable Information must ever be passed to this class. | |
| 11 class AnalyticsLogger { | |
| 12 final Channel _channel; | |
| 13 final String _clientID; | |
| 14 final String _analyticsID; | |
| 15 final String _appName; | |
| 16 final String _appVersion; | |
| 17 | |
| 18 /// Create a new logger | |
| 19 /// [_channel] represents how this is going to be sent, this would typically | |
| 20 /// be a [RateLimitingBufferedChannel] wrapping either a [HttpRequestChannel] | |
| 21 /// or a [HttpClientChannel] | |
| 22 /// [_clientID] is a version 4 UUID associated with the particular site or app | |
| 23 /// [_appName] is an application name | |
| 24 /// [_appVersion] is a verion string | |
| 25 AnalyticsLogger( | |
| 26 this._channel, | |
| 27 this._clientID, | |
| 28 this._analyticsID, | |
| 29 this._appName, | |
| 30 this._appVersion); | |
| 31 | |
| 32 void logAnonymousTiming(String category, String variable, int ms) { | |
| 33 category = Uri.encodeComponent(category); | |
| 34 variable = Uri.encodeComponent(variable); | |
| 35 _channel.sendData( | |
| 36 "v=1" | |
| 37 "&tid=${this._analyticsID}" | |
| 38 "&cid=${this._clientID}" | |
| 39 "&t=timing" | |
| 40 "&utc=$category" | |
| 41 "&utv=$variable" | |
| 42 "&utt=$ms" | |
| 43 "&an=${this._appName}" | |
| 44 "&av=${this._appVersion}" | |
|
ahe
2014/09/02 13:44:24
Can you share (some of) this string between the tw
lukechurch
2014/09/02 19:52:37
Done.
| |
| 45 ); | |
|
ahe
2014/09/02 13:44:24
Move to previous line.
lukechurch
2014/09/02 19:52:37
Done.
| |
| 46 } | |
| 47 | |
| 48 void logAnonymousEvent(String category, String event) { | |
| 49 category = Uri.encodeComponent(category); | |
| 50 event = Uri.encodeComponent(event); | |
| 51 _channel.sendData( | |
| 52 "v=1" | |
| 53 "&tid=${this._analyticsID}" | |
| 54 "&cid=${this._clientID}" | |
| 55 "&t=event" | |
| 56 "&ec=$category" | |
| 57 "&ea=$event" | |
| 58 "&an=${this._appName}" | |
| 59 "&av=${this._appVersion}" | |
| 60 ); | |
|
ahe
2014/09/02 13:44:24
Move to previous line.
lukechurch
2014/09/02 19:52:37
Done.
| |
| 61 } | |
| 62 } | |
| 63 | |
| OLD | NEW |