Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
9da80217
Unverified
Commit
9da80217
authored
Jun 20, 2018
by
Yegor
Committed by
GitHub
Jun 20, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make crash server URL customizable from environment (#18649)
parent
97e58ecb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
8 deletions
+64
-8
crash_reporting.dart
packages/flutter_tools/lib/src/crash_reporting.dart
+25
-8
crash_reporting_test.dart
packages/flutter_tools/test/crash_reporting_test.dart
+39
-0
No files found.
packages/flutter_tools/lib/src/crash_reporting.dart
View file @
9da80217
...
...
@@ -37,14 +37,17 @@ const String _kStackTraceFileField = 'DartError';
const
String
_kStackTraceFilename
=
'stacktrace_file'
;
/// Sends crash reports to Google.
///
/// There are two ways to override the behavior of this class:
///
/// * Define a `FLUTTER_CRASH_SERVER_BASE_URL` environment variable that points
/// to a custom crash reporting server. This is useful if your development
/// environment is behind a firewall and unable to send crash reports to
/// Google, or when you wish to use your own server for collecting crash
/// reports from Flutter Tools.
/// * In tests call [initializeWith] and provide a mock implementation of
/// [http.Client].
class
CrashReportSender
{
static
final
Uri
_baseUri
=
new
Uri
(
scheme:
'https'
,
host:
_kCrashServerHost
,
port:
443
,
path:
_kCrashEndpointPath
,
);
static
CrashReportSender
_instance
;
CrashReportSender
.
_
(
this
.
_client
);
...
...
@@ -60,6 +63,20 @@ class CrashReportSender {
final
http
.
Client
_client
;
final
Usage
_usage
=
Usage
.
instance
;
Uri
get
_baseUrl
{
final
String
overrideUrl
=
platform
.
environment
[
'FLUTTER_CRASH_SERVER_BASE_URL'
];
if
(
overrideUrl
!=
null
)
{
return
Uri
.
parse
(
overrideUrl
);
}
return
new
Uri
(
scheme:
'https'
,
host:
_kCrashServerHost
,
port:
443
,
path:
_kCrashEndpointPath
,
);
}
/// Sends one crash report.
///
/// The report is populated from data in [error] and [stackTrace].
...
...
@@ -75,7 +92,7 @@ class CrashReportSender {
printStatus
(
'Sending crash report to Google.'
);
final
String
flutterVersion
=
getFlutterVersion
();
final
Uri
uri
=
_baseUr
i
.
replace
(
final
Uri
uri
=
_baseUr
l
.
replace
(
queryParameters:
<
String
,
String
>{
'product'
:
_kProductId
,
'version'
:
flutterVersion
,
...
...
packages/flutter_tools/test/crash_reporting_test.dart
View file @
9da80217
...
...
@@ -120,6 +120,45 @@ void main() {
},
overrides:
<
Type
,
Generator
>{
Stdio:
()
=>
const
_NoStderr
(),
});
testUsingContext
(
'can override base URL'
,
()
async
{
Uri
uri
;
CrashReportSender
.
initializeWith
(
new
MockClient
((
Request
request
)
async
{
uri
=
request
.
url
;
return
new
Response
(
'test-report-id'
,
200
);
}));
final
int
exitCode
=
await
tools
.
run
(
<
String
>[
'crash'
],
<
FlutterCommand
>[
new
_CrashCommand
()],
reportCrashes:
true
,
flutterVersion:
'test-version'
,
);
expect
(
exitCode
,
1
);
// Verify that we sent the crash report.
expect
(
uri
,
isNotNull
);
expect
(
uri
,
new
Uri
(
scheme:
'https'
,
host:
'localhost'
,
port:
12345
,
path:
'/fake_server'
,
queryParameters:
<
String
,
String
>{
'product'
:
'Flutter_Tools'
,
'version'
:
'test-version'
,
},
));
},
overrides:
<
Type
,
Generator
>
{
Platform:
()
=>
new
FakePlatform
(
operatingSystem:
'linux'
,
environment:
<
String
,
String
>{
'FLUTTER_CRASH_SERVER_BASE_URL'
:
'https://localhost:12345/fake_server'
,
},
script:
new
Uri
(
scheme:
'data'
),
),
Stdio:
()
=>
const
_NoStderr
(),
});
});
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment