Skip to content

Commit

Permalink
RUMM-2197 Avoid strict device and os validation in browser SDK ev…
Browse files Browse the repository at this point in the history
…ents (for integration tests)
  • Loading branch information
ncreated committed Jun 13, 2022
1 parent 793bdcc commit 6cdf6c6
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions Tests/DatadogTests/Matchers/RUMSessionMatcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,10 @@ private func validate(rumViewEvents: [RUMViewEvent]) throws {
description: "All RUM events must use session plan `1` (RUM Lite). Bad view event: \(viewEvent)"
)
}
try validate(device: viewEvent.device)
try validate(os: viewEvent.os)
if viewEvent.source == .ios { // validete only mobile events
try validate(device: viewEvent.device)
try validate(os: viewEvent.os)
}
}
}

Expand All @@ -262,8 +264,10 @@ private func validate(rumActionEvents: [RUMActionEvent]) throws {
description: "All RUM events must use session plan `1` (RUM Lite). Bad action event: \(actionEvent)"
)
}
try validate(device: actionEvent.device)
try validate(os: actionEvent.os)
if actionEvent.source == .ios { // validete only mobile events
try validate(device: actionEvent.device)
try validate(os: actionEvent.os)
}
}
}

Expand Down Expand Up @@ -296,8 +300,10 @@ private func validate(rumErrorEvents: [RUMErrorEvent]) throws {
description: "All RUM events must use session plan `1` (RUM Lite). Bad error event: \(errorEvent)"
)
}
try validate(device: errorEvent.device)
try validate(os: errorEvent.os)
if errorEvent.source == .ios { // validete only mobile events
try validate(device: errorEvent.device)
try validate(os: errorEvent.os)
}
}
}

Expand All @@ -309,8 +315,10 @@ private func validate(rumLongTaskEvents: [RUMLongTaskEvent]) throws {
description: "All RUM events must use session plan `1` (RUM Lite). Bad long task event: \(longTaskEvent)"
)
}
try validate(device: longTaskEvent.device)
try validate(os: longTaskEvent.os)
if longTaskEvent.source == .ios { // validete only mobile events
try validate(device: longTaskEvent.device)
try validate(os: longTaskEvent.os)
}
}
}

Expand Down Expand Up @@ -384,13 +392,13 @@ private func strictValidate(device: RUMDevice) throws {
/// It asserts that all values make sense for current environment.
private func strictValidate(os: RUMOperatingSystem) throws {
#if os(iOS)
if os.name != "iOS" && os.name != "iPadOS" {
guard os.name == "iOS" || os.name == "iPadOS" else {
throw RUMSessionConsistencyException(
description: "When running on iOS or iPadOS the `os.name` must be either 'iOS' or 'iPadOS'"
)
}
#else
if os.name != "tvOS" {
guard os.name == "tvOS" else {
throw RUMSessionConsistencyException(
description: "When running on tvOS the `os.name` must be 'tvOS'"
)
Expand Down

0 comments on commit 6cdf6c6

Please sign in to comment.