Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
163cce7
Merge branch 'main' into feature/unified-api
marandaneto Oct 14, 2020
b91c954
Merge branch 'main' into feature/unified-api
marandaneto Oct 14, 2020
5018978
feat : static SDK main entry withSentry.init(options),... (#108)
rxlabz Oct 14, 2020
d577e35
Feat : add a Hub class (#113)
rxlabz Oct 19, 2020
fabf56f
feat: sentry options (#116)
marandaneto Oct 20, 2020
2b36bec
ref: Hub passes the Scope (#114)
marandaneto Oct 20, 2020
af3ecc0
Refacto : initialize SentryClient with SentryOptions (#118)
rxlabz Oct 20, 2020
19f5592
ref: SentryId generates UUID (#119)
marandaneto Oct 21, 2020
b51b0da
ref: Event now is SentryEvent and added GPU (#121)
marandaneto Oct 22, 2020
3fa0b79
feat: before breadcrumb and scope ref (#122)
marandaneto Oct 22, 2020
2cc1d78
Ref: Hint is passed across Sentry static class, Hub and Client (#124)
marandaneto Oct 22, 2020
11b821b
Ref: Remove stackFrameFilter in favor of beforeSendCallback (#125)
marandaneto Oct 22, 2020
ee737a2
Ref: Sentry init with null and empty DSN and close method (#126)
marandaneto Oct 22, 2020
eab4ccf
Refacto : add a Transport class (#123)
rxlabz Oct 23, 2020
c301ec6
Ref: execute before send callback (#128)
marandaneto Oct 24, 2020
1794f04
feat: addBreadcrumb to the Sentry static API (#133)
marandaneto Oct 26, 2020
e7db5d1
Feat: add lastEventId to the Sentry static API (#134)
marandaneto Oct 26, 2020
dc962ae
Fix: Breadcrumb data should accept serializable types and not only St…
marandaneto Oct 26, 2020
b9cd68b
Fix: NoOp encode for Web (#138)
marandaneto Oct 26, 2020
7b81890
Fix: execute Integrations on Hub creation (#136)
marandaneto Oct 26, 2020
b1761f4
unified api fixes and add web example (#137)
rxlabz Oct 27, 2020
d249c97
Ref/prepare event & scope.applyToEvent (#140)
rxlabz Oct 27, 2020
dc258d9
Ref : rename files accordely to their content (#141)
rxlabz Oct 27, 2020
c6669c3
rename the `throwable` argument to `exception` (#142)
rxlabz Oct 27, 2020
a0bb939
lint : prefer relative imports and show error when a @required argume…
rxlabz Oct 27, 2020
a7ca364
fix: Unified API code review (#144)
marandaneto Oct 28, 2020
56ac62a
Ref : remove dsn from Transport public API (#145)
rxlabz Oct 28, 2020
209f18a
Fix the pubspecs SDK constraints (#146)
rxlabz Oct 28, 2020
108ac6c
fix : throws on invalid dsn (#148)
rxlabz Oct 28, 2020
a81da3e
add comment to change the DSN
marandaneto Oct 28, 2020
c1812b7
update the workflow to run both on vm and on browser (#150)
rxlabz Oct 28, 2020
f597604
Bump sentry sdk to 4.0.0-alpha.1 (#151)
marandaneto Oct 28, 2020
6d9caff
remove TODOs
marandaneto Oct 28, 2020
32debd7
fix the web example pubspec (#153)
rxlabz Oct 28, 2020
c80365f
Ref: remove platform specific clients to use SentryClient (#152)
rxlabz Oct 29, 2020
2ed0f92
fix conflict
marandaneto Oct 29, 2020
c3ab59f
rewrite changelog
marandaneto Oct 29, 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
Fix: execute Integrations on Hub creation (#136)
  • Loading branch information
marandaneto authored Oct 26, 2020
commit 7b818907946bcfa3c1f3d8e373777477b7ce93f5
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
- Ref: execute before send callback
- Feat: add lastEventId to the Sentry static API
- Feat: addBreadcrumb on Static API
- Fix: Integrations are executed on Hub creation
- Fix: NoOp encode for Web
- Fix: Breadcrumb data should accept serializable types and not only String values

Expand Down
7 changes: 7 additions & 0 deletions dart/lib/src/hub.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'dart:async';
import 'dart:collection';

import 'package:sentry/src/hub_adapter.dart';

import 'client.dart';
import 'noop_client.dart';
import 'protocol.dart';
Expand Down Expand Up @@ -31,6 +33,11 @@ class Hub {
Hub._(SentryOptions options) : _options = options {
_stack.add(_StackItem(_getClient(_options), Scope(_options)));
_isEnabled = true;

// execute integrations
options.integrations.forEach((integration) {
integration(HubAdapter(), _options);
});
}

static void _validateOptions(SentryOptions options) {
Expand Down
74 changes: 74 additions & 0 deletions dart/lib/src/hub_adapter.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import 'package:sentry/src/protocol/sentry_level.dart';
import 'package:sentry/src/protocol/sentry_id.dart';
import 'package:sentry/src/protocol/sentry_event.dart';
import 'package:sentry/src/protocol/breadcrumb.dart';
import 'package:sentry/src/client.dart';
import 'package:sentry/src/sentry.dart';
import 'hub.dart';
import 'dart:async';

/// Hub adapter to make Integrations testable
class HubAdapter implements Hub {
HubAdapter._();

static final HubAdapter _instance = HubAdapter._();

factory HubAdapter() {
return _instance;
}

@override
void addBreadcrumb(Breadcrumb crumb, {dynamic hint}) =>
Sentry.addBreadcrumb(crumb, hint: hint);

@override
void bindClient(SentryClient client) => Sentry.bindClient(client);

@override
Future<SentryId> captureEvent(SentryEvent event, {dynamic hint}) =>
Sentry.captureEvent(event, hint: hint);

@override
Future<SentryId> captureException(
dynamic throwable, {
dynamic stackTrace,
dynamic hint,
}) =>
Sentry.captureException(
throwable,
stackTrace: stackTrace,
hint: hint,
);

@override
Future<SentryId> captureMessage(
String message, {
SentryLevel level = SentryLevel.info,
String template,
List params,
dynamic hint,
}) =>
Sentry.captureMessage(
message,
level: level,
template: template,
params: params,
hint: hint,
);

@override
Hub clone() => Sentry.clone();

@override
void close() => Sentry.close();

@override
void configureScope(ScopeCallback callback) =>
Sentry.configureScope(callback);

@override
bool get isEnabled => Sentry.isEnabled;

@override
SentryId get lastEventId => Sentry.lastEventId;
}
57 changes: 33 additions & 24 deletions dart/lib/src/sentry.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,38 +51,35 @@ class Sentry {
static Future<SentryId> captureEvent(
SentryEvent event, {
dynamic hint,
}) async {
return currentHub.captureEvent(event, hint: hint);
}
}) async =>
currentHub.captureEvent(event, hint: hint);

/// Reports the [exception] and optionally its [stackTrace] to Sentry.io.
static Future<SentryId> captureException(
dynamic error, {
dynamic throwable, {
dynamic stackTrace,
dynamic hint,
}) async {
return currentHub.captureException(
error,
stackTrace: stackTrace,
hint: hint,
);
}
}) async =>
currentHub.captureException(
throwable,
stackTrace: stackTrace,
hint: hint,
);

Future<SentryId> captureMessage(
static Future<SentryId> captureMessage(
String message, {
SentryLevel level,
String template,
List<dynamic> params,
dynamic hint,
}) async {
return currentHub.captureMessage(
message,
level: level,
template: template,
params: params,
hint: hint,
);
}
}) async =>
currentHub.captureMessage(
message,
level: level,
template: template,
params: params,
hint: hint,
);

/// Close the client SDK
static void close() {
Expand All @@ -98,20 +95,32 @@ class Sentry {
static SentryId get lastEventId => currentHub.lastEventId;

/// Adds a breacrumb to the current Scope
static void addBreadcrumb(Breadcrumb crumb, {dynamic hint}) {
currentHub.addBreadcrumb(crumb, hint: hint);
}
static void addBreadcrumb(Breadcrumb crumb, {dynamic hint}) =>
currentHub.addBreadcrumb(crumb, hint: hint);

/// Configures the scope through the callback.
static void configureScope(ScopeCallback callback) =>
currentHub.configureScope(callback);

/// Clones the current Hub
static Hub clone() => currentHub.clone();

/// Binds a different client to the current hub
static void bindClient(SentryClient client) => currentHub.bindClient(client);

static bool _setDefaultConfiguration(SentryOptions options) {
// if DSN is null, let's crash the App.
if (options.dsn == null) {
throw ArgumentError.notNull(
'DSN is required. Use empty string to disable SDK.');
}
// if the DSN is empty, let's disable the SDK
if (options.dsn.isEmpty) {
close();
return false;
}

// if logger os NoOp, let's set a logger that prints on the console
if (options.debug && options.logger == noOpLogger) {
options.logger = dartLogger;
}
Expand Down
10 changes: 10 additions & 0 deletions dart/test/hub_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:mockito/mockito.dart';
import 'package:sentry/sentry.dart';
import 'package:sentry/src/hub.dart';
import 'package:test/test.dart';
import 'dart:async';

import 'mocks.dart';

Expand Down Expand Up @@ -95,6 +96,15 @@ void main() {
final returnedId = await hub.captureEvent(event);
expect(eventId.toString(), returnedId.toString());
});

test('should install integrations', () {
var called = false;
void integration(Hub hub, SentryOptions options) => called = true;
options.addIntegration(integration);
Hub(options);

expect(called, true);
});
});

group('Hub scope', () {
Expand Down