From 0f8a78acec1d676dee64cb9508dcb593f266956d Mon Sep 17 00:00:00 2001 From: Wenxi Zeng Date: Fri, 3 May 2024 16:02:49 -0500 Subject: [PATCH] replace utility method --- .../destination/filters/app/TestActivity.kt | 23 +------------------ 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/sample/src/main/java/com/segment/analytics/destination/filters/app/TestActivity.kt b/sample/src/main/java/com/segment/analytics/destination/filters/app/TestActivity.kt index 0727545..dd026c5 100644 --- a/sample/src/main/java/com/segment/analytics/destination/filters/app/TestActivity.kt +++ b/sample/src/main/java/com/segment/analytics/destination/filters/app/TestActivity.kt @@ -3,18 +3,10 @@ package com.segment.analytics.destination.filters.app import android.os.Bundle import android.widget.TextView import androidx.appcompat.app.AppCompatActivity -import com.segment.analytics.kotlin.core.AliasEvent -import com.segment.analytics.kotlin.core.BaseEvent -import com.segment.analytics.kotlin.core.GroupEvent -import com.segment.analytics.kotlin.core.IdentifyEvent -import com.segment.analytics.kotlin.core.ScreenEvent -import com.segment.analytics.kotlin.core.TrackEvent -import com.segment.analytics.kotlin.core.utilities.LenientJson -import com.segment.analytics.kotlin.core.utilities.getString +import com.segment.analytics.kotlin.core.utilities.toBaseEvent import com.segment.analytics.plugins.DestinationFilters import com.segment.analytics.substrata.kotlin.JSObject import com.segment.analytics.substrata.kotlin.JsonElementConverter -import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.jsonObject class TestActivity : AppCompatActivity() { @@ -133,17 +125,4 @@ class TestActivity : AppCompatActivity() { textView.text = testProgress.toString() } - - private fun JsonObject.toBaseEvent(): BaseEvent? { - val type = getString("type") - - return when (type) { - "identify" -> LenientJson.decodeFromJsonElement(IdentifyEvent.serializer(), this) - "track" -> LenientJson.decodeFromJsonElement(TrackEvent.serializer(), this) - "screen" -> LenientJson.decodeFromJsonElement(ScreenEvent.serializer(), this) - "group" -> LenientJson.decodeFromJsonElement(GroupEvent.serializer(), this) - "alias" -> LenientJson.decodeFromJsonElement(AliasEvent.serializer(), this) - else -> null - } - } }