From eb42fc5071657f1820a78f0b2c5122bd319d242e Mon Sep 17 00:00:00 2001 From: Shahroz Khan Date: Thu, 7 Nov 2024 13:15:41 +0500 Subject: [PATCH 1/7] added identify and attributes --- .../customer/customer_io/CustomerIoPlugin.kt | 23 +-- .../io/customer/customer_io/constant/Keys.kt | 4 +- apps/amiapp_flutter/lib/src/app.dart | 2 +- ios/Classes/Keys.swift | 4 +- ios/Classes/SwiftCustomerIoPlugin.swift | 135 +++++++++--------- lib/customer_io.dart | 6 +- lib/customer_io_method_channel.dart | 8 +- lib/customer_io_platform_interface.dart | 4 +- test/customer_io_method_channel_test.dart | 8 +- test/customer_io_test.dart | 16 +-- test/customer_io_test.mocks.dart | 8 +- 11 files changed, 113 insertions(+), 105 deletions(-) diff --git a/android/src/main/kotlin/io/customer/customer_io/CustomerIoPlugin.kt b/android/src/main/kotlin/io/customer/customer_io/CustomerIoPlugin.kt index 5c12a1f..a621335 100644 --- a/android/src/main/kotlin/io/customer/customer_io/CustomerIoPlugin.kt +++ b/android/src/main/kotlin/io/customer/customer_io/CustomerIoPlugin.kt @@ -22,7 +22,6 @@ import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding import io.flutter.plugin.common.MethodCall import io.flutter.plugin.common.MethodChannel import io.flutter.plugin.common.MethodChannel.MethodCallHandler -import io.flutter.plugin.common.MethodChannel.Result import java.lang.ref.WeakReference /** @@ -153,13 +152,21 @@ class CustomerIoPlugin : FlutterPlugin, MethodCallHandler, ActivityAware { } private fun identify(params: Map) { - // TODO: Fix identify implementation - /* - val identifier = params.getString(Keys.Tracking.IDENTIFIER) - val attributes = - params.getProperty>(Keys.Tracking.ATTRIBUTES) ?: emptyMap() - CustomerIO.instance().identify(identifier, attributes) - */ + val userId = params.getAsTypeOrNull(Keys.Tracking.USER_ID) + val traits = params.getAsTypeOrNull>(Keys.Tracking.TRAITS) ?: emptyMap() + + if (userId == null && traits.isEmpty()) { + logger.error("Please provide either an ID or traits to identify.") + return + } + + if (userId != null && traits.isNotEmpty()) { + CustomerIO.instance().identify(userId, traits) + } else if (userId != null) { + CustomerIO.instance().identify(userId) + } else { + CustomerIO.instance().profileAttributes = traits + } } private fun track(params: Map) { diff --git a/android/src/main/kotlin/io/customer/customer_io/constant/Keys.kt b/android/src/main/kotlin/io/customer/customer_io/constant/Keys.kt index 1bc5ec0..81670dc 100644 --- a/android/src/main/kotlin/io/customer/customer_io/constant/Keys.kt +++ b/android/src/main/kotlin/io/customer/customer_io/constant/Keys.kt @@ -17,8 +17,8 @@ internal object Keys { } object Tracking { - const val IDENTIFIER = "identifier" - const val ATTRIBUTES = "attributes" + const val USER_ID = "userId" + const val TRAITS = "traits" const val EVENT_NAME = "eventName" const val TOKEN = "token" const val DELIVERY_ID = "deliveryId" diff --git a/apps/amiapp_flutter/lib/src/app.dart b/apps/amiapp_flutter/lib/src/app.dart index 33f00be..9ca6f17 100644 --- a/apps/amiapp_flutter/lib/src/app.dart +++ b/apps/amiapp_flutter/lib/src/app.dart @@ -79,7 +79,7 @@ class _AmiAppState extends State { onLogin: (user) { _auth.login(user).then((signedIn) { if (signedIn) { - CustomerIO.instance.identify(identifier: user.email, attributes: { + CustomerIO.instance.identify(userId: user.email, traits: { "first_name": user.displayName, "email": user.email, "is_guest": user.isGuest, diff --git a/ios/Classes/Keys.swift b/ios/Classes/Keys.swift index 06f1f62..bc15524 100644 --- a/ios/Classes/Keys.swift +++ b/ios/Classes/Keys.swift @@ -16,8 +16,8 @@ struct Keys { } struct Tracking { - static let identifier = "identifier" - static let attributes = "attributes" + static let userId = "userId" + static let traits = "traits" static let eventName = "eventName" static let token = "token" static let deliveryId = "deliveryId" diff --git a/ios/Classes/SwiftCustomerIoPlugin.swift b/ios/Classes/SwiftCustomerIoPlugin.swift index ebcb1fa..caba065 100644 --- a/ios/Classes/SwiftCustomerIoPlugin.swift +++ b/ios/Classes/SwiftCustomerIoPlugin.swift @@ -8,7 +8,6 @@ public class SwiftCustomerIoPlugin: NSObject, FlutterPlugin { private var methodChannel: FlutterMethodChannel! private var inAppMessagingChannelHandler: CusomterIOInAppMessaging! - private let logger: CioInternalCommon.Logger = DIGraphShared.shared.logger public static func register(with registrar: FlutterPluginRegistrar) { @@ -70,20 +69,22 @@ public class SwiftCustomerIoPlugin: NSObject, FlutterPlugin { } private func identify(params : Dictionary){ - // TODO: Fix identify implementation - /* - guard let identifier = params[Keys.Tracking.identifier] as? String - else { - return - } - guard let attributes = params[Keys.Tracking.attributes] as? Dictionary else{ - CustomerIO.shared.identify(identifier: identifier) + let userId = params[Keys.Tracking.userId] as? String + let traits = params[Keys.Tracking.traits] as? Dictionary ?? [:] + + if userId == nil && traits.isEmpty { + logger.error("Please provide either an ID or traits to identify.") return } - CustomerIO.shared.identify(identifier: identifier, body: attributes) - */ + if let userId = userId, !traits.isEmpty { + CustomerIO.shared.identify(userId: userId, traits: traits) + } else if let userId = userId { + CustomerIO.shared.identify(userId: userId) + } else { + CustomerIO.shared.profileAttributes = traits + } } private func clearIdentify() { @@ -93,17 +94,17 @@ public class SwiftCustomerIoPlugin: NSObject, FlutterPlugin { private func track(params : Dictionary) { // TODO: Fix track implementation /* - guard let name = params[Keys.Tracking.eventName] as? String - else { - return - } - - guard let attributes = params[Keys.Tracking.attributes] as? Dictionary else{ - CustomerIO.shared.track(name: name) - return - } - - CustomerIO.shared.track(name: name, data: attributes) + guard let name = params[Keys.Tracking.eventName] as? String + else { + return + } + + guard let attributes = params[Keys.Tracking.attributes] as? Dictionary else{ + CustomerIO.shared.track(name: name) + return + } + + CustomerIO.shared.track(name: name, data: attributes) */ } @@ -111,17 +112,17 @@ public class SwiftCustomerIoPlugin: NSObject, FlutterPlugin { func screen(params : Dictionary) { // TODO: Fix screen implementation /* - guard let name = params[Keys.Tracking.eventName] as? String - else { - return - } - - guard let attributes = params[Keys.Tracking.attributes] as? Dictionary else{ - CustomerIO.shared.screen(name: name) - return - } - - CustomerIO.shared.screen(name: name, data: attributes) + guard let name = params[Keys.Tracking.eventName] as? String + else { + return + } + + guard let attributes = params[Keys.Tracking.attributes] as? Dictionary else{ + CustomerIO.shared.screen(name: name) + return + } + + CustomerIO.shared.screen(name: name, data: attributes) */ } @@ -129,51 +130,51 @@ public class SwiftCustomerIoPlugin: NSObject, FlutterPlugin { private func setDeviceAttributes(params : Dictionary){ // TODO: Fix setDeviceAttributes implementation /* - guard let attributes = params[Keys.Tracking.attributes] as? Dictionary - else { - return - } - CustomerIO.shared.deviceAttributes = attributes + guard let attributes = params[Keys.Tracking.attributes] as? Dictionary + else { + return + } + CustomerIO.shared.deviceAttributes = attributes */ } private func setProfileAttributes(params : Dictionary){ // TODO: Fix setProfileAttributes implementation /* - guard let attributes = params[Keys.Tracking.attributes] as? Dictionary - else { - return - } - CustomerIO.shared.profileAttributes = attributes + guard let attributes = params[Keys.Tracking.attributes] as? Dictionary + else { + return + } + CustomerIO.shared.profileAttributes = attributes */ } private func registerDeviceToken(params : Dictionary){ // TODO: Fix registerDeviceToken implementation /* - guard let token = params[Keys.Tracking.token] as? String - else { - return - } - - CustomerIO.shared.registerDeviceToken(token) + guard let token = params[Keys.Tracking.token] as? String + else { + return + } + + CustomerIO.shared.registerDeviceToken(token) */ } private func trackMetric(params : Dictionary){ // TODO: Fix trackMetric implementation /* - guard let deliveryId = params[Keys.Tracking.deliveryId] as? String, - let deviceToken = params[Keys.Tracking.deliveryToken] as? String, - let metricEvent = params[Keys.Tracking.metricEvent] as? String, - let event = Metric.getEvent(from: metricEvent) - else { - return - } - - CustomerIO.shared.trackMetric(deliveryID: deliveryId, - event: event, - deviceToken: deviceToken) + guard let deliveryId = params[Keys.Tracking.deliveryId] as? String, + let deviceToken = params[Keys.Tracking.deliveryToken] as? String, + let metricEvent = params[Keys.Tracking.metricEvent] as? String, + let event = Metric.getEvent(from: metricEvent) + else { + return + } + + CustomerIO.shared.trackMetric(deliveryID: deliveryId, + event: event, + deviceToken: deviceToken) */ } @@ -195,13 +196,13 @@ public class SwiftCustomerIoPlugin: NSObject, FlutterPlugin { private func initializeInApp(){ // TODO: Fix initializeInApp implementation /* - DispatchQueue.main.async { - MessagingInApp.shared.initialize(eventListener: CustomerIOInAppEventListener( - invokeMethod: {method,args in - self.invokeMethod(method, args) - }) - ) - } + DispatchQueue.main.async { + MessagingInApp.shared.initialize(eventListener: CustomerIOInAppEventListener( + invokeMethod: {method,args in + self.invokeMethod(method, args) + }) + ) + } */ } diff --git a/lib/customer_io.dart b/lib/customer_io.dart index 4584e5b..5918469 100644 --- a/lib/customer_io.dart +++ b/lib/customer_io.dart @@ -88,9 +88,9 @@ class CustomerIO { /// @param identifier unique identifier for a profile /// @param attributes (Optional) params to set profile attributes void identify( - {required String identifier, - Map attributes = const {}}) { - return _platform.identify(identifier: identifier, attributes: attributes); + {required String userId, + Map traits = const {}}) { + return _platform.identify(userId: userId, traits: traits); } /// Call this function to stop identifying a person. diff --git a/lib/customer_io_method_channel.dart b/lib/customer_io_method_channel.dart index 1f64cd2..6c70669 100644 --- a/lib/customer_io_method_channel.dart +++ b/lib/customer_io_method_channel.dart @@ -77,12 +77,12 @@ class CustomerIOMethodChannel extends CustomerIOPlatform { /// will be removed automatically. @override void identify( - {required String identifier, - Map attributes = const {}}) async { + {required String userId, + Map traits = const {}}) async { try { final payload = { - TrackingConsts.identifier: identifier, - TrackingConsts.attributes: attributes + TrackingConsts.identifier: userId, + TrackingConsts.attributes: traits }; methodChannel.invokeMethod(MethodConsts.identify, payload); } on PlatformException catch (exception) { diff --git a/lib/customer_io_platform_interface.dart b/lib/customer_io_platform_interface.dart index 2ab9be0..27bf781 100644 --- a/lib/customer_io_platform_interface.dart +++ b/lib/customer_io_platform_interface.dart @@ -35,8 +35,8 @@ abstract class CustomerIOPlatform extends PlatformInterface { } void identify( - {required String identifier, - Map attributes = const {}}) { + {required String userId, + Map traits = const {}}) { throw UnimplementedError('identify() has not been implemented.'); } diff --git a/test/customer_io_method_channel_test.dart b/test/customer_io_method_channel_test.dart index 1a91ac8..7f60318 100644 --- a/test/customer_io_method_channel_test.dart +++ b/test/customer_io_method_channel_test.dart @@ -62,14 +62,14 @@ void main() { test('identify() should call platform method with correct arguments', () async { final Map args = { - 'identifier': 'Customer 1', - 'attributes': {'email': 'customer@email.com'} + 'userId': 'Customer 1', + 'traits': {'email': 'customer@email.com'} }; final customerIO = CustomerIOMethodChannel(); customerIO.identify( - identifier: args['identifier'] as String, - attributes: args['attributes']); + userId: args['userId'] as String, + traits: args['traits']); expectMethodInvocationArguments('identify', args); }); diff --git a/test/customer_io_test.dart b/test/customer_io_test.dart index 77b06e8..15e9848 100644 --- a/test/customer_io_test.dart +++ b/test/customer_io_test.dart @@ -97,13 +97,13 @@ void main() { const givenIdentifier = 'user@example.com'; final givenAttributes = {'name': 'John Doe'}; CustomerIO.instance.identify( - identifier: givenIdentifier, - attributes: givenAttributes, + userId: givenIdentifier, + traits: givenAttributes, ); verify(mockPlatform.identify( - identifier: givenIdentifier, - attributes: givenAttributes, + userId: givenIdentifier, + traits: givenAttributes, )).called(1); }); @@ -111,13 +111,13 @@ void main() { const givenIdentifier = 'user@example.com'; final givenAttributes = {'name': 'John Doe'}; CustomerIO.instance.identify( - identifier: givenIdentifier, - attributes: givenAttributes, + userId: givenIdentifier, + traits: givenAttributes, ); expect( verify(mockPlatform.identify( - identifier: captureAnyNamed("identifier"), - attributes: captureAnyNamed("attributes"), + userId: captureAnyNamed("userId"), + traits: captureAnyNamed("traits"), )).captured, [givenIdentifier, givenAttributes], ); diff --git a/test/customer_io_test.mocks.dart b/test/customer_io_test.mocks.dart index b745f01..7b1a273 100644 --- a/test/customer_io_test.mocks.dart +++ b/test/customer_io_test.mocks.dart @@ -56,16 +56,16 @@ class MockTestCustomerIoPlatform extends _i1.Mock ) as _i2.Future); @override void identify({ - required String? identifier, - Map? attributes = const {}, + required String? userId, + Map? traits = const {}, }) => super.noSuchMethod( Invocation.method( #identify, [], { - #identifier: identifier, - #attributes: attributes, + #identifier: userId, + #attributes: traits, }, ), returnValueForMissingStub: null, From 1c7d0967e1e70f18e531dc5d3b2e63c87079a21c Mon Sep 17 00:00:00 2001 From: Shahroz Khan Date: Thu, 7 Nov 2024 13:51:59 +0500 Subject: [PATCH 2/7] mocks fail --- test/customer_io_test.mocks.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/customer_io_test.mocks.dart b/test/customer_io_test.mocks.dart index 7b1a273..06d7e5b 100644 --- a/test/customer_io_test.mocks.dart +++ b/test/customer_io_test.mocks.dart @@ -64,8 +64,8 @@ class MockTestCustomerIoPlatform extends _i1.Mock #identify, [], { - #identifier: userId, - #attributes: traits, + #userId: userId, + #traits: traits, }, ), returnValueForMissingStub: null, From 04b15ede22ef20bebb17aae072ee7311038a0759 Mon Sep 17 00:00:00 2001 From: Shahroz Khan Date: Thu, 7 Nov 2024 14:02:27 +0500 Subject: [PATCH 3/7] profile attributes --- .../io/customer/customer_io/CustomerIoPlugin.kt | 5 +---- ios/Classes/SwiftCustomerIoPlugin.swift | 11 +++-------- lib/customer_io_const.dart | 3 ++- lib/customer_io_method_channel.dart | 2 +- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/android/src/main/kotlin/io/customer/customer_io/CustomerIoPlugin.kt b/android/src/main/kotlin/io/customer/customer_io/CustomerIoPlugin.kt index a621335..4e1fb75 100644 --- a/android/src/main/kotlin/io/customer/customer_io/CustomerIoPlugin.kt +++ b/android/src/main/kotlin/io/customer/customer_io/CustomerIoPlugin.kt @@ -221,12 +221,9 @@ class CustomerIoPlugin : FlutterPlugin, MethodCallHandler, ActivityAware { } private fun setProfileAttributes(params: Map) { - // TODO: Fix setProfileAttributes implementation - /* - val attributes = params.getProperty>(Keys.Tracking.ATTRIBUTES) ?: return + val attributes = params.getAsTypeOrNull>(Keys.Tracking.TRAITS) ?: return CustomerIO.instance().profileAttributes = attributes - */ } private fun screen(params: Map) { diff --git a/ios/Classes/SwiftCustomerIoPlugin.swift b/ios/Classes/SwiftCustomerIoPlugin.swift index caba065..bc5e665 100644 --- a/ios/Classes/SwiftCustomerIoPlugin.swift +++ b/ios/Classes/SwiftCustomerIoPlugin.swift @@ -139,14 +139,9 @@ public class SwiftCustomerIoPlugin: NSObject, FlutterPlugin { } private func setProfileAttributes(params : Dictionary){ - // TODO: Fix setProfileAttributes implementation - /* - guard let attributes = params[Keys.Tracking.attributes] as? Dictionary - else { - return - } - CustomerIO.shared.profileAttributes = attributes - */ + guard let attributes = params[Keys.Tracking.traits] as? Dictionary + else { return } + CustomerIO.shared.profileAttributes = attributes } private func registerDeviceToken(params : Dictionary){ diff --git a/lib/customer_io_const.dart b/lib/customer_io_const.dart index b7dfa58..c6ca7a1 100644 --- a/lib/customer_io_const.dart +++ b/lib/customer_io_const.dart @@ -13,7 +13,8 @@ class MethodConsts { } class TrackingConsts { - static const String identifier = "identifier"; + static const String userId = "userId"; + static const String traits = "traits"; static const String attributes = "attributes"; static const String eventName = "eventName"; static const String token = "token"; diff --git a/lib/customer_io_method_channel.dart b/lib/customer_io_method_channel.dart index 6c70669..5e71dcd 100644 --- a/lib/customer_io_method_channel.dart +++ b/lib/customer_io_method_channel.dart @@ -170,7 +170,7 @@ class CustomerIOMethodChannel extends CustomerIOPlatform { @override void setProfileAttributes({required Map attributes}) { try { - final payload = {TrackingConsts.attributes: attributes}; + final payload = {TrackingConsts.traits: attributes}; methodChannel.invokeMethod(MethodConsts.setProfileAttributes, payload); } on PlatformException catch (exception) { handleException(exception); From 21fee0a3cfbf63e69b49cb3f4905a8e1722ebcd8 Mon Sep 17 00:00:00 2001 From: Shahroz Khan Date: Thu, 7 Nov 2024 14:03:12 +0500 Subject: [PATCH 4/7] typo --- lib/customer_io_method_channel.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/customer_io_method_channel.dart b/lib/customer_io_method_channel.dart index 5e71dcd..e870f97 100644 --- a/lib/customer_io_method_channel.dart +++ b/lib/customer_io_method_channel.dart @@ -81,7 +81,7 @@ class CustomerIOMethodChannel extends CustomerIOPlatform { Map traits = const {}}) async { try { final payload = { - TrackingConsts.identifier: userId, + TrackingConsts.userId: userId, TrackingConsts.attributes: traits }; methodChannel.invokeMethod(MethodConsts.identify, payload); From 8a766e37cd9f820e5425275041d64319ec47fdc2 Mon Sep 17 00:00:00 2001 From: Shahroz Khan Date: Thu, 7 Nov 2024 14:10:09 +0500 Subject: [PATCH 5/7] typos --- lib/customer_io.dart | 6 +++--- lib/customer_io_method_channel.dart | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/customer_io.dart b/lib/customer_io.dart index 5918469..8622f0d 100644 --- a/lib/customer_io.dart +++ b/lib/customer_io.dart @@ -80,13 +80,13 @@ class CustomerIO { } } - /// Identify a person using a unique identifier, eg. email id. + /// Identify a person using a unique userId, eg. email id. /// Note that you can identify only 1 profile at a time. In case, multiple /// identifiers are attempted to be identified, then the last identified profile /// will be removed automatically. /// - /// @param identifier unique identifier for a profile - /// @param attributes (Optional) params to set profile attributes + /// @param userId unique identifier for a profile + /// @param traits (Optional) params to set profile attributes void identify( {required String userId, Map traits = const {}}) { diff --git a/lib/customer_io_method_channel.dart b/lib/customer_io_method_channel.dart index e870f97..ded1b89 100644 --- a/lib/customer_io_method_channel.dart +++ b/lib/customer_io_method_channel.dart @@ -71,7 +71,7 @@ class CustomerIOMethodChannel extends CustomerIOPlatform { } } - /// Identify a person using a unique identifier, eg. email id. + /// Identify a person using a unique userId, eg. email id. /// Note that you can identify only 1 profile at a time. In case, multiple /// identifiers are attempted to be identified, then the last identified profile /// will be removed automatically. From 8bd4da7e73076600f9d86c8b3ace99dc67dbf509 Mon Sep 17 00:00:00 2001 From: Shahroz Khan Date: Thu, 7 Nov 2024 21:09:43 +0500 Subject: [PATCH 6/7] test fix --- lib/customer_io_method_channel.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/customer_io_method_channel.dart b/lib/customer_io_method_channel.dart index ded1b89..7d586c5 100644 --- a/lib/customer_io_method_channel.dart +++ b/lib/customer_io_method_channel.dart @@ -82,7 +82,7 @@ class CustomerIOMethodChannel extends CustomerIOPlatform { try { final payload = { TrackingConsts.userId: userId, - TrackingConsts.attributes: traits + TrackingConsts.traits: traits }; methodChannel.invokeMethod(MethodConsts.identify, payload); } on PlatformException catch (exception) { From 3e925d66f6a63ae37b1c52d2e08c4f38b3a8bb95 Mon Sep 17 00:00:00 2001 From: Shahroz Khan Date: Thu, 7 Nov 2024 22:59:50 +0500 Subject: [PATCH 7/7] profile attributs fixes --- lib/customer_io.dart | 2 +- lib/customer_io_method_channel.dart | 4 ++-- lib/customer_io_platform_interface.dart | 2 +- test/customer_io_method_channel_test.dart | 4 ++-- test/customer_io_test.dart | 2 +- test/customer_io_test.mocks.dart | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/customer_io.dart b/lib/customer_io.dart index 8622f0d..142bcd8 100644 --- a/lib/customer_io.dart +++ b/lib/customer_io.dart @@ -148,7 +148,7 @@ class CustomerIO { /// /// @param attributes additional attributes for a user profile void setProfileAttributes({required Map attributes}) { - return _platform.setProfileAttributes(attributes: attributes); + return _platform.setProfileAttributes(traits: attributes); } /// Subscribes to an in-app event listener. diff --git a/lib/customer_io_method_channel.dart b/lib/customer_io_method_channel.dart index 7d586c5..9510b99 100644 --- a/lib/customer_io_method_channel.dart +++ b/lib/customer_io_method_channel.dart @@ -168,9 +168,9 @@ class CustomerIOMethodChannel extends CustomerIOPlatform { /// Set custom user profile information such as user preference, specific /// user actions etc @override - void setProfileAttributes({required Map attributes}) { + void setProfileAttributes({required Map traits}) { try { - final payload = {TrackingConsts.traits: attributes}; + final payload = {TrackingConsts.traits: traits}; methodChannel.invokeMethod(MethodConsts.setProfileAttributes, payload); } on PlatformException catch (exception) { handleException(exception); diff --git a/lib/customer_io_platform_interface.dart b/lib/customer_io_platform_interface.dart index 27bf781..f85f0d5 100644 --- a/lib/customer_io_platform_interface.dart +++ b/lib/customer_io_platform_interface.dart @@ -69,7 +69,7 @@ abstract class CustomerIOPlatform extends PlatformInterface { throw UnimplementedError('setDeviceAttributes() has not been implemented.'); } - void setProfileAttributes({required Map attributes}) { + void setProfileAttributes({required Map traits}) { throw UnimplementedError( 'setProfileAttributes() has not been implemented.'); } diff --git a/test/customer_io_method_channel_test.dart b/test/customer_io_method_channel_test.dart index 7f60318..2552c46 100644 --- a/test/customer_io_method_channel_test.dart +++ b/test/customer_io_method_channel_test.dart @@ -140,11 +140,11 @@ void main() { 'setProfileAttributes() should call platform method with correct arguments', () async { final Map args = { - 'attributes': {'age': 1} + 'traits': {'age': 1} }; final customerIO = CustomerIOMethodChannel(); - customerIO.setProfileAttributes(attributes: args['attributes']); + customerIO.setProfileAttributes(traits: args['traits']); expectMethodInvocationArguments('setProfileAttributes', args); }); diff --git a/test/customer_io_test.dart b/test/customer_io_test.dart index 15e9848..69476eb 100644 --- a/test/customer_io_test.dart +++ b/test/customer_io_test.dart @@ -172,7 +172,7 @@ void main() { CustomerIO.instance.setProfileAttributes(attributes: givenAttributes); expect( verify(mockPlatform.setProfileAttributes( - attributes: captureAnyNamed("attributes"), + traits: captureAnyNamed("traits"), )).captured.first, givenAttributes, ); diff --git a/test/customer_io_test.mocks.dart b/test/customer_io_test.mocks.dart index 06d7e5b..f306ef0 100644 --- a/test/customer_io_test.mocks.dart +++ b/test/customer_io_test.mocks.dart @@ -149,12 +149,12 @@ class MockTestCustomerIoPlatform extends _i1.Mock returnValueForMissingStub: null, ); @override - void setProfileAttributes({required Map? attributes}) => + void setProfileAttributes({required Map? traits}) => super.noSuchMethod( Invocation.method( #setProfileAttributes, [], - {#attributes: attributes}, + {#traits: traits}, ), returnValueForMissingStub: null, );