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

Side by Side Diff: pkg/microlytics/lib/microlytics.dart

Issue 2770573002: Run dartfmt on microlytics package. (Closed)
Patch Set: Created 3 years, 9 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 | « pkg/microlytics/lib/io_channels.dart ('k') | pkg/microlytics/test/dart_microlytics_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library microlytics; 5 library microlytics;
6 6
7 import 'channels.dart'; 7 import 'channels.dart';
8 8
9 /// Very limited implementation of an API to report usage to Google Analytics. 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. 10 /// No Personally Identifiable Information must ever be passed to this class.
11 class AnalyticsLogger { 11 class AnalyticsLogger {
12 final Channel _channel; 12 final Channel _channel;
13 final String _clientID; 13 final String _clientID;
14 final String _analyticsID; 14 final String _analyticsID;
15 final String _appName; 15 final String _appName;
16 final String _appVersion; 16 final String _appVersion;
17 final String _messagePrefix; //Computed prefix for analytics messages 17 final String _messagePrefix; //Computed prefix for analytics messages
18 18
19 /// Create a new logger 19 /// Create a new logger
20 /// [channel] represents how this is going to be sent, this would typically 20 /// [channel] represents how this is going to be sent, this would typically
21 /// be a [RateLimitingBufferedChannel] wrapping either a [HttpRequestChannel] 21 /// be a [RateLimitingBufferedChannel] wrapping either a [HttpRequestChannel]
22 /// or a [HttpClientChannel]. 22 /// or a [HttpClientChannel].
23 /// [clientID] is a version 4 UUID associated with the site or app. 23 /// [clientID] is a version 4 UUID associated with the site or app.
24 /// [appName] is an application name. 24 /// [appName] is an application name.
25 /// [appVersion] is a verion string. 25 /// [appVersion] is a verion string.
26 AnalyticsLogger(Channel channel, String clientID, String analyticsID, 26 AnalyticsLogger(Channel channel, String clientID, String analyticsID,
27 String appName, String appVersion) 27 String appName, String appVersion)
28 : this._channel = channel, 28 : this._channel = channel,
29 this._clientID = clientID, 29 this._clientID = clientID,
30 this._analyticsID = analyticsID, 30 this._analyticsID = analyticsID,
31 this._appName = appName, 31 this._appName = appName,
32 this._appVersion = appVersion, 32 this._appVersion = appVersion,
33 this._messagePrefix = 33 this._messagePrefix = "v=1"
34 "v=1" 34 "&tid=$analyticsID"
35 "&tid=$analyticsID" 35 "&cid=$clientID"
36 "&cid=$clientID" 36 "&an=$appName"
37 "&an=$appName" 37 "&av=$appVersion";
38 "&av=$appVersion";
39 38
40 void logAnonymousTiming(String category, String variable, int ms) { 39 void logAnonymousTiming(String category, String variable, int ms) {
41 category = Uri.encodeComponent(category); 40 category = Uri.encodeComponent(category);
42 variable = Uri.encodeComponent(variable); 41 variable = Uri.encodeComponent(variable);
43 _channel.sendData( 42 _channel.sendData("${this._messagePrefix}"
44 "${this._messagePrefix}"
45 "&t=timing" 43 "&t=timing"
46 "&utc=$category" 44 "&utc=$category"
47 "&utv=$variable" 45 "&utv=$variable"
48 "&utt=$ms"); 46 "&utt=$ms");
49 } 47 }
50 48
51 void logAnonymousEvent(String category, String event) { 49 void logAnonymousEvent(String category, String event) {
52 category = Uri.encodeComponent(category); 50 category = Uri.encodeComponent(category);
53 event = Uri.encodeComponent(event); 51 event = Uri.encodeComponent(event);
54 _channel.sendData( 52 _channel.sendData("${this._messagePrefix}"
55 "${this._messagePrefix}"
56 "&t=event" 53 "&t=event"
57 "&ec=$category" 54 "&ec=$category"
58 "&ea=$event"); 55 "&ea=$event");
59 } 56 }
60 } 57 }
61
OLDNEW
« no previous file with comments | « pkg/microlytics/lib/io_channels.dart ('k') | pkg/microlytics/test/dart_microlytics_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698