diff --git a/Sources/Datadog/FeaturesIntegration/CrashReporting/CrashReportingWithRUMIntegration.swift b/Sources/Datadog/FeaturesIntegration/CrashReporting/CrashReportingWithRUMIntegration.swift index 3720fb2b86..c34a3e3767 100644 --- a/Sources/Datadog/FeaturesIntegration/CrashReporting/CrashReportingWithRUMIntegration.swift +++ b/Sources/Datadog/FeaturesIntegration/CrashReporting/CrashReportingWithRUMIntegration.swift @@ -225,10 +225,12 @@ internal struct CrashReportingWithRUMIntegration: CrashReportingIntegration { let rumError = RUMErrorEvent( dd: .init( + browserSdkVersion: nil, session: .init(plan: .plan1) ), action: nil, application: .init(id: lastRUMView.application.id), + ciTest: nil, connectivity: lastRUMView.connectivity, context: nil, date: crashDate.timeIntervalSince1970.toInt64Milliseconds, @@ -250,6 +252,7 @@ internal struct CrashReportingWithRUMIntegration: CrashReportingIntegration { id: lastRUMView.session.id, type: .user ), + source: .ios, synthetics: nil, usr: lastRUMView.usr, view: .init( @@ -271,15 +274,18 @@ internal struct CrashReportingWithRUMIntegration: CrashReportingIntegration { let original = rumViewEvent.model let rumView = RUMViewEvent( dd: .init( + browserSdkVersion: nil, documentVersion: original.dd.documentVersion + 1, session: .init(plan: .plan1) ), application: original.application, + ciTest: nil, connectivity: original.connectivity, context: original.context, date: crashDate.timeIntervalSince1970.toInt64Milliseconds - 1, // -1ms to put the crash after view in RUM session service: original.service, session: original.session, + source: .ios, synthetics: nil, usr: original.usr, view: .init( @@ -333,12 +339,14 @@ internal struct CrashReportingWithRUMIntegration: CrashReportingIntegration { let rumView = RUMViewEvent( dd: .init( + browserSdkVersion: nil, documentVersion: 1, session: .init(plan: .plan1) ), application: .init( id: rumConfiguration.applicationID ), + ciTest: nil, connectivity: RUMConnectivity( networkInfo: crashContext.lastNetworkConnectionInfo, carrierInfo: crashContext.lastCarrierInfo @@ -351,6 +359,7 @@ internal struct CrashReportingWithRUMIntegration: CrashReportingIntegration { id: sessionUUID.toRUMDataFormat, type: .user ), + source: .ios, synthetics: nil, usr: crashContext.lastUserInfo.flatMap { RUMUser(userInfo: $0) }, view: .init( diff --git a/Sources/Datadog/RUM/DataModels/RUMDataModels.swift b/Sources/Datadog/RUM/DataModels/RUMDataModels.swift index e49f02bd5a..fba88de49a 100644 --- a/Sources/Datadog/RUM/DataModels/RUMDataModels.swift +++ b/Sources/Datadog/RUM/DataModels/RUMDataModels.swift @@ -16,6 +16,9 @@ public struct RUMViewEvent: RUMDataModel { /// Application properties public let application: Application + /// CI Visibility properties + public let ciTest: CiTest? + /// Device connectivity properties public let connectivity: RUMConnectivity? @@ -31,6 +34,9 @@ public struct RUMViewEvent: RUMDataModel { /// Session properties public let session: Session + /// The source of this event + public let source: Source? + /// Synthetics properties public let synthetics: Synthetics? @@ -46,11 +52,13 @@ public struct RUMViewEvent: RUMDataModel { enum CodingKeys: String, CodingKey { case dd = "_dd" case application = "application" + case ciTest = "ci_test" case connectivity = "connectivity" case context = "context" case date = "date" case service = "service" case session = "session" + case source = "source" case synthetics = "synthetics" case type = "type" case usr = "usr" @@ -59,6 +67,9 @@ public struct RUMViewEvent: RUMDataModel { /// Internal properties public struct DD: Codable { + /// Browser SDK version + public let browserSdkVersion: String? + /// Version of the update of the view event public let documentVersion: Int64 @@ -69,6 +80,7 @@ public struct RUMViewEvent: RUMDataModel { public let session: Session? enum CodingKeys: String, CodingKey { + case browserSdkVersion = "browser_sdk_version" case documentVersion = "document_version" case formatVersion = "format_version" case session = "session" @@ -101,6 +113,16 @@ public struct RUMViewEvent: RUMDataModel { } } + /// CI Visibility properties + public struct CiTest: Codable { + /// The identifier of the current CI Visibility test execution + public let testExecutionId: String + + enum CodingKeys: String, CodingKey { + case testExecutionId = "test_execution_id" + } + } + /// Session properties public struct Session: Codable { /// Whether this session has a replay @@ -122,11 +144,24 @@ public struct RUMViewEvent: RUMDataModel { public enum SessionType: String, Codable { case user = "user" case synthetics = "synthetics" + case ciTest = "ci_test" } } + /// The source of this event + public enum Source: String, Codable { + case android = "android" + case ios = "ios" + case browser = "browser" + case flutter = "flutter" + case reactNative = "react-native" + } + /// Synthetics properties public struct Synthetics: Codable { + /// Whether the event comes from a SDK instance injected by Synthetics + public let injected: Bool? + /// The identifier of the current Synthetics test results public let resultId: String @@ -134,6 +169,7 @@ public struct RUMViewEvent: RUMDataModel { public let testId: String enum CodingKeys: String, CodingKey { + case injected = "injected" case resultId = "result_id" case testId = "test_id" } @@ -371,6 +407,9 @@ public struct RUMResourceEvent: RUMDataModel { /// Application properties public let application: Application + /// CI Visibility properties + public let ciTest: CiTest? + /// Device connectivity properties public let connectivity: RUMConnectivity? @@ -389,6 +428,9 @@ public struct RUMResourceEvent: RUMDataModel { /// Session properties public let session: Session + /// The source of this event + public let source: Source? + /// Synthetics properties public let synthetics: Synthetics? @@ -405,12 +447,14 @@ public struct RUMResourceEvent: RUMDataModel { case dd = "_dd" case action = "action" case application = "application" + case ciTest = "ci_test" case connectivity = "connectivity" case context = "context" case date = "date" case resource = "resource" case service = "service" case session = "session" + case source = "source" case synthetics = "synthetics" case type = "type" case usr = "usr" @@ -419,6 +463,9 @@ public struct RUMResourceEvent: RUMDataModel { /// Internal properties public struct DD: Codable { + /// Browser SDK version + public let browserSdkVersion: String? + /// Version of the RUM event format public let formatVersion: Int64 = 2 @@ -432,6 +479,7 @@ public struct RUMResourceEvent: RUMDataModel { public let traceId: String? enum CodingKeys: String, CodingKey { + case browserSdkVersion = "browser_sdk_version" case formatVersion = "format_version" case session = "session" case spanId = "span_id" @@ -475,6 +523,16 @@ public struct RUMResourceEvent: RUMDataModel { } } + /// CI Visibility properties + public struct CiTest: Codable { + /// The identifier of the current CI Visibility test execution + public let testExecutionId: String + + enum CodingKeys: String, CodingKey { + case testExecutionId = "test_execution_id" + } + } + /// Resource properties public struct Resource: Codable { /// Connect phase properties @@ -693,11 +751,24 @@ public struct RUMResourceEvent: RUMDataModel { public enum SessionType: String, Codable { case user = "user" case synthetics = "synthetics" + case ciTest = "ci_test" } } + /// The source of this event + public enum Source: String, Codable { + case android = "android" + case ios = "ios" + case browser = "browser" + case flutter = "flutter" + case reactNative = "react-native" + } + /// Synthetics properties public struct Synthetics: Codable { + /// Whether the event comes from a SDK instance injected by Synthetics + public let injected: Bool? + /// The identifier of the current Synthetics test results public let resultId: String @@ -705,6 +776,7 @@ public struct RUMResourceEvent: RUMDataModel { public let testId: String enum CodingKeys: String, CodingKey { + case injected = "injected" case resultId = "result_id" case testId = "test_id" } @@ -744,6 +816,9 @@ public struct RUMActionEvent: RUMDataModel { /// Application properties public let application: Application + /// CI Visibility properties + public let ciTest: CiTest? + /// Device connectivity properties public let connectivity: RUMConnectivity? @@ -759,6 +834,9 @@ public struct RUMActionEvent: RUMDataModel { /// Session properties public let session: Session + /// The source of this event + public let source: Source? + /// Synthetics properties public let synthetics: Synthetics? @@ -775,11 +853,13 @@ public struct RUMActionEvent: RUMDataModel { case dd = "_dd" case action = "action" case application = "application" + case ciTest = "ci_test" case connectivity = "connectivity" case context = "context" case date = "date" case service = "service" case session = "session" + case source = "source" case synthetics = "synthetics" case type = "type" case usr = "usr" @@ -788,6 +868,9 @@ public struct RUMActionEvent: RUMDataModel { /// Internal properties public struct DD: Codable { + /// Browser SDK version + public let browserSdkVersion: String? + /// Version of the RUM event format public let formatVersion: Int64 = 2 @@ -795,6 +878,7 @@ public struct RUMActionEvent: RUMDataModel { public let session: Session? enum CodingKeys: String, CodingKey { + case browserSdkVersion = "browser_sdk_version" case formatVersion = "format_version" case session = "session" } @@ -925,6 +1009,16 @@ public struct RUMActionEvent: RUMDataModel { } } + /// CI Visibility properties + public struct CiTest: Codable { + /// The identifier of the current CI Visibility test execution + public let testExecutionId: String + + enum CodingKeys: String, CodingKey { + case testExecutionId = "test_execution_id" + } + } + /// Session properties public struct Session: Codable { /// Whether this session has a replay @@ -946,11 +1040,24 @@ public struct RUMActionEvent: RUMDataModel { public enum SessionType: String, Codable { case user = "user" case synthetics = "synthetics" + case ciTest = "ci_test" } } + /// The source of this event + public enum Source: String, Codable { + case android = "android" + case ios = "ios" + case browser = "browser" + case flutter = "flutter" + case reactNative = "react-native" + } + /// Synthetics properties public struct Synthetics: Codable { + /// Whether the event comes from a SDK instance injected by Synthetics + public let injected: Bool? + /// The identifier of the current Synthetics test results public let resultId: String @@ -958,6 +1065,7 @@ public struct RUMActionEvent: RUMDataModel { public let testId: String enum CodingKeys: String, CodingKey { + case injected = "injected" case resultId = "result_id" case testId = "test_id" } @@ -1001,6 +1109,9 @@ public struct RUMErrorEvent: RUMDataModel { /// Application properties public let application: Application + /// CI Visibility properties + public let ciTest: CiTest? + /// Device connectivity properties public let connectivity: RUMConnectivity? @@ -1019,6 +1130,9 @@ public struct RUMErrorEvent: RUMDataModel { /// Session properties public let session: Session + /// The source of this event + public let source: Source? + /// Synthetics properties public let synthetics: Synthetics? @@ -1035,12 +1149,14 @@ public struct RUMErrorEvent: RUMDataModel { case dd = "_dd" case action = "action" case application = "application" + case ciTest = "ci_test" case connectivity = "connectivity" case context = "context" case date = "date" case error = "error" case service = "service" case session = "session" + case source = "source" case synthetics = "synthetics" case type = "type" case usr = "usr" @@ -1049,6 +1165,9 @@ public struct RUMErrorEvent: RUMDataModel { /// Internal properties public struct DD: Codable { + /// Browser SDK version + public let browserSdkVersion: String? + /// Version of the RUM event format public let formatVersion: Int64 = 2 @@ -1056,6 +1175,7 @@ public struct RUMErrorEvent: RUMDataModel { public let session: Session? enum CodingKeys: String, CodingKey { + case browserSdkVersion = "browser_sdk_version" case formatVersion = "format_version" case session = "session" } @@ -1097,6 +1217,16 @@ public struct RUMErrorEvent: RUMDataModel { } } + /// CI Visibility properties + public struct CiTest: Codable { + /// The identifier of the current CI Visibility test execution + public let testExecutionId: String + + enum CodingKeys: String, CodingKey { + case testExecutionId = "test_execution_id" + } + } + /// Error properties public struct Error: Codable { /// Whether the error has been handled manually in the source code or not @@ -1223,6 +1353,7 @@ public struct RUMErrorEvent: RUMDataModel { case browser = "browser" case ios = "ios" case reactNative = "react-native" + case flutter = "flutter" } } @@ -1247,11 +1378,24 @@ public struct RUMErrorEvent: RUMDataModel { public enum SessionType: String, Codable { case user = "user" case synthetics = "synthetics" + case ciTest = "ci_test" } } + /// The source of this event + public enum Source: String, Codable { + case android = "android" + case ios = "ios" + case browser = "browser" + case flutter = "flutter" + case reactNative = "react-native" + } + /// Synthetics properties public struct Synthetics: Codable { + /// Whether the event comes from a SDK instance injected by Synthetics + public let injected: Bool? + /// The identifier of the current Synthetics test results public let resultId: String @@ -1259,6 +1403,7 @@ public struct RUMErrorEvent: RUMDataModel { public let testId: String enum CodingKeys: String, CodingKey { + case injected = "injected" case resultId = "result_id" case testId = "test_id" } @@ -1302,6 +1447,9 @@ public struct RUMLongTaskEvent: RUMDataModel { /// Application properties public let application: Application + /// CI Visibility properties + public let ciTest: CiTest? + /// Device connectivity properties public let connectivity: RUMConnectivity? @@ -1320,6 +1468,9 @@ public struct RUMLongTaskEvent: RUMDataModel { /// Session properties public let session: Session + /// The source of this event + public let source: Source? + /// Synthetics properties public let synthetics: Synthetics? @@ -1336,12 +1487,14 @@ public struct RUMLongTaskEvent: RUMDataModel { case dd = "_dd" case action = "action" case application = "application" + case ciTest = "ci_test" case connectivity = "connectivity" case context = "context" case date = "date" case longTask = "long_task" case service = "service" case session = "session" + case source = "source" case synthetics = "synthetics" case type = "type" case usr = "usr" @@ -1350,6 +1503,9 @@ public struct RUMLongTaskEvent: RUMDataModel { /// Internal properties public struct DD: Codable { + /// Browser SDK version + public let browserSdkVersion: String? + /// Version of the RUM event format public let formatVersion: Int64 = 2 @@ -1357,6 +1513,7 @@ public struct RUMLongTaskEvent: RUMDataModel { public let session: Session? enum CodingKeys: String, CodingKey { + case browserSdkVersion = "browser_sdk_version" case formatVersion = "format_version" case session = "session" } @@ -1398,6 +1555,16 @@ public struct RUMLongTaskEvent: RUMDataModel { } } + /// CI Visibility properties + public struct CiTest: Codable { + /// The identifier of the current CI Visibility test execution + public let testExecutionId: String + + enum CodingKeys: String, CodingKey { + case testExecutionId = "test_execution_id" + } + } + /// Long Task properties public struct LongTask: Codable { /// Duration in ns of the long task @@ -1437,11 +1604,24 @@ public struct RUMLongTaskEvent: RUMDataModel { public enum SessionType: String, Codable { case user = "user" case synthetics = "synthetics" + case ciTest = "ci_test" } } + /// The source of this event + public enum Source: String, Codable { + case android = "android" + case ios = "ios" + case browser = "browser" + case flutter = "flutter" + case reactNative = "react-native" + } + /// Synthetics properties public struct Synthetics: Codable { + /// Whether the event comes from a SDK instance injected by Synthetics + public let injected: Bool? + /// The identifier of the current Synthetics test results public let resultId: String @@ -1449,6 +1629,7 @@ public struct RUMLongTaskEvent: RUMDataModel { public let testId: String enum CodingKeys: String, CodingKey { + case injected = "injected" case resultId = "result_id" case testId = "test_id" } @@ -1640,4 +1821,4 @@ public enum RUMMethod: String, Codable { case patch = "PATCH" } -// Generated from https://github.com/DataDog/rum-events-format/tree/9c135e77bb1da61ebbb6b2fb3b39e156d5120a8e +// Generated from https://github.com/DataDog/rum-events-format/tree/114c173caac5ea15446a157b666acbab05431361 diff --git a/Sources/Datadog/RUM/RUMMonitor/Scopes/RUMResourceScope.swift b/Sources/Datadog/RUM/RUMMonitor/Scopes/RUMResourceScope.swift index 15926dbc6e..e5748651a4 100644 --- a/Sources/Datadog/RUM/RUMMonitor/Scopes/RUMResourceScope.swift +++ b/Sources/Datadog/RUM/RUMMonitor/Scopes/RUMResourceScope.swift @@ -130,6 +130,7 @@ internal class RUMResourceScope: RUMScope { let eventData = RUMResourceEvent( dd: .init( + browserSdkVersion: nil, session: .init(plan: .plan1), spanId: spanId, traceId: traceId @@ -138,6 +139,7 @@ internal class RUMResourceScope: RUMScope { .init(id: rumUUID.toRUMDataFormat) }, application: .init(id: context.rumApplicationID), + ciTest: nil, connectivity: dependencies.connectivityInfoProvider.current, context: .init(contextInfo: attributes), date: dateCorrection.applying(to: resourceStartTime).timeIntervalSince1970.toInt64Milliseconds, @@ -189,6 +191,7 @@ internal class RUMResourceScope: RUMScope { ), service: nil, session: .init(hasReplay: nil, id: context.sessionID.toRUMDataFormat, type: .user), + source: .ios, synthetics: nil, usr: dependencies.userInfoProvider.current, view: .init( @@ -211,12 +214,14 @@ internal class RUMResourceScope: RUMScope { let eventData = RUMErrorEvent( dd: .init( + browserSdkVersion: nil, session: .init(plan: .plan1) ), action: context.activeUserActionID.flatMap { rumUUID in .init(id: rumUUID.toRUMDataFormat) }, application: .init(id: context.rumApplicationID), + ciTest: nil, connectivity: dependencies.connectivityInfoProvider.current, context: .init(contextInfo: attributes), date: dateCorrection.applying(to: command.time).timeIntervalSince1970.toInt64Milliseconds, @@ -239,6 +244,7 @@ internal class RUMResourceScope: RUMScope { ), service: nil, session: .init(hasReplay: nil, id: context.sessionID.toRUMDataFormat, type: .user), + source: .ios, synthetics: nil, usr: dependencies.userInfoProvider.current, view: .init( diff --git a/Sources/Datadog/RUM/RUMMonitor/Scopes/RUMUserActionScope.swift b/Sources/Datadog/RUM/RUMMonitor/Scopes/RUMUserActionScope.swift index 3f8822eec4..34c8a4e364 100644 --- a/Sources/Datadog/RUM/RUMMonitor/Scopes/RUMUserActionScope.swift +++ b/Sources/Datadog/RUM/RUMMonitor/Scopes/RUMUserActionScope.swift @@ -134,6 +134,7 @@ internal class RUMUserActionScope: RUMScope, RUMContextProvider { let eventData = RUMActionEvent( dd: .init( + browserSdkVersion: nil, session: .init(plan: .plan1) ), action: .init( @@ -147,11 +148,13 @@ internal class RUMUserActionScope: RUMScope, RUMContextProvider { type: actionType.toRUMDataFormat ), application: .init(id: context.rumApplicationID), + ciTest: nil, connectivity: dependencies.connectivityInfoProvider.current, context: .init(contextInfo: attributes), date: dateCorrection.applying(to: actionStartTime).timeIntervalSince1970.toInt64Milliseconds, service: nil, session: .init(hasReplay: nil, id: context.sessionID.toRUMDataFormat, type: .user), + source: .ios, synthetics: nil, usr: dependencies.userInfoProvider.current, view: .init( diff --git a/Sources/Datadog/RUM/RUMMonitor/Scopes/RUMViewScope.swift b/Sources/Datadog/RUM/RUMMonitor/Scopes/RUMViewScope.swift index 403478b6bc..db97ebd8f7 100644 --- a/Sources/Datadog/RUM/RUMMonitor/Scopes/RUMViewScope.swift +++ b/Sources/Datadog/RUM/RUMMonitor/Scopes/RUMViewScope.swift @@ -305,6 +305,7 @@ internal class RUMViewScope: RUMScope, RUMContextProvider { private func sendApplicationStartAction() -> Bool { let eventData = RUMActionEvent( dd: .init( + browserSdkVersion: nil, session: .init(plan: .plan1) ), action: .init( @@ -318,11 +319,13 @@ internal class RUMViewScope: RUMScope, RUMContextProvider { type: .applicationStart ), application: .init(id: context.rumApplicationID), + ciTest: nil, connectivity: dependencies.connectivityInfoProvider.current, context: .init(contextInfo: attributes), date: dateCorrection.applying(to: viewStartTime).timeIntervalSince1970.toInt64Milliseconds, service: nil, session: .init(hasReplay: nil, id: context.sessionID.toRUMDataFormat, type: .user), + source: .ios, synthetics: nil, usr: dependencies.userInfoProvider.current, view: .init( @@ -356,15 +359,18 @@ internal class RUMViewScope: RUMScope, RUMContextProvider { let eventData = RUMViewEvent( dd: .init( + browserSdkVersion: nil, documentVersion: version.toInt64, session: .init(plan: .plan1) ), application: .init(id: context.rumApplicationID), + ciTest: nil, connectivity: dependencies.connectivityInfoProvider.current, context: .init(contextInfo: attributes), date: dateCorrection.applying(to: viewStartTime).timeIntervalSince1970.toInt64Milliseconds, service: nil, session: .init(hasReplay: nil, id: context.sessionID.toRUMDataFormat, type: .user), + source: .ios, synthetics: nil, usr: dependencies.userInfoProvider.current, view: .init( @@ -420,12 +426,14 @@ internal class RUMViewScope: RUMScope, RUMContextProvider { let eventData = RUMErrorEvent( dd: .init( + browserSdkVersion: nil, session: .init(plan: .plan1) ), action: context.activeUserActionID.flatMap { rumUUID in .init(id: rumUUID.toRUMDataFormat) }, application: .init(id: context.rumApplicationID), + ciTest: nil, connectivity: dependencies.connectivityInfoProvider.current, context: .init(contextInfo: attributes), date: dateCorrection.applying(to: command.time).timeIntervalSince1970.toInt64Milliseconds, @@ -443,6 +451,7 @@ internal class RUMViewScope: RUMScope, RUMContextProvider { ), service: nil, session: .init(hasReplay: nil, id: context.sessionID.toRUMDataFormat, type: .user), + source: .ios, synthetics: nil, usr: dependencies.userInfoProvider.current, view: .init( @@ -468,15 +477,20 @@ internal class RUMViewScope: RUMScope, RUMContextProvider { let isFrozenFrame = taskDurationInNs > Constants.frozenFrameThresholdInNs let eventData = RUMLongTaskEvent( - dd: .init(session: .init(plan: .plan1)), + dd: .init( + browserSdkVersion: nil, + session: .init(plan: .plan1) + ), action: context.activeUserActionID.flatMap { RUMLongTaskEvent.Action(id: $0.toRUMDataFormat) }, application: .init(id: context.rumApplicationID), + ciTest: nil, connectivity: dependencies.connectivityInfoProvider.current, context: .init(contextInfo: attributes), date: dateCorrection.applying(to: command.time - command.duration).timeIntervalSince1970.toInt64Milliseconds, longTask: .init(duration: taskDurationInNs, id: nil, isFrozenFrame: isFrozenFrame), service: nil, session: .init(hasReplay: nil, id: context.sessionID.toRUMDataFormat, type: .user), + source: .ios, synthetics: nil, usr: dependencies.userInfoProvider.current, view: .init( diff --git a/Sources/DatadogObjc/RUM/RUMDataModels+objc.swift b/Sources/DatadogObjc/RUM/RUMDataModels+objc.swift index bdbe834c8e..001b65d7db 100644 --- a/Sources/DatadogObjc/RUM/RUMDataModels+objc.swift +++ b/Sources/DatadogObjc/RUM/RUMDataModels+objc.swift @@ -28,6 +28,10 @@ public class DDRUMViewEvent: NSObject { DDRUMViewEventApplication(root: root) } + @objc public var ciTest: DDRUMViewEventCiTest? { + root.swiftModel.ciTest != nil ? DDRUMViewEventCiTest(root: root) : nil + } + @objc public var connectivity: DDRUMViewEventRUMConnectivity? { root.swiftModel.connectivity != nil ? DDRUMViewEventRUMConnectivity(root: root) : nil } @@ -48,6 +52,10 @@ public class DDRUMViewEvent: NSObject { DDRUMViewEventSession(root: root) } + @objc public var source: DDRUMViewEventSource { + .init(swift: root.swiftModel.source) + } + @objc public var synthetics: DDRUMViewEventSynthetics? { root.swiftModel.synthetics != nil ? DDRUMViewEventSynthetics(root: root) : nil } @@ -73,6 +81,10 @@ public class DDRUMViewEventDD: NSObject { self.root = root } + @objc public var browserSdkVersion: String? { + root.swiftModel.dd.browserSdkVersion + } + @objc public var documentVersion: NSNumber { root.swiftModel.dd.documentVersion as NSNumber } @@ -132,6 +144,19 @@ public class DDRUMViewEventApplication: NSObject { } } +@objc +public class DDRUMViewEventCiTest: NSObject { + internal let root: DDRUMViewEvent + + internal init(root: DDRUMViewEvent) { + self.root = root + } + + @objc public var testExecutionId: String { + root.swiftModel.ciTest!.testExecutionId + } +} + @objc public class DDRUMViewEventRUMConnectivity: NSObject { internal let root: DDRUMViewEvent @@ -274,6 +299,7 @@ public enum DDRUMViewEventSessionSessionType: Int { switch swift { case .user: self = .user case .synthetics: self = .synthetics + case .ciTest: self = .ciTest } } @@ -281,11 +307,45 @@ public enum DDRUMViewEventSessionSessionType: Int { switch self { case .user: return .user case .synthetics: return .synthetics + case .ciTest: return .ciTest } } case user case synthetics + case ciTest +} + +@objc +public enum DDRUMViewEventSource: Int { + internal init(swift: RUMViewEvent.Source?) { + switch swift { + case nil: self = .none + case .android?: self = .android + case .ios?: self = .ios + case .browser?: self = .browser + case .flutter?: self = .flutter + case .reactNative?: self = .reactNative + } + } + + internal var toSwift: RUMViewEvent.Source? { + switch self { + case .none: return nil + case .android: return .android + case .ios: return .ios + case .browser: return .browser + case .flutter: return .flutter + case .reactNative: return .reactNative + } + } + + case none + case android + case ios + case browser + case flutter + case reactNative } @objc @@ -296,6 +356,10 @@ public class DDRUMViewEventSynthetics: NSObject { self.root = root } + @objc public var injected: NSNumber? { + root.swiftModel.synthetics!.injected as NSNumber? + } + @objc public var resultId: String { root.swiftModel.synthetics!.resultId } @@ -628,6 +692,10 @@ public class DDRUMResourceEvent: NSObject { DDRUMResourceEventApplication(root: root) } + @objc public var ciTest: DDRUMResourceEventCiTest? { + root.swiftModel.ciTest != nil ? DDRUMResourceEventCiTest(root: root) : nil + } + @objc public var connectivity: DDRUMResourceEventRUMConnectivity? { root.swiftModel.connectivity != nil ? DDRUMResourceEventRUMConnectivity(root: root) : nil } @@ -652,6 +720,10 @@ public class DDRUMResourceEvent: NSObject { DDRUMResourceEventSession(root: root) } + @objc public var source: DDRUMResourceEventSource { + .init(swift: root.swiftModel.source) + } + @objc public var synthetics: DDRUMResourceEventSynthetics? { root.swiftModel.synthetics != nil ? DDRUMResourceEventSynthetics(root: root) : nil } @@ -677,6 +749,10 @@ public class DDRUMResourceEventDD: NSObject { self.root = root } + @objc public var browserSdkVersion: String? { + root.swiftModel.dd.browserSdkVersion + } + @objc public var formatVersion: NSNumber { root.swiftModel.dd.formatVersion as NSNumber } @@ -753,6 +829,19 @@ public class DDRUMResourceEventApplication: NSObject { } } +@objc +public class DDRUMResourceEventCiTest: NSObject { + internal let root: DDRUMResourceEvent + + internal init(root: DDRUMResourceEvent) { + self.root = root + } + + @objc public var testExecutionId: String { + root.swiftModel.ciTest!.testExecutionId + } +} + @objc public class DDRUMResourceEventRUMConnectivity: NSObject { internal let root: DDRUMResourceEvent @@ -1225,6 +1314,7 @@ public enum DDRUMResourceEventSessionSessionType: Int { switch swift { case .user: self = .user case .synthetics: self = .synthetics + case .ciTest: self = .ciTest } } @@ -1232,11 +1322,45 @@ public enum DDRUMResourceEventSessionSessionType: Int { switch self { case .user: return .user case .synthetics: return .synthetics + case .ciTest: return .ciTest } } case user case synthetics + case ciTest +} + +@objc +public enum DDRUMResourceEventSource: Int { + internal init(swift: RUMResourceEvent.Source?) { + switch swift { + case nil: self = .none + case .android?: self = .android + case .ios?: self = .ios + case .browser?: self = .browser + case .flutter?: self = .flutter + case .reactNative?: self = .reactNative + } + } + + internal var toSwift: RUMResourceEvent.Source? { + switch self { + case .none: return nil + case .android: return .android + case .ios: return .ios + case .browser: return .browser + case .flutter: return .flutter + case .reactNative: return .reactNative + } + } + + case none + case android + case ios + case browser + case flutter + case reactNative } @objc @@ -1247,6 +1371,10 @@ public class DDRUMResourceEventSynthetics: NSObject { self.root = root } + @objc public var injected: NSNumber? { + root.swiftModel.synthetics!.injected as NSNumber? + } + @objc public var resultId: String { root.swiftModel.synthetics!.resultId } @@ -1330,6 +1458,10 @@ public class DDRUMActionEvent: NSObject { DDRUMActionEventApplication(root: root) } + @objc public var ciTest: DDRUMActionEventCiTest? { + root.swiftModel.ciTest != nil ? DDRUMActionEventCiTest(root: root) : nil + } + @objc public var connectivity: DDRUMActionEventRUMConnectivity? { root.swiftModel.connectivity != nil ? DDRUMActionEventRUMConnectivity(root: root) : nil } @@ -1350,6 +1482,10 @@ public class DDRUMActionEvent: NSObject { DDRUMActionEventSession(root: root) } + @objc public var source: DDRUMActionEventSource { + .init(swift: root.swiftModel.source) + } + @objc public var synthetics: DDRUMActionEventSynthetics? { root.swiftModel.synthetics != nil ? DDRUMActionEventSynthetics(root: root) : nil } @@ -1375,6 +1511,10 @@ public class DDRUMActionEventDD: NSObject { self.root = root } + @objc public var browserSdkVersion: String? { + root.swiftModel.dd.browserSdkVersion + } + @objc public var formatVersion: NSNumber { root.swiftModel.dd.formatVersion as NSNumber } @@ -1572,6 +1712,19 @@ public class DDRUMActionEventApplication: NSObject { } } +@objc +public class DDRUMActionEventCiTest: NSObject { + internal let root: DDRUMActionEvent + + internal init(root: DDRUMActionEvent) { + self.root = root + } + + @objc public var testExecutionId: String { + root.swiftModel.ciTest!.testExecutionId + } +} + @objc public class DDRUMActionEventRUMConnectivity: NSObject { internal let root: DDRUMActionEvent @@ -1714,6 +1867,7 @@ public enum DDRUMActionEventSessionSessionType: Int { switch swift { case .user: self = .user case .synthetics: self = .synthetics + case .ciTest: self = .ciTest } } @@ -1721,11 +1875,45 @@ public enum DDRUMActionEventSessionSessionType: Int { switch self { case .user: return .user case .synthetics: return .synthetics + case .ciTest: return .ciTest } } case user case synthetics + case ciTest +} + +@objc +public enum DDRUMActionEventSource: Int { + internal init(swift: RUMActionEvent.Source?) { + switch swift { + case nil: self = .none + case .android?: self = .android + case .ios?: self = .ios + case .browser?: self = .browser + case .flutter?: self = .flutter + case .reactNative?: self = .reactNative + } + } + + internal var toSwift: RUMActionEvent.Source? { + switch self { + case .none: return nil + case .android: return .android + case .ios: return .ios + case .browser: return .browser + case .flutter: return .flutter + case .reactNative: return .reactNative + } + } + + case none + case android + case ios + case browser + case flutter + case reactNative } @objc @@ -1736,6 +1924,10 @@ public class DDRUMActionEventSynthetics: NSObject { self.root = root } + @objc public var injected: NSNumber? { + root.swiftModel.synthetics!.injected as NSNumber? + } + @objc public var resultId: String { root.swiftModel.synthetics!.resultId } @@ -1823,6 +2015,10 @@ public class DDRUMErrorEvent: NSObject { DDRUMErrorEventApplication(root: root) } + @objc public var ciTest: DDRUMErrorEventCiTest? { + root.swiftModel.ciTest != nil ? DDRUMErrorEventCiTest(root: root) : nil + } + @objc public var connectivity: DDRUMErrorEventRUMConnectivity? { root.swiftModel.connectivity != nil ? DDRUMErrorEventRUMConnectivity(root: root) : nil } @@ -1847,6 +2043,10 @@ public class DDRUMErrorEvent: NSObject { DDRUMErrorEventSession(root: root) } + @objc public var source: DDRUMErrorEventSource { + .init(swift: root.swiftModel.source) + } + @objc public var synthetics: DDRUMErrorEventSynthetics? { root.swiftModel.synthetics != nil ? DDRUMErrorEventSynthetics(root: root) : nil } @@ -1872,6 +2072,10 @@ public class DDRUMErrorEventDD: NSObject { self.root = root } + @objc public var browserSdkVersion: String? { + root.swiftModel.dd.browserSdkVersion + } + @objc public var formatVersion: NSNumber { root.swiftModel.dd.formatVersion as NSNumber } @@ -1940,6 +2144,19 @@ public class DDRUMErrorEventApplication: NSObject { } } +@objc +public class DDRUMErrorEventCiTest: NSObject { + internal let root: DDRUMErrorEvent + + internal init(root: DDRUMErrorEvent) { + self.root = root + } + + @objc public var testExecutionId: String { + root.swiftModel.ciTest!.testExecutionId + } +} + @objc public class DDRUMErrorEventRUMConnectivity: NSObject { internal let root: DDRUMErrorEvent @@ -2311,6 +2528,7 @@ public enum DDRUMErrorEventErrorSourceType: Int { case .browser?: self = .browser case .ios?: self = .ios case .reactNative?: self = .reactNative + case .flutter?: self = .flutter } } @@ -2321,6 +2539,7 @@ public enum DDRUMErrorEventErrorSourceType: Int { case .browser: return .browser case .ios: return .ios case .reactNative: return .reactNative + case .flutter: return .flutter } } @@ -2329,6 +2548,7 @@ public enum DDRUMErrorEventErrorSourceType: Int { case browser case ios case reactNative + case flutter } @objc @@ -2358,6 +2578,7 @@ public enum DDRUMErrorEventSessionSessionType: Int { switch swift { case .user: self = .user case .synthetics: self = .synthetics + case .ciTest: self = .ciTest } } @@ -2365,11 +2586,45 @@ public enum DDRUMErrorEventSessionSessionType: Int { switch self { case .user: return .user case .synthetics: return .synthetics + case .ciTest: return .ciTest } } case user case synthetics + case ciTest +} + +@objc +public enum DDRUMErrorEventSource: Int { + internal init(swift: RUMErrorEvent.Source?) { + switch swift { + case nil: self = .none + case .android?: self = .android + case .ios?: self = .ios + case .browser?: self = .browser + case .flutter?: self = .flutter + case .reactNative?: self = .reactNative + } + } + + internal var toSwift: RUMErrorEvent.Source? { + switch self { + case .none: return nil + case .android: return .android + case .ios: return .ios + case .browser: return .browser + case .flutter: return .flutter + case .reactNative: return .reactNative + } + } + + case none + case android + case ios + case browser + case flutter + case reactNative } @objc @@ -2380,6 +2635,10 @@ public class DDRUMErrorEventSynthetics: NSObject { self.root = root } + @objc public var injected: NSNumber? { + root.swiftModel.synthetics!.injected as NSNumber? + } + @objc public var resultId: String { root.swiftModel.synthetics!.resultId } @@ -2467,6 +2726,10 @@ public class DDRUMLongTaskEvent: NSObject { DDRUMLongTaskEventApplication(root: root) } + @objc public var ciTest: DDRUMLongTaskEventCiTest? { + root.swiftModel.ciTest != nil ? DDRUMLongTaskEventCiTest(root: root) : nil + } + @objc public var connectivity: DDRUMLongTaskEventRUMConnectivity? { root.swiftModel.connectivity != nil ? DDRUMLongTaskEventRUMConnectivity(root: root) : nil } @@ -2491,6 +2754,10 @@ public class DDRUMLongTaskEvent: NSObject { DDRUMLongTaskEventSession(root: root) } + @objc public var source: DDRUMLongTaskEventSource { + .init(swift: root.swiftModel.source) + } + @objc public var synthetics: DDRUMLongTaskEventSynthetics? { root.swiftModel.synthetics != nil ? DDRUMLongTaskEventSynthetics(root: root) : nil } @@ -2516,6 +2783,10 @@ public class DDRUMLongTaskEventDD: NSObject { self.root = root } + @objc public var browserSdkVersion: String? { + root.swiftModel.dd.browserSdkVersion + } + @objc public var formatVersion: NSNumber { root.swiftModel.dd.formatVersion as NSNumber } @@ -2584,6 +2855,19 @@ public class DDRUMLongTaskEventApplication: NSObject { } } +@objc +public class DDRUMLongTaskEventCiTest: NSObject { + internal let root: DDRUMLongTaskEvent + + internal init(root: DDRUMLongTaskEvent) { + self.root = root + } + + @objc public var testExecutionId: String { + root.swiftModel.ciTest!.testExecutionId + } +} + @objc public class DDRUMLongTaskEventRUMConnectivity: NSObject { internal let root: DDRUMLongTaskEvent @@ -2747,6 +3031,7 @@ public enum DDRUMLongTaskEventSessionSessionType: Int { switch swift { case .user: self = .user case .synthetics: self = .synthetics + case .ciTest: self = .ciTest } } @@ -2754,11 +3039,45 @@ public enum DDRUMLongTaskEventSessionSessionType: Int { switch self { case .user: return .user case .synthetics: return .synthetics + case .ciTest: return .ciTest } } case user case synthetics + case ciTest +} + +@objc +public enum DDRUMLongTaskEventSource: Int { + internal init(swift: RUMLongTaskEvent.Source?) { + switch swift { + case nil: self = .none + case .android?: self = .android + case .ios?: self = .ios + case .browser?: self = .browser + case .flutter?: self = .flutter + case .reactNative?: self = .reactNative + } + } + + internal var toSwift: RUMLongTaskEvent.Source? { + switch self { + case .none: return nil + case .android: return .android + case .ios: return .ios + case .browser: return .browser + case .flutter: return .flutter + case .reactNative: return .reactNative + } + } + + case none + case android + case ios + case browser + case flutter + case reactNative } @objc @@ -2769,6 +3088,10 @@ public class DDRUMLongTaskEventSynthetics: NSObject { self.root = root } + @objc public var injected: NSNumber? { + root.swiftModel.synthetics!.injected as NSNumber? + } + @objc public var resultId: String { root.swiftModel.synthetics!.resultId } @@ -2833,4 +3156,4 @@ public class DDRUMLongTaskEventView: NSObject { // swiftlint:enable force_unwrapping -// Generated from https://github.com/DataDog/rum-events-format/tree/9c135e77bb1da61ebbb6b2fb3b39e156d5120a8e +// Generated from https://github.com/DataDog/rum-events-format/tree/114c173caac5ea15446a157b666acbab05431361 diff --git a/Tests/DatadogTests/Datadog/Mocks/RUMDataModelMocks.swift b/Tests/DatadogTests/Datadog/Mocks/RUMDataModelMocks.swift index 2fbbe91e01..134d1c5067 100644 --- a/Tests/DatadogTests/Datadog/Mocks/RUMDataModelMocks.swift +++ b/Tests/DatadogTests/Datadog/Mocks/RUMDataModelMocks.swift @@ -55,10 +55,12 @@ extension RUMViewEvent: RandomMockable { static func mockRandom() -> RUMViewEvent { return RUMViewEvent( dd: .init( + browserSdkVersion: nil, documentVersion: .mockRandom(), session: .init(plan: .plan1) ), application: .init(id: .mockRandom()), + ciTest: nil, connectivity: .mockRandom(), context: .mockRandom(), date: .mockRandom(), @@ -68,6 +70,7 @@ extension RUMViewEvent: RandomMockable { id: .mockRandom(), type: .user ), + source: .ios, synthetics: nil, usr: .mockRandom(), view: .init( @@ -117,12 +120,14 @@ extension RUMResourceEvent: RandomMockable { static func mockRandom() -> RUMResourceEvent { return RUMResourceEvent( dd: .init( + browserSdkVersion: nil, session: .init(plan: .plan1), spanId: .mockRandom(), traceId: .mockRandom() ), action: .init(id: .mockRandom()), application: .init(id: .mockRandom()), + ciTest: nil, connectivity: .mockRandom(), context: .mockRandom(), date: .mockRandom(), @@ -152,6 +157,7 @@ extension RUMResourceEvent: RandomMockable { id: .mockRandom(), type: .user ), + source: .ios, synthetics: nil, usr: .mockRandom(), view: .init( @@ -167,6 +173,7 @@ extension RUMActionEvent: RandomMockable { static func mockRandom() -> RUMActionEvent { return RUMActionEvent( dd: .init( + browserSdkVersion: nil, session: .init(plan: .plan1) ), action: .init( @@ -180,6 +187,7 @@ extension RUMActionEvent: RandomMockable { type: [.tap, .swipe, .scroll].randomElement()! ), application: .init(id: .mockRandom()), + ciTest: nil, connectivity: .mockRandom(), context: .mockRandom(), date: .mockRandom(), @@ -189,6 +197,7 @@ extension RUMActionEvent: RandomMockable { id: .mockRandom(), type: .user ), + source: .ios, synthetics: nil, usr: .mockRandom(), view: .init( @@ -211,10 +220,12 @@ extension RUMErrorEvent: RandomMockable { static func mockRandom() -> RUMErrorEvent { return RUMErrorEvent( dd: .init( + browserSdkVersion: nil, session: .init(plan: .plan1) ), action: .init(id: .mockRandom()), application: .init(id: .mockRandom()), + ciTest: nil, connectivity: .mockRandom(), context: .mockRandom(), date: .mockRandom(), @@ -245,6 +256,7 @@ extension RUMErrorEvent: RandomMockable { id: .mockRandom(), type: .user ), + source: .ios, synthetics: nil, usr: .mockRandom(), view: .init( @@ -260,15 +272,20 @@ extension RUMErrorEvent: RandomMockable { extension RUMLongTaskEvent: RandomMockable { static func mockRandom() -> RUMLongTaskEvent { return RUMLongTaskEvent( - dd: .init(session: .init(plan: .plan1)), + dd: .init( + browserSdkVersion: nil, + session: .init(plan: .plan1) + ), action: .init(id: .mockRandom()), application: .init(id: .mockRandom()), + ciTest: nil, connectivity: .mockRandom(), context: .mockRandom(), date: .mockRandom(), longTask: .init(duration: .mockRandom(), id: .mockRandom(), isFrozenFrame: .mockRandom()), service: .mockRandom(), session: .init(hasReplay: false, id: .mockRandom(), type: .user), + source: .ios, synthetics: nil, usr: .mockRandom(), view: .init(id: .mockRandom(), name: .mockRandom(), referrer: .mockRandom(), url: .mockRandom()) diff --git a/Tests/DatadogTests/Datadog/RUM/RUMMonitor/Scopes/RUMResourceScopeTests.swift b/Tests/DatadogTests/Datadog/RUM/RUMMonitor/Scopes/RUMResourceScopeTests.swift index 5a66e0e32c..f0864ba148 100644 --- a/Tests/DatadogTests/Datadog/RUM/RUMMonitor/Scopes/RUMResourceScopeTests.swift +++ b/Tests/DatadogTests/Datadog/RUM/RUMMonitor/Scopes/RUMResourceScopeTests.swift @@ -76,6 +76,7 @@ class RUMResourceScopeTests: XCTestCase { XCTAssertEqual(event.model.application.id, scope.context.rumApplicationID) XCTAssertEqual(event.model.session.id, scope.context.sessionID.toRUMDataFormat) XCTAssertEqual(event.model.session.type, .user) + XCTAssertEqual(event.model.source, .ios) XCTAssertEqual(event.model.view.id, context.activeViewID?.toRUMDataFormat) XCTAssertEqual(event.model.view.url, "FooViewController") XCTAssertEqual(event.model.view.name, "FooViewName") diff --git a/Tests/DatadogTests/Datadog/RUM/RUMMonitor/Scopes/RUMUserActionScopeTests.swift b/Tests/DatadogTests/Datadog/RUM/RUMMonitor/Scopes/RUMUserActionScopeTests.swift index 0a6dc208f2..6af0221066 100644 --- a/Tests/DatadogTests/Datadog/RUM/RUMMonitor/Scopes/RUMUserActionScopeTests.swift +++ b/Tests/DatadogTests/Datadog/RUM/RUMMonitor/Scopes/RUMUserActionScopeTests.swift @@ -58,6 +58,7 @@ class RUMUserActionScopeTests: XCTestCase { let recordedAction = try XCTUnwrap(recordedActionEvents.last) XCTAssertEqual(recordedAction.model.action.type.rawValue, String(describing: mockUserActionCmd.actionType)) XCTAssertEqual(recordedAction.model.dd.session?.plan, .plan1, "All RUM events should use RUM Lite plan") + XCTAssertEqual(recordedAction.model.source, .ios) } // MARK: - Continuous User Action diff --git a/Tests/DatadogTests/Datadog/RUM/RUMMonitor/Scopes/RUMViewScopeTests.swift b/Tests/DatadogTests/Datadog/RUM/RUMMonitor/Scopes/RUMViewScopeTests.swift index ef8441aba7..2751657b3a 100644 --- a/Tests/DatadogTests/Datadog/RUM/RUMMonitor/Scopes/RUMViewScopeTests.swift +++ b/Tests/DatadogTests/Datadog/RUM/RUMMonitor/Scopes/RUMViewScopeTests.swift @@ -92,6 +92,7 @@ class RUMViewScopeTests: XCTestCase { XCTAssertEqual(event.model.action.type, .applicationStart) XCTAssertEqual(event.model.action.loadingTime, 2_000_000_000) // 2e+9 ns XCTAssertEqual(event.model.dd.session?.plan, .plan1, "All RUM events should use RUM Lite plan") + XCTAssertEqual(event.model.source, .ios) } func testWhenInitialViewReceivesAnyCommand_itSendsViewUpdateEvent() throws { @@ -786,6 +787,7 @@ class RUMViewScopeTests: XCTestCase { XCTAssertEqual(longTask.context?.contextInfo as? [String: String], ["foo": "bar"]) XCTAssertEqual(longTask.date, longTaskStartingDate.timeIntervalSince1970.toInt64Milliseconds) XCTAssertEqual(longTask.dd.session?.plan, .plan1) + XCTAssertEqual(longTask.source, .ios) XCTAssertEqual(longTask.longTask.duration, (1.0).toInt64Nanoseconds) XCTAssertTrue(longTask.longTask.isFrozenFrame == true) XCTAssertEqual(longTask.view.id, scope.viewUUID.toRUMDataFormat)