Skip to content

Commit 3400700

Browse files
committed
bug fix
1 parent 5329eda commit 3400700

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

core/src/main/java/com/segment/analytics/kotlin/core/Analytics.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,11 +509,11 @@ open class Analytics protected constructor(
509509
fun process(event: BaseEvent, enrichment: EnrichmentClosure? = null) {
510510
if (!enabled) return
511511

512-
event.applyBaseData()
512+
event.applyBaseData(enrichment)
513513

514514
log("applying base attributes on ${Thread.currentThread().name}")
515515
analyticsScope.launch(analyticsDispatcher) {
516-
event.applyBaseEventData(store, enrichment)
516+
event.applyBaseEventData(store)
517517
log("processing event on ${Thread.currentThread().name}")
518518
timeline.process(event)
519519
}

core/src/main/java/com/segment/analytics/kotlin/core/Events.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,16 @@ sealed class BaseEvent {
8282
internal const val ALL_INTEGRATIONS_KEY = "All"
8383
}
8484

85-
internal fun applyBaseData() {
85+
internal fun applyBaseData(enrichment: EnrichmentClosure?) {
86+
this.enrichment = enrichment
8687
this.timestamp = SegmentInstant.now()
8788
this.context = emptyJsonObject
8889
this.messageId = UUID.randomUUID().toString()
8990
}
9091

91-
internal suspend fun applyBaseEventData(store: Store, enrichment: EnrichmentClosure?) {
92+
internal suspend fun applyBaseEventData(store: Store) {
9293
val userInfo = store.currentState(UserInfo::class) ?: return
9394

94-
this.enrichment = enrichment
9595
this.anonymousId = userInfo.anonymousId
9696
this.integrations = emptyJsonObject
9797

@@ -123,6 +123,7 @@ sealed class BaseEvent {
123123
integrations = original.integrations
124124
userId = original.userId
125125
_metadata = original._metadata
126+
enrichment = original.enrichment
126127
}
127128
@Suppress("UNCHECKED_CAST")
128129
return copy as T // This is ok because resultant type will be same as input type

0 commit comments

Comments
 (0)