mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 16:41:07 +00:00
Run dartfmt on microlytics package.
BUG= R=lukechurch@google.com Review-Url: https://codereview.chromium.org/2770573002 .
This commit is contained in:
parent
e5c091e048
commit
7819a400bd
|
@ -8,8 +8,8 @@ import 'package:microlytics/microlytics.dart';
|
|||
|
||||
void main(List<String> arguments) {
|
||||
// Create the channel that will be used to communicate to analytics.
|
||||
var channel = new RateLimitingBufferedChannel(
|
||||
new HttpClientChannel(), packetsPerSecond: 1.0);
|
||||
var channel = new RateLimitingBufferedChannel(new HttpClientChannel(),
|
||||
packetsPerSecond: 1.0);
|
||||
|
||||
if (arguments.length != 1) {
|
||||
print("usage: dart simple.dart GA-Client-ID");
|
||||
|
|
|
@ -22,10 +22,8 @@ class RateLimitingBufferedChannel extends Channel {
|
|||
final int _bufferSizeLimit;
|
||||
Timer _timer;
|
||||
|
||||
RateLimitingBufferedChannel(
|
||||
this._innerChannel,
|
||||
{int bufferSizeLimit: 10,
|
||||
double packetsPerSecond: 1.0})
|
||||
RateLimitingBufferedChannel(this._innerChannel,
|
||||
{int bufferSizeLimit: 10, double packetsPerSecond: 1.0})
|
||||
: this._bufferSizeLimit = bufferSizeLimit {
|
||||
if (!(packetsPerSecond > 0)) {
|
||||
throw new ArgumentError("packetsPerSecond must be larger than zero.");
|
||||
|
|
|
@ -18,4 +18,3 @@ class HttpClientChannel extends Channel {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -26,22 +26,20 @@ class AnalyticsLogger {
|
|||
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";
|
||||
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}"
|
||||
_channel.sendData("${this._messagePrefix}"
|
||||
"&t=timing"
|
||||
"&utc=$category"
|
||||
"&utv=$variable"
|
||||
|
@ -51,11 +49,9 @@ class AnalyticsLogger {
|
|||
void logAnonymousEvent(String category, String event) {
|
||||
category = Uri.encodeComponent(category);
|
||||
event = Uri.encodeComponent(event);
|
||||
_channel.sendData(
|
||||
"${this._messagePrefix}"
|
||||
_channel.sendData("${this._messagePrefix}"
|
||||
"&t=event"
|
||||
"&ec=$category"
|
||||
"&ea=$event");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,16 +17,15 @@ void main() {
|
|||
}
|
||||
|
||||
void testBasicEventRead() {
|
||||
TestChannel c = new TestChannel();
|
||||
AnalyticsLogger logger = new AnalyticsLogger(
|
||||
TestChannel c = new TestChannel();
|
||||
AnalyticsLogger logger = new AnalyticsLogger(
|
||||
c,
|
||||
"2cfac780-31e2-11e4-8c21-0800200c9a66",
|
||||
"UA-53895644-1",
|
||||
"TestApp",
|
||||
"0.42");
|
||||
logger.logAnonymousEvent("video", "play");
|
||||
Expect.isTrue(c.contains(
|
||||
"v=1"
|
||||
logger.logAnonymousEvent("video", "play");
|
||||
Expect.isTrue(c.contains("v=1"
|
||||
"&tid=UA-53895644-1"
|
||||
"&cid=2cfac780-31e2-11e4-8c21-0800200c9a66"
|
||||
"&an=TestApp"
|
||||
|
@ -37,84 +36,79 @@ void testBasicEventRead() {
|
|||
}
|
||||
|
||||
void testBasicNegativeEventRead() {
|
||||
TestChannel c = new TestChannel();
|
||||
AnalyticsLogger logger = new AnalyticsLogger(
|
||||
c,
|
||||
"2cfac780-31e2-11e4-8c21-0800200c9a66",
|
||||
"UA-53895644-1",
|
||||
"TestApp",
|
||||
"0.42");
|
||||
logger.logAnonymousEvent("video", "play");
|
||||
Expect.isFalse(c.contains(
|
||||
"v=1"
|
||||
"&tid=UA-53895644-1"
|
||||
"&cid=2cfac780-31e2-11e4-8c21-0800200c9a66"
|
||||
"&an=TestApp"
|
||||
"&av=XXX"
|
||||
"&t=event"
|
||||
"&ec=video"
|
||||
"&ea=play"));
|
||||
TestChannel c = new TestChannel();
|
||||
AnalyticsLogger logger = new AnalyticsLogger(
|
||||
c,
|
||||
"2cfac780-31e2-11e4-8c21-0800200c9a66",
|
||||
"UA-53895644-1",
|
||||
"TestApp",
|
||||
"0.42");
|
||||
logger.logAnonymousEvent("video", "play");
|
||||
Expect.isFalse(c.contains("v=1"
|
||||
"&tid=UA-53895644-1"
|
||||
"&cid=2cfac780-31e2-11e4-8c21-0800200c9a66"
|
||||
"&an=TestApp"
|
||||
"&av=XXX"
|
||||
"&t=event"
|
||||
"&ec=video"
|
||||
"&ea=play"));
|
||||
}
|
||||
|
||||
void testBasicTimingRead() {
|
||||
TestChannel c = new TestChannel();
|
||||
AnalyticsLogger logger = new AnalyticsLogger(
|
||||
c,
|
||||
"2cfac780-31e2-11e4-8c21-0800200c9a66",
|
||||
"UA-53895644-1",
|
||||
"TestApp",
|
||||
"0.42");
|
||||
logger.logAnonymousTiming("video", "delay", 157);
|
||||
Expect.isTrue(c.contains(
|
||||
"v=1"
|
||||
"&tid=UA-53895644-1"
|
||||
"&cid=2cfac780-31e2-11e4-8c21-0800200c9a66"
|
||||
"&an=TestApp"
|
||||
"&av=0.42"
|
||||
"&t=timing"
|
||||
"&utc=video"
|
||||
"&utv=delay"
|
||||
"&utt=157"));
|
||||
TestChannel c = new TestChannel();
|
||||
AnalyticsLogger logger = new AnalyticsLogger(
|
||||
c,
|
||||
"2cfac780-31e2-11e4-8c21-0800200c9a66",
|
||||
"UA-53895644-1",
|
||||
"TestApp",
|
||||
"0.42");
|
||||
logger.logAnonymousTiming("video", "delay", 157);
|
||||
Expect.isTrue(c.contains("v=1"
|
||||
"&tid=UA-53895644-1"
|
||||
"&cid=2cfac780-31e2-11e4-8c21-0800200c9a66"
|
||||
"&an=TestApp"
|
||||
"&av=0.42"
|
||||
"&t=timing"
|
||||
"&utc=video"
|
||||
"&utv=delay"
|
||||
"&utt=157"));
|
||||
}
|
||||
|
||||
void testBasicTimingMultiread() {
|
||||
TestChannel c = new TestChannel();
|
||||
AnalyticsLogger logger = new AnalyticsLogger(
|
||||
c,
|
||||
"2cfac780-31e2-11e4-8c21-0800200c9a66",
|
||||
"UA-53895644-1",
|
||||
"TestApp",
|
||||
"0.42");
|
||||
logger.logAnonymousTiming("video", "delay", 159);
|
||||
logger.logAnonymousTiming("video", "delay", 152);
|
||||
Expect.isTrue(c.contains(
|
||||
"v=1"
|
||||
"&tid=UA-53895644-1"
|
||||
"&cid=2cfac780-31e2-11e4-8c21-0800200c9a66"
|
||||
"&an=TestApp"
|
||||
"&av=0.42"
|
||||
"&t=timing"
|
||||
"&utc=video"
|
||||
"&utv=delay"
|
||||
"&utt=152"));
|
||||
Expect.isTrue(c.contains(
|
||||
"v=1"
|
||||
"&tid=UA-53895644-1"
|
||||
"&cid=2cfac780-31e2-11e4-8c21-0800200c9a66"
|
||||
"&an=TestApp"
|
||||
"&av=0.42"
|
||||
"&t=timing"
|
||||
"&utc=video"
|
||||
"&utv=delay"
|
||||
"&utt=159"));
|
||||
Expect.isFalse(c.contains(
|
||||
"v=1"
|
||||
"&tid=UA-53895644-1"
|
||||
"&cid=2cfac780-31e2-11e4-8c21-0800200c9a66"
|
||||
"&an=TestApp"
|
||||
"&av=0.42"
|
||||
"&t=timing"
|
||||
"&utc=video"
|
||||
"&utv=delay"
|
||||
"&utt=19"));
|
||||
TestChannel c = new TestChannel();
|
||||
AnalyticsLogger logger = new AnalyticsLogger(
|
||||
c,
|
||||
"2cfac780-31e2-11e4-8c21-0800200c9a66",
|
||||
"UA-53895644-1",
|
||||
"TestApp",
|
||||
"0.42");
|
||||
logger.logAnonymousTiming("video", "delay", 159);
|
||||
logger.logAnonymousTiming("video", "delay", 152);
|
||||
Expect.isTrue(c.contains("v=1"
|
||||
"&tid=UA-53895644-1"
|
||||
"&cid=2cfac780-31e2-11e4-8c21-0800200c9a66"
|
||||
"&an=TestApp"
|
||||
"&av=0.42"
|
||||
"&t=timing"
|
||||
"&utc=video"
|
||||
"&utv=delay"
|
||||
"&utt=152"));
|
||||
Expect.isTrue(c.contains("v=1"
|
||||
"&tid=UA-53895644-1"
|
||||
"&cid=2cfac780-31e2-11e4-8c21-0800200c9a66"
|
||||
"&an=TestApp"
|
||||
"&av=0.42"
|
||||
"&t=timing"
|
||||
"&utc=video"
|
||||
"&utv=delay"
|
||||
"&utt=159"));
|
||||
Expect.isFalse(c.contains("v=1"
|
||||
"&tid=UA-53895644-1"
|
||||
"&cid=2cfac780-31e2-11e4-8c21-0800200c9a66"
|
||||
"&an=TestApp"
|
||||
"&av=0.42"
|
||||
"&t=timing"
|
||||
"&utc=video"
|
||||
"&utv=delay"
|
||||
"&utt=19"));
|
||||
}
|
Loading…
Reference in a new issue