Skip to content

Commit 9924563

Browse files
committed
Merge setVitalOperationStepEventMapper & setVitalAppLaunchEventMapper
1 parent deb5025 commit 9924563

File tree

7 files changed

+67
-44
lines changed

7 files changed

+67
-44
lines changed

features/dd-sdk-android-rum/api/apiSurface

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ data class com.datadog.android.rum.RumConfiguration
7575
fun setErrorEventMapper(com.datadog.android.event.EventMapper<com.datadog.android.rum.model.ErrorEvent>): Builder
7676
fun setLongTaskEventMapper(com.datadog.android.event.EventMapper<com.datadog.android.rum.model.LongTaskEvent>): Builder
7777
DEPRECATED fun setVitalEventMapper(com.datadog.android.event.EventMapper<com.datadog.android.rum.model.RumVitalOperationStepEvent>): Builder
78-
fun setVitalOperationStepEventMapper(com.datadog.android.event.EventMapper<com.datadog.android.rum.model.RumVitalOperationStepEvent>): Builder
79-
fun setVitalAppLaunchEventMapper(com.datadog.android.event.EventMapper<com.datadog.android.rum.model.RumVitalAppLaunchEvent>): Builder
78+
fun setVitalEventMapper(com.datadog.android.event.EventMapper<com.datadog.android.rum.model.RumVitalOperationStepEvent> = NoOpEventMapper(), com.datadog.android.event.EventMapper<com.datadog.android.rum.model.RumVitalAppLaunchEvent> = NoOpEventMapper()): Builder
8079
fun trackBackgroundEvents(Boolean): Builder
8180
fun trackFrustrations(Boolean): Builder
8281
fun setVitalsUpdateFrequency(com.datadog.android.rum.configuration.VitalsUpdateFrequency): Builder

