From d2172ad63cec4da3f52bd4b9965ec6477e8a94e2 Mon Sep 17 00:00:00 2001 From: Jeff Ward Date: Tue, 11 Jan 2022 09:42:04 -0500 Subject: [PATCH 1/2] Update RUM Schema Adds support for flutter error source (RUMM-1900) --- .../CrashReportingWithRUMIntegration.swift | 6 + .../RUM/DataModels/RUMDataModels.swift | 118 +++++++++++++- .../RUMMonitor/Scopes/RUMResourceScope.swift | 4 + .../Scopes/RUMUserActionScope.swift | 2 + .../RUM/RUMMonitor/Scopes/RUMViewScope.swift | 12 +- .../DatadogObjc/RUM/RUMDataModels+objc.swift | 145 +++++++++++++++++- .../Datadog/Mocks/RUMDataModelMocks.swift | 14 +- 7 files changed, 297 insertions(+), 4 deletions(-) diff --git a/Sources/Datadog/FeaturesIntegration/CrashReporting/CrashReportingWithRUMIntegration.swift b/Sources/Datadog/FeaturesIntegration/CrashReporting/CrashReportingWithRUMIntegration.swift index 3720fb2b86..16449a8b2e 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, @@ -271,10 +273,12 @@ 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 @@ -333,12 +337,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 diff --git a/Sources/Datadog/RUM/DataModels/RUMDataModels.swift b/Sources/Datadog/RUM/DataModels/RUMDataModels.swift index e49f02bd5a..b9d344089e 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? @@ -46,6 +49,7 @@ 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" @@ -59,6 +63,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 +76,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 +109,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 +140,15 @@ public struct RUMViewEvent: RUMDataModel { public enum SessionType: String, Codable { case user = "user" case synthetics = "synthetics" + case ciTest = "ci_test" } } /// 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 +156,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 +394,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? @@ -405,6 +431,7 @@ 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" @@ -419,6 +446,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 +462,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 +506,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 +734,15 @@ public struct RUMResourceEvent: RUMDataModel { public enum SessionType: String, Codable { case user = "user" case synthetics = "synthetics" + case ciTest = "ci_test" } } /// 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 +750,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 +790,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? @@ -775,6 +824,7 @@ 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" @@ -788,6 +838,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 +848,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 +979,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 +1010,15 @@ public struct RUMActionEvent: RUMDataModel { public enum SessionType: String, Codable { case user = "user" case synthetics = "synthetics" + case ciTest = "ci_test" } } /// 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 +1026,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 +1070,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? @@ -1035,6 +1107,7 @@ 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" @@ -1049,6 +1122,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 +1132,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 +1174,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 +1310,7 @@ public struct RUMErrorEvent: RUMDataModel { case browser = "browser" case ios = "ios" case reactNative = "react-native" + case flutter = "flutter" } } @@ -1247,11 +1335,15 @@ public struct RUMErrorEvent: RUMDataModel { public enum SessionType: String, Codable { case user = "user" case synthetics = "synthetics" + case ciTest = "ci_test" } } /// 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 +1351,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 +1395,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? @@ -1336,6 +1432,7 @@ 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" @@ -1350,6 +1447,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 +1457,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 +1499,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 +1548,15 @@ public struct RUMLongTaskEvent: RUMDataModel { public enum SessionType: String, Codable { case user = "user" case synthetics = "synthetics" + case ciTest = "ci_test" } } /// 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 +1564,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 +1756,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/a7adc4275073e4d5bc146e9fdd4ceb4147379327 diff --git a/Sources/Datadog/RUM/RUMMonitor/Scopes/RUMResourceScope.swift b/Sources/Datadog/RUM/RUMMonitor/Scopes/RUMResourceScope.swift index 15926dbc6e..d48b6c4332 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, @@ -211,12 +213,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, diff --git a/Sources/Datadog/RUM/RUMMonitor/Scopes/RUMUserActionScope.swift b/Sources/Datadog/RUM/RUMMonitor/Scopes/RUMUserActionScope.swift index 3f8822eec4..78def6a3c1 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,6 +148,7 @@ 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, diff --git a/Sources/Datadog/RUM/RUMMonitor/Scopes/RUMViewScope.swift b/Sources/Datadog/RUM/RUMMonitor/Scopes/RUMViewScope.swift index 403478b6bc..fa07b13ab1 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,6 +319,7 @@ 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, @@ -356,10 +358,12 @@ 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, @@ -420,12 +424,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, @@ -468,9 +474,13 @@ 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, diff --git a/Sources/DatadogObjc/RUM/RUMDataModels+objc.swift b/Sources/DatadogObjc/RUM/RUMDataModels+objc.swift index bdbe834c8e..3a3ba6d83e 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 } @@ -73,6 +77,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 +140,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 +295,7 @@ public enum DDRUMViewEventSessionSessionType: Int { switch swift { case .user: self = .user case .synthetics: self = .synthetics + case .ciTest: self = .ciTest } } @@ -281,11 +303,13 @@ 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 @@ -296,6 +320,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 +656,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 } @@ -677,6 +709,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 +789,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 +1274,7 @@ public enum DDRUMResourceEventSessionSessionType: Int { switch swift { case .user: self = .user case .synthetics: self = .synthetics + case .ciTest: self = .ciTest } } @@ -1232,11 +1282,13 @@ 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 @@ -1247,6 +1299,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 +1386,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 } @@ -1375,6 +1435,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 +1636,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 +1791,7 @@ public enum DDRUMActionEventSessionSessionType: Int { switch swift { case .user: self = .user case .synthetics: self = .synthetics + case .ciTest: self = .ciTest } } @@ -1721,11 +1799,13 @@ 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 @@ -1736,6 +1816,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 +1907,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 } @@ -1872,6 +1960,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 +2032,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 +2416,7 @@ public enum DDRUMErrorEventErrorSourceType: Int { case .browser?: self = .browser case .ios?: self = .ios case .reactNative?: self = .reactNative + case .flutter?: self = .flutter } } @@ -2321,6 +2427,7 @@ public enum DDRUMErrorEventErrorSourceType: Int { case .browser: return .browser case .ios: return .ios case .reactNative: return .reactNative + case .flutter: return .flutter } } @@ -2329,6 +2436,7 @@ public enum DDRUMErrorEventErrorSourceType: Int { case browser case ios case reactNative + case flutter } @objc @@ -2358,6 +2466,7 @@ public enum DDRUMErrorEventSessionSessionType: Int { switch swift { case .user: self = .user case .synthetics: self = .synthetics + case .ciTest: self = .ciTest } } @@ -2365,11 +2474,13 @@ 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 @@ -2380,6 +2491,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 +2582,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 } @@ -2516,6 +2635,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 +2707,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 +2883,7 @@ public enum DDRUMLongTaskEventSessionSessionType: Int { switch swift { case .user: self = .user case .synthetics: self = .synthetics + case .ciTest: self = .ciTest } } @@ -2754,11 +2891,13 @@ 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 @@ -2769,6 +2908,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 +2976,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/a7adc4275073e4d5bc146e9fdd4ceb4147379327 diff --git a/Tests/DatadogTests/Datadog/Mocks/RUMDataModelMocks.swift b/Tests/DatadogTests/Datadog/Mocks/RUMDataModelMocks.swift index 2fbbe91e01..5bc931329a 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(), @@ -117,12 +119,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(), @@ -167,6 +171,7 @@ extension RUMActionEvent: RandomMockable { static func mockRandom() -> RUMActionEvent { return RUMActionEvent( dd: .init( + browserSdkVersion: nil, session: .init(plan: .plan1) ), action: .init( @@ -180,6 +185,7 @@ extension RUMActionEvent: RandomMockable { type: [.tap, .swipe, .scroll].randomElement()! ), application: .init(id: .mockRandom()), + ciTest: nil, connectivity: .mockRandom(), context: .mockRandom(), date: .mockRandom(), @@ -211,10 +217,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(), @@ -260,9 +268,13 @@ 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(), From 9411e486e69f1656f2b741d809f844cc6286808a Mon Sep 17 00:00:00 2001 From: Mert Buran Date: Thu, 13 Jan 2022 10:47:13 +0100 Subject: [PATCH 2/2] RUMM-1904 source added to RUMEvents.common_schema --- .../CrashReportingWithRUMIntegration.swift | 3 + .../RUM/DataModels/RUMDataModels.swift | 67 ++++++- .../RUMMonitor/Scopes/RUMResourceScope.swift | 2 + .../Scopes/RUMUserActionScope.swift | 1 + .../RUM/RUMMonitor/Scopes/RUMViewScope.swift | 4 + .../DatadogObjc/RUM/RUMDataModels+objc.swift | 182 +++++++++++++++++- .../Datadog/Mocks/RUMDataModelMocks.swift | 5 + .../Scopes/RUMResourceScopeTests.swift | 1 + .../Scopes/RUMUserActionScopeTests.swift | 1 + .../RUMMonitor/Scopes/RUMViewScopeTests.swift | 2 + 10 files changed, 266 insertions(+), 2 deletions(-) diff --git a/Sources/Datadog/FeaturesIntegration/CrashReporting/CrashReportingWithRUMIntegration.swift b/Sources/Datadog/FeaturesIntegration/CrashReporting/CrashReportingWithRUMIntegration.swift index 16449a8b2e..c34a3e3767 100644 --- a/Sources/Datadog/FeaturesIntegration/CrashReporting/CrashReportingWithRUMIntegration.swift +++ b/Sources/Datadog/FeaturesIntegration/CrashReporting/CrashReportingWithRUMIntegration.swift @@ -252,6 +252,7 @@ internal struct CrashReportingWithRUMIntegration: CrashReportingIntegration { id: lastRUMView.session.id, type: .user ), + source: .ios, synthetics: nil, usr: lastRUMView.usr, view: .init( @@ -284,6 +285,7 @@ internal struct CrashReportingWithRUMIntegration: CrashReportingIntegration { 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( @@ -357,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 b9d344089e..fba88de49a 100644 --- a/Sources/Datadog/RUM/DataModels/RUMDataModels.swift +++ b/Sources/Datadog/RUM/DataModels/RUMDataModels.swift @@ -34,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? @@ -55,6 +58,7 @@ public struct RUMViewEvent: RUMDataModel { case date = "date" case service = "service" case session = "session" + case source = "source" case synthetics = "synthetics" case type = "type" case usr = "usr" @@ -144,6 +148,15 @@ public struct RUMViewEvent: RUMDataModel { } } + /// 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 @@ -415,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? @@ -438,6 +454,7 @@ public struct RUMResourceEvent: RUMDataModel { case resource = "resource" case service = "service" case session = "session" + case source = "source" case synthetics = "synthetics" case type = "type" case usr = "usr" @@ -738,6 +755,15 @@ public struct RUMResourceEvent: RUMDataModel { } } + /// 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 @@ -808,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? @@ -830,6 +859,7 @@ public struct RUMActionEvent: RUMDataModel { case date = "date" case service = "service" case session = "session" + case source = "source" case synthetics = "synthetics" case type = "type" case usr = "usr" @@ -1014,6 +1044,15 @@ public struct RUMActionEvent: RUMDataModel { } } + /// 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 @@ -1091,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? @@ -1114,6 +1156,7 @@ public struct RUMErrorEvent: RUMDataModel { case error = "error" case service = "service" case session = "session" + case source = "source" case synthetics = "synthetics" case type = "type" case usr = "usr" @@ -1339,6 +1382,15 @@ public struct RUMErrorEvent: RUMDataModel { } } + /// 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 @@ -1416,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? @@ -1439,6 +1494,7 @@ public struct RUMLongTaskEvent: RUMDataModel { case longTask = "long_task" case service = "service" case session = "session" + case source = "source" case synthetics = "synthetics" case type = "type" case usr = "usr" @@ -1552,6 +1608,15 @@ public struct RUMLongTaskEvent: RUMDataModel { } } + /// 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 @@ -1756,4 +1821,4 @@ public enum RUMMethod: String, Codable { case patch = "PATCH" } -// Generated from https://github.com/DataDog/rum-events-format/tree/a7adc4275073e4d5bc146e9fdd4ceb4147379327 +// 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 d48b6c4332..e5748651a4 100644 --- a/Sources/Datadog/RUM/RUMMonitor/Scopes/RUMResourceScope.swift +++ b/Sources/Datadog/RUM/RUMMonitor/Scopes/RUMResourceScope.swift @@ -191,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( @@ -243,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 78def6a3c1..34c8a4e364 100644 --- a/Sources/Datadog/RUM/RUMMonitor/Scopes/RUMUserActionScope.swift +++ b/Sources/Datadog/RUM/RUMMonitor/Scopes/RUMUserActionScope.swift @@ -154,6 +154,7 @@ internal class RUMUserActionScope: RUMScope, RUMContextProvider { 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 fa07b13ab1..db97ebd8f7 100644 --- a/Sources/Datadog/RUM/RUMMonitor/Scopes/RUMViewScope.swift +++ b/Sources/Datadog/RUM/RUMMonitor/Scopes/RUMViewScope.swift @@ -325,6 +325,7 @@ internal class RUMViewScope: RUMScope, RUMContextProvider { 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( @@ -369,6 +370,7 @@ internal class RUMViewScope: RUMScope, RUMContextProvider { 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( @@ -449,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( @@ -487,6 +490,7 @@ internal class RUMViewScope: RUMScope, RUMContextProvider { 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 3a3ba6d83e..001b65d7db 100644 --- a/Sources/DatadogObjc/RUM/RUMDataModels+objc.swift +++ b/Sources/DatadogObjc/RUM/RUMDataModels+objc.swift @@ -52,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 } @@ -312,6 +316,38 @@ public enum DDRUMViewEventSessionSessionType: Int { 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 public class DDRUMViewEventSynthetics: NSObject { internal let root: DDRUMViewEvent @@ -684,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 } @@ -1291,6 +1331,38 @@ public enum DDRUMResourceEventSessionSessionType: Int { 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 public class DDRUMResourceEventSynthetics: NSObject { internal let root: DDRUMResourceEvent @@ -1410,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 } @@ -1808,6 +1884,38 @@ public enum DDRUMActionEventSessionSessionType: Int { 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 public class DDRUMActionEventSynthetics: NSObject { internal let root: DDRUMActionEvent @@ -1935,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 } @@ -2483,6 +2595,38 @@ public enum DDRUMErrorEventSessionSessionType: Int { 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 public class DDRUMErrorEventSynthetics: NSObject { internal let root: DDRUMErrorEvent @@ -2610,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 } @@ -2900,6 +3048,38 @@ public enum DDRUMLongTaskEventSessionSessionType: Int { 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 public class DDRUMLongTaskEventSynthetics: NSObject { internal let root: DDRUMLongTaskEvent @@ -2976,4 +3156,4 @@ public class DDRUMLongTaskEventView: NSObject { // swiftlint:enable force_unwrapping -// Generated from https://github.com/DataDog/rum-events-format/tree/a7adc4275073e4d5bc146e9fdd4ceb4147379327 +// 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 5bc931329a..134d1c5067 100644 --- a/Tests/DatadogTests/Datadog/Mocks/RUMDataModelMocks.swift +++ b/Tests/DatadogTests/Datadog/Mocks/RUMDataModelMocks.swift @@ -70,6 +70,7 @@ extension RUMViewEvent: RandomMockable { id: .mockRandom(), type: .user ), + source: .ios, synthetics: nil, usr: .mockRandom(), view: .init( @@ -156,6 +157,7 @@ extension RUMResourceEvent: RandomMockable { id: .mockRandom(), type: .user ), + source: .ios, synthetics: nil, usr: .mockRandom(), view: .init( @@ -195,6 +197,7 @@ extension RUMActionEvent: RandomMockable { id: .mockRandom(), type: .user ), + source: .ios, synthetics: nil, usr: .mockRandom(), view: .init( @@ -253,6 +256,7 @@ extension RUMErrorEvent: RandomMockable { id: .mockRandom(), type: .user ), + source: .ios, synthetics: nil, usr: .mockRandom(), view: .init( @@ -281,6 +285,7 @@ extension RUMLongTaskEvent: RandomMockable { 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)