@@ -16,6 +16,8 @@ import io.customer.sdk.core.di.SDKComponent
16
16
import io.customer.sdk.core.util.CioLogLevel
17
17
import io.customer.sdk.core.util.Logger
18
18
import io.customer.sdk.data.model.Region
19
+ import io.customer.sdk.events.Metric
20
+ import io.customer.sdk.events.TrackMetric
19
21
import io.flutter.embedding.engine.plugins.FlutterPlugin
20
22
import io.flutter.embedding.engine.plugins.activity.ActivityAware
21
23
import io.flutter.embedding.engine.plugins.activity.ActivityPluginBinding
@@ -191,22 +193,23 @@ class CustomerIoPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
191
193
}
192
194
193
195
private fun trackMetric (params : Map <String , Any >) {
194
- // TODO: Fix trackMetric implementation
195
- /*
196
- val deliveryId = params.getString(Keys.Tracking.DELIVERY_ID)
197
- val deliveryToken = params.getString(Keys.Tracking.DELIVERY_TOKEN)
198
- val eventName = params.getProperty<String>(Keys.Tracking.METRIC_EVENT)
199
- val event = MetricEvent.getEvent(eventName)
200
-
201
- if (event == null) {
202
- logger.info("metric event type null. Possible issue with SDK? Given: $eventName")
203
- return
196
+ val deliveryId = params.getAsTypeOrNull<String >(Keys .Tracking .DELIVERY_ID )
197
+ val deliveryToken = params.getAsTypeOrNull<String >(Keys .Tracking .DELIVERY_TOKEN )
198
+ val eventName = params.getAsTypeOrNull<String >(Keys .Tracking .METRIC_EVENT )
199
+
200
+ if (deliveryId == null || deliveryToken == null || eventName == null ) {
201
+ throw IllegalArgumentException (" Missing required parameters" )
204
202
}
205
203
204
+ val event = Metric .valueOf(eventName)
205
+
206
206
CustomerIO .instance().trackMetric(
207
- deliveryID = deliveryId, deviceToken = deliveryToken, event = event
207
+ event = TrackMetric .Push (
208
+ deliveryId = deliveryId,
209
+ deviceToken = deliveryToken,
210
+ metric = event
211
+ )
208
212
)
209
- */
210
213
}
211
214
212
215
private fun setDeviceAttributes (params : Map <String , Any >) {
0 commit comments