Skip to content

Commit

Permalink
Fix conflicts with #1354
Browse files Browse the repository at this point in the history
  • Loading branch information
maxep committed Jul 10, 2023
1 parent 524eb9e commit 08540ad
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 466 deletions.
444 changes: 21 additions & 423 deletions Datadog/Datadog.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions DatadogCore/Tests/Datadog/Mocks/RUMFeatureMocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -653,12 +653,6 @@ extension RUMSessionState: AnyMockable, RandomMockable {

// MARK: - RUMScope Mocks

internal struct NoOpRUMViewUpdatesThrottler: RUMViewUpdatesThrottlerType {
func accept(event: RUMViewEvent) -> Bool {
return true // always send view update
}
}

func mockNoOpSessionListener() -> RUM.SessionListener {
return { _, _ in }
}
Expand Down
1 change: 0 additions & 1 deletion DatadogCore/Tests/Datadog/RUM/RUMMonitorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class RUMMonitorTests: XCTestCase {
super.setUp()
core = DatadogCoreProxy()
config = RUM.Configuration(applicationID: .mockAny())
config.viewUpdatesThrottlerFactory = { NoOpRUMViewUpdatesThrottler() } // disable view updates sampling for deterministic behaviour
}

override func tearDown() {
Expand Down
4 changes: 1 addition & 3 deletions DatadogCore/Tests/DatadogObjc/DDRUMMonitorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ class DDRUMMonitorTests: XCTestCase {
core = DatadogCoreProxy()
CoreRegistry.register(default: core)
config = RUM.Configuration(applicationID: .mockAny())
config.viewUpdatesThrottlerFactory = { NoOpRUMViewUpdatesThrottler() } // disable view updates sampling for deterministic behaviour
}

override func tearDown() {
Expand Down Expand Up @@ -198,7 +197,6 @@ class DDRUMMonitorTests: XCTestCase {
}

func testSendingViewEventsWithTiming() throws {
config.viewUpdatesThrottlerFactory = { RUMViewUpdatesThrottler() }
RUM.enable(with: config)
let objcRUMMonitor = DDRUMMonitor.shared()

Expand All @@ -211,7 +209,7 @@ class DDRUMMonitorTests: XCTestCase {
let viewEvents = rumEventMatchers.filterRUMEvents(ofType: RUMViewEvent.self) { event in
return event.view.name != RUMOffViewEventsHandlingRule.Constants.applicationLaunchViewName
}
XCTAssertEqual(viewEvents.count, 2)
XCTAssertEqual(viewEvents.count, 3)

let event1: RUMViewEvent = try viewEvents[0].model()
let event2: RUMViewEvent = try viewEvents[1].model()
Expand Down
1 change: 0 additions & 1 deletion DatadogRUM/Sources/Feature/RUMFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ internal final class RUMFeature: DatadogRemoteFeature {
),
rumUUIDGenerator: configuration.uuidGenerator,
ciTest: configuration.ciTestExecutionID.map { RUMCITest(testExecutionId: $0) },
viewUpdatesThrottlerFactory: configuration.viewUpdatesThrottlerFactory,
vitalsReaders: configuration.vitalsUpdateFrequency.map { VitalsReaders(frequency: $0.timeInterval) },
onSessionStart: configuration.onSessionStart
)
Expand Down
3 changes: 0 additions & 3 deletions DatadogRUM/Sources/RUMConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,6 @@ extension RUM {

internal var dateProvider: DateProvider = SystemDateProvider()

/// Produces view update events' throttler for each started RUM view scope.
internal var viewUpdatesThrottlerFactory: () -> RUMViewUpdatesThrottlerType = { RUMViewUpdatesThrottler() }

internal var debugSDK: Bool = ProcessInfo.processInfo.arguments.contains(LaunchArguments.Debug)
internal var debugViews: Bool = ProcessInfo.processInfo.arguments.contains("DD_DEBUG_RUM")
internal var ciTestExecutionID: String? = ProcessInfo.processInfo.environment["CI_VISIBILITY_TEST_EXECUTION_ID"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ internal struct RUMScopeDependencies {
let rumUUIDGenerator: RUMUUIDGenerator
/// Integration with CIApp tests. It contains the CIApp test context when active.
let ciTest: RUMCITest?
/// Produces `RUMViewUpdatesThrottlerType` for each started RUM view scope.
let viewUpdatesThrottlerFactory: () -> RUMViewUpdatesThrottlerType

let vitalsReaders: VitalsReaders?
let onSessionStart: RUM.SessionListener?
}
28 changes: 14 additions & 14 deletions DatadogRUM/Sources/RUMMonitor/Scopes/RUMViewScope.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ internal class RUMViewScope: RUMScope, RUMContextProvider {

private let vitalInfoSampler: VitalInfoSampler?

/// Samples view update events, so we can minimize the number of events in payload.
private let viewUpdatesThrottler: RUMViewUpdatesThrottlerType

private var viewPerformanceMetrics: [PerformanceMetric: VitalInfo] = [:]

init(
Expand Down Expand Up @@ -127,7 +124,6 @@ internal class RUMViewScope: RUMScope, RUMContextProvider {
frequency: $0.frequency
)
}
self.viewUpdatesThrottler = dependencies.viewUpdatesThrottlerFactory()
}

// MARK: - RUMContextProvider
Expand Down Expand Up @@ -395,7 +391,7 @@ internal class RUMViewScope: RUMScope, RUMContextProvider {
os: .init(context: context),
service: context.service,
session: .init(
hasReplay: context.srBaggage?.isReplayBeingRecorded,
hasReplay: context.srBaggage?.hasReplay,
id: self.context.sessionID.toRUMDataFormat,
type: dependencies.ciTest != nil ? .ciTest : .user
),
Expand Down Expand Up @@ -442,6 +438,12 @@ internal class RUMViewScope: RUMScope, RUMContextProvider {
dd: .init(
browserSdkVersion: nil,
documentVersion: version.toInt64,
pageStates: nil,
replayStats: .init(
recordsCount: context.srBaggage?.recordsCountByViewID[viewUUID.toRUMDataFormat],
segmentsCount: nil,
segmentsTotalRawSize: nil
),
session: .init(plan: .plan1)
),
application: .init(id: self.context.rumApplicationID),
Expand All @@ -453,12 +455,14 @@ internal class RUMViewScope: RUMScope, RUMContextProvider {
display: nil,
featureFlags: .init(featureFlagsInfo: featureFlags),
os: .init(context: context),
privacy: nil,
service: context.service,
session: .init(
hasReplay: context.srBaggage?.isReplayBeingRecorded,
hasReplay: context.srBaggage?.hasReplay,
id: self.context.sessionID.toRUMDataFormat,
isActive: self.context.isSessionActive,
startReason: nil,
sampledForReplay: nil,
startPrecondition: nil,
type: dependencies.ciTest != nil ? .ciTest : .user
),
source: .init(rawValue: context.source) ?? .ios,
Expand Down Expand Up @@ -509,11 +513,7 @@ internal class RUMViewScope: RUMScope, RUMContextProvider {
)

if let event = dependencies.eventBuilder.build(from: viewEvent) {
if viewUpdatesThrottler.accept(event: event) {
writer.write(value: event, metadata: event.metadata())
} else { // if event was dropped by sampler
version -= 1
}
writer.write(value: event, metadata: event.metadata())

// Update `CrashContext` with recent RUM view (no matter sampling - we want to always
// have recent information if process is interrupted by crash):
Expand Down Expand Up @@ -564,7 +564,7 @@ internal class RUMViewScope: RUMScope, RUMContextProvider {
os: .init(context: context),
service: context.service,
session: .init(
hasReplay: context.srBaggage?.isReplayBeingRecorded,
hasReplay: context.srBaggage?.hasReplay,
id: self.context.sessionID.toRUMDataFormat,
type: dependencies.ciTest != nil ? .ciTest : .user
),
Expand Down Expand Up @@ -615,7 +615,7 @@ internal class RUMViewScope: RUMScope, RUMContextProvider {
os: .init(context: context),
service: context.service,
session: .init(
hasReplay: context.srBaggage?.isReplayBeingRecorded,
hasReplay: context.srBaggage?.hasReplay,
id: self.context.sessionID.toRUMDataFormat,
type: dependencies.ciTest != nil ? .ciTest : .user
),
Expand Down
14 changes: 2 additions & 12 deletions DatadogRUM/Tests/Mocks/RUMFeatureMocks.swift
Original file line number Diff line number Diff line change
Expand Up @@ -640,12 +640,6 @@ extension RUMContext {

// MARK: - RUMScope Mocks

internal struct NoOpRUMViewUpdatesThrottler: RUMViewUpdatesThrottlerType {
func accept(event: RUMViewEvent) -> Bool {
return true // always send view update
}
}

func mockNoOpSessionListener() -> RUM.SessionListener {
return { _, _ in }
}
Expand All @@ -665,7 +659,6 @@ extension RUMScopeDependencies {
eventBuilder: RUMEventBuilder = RUMEventBuilder(eventsMapper: .mockNoOp()),
rumUUIDGenerator: RUMUUIDGenerator = DefaultRUMUUIDGenerator(),
ciTest: RUMCITest? = nil,
viewUpdatesThrottlerFactory: @escaping () -> RUMViewUpdatesThrottlerType = { NoOpRUMViewUpdatesThrottler() },
vitalsReaders: VitalsReaders? = nil,
onSessionStart: @escaping RUM.SessionListener = mockNoOpSessionListener()
) -> RUMScopeDependencies {
Expand All @@ -679,7 +672,6 @@ extension RUMScopeDependencies {
eventBuilder: eventBuilder,
rumUUIDGenerator: rumUUIDGenerator,
ciTest: ciTest,
viewUpdatesThrottlerFactory: viewUpdatesThrottlerFactory,
vitalsReaders: vitalsReaders,
onSessionStart: onSessionStart
)
Expand All @@ -695,7 +687,6 @@ extension RUMScopeDependencies {
eventBuilder: RUMEventBuilder? = nil,
rumUUIDGenerator: RUMUUIDGenerator? = nil,
ciTest: RUMCITest? = nil,
viewUpdatesThrottlerFactory: (() -> RUMViewUpdatesThrottlerType)? = nil,
vitalsReaders: VitalsReaders? = nil,
onSessionStart: RUM.SessionListener? = nil
) -> RUMScopeDependencies {
Expand All @@ -709,7 +700,6 @@ extension RUMScopeDependencies {
eventBuilder: eventBuilder ?? self.eventBuilder,
rumUUIDGenerator: rumUUIDGenerator ?? self.rumUUIDGenerator,
ciTest: ciTest ?? self.ciTest,
viewUpdatesThrottlerFactory: viewUpdatesThrottlerFactory ?? self.viewUpdatesThrottlerFactory,
vitalsReaders: vitalsReaders ?? self.vitalsReaders,
onSessionStart: onSessionStart ?? self.onSessionStart
)
Expand All @@ -733,14 +723,14 @@ extension RUMSessionScope {
parent: RUMContextProvider = RUMContextProviderMock(),
startTime: Date = .mockAny(),
dependencies: RUMScopeDependencies = .mockAny(),
isReplayBeingRecorded: Bool? = .mockAny()
hasReplay: Bool? = .mockAny()
) -> RUMSessionScope {
return RUMSessionScope(
isInitialSession: isInitialSession,
parent: parent,
startTime: startTime,
dependencies: dependencies,
isReplayBeingRecorded: isReplayBeingRecorded
hasReplay: hasReplay
)
}
}
Expand Down

0 comments on commit 08540ad

Please sign in to comment.