diff --git a/android/src/main/kotlin/com/amplitude/amplitude_flutter/AmplitudeFlutterPlugin.kt b/android/src/main/kotlin/com/amplitude/amplitude_flutter/AmplitudeFlutterPlugin.kt index 2a20845..c55f443 100644 --- a/android/src/main/kotlin/com/amplitude/amplitude_flutter/AmplitudeFlutterPlugin.kt +++ b/android/src/main/kotlin/com/amplitude/amplitude_flutter/AmplitudeFlutterPlugin.kt @@ -81,44 +81,12 @@ class AmplitudeFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware { result.success("init called..") } - "track" -> { + "track", "identify", "groupIdentify", "setGroup", "revenue" -> { val event = getEvent(call) amplitude.track(event) - amplitude.logger.debug("Track event: ${call.arguments}") + amplitude.logger.debug("Track ${call.method} event: ${call.arguments}") - result.success("track called..") - } - - "identify" -> { - val event = getEvent(call) - amplitude.track(event) - amplitude.logger.debug("Track identify event: ${call.arguments}") - - result.success("identify called..") - } - - "groupIdentify" -> { - val event = getEvent(call) - amplitude.track(event) - amplitude.logger.debug("Track group identify event: ${call.arguments}") - - result.success("groupIdentify called..") - } - - "setGroup" -> { - val event = getEvent(call) - amplitude.track(event) - amplitude.logger.debug("Track set group event: ${call.arguments}") - - result.success("setGroup called..") - } - - "revenue" -> { - val event = getEvent(call) - amplitude.track(event) - amplitude.logger.debug("Track revenue event: ${call.arguments}") - - result.success("revenue called..") + result.success("${call.method} called..") } "setUserId" -> { diff --git a/ios/Classes/SwiftAmplitudeFlutterPlugin.swift b/ios/Classes/SwiftAmplitudeFlutterPlugin.swift index 27d5cc8..536d7a5 100644 --- a/ios/Classes/SwiftAmplitudeFlutterPlugin.swift +++ b/ios/Classes/SwiftAmplitudeFlutterPlugin.swift @@ -35,7 +35,7 @@ import AmplitudeSwift result("init called..") - case "track": + case "track", "identify", "groupIdentify", "setGroup", "revenue": guard let args = call.arguments as? [String: Any] else { print("\(call.method) called but call.arguments type casting failed.") return @@ -44,75 +44,11 @@ import AmplitudeSwift do { let event = try getEvent(args: args) amplitude?.track(event: event) - amplitude?.logger?.debug(message: "Track event: \(String(describing: call.arguments))") + amplitude?.logger?.debug(message: "Track \(call.method) event: \(String(describing: call.arguments))") - result("track called..") + result("\(call.method) called..") } catch { - amplitude?.logger?.warn(message: "track called but failed.") - } - - case "identify": - guard let args = call.arguments as? [String: Any] else { - print("\(call.method) called but call.arguments type casting failed.") - return - } - - do { - let event = try getEvent(args: args) - amplitude?.track(event: event) - amplitude?.logger?.debug(message: "Track identify event: \(String(describing: call.arguments))") - - result("identify called..") - } catch { - amplitude?.logger?.warn(message: "identify called but failed.") - } - - case "groupIdentify": - guard let args = call.arguments as? [String: Any] else { - print("\(call.method) called but call.arguments type casting failed.") - return - } - - do { - let event = try getEvent(args: args) - amplitude?.track(event: event) - amplitude?.logger?.debug(message: "Track group identify event: \(String(describing: call.arguments))") - - result("groupIdentify called..") - } catch { - amplitude?.logger?.warn(message: "groupIdentify called but failed.") - } - - case "setGroup": - guard let args = call.arguments as? [String: Any] else { - print("\(call.method) called but call.arguments type casting failed.") - return - } - - do { - let event = try getEvent(args: args) - amplitude?.track(event: event) - amplitude?.logger?.debug(message: "Track set group event: \(String(describing: call.arguments))") - - result("setGroup called..") - } catch { - amplitude?.logger?.warn(message: "setGroup called but failed.") - } - - case "revenue": - guard let args = call.arguments as? [String: Any] else { - print("\(call.method) called but call.arguments type casting failed.") - return - } - - do { - let event = try getEvent(args: args) - amplitude?.track(event: event) - amplitude?.logger?.debug(message: "Track revenue event: \(String(describing: call.arguments))") - - result("revenue called..") - } catch { - amplitude?.logger?.warn(message: "revenue called but failed.") + amplitude?.logger?.warn(message: "\(call.method) called but failed.") } case "setUserId":