diff --git a/Sources/AlgoliaSearchClient/Models/Insights/Event/EventType.swift b/Sources/AlgoliaSearchClient/Models/Insights/Event/EventType.swift index 085cd2675..8ed823be7 100644 --- a/Sources/AlgoliaSearchClient/Models/Insights/Event/EventType.swift +++ b/Sources/AlgoliaSearchClient/Models/Insights/Event/EventType.swift @@ -9,7 +9,7 @@ import Foundation extension InsightsEvent { - public struct EventType: StringOption, ProvidingCustomOption { + public struct EventType: StringOption, ProvidingCustomOption, CustomStringConvertible { public static var click: Self { .init(rawValue: #function) } public static var view: Self { .init(rawValue: #function) } @@ -20,6 +20,10 @@ extension InsightsEvent { public init(rawValue: String) { self.rawValue = rawValue } + + public var description: String { + rawValue + } } diff --git a/Sources/AlgoliaSearchClient/Models/Insights/Event/InsightsEvent.swift b/Sources/AlgoliaSearchClient/Models/Insights/Event/InsightsEvent.swift index 62103aac5..69ada832a 100644 --- a/Sources/AlgoliaSearchClient/Models/Insights/Event/InsightsEvent.swift +++ b/Sources/AlgoliaSearchClient/Models/Insights/Event/InsightsEvent.swift @@ -91,3 +91,21 @@ extension InsightsEvent: Codable { } } + +extension InsightsEvent: CustomStringConvertible { + + public var description: String { + """ + \n{ + name: \"\(name)\", + type: \(type), + indexName: \(indexName), + userToken: \(userToken ?? "none"), + timestamp: \(timestamp?.description ?? "none"), + queryID: \(queryID ?? "none"), + \(resources) + } + """ + } + +} diff --git a/Sources/AlgoliaSearchClient/Models/Insights/InsightsEvent+Resources.swift b/Sources/AlgoliaSearchClient/Models/Insights/InsightsEvent+Resources.swift index f8a55f34c..9c83628ae 100644 --- a/Sources/AlgoliaSearchClient/Models/Insights/InsightsEvent+Resources.swift +++ b/Sources/AlgoliaSearchClient/Models/Insights/InsightsEvent+Resources.swift @@ -31,6 +31,21 @@ extension InsightsEvent { } +extension InsightsEvent.Resources: CustomStringConvertible { + + public var description: String { + switch self { + case .filters(let filters): + return "filters: \(filters)" + case .objectIDs(let objectIDs): + return "object IDs: \(objectIDs)" + case .objectIDsWithPositions(let objectIDsPositions): + return "object IDs & positions: \(objectIDsPositions)" + } + } + +} + extension InsightsEvent.Resources: Codable { enum CodingKeys: String, CodingKey {