From 4e85aeef9d4dd977943408867e98382203cfe9c1 Mon Sep 17 00:00:00 2001 From: Maciej Burda Date: Wed, 28 Jun 2023 17:13:19 +0100 Subject: [PATCH 1/4] Regenerate rum model --- .../RUM/DataModels/RUMDataModels.swift | 300 +++++++++++++++--- .../Integrations/CrashReportReceiver.swift | 9 +- .../RUM/RUMEvent/RUMOperatingSystemInfo.swift | 1 + .../RUM/RUMMonitor/Scopes/RUMViewScope.swift | 6 +- .../DatadogObjc/RUM/RUMDataModels+objc.swift | 262 +++++++++++++-- .../CodeDecoration/RUMCodeDecorator.swift | 1 - .../CodeGeneration/Generate/JSONSchema.swift | 26 ++ .../JSONSchemaToJSONTypeTransformer.swift | 10 +- ...JSONSchemaToJSONTypeTransformerTests.swift | 4 + 9 files changed, 534 insertions(+), 85 deletions(-) diff --git a/Sources/Datadog/RUM/DataModels/RUMDataModels.swift b/Sources/Datadog/RUM/DataModels/RUMDataModels.swift index db44f7b0ca..494dcff394 100644 --- a/Sources/Datadog/RUM/DataModels/RUMDataModels.swift +++ b/Sources/Datadog/RUM/DataModels/RUMDataModels.swift @@ -154,14 +154,14 @@ public struct RUMActionEvent: RUMDataModel { /// Session-related internal properties public struct Session: Codable { - /// Session plan: 1 is the plan without replay, 2 is the plan with replay - public let plan: Plan + /// Session plan: 1 is the plan without replay, 2 is the plan with replay (deprecated) + public let plan: Plan? enum CodingKeys: String, CodingKey { case plan = "plan" } - /// Session plan: 1 is the plan without replay, 2 is the plan with replay + /// Session plan: 1 is the plan without replay, 2 is the plan with replay (deprecated) public enum Plan: Int, Codable { case plan1 = 1 case plan2 = 2 @@ -300,6 +300,30 @@ public struct RUMActionEvent: RUMDataModel { } } + /// Display properties + public struct RUMDisplay: Codable { + /// The viewport represents the rectangular area that is currently being viewed. Content outside the viewport is not visible onscreen until scrolled into view. + public let viewport: Viewport? + + enum CodingKeys: String, CodingKey { + case viewport = "viewport" + } + + /// The viewport represents the rectangular area that is currently being viewed. Content outside the viewport is not visible onscreen until scrolled into view. + public struct Viewport: Codable { + /// Height of the viewport (in pixels) + public let height: Double + + /// Width of the viewport (in pixels) + public let width: Double + + enum CodingKeys: String, CodingKey { + case height = "height" + case width = "width" + } + } + } + /// Session properties public struct Session: Codable { /// Whether this session has a replay @@ -484,14 +508,14 @@ public struct RUMErrorEvent: RUMDataModel { /// Session-related internal properties public struct Session: Codable { - /// Session plan: 1 is the plan without replay, 2 is the plan with replay - public let plan: Plan + /// Session plan: 1 is the plan without replay, 2 is the plan with replay (deprecated) + public let plan: Plan? enum CodingKeys: String, CodingKey { case plan = "plan" } - /// Session plan: 1 is the plan without replay, 2 is the plan with replay + /// Session plan: 1 is the plan without replay, 2 is the plan with replay (deprecated) public enum Plan: Int, Codable { case plan1 = 1 case plan2 = 2 @@ -519,11 +543,38 @@ public struct RUMErrorEvent: RUMDataModel { } } + /// Display properties + public struct RUMDisplay: Codable { + /// The viewport represents the rectangular area that is currently being viewed. Content outside the viewport is not visible onscreen until scrolled into view. + public let viewport: Viewport? + + enum CodingKeys: String, CodingKey { + case viewport = "viewport" + } + + /// The viewport represents the rectangular area that is currently being viewed. Content outside the viewport is not visible onscreen until scrolled into view. + public struct Viewport: Codable { + /// Height of the viewport (in pixels) + public let height: Double + + /// Width of the viewport (in pixels) + public let width: Double + + enum CodingKeys: String, CodingKey { + case height = "height" + case width = "width" + } + } + } + /// Error properties public struct Error: Codable { /// Causes of the error public var causes: [Causes]? + /// Fingerprint used for Error Tracking custom grouping + public var fingerprint: String? + /// Whether the error has been handled manually in the source code or not public let handling: Handling? @@ -556,6 +607,7 @@ public struct RUMErrorEvent: RUMDataModel { enum CodingKeys: String, CodingKey { case causes = "causes" + case fingerprint = "fingerprint" case handling = "handling" case handlingStack = "handling_stack" case id = "id" @@ -902,14 +954,14 @@ public struct RUMLongTaskEvent: RUMDataModel { /// Session-related internal properties public struct Session: Codable { - /// Session plan: 1 is the plan without replay, 2 is the plan with replay - public let plan: Plan + /// Session plan: 1 is the plan without replay, 2 is the plan with replay (deprecated) + public let plan: Plan? enum CodingKeys: String, CodingKey { case plan = "plan" } - /// Session plan: 1 is the plan without replay, 2 is the plan with replay + /// Session plan: 1 is the plan without replay, 2 is the plan with replay (deprecated) public enum Plan: Int, Codable { case plan1 = 1 case plan2 = 2 @@ -937,6 +989,30 @@ public struct RUMLongTaskEvent: RUMDataModel { } } + /// Display properties + public struct RUMDisplay: Codable { + /// The viewport represents the rectangular area that is currently being viewed. Content outside the viewport is not visible onscreen until scrolled into view. + public let viewport: Viewport? + + enum CodingKeys: String, CodingKey { + case viewport = "viewport" + } + + /// The viewport represents the rectangular area that is currently being viewed. Content outside the viewport is not visible onscreen until scrolled into view. + public struct Viewport: Codable { + /// Height of the viewport (in pixels) + public let height: Double + + /// Width of the viewport (in pixels) + public let width: Double + + enum CodingKeys: String, CodingKey { + case height = "height" + case width = "width" + } + } + } + /// Long Task properties public struct LongTask: Codable { /// Duration in ns of the long task @@ -1147,14 +1223,14 @@ public struct RUMResourceEvent: RUMDataModel { /// Session-related internal properties public struct Session: Codable { - /// Session plan: 1 is the plan without replay, 2 is the plan with replay - public let plan: Plan + /// Session plan: 1 is the plan without replay, 2 is the plan with replay (deprecated) + public let plan: Plan? enum CodingKeys: String, CodingKey { case plan = "plan" } - /// Session plan: 1 is the plan without replay, 2 is the plan with replay + /// Session plan: 1 is the plan without replay, 2 is the plan with replay (deprecated) public enum Plan: Int, Codable { case plan1 = 1 case plan2 = 2 @@ -1182,6 +1258,30 @@ public struct RUMResourceEvent: RUMDataModel { } } + /// Display properties + public struct RUMDisplay: Codable { + /// The viewport represents the rectangular area that is currently being viewed. Content outside the viewport is not visible onscreen until scrolled into view. + public let viewport: Viewport? + + enum CodingKeys: String, CodingKey { + case viewport = "viewport" + } + + /// The viewport represents the rectangular area that is currently being viewed. Content outside the viewport is not visible onscreen until scrolled into view. + public struct Viewport: Codable { + /// Height of the viewport (in pixels) + public let height: Double + + /// Width of the viewport (in pixels) + public let width: Double + + enum CodingKeys: String, CodingKey { + case height = "height" + case width = "width" + } + } + } + /// Resource properties public struct Resource: Codable { /// Connect phase properties @@ -1194,7 +1294,7 @@ public struct RUMResourceEvent: RUMDataModel { public let download: Download? /// Duration of the resource - public let duration: Int64 + public let duration: Int64? /// First Byte phase properties public let firstByte: FirstByte? @@ -1487,6 +1587,9 @@ public struct RUMViewEvent: RUMDataModel { /// Operating system properties public let os: RUMOperatingSystem? + /// Privacy properties + public let privacy: Privacy? + /// The service name for this application public let service: String? @@ -1522,6 +1625,7 @@ public struct RUMViewEvent: RUMDataModel { case display = "display" case featureFlags = "feature_flags" case os = "os" + case privacy = "privacy" case service = "service" case session = "session" case source = "source" @@ -1543,6 +1647,12 @@ public struct RUMViewEvent: RUMDataModel { /// Version of the RUM event format public let formatVersion: Int64 = 2 + /// List of the page states during the view + public let pageStates: [PageStates]? + + /// Debug metadata for Replay Sessions + public let replayStats: ReplayStats? + /// Session-related internal properties public let session: Session? @@ -1550,19 +1660,62 @@ public struct RUMViewEvent: RUMDataModel { case browserSdkVersion = "browser_sdk_version" case documentVersion = "document_version" case formatVersion = "format_version" + case pageStates = "page_states" + case replayStats = "replay_stats" case session = "session" } + /// Properties of the page state + public struct PageStates: Codable { + /// Duration in ns between start of the view and start of the page state + public let start: Int64 + + /// Page state name + public let state: State + + enum CodingKeys: String, CodingKey { + case start = "start" + case state = "state" + } + + /// Page state name + public enum State: String, Codable { + case active = "active" + case passive = "passive" + case hidden = "hidden" + case frozen = "frozen" + case terminated = "terminated" + } + } + + /// Debug metadata for Replay Sessions + public struct ReplayStats: Codable { + /// The number of records produced during this view lifetime + public let recordsCount: Int64? + + /// The number of segments sent during this view lifetime + public let segmentsCount: Int64? + + /// The total size in bytes of the segments sent during this view lifetime + public let segmentsTotalRawSize: Int64? + + enum CodingKeys: String, CodingKey { + case recordsCount = "records_count" + case segmentsCount = "segments_count" + case segmentsTotalRawSize = "segments_total_raw_size" + } + } + /// Session-related internal properties public struct Session: Codable { - /// Session plan: 1 is the plan without replay, 2 is the plan with replay - public let plan: Plan + /// Session plan: 1 is the plan without replay, 2 is the plan with replay (deprecated) + public let plan: Plan? enum CodingKeys: String, CodingKey { case plan = "plan" } - /// Session plan: 1 is the plan without replay, 2 is the plan with replay + /// Session plan: 1 is the plan without replay, 2 is the plan with replay (deprecated) public enum Plan: Int, Codable { case plan1 = 1 case plan2 = 2 @@ -1580,11 +1733,78 @@ public struct RUMViewEvent: RUMDataModel { } } + /// Display properties + public struct RUMDisplay: Codable { + /// Scroll properties + public let scroll: Scroll? + + /// The viewport represents the rectangular area that is currently being viewed. Content outside the viewport is not visible onscreen until scrolled into view. + public let viewport: Viewport? + + enum CodingKeys: String, CodingKey { + case scroll = "scroll" + case viewport = "viewport" + } + + /// Scroll properties + public struct Scroll: Codable { + /// Distance between the top and the lowest point reached on this view (in pixels) + public let maxDepth: Double + + /// Page scroll height (total height) when the maximum scroll depth was reached for this view (in pixels) + public let maxDepthScrollHeight: Double + + /// Page scroll top (scrolled distance) when the maximum scroll depth was reached for this view (in pixels) + public let maxDepthScrollTop: Double + + /// Duration between the view start and the scroll event that reached the maximum scroll depth for this view (in nanoseconds) + public let maxDepthTime: Double + + enum CodingKeys: String, CodingKey { + case maxDepth = "max_depth" + case maxDepthScrollHeight = "max_depth_scroll_height" + case maxDepthScrollTop = "max_depth_scroll_top" + case maxDepthTime = "max_depth_time" + } + } + + /// The viewport represents the rectangular area that is currently being viewed. Content outside the viewport is not visible onscreen until scrolled into view. + public struct Viewport: Codable { + /// Height of the viewport (in pixels) + public let height: Double + + /// Width of the viewport (in pixels) + public let width: Double + + enum CodingKeys: String, CodingKey { + case height = "height" + case width = "width" + } + } + } + /// Feature flags properties public struct FeatureFlags: Codable { public internal(set) var featureFlagsInfo: [String: Encodable] } + /// Privacy properties + public struct Privacy: Codable { + /// The replay privacy level + public let replayLevel: ReplayLevel + + enum CodingKeys: String, CodingKey { + case replayLevel = "replay_level" + } + + /// The replay privacy level + public enum ReplayLevel: String, Codable { + case allow = "allow" + case mask = "mask" + case maskUserInput = "mask-user-input" + } + } + /// Session properties public struct Session: Codable { /// Whether this session has a replay @@ -1596,8 +1816,11 @@ public struct RUMViewEvent: RUMDataModel { /// Whether this session is currently active. Set to false to manually stop a session public let isActive: Bool? + /// Whether this session has been sampled for replay + public let sampledForReplay: Bool? + /// The precondition that led to the creation of the session - public let startReason: StartReason? + public let startPrecondition: StartPrecondition? /// Type of the session public let type: SessionType @@ -1606,16 +1829,17 @@ public struct RUMViewEvent: RUMDataModel { case hasReplay = "has_replay" case id = "id" case isActive = "is_active" - case startReason = "start_reason" + case sampledForReplay = "sampled_for_replay" + case startPrecondition = "start_precondition" case type = "type" } /// The precondition that led to the creation of the session - public enum StartReason: String, Codable { - case appStart = "app_start" + public enum StartPrecondition: String, Codable { + case appLaunch = "app_launch" case inactivityTimeout = "inactivity_timeout" case maxDuration = "max_duration" - case stopApi = "stop_api" + case explicitStop = "explicit_stop" case backgroundEvent = "background_event" } @@ -2447,6 +2671,9 @@ public struct TelemetryConfigurationEvent: RUMDataModel { /// Whether initialization fails silently if the SDK is already initialized public let silentMultipleInit: Bool? + /// Whether the session replay start is handled manually + public var startSessionReplayRecordingManually: Bool? + /// The percentage of telemetry configuration events sent after being sampled by telemetry_sample_rate public let telemetryConfigurationSampleRate: Int64? @@ -2553,6 +2780,7 @@ public struct TelemetryConfigurationEvent: RUMDataModel { case sessionReplaySampleRate = "session_replay_sample_rate" case sessionSampleRate = "session_sample_rate" case silentMultipleInit = "silent_multiple_init" + case startSessionReplayRecordingManually = "start_session_replay_recording_manually" case telemetryConfigurationSampleRate = "telemetry_configuration_sample_rate" case telemetrySampleRate = "telemetry_sample_rate" case traceSampleRate = "trace_sample_rate" @@ -2823,32 +3051,11 @@ public struct RUMDevice: Codable { } } -/// Display properties -public struct RUMDisplay: Codable { - /// The viewport represents the rectangular area that is currently being viewed. Content outside the viewport is not visible onscreen until scrolled into view. - public let viewport: Viewport? - - enum CodingKeys: String, CodingKey { - case viewport = "viewport" - } - - /// The viewport represents the rectangular area that is currently being viewed. Content outside the viewport is not visible onscreen until scrolled into view. - public struct Viewport: Codable { - /// Height of the viewport (in pixels) - public let height: Double - - /// Width of the viewport (in pixels) - public let width: Double - - enum CodingKeys: String, CodingKey { - case height = "height" - case width = "width" - } - } -} - /// Operating system properties public struct RUMOperatingSystem: Codable { + /// Operating system build number, e.g. 15D21 + public let build: String? + /// Operating system name, e.g. Android, iOS public let name: String @@ -2859,6 +3066,7 @@ public struct RUMOperatingSystem: Codable { public let versionMajor: String enum CodingKeys: String, CodingKey { + case build = "build" case name = "name" case version = "version" case versionMajor = "version_major" @@ -2974,4 +3182,4 @@ public enum RUMMethod: String, Codable { case patch = "PATCH" } -// Generated from https://github.com/DataDog/rum-events-format/tree/a45fbc913eb36f3bf0cc37aa1bdbee126104972b +// Generated from https://github.com/DataDog/rum-events-format/tree/dcb6897cf883fb8938e7aa0f69ed9a035df98c2c diff --git a/Sources/Datadog/RUM/Integrations/CrashReportReceiver.swift b/Sources/Datadog/RUM/Integrations/CrashReportReceiver.swift index 2272569653..1907baf083 100644 --- a/Sources/Datadog/RUM/Integrations/CrashReportReceiver.swift +++ b/Sources/Datadog/RUM/Integrations/CrashReportReceiver.swift @@ -373,6 +373,8 @@ internal struct CrashReportReceiver: FeatureMessageReceiver { dd: .init( browserSdkVersion: nil, documentVersion: original.dd.documentVersion + 1, + pageStates: nil, + replayStats: nil, session: .init(plan: .plan1) ), application: original.application, @@ -383,6 +385,7 @@ internal struct CrashReportReceiver: FeatureMessageReceiver { device: original.device, display: nil, os: original.os, + privacy: nil, service: original.service, session: original.session, source: original.source ?? .ios, @@ -446,6 +449,8 @@ internal struct CrashReportReceiver: FeatureMessageReceiver { dd: .init( browserSdkVersion: nil, documentVersion: 1, + pageStates: nil, + replayStats: nil, session: .init(plan: .plan1) ), application: .init( @@ -465,12 +470,14 @@ internal struct CrashReportReceiver: FeatureMessageReceiver { // before restarting the app after crash. To solve this, the OS information would have to be // persisted in `crashContext` the same way as we do for other dynamic information. os: .init(device: context.device), + privacy: nil, service: context.service, session: .init( hasReplay: hasReplay, id: sessionUUID.toRUMDataFormat, isActive: true, - startReason: nil, + sampledForReplay: nil, + startPrecondition: nil, type: CITestIntegration.active != nil ? .ciTest : .user ), source: .init(rawValue: context.source) ?? .ios, diff --git a/Sources/Datadog/RUM/RUMEvent/RUMOperatingSystemInfo.swift b/Sources/Datadog/RUM/RUMEvent/RUMOperatingSystemInfo.swift index 59bed57c28..0d9503f8de 100644 --- a/Sources/Datadog/RUM/RUMEvent/RUMOperatingSystemInfo.swift +++ b/Sources/Datadog/RUM/RUMEvent/RUMOperatingSystemInfo.swift @@ -15,5 +15,6 @@ extension RUMOperatingSystem { self.name = device.osName self.version = device.osVersion self.versionMajor = device.osVersion.split(separator: ".").first.map { String($0) } ?? device.osVersion + self.build = nil } } diff --git a/Sources/Datadog/RUM/RUMMonitor/Scopes/RUMViewScope.swift b/Sources/Datadog/RUM/RUMMonitor/Scopes/RUMViewScope.swift index 864cde834b..0326b40d6f 100644 --- a/Sources/Datadog/RUM/RUMMonitor/Scopes/RUMViewScope.swift +++ b/Sources/Datadog/RUM/RUMMonitor/Scopes/RUMViewScope.swift @@ -441,6 +441,8 @@ internal class RUMViewScope: RUMScope, RUMContextProvider { dd: .init( browserSdkVersion: nil, documentVersion: version.toInt64, + pageStates: nil, + replayStats: nil, session: .init(plan: .plan1) ), application: .init(id: self.context.rumApplicationID), @@ -452,12 +454,14 @@ internal class RUMViewScope: RUMScope, RUMContextProvider { display: nil, featureFlags: .init(featureFlagsInfo: featureFlags), os: .init(context: context), + privacy: nil, service: context.service, session: .init( hasReplay: context.srBaggage?.isReplayBeingRecorded, id: self.context.sessionID.toRUMDataFormat, isActive: self.context.isSessionActive, - startReason: nil, + sampledForReplay: nil, + startPrecondition: nil, type: dependencies.ciTest != nil ? .ciTest : .user ), source: .init(rawValue: context.source) ?? .ios, diff --git a/Sources/DatadogObjc/RUM/RUMDataModels+objc.swift b/Sources/DatadogObjc/RUM/RUMDataModels+objc.swift index 1b41e5bee6..045afe08cf 100644 --- a/Sources/DatadogObjc/RUM/RUMDataModels+objc.swift +++ b/Sources/DatadogObjc/RUM/RUMDataModels+objc.swift @@ -188,20 +188,23 @@ public class DDRUMActionEventDDSession: NSObject { @objc public enum DDRUMActionEventDDSessionPlan: Int { - internal init(swift: RUMActionEvent.DD.Session.Plan) { + internal init(swift: RUMActionEvent.DD.Session.Plan?) { switch swift { - case .plan1: self = .plan1 - case .plan2: self = .plan2 + case nil: self = .none + case .plan1?: self = .plan1 + case .plan2?: self = .plan2 } } - internal var toSwift: RUMActionEvent.DD.Session.Plan { + internal var toSwift: RUMActionEvent.DD.Session.Plan? { switch self { + case .none: return nil case .plan1: return .plan1 case .plan2: return .plan2 } } + case none case plan1 case plan2 } @@ -637,6 +640,10 @@ public class DDRUMActionEventRUMOperatingSystem: NSObject { self.root = root } + @objc public var build: String? { + root.swiftModel.os!.build + } + @objc public var name: String { root.swiftModel.os!.name } @@ -933,20 +940,23 @@ public class DDRUMErrorEventDDSession: NSObject { @objc public enum DDRUMErrorEventDDSessionPlan: Int { - internal init(swift: RUMErrorEvent.DD.Session.Plan) { + internal init(swift: RUMErrorEvent.DD.Session.Plan?) { switch swift { - case .plan1: self = .plan1 - case .plan2: self = .plan2 + case nil: self = .none + case .plan1?: self = .plan1 + case .plan2?: self = .plan2 } } - internal var toSwift: RUMErrorEvent.DD.Session.Plan { + internal var toSwift: RUMErrorEvent.DD.Session.Plan? { switch self { + case .none: return nil case .plan1: return .plan1 case .plan2: return .plan2 } } + case none case plan1 case plan2 } @@ -1235,6 +1245,11 @@ public class DDRUMErrorEventError: NSObject { get { root.swiftModel.error.causes?.map { DDRUMErrorEventErrorCauses(swiftModel: $0) } } } + @objc public var fingerprint: String? { + set { root.swiftModel.error.fingerprint = newValue } + get { root.swiftModel.error.fingerprint } + } + @objc public var handling: DDRUMErrorEventErrorHandling { .init(swift: root.swiftModel.error.handling) } @@ -1599,6 +1614,10 @@ public class DDRUMErrorEventRUMOperatingSystem: NSObject { self.root = root } + @objc public var build: String? { + root.swiftModel.os!.build + } + @objc public var name: String { root.swiftModel.os!.name } @@ -1895,20 +1914,23 @@ public class DDRUMLongTaskEventDDSession: NSObject { @objc public enum DDRUMLongTaskEventDDSessionPlan: Int { - internal init(swift: RUMLongTaskEvent.DD.Session.Plan) { + internal init(swift: RUMLongTaskEvent.DD.Session.Plan?) { switch swift { - case .plan1: self = .plan1 - case .plan2: self = .plan2 + case nil: self = .none + case .plan1?: self = .plan1 + case .plan2?: self = .plan2 } } - internal var toSwift: RUMLongTaskEvent.DD.Session.Plan { + internal var toSwift: RUMLongTaskEvent.DD.Session.Plan? { switch self { + case .none: return nil case .plan1: return .plan1 case .plan2: return .plan2 } } + case none case plan1 case plan2 } @@ -2213,6 +2235,10 @@ public class DDRUMLongTaskEventRUMOperatingSystem: NSObject { self.root = root } + @objc public var build: String? { + root.swiftModel.os!.build + } + @objc public var name: String { root.swiftModel.os!.name } @@ -2517,20 +2543,23 @@ public class DDRUMResourceEventDDSession: NSObject { @objc public enum DDRUMResourceEventDDSessionPlan: Int { - internal init(swift: RUMResourceEvent.DD.Session.Plan) { + internal init(swift: RUMResourceEvent.DD.Session.Plan?) { switch swift { - case .plan1: self = .plan1 - case .plan2: self = .plan2 + case nil: self = .none + case .plan1?: self = .plan1 + case .plan2?: self = .plan2 } } - internal var toSwift: RUMResourceEvent.DD.Session.Plan { + internal var toSwift: RUMResourceEvent.DD.Session.Plan? { switch self { + case .none: return nil case .plan1: return .plan1 case .plan2: return .plan2 } } + case none case plan1 case plan2 } @@ -2814,6 +2843,10 @@ public class DDRUMResourceEventRUMOperatingSystem: NSObject { self.root = root } + @objc public var build: String? { + root.swiftModel.os!.build + } + @objc public var name: String { root.swiftModel.os!.name } @@ -2847,8 +2880,8 @@ public class DDRUMResourceEventResource: NSObject { root.swiftModel.resource.download != nil ? DDRUMResourceEventResourceDownload(root: root) : nil } - @objc public var duration: NSNumber { - root.swiftModel.resource.duration as NSNumber + @objc public var duration: NSNumber? { + root.swiftModel.resource.duration as NSNumber? } @objc public var firstByte: DDRUMResourceEventResourceFirstByte? { @@ -3359,6 +3392,10 @@ public class DDRUMViewEvent: NSObject { root.swiftModel.os != nil ? DDRUMViewEventRUMOperatingSystem(root: root) : nil } + @objc public var privacy: DDRUMViewEventPrivacy? { + root.swiftModel.privacy != nil ? DDRUMViewEventPrivacy(root: root) : nil + } + @objc public var service: String? { root.swiftModel.service } @@ -3412,11 +3449,87 @@ public class DDRUMViewEventDD: NSObject { root.swiftModel.dd.formatVersion as NSNumber } + @objc public var pageStates: [DDRUMViewEventDDPageStates]? { + root.swiftModel.dd.pageStates?.map { DDRUMViewEventDDPageStates(swiftModel: $0) } + } + + @objc public var replayStats: DDRUMViewEventDDReplayStats? { + root.swiftModel.dd.replayStats != nil ? DDRUMViewEventDDReplayStats(root: root) : nil + } + @objc public var session: DDRUMViewEventDDSession? { root.swiftModel.dd.session != nil ? DDRUMViewEventDDSession(root: root) : nil } } +@objc +public class DDRUMViewEventDDPageStates: NSObject { + internal var swiftModel: RUMViewEvent.DD.PageStates + internal var root: DDRUMViewEventDDPageStates { self } + + internal init(swiftModel: RUMViewEvent.DD.PageStates) { + self.swiftModel = swiftModel + } + + @objc public var start: NSNumber { + root.swiftModel.start as NSNumber + } + + @objc public var state: DDRUMViewEventDDPageStatesState { + .init(swift: root.swiftModel.state) + } +} + +@objc +public enum DDRUMViewEventDDPageStatesState: Int { + internal init(swift: RUMViewEvent.DD.PageStates.State) { + switch swift { + case .active: self = .active + case .passive: self = .passive + case .hidden: self = .hidden + case .frozen: self = .frozen + case .terminated: self = .terminated + } + } + + internal var toSwift: RUMViewEvent.DD.PageStates.State { + switch self { + case .active: return .active + case .passive: return .passive + case .hidden: return .hidden + case .frozen: return .frozen + case .terminated: return .terminated + } + } + + case active + case passive + case hidden + case frozen + case terminated +} + +@objc +public class DDRUMViewEventDDReplayStats: NSObject { + internal let root: DDRUMViewEvent + + internal init(root: DDRUMViewEvent) { + self.root = root + } + + @objc public var recordsCount: NSNumber? { + root.swiftModel.dd.replayStats!.recordsCount as NSNumber? + } + + @objc public var segmentsCount: NSNumber? { + root.swiftModel.dd.replayStats!.segmentsCount as NSNumber? + } + + @objc public var segmentsTotalRawSize: NSNumber? { + root.swiftModel.dd.replayStats!.segmentsTotalRawSize as NSNumber? + } +} + @objc public class DDRUMViewEventDDSession: NSObject { internal let root: DDRUMViewEvent @@ -3432,20 +3545,23 @@ public class DDRUMViewEventDDSession: NSObject { @objc public enum DDRUMViewEventDDSessionPlan: Int { - internal init(swift: RUMViewEvent.DD.Session.Plan) { + internal init(swift: RUMViewEvent.DD.Session.Plan?) { switch swift { - case .plan1: self = .plan1 - case .plan2: self = .plan2 + case nil: self = .none + case .plan1?: self = .plan1 + case .plan2?: self = .plan2 } } - internal var toSwift: RUMViewEvent.DD.Session.Plan { + internal var toSwift: RUMViewEvent.DD.Session.Plan? { switch self { + case .none: return nil case .plan1: return .plan1 case .plan2: return .plan2 } } + case none case plan1 case plan2 } @@ -3663,11 +3779,40 @@ public class DDRUMViewEventRUMDisplay: NSObject { self.root = root } + @objc public var scroll: DDRUMViewEventRUMDisplayScroll? { + root.swiftModel.display!.scroll != nil ? DDRUMViewEventRUMDisplayScroll(root: root) : nil + } + @objc public var viewport: DDRUMViewEventRUMDisplayViewport? { root.swiftModel.display!.viewport != nil ? DDRUMViewEventRUMDisplayViewport(root: root) : nil } } +@objc +public class DDRUMViewEventRUMDisplayScroll: NSObject { + internal let root: DDRUMViewEvent + + internal init(root: DDRUMViewEvent) { + self.root = root + } + + @objc public var maxDepth: NSNumber { + root.swiftModel.display!.scroll!.maxDepth as NSNumber + } + + @objc public var maxDepthScrollHeight: NSNumber { + root.swiftModel.display!.scroll!.maxDepthScrollHeight as NSNumber + } + + @objc public var maxDepthScrollTop: NSNumber { + root.swiftModel.display!.scroll!.maxDepthScrollTop as NSNumber + } + + @objc public var maxDepthTime: NSNumber { + root.swiftModel.display!.scroll!.maxDepthTime as NSNumber + } +} + @objc public class DDRUMViewEventRUMDisplayViewport: NSObject { internal let root: DDRUMViewEvent @@ -3706,6 +3851,10 @@ public class DDRUMViewEventRUMOperatingSystem: NSObject { self.root = root } + @objc public var build: String? { + root.swiftModel.os!.build + } + @objc public var name: String { root.swiftModel.os!.name } @@ -3719,6 +3868,42 @@ public class DDRUMViewEventRUMOperatingSystem: NSObject { } } +@objc +public class DDRUMViewEventPrivacy: NSObject { + internal let root: DDRUMViewEvent + + internal init(root: DDRUMViewEvent) { + self.root = root + } + + @objc public var replayLevel: DDRUMViewEventPrivacyReplayLevel { + .init(swift: root.swiftModel.privacy!.replayLevel) + } +} + +@objc +public enum DDRUMViewEventPrivacyReplayLevel: Int { + internal init(swift: RUMViewEvent.Privacy.ReplayLevel) { + switch swift { + case .allow: self = .allow + case .mask: self = .mask + case .maskUserInput: self = .maskUserInput + } + } + + internal var toSwift: RUMViewEvent.Privacy.ReplayLevel { + switch self { + case .allow: return .allow + case .mask: return .mask + case .maskUserInput: return .maskUserInput + } + } + + case allow + case mask + case maskUserInput +} + @objc public class DDRUMViewEventSession: NSObject { internal let root: DDRUMViewEvent @@ -3739,8 +3924,12 @@ public class DDRUMViewEventSession: NSObject { root.swiftModel.session.isActive as NSNumber? } - @objc public var startReason: DDRUMViewEventSessionStartReason { - .init(swift: root.swiftModel.session.startReason) + @objc public var sampledForReplay: NSNumber? { + root.swiftModel.session.sampledForReplay as NSNumber? + } + + @objc public var startPrecondition: DDRUMViewEventSessionStartPrecondition { + .init(swift: root.swiftModel.session.startPrecondition) } @objc public var type: DDRUMViewEventSessionSessionType { @@ -3749,34 +3938,34 @@ public class DDRUMViewEventSession: NSObject { } @objc -public enum DDRUMViewEventSessionStartReason: Int { - internal init(swift: RUMViewEvent.Session.StartReason?) { +public enum DDRUMViewEventSessionStartPrecondition: Int { + internal init(swift: RUMViewEvent.Session.StartPrecondition?) { switch swift { case nil: self = .none - case .appStart?: self = .appStart + case .appLaunch?: self = .appLaunch case .inactivityTimeout?: self = .inactivityTimeout case .maxDuration?: self = .maxDuration - case .stopApi?: self = .stopApi + case .explicitStop?: self = .explicitStop case .backgroundEvent?: self = .backgroundEvent } } - internal var toSwift: RUMViewEvent.Session.StartReason? { + internal var toSwift: RUMViewEvent.Session.StartPrecondition? { switch self { case .none: return nil - case .appStart: return .appStart + case .appLaunch: return .appLaunch case .inactivityTimeout: return .inactivityTimeout case .maxDuration: return .maxDuration - case .stopApi: return .stopApi + case .explicitStop: return .explicitStop case .backgroundEvent: return .backgroundEvent } } case none - case appStart + case appLaunch case inactivityTimeout case maxDuration - case stopApi + case explicitStop case backgroundEvent } @@ -4879,6 +5068,11 @@ public class DDTelemetryConfigurationEventTelemetryConfiguration: NSObject { root.swiftModel.telemetry.configuration.silentMultipleInit as NSNumber? } + @objc public var startSessionReplayRecordingManually: NSNumber? { + set { root.swiftModel.telemetry.configuration.startSessionReplayRecordingManually = newValue?.boolValue } + get { root.swiftModel.telemetry.configuration.startSessionReplayRecordingManually as NSNumber? } + } + @objc public var telemetryConfigurationSampleRate: NSNumber? { root.swiftModel.telemetry.configuration.telemetryConfigurationSampleRate as NSNumber? } @@ -5131,4 +5325,4 @@ public class DDTelemetryConfigurationEventView: NSObject { // swiftlint:enable force_unwrapping -// Generated from https://github.com/DataDog/rum-events-format/tree/a45fbc913eb36f3bf0cc37aa1bdbee126104972b +// Generated from https://github.com/DataDog/rum-events-format/tree/dcb6897cf883fb8938e7aa0f69ed9a035df98c2c diff --git a/tools/rum-models-generator/Sources/CodeDecoration/RUMCodeDecorator.swift b/tools/rum-models-generator/Sources/CodeDecoration/RUMCodeDecorator.swift index 381610826b..43f13ac021 100644 --- a/tools/rum-models-generator/Sources/CodeDecoration/RUMCodeDecorator.swift +++ b/tools/rum-models-generator/Sources/CodeDecoration/RUMCodeDecorator.swift @@ -22,7 +22,6 @@ public class RUMCodeDecorator: SwiftCodeDecorator { "RUMCITest", "RUMDevice", "RUMOperatingSystem", - "RUMDisplay", "RUMActionID", ] ) diff --git a/tools/rum-models-generator/Sources/CodeGeneration/Generate/JSONSchema.swift b/tools/rum-models-generator/Sources/CodeGeneration/Generate/JSONSchema.swift index e589d9848c..efddd5b759 100644 --- a/tools/rum-models-generator/Sources/CodeGeneration/Generate/JSONSchema.swift +++ b/tools/rum-models-generator/Sources/CodeGeneration/Generate/JSONSchema.swift @@ -288,3 +288,29 @@ internal class JSONSchema: Decodable { } } } + +extension Array where Element == JSONSchema.EnumValue { + func inferrSchemaType() -> JSONSchema.SchemaType? { + let hasOnlyStrings = allSatisfy { element in + if case .string = element { + return true + } + return false + } + if hasOnlyStrings { + return .string + } + + let hasOnlyIntegers = allSatisfy { element in + if case .integer = element { + return true + } + return false + } + if hasOnlyIntegers { + return .number + } + + return nil + } +} diff --git a/tools/rum-models-generator/Sources/CodeGeneration/Generate/Transformers/JSON/JSONSchemaToJSONTypeTransformer.swift b/tools/rum-models-generator/Sources/CodeGeneration/Generate/Transformers/JSON/JSONSchemaToJSONTypeTransformer.swift index e03be2f3f5..e248acfd82 100644 --- a/tools/rum-models-generator/Sources/CodeGeneration/Generate/Transformers/JSON/JSONSchemaToJSONTypeTransformer.swift +++ b/tools/rum-models-generator/Sources/CodeGeneration/Generate/Transformers/JSON/JSONSchemaToJSONTypeTransformer.swift @@ -35,8 +35,14 @@ internal class JSONSchemaToJSONTypeTransformer { return try transformSchemaToObject(schema, named: name) } - let schemaType = try schema.type - .unwrapOrThrow(.inconsistency("`JSONSchema` must define `type`: \(schema).")) + let schemaType: JSONSchema.SchemaType + if let enumarations = schema.enum, schema.type == nil { + schemaType = try enumarations.inferrSchemaType() + .unwrapOrThrow(.inconsistency("Heteregenous enum is not supported: \(enumarations).")) + } else { + schemaType = try schema.type + .unwrapOrThrow(.inconsistency("`JSONSchema` must define `type`: \(schema).")) + } switch schemaType { case .object: diff --git a/tools/rum-models-generator/Tests/CodeGenerationTests/Generate/Transformers/JSONSchemaToJSONTypeTransformerTests.swift b/tools/rum-models-generator/Tests/CodeGenerationTests/Generate/Transformers/JSONSchemaToJSONTypeTransformerTests.swift index 96e2b9825f..80a38f3ac6 100644 --- a/tools/rum-models-generator/Tests/CodeGenerationTests/Generate/Transformers/JSONSchemaToJSONTypeTransformerTests.swift +++ b/tools/rum-models-generator/Tests/CodeGenerationTests/Generate/Transformers/JSONSchemaToJSONTypeTransformerTests.swift @@ -215,4 +215,8 @@ final class JSONSchemaToJSONTypeTransformerTests: XCTestCase { let actual = try JSONSchemaToJSONTypeTransformer().transform(jsonSchema: jsonSchema) XCTAssertEqual(expected, actual as? JSONUnionType) } + + func test_enumTypeInferring() { + + } } From fabc19d78df3e89aca399f3942554b642708439e Mon Sep 17 00:00:00 2001 From: Maciej Burda Date: Thu, 29 Jun 2023 12:57:51 +0100 Subject: [PATCH 2/4] Add test --- .../fixture-schema-with-typeless-enum.json | 16 +++++++ ...JSONSchemaToJSONTypeTransformerTests.swift | 42 ++++++++++++++++++- 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 tools/rum-models-generator/Tests/CodeGenerationTests/Fixtures/fixture-schema-with-typeless-enum.json diff --git a/tools/rum-models-generator/Tests/CodeGenerationTests/Fixtures/fixture-schema-with-typeless-enum.json b/tools/rum-models-generator/Tests/CodeGenerationTests/Fixtures/fixture-schema-with-typeless-enum.json new file mode 100644 index 0000000000..0413fa6a7a --- /dev/null +++ b/tools/rum-models-generator/Tests/CodeGenerationTests/Fixtures/fixture-schema-with-typeless-enum.json @@ -0,0 +1,16 @@ +{ + "$id": "Schema ID", + "type": "object", + "title": "Schema title", + "description": "Schema description.", + "properties": { + "stringEnumProperty": { + "description": "Description of `stringEnumProperty` without explicit type.", + "enum": ["case1", "case2", "case3", "case4"] + }, + "integerEnumProperty": { + "description": "Description of `integerEnumProperty` without explicit type.", + "enum": [1, 2, 3, 4] + } + } +} diff --git a/tools/rum-models-generator/Tests/CodeGenerationTests/Generate/Transformers/JSONSchemaToJSONTypeTransformerTests.swift b/tools/rum-models-generator/Tests/CodeGenerationTests/Generate/Transformers/JSONSchemaToJSONTypeTransformerTests.swift index 80a38f3ac6..8c3028cce1 100644 --- a/tools/rum-models-generator/Tests/CodeGenerationTests/Generate/Transformers/JSONSchemaToJSONTypeTransformerTests.swift +++ b/tools/rum-models-generator/Tests/CodeGenerationTests/Generate/Transformers/JSONSchemaToJSONTypeTransformerTests.swift @@ -216,7 +216,45 @@ final class JSONSchemaToJSONTypeTransformerTests: XCTestCase { XCTAssertEqual(expected, actual as? JSONUnionType) } - func test_enumTypeInferring() { - + func testTransformingJSONSchemaWithNoExplicitEnumTypeIntoJSONObject() throws { + let expected = JSONObject( + name: "Schema title", + comment: "Schema description.", + properties: [ + JSONObject.Property( + name: "stringEnumProperty", + comment: "Description of `stringEnumProperty` without explicit type.", + type: JSONEnumeration( + name: "stringEnumProperty", + comment: "Description of `stringEnumProperty` without explicit type.", + values: [.string(value: "case1"), .string(value: "case2"), .string(value: "case3"), .string(value: "case4")] + ), + defaultValue: nil, + isRequired: false, + isReadOnly: true + ), + JSONObject.Property( + name: "integerEnumProperty", + comment: "Description of `integerEnumProperty` without explicit type.", + type: JSONEnumeration( + name: "integerEnumProperty", + comment: "Description of `integerEnumProperty` without explicit type.", + values: [.integer(value: 1), .integer(value: 2), .integer(value: 3), .integer(value: 4)] + ), + defaultValue: nil, + isRequired: false, + isReadOnly: true + ) + ] + ) + + let file = Bundle.module.url(forResource: "Fixtures/fixture-schema-with-typeless-enum", withExtension: "json")! + + let jsonSchema = try JSONSchemaReader().read(file) + + let actual = try JSONSchemaToJSONTypeTransformer().transform(jsonSchema: jsonSchema) + XCTAssertEqual(expected, actual as? JSONObject) } } + + From 7120dc84e74d913d1a91830a8fc869cadd2302ff Mon Sep 17 00:00:00 2001 From: Maciej Burda Date: Thu, 29 Jun 2023 13:04:14 +0100 Subject: [PATCH 3/4] Update mock --- Tests/DatadogTests/Datadog/Mocks/RUMDataModelMocks.swift | 7 ++++++- .../JSONSchemaToJSONTypeTransformerTests.swift | 2 -- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Tests/DatadogTests/Datadog/Mocks/RUMDataModelMocks.swift b/Tests/DatadogTests/Datadog/Mocks/RUMDataModelMocks.swift index 3a7ffc3136..08be91cc36 100644 --- a/Tests/DatadogTests/Datadog/Mocks/RUMDataModelMocks.swift +++ b/Tests/DatadogTests/Datadog/Mocks/RUMDataModelMocks.swift @@ -85,6 +85,7 @@ extension RUMDevice.RUMDeviceType: RandomMockable { extension RUMOperatingSystem: RandomMockable { public static func mockRandom() -> RUMOperatingSystem { return .init( + build: nil, name: .mockRandom(length: 5), version: .mockRandom(among: .decimalDigits, length: 2), versionMajor: .mockRandom(among: .decimalDigits, length: 1) @@ -107,6 +108,8 @@ extension RUMViewEvent: RandomMockable { dd: .init( browserSdkVersion: nil, documentVersion: .mockRandom(), + pageStates: nil, + replayStats: nil, session: .init(plan: .plan1) ), application: .init(id: .mockRandom()), @@ -117,12 +120,14 @@ extension RUMViewEvent: RandomMockable { device: .mockRandom(), display: nil, os: .mockRandom(), + privacy: nil, service: .mockRandom(), session: .init( hasReplay: nil, id: .mockRandom(), isActive: true, - startReason: .appStart, + sampledForReplay: nil, + startPrecondition: .appLaunch, type: .user ), source: .ios, diff --git a/tools/rum-models-generator/Tests/CodeGenerationTests/Generate/Transformers/JSONSchemaToJSONTypeTransformerTests.swift b/tools/rum-models-generator/Tests/CodeGenerationTests/Generate/Transformers/JSONSchemaToJSONTypeTransformerTests.swift index 8c3028cce1..db9b384e57 100644 --- a/tools/rum-models-generator/Tests/CodeGenerationTests/Generate/Transformers/JSONSchemaToJSONTypeTransformerTests.swift +++ b/tools/rum-models-generator/Tests/CodeGenerationTests/Generate/Transformers/JSONSchemaToJSONTypeTransformerTests.swift @@ -256,5 +256,3 @@ final class JSONSchemaToJSONTypeTransformerTests: XCTestCase { XCTAssertEqual(expected, actual as? JSONObject) } } - - From 6fb6e8063c0812297e782a29bc32ce255b7b27ee Mon Sep 17 00:00:00 2001 From: Maciej Burda Date: Thu, 29 Jun 2023 15:45:06 +0100 Subject: [PATCH 4/4] PR fixes --- .../RUM/DataModels/RUMDataModels.swift | 22 +++--- .../DatadogObjc/RUM/RUMDataModels+objc.swift | 68 +++++++++---------- .../CodeDecoration/RUMCodeDecorator.swift | 4 -- 3 files changed, 45 insertions(+), 49 deletions(-) diff --git a/Sources/Datadog/RUM/DataModels/RUMDataModels.swift b/Sources/Datadog/RUM/DataModels/RUMDataModels.swift index 494dcff394..75a59d0022 100644 --- a/Sources/Datadog/RUM/DataModels/RUMDataModels.swift +++ b/Sources/Datadog/RUM/DataModels/RUMDataModels.swift @@ -35,7 +35,7 @@ public struct RUMActionEvent: RUMDataModel { public let device: RUMDevice? /// Display properties - public let display: RUMDisplay? + public let display: Display? /// Operating system properties public let os: RUMOperatingSystem? @@ -301,7 +301,7 @@ public struct RUMActionEvent: RUMDataModel { } /// Display properties - public struct RUMDisplay: Codable { + public struct Display: Codable { /// The viewport represents the rectangular area that is currently being viewed. Content outside the viewport is not visible onscreen until scrolled into view. public let viewport: Viewport? @@ -431,7 +431,7 @@ public struct RUMErrorEvent: RUMDataModel { public let device: RUMDevice? /// Display properties - public let display: RUMDisplay? + public let display: Display? /// Error properties public var error: Error @@ -544,7 +544,7 @@ public struct RUMErrorEvent: RUMDataModel { } /// Display properties - public struct RUMDisplay: Codable { + public struct Display: Codable { /// The viewport represents the rectangular area that is currently being viewed. Content outside the viewport is not visible onscreen until scrolled into view. public let viewport: Viewport? @@ -877,7 +877,7 @@ public struct RUMLongTaskEvent: RUMDataModel { public let device: RUMDevice? /// Display properties - public let display: RUMDisplay? + public let display: Display? /// Long Task properties public let longTask: LongTask @@ -990,7 +990,7 @@ public struct RUMLongTaskEvent: RUMDataModel { } /// Display properties - public struct RUMDisplay: Codable { + public struct Display: Codable { /// The viewport represents the rectangular area that is currently being viewed. Content outside the viewport is not visible onscreen until scrolled into view. public let viewport: Viewport? @@ -1134,7 +1134,7 @@ public struct RUMResourceEvent: RUMDataModel { public let device: RUMDevice? /// Display properties - public let display: RUMDisplay? + public let display: Display? /// Operating system properties public let os: RUMOperatingSystem? @@ -1259,7 +1259,7 @@ public struct RUMResourceEvent: RUMDataModel { } /// Display properties - public struct RUMDisplay: Codable { + public struct Display: Codable { /// The viewport represents the rectangular area that is currently being viewed. Content outside the viewport is not visible onscreen until scrolled into view. public let viewport: Viewport? @@ -1579,7 +1579,7 @@ public struct RUMViewEvent: RUMDataModel { public let device: RUMDevice? /// Display properties - public let display: RUMDisplay? + public let display: Display? /// Feature flags properties public internal(set) var featureFlags: FeatureFlags? @@ -1734,7 +1734,7 @@ public struct RUMViewEvent: RUMDataModel { } /// Display properties - public struct RUMDisplay: Codable { + public struct Display: Codable { /// Scroll properties public let scroll: Scroll? @@ -3182,4 +3182,4 @@ public enum RUMMethod: String, Codable { case patch = "PATCH" } -// Generated from https://github.com/DataDog/rum-events-format/tree/dcb6897cf883fb8938e7aa0f69ed9a035df98c2c +// Generated from https://github.com/DataDog/rum-events-format/tree/1c5eaa897c065e5f790a5f8aaf6fc8782d706051 diff --git a/Sources/DatadogObjc/RUM/RUMDataModels+objc.swift b/Sources/DatadogObjc/RUM/RUMDataModels+objc.swift index 045afe08cf..d43b1355ab 100644 --- a/Sources/DatadogObjc/RUM/RUMDataModels+objc.swift +++ b/Sources/DatadogObjc/RUM/RUMDataModels+objc.swift @@ -52,8 +52,8 @@ public class DDRUMActionEvent: NSObject { root.swiftModel.device != nil ? DDRUMActionEventRUMDevice(root: root) : nil } - @objc public var display: DDRUMActionEventRUMDisplay? { - root.swiftModel.display != nil ? DDRUMActionEventRUMDisplay(root: root) : nil + @objc public var display: DDRUMActionEventDisplay? { + root.swiftModel.display != nil ? DDRUMActionEventDisplay(root: root) : nil } @objc public var os: DDRUMActionEventRUMOperatingSystem? { @@ -603,20 +603,20 @@ public enum DDRUMActionEventRUMDeviceRUMDeviceType: Int { } @objc -public class DDRUMActionEventRUMDisplay: NSObject { +public class DDRUMActionEventDisplay: NSObject { internal let root: DDRUMActionEvent internal init(root: DDRUMActionEvent) { self.root = root } - @objc public var viewport: DDRUMActionEventRUMDisplayViewport? { - root.swiftModel.display!.viewport != nil ? DDRUMActionEventRUMDisplayViewport(root: root) : nil + @objc public var viewport: DDRUMActionEventDisplayViewport? { + root.swiftModel.display!.viewport != nil ? DDRUMActionEventDisplayViewport(root: root) : nil } } @objc -public class DDRUMActionEventRUMDisplayViewport: NSObject { +public class DDRUMActionEventDisplayViewport: NSObject { internal let root: DDRUMActionEvent internal init(root: DDRUMActionEvent) { @@ -855,8 +855,8 @@ public class DDRUMErrorEvent: NSObject { root.swiftModel.device != nil ? DDRUMErrorEventRUMDevice(root: root) : nil } - @objc public var display: DDRUMErrorEventRUMDisplay? { - root.swiftModel.display != nil ? DDRUMErrorEventRUMDisplay(root: root) : nil + @objc public var display: DDRUMErrorEventDisplay? { + root.swiftModel.display != nil ? DDRUMErrorEventDisplay(root: root) : nil } @objc public var error: DDRUMErrorEventError { @@ -1203,20 +1203,20 @@ public enum DDRUMErrorEventRUMDeviceRUMDeviceType: Int { } @objc -public class DDRUMErrorEventRUMDisplay: NSObject { +public class DDRUMErrorEventDisplay: NSObject { internal let root: DDRUMErrorEvent internal init(root: DDRUMErrorEvent) { self.root = root } - @objc public var viewport: DDRUMErrorEventRUMDisplayViewport? { - root.swiftModel.display!.viewport != nil ? DDRUMErrorEventRUMDisplayViewport(root: root) : nil + @objc public var viewport: DDRUMErrorEventDisplayViewport? { + root.swiftModel.display!.viewport != nil ? DDRUMErrorEventDisplayViewport(root: root) : nil } } @objc -public class DDRUMErrorEventRUMDisplayViewport: NSObject { +public class DDRUMErrorEventDisplayViewport: NSObject { internal let root: DDRUMErrorEvent internal init(root: DDRUMErrorEvent) { @@ -1829,8 +1829,8 @@ public class DDRUMLongTaskEvent: NSObject { root.swiftModel.device != nil ? DDRUMLongTaskEventRUMDevice(root: root) : nil } - @objc public var display: DDRUMLongTaskEventRUMDisplay? { - root.swiftModel.display != nil ? DDRUMLongTaskEventRUMDisplay(root: root) : nil + @objc public var display: DDRUMLongTaskEventDisplay? { + root.swiftModel.display != nil ? DDRUMLongTaskEventDisplay(root: root) : nil } @objc public var longTask: DDRUMLongTaskEventLongTask { @@ -2177,20 +2177,20 @@ public enum DDRUMLongTaskEventRUMDeviceRUMDeviceType: Int { } @objc -public class DDRUMLongTaskEventRUMDisplay: NSObject { +public class DDRUMLongTaskEventDisplay: NSObject { internal let root: DDRUMLongTaskEvent internal init(root: DDRUMLongTaskEvent) { self.root = root } - @objc public var viewport: DDRUMLongTaskEventRUMDisplayViewport? { - root.swiftModel.display!.viewport != nil ? DDRUMLongTaskEventRUMDisplayViewport(root: root) : nil + @objc public var viewport: DDRUMLongTaskEventDisplayViewport? { + root.swiftModel.display!.viewport != nil ? DDRUMLongTaskEventDisplayViewport(root: root) : nil } } @objc -public class DDRUMLongTaskEventRUMDisplayViewport: NSObject { +public class DDRUMLongTaskEventDisplayViewport: NSObject { internal let root: DDRUMLongTaskEvent internal init(root: DDRUMLongTaskEvent) { @@ -2446,8 +2446,8 @@ public class DDRUMResourceEvent: NSObject { root.swiftModel.device != nil ? DDRUMResourceEventRUMDevice(root: root) : nil } - @objc public var display: DDRUMResourceEventRUMDisplay? { - root.swiftModel.display != nil ? DDRUMResourceEventRUMDisplay(root: root) : nil + @objc public var display: DDRUMResourceEventDisplay? { + root.swiftModel.display != nil ? DDRUMResourceEventDisplay(root: root) : nil } @objc public var os: DDRUMResourceEventRUMOperatingSystem? { @@ -2806,20 +2806,20 @@ public enum DDRUMResourceEventRUMDeviceRUMDeviceType: Int { } @objc -public class DDRUMResourceEventRUMDisplay: NSObject { +public class DDRUMResourceEventDisplay: NSObject { internal let root: DDRUMResourceEvent internal init(root: DDRUMResourceEvent) { self.root = root } - @objc public var viewport: DDRUMResourceEventRUMDisplayViewport? { - root.swiftModel.display!.viewport != nil ? DDRUMResourceEventRUMDisplayViewport(root: root) : nil + @objc public var viewport: DDRUMResourceEventDisplayViewport? { + root.swiftModel.display!.viewport != nil ? DDRUMResourceEventDisplayViewport(root: root) : nil } } @objc -public class DDRUMResourceEventRUMDisplayViewport: NSObject { +public class DDRUMResourceEventDisplayViewport: NSObject { internal let root: DDRUMResourceEvent internal init(root: DDRUMResourceEvent) { @@ -3380,8 +3380,8 @@ public class DDRUMViewEvent: NSObject { root.swiftModel.device != nil ? DDRUMViewEventRUMDevice(root: root) : nil } - @objc public var display: DDRUMViewEventRUMDisplay? { - root.swiftModel.display != nil ? DDRUMViewEventRUMDisplay(root: root) : nil + @objc public var display: DDRUMViewEventDisplay? { + root.swiftModel.display != nil ? DDRUMViewEventDisplay(root: root) : nil } @objc public var featureFlags: DDRUMViewEventFeatureFlags? { @@ -3772,24 +3772,24 @@ public enum DDRUMViewEventRUMDeviceRUMDeviceType: Int { } @objc -public class DDRUMViewEventRUMDisplay: NSObject { +public class DDRUMViewEventDisplay: NSObject { internal let root: DDRUMViewEvent internal init(root: DDRUMViewEvent) { self.root = root } - @objc public var scroll: DDRUMViewEventRUMDisplayScroll? { - root.swiftModel.display!.scroll != nil ? DDRUMViewEventRUMDisplayScroll(root: root) : nil + @objc public var scroll: DDRUMViewEventDisplayScroll? { + root.swiftModel.display!.scroll != nil ? DDRUMViewEventDisplayScroll(root: root) : nil } - @objc public var viewport: DDRUMViewEventRUMDisplayViewport? { - root.swiftModel.display!.viewport != nil ? DDRUMViewEventRUMDisplayViewport(root: root) : nil + @objc public var viewport: DDRUMViewEventDisplayViewport? { + root.swiftModel.display!.viewport != nil ? DDRUMViewEventDisplayViewport(root: root) : nil } } @objc -public class DDRUMViewEventRUMDisplayScroll: NSObject { +public class DDRUMViewEventDisplayScroll: NSObject { internal let root: DDRUMViewEvent internal init(root: DDRUMViewEvent) { @@ -3814,7 +3814,7 @@ public class DDRUMViewEventRUMDisplayScroll: NSObject { } @objc -public class DDRUMViewEventRUMDisplayViewport: NSObject { +public class DDRUMViewEventDisplayViewport: NSObject { internal let root: DDRUMViewEvent internal init(root: DDRUMViewEvent) { @@ -5325,4 +5325,4 @@ public class DDTelemetryConfigurationEventView: NSObject { // swiftlint:enable force_unwrapping -// Generated from https://github.com/DataDog/rum-events-format/tree/dcb6897cf883fb8938e7aa0f69ed9a035df98c2c +// Generated from https://github.com/DataDog/rum-events-format/tree/1c5eaa897c065e5f790a5f8aaf6fc8782d706051 diff --git a/tools/rum-models-generator/Sources/CodeDecoration/RUMCodeDecorator.swift b/tools/rum-models-generator/Sources/CodeDecoration/RUMCodeDecorator.swift index 43f13ac021..def1aaff88 100644 --- a/tools/rum-models-generator/Sources/CodeDecoration/RUMCodeDecorator.swift +++ b/tools/rum-models-generator/Sources/CodeDecoration/RUMCodeDecorator.swift @@ -100,10 +100,6 @@ public class RUMCodeDecorator: SwiftCodeDecorator { fixedName = "RUMOperatingSystem" } - if fixedName == "Display" { - fixedName = "RUMDisplay" - } - // Since https://github.com/DataDog/rum-events-format/pull/57 `action.id` can be either // single `String` or an array of `[String]`. This is handled by generating Swift enum with // two cases and different associated types. To not duplicate generated code in each nested