diff --git a/CHANGELOG.md b/CHANGELOG.md index cb68b87758..785faa71c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/dart/lib/src/protocol.dart b/dart/lib/src/protocol.dart index 826c336266..89f2ab65d5 100644 --- a/dart/lib/src/protocol.dart +++ b/dart/lib/src/protocol.dart @@ -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'; @@ -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'; diff --git a/dart/lib/src/protocol/contexts.dart b/dart/lib/src/protocol/contexts.dart index 7ebeb8eb8f..a1205e9650 100644 --- a/dart/lib/src/protocol/contexts.dart +++ b/dart/lib/src/protocol/contexts.dart @@ -10,37 +10,38 @@ import '../protocol.dart'; /// See also: https://develop.sentry.dev/sdk/event-payloads/contexts/. class Contexts extends MapView { Contexts({ - Device? device, - OperatingSystem? operatingSystem, + SentryDevice? device, + SentryOperatingSystem? operatingSystem, List? 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 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]))] @@ -55,18 +56,19 @@ class Contexts extends MapView { } /// 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 @@ -84,23 +86,23 @@ class Contexts extends MapView { /// /// 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 toJson() { @@ -109,37 +111,37 @@ class Contexts extends MapView { 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; @@ -199,12 +201,12 @@ class Contexts extends MapView { } Contexts copyWith({ - Device? device, - OperatingSystem? operatingSystem, + SentryDevice? device, + SentryOperatingSystem? operatingSystem, List? runtimes, - App? app, - Browser? browser, - Gpu? gpu, + SentryApp? app, + SentryBrowser? browser, + SentryGpu? gpu, }) => Contexts( device: device ?? this.device, @@ -218,12 +220,12 @@ class Contexts extends MapView { ); 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, ]; } diff --git a/dart/lib/src/protocol/app.dart b/dart/lib/src/protocol/sentry_app.dart similarity index 93% rename from dart/lib/src/protocol/app.dart rename to dart/lib/src/protocol/sentry_app.dart index fd0b97446f..1e4c87ecbe 100644 --- a/dart/lib/src/protocol/app.dart +++ b/dart/lib/src/protocol/sentry_app.dart @@ -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, @@ -18,7 +18,7 @@ class App { this.deviceAppHash, }); - factory App.fromJson(Map data) => App( + factory SentryApp.fromJson(Map data) => SentryApp( name: data['app_name'], version: data['app_version'], identifier: data['app_identifier'], @@ -86,7 +86,7 @@ class App { return json; } - App clone() => App( + SentryApp clone() => SentryApp( name: name, version: version, identifier: identifier, @@ -96,7 +96,7 @@ class App { deviceAppHash: deviceAppHash, ); - App copyWith({ + SentryApp copyWith({ String? name, String? version, String? identifier, @@ -105,7 +105,7 @@ class App { DateTime? startTime, String? deviceAppHash, }) => - App( + SentryApp( name: name ?? this.name, version: version ?? this.version, identifier: identifier ?? this.identifier, diff --git a/dart/lib/src/protocol/browser.dart b/dart/lib/src/protocol/sentry_browser.dart similarity index 75% rename from dart/lib/src/protocol/browser.dart rename to dart/lib/src/protocol/sentry_browser.dart index f6c6d9db2c..32038bf2a4 100644 --- a/dart/lib/src/protocol/browser.dart +++ b/dart/lib/src/protocol/sentry_browser.dart @@ -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 data) => Browser( + factory SentryBrowser.fromJson(Map data) => SentryBrowser( name: data['name'], version: data['version'], ); @@ -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, ); diff --git a/dart/lib/src/protocol/device.dart b/dart/lib/src/protocol/sentry_device.dart similarity index 95% rename from dart/lib/src/protocol/device.dart rename to dart/lib/src/protocol/sentry_device.dart index 584e3c840e..36bad0e280 100644 --- a/dart/lib/src/protocol/device.dart +++ b/dart/lib/src/protocol/sentry_device.dart @@ -1,14 +1,14 @@ import 'package:meta/meta.dart'; /// If a device is on portrait or landscape mode -enum Orientation { portrait, landscape } +enum SentryOrientation { portrait, landscape } /// This describes the device that caused the event. @immutable -class Device { +class SentryDevice { static const type = 'device'; - const Device({ + const SentryDevice({ this.name, this.family, this.model, @@ -38,7 +38,7 @@ class Device { batteryLevel == null || (batteryLevel >= 0 && batteryLevel <= 100), ); - factory Device.fromJson(Map data) => Device( + factory SentryDevice.fromJson(Map data) => SentryDevice( name: data['name'], family: data['family'], model: data['model'], @@ -92,7 +92,7 @@ class Device { final double? batteryLevel; /// Defines the orientation of a device. - final Orientation? orientation; + final SentryOrientation? orientation; /// The manufacturer of the device. final String? manufacturer; @@ -157,10 +157,10 @@ class Device { String? orientation; switch (this.orientation) { - case Orientation.portrait: + case SentryOrientation.portrait: orientation = 'portait'; break; - case Orientation.landscape: + case SentryOrientation.landscape: orientation = 'landscape'; break; case null: @@ -271,7 +271,7 @@ class Device { return json; } - Device clone() => Device( + SentryDevice clone() => SentryDevice( name: name, family: family, model: model, @@ -299,14 +299,14 @@ class Device { timezone: timezone, ); - Device copyWith({ + SentryDevice copyWith({ String? name, String? family, String? model, String? modelId, String? arch, double? batteryLevel, - Orientation? orientation, + SentryOrientation? orientation, String? manufacturer, String? brand, String? screenResolution, @@ -326,7 +326,7 @@ class Device { DateTime? bootTime, String? timezone, }) => - Device( + SentryDevice( name: name ?? this.name, family: family ?? this.family, model: model ?? this.model, diff --git a/dart/lib/src/protocol/sentry_event.dart b/dart/lib/src/protocol/sentry_event.dart index d3c85b5fb5..7472ce1950 100644 --- a/dart/lib/src/protocol/sentry_event.dart +++ b/dart/lib/src/protocol/sentry_event.dart @@ -80,7 +80,7 @@ class SentryEvent { /// Event message. /// /// Generally an event either contains a [message] or an [exception]. - final Message? message; + final SentryMessage? message; final dynamic _throwable; @@ -135,7 +135,7 @@ class SentryEvent { /// /// The value in this field overrides the user context /// set in [Scope.user] for this logged event. - final User? user; + final SentryUser? user; /// The context interfaces provide additional context data. /// Typically this is data related to the current user, @@ -164,7 +164,7 @@ class SentryEvent { /// contains information on a HTTP request related to the event. /// In client, this can be an outgoing request, or the request that rendered the current web page. /// On server, this could be the incoming web request that is being handled - final Request? request; + final SentryRequest? request; /// The debug meta interface carries debug information for processing errors and crash reports. final DebugMeta? debugMeta; @@ -179,7 +179,7 @@ class SentryEvent { String? dist, String? environment, Map? modules, - Message? message, + SentryMessage? message, String? transaction, dynamic throwable, SentryException? exception, @@ -189,11 +189,11 @@ class SentryEvent { Map? tags, Map? extra, List? fingerprint, - User? user, + SentryUser? user, Contexts? contexts, List? breadcrumbs, SdkVersion? sdk, - Request? request, + SentryRequest? request, DebugMeta? debugMeta, }) => SentryEvent( diff --git a/dart/lib/src/protocol/gpu.dart b/dart/lib/src/protocol/sentry_gpu.dart similarity index 94% rename from dart/lib/src/protocol/gpu.dart rename to dart/lib/src/protocol/sentry_gpu.dart index 26fa7f85fc..bba5cfe07b 100644 --- a/dart/lib/src/protocol/gpu.dart +++ b/dart/lib/src/protocol/sentry_gpu.dart @@ -14,7 +14,7 @@ import 'package:meta/meta.dart'; /// GPU context describes the GPU of the device. @immutable -class Gpu { +class SentryGpu { static const type = 'gpu'; /// The name of the graphics device. @@ -44,7 +44,7 @@ class Gpu { /// The Non-Power-Of-Two-Support support. final String? npotSupport; - const Gpu({ + const SentryGpu({ this.name, this.id, this.vendorId, @@ -56,7 +56,7 @@ class Gpu { this.npotSupport, }); - factory Gpu.fromJson(Map data) => Gpu( + factory SentryGpu.fromJson(Map data) => SentryGpu( name: data['name'], id: data['id'], vendorId: data['vendor_id'], @@ -68,7 +68,7 @@ class Gpu { npotSupport: data['npot_support'], ); - Gpu clone() => Gpu( + SentryGpu clone() => SentryGpu( name: name, id: id, vendorId: vendorId, @@ -123,7 +123,7 @@ class Gpu { return json; } - Gpu copyWith({ + SentryGpu copyWith({ String? name, int? id, int? vendorId, @@ -134,7 +134,7 @@ class Gpu { String? version, String? npotSupport, }) => - Gpu( + SentryGpu( name: name ?? this.name, id: id ?? this.id, vendorId: vendorId ?? this.vendorId, diff --git a/dart/lib/src/protocol/message.dart b/dart/lib/src/protocol/sentry_message.dart similarity index 90% rename from dart/lib/src/protocol/message.dart rename to dart/lib/src/protocol/sentry_message.dart index 58f09b9e4a..3842e35b1d 100644 --- a/dart/lib/src/protocol/message.dart +++ b/dart/lib/src/protocol/sentry_message.dart @@ -9,7 +9,7 @@ import 'package:meta/meta.dart'; /// } /// } @immutable -class Message { +class SentryMessage { /// The fully formatted message. If missing, Sentry will try to interpolate the message. final String formatted; @@ -20,7 +20,7 @@ class Message { /// A list of formatting parameters, preferably strings. Non-strings will be coerced to strings. final List? params; - const Message(this.formatted, {this.template, this.params}); + const SentryMessage(this.formatted, {this.template, this.params}); Map toJson() { final json = {}; @@ -38,12 +38,12 @@ class Message { return json; } - Message copyWith({ + SentryMessage copyWith({ String? formatted, String? template, List? params, }) => - Message( + SentryMessage( formatted ?? this.formatted, template: template ?? this.template, params: params ?? this.params, diff --git a/dart/lib/src/protocol/operating_system.dart b/dart/lib/src/protocol/sentry_operating_system.dart similarity index 89% rename from dart/lib/src/protocol/operating_system.dart rename to dart/lib/src/protocol/sentry_operating_system.dart index b8779ee925..60d7ce6848 100644 --- a/dart/lib/src/protocol/operating_system.dart +++ b/dart/lib/src/protocol/sentry_operating_system.dart @@ -5,10 +5,10 @@ import 'package:meta/meta.dart'; /// In web contexts, this is the operating system of the browse /// (normally pulled from the User-Agent string). @immutable -class OperatingSystem { +class SentryOperatingSystem { static const type = 'os'; - const OperatingSystem({ + const SentryOperatingSystem({ this.name, this.version, this.build, @@ -17,8 +17,8 @@ class OperatingSystem { this.rawDescription, }); - factory OperatingSystem.fromJson(Map data) => - OperatingSystem( + factory SentryOperatingSystem.fromJson(Map data) => + SentryOperatingSystem( name: data['name'], version: data['version'], build: data['build'], @@ -81,7 +81,7 @@ class OperatingSystem { return json; } - OperatingSystem clone() => OperatingSystem( + SentryOperatingSystem clone() => SentryOperatingSystem( name: name, version: version, build: build, @@ -90,7 +90,7 @@ class OperatingSystem { rawDescription: rawDescription, ); - OperatingSystem copyWith({ + SentryOperatingSystem copyWith({ String? name, String? version, String? build, @@ -98,7 +98,7 @@ class OperatingSystem { bool? rooted, String? rawDescription, }) => - OperatingSystem( + SentryOperatingSystem( name: name ?? this.name, version: version ?? this.version, build: build ?? this.build, diff --git a/dart/lib/src/protocol/request.dart b/dart/lib/src/protocol/sentry_request.dart similarity index 97% rename from dart/lib/src/protocol/request.dart rename to dart/lib/src/protocol/sentry_request.dart index 4a0fed5bcf..acaef3370e 100644 --- a/dart/lib/src/protocol/request.dart +++ b/dart/lib/src/protocol/sentry_request.dart @@ -4,7 +4,7 @@ import 'package:meta/meta.dart'; /// In client SDKs, this can be an outgoing request, or the request that rendered the current web page. /// On server SDKs, this could be the incoming web request that is being handled. @immutable -class Request { +class SentryRequest { ///The URL of the request if available. ///The query string can be declared either as part of the url, ///or separately in queryString. @@ -55,7 +55,7 @@ class Request { Map get other => Map.unmodifiable(_other ?? const {}); - Request({ + SentryRequest({ this.url, this.method, this.queryString, @@ -107,7 +107,7 @@ class Request { return json; } - Request copyWith({ + SentryRequest copyWith({ String? url, String? method, String? queryString, @@ -117,7 +117,7 @@ class Request { Map? env, Map? other, }) => - Request( + SentryRequest( url: url ?? this.url, method: method ?? this.method, queryString: queryString ?? this.queryString, diff --git a/dart/lib/src/protocol/user.dart b/dart/lib/src/protocol/sentry_user.dart similarity index 96% rename from dart/lib/src/protocol/user.dart rename to dart/lib/src/protocol/sentry_user.dart index e6fc3a6e2f..57d95c0311 100644 --- a/dart/lib/src/protocol/user.dart +++ b/dart/lib/src/protocol/sentry_user.dart @@ -24,9 +24,9 @@ import 'package:meta/meta.dart'; /// } /// ``` @immutable -class User { +class SentryUser { /// At a minimum you must set an [id] or an [ipAddress]. - User({ + SentryUser({ this.id, this.username, this.email, @@ -64,14 +64,14 @@ class User { }; } - User copyWith({ + SentryUser copyWith({ String? id, String? username, String? email, String? ipAddress, Map? extras, }) => - User( + SentryUser( id: id ?? this.id, username: username ?? this.username, email: email ?? this.email, diff --git a/dart/lib/src/scope.dart b/dart/lib/src/scope.dart index e780714db5..41b8b505cb 100644 --- a/dart/lib/src/scope.dart +++ b/dart/lib/src/scope.dart @@ -13,7 +13,7 @@ class Scope { String? transaction; /// Information about the current user. - User? user; + SentryUser? user; List _fingerprint = []; diff --git a/dart/lib/src/sentry_client.dart b/dart/lib/src/sentry_client.dart index 1f37c71910..05d80f953b 100644 --- a/dart/lib/src/sentry_client.dart +++ b/dart/lib/src/sentry_client.dart @@ -162,7 +162,7 @@ class SentryClient { dynamic hint, }) { final event = SentryEvent( - message: Message(formatted, template: template, params: params), + message: SentryMessage(formatted, template: template, params: params), level: level ?? SentryLevel.info, timestamp: _options.clock(), ); diff --git a/dart/test/contexts_test.dart b/dart/test/contexts_test.dart index e03daeeccf..5647f03144 100644 --- a/dart/test/contexts_test.dart +++ b/dart/test/contexts_test.dart @@ -6,21 +6,21 @@ import 'dart:convert'; import 'package:collection/collection.dart'; import 'package:sentry/sentry.dart'; -import 'package:sentry/src/protocol/gpu.dart'; +import 'package:sentry/src/protocol/sentry_gpu.dart'; import 'package:test/test.dart'; void main() { group(Contexts, () { final testBootTime = DateTime.fromMicrosecondsSinceEpoch(0); - final testDevice = Device( + final testDevice = SentryDevice( name: 'testDevice', family: 'testFamily', model: 'testModel', modelId: 'testModelId', arch: 'testArch', batteryLevel: 23, - orientation: Orientation.landscape, + orientation: SentryOrientation.landscape, manufacturer: 'testOEM', brand: 'testBrand', screenResolution: '123x345', @@ -40,15 +40,15 @@ void main() { bootTime: testBootTime, timezone: 'Australia/Melbourne', ); - const testOS = OperatingSystem(name: 'testOS'); + const testOS = SentryOperatingSystem(name: 'testOS'); final testRuntimes = [ const SentryRuntime(name: 'testRT1', version: '1.0'), const SentryRuntime(name: 'testRT2', version: '2.3.1'), ]; - const testApp = App(version: '1.2.3'); - const testBrowser = Browser(version: '12.3.4'); + const testApp = SentryApp(version: '1.2.3'); + const testBrowser = SentryBrowser(version: '12.3.4'); - final gpu = Gpu(name: 'Radeon', version: '1'); + final gpu = SentryGpu(name: 'Radeon', version: '1'); final contexts = Contexts( device: testDevice, diff --git a/dart/test/mocks.dart b/dart/test/mocks.dart index b64290a589..e1d8b87d5c 100644 --- a/dart/test/mocks.dart +++ b/dart/test/mocks.dart @@ -5,20 +5,20 @@ final fakeDsn = 'https://abc@def.ingest.sentry.io/1234567'; final fakeException = Exception('Error'); -final fakeMessage = Message( +final fakeMessage = SentryMessage( 'message 1', template: 'message %d', params: ['1'], ); -final fakeUser = User(id: '1', email: 'test@test'); +final fakeUser = SentryUser(id: '1', email: 'test@test'); final fakeEvent = SentryEvent( logger: 'main', serverName: 'server.dart', release: '1.4.0-preview.1', environment: 'Test', - message: Message('This is an example Dart event.'), + message: SentryMessage('This is an example Dart event.'), transaction: '/example/app', level: SentryLevel.warning, tags: const {'project-id': '7371'}, @@ -26,7 +26,7 @@ final fakeEvent = SentryEvent( fingerprint: const ['example-dart'], modules: const {'module1': 'factory'}, sdk: SdkVersion(name: 'sdk1', version: '1.0.0'), - user: User( + user: SentryUser( id: '800', username: 'first-user', email: 'first@user.lan', @@ -44,7 +44,7 @@ final fakeEvent = SentryEvent( ) ], contexts: Contexts( - operatingSystem: const OperatingSystem( + operatingSystem: const SentryOperatingSystem( name: 'Android', version: '5.0.2', build: 'LRX22G.P900XXS0BPL2', @@ -53,7 +53,7 @@ final fakeEvent = SentryEvent( rooted: false, ), runtimes: [const SentryRuntime(name: 'ART', version: '5')], - app: App( + app: SentryApp( name: 'Example Dart App', version: '1.42.0', identifier: 'HGT-App-13', @@ -61,15 +61,15 @@ final fakeEvent = SentryEvent( buildType: 'release', deviceAppHash: '5afd3a6', startTime: DateTime.now().toUtc()), - browser: const Browser(name: 'Firefox', version: '42.0.1'), - device: Device( + browser: const SentryBrowser(name: 'Firefox', version: '42.0.1'), + device: SentryDevice( name: 'SM-P900', family: 'SM-P900', model: 'SM-P900 (LRX22G)', modelId: 'LRX22G', arch: 'armeabi-v7a', batteryLevel: 99, - orientation: Orientation.landscape, + orientation: SentryOrientation.landscape, manufacturer: 'samsung', brand: 'samsung', screenResolution: '2560x1600', diff --git a/dart/test/protocol/app_test.dart b/dart/test/protocol/app_test.dart index fccfdcea19..fe2abb0957 100644 --- a/dart/test/protocol/app_test.dart +++ b/dart/test/protocol/app_test.dart @@ -39,7 +39,7 @@ void main() { }); } -App _generate({DateTime? startTime}) => App( +SentryApp _generate({DateTime? startTime}) => SentryApp( name: 'name', version: 'version', identifier: 'identifier', diff --git a/dart/test/protocol/browser_test.dart b/dart/test/protocol/browser_test.dart index 20c93595a1..d3123fb638 100644 --- a/dart/test/protocol/browser_test.dart +++ b/dart/test/protocol/browser_test.dart @@ -27,7 +27,7 @@ void main() { }); } -Browser _generate() => Browser( +SentryBrowser _generate() => SentryBrowser( name: 'name', version: 'version', ); diff --git a/dart/test/protocol/contexts_test.dart b/dart/test/protocol/contexts_test.dart index 09893f4137..4533b26879 100644 --- a/dart/test/protocol/contexts_test.dart +++ b/dart/test/protocol/contexts_test.dart @@ -16,12 +16,12 @@ void main() { final data = _generate(); data['extra'] = 'value'; - final device = Device(batteryLevel: 100); - final os = OperatingSystem(name: 'name1'); + final device = SentryDevice(batteryLevel: 100); + final os = SentryOperatingSystem(name: 'name1'); final runtimes = [SentryRuntime(name: 'name1')]; - final app = App(name: 'name1'); - final browser = Browser(name: 'name1'); - final gpu = Gpu(id: 2); + final app = SentryApp(name: 'name1'); + final browser = SentryBrowser(name: 'name1'); + final gpu = SentryGpu(id: 2); final copy = data.copyWith( device: device, @@ -46,10 +46,10 @@ void main() { } Contexts _generate() => Contexts( - device: Device(batteryLevel: 90), - operatingSystem: OperatingSystem(name: 'name'), + device: SentryDevice(batteryLevel: 90), + operatingSystem: SentryOperatingSystem(name: 'name'), runtimes: [SentryRuntime(name: 'name')], - app: App(name: 'name'), - browser: Browser(name: 'name'), - gpu: Gpu(id: 1), + app: SentryApp(name: 'name'), + browser: SentryBrowser(name: 'name'), + gpu: SentryGpu(id: 1), ); diff --git a/dart/test/protocol/device_test.dart b/dart/test/protocol/device_test.dart index 673be6c9f5..fc78261df3 100644 --- a/dart/test/protocol/device_test.dart +++ b/dart/test/protocol/device_test.dart @@ -26,7 +26,7 @@ void main() { modelId: 'modelId1', arch: 'arch1', batteryLevel: 2, - orientation: Orientation.portrait, + orientation: SentryOrientation.portrait, manufacturer: 'manufacturer1', brand: 'brand1', screenResolution: '123x3451', @@ -53,7 +53,7 @@ void main() { expect('modelId1', copy.modelId); expect('arch1', copy.arch); expect(2, copy.batteryLevel); - expect(Orientation.portrait, copy.orientation); + expect(SentryOrientation.portrait, copy.orientation); expect('manufacturer1', copy.manufacturer); expect('brand1', copy.brand); expect('123x3451', copy.screenResolution); @@ -75,14 +75,14 @@ void main() { }); } -Device _generate({DateTime? testBootTime}) => Device( +SentryDevice _generate({DateTime? testBootTime}) => SentryDevice( name: 'name', family: 'family', model: 'model', modelId: 'modelId', arch: 'arch', batteryLevel: 1, - orientation: Orientation.landscape, + orientation: SentryOrientation.landscape, manufacturer: 'manufacturer', brand: 'brand', screenResolution: '123x345', diff --git a/dart/test/protocol/gpu_test.dart b/dart/test/protocol/gpu_test.dart index da9a351a01..872632e4c0 100644 --- a/dart/test/protocol/gpu_test.dart +++ b/dart/test/protocol/gpu_test.dart @@ -41,7 +41,7 @@ void main() { }); } -Gpu _generate() => Gpu( +SentryGpu _generate() => SentryGpu( name: 'name', id: 1, vendorId: 2, diff --git a/dart/test/protocol/message_test.dart b/dart/test/protocol/message_test.dart index db2ee93830..7705b82673 100644 --- a/dart/test/protocol/message_test.dart +++ b/dart/test/protocol/message_test.dart @@ -29,7 +29,7 @@ void main() { }); } -Message _generate() => Message( +SentryMessage _generate() => SentryMessage( 'message 1', template: 'message %d', params: ['1'], diff --git a/dart/test/protocol/operating_system_test.dart b/dart/test/protocol/operating_system_test.dart index 222cbfa170..33d51d5df1 100644 --- a/dart/test/protocol/operating_system_test.dart +++ b/dart/test/protocol/operating_system_test.dart @@ -33,7 +33,7 @@ void main() { }); } -OperatingSystem _generate() => OperatingSystem( +SentryOperatingSystem _generate() => SentryOperatingSystem( name: 'name', version: 'version', build: 'build', diff --git a/dart/test/protocol/request_test.dart b/dart/test/protocol/request_test.dart index aaee399ec5..ef5e68fa45 100644 --- a/dart/test/protocol/request_test.dart +++ b/dart/test/protocol/request_test.dart @@ -33,7 +33,7 @@ void main() { }); } -Request _generate() => Request( +SentryRequest _generate() => SentryRequest( url: 'url', method: 'method', queryString: 'queryString', diff --git a/dart/test/protocol/user_test.dart b/dart/test/protocol/user_test.dart index dba4b41c74..6d3df2518a 100644 --- a/dart/test/protocol/user_test.dart +++ b/dart/test/protocol/user_test.dart @@ -29,7 +29,7 @@ void main() { }); } -User _generate() => User( +SentryUser _generate() => SentryUser( id: 'id', username: 'username', email: 'email', diff --git a/dart/test/scope_test.dart b/dart/test/scope_test.dart index ed1b6b25a9..9c5d73d708 100644 --- a/dart/test/scope_test.dart +++ b/dart/test/scope_test.dart @@ -29,10 +29,10 @@ void main() { expect(sut.transaction, 'test'); }); - test('sets $User', () { + test('sets $SentryUser', () { final sut = fixture.getSut(); - final user = User(id: 'test'); + final user = SentryUser(id: 'test'); sut.user = user; expect(sut.user, user); @@ -200,7 +200,7 @@ void main() { sut.level = SentryLevel.debug; sut.transaction = 'test'; - final user = User(id: 'test'); + final user = SentryUser(id: 'test'); sut.user = user; final fingerprints = ['test']; @@ -247,7 +247,7 @@ void main() { }); group('Scope apply', () { - final scopeUser = User( + final scopeUser = SentryUser( id: '800', username: 'first-user', email: 'first@user.lan', @@ -291,7 +291,7 @@ void main() { test('should not apply the scope properties when event already has it ', () async { - final eventUser = User(id: '123'); + final eventUser = SentryUser(id: '123'); final eventBreadcrumb = Breadcrumb(message: 'event-breadcrumb'); final event = SentryEvent( @@ -319,76 +319,81 @@ void main() { () async { final event = SentryEvent( contexts: Contexts( - device: Device(name: 'event-device'), - app: App(name: 'event-app'), - gpu: Gpu(name: 'event-gpu'), + device: SentryDevice(name: 'event-device'), + app: SentryApp(name: 'event-app'), + gpu: SentryGpu(name: 'event-gpu'), runtimes: [SentryRuntime(name: 'event-runtime')], - browser: Browser(name: 'event-browser'), - operatingSystem: OperatingSystem(name: 'event-os'), + browser: SentryBrowser(name: 'event-browser'), + operatingSystem: SentryOperatingSystem(name: 'event-os'), ), ); final scope = Scope(SentryOptions(dsn: fakeDsn)) ..setContexts( - Device.type, - Device(name: 'context-device'), + SentryDevice.type, + SentryDevice(name: 'context-device'), ) ..setContexts( - App.type, - App(name: 'context-app'), + SentryApp.type, + SentryApp(name: 'context-app'), ) ..setContexts( - Gpu.type, - Gpu(name: 'context-gpu'), + SentryGpu.type, + SentryGpu(name: 'context-gpu'), ) ..setContexts( SentryRuntime.listType, [SentryRuntime(name: 'context-runtime')], ) ..setContexts( - Browser.type, - Browser(name: 'context-browser'), + SentryBrowser.type, + SentryBrowser(name: 'context-browser'), ) ..setContexts( - OperatingSystem.type, - OperatingSystem(name: 'context-os'), + SentryOperatingSystem.type, + SentryOperatingSystem(name: 'context-os'), ); final updatedEvent = await scope.applyToEvent(event, null); - expect(updatedEvent?.contexts[Device.type].name, 'event-device'); - expect(updatedEvent?.contexts[App.type].name, 'event-app'); - expect(updatedEvent?.contexts[Gpu.type].name, 'event-gpu'); + expect(updatedEvent?.contexts[SentryDevice.type].name, 'event-device'); + expect(updatedEvent?.contexts[SentryApp.type].name, 'event-app'); + expect(updatedEvent?.contexts[SentryGpu.type].name, 'event-gpu'); expect(updatedEvent?.contexts[SentryRuntime.listType].first.name, 'event-runtime'); - expect(updatedEvent?.contexts[Browser.type].name, 'event-browser'); - expect(updatedEvent?.contexts[OperatingSystem.type].name, 'event-os'); + expect(updatedEvent?.contexts[SentryBrowser.type].name, 'event-browser'); + expect( + updatedEvent?.contexts[SentryOperatingSystem.type].name, 'event-os'); }); test('should apply the scope.contexts values ', () async { final event = SentryEvent(); final scope = Scope(SentryOptions(dsn: fakeDsn)) - ..setContexts(Device.type, Device(name: 'context-device')) - ..setContexts(App.type, App(name: 'context-app')) - ..setContexts(Gpu.type, Gpu(name: 'context-gpu')) + ..setContexts(SentryDevice.type, SentryDevice(name: 'context-device')) + ..setContexts(SentryApp.type, SentryApp(name: 'context-app')) + ..setContexts(SentryGpu.type, SentryGpu(name: 'context-gpu')) ..setContexts( SentryRuntime.listType, [SentryRuntime(name: 'context-runtime')]) - ..setContexts(Browser.type, Browser(name: 'context-browser')) - ..setContexts(OperatingSystem.type, OperatingSystem(name: 'context-os')) + ..setContexts( + SentryBrowser.type, SentryBrowser(name: 'context-browser')) + ..setContexts(SentryOperatingSystem.type, + SentryOperatingSystem(name: 'context-os')) ..setContexts('theme', 'material') ..setContexts('version', 9) ..setContexts('location', {'city': 'London'}); final updatedEvent = await scope.applyToEvent(event, null); - expect(updatedEvent?.contexts[Device.type].name, 'context-device'); - expect(updatedEvent?.contexts[App.type].name, 'context-app'); - expect(updatedEvent?.contexts[Gpu.type].name, 'context-gpu'); + expect(updatedEvent?.contexts[SentryDevice.type].name, 'context-device'); + expect(updatedEvent?.contexts[SentryApp.type].name, 'context-app'); + expect(updatedEvent?.contexts[SentryGpu.type].name, 'context-gpu'); expect( updatedEvent?.contexts[SentryRuntime.listType].first.name, 'context-runtime', ); - expect(updatedEvent?.contexts[Browser.type].name, 'context-browser'); - expect(updatedEvent?.contexts[OperatingSystem.type].name, 'context-os'); + expect( + updatedEvent?.contexts[SentryBrowser.type].name, 'context-browser'); + expect(updatedEvent?.contexts[SentryOperatingSystem.type].name, + 'context-os'); expect(updatedEvent?.contexts['theme']['value'], 'material'); expect(updatedEvent?.contexts['version']['value'], 9); expect(updatedEvent?.contexts['location'], {'city': 'London'}); diff --git a/dart/test/sentry_client_test.dart b/dart/test/sentry_client_test.dart index 5a8c0c533d..17265cda22 100644 --- a/dart/test/sentry_client_test.dart +++ b/dart/test/sentry_client_test.dart @@ -297,7 +297,7 @@ void main() { final level = SentryLevel.error; const transaction = '/test/scope'; const fingerprint = ['foo', 'bar', 'baz']; - final user = User(id: '123', username: 'test'); + final user = SentryUser(id: '123', username: 'test'); final crumb = Breadcrumb(message: 'bread'); const scopeTagKey = 'scope-tag'; const scopeTagValue = 'scope-tag-value'; @@ -359,8 +359,8 @@ void main() { final eventTransaction = '/event/transaction'; const fingerprint = ['foo', 'bar', 'baz']; const eventFingerprint = ['123', '456', '798']; - final user = User(id: '123'); - final eventUser = User(id: '987'); + final user = SentryUser(id: '123'); + final eventUser = SentryUser(id: '987'); final crumb = Breadcrumb(message: 'bread'); final eventCrumbs = [Breadcrumb(message: 'bread')]; diff --git a/dart/test/sentry_event_test.dart b/dart/test/sentry_event_test.dart index ca8b628d8b..9c168ab2d7 100644 --- a/dart/test/sentry_event_test.dart +++ b/dart/test/sentry_event_test.dart @@ -3,7 +3,7 @@ // found in the LICENSE file. import 'package:sentry/sentry.dart'; -import 'package:sentry/src/protocol/request.dart'; +import 'package:sentry/src/protocol/sentry_request.dart'; import 'package:sentry/src/sentry_stack_trace_factory.dart'; import 'package:sentry/src/utils.dart'; import 'package:sentry/src/version.dart'; @@ -59,7 +59,7 @@ void main() { }); test('serializes to JSON', () { final timestamp = DateTime.utc(2019); - final user = User( + final user = SentryUser( id: 'user_id', username: 'username', email: 'email@email.com', @@ -75,7 +75,7 @@ void main() { ), ]; - final request = Request( + final request = SentryRequest( url: 'https://api.com/users', method: 'GET', headers: const {'authorization': '123456'}, @@ -86,7 +86,7 @@ void main() { eventId: SentryId.empty(), timestamp: timestamp, platform: sdkPlatform, - message: Message( + message: SentryMessage( 'test-message 1 2', template: 'test-message %d %d', params: ['1', '2'], @@ -271,7 +271,7 @@ void main() { contexts: Contexts(), fingerprint: [], breadcrumbs: [Breadcrumb()], - request: Request(), + request: SentryRequest(), debugMeta: DebugMeta(images: []), ); final eventMap = event.toJson(); diff --git a/dart/test/test_utils.dart b/dart/test/test_utils.dart index 9f99b2125e..d4e987ac85 100644 --- a/dart/test/test_utils.dart +++ b/dart/test/test_utils.dart @@ -365,13 +365,13 @@ void runTest({Codec, List?>? gzip, bool isWeb = false}) { ); }); - final clientUser = User( + final clientUser = SentryUser( id: 'client_user', username: 'username', email: 'email@email.com', ipAddress: '127.0.0.1', ); - final eventUser = User( + final eventUser = SentryUser( id: 'event_user', username: 'username', email: 'email@email.com', diff --git a/flutter/test/file_system_transport_test.dart b/flutter/test/file_system_transport_test.dart index 08a5f29957..41b88a5cab 100644 --- a/flutter/test/file_system_transport_test.dart +++ b/flutter/test/file_system_transport_test.dart @@ -51,7 +51,8 @@ void main() { final transport = fixture.getSut(_channel); - final event = SentryEvent(message: Message('hi I am a special char ◤')); + final event = + SentryEvent(message: SentryMessage('hi I am a special char ◤')); await transport.send(event); final envelopeList = arguments as List; diff --git a/flutter/test/load_contexts_integrations_test.dart b/flutter/test/load_contexts_integrations_test.dart index 64b9e646db..dd178b10f3 100644 --- a/flutter/test/load_contexts_integrations_test.dart +++ b/flutter/test/load_contexts_integrations_test.dart @@ -76,11 +76,11 @@ void main() { expect(options.eventProcessors.length, 1); final eventContexts = Contexts( - device: const Device(name: 'eDevice'), - app: const App(name: 'eApp'), - operatingSystem: const OperatingSystem(name: 'eOS'), - gpu: const Gpu(name: 'eGpu'), - browser: const Browser(name: 'eBrowser'), + device: const SentryDevice(name: 'eDevice'), + app: const SentryApp(name: 'eApp'), + operatingSystem: const SentryOperatingSystem(name: 'eOS'), + gpu: const SentryGpu(name: 'eGpu'), + browser: const SentryBrowser(name: 'eBrowser'), runtimes: [const SentryRuntime(name: 'eRT')]) ..['theme'] = 'cuppertino'; final e = SentryEvent(contexts: eventContexts);