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
ref: Event now is SentryEvent and added GPU (#121)
  • Loading branch information
marandaneto authored Oct 22, 2020
commit b51b0dab39d5c39cdec6cb2a8f5da7dc8be4acf7
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
- Added Scope and Breadcrumb ring buffer #109
- Added Hub to SDK #113
- Ref: Hub passes the Scope to SentryClient
- Feat: sentry options #116
- Feature: sentry options #116
- Ref: SentryId generates UUID
- Ref: Event now is SentryEvent and added GPU

# `package:sentry` changelog

Expand Down
4 changes: 2 additions & 2 deletions dart/example/event_example.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:sentry/src/protocol.dart';

final event = Event(
loggerName: 'main',
final event = SentryEvent(
logger: 'main',
serverName: 'server.dart',
release: '1.4.0-preview.1',
environment: 'Test',
Expand Down
8 changes: 0 additions & 8 deletions dart/lib/src/browser_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import 'package:http/browser_client.dart';
import 'client.dart';
import 'protocol.dart';
import 'sentry_options.dart';
import 'utils.dart';
import 'version.dart';

SentryClient createSentryClient(SentryOptions options) =>
Expand All @@ -29,15 +28,8 @@ class SentryBrowserClient extends SentryClient {
///
/// If [httpClient] is provided, it is used instead of the default client to
/// make HTTP calls to Sentry.io. This is useful in tests.
///
/// If [clock] is provided, it is used to get time instead of the system
/// clock. This is useful in tests. Should be an implementation of [ClockProvider].
/// This parameter is dynamic to maintain backwards compatibility with
/// previous use of [Clock](https://pub.dartlang.org/documentation/quiver/latest/quiver.time/Clock-class.html)
/// from [`package:quiver`](https://pub.dartlang.org/packages/quiver).
factory SentryBrowserClient(SentryOptions options, {String origin}) {
options.httpClient ??= BrowserClient();
options.clock ??= getUtcDateTime;

// origin is necessary for sentry to resolve stacktrace
origin ??= '${window.location.origin}/';
Expand Down
36 changes: 17 additions & 19 deletions dart/lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import 'stack_trace.dart';
import 'utils.dart';
import 'version.dart';

/// Used to provide timestamp for logging.
typedef ClockProvider = DateTime Function();

/// Logs crash reports and events to the Sentry.io service.
abstract class SentryClient {
/// Creates a new platform appropriate client.
Expand All @@ -30,15 +27,7 @@ abstract class SentryClient {
Sdk sdk,
}) : _dsn = Dsn.parse(options.dsn),
_platform = platform ?? sdkPlatform,
sdk = sdk ?? Sdk(name: sdkName, version: sdkVersion) {
if (options.clock == null) {
options.clock = getUtcDateTime;
} else {
options.clock = (options.clock is ClockProvider
? options.clock
: options.clock.get) as ClockProvider;
}
}
sdk = sdk ?? Sdk(name: sdkName, version: sdkVersion);

final Dsn _dsn;

Expand Down Expand Up @@ -107,7 +96,7 @@ abstract class SentryClient {

/// Reports an [event] to Sentry.io.
Future<SentryId> captureEvent(
Event event, {
SentryEvent event, {
StackFrameFilter stackFrameFilter,
Scope scope,
}) async {
Expand All @@ -123,7 +112,7 @@ abstract class SentryClient {
final data = <String, dynamic>{
'project': projectId,
'event_id': event.eventId.toString(),
'timestamp': formatDateAsIso8601WithSecondPrecision(now),
'timestamp': formatDateAsIso8601WithSecondPrecision(event.timestamp),
};

if (options.environmentAttributes != null) {
Expand Down Expand Up @@ -162,11 +151,15 @@ abstract class SentryClient {
}

/// Reports the [throwable] and optionally its [stackTrace] to Sentry.io.
Future<SentryId> captureException(dynamic throwable,
{dynamic stackTrace, Scope scope}) {
final event = Event(
Future<SentryId> captureException(
dynamic throwable, {
dynamic stackTrace,
Scope scope,
}) {
final event = SentryEvent(
exception: throwable,
stackTrace: stackTrace,
timestamp: options.clock(),
);
return captureEvent(event, scope: scope);
}
Expand All @@ -179,9 +172,14 @@ abstract class SentryClient {
List<dynamic> params,
Scope scope,
}) {
final event = Event(
message: Message(formatted, template: template, params: params),
final event = SentryEvent(
message: Message(
formatted,
template: template,
params: params,
),
level: level,
timestamp: options.clock(),
);
return captureEvent(event, scope: scope);
}
Expand Down
2 changes: 1 addition & 1 deletion dart/lib/src/hub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Hub {
SentryId get lastEventId => _lastEventId;

/// Captures the event.
Future<SentryId> captureEvent(Event event) async {
Future<SentryId> captureEvent(SentryEvent event) async {
var sentryId = SentryId.empty();

if (!_isEnabled) {
Expand Down
7 changes: 0 additions & 7 deletions dart/lib/src/io_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import 'dart:io';
import 'package:sentry/sentry.dart';

import 'client.dart';
import 'protocol.dart';

SentryClient createSentryClient(SentryOptions options) =>
SentryIOClient(options);
Expand All @@ -30,12 +29,6 @@ class SentryIOClient extends SentryClient {
///
/// If [httpClient] is provided, it is used instead of the default client to
/// make HTTP calls to Sentry.io. This is useful in tests.
///
/// If [clock] is provided, it is used to get time instead of the system
/// clock. This is useful in tests. Should be an implementation of [ClockProvider].
/// This parameter is dynamic to maintain backwards compatibility with
/// previous use of [Clock](https://pub.dartlang.org/documentation/quiver/latest/quiver.time/Clock-class.html)
/// from [`package:quiver`](https://pub.dartlang.org/packages/quiver).
factory SentryIOClient(SentryOptions options) => SentryIOClient._(options);

SentryIOClient._(SentryOptions options) : super.base(options);
Expand Down
2 changes: 1 addition & 1 deletion dart/lib/src/noop_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class NoOpSentryClient implements SentryClient {
Map<String, String> buildHeaders(String authHeader) => {};

@override
Future<SentryId> captureEvent(Event event, {stackFrameFilter, scope}) =>
Future<SentryId> captureEvent(SentryEvent event, {stackFrameFilter, scope}) =>
Future.value(SentryId.empty());

@override
Expand Down
5 changes: 3 additions & 2 deletions dart/lib/src/noop_hub.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'dart:async';

import 'client.dart';
import 'hub.dart';
import 'protocol/event.dart';
import 'protocol/sentry_event.dart';
import 'protocol/sentry_level.dart';
import 'protocol/sentry_id.dart';

Expand All @@ -19,7 +19,8 @@ class NoOpHub implements Hub {
void bindClient(SentryClient client) {}

@override
Future<SentryId> captureEvent(Event event) => Future.value(SentryId.empty());
Future<SentryId> captureEvent(SentryEvent event) =>
Future.value(SentryId.empty());

@override
Future<SentryId> captureException(throwable, {stackTrace}) =>
Expand Down
2 changes: 1 addition & 1 deletion dart/lib/src/protocol.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export 'protocol/browser.dart';
export 'protocol/contexts.dart';
export 'protocol/device.dart';
export 'protocol/dsn.dart';
export 'protocol/event.dart';
export 'protocol/sentry_event.dart';
export 'protocol/sentry_level.dart';
export 'protocol/message.dart';
export 'protocol/package.dart';
Expand Down
12 changes: 12 additions & 0 deletions dart/lib/src/protocol/contexts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import '../protocol.dart';
import 'app.dart';
import 'browser.dart';
import 'device.dart';
import 'gpu.dart';
import 'runtime.dart';

/// The context interfaces provide additional context data.
Expand All @@ -17,6 +18,7 @@ class Contexts {
this.runtimes,
this.app,
this.browser,
this.gpu,
});

/// This describes the device that caused the event.
Expand Down Expand Up @@ -48,6 +50,11 @@ class Contexts {
/// agent of a web request that triggered the event.
final Browser browser;

/// GPU context describes the GPU of the device.
final Gpu gpu;

// TODO: contexts should accept arbitrary values

/// Produces a [Map] that can be serialized to JSON.
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
Expand All @@ -73,6 +80,11 @@ class Contexts {
json['browser'] = browserMap;
}

Map<String, dynamic> gpuMap;
if (gpu != null && (gpuMap = gpu.toJson()).isNotEmpty) {
json['gpu'] = gpuMap;
}

if (runtimes != null) {
if (runtimes.length == 1) {
final runtime = runtimes[0];
Expand Down
95 changes: 95 additions & 0 deletions dart/lib/src/protocol/gpu.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
// https://develop.sentry.dev/sdk/event-payloads/contexts/#gpu-context
// Example:
// "gpu": {
// "name": "AMD Radeon Pro 560",
// "vendor_name": "Apple",
// "memory_size": 4096,
// "api_type": "Metal",
// "multi_threaded_rendering": true,
// "version": "Metal",
// "npot_support": "Full"
// }

class Gpu {
/// The name of the graphics device.
final String name;

/// The PCI identifier of the graphics device.
final int id;

/// The PCI vendor identifier of the graphics device.
final int vendorId;

/// The vendor name as reported by the graphics device.
final String vendorName;

/// The total GPU memory available in Megabytes.
final int memorySize;

/// The device low-level API type.
final String apiType;

/// Whether the GPU has multi-threaded rendering or not.
final bool multiThreadedRendering;

/// The Version of the graphics device.
final String version;

/// The Non-Power-Of-Two-Support support.
final String npotSupport;

const Gpu({
this.name,
this.id,
this.vendorId,
this.vendorName,
this.memorySize,
this.apiType,
this.multiThreadedRendering,
this.version,
this.npotSupport,
});

/// Produces a [Map] that can be serialized to JSON.
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};

if (name != null) {
json['name'] = name;
}

if (id != null) {
json['id'] = id;
}

if (vendorId != null) {
json['vendor_id'] = vendorId;
}

if (vendorName != null) {
json['vendor_name'] = vendorName;
}

if (memorySize != null) {
json['memory_size'] = memorySize;
}

if (apiType != null) {
json['api_type'] = apiType;
}

if (multiThreadedRendering != null) {
json['multi_threaded_rendering'] = multiThreadedRendering;
}

if (version != null) {
json['version'] = version;
}

if (npotSupport != null) {
json['npot_support'] = npotSupport;
}

return json;
}
}
Loading