Skip to content

Commit 20b9a4a

Browse files
authored
[MOBILE-5472] Fix double counting CE for IAX triggers (#1970)
1 parent 525e6ba commit 20b9a4a

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

urbanairship-core/src/main/java/com/urbanairship/analytics/Analytics.kt

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -261,17 +261,7 @@ public constructor(
261261
* @param event The region event.
262262
*/
263263
public fun recordCustomEvent(event: CustomEvent) {
264-
if (!addEvent(event)) {
265-
return
266-
}
267-
268-
eventFeed.emit(
269-
AirshipEventFeed.Event.Analytics(
270-
event.type,
271-
event.toJsonValue(),
272-
event.eventValue?.toDouble()
273-
)
274-
)
264+
addEvent(event)
275265
}
276266

277267
/**

urbanairship-core/src/test/java/com/urbanairship/analytics/AnalyticsTest.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,24 @@ public class AnalyticsTest {
213213
coVerify(exactly = 0) { mockEventManager.addEvent(any(), any()) }
214214
}
215215

216+
@Test
217+
public fun testCustomEventFeed(): TestResult = runTest(testDispatcher) {
218+
val event = CustomEvent.newBuilder("cool").build()
219+
analytics.recordCustomEvent(event)
220+
221+
advanceUntilIdle()
222+
223+
val expectedFeedEvent = AirshipEventFeed.Event.Analytics(
224+
event.type,
225+
event.toJsonValue(),
226+
event.eventValue?.toDouble()
227+
)
228+
229+
verify(exactly = 1) {
230+
mockEventFeed.emit(expectedFeedEvent)
231+
}
232+
}
233+
216234
/**
217235
* Test adding an invalid event
218236
*/

0 commit comments

Comments
 (0)