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. | |
| 4 | |
| 5 library microlytics; | |
| 6 | |
| 7 import 'channels.dart'; | |
| 8 import 'io_channels.dart'; | |
| 9 | |
| 10 /// Very limited implementation of an API to report usage to Google Analytics. | |
| 11 /// No Personally Identifiable Information must ever be passed to this class. | |
| 12 class AnalyticsLogger { | |
| 13 final Channel _channel; | |
| 14 final String _clientID; | |
| 15 final String _analyticsID; | |
| 16 final String _appName; | |
| 17 final String _appVersion; | |
| 18 final String _messagePrefix; //Computed prefix for analytics messages | |
| 19 | |
| 20 /// Create a new logger | |
| 21 /// [_channel] represents how this is going to be sent, this would typically | |
|
danrubel
2014/09/03 11:19:48
Either remove the '_' on the comments to match the
lukechurch
2014/09/04 12:58:42
Done.
| |
| 22 /// be a [RateLimitingBufferedChannel] wrapping either a [HttpRequestChannel] | |
| 23 /// or a [HttpClientChannel]. | |
| 24 /// [_clientID] is a version 4 UUID associated with the site or app. | |
| 25 /// [_appName] is an application name. | |
| 26 /// [_appVersion] is a verion string. | |
| 27 AnalyticsLogger(channel, clientID, analyticsID, appName, appVersion) | |
|
danrubel
2014/09/03 11:19:48
all public API should be fully typed...
https://ww
lukechurch
2014/09/03 11:27:17
Arrg, yes, this was caused by the adjustment to us
| |
| 28 : this._channel = channel, | |
| 29 this._clientID = clientID, | |
| 30 this._analyticsID = analyticsID, | |
| 31 this._appName = appName, | |
| 32 this._appVersion = appVersion, | |
| 33 this._messagePrefix = | |
| 34 "v=1" | |
| 35 "&tid=$analyticsID" | |
| 36 "&cid=$clientID" | |
| 37 "&an=$appName" | |
| 38 "&av=$appVersion"; | |
| 39 | |
| 40 void logAnonymousTiming(String category, String variable, int ms) { | |
| 41 category = Uri.encodeComponent(category); | |
| 42 variable = Uri.encodeComponent(variable); | |
| 43 _channel.sendData( | |
| 44 "${this._messagePrefix}" | |
| 45 "&t=timing" | |
| 46 "&utc=$category" | |
| 47 "&utv=$variable" | |
| 48 "&utt=$ms"); | |
| 49 } | |
| 50 | |
| 51 void logAnonymousEvent(String category, String event) { | |
| 52 category = Uri.encodeComponent(category); | |
| 53 event = Uri.encodeComponent(event); | |
| 54 _channel.sendData( | |
| 55 "${this._messagePrefix}" | |
| 56 "&t=event" | |
| 57 "&ec=$category" | |
| 58 "&ea=$event"); | |
| 59 } | |
| 60 } | |
| 61 | |
| OLD | NEW |