Skip to content

Commit

Permalink
Interactions
Browse files Browse the repository at this point in the history
Signed-off-by: Tomas Chladek <[email protected]>
  • Loading branch information
TomasChladekSL committed Jan 10, 2025
1 parent c16aa10 commit c7320db
Show file tree
Hide file tree
Showing 11 changed files with 200 additions and 1 deletion.
1 change: 1 addition & 0 deletions agent/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ dependencies {
api(project(":integration:anr"))
api(project(":integration:networkrequest"))
api(project(":integration:startup"))
api(project(":integration:interactions"))
}

2 changes: 2 additions & 0 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ object Dependencies {
private const val version = "1.0.10"

const val logger = "com.cisco.android:sr-common-logger:$version"
const val frameCapturer = "com.cisco.android:sr-instrumentation-session-recording-frame-capturer:$version"
const val interactions = "com.cisco.android:sr-instrumentation-session-recording-interactions:$version"
}
}

Expand Down
32 changes: 32 additions & 0 deletions integration/interactions/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import plugins.ConfigAndroidLibrary
import plugins.ConfigPublish
import utils.artifactIdProperty
import utils.artifactPrefix
import utils.integrationPrefix
import utils.versionProperty

plugins {
id("com.android.library")
id("kotlin-android")
}

apply<ConfigAndroidLibrary>()
apply<ConfigPublish>()

ext {
set(artifactIdProperty, "$artifactPrefix$integrationPrefix${project.name}")
set(versionProperty, Configurations.sdkVersionName)
}

android {
namespace = "com.cisco.android.rum.integration.interactions"
}

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

implementation(Dependencies.Android.SessionReplay.logger)
implementation(Dependencies.Android.SessionReplay.frameCapturer)
implementation(Dependencies.Android.SessionReplay.interactions)
}
Empty file.
4 changes: 4 additions & 0 deletions integration/interactions/lint-baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<issues format="6" by="lint 7.3.1" type="baseline" client="gradle" dependencies="false" name="AGP (7.3.1)" variant="all" version="7.3.1">

</issues>
Empty file.
10 changes: 10 additions & 0 deletions integration/interactions/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application>
<provider
android:name=".InteractionsInstaller"
android:authorities="${applicationId}.interactions-integration-installer"
android:enabled="true"
android:exported="false" />
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*
* Copyright 2024 Splunk Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.cisco.android.rum.integration.interactions

import android.app.Application
import android.content.Context
import com.cisco.android.common.logger.Logger
import com.cisco.android.instrumentation.recording.capturer.FrameCapturer
import com.cisco.android.instrumentation.recording.interactions.Interactions
import com.cisco.android.instrumentation.recording.interactions.OnInteractionListener
import com.cisco.android.instrumentation.recording.interactions.model.Interaction
import com.cisco.android.instrumentation.recording.interactions.model.LegacyData
import com.cisco.android.instrumentation.recording.wireframe.model.Wireframe
import com.cisco.android.instrumentation.recording.wireframe.stats.WireframeStats
import com.cisco.android.rum.integration.agent.internal.AgentIntegration
import com.cisco.android.rum.integration.agent.internal.config.ModuleConfigurationManager
import com.cisco.android.rum.integration.agent.internal.config.RemoteModuleConfiguration

internal object InteractionsConfigurator {

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

init {
AgentIntegration.registerModule(MODULE_NAME)
}

fun attach(context: Context) {
AgentIntegration.obtainInstance(context).listeners += installationListener

val application = context.applicationContext as Application

Interactions.attach(application)
FrameCapturer.attach(application)

FrameCapturer.listeners += object : FrameCapturer.Listener {
override fun onNewWireframe(frame: Wireframe.Frame, stats: WireframeStats) {
Interactions.updateWireframe(frame)
}
}

Interactions.listeners += interactionsListener
}

private val interactionsListener = object : OnInteractionListener {
override fun onInteraction(interaction: Interaction, legacyData: LegacyData?) {
Logger.d(TAG, "onInteraction(interaction: $interaction, legacyData: $legacyData)")

// TODO process interaction
}
}

private val configManagerListener = object : ModuleConfigurationManager.Listener {
override fun onRemoteModuleConfigurationsChanged(manager: ModuleConfigurationManager, remoteConfigurations: List<RemoteModuleConfiguration>) {
Logger.d(TAG, "onRemoteModuleConfigurationsChanged(remoteConfigurations: $remoteConfigurations)")
setModuleConfiguration(remoteConfigurations)
}
}

private fun setModuleConfiguration(remoteConfigurations: List<RemoteModuleConfiguration>) {
Logger.d(TAG, "setModuleConfiguration(remoteConfigurations: $remoteConfigurations)")
}

private val installationListener = object : AgentIntegration.Listener {
override fun onInstall(context: Context) {
Logger.d(TAG, "onInstall()")

val integration = AgentIntegration.obtainInstance(context)
integration.moduleConfigurationManager.listeners += configManagerListener

setModuleConfiguration(integration.moduleConfigurationManager.remoteConfigurations)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 2024 Splunk Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.cisco.android.rum.integration.interactions

import android.content.ContentProvider
import android.content.ContentValues
import android.database.Cursor
import android.net.Uri

internal class InteractionsInstaller : ContentProvider() {

override fun onCreate(): Boolean {
InteractionsConfigurator.attach(context!!)
return true
}

override fun query(uri: Uri, projection: Array<out String>?, selection: String?, selectionArgs: Array<out String>?, sortOrder: String?): Cursor? = null

override fun getType(uri: Uri): String? = null

override fun insert(uri: Uri, values: ContentValues?): Uri? = null

override fun delete(uri: Uri, selection: String?, selectionArgs: Array<out String>?): Int = 0

override fun update(uri: Uri, values: ContentValues?, selection: String?, selectionArgs: Array<out String>?): Int = 0
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright 2024 Splunk Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.cisco.android.rum.integration.interactions

import com.cisco.android.rum.integration.agent.module.ModuleConfiguration

class InteractionsModuleConfiguration : ModuleConfiguration
3 changes: 2 additions & 1 deletion settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ include ':instrumentation:runtime:crash',
include ':integration:agent:api',
':integration:agent:module',
':integration:agent:internal',
':integration:startup'
':integration:startup',
':integration:interactions'

// Integration tests
// TODO disable it for now because of different artifactory include ':integration-run'
Expand Down

0 comments on commit c7320db

Please sign in to comment.