Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
- Ref: rename sdk files accordely to their content
- chore: new analysis options rules
- Ref: rename the `throwable` argument name to `exception` in `captureEvents(...)`
- Ref : remove dsn from Transport public Api

# `package:sentry` changelog

Expand Down
7 changes: 3 additions & 4 deletions dart/lib/src/transport/http_transport.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import 'transport.dart';
class HttpTransport implements Transport {
final SentryOptions _options;

@visibleForTesting
final Dsn dsn;
final Dsn _dsn;

/// Use for browser stacktrace
final String _origin;
Expand All @@ -26,7 +25,7 @@ class HttpTransport implements Transport {
HttpTransport({@required SentryOptions options, String origin})
: _options = options,
_origin = origin,
dsn = Dsn.parse(options.dsn),
_dsn = Dsn.parse(options.dsn),
_headers = _buildHeaders(sdkIdentifier: options.sdk.identifier) {
_credentialBuilder = CredentialBuilder(
dsn: Dsn.parse(options.dsn),
Expand All @@ -46,7 +45,7 @@ class HttpTransport implements Transport {
);

final response = await _options.httpClient.post(
dsn.postUri,
_dsn.postUri,
headers: _credentialBuilder.configure(_headers),
body: body,
);
Expand Down
53 changes: 26 additions & 27 deletions dart/test/test_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import 'dart:convert';
import 'package:http/http.dart';
import 'package:http/testing.dart';
import 'package:sentry/sentry.dart';
import 'package:sentry/src/transport/http_transport.dart';
import 'package:test/test.dart';

const String testDsn = 'https://public:[email protected]/1';
Expand Down Expand Up @@ -89,8 +88,8 @@ Future testCaptureException(
expect('$sentryId', 'testeventid');
}

final transport = options.transport as HttpTransport;
expect(postUri, transport.dsn.postUri);
final dsn = Dsn.parse(options.dsn);
expect(postUri, dsn.postUri);

testHeaders(
headers,
Expand Down Expand Up @@ -181,66 +180,66 @@ void runTest({Codec<List<int>, List<int>> gzip, bool isWeb = false}) {
final options = SentryOptions(dsn: testDsn);
final client = SentryClient(options);

final transport = options.transport as HttpTransport;
final dsn = Dsn.parse(options.dsn);

expect(transport.dsn.uri, Uri.parse(testDsn));
expect(dsn.uri, Uri.parse(testDsn));
expect(
transport.dsn.postUri,
dsn.postUri,
'https://sentry.example.com/api/1/store/',
);
expect(transport.dsn.publicKey, 'public');
expect(transport.dsn.secretKey, 'secret');
expect(transport.dsn.projectId, '1');
expect(dsn.publicKey, 'public');
expect(dsn.secretKey, 'secret');
expect(dsn.projectId, '1');
await client.close();
});

test('can parse DSN without secret', () async {
final options = SentryOptions(dsn: _testDsnWithoutSecret);
final client = SentryClient(options);

final transport = options.transport as HttpTransport;
final dsn = Dsn.parse(options.dsn);

expect(transport.dsn.uri, Uri.parse(_testDsnWithoutSecret));
expect(dsn.uri, Uri.parse(_testDsnWithoutSecret));
expect(
transport.dsn.postUri,
dsn.postUri,
'https://sentry.example.com/api/1/store/',
);
expect(transport.dsn.publicKey, 'public');
expect(transport.dsn.secretKey, null);
expect(transport.dsn.projectId, '1');
expect(dsn.publicKey, 'public');
expect(dsn.secretKey, null);
expect(dsn.projectId, '1');
await client.close();
});

test('can parse DSN with path', () async {
final options = SentryOptions(dsn: _testDsnWithPath);
final client = SentryClient(options);

final transport = options.transport as HttpTransport;
final dsn = Dsn.parse(options.dsn);

expect(transport.dsn.uri, Uri.parse(_testDsnWithPath));
expect(dsn.uri, Uri.parse(_testDsnWithPath));
expect(
transport.dsn.postUri,
dsn.postUri,
'https://sentry.example.com/path/api/1/store/',
);
expect(transport.dsn.publicKey, 'public');
expect(transport.dsn.secretKey, 'secret');
expect(transport.dsn.projectId, '1');
expect(dsn.publicKey, 'public');
expect(dsn.secretKey, 'secret');
expect(dsn.projectId, '1');
await client.close();
});
test('can parse DSN with port', () async {
final options = SentryOptions(dsn: _testDsnWithPort);
final client = SentryClient(options);

final transport = options.transport as HttpTransport;
final dsn = Dsn.parse(options.dsn);

expect(transport.dsn.uri, Uri.parse(_testDsnWithPort));
expect(dsn.uri, Uri.parse(_testDsnWithPort));
expect(
transport.dsn.postUri,
dsn.postUri,
'https://sentry.example.com:8888/api/1/store/',
);
expect(transport.dsn.publicKey, 'public');
expect(transport.dsn.secretKey, 'secret');
expect(transport.dsn.projectId, '1');
expect(dsn.publicKey, 'public');
expect(dsn.secretKey, 'secret');
expect(dsn.projectId, '1');
await client.close();
});
test('sends client auth header without secret', () async {
Expand Down