Skip to content

Commit

Permalink
chore(insights): improve events logs
Browse files Browse the repository at this point in the history
  • Loading branch information
VladislavFitz committed Aug 15, 2023
1 parent 71e4e1c commit c77101b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
Expand All @@ -21,6 +21,10 @@ extension InsightsEvent {
self.rawValue = rawValue
}

public var description: String {
rawValue
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
"""
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit c77101b

Please sign in to comment.