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
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,24 @@
* Fix: Pass hint to EventProcessors (#356)
* Fix: EventProcessors were not dropping events when returning null (#353)


## Breaking Changes:

* Fix: Plugin Registrant class moved to barrel file (#358)
* This changed the import from `import 'package:sentry_flutter/src/sentry_flutter_web.dart';`
to `import 'package:sentry_flutter/sentry_flutter_web.dart';`
* This could lead to breaking changes. Typically it shouldn't because the referencing file is auto-generated.
* Fix: Prefix classes with Sentry (#357)
* A couple of classes were often conflicting with user's code.
Thus this change renames the following classes:
* `App` -> `SentryApp`
* `Browser` -> `SentryBrowser`
* `Device` -> `SentryDevice`
* `Gpu` -> `SentryGpu`
* `Integration` -> `SentryIntegration`
* `Message` -> `SentryMessage`
* `OperatingSystem` -> `SentryOperatingSystem`
* `Request` -> `SentryRequest`
* `User` -> `SentryUser`

# 4.1.0-nullsafety.0

Expand Down
16 changes: 8 additions & 8 deletions dart/lib/src/protocol.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
export 'protocol/app.dart';
export 'protocol/sentry_app.dart';
export 'protocol/breadcrumb.dart';
export 'protocol/browser.dart';
export 'protocol/sentry_browser.dart';
export 'protocol/contexts.dart';
export 'protocol/debug_image.dart';
export 'protocol/debug_meta.dart';
export 'protocol/device.dart';
export 'protocol/sentry_device.dart';
export 'protocol/dsn.dart';
export 'protocol/gpu.dart';
export 'protocol/sentry_gpu.dart';
export 'protocol/mechanism.dart';
export 'protocol/message.dart';
export 'protocol/operating_system.dart';
export 'protocol/request.dart';
export 'protocol/sentry_message.dart';
export 'protocol/sentry_operating_system.dart';
export 'protocol/sentry_request.dart';
export 'protocol/sdk_info.dart';
export 'protocol/sdk_version.dart';
export 'protocol/sentry_event.dart';
Expand All @@ -21,4 +21,4 @@ export 'protocol/sentry_package.dart';
export 'protocol/sentry_runtime.dart';
export 'protocol/sentry_stack_frame.dart';
export 'protocol/sentry_stack_trace.dart';
export 'protocol/user.dart';
export 'protocol/sentry_user.dart';
104 changes: 53 additions & 51 deletions dart/lib/src/protocol/contexts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,38 @@ import '../protocol.dart';
/// See also: https://develop.sentry.dev/sdk/event-payloads/contexts/.
class Contexts extends MapView<String, dynamic> {
Contexts({
Device? device,
OperatingSystem? operatingSystem,
SentryDevice? device,
SentryOperatingSystem? operatingSystem,
List<SentryRuntime>? runtimes,
App? app,
Browser? browser,
Gpu? gpu,
SentryApp? app,
SentryBrowser? browser,
SentryGpu? gpu,
}) : super({
Device.type: device,
OperatingSystem.type: operatingSystem,
SentryDevice.type: device,
SentryOperatingSystem.type: operatingSystem,
SentryRuntime.listType: runtimes ?? [],
App.type: app,
Browser.type: browser,
Gpu.type: gpu,
SentryApp.type: app,
SentryBrowser.type: browser,
SentryGpu.type: gpu,
});

factory Contexts.fromJson(Map<String, dynamic> data) {
final contexts = Contexts(
device: data[Device.type] != null
? Device.fromJson(Map.from(data[Device.type]))
device: data[SentryDevice.type] != null
? SentryDevice.fromJson(Map.from(data[SentryDevice.type]))
: null,
operatingSystem: data[OperatingSystem.type] != null
? OperatingSystem.fromJson(Map.from(data[OperatingSystem.type]))
operatingSystem: data[SentryOperatingSystem.type] != null
? SentryOperatingSystem.fromJson(
Map.from(data[SentryOperatingSystem.type]))
: null,
app: data[App.type] != null
? App.fromJson(Map.from(data[App.type]))
app: data[SentryApp.type] != null
? SentryApp.fromJson(Map.from(data[SentryApp.type]))
: null,
browser: data[Browser.type] != null
? Browser.fromJson(Map.from(data[Browser.type]))
browser: data[SentryBrowser.type] != null
? SentryBrowser.fromJson(Map.from(data[SentryBrowser.type]))
: null,
gpu: data[Gpu.type] != null
? Gpu.fromJson(Map.from(data[Gpu.type]))
gpu: data[SentryGpu.type] != null
? SentryGpu.fromJson(Map.from(data[SentryGpu.type]))
: null,
runtimes: data[SentryRuntime.type] != null
? [SentryRuntime.fromJson(Map.from(data[SentryRuntime.type]))]
Expand All @@ -55,18 +56,19 @@ class Contexts extends MapView<String, dynamic> {
}

/// This describes the device that caused the event.
Device? get device => this[Device.type];
SentryDevice? get device => this[SentryDevice.type];

set device(Device? device) => this[Device.type] = device;
set device(SentryDevice? device) => this[SentryDevice.type] = device;

/// Describes the operating system on which the event was created.
///
/// In web contexts, this is the operating system of the browse
/// (normally pulled from the User-Agent string).
OperatingSystem? get operatingSystem => this[OperatingSystem.type];
SentryOperatingSystem? get operatingSystem =>
this[SentryOperatingSystem.type];

set operatingSystem(OperatingSystem? operatingSystem) =>
this[OperatingSystem.type] = operatingSystem;
set operatingSystem(SentryOperatingSystem? operatingSystem) =>
this[SentryOperatingSystem.type] = operatingSystem;

/// Describes an immutable list of runtimes in more detail
/// (for instance if you have a Flutter application running
Expand All @@ -84,23 +86,23 @@ class Contexts extends MapView<String, dynamic> {
///
/// As opposed to the runtime, this is the actual application that was
/// running and carries metadata about the current session.
App? get app => this[App.type];
SentryApp? get app => this[SentryApp.type];

set app(App? app) => this[App.type] = app;
set app(SentryApp? app) => this[SentryApp.type] = app;

/// Carries information about the browser or user agent for web-related
/// errors.
///
/// This can either be the browser this event ocurred in, or the user
/// agent of a web request that triggered the event.
Browser? get browser => this[Browser.type];
SentryBrowser? get browser => this[SentryBrowser.type];

set browser(Browser? browser) => this[Browser.type] = browser;
set browser(SentryBrowser? browser) => this[SentryBrowser.type] = browser;

/// GPU context describes the GPU of the device.
Gpu? get gpu => this[Gpu.type];
SentryGpu? get gpu => this[SentryGpu.type];

set gpu(Gpu? gpu) => this[Gpu.type] = gpu;
set gpu(SentryGpu? gpu) => this[SentryGpu.type] = gpu;

/// Produces a [Map] that can be serialized to JSON.
Map<String, dynamic> toJson() {
Expand All @@ -109,37 +111,37 @@ class Contexts extends MapView<String, dynamic> {
forEach((key, value) {
if (value == null) return;
switch (key) {
case Device.type:
case SentryDevice.type:
final deviceMap = device?.toJson();
if (deviceMap?.isNotEmpty ?? false) {
json[Device.type] = deviceMap;
json[SentryDevice.type] = deviceMap;
}
break;
case OperatingSystem.type:
case SentryOperatingSystem.type:
final osMap = operatingSystem?.toJson();
if (osMap?.isNotEmpty ?? false) {
json[OperatingSystem.type] = osMap;
json[SentryOperatingSystem.type] = osMap;
}
break;

case App.type:
case SentryApp.type:
final appMap = app?.toJson();
if (appMap?.isNotEmpty ?? false) {
json[App.type] = appMap;
json[SentryApp.type] = appMap;
}
break;

case Browser.type:
case SentryBrowser.type:
final browserMap = browser?.toJson();
if (browserMap?.isNotEmpty ?? false) {
json[Browser.type] = browserMap;
json[SentryBrowser.type] = browserMap;
}
break;

case Gpu.type:
case SentryGpu.type:
final gpuMap = gpu?.toJson();
if (gpuMap?.isNotEmpty ?? false) {
json[Gpu.type] = gpuMap;
json[SentryGpu.type] = gpuMap;
}
break;

Expand Down Expand Up @@ -199,12 +201,12 @@ class Contexts extends MapView<String, dynamic> {
}

Contexts copyWith({
Device? device,
OperatingSystem? operatingSystem,
SentryDevice? device,
SentryOperatingSystem? operatingSystem,
List<SentryRuntime>? runtimes,
App? app,
Browser? browser,
Gpu? gpu,
SentryApp? app,
SentryBrowser? browser,
SentryGpu? gpu,
}) =>
Contexts(
device: device ?? this.device,
Expand All @@ -218,12 +220,12 @@ class Contexts extends MapView<String, dynamic> {
);

static const _defaultFields = [
App.type,
Device.type,
OperatingSystem.type,
SentryApp.type,
SentryDevice.type,
SentryOperatingSystem.type,
SentryRuntime.listType,
SentryRuntime.type,
Gpu.type,
Browser.type,
SentryGpu.type,
SentryBrowser.type,
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import 'package:meta/meta.dart';
/// As opposed to the runtime, this is the actual application that was
/// running and carries metadata about the current session.
@immutable
class App {
class SentryApp {
static const type = 'app';

const App({
const SentryApp({
this.name,
this.version,
this.identifier,
Expand All @@ -18,7 +18,7 @@ class App {
this.deviceAppHash,
});

factory App.fromJson(Map<String, dynamic> data) => App(
factory SentryApp.fromJson(Map<String, dynamic> data) => SentryApp(
name: data['app_name'],
version: data['app_version'],
identifier: data['app_identifier'],
Expand Down Expand Up @@ -86,7 +86,7 @@ class App {
return json;
}

App clone() => App(
SentryApp clone() => SentryApp(
name: name,
version: version,
identifier: identifier,
Expand All @@ -96,7 +96,7 @@ class App {
deviceAppHash: deviceAppHash,
);

App copyWith({
SentryApp copyWith({
String? name,
String? version,
String? identifier,
Expand All @@ -105,7 +105,7 @@ class App {
DateTime? startTime,
String? deviceAppHash,
}) =>
App(
SentryApp(
name: name ?? this.name,
version: version ?? this.version,
identifier: identifier ?? this.identifier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import 'package:meta/meta.dart';
/// This can either be the browser this event ocurred in, or the user
/// agent of a web request that triggered the event.
@immutable
class Browser {
class SentryBrowser {
static const type = 'browser';

/// Creates an instance of [Browser].
const Browser({this.name, this.version});
/// Creates an instance of [SentryBrowser].
const SentryBrowser({this.name, this.version});

factory Browser.fromJson(Map<String, dynamic> data) => Browser(
factory SentryBrowser.fromJson(Map<String, dynamic> data) => SentryBrowser(
name: data['name'],
version: data['version'],
);
Expand All @@ -37,13 +37,13 @@ class Browser {
return json;
}

Browser clone() => Browser(name: name, version: version);
SentryBrowser clone() => SentryBrowser(name: name, version: version);

Browser copyWith({
SentryBrowser copyWith({
String? name,
String? version,
}) =>
Browser(
SentryBrowser(
name: name ?? this.name,
version: version ?? this.version,
);
Expand Down
Loading