Migrate package:telemetry
Change-Id: I1d06861b5838a12b807d47cfbb53b0537a68d52f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/194205 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
0fa7878d56
commit
625bfe5cae
@@ -11,7 +11,7 @@
|
||||
"constraint, update this by running tools/generate_package_config.dart."
|
||||
],
|
||||
"configVersion": 2,
|
||||
"generated": "2021-04-06T11:20:39.965073",
|
||||
"generated": "2021-04-06T16:51:44.463801",
|
||||
"generator": "tools/generate_package_config.dart",
|
||||
"packages": [
|
||||
{
|
||||
@@ -659,7 +659,7 @@
|
||||
"name": "telemetry",
|
||||
"rootUri": "../pkg/telemetry",
|
||||
"packageUri": "lib/",
|
||||
"languageVersion": "1.0"
|
||||
"languageVersion": "2.12"
|
||||
},
|
||||
{
|
||||
"name": "term_glyph",
|
||||
@@ -727,12 +727,6 @@
|
||||
"packageUri": "lib/",
|
||||
"languageVersion": "2.12"
|
||||
},
|
||||
{
|
||||
"name": "uuid",
|
||||
"rootUri": "../third_party/pkg/uuid",
|
||||
"packageUri": "lib/",
|
||||
"languageVersion": "2.0"
|
||||
},
|
||||
{
|
||||
"name": "vector_math",
|
||||
"rootUri": "../third_party/pkg/vector_math",
|
||||
|
||||
@@ -54,7 +54,7 @@ class CrashReportSender {
|
||||
CrashReportSender._(
|
||||
this.crashProductId,
|
||||
this.shouldSend, {
|
||||
http.Client httpClient,
|
||||
http.Client? httpClient,
|
||||
String endpointPath = _crashEndpointPathStaging,
|
||||
}) : _httpClient = httpClient ?? new http.Client(),
|
||||
_baseUri = new Uri(
|
||||
@@ -64,7 +64,7 @@ class CrashReportSender {
|
||||
CrashReportSender.staging(
|
||||
String crashProductId,
|
||||
EnablementCallback shouldSend, {
|
||||
http.Client httpClient,
|
||||
http.Client? httpClient,
|
||||
}) : this._(crashProductId, shouldSend,
|
||||
httpClient: httpClient, endpointPath: _crashEndpointPathStaging);
|
||||
|
||||
@@ -72,7 +72,7 @@ class CrashReportSender {
|
||||
CrashReportSender.prod(
|
||||
String crashProductId,
|
||||
EnablementCallback shouldSend, {
|
||||
http.Client httpClient,
|
||||
http.Client? httpClient,
|
||||
}) : this._(crashProductId, shouldSend,
|
||||
httpClient: httpClient, endpointPath: _crashEndpointPathProd);
|
||||
|
||||
@@ -86,7 +86,7 @@ class CrashReportSender {
|
||||
dynamic error,
|
||||
StackTrace stackTrace, {
|
||||
List<CrashReportAttachment> attachments = const [],
|
||||
String comment,
|
||||
String? comment,
|
||||
}) async {
|
||||
if (!shouldSend()) {
|
||||
return;
|
||||
@@ -192,9 +192,9 @@ class CrashReportAttachment {
|
||||
final String _value;
|
||||
|
||||
CrashReportAttachment.string({
|
||||
@required String field,
|
||||
@required String value,
|
||||
}) : _field = field,
|
||||
required String field,
|
||||
required String value,
|
||||
}) : _field = field,
|
||||
_value = value;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,13 +14,10 @@ class ThrottlingBucket {
|
||||
final int bucketSize;
|
||||
final Duration replenishDuration;
|
||||
|
||||
int _drops;
|
||||
int _lastReplenish;
|
||||
late int _drops = bucketSize;
|
||||
late int _lastReplenish = new DateTime.now().millisecondsSinceEpoch;
|
||||
|
||||
ThrottlingBucket(this.bucketSize, this.replenishDuration) {
|
||||
_drops = bucketSize;
|
||||
_lastReplenish = new DateTime.now().millisecondsSinceEpoch;
|
||||
}
|
||||
ThrottlingBucket(this.bucketSize, this.replenishDuration);
|
||||
|
||||
bool removeDrop() {
|
||||
_checkReplenish();
|
||||
|
||||
@@ -59,7 +59,7 @@ Analytics createAnalyticsInstance(
|
||||
bool disableForSession = false,
|
||||
bool forceEnabled = false,
|
||||
}) {
|
||||
Directory dir = getDartStorageDirectory();
|
||||
final dir = getDartStorageDirectory();
|
||||
if (dir == null) {
|
||||
// Some systems don't support user home directories; for those, fail
|
||||
// gracefully by returning a disabled analytics object.
|
||||
@@ -95,7 +95,7 @@ Analytics createAnalyticsInstance(
|
||||
/// This can return null under some conditions, including when the user's home
|
||||
/// directory does not exist.
|
||||
@visibleForTesting
|
||||
Directory getDartStorageDirectory() {
|
||||
Directory? getDartStorageDirectory() {
|
||||
Directory homeDirectory = new Directory(userHomeDir());
|
||||
if (!homeDirectory.existsSync()) return null;
|
||||
|
||||
@@ -114,8 +114,8 @@ class _TelemetryAnalytics extends AnalyticsImpl {
|
||||
String applicationName,
|
||||
String applicationVersion,
|
||||
File settingsFile, {
|
||||
@required this.disableForSession,
|
||||
@required this.forceEnabled,
|
||||
required this.disableForSession,
|
||||
required this.forceEnabled,
|
||||
}) : super(
|
||||
trackingId,
|
||||
new IOPersistentProperties.fromFile(settingsFile),
|
||||
@@ -123,7 +123,7 @@ class _TelemetryAnalytics extends AnalyticsImpl {
|
||||
applicationName: applicationName,
|
||||
applicationVersion: applicationVersion,
|
||||
) {
|
||||
final String locale = getPlatformLocale();
|
||||
final locale = getPlatformLocale();
|
||||
if (locale != null) {
|
||||
setSessionValue('ul', locale);
|
||||
}
|
||||
@@ -141,7 +141,7 @@ class _TelemetryAnalytics extends AnalyticsImpl {
|
||||
}
|
||||
|
||||
// If there's no explicit setting (enabled or disabled) then we don't send.
|
||||
return (properties['enabled'] as bool) ?? false;
|
||||
return (properties['enabled'] as bool?) ?? false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ publish_to: none
|
||||
author: Dart Team <misc@dartlang.org>
|
||||
|
||||
environment:
|
||||
sdk: '>=1.0.0 <3.0.0'
|
||||
sdk: '>=2.12.0 <3.0.0'
|
||||
|
||||
dependencies:
|
||||
http: ^0.12.0
|
||||
|
||||
@@ -12,10 +12,10 @@ import 'package:usage/usage.dart';
|
||||
|
||||
void main() {
|
||||
group('CrashReportSender', () {
|
||||
MockClient mockClient;
|
||||
AnalyticsMock analytics;
|
||||
late MockClient mockClient;
|
||||
late AnalyticsMock analytics;
|
||||
|
||||
Request request;
|
||||
late Request request;
|
||||
|
||||
setUp(() {
|
||||
mockClient = new MockClient((Request r) async {
|
||||
|
||||
@@ -2,15 +2,13 @@
|
||||
// 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 'dart:io';
|
||||
|
||||
import 'package:telemetry/telemetry.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
group('telemetry', () {
|
||||
test('getDartStorageDirectory', () {
|
||||
Directory dir = getDartStorageDirectory();
|
||||
var dir = getDartStorageDirectory();
|
||||
expect(dir, isNotNull);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user