Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interactions report #1170

Merged
merged 1 commit into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ object Dependencies {
}

object SessionReplay {
private const val version = "1.0.10"
private const val version = "1.0.12"

const val bridge = "com.cisco.android:sr-bridge:$version"
const val commonEncoder = "com.cisco.android:sr-common-encoder:$version"
Expand Down
1 change: 1 addition & 0 deletions integration/interactions/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ android {
}

dependencies {
implementation(project(":common:otel"))
implementation(project(":integration:agent:internal"))

implementation(Dependencies.SessionReplay.commonLogger)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,19 @@ import com.splunk.rum.integration.agent.internal.config.ModuleConfigurationManag
import com.splunk.rum.integration.agent.internal.identification.ComposeElementIdentification
import com.splunk.rum.integration.agent.internal.identification.ComposeElementIdentification.OrderPriority
import com.splunk.rum.integration.agent.internal.utils.runIfComposeUiExists
import com.splunk.sdk.common.otel.OpenTelemetry
import io.opentelemetry.api.common.AttributeKey
import java.util.concurrent.TimeUnit

internal object InteractionsConfigurator {

private const val TAG = "InteractionsConfigurator"
private const val MODULE_NAME = "interactions"

private val attributeKeyComponent = AttributeKey.stringKey("component")
private val attributeKeyActionName = AttributeKey.stringKey("action.name")
private val attributeKeyTargetType = AttributeKey.stringKey("target.type")

init {
AgentIntegration.registerModule(MODULE_NAME)
}
Expand Down Expand Up @@ -77,8 +84,51 @@ internal object InteractionsConfigurator {
private val interactionsListener = object : OnInteractionListener {
override fun onInteraction(interaction: Interaction, legacyData: LegacyData?) {
Logger.d(TAG, "onInteraction(interaction: $interaction, legacyData: $legacyData)")
reportEvent(interaction)
}

private fun reportEvent(interaction: Interaction) {
val logger = OpenTelemetry.instance?.sdkLoggerProvider ?: return

val actionName = when (interaction) {
is Interaction.Focus ->
"focus"
is Interaction.Keyboard ->
"soft_keyboard"
is Interaction.Orientation ->
return
is Interaction.PhoneButton ->
"phone_button"
is Interaction.Touch.Gesture.DoubleTap ->
"double_tap"
is Interaction.Touch.Gesture.LongPress ->
"long_press"
is Interaction.Touch.Gesture.Pinch ->
"pinch"
is Interaction.Touch.Gesture.RageTap ->
"rage_tap"
is Interaction.Touch.Gesture.Rotation ->
"rotation"
is Interaction.Touch.Gesture.Swipe ->
return
is Interaction.Touch.Gesture.Tap ->
"tap"
is Interaction.Touch.Pointer ->
return
}

// TODO process interaction
val targetType = if (interaction is Interaction.Targetable)
interaction.targetElementPath?.lastOrNull()?.view?.id
else
null

logger.get("SplunkRum")
.logRecordBuilder()
.setTimestamp(interaction.timestamp, TimeUnit.MILLISECONDS)
.setAttribute(attributeKeyComponent, "ui")
.setAttribute(attributeKeyActionName, actionName)
.setAttribute(attributeKeyTargetType, targetType)
.emit()
}
}

Expand Down