Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Fix generating rum models #1855

Merged
merged 2 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class RUMCodeDecorator: SwiftCodeDecorator {
"RUMOperatingSystem",
"RUMActionID",
"RUMSessionPrecondition",
"RUMTelemetryDevice",
"RUMTelemetryOperatingSystem",
]
)
}
Expand Down Expand Up @@ -104,11 +106,25 @@ public class RUMCodeDecorator: SwiftCodeDecorator {
}

if fixedName == "Device" {
fixedName = "RUMDevice"
if context.parent?.typeName == "telemetry" {
// The `telemetry.device` added in https://github.com/DataDog/rum-events-format/pull/200 has different schema
// than `*.device` in common schema: https://github.com/DataDog/rum-events-format/blob/dcd62e58566b9d158c404f3588edc62c041262dd/schemas/rum/_common-schema.json#L264-L295
// For that reason, we generate it under different name, so the `RUMTelemetryDevice` can be shared between telemetry events.
fixedName = "RUMTelemetryDevice"
} else {
fixedName = "RUMDevice"
}
}

if fixedName == "OS" {
fixedName = "RUMOperatingSystem"
if context.parent?.typeName == "telemetry" {
// The `telemetry.os` added in https://github.com/DataDog/rum-events-format/pull/200 has different schema
// than `*.os` in common schema: https://github.com/DataDog/rum-events-format/blob/dcd62e58566b9d158c404f3588edc62c041262dd/schemas/rum/_common-schema.json#L237-L262
// For that reason, we generate it under different name, so the `RUMTelemetryOperatingSystem` can be shared between telemetry events.
fixedName = "RUMTelemetryOperatingSystem"
} else {
fixedName = "RUMOperatingSystem"
}
}

// Since https://github.com/DataDog/rum-events-format/pull/57 `action.id` can be either
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ internal class JSONSchema: Decodable {
let schema = try reader.read(url)
merge(with: schema)
}

// TODO: RUM-4571 [iOS] Generate RUM models for Usage Telemetry
// With addition of the "usage telemetry" the RUM schema was updated with unsupported constructs.
// To avoid `🚧 Unimplemented: "Building `SwiftAssociatedTypeEnum` case label for JSONObject is not supported` failure
// here we explicitly ignore the "usage" sub-schema.
oneOf = oneOf?.filter { $0.ref != "telemetry/usage-schema.json" }
}

// MARK: - Schemas Merging
Expand Down