From 8fe4d3ec20a13ac81067ef3182a855d54a8f4a19 Mon Sep 17 00:00:00 2001 From: Nikita Ogorodnikov Date: Thu, 13 Jul 2023 14:30:13 +0200 Subject: [PATCH] REPLAY-1894: Remove explicit dependency on RUM module from Session Replay --- .../build.gradle.kts | 1 - .../domain/SessionReplayRequestFactory.kt | 17 ++++++++++------- .../domain/SessionReplayRequestFactoryTest.kt | 11 +++++------ sample/kotlin/build.gradle.kts | 4 +++- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/features/dd-sdk-android-session-replay/build.gradle.kts b/features/dd-sdk-android-session-replay/build.gradle.kts index 5f0437a113..eca47e63ae 100644 --- a/features/dd-sdk-android-session-replay/build.gradle.kts +++ b/features/dd-sdk-android-session-replay/build.gradle.kts @@ -88,7 +88,6 @@ android { dependencies { api(project(":dd-sdk-android-core")) - api(project(":features:dd-sdk-android-rum")) implementation(libs.okHttp) implementation(libs.kotlin) implementation(libs.gson) diff --git a/features/dd-sdk-android-session-replay/src/main/kotlin/com/datadog/android/sessionreplay/internal/domain/SessionReplayRequestFactory.kt b/features/dd-sdk-android-session-replay/src/main/kotlin/com/datadog/android/sessionreplay/internal/domain/SessionReplayRequestFactory.kt index 2babd1327b..faf01356a1 100644 --- a/features/dd-sdk-android-session-replay/src/main/kotlin/com/datadog/android/sessionreplay/internal/domain/SessionReplayRequestFactory.kt +++ b/features/dd-sdk-android-session-replay/src/main/kotlin/com/datadog/android/sessionreplay/internal/domain/SessionReplayRequestFactory.kt @@ -9,7 +9,6 @@ package com.datadog.android.sessionreplay.internal.domain import com.datadog.android.api.context.DatadogContext import com.datadog.android.api.net.Request import com.datadog.android.api.net.RequestFactory -import com.datadog.android.rum.RumAttributes import com.datadog.android.sessionreplay.internal.exception.InvalidPayloadFormatException import com.datadog.android.sessionreplay.internal.net.BatchesToSegmentsMapper import okhttp3.RequestBody @@ -45,14 +44,13 @@ internal class SessionReplayRequestFactory( private fun tags(datadogContext: DatadogContext): String { val elements = mutableListOf( - "${RumAttributes.SERVICE_NAME}:${datadogContext.service}", - "${RumAttributes.APPLICATION_VERSION}:" + - datadogContext.version, - "${RumAttributes.SDK_VERSION}:${datadogContext.sdkVersion}", - "${RumAttributes.ENV}:${datadogContext.env}" + "$SERVICE_NAME:${datadogContext.service}", + "$APPLICATION_VERSION:${datadogContext.version}", + "$SDK_VERSION:${datadogContext.sdkVersion}", + "$ENV:${datadogContext.env}" ) if (datadogContext.variant.isNotEmpty()) { - elements.add("${RumAttributes.VARIANT}:${datadogContext.variant}") + elements.add("$VARIANT:${datadogContext.variant}") } return elements.joinToString(",") } @@ -115,5 +113,10 @@ internal class SessionReplayRequestFactory( companion object { private const val UPLOAD_URL = "%s/api/v2/%s" + internal const val APPLICATION_VERSION = "version" + internal const val ENV = "env" + internal const val SERVICE_NAME = "service" + internal const val VARIANT = "variant" + internal const val SDK_VERSION = "sdk_version" } } diff --git a/features/dd-sdk-android-session-replay/src/test/kotlin/com/datadog/android/sessionreplay/internal/domain/SessionReplayRequestFactoryTest.kt b/features/dd-sdk-android-session-replay/src/test/kotlin/com/datadog/android/sessionreplay/internal/domain/SessionReplayRequestFactoryTest.kt index c223a37132..8864b44f4b 100644 --- a/features/dd-sdk-android-session-replay/src/test/kotlin/com/datadog/android/sessionreplay/internal/domain/SessionReplayRequestFactoryTest.kt +++ b/features/dd-sdk-android-session-replay/src/test/kotlin/com/datadog/android/sessionreplay/internal/domain/SessionReplayRequestFactoryTest.kt @@ -8,7 +8,6 @@ package com.datadog.android.sessionreplay.internal.domain import com.datadog.android.api.context.DatadogContext import com.datadog.android.api.net.RequestFactory -import com.datadog.android.rum.RumAttributes import com.datadog.android.sessionreplay.forge.ForgeConfigurator import com.datadog.android.sessionreplay.internal.exception.InvalidPayloadFormatException import com.datadog.android.sessionreplay.internal.net.BatchesToSegmentsMapper @@ -178,14 +177,14 @@ internal class SessionReplayRequestFactoryTest { private fun expectedUrl(endpointUrl: String): String { val queryTags = mutableListOf( - "${RumAttributes.SERVICE_NAME}:${fakeDatadogContext.service}", - "${RumAttributes.APPLICATION_VERSION}:${fakeDatadogContext.version}", - "${RumAttributes.SDK_VERSION}:${fakeDatadogContext.sdkVersion}", - "${RumAttributes.ENV}:${fakeDatadogContext.env}" + "${SessionReplayRequestFactory.SERVICE_NAME}:${fakeDatadogContext.service}", + "${SessionReplayRequestFactory.APPLICATION_VERSION}:${fakeDatadogContext.version}", + "${SessionReplayRequestFactory.SDK_VERSION}:${fakeDatadogContext.sdkVersion}", + "${SessionReplayRequestFactory.ENV}:${fakeDatadogContext.env}" ) if (fakeDatadogContext.variant.isNotEmpty()) { - queryTags.add("${RumAttributes.VARIANT}:${fakeDatadogContext.variant}") + queryTags.add("${SessionReplayRequestFactory.VARIANT}:${fakeDatadogContext.variant}") } return "$endpointUrl/api/v2/replay?${RequestFactory.QUERY_PARAM_SOURCE}=" + diff --git a/sample/kotlin/build.gradle.kts b/sample/kotlin/build.gradle.kts index 922b626156..ebf94b8cfb 100644 --- a/sample/kotlin/build.gradle.kts +++ b/sample/kotlin/build.gradle.kts @@ -116,8 +116,10 @@ android { dependencies { implementation(project(":dd-sdk-android-core")) - implementation(project(":features:dd-sdk-android-ndk")) + implementation(project(":features:dd-sdk-android-logs")) + implementation(project(":features:dd-sdk-android-rum")) implementation(project(":features:dd-sdk-android-trace")) + implementation(project(":features:dd-sdk-android-ndk")) implementation(project(":features:dd-sdk-android-webview")) implementation(project(":features:dd-sdk-android-session-replay")) implementation(project(":features:dd-sdk-android-session-replay-material"))