Skip to content

Commit

Permalink
chore(insights): improve events logs (#823)
Browse files Browse the repository at this point in the history
* chore(insights): improve events logs

* chore: remove redundant initializers
  • Loading branch information
VladislavFitz authored Aug 15, 2023
1 parent c060289 commit 555c1de
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@ struct DisjunctiveFacetingHelper {
let refinements: [Attribute: [String]]
let disjunctiveFacets: Set<Attribute>

init(query: Query,
refinements: [Attribute: [String]],
disjunctiveFacets: Set<Attribute>) {
self.query = query
self.refinements = refinements
self.disjunctiveFacets = disjunctiveFacets
}

/// Build filters SQL string from the provided refinements and disjunctive facets set
func buildFilters(excluding excludedAttribute: Attribute?) -> String {
String(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ public struct WaitableWrapper<T> {
public let wrapped: T
let tasksToWait: [Waitable]

init(wrapped: T, tasksToWait: [Waitable]) {
self.wrapped = wrapped
self.tasksToWait = tasksToWait
}

}

extension WaitableWrapper where T: IndexTask {
Expand Down
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
4 changes: 0 additions & 4 deletions Sources/AlgoliaSearchClient/Models/Logs/LogType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ public struct LogType: Codable {

let rawValue: String

init(rawValue: String) {
self.rawValue = rawValue
}

/// Retrieve all the logs.
public static var all: Self { .init(rawValue: #function) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,6 @@ public extension MultiSearchResponse {
/// Error occured while facets search response decoding
public let facetSearchResponseDecodingError: Error

init(searchResponseDecodingError: Error,
facetSearchResponseDecodingError: Error) {
self.searchResponseDecodingError = searchResponseDecodingError
self.facetSearchResponseDecodingError = facetSearchResponseDecodingError
}

}

}
Expand Down

0 comments on commit 555c1de

Please sign in to comment.