@@ -16,13 +16,14 @@ 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
22
24
import io.flutter.plugin.common.MethodCall
23
25
import io.flutter.plugin.common.MethodChannel
24
26
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
25
- import io.flutter.plugin.common.MethodChannel.Result
26
27
import java.lang.ref.WeakReference
27
28
28
29
/* *
@@ -191,22 +192,23 @@ class CustomerIoPlugin : FlutterPlugin, MethodCallHandler, ActivityAware {
191
192
}
192
193
193
194
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
195
+ val deliveryId = params.getAsTypeOrNull<String >(Keys .Tracking .DELIVERY_ID )
196
+ val deliveryToken = params.getAsTypeOrNull<String >(Keys .Tracking .DELIVERY_TOKEN )
197
+ val eventName = params.getAsTypeOrNull<String >(Keys .Tracking .METRIC_EVENT )
198
+
199
+ if (deliveryId == null || deliveryToken == null || eventName == null ) {
200
+ throw IllegalArgumentException (" Missing required parameters" )
204
201
}
205
202
203
+ val event = Metric .valueOf(eventName)
204
+
206
205
CustomerIO .instance().trackMetric(
207
- deliveryID = deliveryId, deviceToken = deliveryToken, event = event
206
+ event = TrackMetric .Push (
207
+ deliveryId = deliveryId,
208
+ deviceToken = deliveryToken,
209
+ metric = event
210
+ )
208
211
)
209
- */
210
212
}
211
213
212
214
private fun setDeviceAttributes (params : Map <String , Any >) {
0 commit comments