-
Notifications
You must be signed in to change notification settings - Fork 64
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
RUMM-2273 Create the Session Replay Writer component #1041
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
* This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
* Copyright 2016-Present Datadog, Inc. | ||
*/ | ||
|
||
package com.datadog.android.sessionreplay.internal | ||
|
||
import android.app.Activity | ||
import android.app.Application | ||
import android.os.Bundle | ||
import com.datadog.android.sessionreplay.LifecycleCallback | ||
|
||
internal class NoOpLifecycleCallback : LifecycleCallback { | ||
override fun register(appContext: Application) {} | ||
|
||
override fun unregisterAndStopRecorders(appContext: Application) {} | ||
|
||
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {} | ||
|
||
override fun onActivityPaused(activity: Activity) {} | ||
|
||
override fun onActivityResumed(activity: Activity) {} | ||
|
||
override fun onActivityDestroyed(activity: Activity) {} | ||
|
||
override fun onActivityStarted(activity: Activity) {} | ||
|
||
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {} | ||
|
||
override fun onActivityStopped(activity: Activity) {} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,10 +8,8 @@ package com.datadog.android.sessionreplay.internal.domain | |
|
||
import com.datadog.android.core.internal.persistence.Serializer | ||
|
||
internal class RecordSerializer : Serializer<Any> { | ||
override fun serialize(model: Any): String? { | ||
// TODO: This will be switched to a Serializer<Record> once the models | ||
// will be in place. RUMM-2330" | ||
return null | ||
internal class SessionReplayRecordSerializer : Serializer<String> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. by some reason github doesn't show any syntax highlight for this file. Is this file ok? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah, I will recreate this file, have the same issue in my editor. |
||
override fun serialize(model: String): String { | ||
return model | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
* This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
* Copyright 2016-Present Datadog, Inc. | ||
*/ | ||
|
||
package com.datadog.android.sessionreplay.internal.domain | ||
|
||
import com.datadog.android.core.internal.persistence.DataWriter | ||
import com.datadog.android.sessionreplay.SerializedRecordWriter | ||
|
||
internal class SessionReplaySerializedRecordWriter(private val dataWriter: DataWriter<String>) : | ||
SerializedRecordWriter { | ||
// This method is being called from the `SnapshotProcessor` in Session Replay module which | ||
// runs on a WorkerThread already. | ||
@Suppress("ThreadSafety") | ||
override fun write(serializedRecord: String) { | ||
dataWriter.write(serializedRecord) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
* This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
* Copyright 2016-Present Datadog, Inc. | ||
*/ | ||
|
||
package com.datadog.android.sessionreplay.internal.domain | ||
|
||
import com.datadog.android.utils.forge.Configurator | ||
import fr.xgouchet.elmyr.annotation.StringForgery | ||
import fr.xgouchet.elmyr.junit5.ForgeConfiguration | ||
import fr.xgouchet.elmyr.junit5.ForgeExtension | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.extension.ExtendWith | ||
import org.junit.jupiter.api.extension.Extensions | ||
import org.mockito.junit.jupiter.MockitoExtension | ||
import org.mockito.junit.jupiter.MockitoSettings | ||
import org.mockito.quality.Strictness | ||
|
||
@Extensions( | ||
ExtendWith(MockitoExtension::class), | ||
ExtendWith(ForgeExtension::class) | ||
) | ||
@MockitoSettings(strictness = Strictness.LENIENT) | ||
@ForgeConfiguration(Configurator::class) | ||
internal class SessionReplayRecordSerializerTest { | ||
|
||
lateinit var testedRecordSerializer: SessionReplayRecordSerializer | ||
|
||
@BeforeEach | ||
fun `set up`() { | ||
testedRecordSerializer = SessionReplayRecordSerializer() | ||
} | ||
|
||
@Test | ||
fun `M do nothing and return the serializedRecord W serialize`( | ||
@StringForgery fakeSerializedRecord: String | ||
) { | ||
// When | ||
val serializedRecord = testedRecordSerializer.serialize(fakeSerializedRecord) | ||
|
||
// Then | ||
assertThat(serializedRecord).isSameAs(fakeSerializedRecord) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
* This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
* Copyright 2016-Present Datadog, Inc. | ||
*/ | ||
|
||
package com.datadog.android.sessionreplay.internal.domain | ||
|
||
import com.datadog.android.core.internal.persistence.DataWriter | ||
import com.datadog.android.utils.forge.Configurator | ||
import com.nhaarman.mockitokotlin2.verify | ||
import fr.xgouchet.elmyr.annotation.StringForgery | ||
import fr.xgouchet.elmyr.junit5.ForgeConfiguration | ||
import fr.xgouchet.elmyr.junit5.ForgeExtension | ||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.extension.ExtendWith | ||
import org.junit.jupiter.api.extension.Extensions | ||
import org.mockito.Mock | ||
import org.mockito.junit.jupiter.MockitoExtension | ||
import org.mockito.junit.jupiter.MockitoSettings | ||
import org.mockito.quality.Strictness | ||
|
||
@Extensions( | ||
ExtendWith(MockitoExtension::class), | ||
ExtendWith(ForgeExtension::class) | ||
) | ||
@MockitoSettings(strictness = Strictness.LENIENT) | ||
@ForgeConfiguration(Configurator::class) | ||
internal class SessionReplaySerializedRecordWriterTest { | ||
|
||
lateinit var testedSessionReplayRecordWriter: SessionReplaySerializedRecordWriter | ||
|
||
@Mock | ||
lateinit var mockDataWriter: DataWriter<String> | ||
|
||
@BeforeEach | ||
fun `set up`() { | ||
testedSessionReplayRecordWriter = SessionReplaySerializedRecordWriter(mockDataWriter) | ||
} | ||
|
||
@Test | ||
fun `M delegate to the dataWriter W write`(@StringForgery fakeSerializedRecord: String) { | ||
// When | ||
testedSessionReplayRecordWriter.write(fakeSerializedRecord) | ||
|
||
// Then | ||
verify(mockDataWriter).write(fakeSerializedRecord) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
* This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
* Copyright 2016-Present Datadog, Inc. | ||
*/ | ||
|
||
package com.datadog.android.sessionreplay | ||
|
||
import android.app.Application | ||
|
||
/** | ||
* The Session Replay related LifecycleCallback interface. | ||
* It will be registered as `Application.ActivityLifecycleCallbacks` and will decide when the | ||
* activity can be recorded or not based on the `onActivityResume`, `onActivityPause` callbacks. | ||
* This is only meant for internal usage and later will change visibility from public to internal. | ||
*/ | ||
interface LifecycleCallback : Application.ActivityLifecycleCallbacks { | ||
|
||
/** | ||
* Registers the callback on the Application lifecycle. | ||
* @param appContext | ||
*/ | ||
fun register(appContext: Application) | ||
|
||
/** | ||
* Unregister the callback and stops any related recorders that were previously started. | ||
* @param appContext | ||
*/ | ||
fun unregisterAndStopRecorders(appContext: Application) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't you use the automatic NoOpFactory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly because the
LifecycleCallback
lives in thedd-dk-android-session-replay
module andNoOpLifecycleCallback
is only relevant in thedd-sdk-android
module where is actually being used. If I used theNoOpFactory
it will be generated in thedd-sdk-android-session-replay
and I want to avoid that.