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

RUMM-2273 Create the Session Replay Writer component #1041

Conversation

mariusc83
Copy link
Collaborator

What does this PR do?

In this PR we are introducing the Session Replay RecordWriter component in the dd-sdk-android-session-replay module which delegates to the SessionReplaySerializedRecordWriter in the dd-sdk-android module. The latter delegates all its functionality to the DataWriter<String> component provided by the SessionReplayPersistenceStrategy. Later the plan is to switch to the Storage implementation of the SDK V2 persistence layer.

Motivation

What inspired you to submit this pull request?

Additional Notes

Anything else we should know when reviewing?

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

@mariusc83 mariusc83 self-assigned this Sep 14, 2022
@mariusc83 mariusc83 force-pushed the mconstantin/rumm-2273/create-session-replay-writer branch from 3a24960 to 59fc648 Compare September 14, 2022 10:26
@mariusc83 mariusc83 marked this pull request as ready for review September 14, 2022 10:31
@mariusc83 mariusc83 requested a review from a team as a code owner September 14, 2022 10:31
@codecov-commenter
Copy link

codecov-commenter commented Sep 14, 2022

Codecov Report

Merging #1041 (78d2fbe) into feature/session-replay-vo (a710a59) will increase coverage by 0.04%.
The diff coverage is 73.53%.

@@                      Coverage Diff                      @@
##           feature/session-replay-vo    #1041      +/-   ##
=============================================================
+ Coverage                      83.26%   83.31%   +0.04%     
=============================================================
  Files                            332      334       +2     
  Lines                          10569    10591      +22     
  Branches                        1773     1774       +1     
=============================================================
+ Hits                            8800     8823      +23     
+ Misses                          1219     1218       -1     
  Partials                         550      550              
Impacted Files Coverage Δ
...id/sessionreplay/internal/NoOpLifecycleCallback.kt 10.00% <10.00%> (ø)
...oid/sessionreplay/internal/SessionReplayFeature.kt 94.29% <100.00%> (-1.71%) ⬇️
...l/domain/SessionReplayRecordPersistenceStrategy.kt 100.00% <100.00%> (ø)
...y/internal/domain/SessionReplayRecordSerializer.kt 100.00% <100.00%> (ø)
...rnal/domain/SessionReplaySerializedRecordWriter.kt 100.00% <100.00%> (ø)
.../kotlin/com/datadog/android/v2/core/DatadogCore.kt 66.91% <100.00%> (-0.48%) ⬇️
...id/sessionreplay/SessionReplayLifecycleCallback.kt 96.55% <100.00%> (+0.12%) ⬆️
...droid/sessionreplay/processor/SnapshotProcessor.kt 93.81% <100.00%> (ø)
...tadog/android/sessionreplay/writer/RecordWriter.kt 100.00% <100.00%> (ø)
... and 7 more

@xgouchet xgouchet added the size-medium This PR is medium sized label Sep 14, 2022
// 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> {
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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 write(record: EnrichedRecord) {
// TODO: RUMM-2273 Create the Session Replay Writer
jsonStringWriter.write(record.toJson())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we call toJson in Serializer?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually not because the EnrichedRecord lives in the dd-dk-android-session-replay module. I don't want to expose anything from there so that's the reason I want to just delegate to a jsonStringWriter which is provided from the dd-sdk-android. If I'll do it in the SessionReplayRecordSerializer I'd need to expose the EnrichedRecord to that module and I don't want that. Better to keep everything abstract.

}

return EnrichedRecord(
forge.getForgery<UUID>().toString(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: it is better to add named arguments, not clear what these are (same applies to all other new forgeries).

import android.os.Bundle
import com.datadog.android.sessionreplay.LifecycleCallback

internal class NoOpLifecycleCallback : LifecycleCallback {
Copy link
Collaborator

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?

Copy link
Collaborator Author

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 the dd-dk-android-session-replay module and NoOpLifecycleCallback is only relevant in the dd-sdk-android module where is actually being used. If I used the NoOpFactory it will be generated in the dd-sdk-android-session-replay and I want to avoid that.

@mariusc83 mariusc83 force-pushed the mconstantin/rumm-2273/create-session-replay-writer branch from 59fc648 to 78d2fbe Compare September 15, 2022 08:18
@mariusc83 mariusc83 requested a review from 0xnm September 15, 2022 08:31
@mariusc83 mariusc83 merged commit 3976aa2 into feature/session-replay-vo Sep 15, 2022
@mariusc83 mariusc83 deleted the mconstantin/rumm-2273/create-session-replay-writer branch September 15, 2022 09:01
@xgouchet xgouchet added this to the internal milestone Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size-medium This PR is medium sized
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants