From 43e8d441bac937b747d1237d2c8d64a7c0c950f3 Mon Sep 17 00:00:00 2001 From: Maciek Grzybowski Date: Tue, 21 May 2024 10:46:37 +0200 Subject: [PATCH 1/2] Explicitly ignore `telemetry/usage-schema.json` to unblock generatin RUM models --- .../Sources/CodeGeneration/Generate/JSONSchema.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/rum-models-generator/Sources/CodeGeneration/Generate/JSONSchema.swift b/tools/rum-models-generator/Sources/CodeGeneration/Generate/JSONSchema.swift index efddd5b759..afcce8ae7b 100644 --- a/tools/rum-models-generator/Sources/CodeGeneration/Generate/JSONSchema.swift +++ b/tools/rum-models-generator/Sources/CodeGeneration/Generate/JSONSchema.swift @@ -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 From 421f9b908d1deea28b7cd070fe388476911c6847 Mon Sep 17 00:00:00 2001 From: Maciek Grzybowski Date: Tue, 21 May 2024 11:22:40 +0200 Subject: [PATCH 2/2] Fix shared type ambiguity for `telemetry.device` and `telemetry.os` models --- .../CodeDecoration/RUMCodeDecorator.swift | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tools/rum-models-generator/Sources/CodeDecoration/RUMCodeDecorator.swift b/tools/rum-models-generator/Sources/CodeDecoration/RUMCodeDecorator.swift index f551140b58..aa22d6ad24 100644 --- a/tools/rum-models-generator/Sources/CodeDecoration/RUMCodeDecorator.swift +++ b/tools/rum-models-generator/Sources/CodeDecoration/RUMCodeDecorator.swift @@ -26,6 +26,8 @@ public class RUMCodeDecorator: SwiftCodeDecorator { "RUMOperatingSystem", "RUMActionID", "RUMSessionPrecondition", + "RUMTelemetryDevice", + "RUMTelemetryOperatingSystem", ] ) } @@ -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