-
-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/add-ignore-routes
* main: Add proxy support (#2192) Deserialize and serialize unknown fields (#2153) feat: add `ignoreTransactions` and ignoreErrors` #1391 (#2207) feat: add span level measurements #1855 (#2214)
- Loading branch information
Showing
77 changed files
with
1,805 additions
and
274 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import 'package:meta/meta.dart'; | ||
import 'package:http/http.dart'; | ||
|
||
import '../sentry_options.dart'; | ||
|
||
@internal | ||
ClientProvider getClientProvider() { | ||
return ClientProvider(); | ||
} | ||
|
||
@internal | ||
class ClientProvider { | ||
Client getClient(SentryOptions options) { | ||
return Client(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:http/http.dart'; | ||
import 'package:http/io_client.dart'; | ||
import 'package:meta/meta.dart'; | ||
|
||
import '../protocol.dart'; | ||
import '../protocol/sentry_proxy.dart'; | ||
import '../sentry_options.dart'; | ||
import 'client_provider.dart'; | ||
|
||
@internal | ||
ClientProvider getClientProvider() { | ||
return IoClientProvider( | ||
() { | ||
return HttpClient(); | ||
}, | ||
(user, pass) { | ||
return HttpClientBasicCredentials(user, pass); | ||
}, | ||
); | ||
} | ||
|
||
@internal | ||
class IoClientProvider implements ClientProvider { | ||
final HttpClient Function() _httpClient; | ||
final HttpClientCredentials Function(String, String) _httpClientCredentials; | ||
|
||
IoClientProvider(this._httpClient, this._httpClientCredentials); | ||
|
||
@override | ||
Client getClient(SentryOptions options) { | ||
final proxy = options.proxy; | ||
if (proxy == null) { | ||
return Client(); | ||
} | ||
final pac = proxy.toPacString(); | ||
if (proxy.type == SentryProxyType.socks) { | ||
options.logger( | ||
SentryLevel.warning, | ||
"Setting proxy '$pac' is not supported.", | ||
); | ||
return Client(); | ||
} | ||
options.logger( | ||
SentryLevel.info, | ||
"Setting proxy '$pac'", | ||
); | ||
final httpClient = _httpClient(); | ||
httpClient.findProxy = (url) => pac; | ||
|
||
final host = proxy.host; | ||
final port = proxy.port; | ||
final user = proxy.user; | ||
final pass = proxy.pass; | ||
|
||
if (host != null && port != null && user != null && pass != null) { | ||
httpClient.addProxyCredentials( | ||
host, | ||
port, | ||
'', | ||
_httpClientCredentials(user, pass), | ||
); | ||
} | ||
return IOClient(httpClient); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import 'dart:collection'; | ||
|
||
import 'package:meta/meta.dart'; | ||
|
||
@internal | ||
class AccessAwareMap<String, V> extends MapBase<String, V> { | ||
AccessAwareMap(this._map); | ||
|
||
final Map<String, V> _map; | ||
final Set<String> _accessedKeysWithValues = {}; | ||
|
||
Set<String> get accessedKeysWithValues => _accessedKeysWithValues; | ||
|
||
@override | ||
V? operator [](Object? key) { | ||
if (key is String && _map.containsKey(key)) { | ||
_accessedKeysWithValues.add(key); | ||
} | ||
return _map[key]; | ||
} | ||
|
||
@override | ||
void operator []=(String key, V value) { | ||
_map[key] = value; | ||
} | ||
|
||
@override | ||
void clear() { | ||
_map.clear(); | ||
_accessedKeysWithValues.clear(); | ||
} | ||
|
||
@override | ||
Iterable<String> get keys => _map.keys; | ||
|
||
@override | ||
V? remove(Object? key) { | ||
return _map.remove(key); | ||
} | ||
|
||
Map<String, dynamic>? notAccessed() { | ||
if (_accessedKeysWithValues.length == _map.length) { | ||
return null; | ||
} | ||
Map<String, dynamic> unknown = _map.keys | ||
.where((key) => !_accessedKeysWithValues.contains(key)) | ||
.fold<Map<String, dynamic>>({}, (map, key) { | ||
map[key] = _map[key]; | ||
return map; | ||
}); | ||
return unknown.isNotEmpty ? unknown : null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.