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

Unified Diff: dart/pkg/microlytics/lib/microlytics.dart

Issue 515993003: Minimalistic analytics library used by Dart Server and try.dartlang.org (Closed) Base URL: https://github.com/lukechurch/dart-mircolytics.git@master
Patch Set: Address review comments Created 6 years, 3 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 | « dart/pkg/microlytics/lib/io_channels.dart ('k') | dart/pkg/microlytics/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: dart/pkg/microlytics/lib/microlytics.dart
diff --git a/dart/pkg/microlytics/lib/microlytics.dart b/dart/pkg/microlytics/lib/microlytics.dart
new file mode 100644
index 0000000000000000000000000000000000000000..84d89e3257d249b1067d103d3d6035033bdaa4ff
--- /dev/null
+++ b/dart/pkg/microlytics/lib/microlytics.dart
@@ -0,0 +1,61 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library microlytics;
+
+import 'channels.dart';
+
+/// Very limited implementation of an API to report usage to Google Analytics.
+/// No Personally Identifiable Information must ever be passed to this class.
+class AnalyticsLogger {
+ final Channel _channel;
+ final String _clientID;
+ final String _analyticsID;
+ final String _appName;
+ final String _appVersion;
+ final String _messagePrefix; //Computed prefix for analytics messages
+
+ /// Create a new logger
+ /// [channel] represents how this is going to be sent, this would typically
+ /// be a [RateLimitingBufferedChannel] wrapping either a [HttpRequestChannel]
+ /// or a [HttpClientChannel].
+ /// [clientID] is a version 4 UUID associated with the site or app.
+ /// [appName] is an application name.
+ /// [appVersion] is a verion string.
+ AnalyticsLogger(Channel channel, String clientID, String analyticsID,
+ String appName, String appVersion)
+ : this._channel = channel,
+ this._clientID = clientID,
+ this._analyticsID = analyticsID,
+ this._appName = appName,
+ this._appVersion = appVersion,
+ this._messagePrefix =
+ "v=1"
+ "&tid=$analyticsID"
+ "&cid=$clientID"
+ "&an=$appName"
+ "&av=$appVersion";
+
+ void logAnonymousTiming(String category, String variable, int ms) {
+ category = Uri.encodeComponent(category);
+ variable = Uri.encodeComponent(variable);
+ _channel.sendData(
+ "${this._messagePrefix}"
+ "&t=timing"
+ "&utc=$category"
+ "&utv=$variable"
+ "&utt=$ms");
+ }
+
+ void logAnonymousEvent(String category, String event) {
+ category = Uri.encodeComponent(category);
+ event = Uri.encodeComponent(event);
+ _channel.sendData(
+ "${this._messagePrefix}"
+ "&t=event"
+ "&ec=$category"
+ "&ea=$event");
+ }
+}
+
« no previous file with comments | « dart/pkg/microlytics/lib/io_channels.dart ('k') | dart/pkg/microlytics/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698