diff --git a/example/lib/event_form.dart b/example/lib/event_form.dart index e5c15d6..d95fe8e 100644 --- a/example/lib/event_form.dart +++ b/example/lib/event_form.dart @@ -14,7 +14,7 @@ class _EventFormState extends State { void onPress() { AppState.of(context) - ..analytics.track(BaseEvent(eventType: _controller.text)) + ..analytics.track(BaseEvent(_controller.text)) ..setMessage('Event sent.'); } diff --git a/lib/amplitude.dart b/lib/amplitude.dart index c7a749d..2657cba 100644 --- a/lib/amplitude.dart +++ b/lib/amplitude.dart @@ -51,7 +51,7 @@ class Amplitude { /// (whichever comes first), as well as on app close. /// /// ``` - /// amplitude.track(BaseEvent(eventType: 'Button Clicked')) + /// amplitude.track(BaseEvent('Button Clicked')) /// ``` Future track( BaseEvent event, [ diff --git a/lib/events/base_event.dart b/lib/events/base_event.dart index b70b233..dd7f8b2 100644 --- a/lib/events/base_event.dart +++ b/lib/events/base_event.dart @@ -9,51 +9,51 @@ class BaseEvent extends EventOptions { Map? groups; Map? groupProperties; - BaseEvent({ - String? userId, - String? deviceId, - int? timestamp, - int? eventId, - int? sessionId, - String? insertId, - double? locationLat, - double? locationLng, - String? appVersion, - String? versionName, - String? platform, - String? osName, - String? osVersion, - String? deviceBrand, - String? deviceManufacturer, - String? deviceModel, - String? carrier, - String? country, - String? region, - String? city, - String? dma, - String? idfa, - String? idfv, - String? adid, - String? appSetId, - String? androidId, - String? language, - String? library, - String? ip, - Plan? plan, - IngestionMetadata? ingestionMetadata, - double? revenue, - double? price, - int? quantity, - String? productId, - String? revenueType, - Map? extra, - String? partnerId, - required this.eventType, - this.eventProperties, - this.userProperties, - this.groups, - this.groupProperties, - }) : super( + BaseEvent( + this.eventType, { + String? userId, + String? deviceId, + int? timestamp, + int? eventId, + int? sessionId, + String? insertId, + double? locationLat, + double? locationLng, + String? appVersion, + String? versionName, + String? platform, + String? osName, + String? osVersion, + String? deviceBrand, + String? deviceManufacturer, + String? deviceModel, + String? carrier, + String? country, + String? region, + String? city, + String? dma, + String? idfa, + String? idfv, + String? adid, + String? appSetId, + String? androidId, + String? language, + String? library, + String? ip, + Plan? plan, + IngestionMetadata? ingestionMetadata, + double? revenue, + double? price, + int? quantity, + String? productId, + String? revenueType, + Map? extra, + String? partnerId, + this.eventProperties, + this.userProperties, + this.groups, + this.groupProperties, + }) : super( userId: userId, deviceId: deviceId, timestamp: timestamp, @@ -131,7 +131,8 @@ class BaseEvent extends EventOptions { if (library != null) 'library': library, if (ip != null) 'ip': ip, if (plan != null) 'plan': plan?.toMap(), - if (ingestionMetadata != null) 'ingestion_metadata': ingestionMetadata?.toMap(), + if (ingestionMetadata != null) + 'ingestion_metadata': ingestionMetadata?.toMap(), if (revenue != null) 'revenue': revenue, if (price != null) 'price': price, if (quantity != null) 'quantity': quantity, diff --git a/lib/events/group_identify_event.dart b/lib/events/group_identify_event.dart index 94891c6..a70f276 100644 --- a/lib/events/group_identify_event.dart +++ b/lib/events/group_identify_event.dart @@ -2,5 +2,5 @@ import '../constants.dart'; import 'base_event.dart'; class GroupIdentifyEvent extends BaseEvent { - GroupIdentifyEvent() : super(eventType: Constants.groupIdentifyEvent); + GroupIdentifyEvent() : super(Constants.groupIdentifyEvent); } diff --git a/lib/events/identify_event.dart b/lib/events/identify_event.dart index 6f91f48..7eea551 100644 --- a/lib/events/identify_event.dart +++ b/lib/events/identify_event.dart @@ -2,5 +2,5 @@ import '../constants.dart'; import 'base_event.dart'; class IdentifyEvent extends BaseEvent { - IdentifyEvent() : super(eventType: Constants.identifyEvent); + IdentifyEvent() : super(Constants.identifyEvent); } diff --git a/lib/events/revenue_event.dart b/lib/events/revenue_event.dart index c6850c8..43b59b6 100644 --- a/lib/events/revenue_event.dart +++ b/lib/events/revenue_event.dart @@ -2,5 +2,5 @@ import '../constants.dart'; import 'base_event.dart'; class RevenueEvent extends BaseEvent { - RevenueEvent() : super(eventType: Constants.revenueEvent); + RevenueEvent() : super(Constants.revenueEvent); } diff --git a/test/amplitude_test.dart b/test/amplitude_test.dart index 3ff9f46..377de8f 100644 --- a/test/amplitude_test.dart +++ b/test/amplitude_test.dart @@ -86,7 +86,7 @@ void main() { // Pass it for FlutterLibraryPlugin 'library': '${Constants.packageName}/${Constants.packageVersion}' }; - final testEvent = BaseEvent(eventType: 'testEvent'); + final testEvent = BaseEvent('testEvent'); final testEventMap = { 'event_type': 'testEvent', 'attempts': 0, diff --git a/test/events/base_event_test.dart b/test/events/base_event_test.dart index 76f2dc8..49b15a0 100644 --- a/test/events/base_event_test.dart +++ b/test/events/base_event_test.dart @@ -8,7 +8,7 @@ void main() { group('BaseEvent', () { test('Should init with default values', () { final testEventType = 'test-event-type'; - final event = BaseEvent(eventType: testEventType); + final event = BaseEvent(testEventType); expect(event.eventType, testEventType); expect(event.eventProperties, isNull); @@ -30,7 +30,7 @@ void main() { 'test-group-property-key': 'test-group-property-value' }; final event = BaseEvent( - eventType: testEventType, + testEventType, eventProperties: testEventProperties, userProperties: testUserProperties, groups: testGroups, @@ -86,6 +86,7 @@ void main() { final partnerId = 'partner_id'; final event = BaseEvent( + eventType, userId: userId, deviceId: deviceId, timestamp: timestamp, @@ -124,7 +125,6 @@ void main() { revenueType: revenueType, extra: extra, partnerId: partnerId, - eventType: eventType, ); final expectedMap = { @@ -179,7 +179,7 @@ void main() { final deviceId = 'device_id'; final eventType = 'event_type'; - final originalEvent = BaseEvent(userId: originalUserId, deviceId: deviceId, eventType: eventType); + final originalEvent = BaseEvent(eventType, userId: originalUserId, deviceId: deviceId); final newOptions = EventOptions(userId: newUserId); originalEvent.mergeEventOptions(newOptions);