mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
Remove pkg:microlytics
Never used, not touched in 4+ years Change-Id: Ia1568969b2d07c56b5cbe3258e6a13e10b80813d Reviewed-on: https://dart-review.googlesource.com/c/86941 Reviewed-by: Devon Carew <devoncarew@google.com> Commit-Queue: Kevin Moore <kevmoo@google.com>
This commit is contained in:
parent
e6aec46b5f
commit
1337062779
|
@ -61,7 +61,6 @@ logging:third_party/pkg/logging/lib
|
|||
markdown:third_party/pkg/markdown/lib
|
||||
matcher:third_party/pkg/matcher/lib
|
||||
meta:pkg/meta/lib
|
||||
microlytics:pkg/microlytics/lib
|
||||
mime:third_party/pkg/mime/lib
|
||||
mockito:third_party/pkg/mockito/lib
|
||||
mustache4dart:third_party/pkg/mustache4dart/lib
|
||||
|
|
|
@ -71,9 +71,6 @@ Future main(List<String> arguments) async {
|
|||
await compileModule('expect', libs: ['minitest']);
|
||||
await compileModule('js', libs: ['js_util']);
|
||||
await compileModule('meta');
|
||||
if (isTravis) {
|
||||
await compileModule('microlytics', libs: ['html_channels']);
|
||||
}
|
||||
|
||||
// Under third_party/pkg.
|
||||
await compileModule('collection');
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
// 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.
|
||||
|
||||
import 'package:microlytics/channels.dart';
|
||||
import 'package:microlytics/io_channels.dart';
|
||||
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);
|
||||
|
||||
if (arguments.length != 1) {
|
||||
print("usage: dart simple.dart GA-Client-ID");
|
||||
return;
|
||||
}
|
||||
final String clientID = arguments.single;
|
||||
|
||||
// Create the logger.
|
||||
var lg = new AnalyticsLogger(channel, "555", clientID, "test", "1.2");
|
||||
|
||||
// Send some messages.
|
||||
lg.logAnonymousEvent("hello", "world");
|
||||
lg.logAnonymousTiming("loader", "var", 42);
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
// 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.channels;
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
const String ANALYTICS_URL = "https://ssl.google-analytics.com/collect";
|
||||
|
||||
abstract class Channel {
|
||||
void sendData(String data);
|
||||
void shutdown() {}
|
||||
}
|
||||
|
||||
/// [Channel] that implements a leaky bucket
|
||||
/// algorithm to provide rate limiting.
|
||||
/// See [http://en.wikipedia.org/wiki/Leaky_bucket].
|
||||
class RateLimitingBufferedChannel extends Channel {
|
||||
final List<String> _buffer = <String>[];
|
||||
final Channel _innerChannel;
|
||||
final int _bufferSizeLimit;
|
||||
Timer _timer;
|
||||
|
||||
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.");
|
||||
}
|
||||
|
||||
int transmitDelay = (1000 / packetsPerSecond).floor();
|
||||
_timer = new Timer.periodic(
|
||||
new Duration(milliseconds: transmitDelay), _onTimerTick);
|
||||
}
|
||||
|
||||
void _onTimerTick(_) {
|
||||
if (_buffer.length > 0) {
|
||||
String item = _buffer.removeLast();
|
||||
_innerChannel.sendData(item);
|
||||
}
|
||||
}
|
||||
|
||||
void sendData(String data) {
|
||||
if (_buffer.length >= _bufferSizeLimit) return;
|
||||
_buffer.add(data);
|
||||
}
|
||||
|
||||
void shutdown() {
|
||||
_timer.cancel();
|
||||
_innerChannel.shutdown();
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
// 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.html_channels;
|
||||
|
||||
import 'dart:html';
|
||||
import 'channels.dart';
|
||||
|
||||
class HttpRequestChannel extends Channel {
|
||||
void sendData(String data) {
|
||||
HttpRequest.request(ANALYTICS_URL, method: "POST", sendData: data);
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
// 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.io_channels;
|
||||
|
||||
import 'dart:io';
|
||||
import 'channels.dart';
|
||||
|
||||
class HttpClientChannel extends Channel {
|
||||
void sendData(String data) {
|
||||
HttpClient client = new HttpClient();
|
||||
client.postUrl(Uri.parse(ANALYTICS_URL)).then((HttpClientRequest req) {
|
||||
req.write(data);
|
||||
return req.close();
|
||||
}).then((HttpClientResponse response) {
|
||||
response.drain();
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
// 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");
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
# 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.
|
||||
|
||||
name: microlytics
|
||||
description: A minimal implementation of the Analytics API in pure Dart
|
||||
dev_dependencies:
|
||||
unittest: any
|
|
@ -1,114 +0,0 @@
|
|||
// 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.test;
|
||||
|
||||
import 'package:expect/expect.dart';
|
||||
import 'package:microlytics/microlytics.dart';
|
||||
|
||||
import 'test_channel.dart';
|
||||
|
||||
void main() {
|
||||
testBasicEventRead();
|
||||
testBasicNegativeEventRead();
|
||||
testBasicTimingRead();
|
||||
testBasicTimingMultiread();
|
||||
}
|
||||
|
||||
void testBasicEventRead() {
|
||||
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"
|
||||
"&tid=UA-53895644-1"
|
||||
"&cid=2cfac780-31e2-11e4-8c21-0800200c9a66"
|
||||
"&an=TestApp"
|
||||
"&av=0.42"
|
||||
"&t=event"
|
||||
"&ec=video"
|
||||
"&ea=play"));
|
||||
}
|
||||
|
||||
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"));
|
||||
}
|
||||
|
||||
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"));
|
||||
}
|
||||
|
||||
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"));
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
// 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.test_channel;
|
||||
|
||||
import 'package:microlytics/channels.dart';
|
||||
|
||||
class TestChannel extends Channel {
|
||||
List<String> _channelLog = [];
|
||||
|
||||
void sendData(String data) {
|
||||
_channelLog.add(data);
|
||||
}
|
||||
|
||||
bool contains(String data) {
|
||||
return _channelLog.contains(data);
|
||||
}
|
||||
}
|
|
@ -1534,11 +1534,6 @@
|
|||
"script": "out/ReleaseX64/dart-sdk/bin/dartanalyzer",
|
||||
"arguments": ["--fatal-warnings", "pkg/meta"]
|
||||
},
|
||||
{
|
||||
"name": "analyze pkg/microlytics",
|
||||
"script": "out/ReleaseX64/dart-sdk/bin/dartanalyzer",
|
||||
"arguments": ["--fatal-warnings", "pkg/microlytics"]
|
||||
},
|
||||
{
|
||||
"name": "analyze pkg/smith",
|
||||
"script": "out/ReleaseX64/dart-sdk/bin/dartanalyzer",
|
||||
|
|
Loading…
Reference in a new issue