Skip to content

Commit de0bf0f

Browse files
committed
Add event logging and auto close
1 parent 7fbcfe2 commit de0bf0f

File tree

1 file changed

+15
-9
lines changed
  • core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/activities

1 file changed

+15
-9
lines changed

core-sdk-samples/higgs-shop-sample-app/app/src/main/kotlin/com/mparticle/example/higgsshopsampleapp/activities/CheckoutActivity.kt

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import androidx.lifecycle.lifecycleScope
3131
import com.google.android.material.snackbar.BaseTransientBottomBar
3232
import com.google.android.material.snackbar.Snackbar
3333
import com.mparticle.MParticle
34-
import com.mparticle.RoktEvent
3534
import com.mparticle.RoktEvent.PlacementReady
3635
import com.mparticle.commerce.CommerceEvent
3736
import com.mparticle.commerce.Product
@@ -43,9 +42,7 @@ import com.mparticle.example.higgsshopsampleapp.databinding.ActivityCheckoutBind
4342
import com.mparticle.example.higgsshopsampleapp.repositories.database.entities.CartItemEntity
4443
import com.mparticle.example.higgsshopsampleapp.utils.Constants
4544
import com.mparticle.example.higgsshopsampleapp.viewmodels.CheckoutViewModel
46-
import com.rokt.roktsdk.Rokt
4745
import kotlinx.coroutines.delay
48-
import kotlinx.coroutines.flow.onEach
4946
import kotlinx.coroutines.launch
5047
import java.math.BigDecimal
5148
import java.util.*
@@ -109,7 +106,20 @@ class CheckoutActivity : AppCompatActivity() {
109106
}
110107

111108
private fun showRoktPlacement() {
112-
val identifer = "MSDKOverlayLayout"
109+
val identifier = "MSDKOverlayLayout"
110+
111+
lifecycleScope.launch {
112+
MParticle.getInstance()?.Rokt()?.events(identifier)?.collect {
113+
Log.v(TAG, "Rokt event: $it")
114+
when (it) {
115+
is PlacementReady -> {
116+
delay(5000)
117+
MParticle.getInstance()?.Rokt()?.close()
118+
}
119+
else -> {}
120+
}
121+
}
122+
}
113123

114124
val attributes = mapOf(
115125
"email" to "[email protected]",
@@ -120,13 +130,9 @@ class CheckoutActivity : AppCompatActivity() {
120130
)
121131

122132
MParticle.getInstance()?.Rokt()?.selectPlacements(
123-
identifier = identifer,
133+
identifier = identifier,
124134
attributes = attributes,
125135
)
126-
lifecycleScope.launch {
127-
delay(5000)
128-
MParticle.getInstance()?.Rokt()?.close()
129-
}
130136
}
131137

132138
private fun showPurchaseAlert() {

0 commit comments

Comments
 (0)