features/dd-sdk-android-rum/api/dd-sdk-android-rum.api

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ public final class com/datadog/android/rum/RumConfiguration$Builder {
113113
public final fun setSlowFramesConfiguration (Lcom/datadog/android/rum/configuration/SlowFramesConfiguration;)Lcom/datadog/android/rum/RumConfiguration$Builder;
114114
public final fun setTelemetrySampleRate (F)Lcom/datadog/android/rum/RumConfiguration$Builder;
115115
public final fun setViewEventMapper (Lcom/datadog/android/rum/event/ViewEventMapper;)Lcom/datadog/android/rum/RumConfiguration$Builder;
116-
public final fun setVitalAppLaunchEventMapper (Lcom/datadog/android/event/EventMapper;)Lcom/datadog/android/rum/RumConfiguration$Builder;
117116
public final fun setVitalEventMapper (Lcom/datadog/android/event/EventMapper;)Lcom/datadog/android/rum/RumConfiguration$Builder;
118-
public final fun setVitalOperationStepEventMapper (Lcom/datadog/android/event/EventMapper;)Lcom/datadog/android/rum/RumConfiguration$Builder;
117+
public final fun setVitalEventMapper (Lcom/datadog/android/event/EventMapper;Lcom/datadog/android/event/EventMapper;)Lcom/datadog/android/rum/RumConfiguration$Builder;
118+
public static synthetic fun setVitalEventMapper$default (Lcom/datadog/android/rum/RumConfiguration$Builder;Lcom/datadog/android/event/EventMapper;Lcom/datadog/android/event/EventMapper;ILjava/lang/Object;)Lcom/datadog/android/rum/RumConfiguration$Builder;
119119
public final fun setVitalsUpdateFrequency (Lcom/datadog/android/rum/configuration/VitalsUpdateFrequency;)Lcom/datadog/android/rum/RumConfiguration$Builder;
120120
public final fun trackAnonymousUser (Z)Lcom/datadog/android/rum/RumConfiguration$Builder;
121121
public final fun trackBackgroundEvents (Z)Lcom/datadog/android/rum/RumConfiguration$Builder;

features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/RumConfiguration.kt

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ package com.datadog.android.rum
99
import android.os.Looper
1010
import androidx.annotation.FloatRange
1111
import com.datadog.android.event.EventMapper
12+
import com.datadog.android.event.NoOpEventMapper
1213
import com.datadog.android.rum.configuration.SlowFramesConfiguration
1314
import com.datadog.android.rum.configuration.VitalsUpdateFrequency
1415
import com.datadog.android.rum.event.ViewEventMapper
@@ -229,30 +230,27 @@ data class RumConfiguration internal constructor(
229230
@Deprecated(message = "Use setVitalOperationStepEventMapper instead")
230231
fun setVitalEventMapper(eventMapper: EventMapper<RumVitalOperationStepEvent>): Builder {
231232
@OptIn(ExperimentalRumApi::class)
232-
return setVitalOperationStepEventMapper(eventMapper)
233+
return setVitalEventMapper(vitalOperationStepEventMapper = eventMapper)
233234
}
234235

235236
/**
236-
* Sets the [EventMapper] for the RUM [RumVitalOperationStepEvent]. You can use this interface implementation
237-
* to modify the [RumVitalOperationStepEvent] attributes before serialisation.
238-
*
239-
* @param eventMapper the [EventMapper] implementation.
240-
*/
241-
@ExperimentalRumApi
242-
fun setVitalOperationStepEventMapper(eventMapper: EventMapper<RumVitalOperationStepEvent>): Builder {
243-
rumConfig = rumConfig.copy(vitalOperationStepEventMapper = eventMapper)
244-
return this
245-
}
246-
247-
/**
248-
* Sets the [EventMapper] for the RUM [RumVitalAppLaunchEvent]. You can use this interface implementation
249-
* to modify the [RumVitalAppLaunchEvent] attributes before serialisation.
237+
* Sets the [EventMapper] for the RUM [RumVitalOperationStepEvent] and the
238+
* RUM [RumVitalAppLaunchEvent]. You can use this interface implementation
239+
* to modify the [RumVitalOperationStepEvent] attributes and the [RumVitalAppLaunchEvent]
240+
* attributes before serialisation.
250241
*
251-
* @param eventMapper the [EventMapper] implementation.
242+
* @param vitalOperationStepEventMapper the [EventMapper] implementation for [RumVitalOperationStepEvent]
243+
* @param vitalAppLaunchEventMapper the [EventMapper] implementation for [RumVitalAppLaunchEvent]
252244
*/
253245
@ExperimentalRumApi
254-
fun setVitalAppLaunchEventMapper(eventMapper: EventMapper<RumVitalAppLaunchEvent>): Builder {
255-
rumConfig = rumConfig.copy(vitalAppLaunchEventMapper = eventMapper)
246+
fun setVitalEventMapper(
247+
vitalOperationStepEventMapper: EventMapper<RumVitalOperationStepEvent> = NoOpEventMapper(),
248+
vitalAppLaunchEventMapper: EventMapper<RumVitalAppLaunchEvent> = NoOpEventMapper()
249+
): Builder {
250+
rumConfig = rumConfig.copy(
251+
vitalOperationStepEventMapper = vitalOperationStepEventMapper,
252+
vitalAppLaunchEventMapper = vitalAppLaunchEventMapper
253+
)
256254
return this
257255
}
258256

features/dd-sdk-android-rum/src/main/kotlin/com/datadog/android/rum/internal/domain/event/RumEventMapper.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ internal data class RumEventMapper(
6767
is RumVitalOperationStepEvent -> vitalOperationStepEventMapper.map(event)
6868
is RumVitalAppLaunchEvent -> vitalAppLaunchEventMapper.map(event)
6969
is TelemetryConfigurationEvent -> telemetryConfigurationMapper.map(event)
70-
// TODO RUM-13103: add vitalAppLaunchEventMapper.
71-
is RumVitalAppLaunchEvent,
7270
is TelemetryDebugEvent,
7371
is TelemetryUsageEvent,
7472
is TelemetryErrorEvent -> event

features/dd-sdk-android-rum/src/test/kotlin/com/datadog/android/rum/RumConfigurationBuilderTest.kt

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -452,13 +452,13 @@ internal class RumConfigurationBuilderTest {
452452

453453
@OptIn(ExperimentalRumApi::class)
454454
@Test
455-
fun `M build config with RUM OperationStep Vital eventMapper W setVitalOperationStepEventMapper() & build()`() {
455+
fun `M build config W setVitalEventMapper() & build() {only vitalOperationStepEventMapper}`() {
456456
// Given
457457
val eventMapper: EventMapper<RumVitalOperationStepEvent> = mock()
458458

459459
// When
460460
val rumConfiguration = testedBuilder
461-
.setVitalOperationStepEventMapper(eventMapper)
461+
.setVitalEventMapper(vitalOperationStepEventMapper = eventMapper)
462462
.build()
463463

464464
// Then
@@ -471,13 +471,13 @@ internal class RumConfigurationBuilderTest {
471471

472472
@OptIn(ExperimentalRumApi::class)
473473
@Test
474-
fun `M build config with RUM AppLaunch Vital eventMapper W setVitalAppLaunchEventMapper() & build()`() {
474+
fun `M build config W setVitalEventMapper() & build() {only vitalAppLaunchEventMapper}`() {
475475
// Given
476476
val eventMapper: EventMapper<RumVitalAppLaunchEvent> = mock()
477477

478478
// When
479479
val rumConfiguration = testedBuilder
480-
.setVitalAppLaunchEventMapper(eventMapper)
480+
.setVitalEventMapper(vitalAppLaunchEventMapper = eventMapper)
481481
.build()
482482

483483
// Then
@@ -488,6 +488,30 @@ internal class RumConfigurationBuilderTest {
488488
)
489489
}
490490

491+
@OptIn(ExperimentalRumApi::class)
492+
@Test
493+
fun `M build config W setVitalEventMapper() & build()`() {
494+
// Given
495+
val rumVitalAppLaunchEventMapper: EventMapper<RumVitalAppLaunchEvent> = mock()
496+
val rumVitalOperationStepEventMapper: EventMapper<RumVitalOperationStepEvent> = mock()
497+
498+
// When
499+
val rumConfiguration = testedBuilder
500+
.setVitalEventMapper(
501+
vitalOperationStepEventMapper = rumVitalOperationStepEventMapper,
502+
vitalAppLaunchEventMapper = rumVitalAppLaunchEventMapper
503+
)
504+
.build()
505+
506+
// Then
507+
assertThat(rumConfiguration.featureConfiguration).isEqualTo(
508+
RumFeature.DEFAULT_RUM_CONFIG.copy(
509+
vitalOperationStepEventMapper = rumVitalOperationStepEventMapper,
510+
vitalAppLaunchEventMapper = rumVitalAppLaunchEventMapper
511+
)
512+
)
513+
}
514+
491515
@Test
492516
fun `M use the given frequency W setVitalsMonitorUpdateFrequency`(
493517
@Forgery fakeFrequency: VitalsUpdateFrequency

sample/benchmark/src/main/java/com/datadog/benchmark/sample/DatadogFeaturesInitializer.kt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,16 @@ internal class DatadogFeaturesInitializer @Inject constructor(
135135
event.context?.additionalProperties?.put(ATTR_IS_MAPPED, true)
136136
event
137137
}
138-
setVitalOperationStepEventMapper { event ->
139-
event.context?.additionalProperties?.put(ATTR_IS_MAPPED, true)
140-
event
141-
}
142-
setVitalAppLaunchEventMapper { event ->
143-
event.context?.additionalProperties?.put(ATTR_IS_MAPPED, true)
144-
event
145-
}
138+
setVitalEventMapper(
139+
vitalOperationStepEventMapper = { event ->
140+
event.context?.additionalProperties?.put(ATTR_IS_MAPPED, true)
141+
event
142+
},
143+
vitalAppLaunchEventMapper = { event ->
144+
event.context?.additionalProperties?.put(ATTR_IS_MAPPED, true)
145+
event
146+
}
147+
)
146148
enableComposeActionTracking()
147149
}.build()
148150
}

sample/kotlin/src/main/kotlin/com/datadog/android/sample/SampleApplication.kt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -325,14 +325,16 @@ class SampleApplication : Application() {
325325
event.context?.additionalProperties?.put(ATTR_IS_MAPPED, true)
326326
event
327327
}
328-
.setVitalOperationStepEventMapper { event ->
329-
event.context?.additionalProperties?.put(ATTR_IS_MAPPED, true)
330-
event
331-
}
332-
.setVitalAppLaunchEventMapper { event ->
333-
event.context?.additionalProperties?.put(ATTR_IS_MAPPED, true)
334-
event
335-
}
328+
.setVitalEventMapper(
329+
vitalOperationStepEventMapper = { event ->
330+
event.context?.additionalProperties?.put(ATTR_IS_MAPPED, true)
331+
event
332+
},
333+
vitalAppLaunchEventMapper = { event ->
334+
event.context?.additionalProperties?.put(ATTR_IS_MAPPED, true)
335+
event
336+
}
337+
)
336338
.trackBackgroundEvents(true)
337339
.trackAnonymousUser(true)
338340
.enableComposeActionTracking()

0 commit comments

Comments
 (0)