Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a10d740
remove the SentryResponse class
rxlabz Oct 21, 2020
623c904
refactor : add a Transport class
rxlabz Oct 21, 2020
0dcb613
refactor : move the clock initialization to Transport
rxlabz Oct 21, 2020
c97c98b
- refactor : applyScope
rxlabz Oct 21, 2020
477fdac
changelog
rxlabz Oct 21, 2020
b8fb322
fix merge conflicts
rxlabz Oct 22, 2020
fd92e3f
Merge branch 'feature/unified-api' into ref/transport
rxlabz Oct 22, 2020
0944c68
move the headers definition strategy to transport
rxlabz Oct 22, 2020
46829fc
- Instantiate Transport from options
rxlabz Oct 22, 2020
01d4e19
handle event dropping in event processors
rxlabz Oct 22, 2020
fbd001e
fix client._applyScope : merge event and scope tags and extra
rxlabz Oct 22, 2020
4d39531
remove client.toString()
rxlabz Oct 22, 2020
34fb528
fix a test
rxlabz Oct 22, 2020
2437fa4
Merge branch 'feature/unified-api' into ref/transport
rxlabz Oct 22, 2020
57798f5
handle the event serialization in the transport layer
rxlabz Oct 22, 2020
789e154
Merge remote-tracking branch 'origin/feature/unified-api' into ref/tr…
rxlabz Oct 22, 2020
1aa05d6
remove stackFrameFilter references
rxlabz Oct 22, 2020
9895142
Merge remote-tracking branch 'origin/feature/unified-api' into ref/tr…
rxlabz Oct 22, 2020
cb5e309
add a CredentialBuilder
rxlabz Oct 22, 2020
e563d2c
- headers configuration
rxlabz Oct 23, 2020
71b53c8
- fix scope.level precedence
rxlabz Oct 23, 2020
be3f0a2
buildHeaders and fix timestamp test
rxlabz Oct 23, 2020
43b798c
- add a isWeb helper to define the event.platform
rxlabz Oct 23, 2020
19dc91d
feat: apply sample rate
marandaneto Oct 23, 2020
cec1f21
changelog
marandaneto Oct 23, 2020
909d4f9
- add a isWeb helper to define the event.platform and sdkName
rxlabz Oct 23, 2020
8b600dc
- add a isWeb helper to define the event.platform and sdkName
rxlabz Oct 23, 2020
4ff58a6
Merge remote-tracking branch 'origin/feat/sample-rate' into ref/trans…
rxlabz Oct 23, 2020
5493e19
fix
marandaneto Oct 23, 2020
621d6c4
update tests
rxlabz Oct 23, 2020
e11f653
Merge remote-tracking branch 'origin/feat/sample-rate' into ref/trans…
rxlabz Oct 23, 2020
88526e2
remove the platform arg from Client ctor
rxlabz Oct 23, 2020
796b633
set client.options private
rxlabz Oct 23, 2020
fb8b9e0
remove event.platform redefinition
rxlabz Oct 23, 2020
1dbcba4
set options.sdk if null
rxlabz Oct 23, 2020
8b56bce
remove fields from Transport Api
rxlabz Oct 23, 2020
daeb29e
private version consts
rxlabz Oct 23, 2020
098d58c
remove transport from the Client ctor
rxlabz Oct 23, 2020
2833a94
remove options.environmentAttributes
rxlabz Oct 23, 2020
35671d4
event processing : platform
rxlabz Oct 23, 2020
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
Prev Previous commit
Next Next commit
add a CredentialBuilder
  • Loading branch information
rxlabz committed Oct 22, 2020
commit cb5e30955726a1b6ee3aba0fff602ca48c7b48a9
13 changes: 0 additions & 13 deletions dart/lib/src/protocol/dsn.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ class Dsn {
});

/// The Sentry.io public key for the project.
@visibleForTesting
final String publicKey;

/// The Sentry.io secret key for the project.
@visibleForTesting
final String secretKey;

/// The ID issued by Sentry.io to your project.
Expand Down Expand Up @@ -65,15 +63,4 @@ class Dsn {
uri: uri,
);
}

String buildAuthHeader({int timestamp, String clientId}) {
var header = 'Sentry sentry_version=6, sentry_client=$clientId, '
'sentry_timestamp=$timestamp, sentry_key=${publicKey}';

if (secretKey != null) {
header += ', sentry_secret=${secretKey}';
}

return header;
}
}
40 changes: 37 additions & 3 deletions dart/lib/src/transport/transport.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,25 @@ class Transport {

final Sdk sdk;

CredentialBuilder _credentialBuilder;

Transport({
@required SentryOptions options,
@required this.sdk,
@required this.platform,
this.origin,
}) : _options = options,
dsn = Dsn.parse(options.dsn);
dsn = Dsn.parse(options.dsn) {
_credentialBuilder = CredentialBuilder(
dsn: Dsn.parse(options.dsn),
clientId: sdk.identifier,
);
}

Future<SentryId> send(SentryEvent event) async {
final now = _options.clock();

var authHeader = dsn.buildAuthHeader(
timestamp: now.millisecondsSinceEpoch, clientId: sdk.identifier);
var authHeader = _credentialBuilder.build(now.millisecondsSinceEpoch);
final headers = buildHeaders(authHeader, sdk: sdk);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could be assigned to a private global field on the ctor body, so we don't need to do on every event


final data = _getEventData(
Expand Down Expand Up @@ -98,3 +104,31 @@ class Transport {
'platform': platform,
};
}

class CredentialBuilder {
final String authHeader;

CredentialBuilder({@required Dsn dsn, String clientId})
: authHeader = buildAuthHeader(
publicKey: dsn.publicKey,
secretKey: dsn.secretKey,
clientId: clientId,
);

String build(int timestamp) => '$authHeader, sentry_timestamp=$timestamp';

static String buildAuthHeader({
String publicKey,
String secretKey,
String clientId,
}) {
var header = 'Sentry sentry_version=6, sentry_client=$clientId, '
'sentry_key=${publicKey}';

if (secretKey != null) {
header += ', sentry_secret=${secretKey}';
}

return header;
}
}
9 changes: 5 additions & 4 deletions dart/test/test_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,16 @@ void testHeaders(
'Content-Type': 'application/json',
'X-Sentry-Auth': 'Sentry sentry_version=6, '
'sentry_client=$sdkName/$sdkVersion, '
'sentry_timestamp=${fakeClockProvider().millisecondsSinceEpoch}, '
'sentry_key=public'
'sentry_key=public, '
};

if (withSecret) {
expectedHeaders['X-Sentry-Auth'] += ', '
'sentry_secret=secret';
expectedHeaders['X-Sentry-Auth'] += 'sentry_secret=secret, ';
}

expectedHeaders['X-Sentry-Auth'] +=
'sentry_timestamp=${fakeClockProvider().millisecondsSinceEpoch}';

if (withUserAgent) {
expectedHeaders['User-Agent'] = '$sdkName/$sdkVersion';
}
Expand Down