Skip to content

Commit 0b5e7c7

Browse files
authored
Merge pull request #1439 from DataDog/nogorodnikov/prepare-release-1.19.1
Prepare release 1.19.1
2 parents c435fde + 5e307dc commit 0b5e7c7

File tree

10 files changed

+127
-8
lines changed

10 files changed

+127
-8
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 1.19.1 / 2023-05-30
2+
3+
* [IMPROVEMENT] RUM: Force new session at SDK initialization. See [#1399](https://github.com/DataDog/dd-sdk-android/pull/1399)
4+
* [BUGFIX] RUM: Ignore adding custom timings and feature flags for the stopped view. See [#1433](https://github.com/DataDog/dd-sdk-android/pull/1433)
5+
16
# 1.19.0 / 2023-04-24
27

38
* [FEATURE] RUM: Allow users to stop a RUM session. See [#1356](https://github.com/DataDog/dd-sdk-android/pull/1356)

buildSrc/src/main/kotlin/com/datadog/gradle/config/AndroidConfig.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ object AndroidConfig {
1919
const val MIN_SDK_FOR_WEAR = 23
2020
const val BUILD_TOOLS_VERSION = "33.0.0"
2121

22-
val VERSION = Version(1, 19, 0, Version.Type.Release)
22+
val VERSION = Version(1, 19, 1, Version.Type.Release)
2323
}
2424

2525
@Suppress("UnstableApiUsage")

dd-sdk-android/src/main/kotlin/com/datadog/android/rum/internal/domain/scope/RumRawEvent.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ internal sealed class RumRawEvent {
204204
override val eventTime: Time = Time()
205205
) : RumRawEvent()
206206

207+
internal data class SdkInit(
208+
override val eventTime: Time = Time()
209+
) : RumRawEvent()
210+
207211
internal data class WebViewEvent(override val eventTime: Time = Time()) : RumRawEvent()
208212

209213
internal data class SendTelemetry(

dd-sdk-android/src/main/kotlin/com/datadog/android/rum/internal/domain/scope/RumSessionScope.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,9 @@ internal class RumSessionScope(
146146
val isInteraction = (event is RumRawEvent.StartView) || (event is RumRawEvent.StartAction)
147147
val isBackgroundEvent = (event.javaClass in RumViewManagerScope.validBackgroundEventTypes)
148148

149-
if (isInteraction) {
149+
if (event is RumRawEvent.SdkInit && isNewSession) {
150+
renewSession(nanoTime)
151+
} else if (isInteraction) {
150152
if (isNewSession || isExpired || isTimedOut) {
151153
renewSession(nanoTime)
152154
}

dd-sdk-android/src/main/kotlin/com/datadog/android/rum/internal/domain/scope/RumViewManagerScope.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ internal class RumViewManagerScope(
8585

8686
// region Internal
8787

88-
fun isViewManagerComplete(): Boolean {
88+
private fun isViewManagerComplete(): Boolean {
8989
return stopped && childrenScopes.isEmpty()
9090
}
9191

dd-sdk-android/src/main/kotlin/com/datadog/android/rum/internal/domain/scope/RumViewScope.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ internal open class RumViewScope(
106106
private var version: Long = 1
107107
private var loadingTime: Long? = null
108108
private var loadingType: ViewEvent.LoadingType? = null
109-
private val customTimings: MutableMap<String, Long> = mutableMapOf()
109+
internal val customTimings: MutableMap<String, Long> = mutableMapOf()
110110
internal val featureFlags: MutableMap<String, Any?> = mutableMapOf()
111111

112112
internal var stopped: Boolean = false
@@ -467,6 +467,8 @@ internal open class RumViewScope(
467467
event: RumRawEvent.AddCustomTiming,
468468
writer: DataWriter<Any>
469469
) {
470+
if (stopped) return
471+
470472
customTimings[event.name] = max(event.eventTime.nanoTime - startedNanos, 1L)
471473
sendViewUpdate(event, writer)
472474
}
@@ -988,6 +990,8 @@ internal open class RumViewScope(
988990
event: RumRawEvent.AddFeatureFlagEvaluation,
989991
writer: DataWriter<Any>
990992
) {
993+
if (stopped) return
994+
991995
featureFlags[event.name] = event.value
992996
sendViewUpdate(event, writer)
993997
sendViewChanged()

dd-sdk-android/src/main/kotlin/com/datadog/android/rum/internal/monitor/DatadogRumMonitor.kt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ internal class DatadogRumMonitor(
6464
frameRateVitalMonitor: VitalMonitor,
6565
sessionListener: RumSessionListener?,
6666
contextProvider: ContextProvider,
67-
private val executorService: ExecutorService = Executors.newSingleThreadExecutor()
67+
private val executorService: ExecutorService = Executors.newSingleThreadExecutor(),
68+
sendSdkInit: Boolean = true
6869
) : RumMonitor, AdvancedRumMonitor {
6970

7071
internal var rootScope: RumScope = RumApplicationScope(
@@ -95,6 +96,9 @@ internal class DatadogRumMonitor(
9596

9697
init {
9798
handler.postDelayed(keepAliveRunnable, KEEP_ALIVE_MS)
99+
if (sendSdkInit) {
100+
sendSdkInitEvent()
101+
}
98102
}
99103

100104
// region RumMonitor
@@ -507,6 +511,12 @@ internal class DatadogRumMonitor(
507511
}
508512
}
509513

514+
private fun sendSdkInitEvent() {
515+
handleEvent(
516+
RumRawEvent.SdkInit()
517+
)
518+
}
519+
510520
// endregion
511521

512522
companion object {

dd-sdk-android/src/test/kotlin/com/datadog/android/rum/internal/domain/scope/RumSessionScopeTest.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,23 @@ internal class RumSessionScopeTest {
283283
assertThat(context.viewId).isEqualTo(fakeParentContext.viewId)
284284
}
285285

286+
@Test
287+
fun `𝕄 create new session context 𝕎 handleEvent(sdkInit)+getRumContext() {sampling = 100}`() {
288+
// Given
289+
initializeTestedScope(100f)
290+
291+
// When
292+
val result = testedScope.handleEvent(RumRawEvent.SdkInit(), mockWriter)
293+
val context = testedScope.getRumContext()
294+
295+
// Then
296+
assertThat(result).isSameAs(testedScope)
297+
assertThat(context.sessionId).isNotEqualTo(RumContext.NULL_UUID)
298+
assertThat(context.sessionState).isEqualTo(RumSessionScope.State.TRACKED)
299+
assertThat(context.applicationId).isEqualTo(fakeParentContext.applicationId)
300+
assertThat(context.viewId).isEqualTo(fakeParentContext.viewId)
301+
}
302+
286303
@Test
287304
fun `𝕄 create new session context 𝕎 handleEvent(view)+getRumContext() {sampling = 100}`(
288305
forge: Forge

dd-sdk-android/src/test/kotlin/com/datadog/android/rum/internal/domain/scope/RumViewScopeTest.kt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5563,6 +5563,25 @@ internal class RumViewScopeTest {
55635563
verifyNoMoreInteractions(mockWriter)
55645564
}
55655565

5566+
@Test
5567+
fun `𝕄 not add custom timing 𝕎 handleEvent(AddCustomTiming) on stopped view`(
5568+
forge: Forge
5569+
) {
5570+
// Given
5571+
testedScope.stopped = true
5572+
val fakeTimingKey = forge.anAlphabeticalString()
5573+
5574+
// When
5575+
testedScope.handleEvent(
5576+
RumRawEvent.AddCustomTiming(fakeTimingKey),
5577+
mockWriter
5578+
)
5579+
5580+
// Then
5581+
assertThat(testedScope.customTimings).isEmpty()
5582+
verifyZeroInteractions(mockWriter)
5583+
}
5584+
55665585
// endregion
55675586

55685587
// region Vitals
@@ -6904,6 +6923,28 @@ internal class RumViewScopeTest {
69046923
}
69056924
}
69066925

6926+
@Test
6927+
fun `M not add feature flag W handleEvent(AddFeatureFlagEvaluation) on stopped view`(
6928+
@StringForgery flagName: String,
6929+
@StringForgery flagValue: String
6930+
) {
6931+
// GIVEN
6932+
testedScope.stopped = true
6933+
6934+
// WHEN
6935+
testedScope.handleEvent(
6936+
RumRawEvent.AddFeatureFlagEvaluation(
6937+
name = flagName,
6938+
value = flagValue
6939+
),
6940+
mockWriter
6941+
)
6942+
6943+
// THEN
6944+
assertThat(testedScope.featureFlags).isEmpty()
6945+
verifyZeroInteractions(mockWriter)
6946+
}
6947+
69076948
@Test
69086949
fun `M modify flag W handleEvent(AddFeatureFlagEvaluation) on active view { existing feature flag }`(
69096950
@StringForgery flagName: String,

dd-sdk-android/src/test/kotlin/com/datadog/android/rum/internal/monitor/DatadogRumMonitorTest.kt

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ internal class DatadogRumMonitorTest {
159159
mockMemoryVitalMonitor,
160160
mockFrameRateVitalMonitor,
161161
mockSessionListener,
162-
mockContextProvider
162+
mockContextProvider,
163+
sendSdkInit = false
163164
)
164165
testedMonitor.rootScope = mockScope
165166
}
@@ -1130,6 +1131,39 @@ internal class DatadogRumMonitorTest {
11301131
}
11311132
}
11321133

1134+
@Test
1135+
fun `M delegate SdkInit event to rootScope W init()`() {
1136+
// When
1137+
testedMonitor = DatadogRumMonitor(
1138+
fakeApplicationId,
1139+
mockSdkCore,
1140+
fakeSamplingRate,
1141+
fakeBackgroundTrackingEnabled,
1142+
fakeTrackFrustrations,
1143+
mockWriter,
1144+
mockHandler,
1145+
mockTelemetryEventHandler,
1146+
mockResolver,
1147+
mockCpuVitalMonitor,
1148+
mockMemoryVitalMonitor,
1149+
mockFrameRateVitalMonitor,
1150+
mockSessionListener,
1151+
mockContextProvider,
1152+
sendSdkInit = true
1153+
)
1154+
testedMonitor.rootScope = mockScope
1155+
1156+
Thread.sleep(PROCESSING_DELAY)
1157+
1158+
// Then
1159+
verify(mockScope).handleEvent(
1160+
argThat { this is RumRawEvent.SdkInit },
1161+
same(mockWriter)
1162+
)
1163+
1164+
verifyNoMoreInteractions(mockScope, mockWriter)
1165+
}
1166+
11331167
@Test
11341168
fun `delays keep alive runnable on other event`() {
11351169
val mockEvent: RumRawEvent = mock()
@@ -1258,7 +1292,8 @@ internal class DatadogRumMonitorTest {
12581292
mockFrameRateVitalMonitor,
12591293
mockSessionListener,
12601294
mockContextProvider,
1261-
mockExecutorService
1295+
mockExecutorService,
1296+
false
12621297
)
12631298
whenever(mockExecutorService.isShutdown).thenReturn(true)
12641299

@@ -1570,7 +1605,8 @@ internal class DatadogRumMonitorTest {
15701605
mockFrameRateVitalMonitor,
15711606
mockSessionListener,
15721607
mockContextProvider,
1573-
executorService = mockExecutorService
1608+
executorService = mockExecutorService,
1609+
false
15741610
)
15751611

15761612
var isMethodOccupied = false

0 commit comments

Comments
 (0)