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

Integrate Session Replay into the Agent #235

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 MRUM.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"location" : "[email protected]:smartlook/smartlook-ios-sdk-private.git",
"state" : {
"branch" : "develop",
"revision" : "dcf32bba46bea84c6cdf55de62d8249fad24be25"
"revision" : "814c1a3e2650ee705ef0cfb0419000397bbf792a"
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import Foundation
@_implementationOnly import MRUMCrashReports
@_implementationOnly import MRUMLogger
@_implementationOnly import MRUMOTel
@_implementationOnly import MRUMSessionReplay
@_implementationOnly import CiscoSessionReplay
@_implementationOnly import MRUMSharedProtocols

/// Default Event Manager instantiates LogEventProcessor for sending logs, instantiates TraceProcessor for sending traces.
Expand Down Expand Up @@ -110,7 +110,7 @@ class DefaultEventManager: AgentEventManager {
switch (metadata, data) {

// Session Replay module data
case let (metadata as RecordMetadata, data as Data):
case let (metadata as Metadata, data as Data):
let sessionID = agent.session.sessionId(for: metadata.timestamp)
let event = SessionReplayDataEvent(metadata: metadata, data: data, sessionID: sessionID)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.
*/

import Foundation
@_implementationOnly import MRUMSessionReplay
@_implementationOnly import CiscoSessionReplay
@_implementationOnly import MRUMSharedProtocols

/// Session Replay data events. Sends session replay blob with metadata.
Expand All @@ -30,7 +30,7 @@ class SessionReplayDataEvent: AgentEvent {
/// - metadata: `RecordMetadata` describing the session replay record.
/// - data: Session replay blob of type `Data`.
/// - sessionID: The `session ID` of a session in which the event occured. Optional so that we can see sessions with no session id in the backend.
public init(metadata: RecordMetadata, data: Data, sessionID: String?) {
public init(metadata: Metadata, data: Data, sessionID: String?) {
super.init()

// Event identification
Expand All @@ -39,9 +39,9 @@ class SessionReplayDataEvent: AgentEvent {

// Event properties
let timestamp = metadata.timestamp
let startTimestamp = metadata.timestamp.timeIntervalSince1970.nanoseconds
let endTimestamp = metadata.timestampEnd.timeIntervalSince1970.nanoseconds
let recordId = metadata.recordId
let startTimestamp = metadata.startUnixMs
let endTimestamp = metadata.endUnixMs
// let recordId = metadata.recordId

if let sessionID {
self.sessionID = sessionID
Expand All @@ -52,8 +52,8 @@ class SessionReplayDataEvent: AgentEvent {

attributes = [
"replay.start_timestamp": EventAttributeValue.int(startTimestamp),
"replay.end_timestamp": EventAttributeValue.int(endTimestamp),
"replay.record_id": EventAttributeValue.string(recordId)
"replay.end_timestamp": EventAttributeValue.int(endTimestamp)
// "replay.record_id": EventAttributeValue.string(recordId)
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ limitations under the License.
@_implementationOnly import MRUMNetwork
#endif

#if canImport(MRUMSessionReplay)
@_implementationOnly import MRUMSessionReplay
#if canImport(CiscoSessionReplay)
@_implementationOnly import CiscoSessionReplay
@_implementationOnly import MRUMSessionReplayProxy
#endif

Expand All @@ -47,8 +47,8 @@ class DefaultModulesPool: AgentModulesPool {
#endif

// Session Replay
#if canImport(MRUMSessionReplay)
knownModules.append(MRUMSessionReplay.SessionReplay.self)
#if canImport(CiscoSessionReplay)
knownModules.append(CiscoSessionReplay.SessionReplay.self)
#endif

// Network Instrumentation
Expand Down
4 changes: 2 additions & 2 deletions MRUMAgent/Sources/CiscoRUM/Public API/CiscoRUMAgent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import Foundation
@_implementationOnly import MRUMLogger
@_implementationOnly import MRUMNetwork
@_implementationOnly import MRUMOTel
@_implementationOnly import MRUMSessionReplay
@_implementationOnly import CiscoSessionReplay
@_implementationOnly import MRUMSharedProtocols

/// The class implementing MRUM Agent public API.
Expand Down Expand Up @@ -208,7 +208,7 @@ public class CiscoRUMAgent: ObservableObject {

/// Perform operations specific to the SessionReplay module.
private func customizeSessionReplay() {
let moduleType = MRUMSessionReplay.SessionReplay.self
let moduleType = CiscoSessionReplay.SessionReplay.self
let sessionReplayModule = modulesManager?.module(ofType: moduleType)

guard let sessionReplayModule else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ limitations under the License.
*/

import Foundation
@_implementationOnly import MRUMSessionReplay
@_implementationOnly import CiscoSessionReplay

typealias MRUMSessionReplayPreferences = MRUMSessionReplay.Preferences
typealias MRUMSessionReplayPreferences = CiscoSessionReplay.Preferences

// Internal extensions to convert `SessionReplayModulePreferences` proxy model to
// the underlying SessionReplay's `Preferences` model and vice versa.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ limitations under the License.
*/

import Foundation
@_implementationOnly import MRUMSessionReplay
@_implementationOnly import CiscoSessionReplay

// MARK: - MRUMSessionReplay RecordingMask-related type conversions

typealias MRUMSessionReplayRecordingMask = MRUMSessionReplay.RecordingMask
typealias MRUMSessionReplayMaskElement = MRUMSessionReplay.MaskElement
typealias MRUMSessionReplayMaskType = MRUMSessionReplay.MaskElement.MaskType
typealias MRUMSessionReplayRecordingMask = CiscoSessionReplay.RecordingMask
typealias MRUMSessionReplayMaskElement = CiscoSessionReplay.MaskElement
typealias MRUMSessionReplayMaskType = CiscoSessionReplay.MaskElement.MaskType

extension MRUMSessionReplayMaskType {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ limitations under the License.
*/

import Foundation
@_implementationOnly import MRUMSessionReplay
@_implementationOnly import CiscoSessionReplay

typealias MRUMSessionReplayRenderingMode = MRUMSessionReplay.RenderingMode
typealias MRUMSessionReplayRenderingMode = CiscoSessionReplay.RenderingMode

// Internal extension to convert `RenderingMode` proxy model to the underlying SessionReplay's `RenderingMode` model
extension RenderingMode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ limitations under the License.
*/

import Foundation
@_implementationOnly import MRUMSessionReplay
@_implementationOnly import CiscoSessionReplay

typealias MRUMSessionReplayStatus = MRUMSessionReplay.Status
typealias MRUMSessionReplayStatus = CiscoSessionReplay.Status

// Internal extension to convert `Status` proxy model to the underlying SessionReplay's `Status` model
extension SessionReplayStatus {
Expand All @@ -41,7 +41,8 @@ extension SessionReplayStatus {
return .notRecording(.notStarted)

case .notRecording(.projectLimitReached):
return .notRecording(.projectLimitReached)
// TODO: validate - this changed from .projectLimitReached
return .notRecording(.notStarted)

case .notRecording(.stopped):
return .notRecording(.stopped)
Expand Down Expand Up @@ -76,8 +77,9 @@ extension SessionReplayStatus {
case .notRecording(.notStarted):
self = .notRecording(.notStarted)

case .notRecording(.projectLimitReached):
self = .notRecording(.projectLimitReached)
// TODO: validate - this changed from .projectLimitReached
// case .notRecording(.projectLimitReached):
// self = .notRecording(.projectLimitReached)

case .notRecording(.stopped):
self = .notRecording(.stopped)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

@_implementationOnly import MRUMSessionReplay
@_implementationOnly import CiscoSessionReplay

extension SessionReplay {

Expand All @@ -26,7 +26,7 @@ extension SessionReplay {
RecordingMask(from: module.recordingMask)
}
set {
module.recordingMask = MRUMSessionReplay.RecordingMask(from: newValue)
module.recordingMask = CiscoSessionReplay.RecordingMask(from: newValue)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ limitations under the License.
import Foundation

@_implementationOnly import MRUMLogger
@_implementationOnly import MRUMSessionReplay
@_implementationOnly import CiscoSessionReplay

/// The class implementing Session Replay public API.
final class SessionReplay: SessionReplayModule {

// MARK: - Internal

unowned let module: MRUMSessionReplay.SessionReplay
unowned let module: CiscoSessionReplay.SessionReplay


// MARK: - Private
Expand All @@ -43,7 +43,7 @@ final class SessionReplay: SessionReplayModule {

// MARK: - Initialization

init(for module: MRUMSessionReplay.SessionReplay) {
init(for module: CiscoSessionReplay.SessionReplay) {
self.module = module
internalLogger = InternalLogger(configuration: .agent(category: "SessionReplay Module"))

Expand Down Expand Up @@ -107,7 +107,7 @@ extension SessionReplay {
// to the module. Opening a new session in the module closes the old one and ends the current record.
//
// This ensures the current record will end before a new session exists in the agent.
self?.module.openNewSession()
// self?.module.openNewSession()

// Log the change for easier debugging
self?.internalLogger.log(level: .info) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.
*/

import Foundation
@_implementationOnly import MRUMSessionReplay
@_implementationOnly import CiscoSessionReplay

/// The preferences object is a representation of the user's preferred settings.
///
Expand All @@ -32,7 +32,7 @@ public final class SessionReplayPreferences: SessionReplayModulePreferences, Cod

// MARK: - Internal

unowned var module: MRUMSessionReplay.SessionReplay?
unowned var module: CiscoSessionReplay.SessionReplay?


// MARK: - Initialization
Expand All @@ -41,7 +41,7 @@ public final class SessionReplayPreferences: SessionReplayModulePreferences, Cod
module = nil
}

init(for module: MRUMSessionReplay.SessionReplay?) {
init(for module: CiscoSessionReplay.SessionReplay?) {
self.module = module
renderingMode = RenderingMode(with: module?.preferences.renderingMode)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ limitations under the License.
*/


@_implementationOnly import MRUMSessionReplay
@_implementationOnly import CiscoSessionReplay
import UIKit

/// The sensitivity object implements public API for the view element's sensitivity.
final class SessionReplaySensitivity: SessionReplayModuleSensitivity {

// MARK: - Internal

private(set) unowned var module: MRUMSessionReplay.SessionReplay
private(set) unowned var module: CiscoSessionReplay.SessionReplay


// MARK: - Initialization

init(for module: MRUMSessionReplay.SessionReplay) {
init(for module: CiscoSessionReplay.SessionReplay) {
self.module = module
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ limitations under the License.
*/

import Foundation
@_implementationOnly import MRUMSessionReplay
@_implementationOnly import CiscoSessionReplay

/// The state object implements public API for the current state of the Session Replay module.
final class SessionReplayState: SessionReplayModuleState {

// MARK: - Internal

private(set) unowned var module: MRUMSessionReplay.SessionReplay
private(set) unowned var module: CiscoSessionReplay.SessionReplay


// MARK: - Initialization

init(for module: MRUMSessionReplay.SessionReplay) {
init(for module: CiscoSessionReplay.SessionReplay) {
self.module = module
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

@_implementationOnly import MRUMSessionReplay
@_implementationOnly import CiscoSessionReplay
import QuartzCore
import UIKit

Expand Down
21 changes: 12 additions & 9 deletions MRUMAgent/Tests/CiscoRUMTests/Agent/Events/EventsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.

@testable import CiscoRUM
@testable import MRUMOTel
@testable import MRUMSessionReplay
@testable import CiscoSessionReplay
@testable import MRUMSharedProtocols

import XCTest
Expand Down Expand Up @@ -139,14 +139,17 @@ final class EventsTests: XCTestCase {
let timestamp = Date()
let endTimestamp = Date()

let recordMetadata = RecordMetadata(
recordId: recordID,
recordIndex: 0,
timestamp: timestamp,
timestampEnd: endTimestamp,
replaySessionId: replaySessionID
)
let event = SessionReplayDataEvent(metadata: recordMetadata, data: sampleVideoData, sessionID: sessionID)
// let recordMetadata = RecordMetadata(
// recordId: recordID,
// recordIndex: 0,
// timestamp: timestamp,
// timestampEnd: endTimestamp,
// replaySessionId: replaySessionID
// )

let datachunkMetadata = Metadata(startUnixMs: timestamp.timeIntervalSince1970 * 1000, endUnixMs: endTimestamp.timeIntervalSince1970 * 1000)

let event = SessionReplayDataEvent(metadata: datachunkMetadata, data: sampleVideoData, sessionID: sessionID)

let requestExpectation = XCTestExpectation(description: "Send request")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.
*/

@testable import CiscoRUM
@testable import MRUMSessionReplay
@testable import CiscoSessionReplay

import XCTest

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ limitations under the License.
*/

@testable import CiscoRUM
import MRUMSessionReplay
import CiscoSessionReplay

final class SessionReplayTestBuilder {

// MARK: - Basic builds

public static func buildDefault() -> CiscoRUM.SessionReplay {
// Build Session Replay proxy with actual Session Replay module
let module = MRUMSessionReplay.SessionReplay.instance
let module = CiscoSessionReplay.SessionReplay.instance
let moduleProxy = SessionReplay(for: module)

return moduleProxy
Expand Down
Loading
Loading