Skip to content

Commit 555c1de

Browse files
chore(insights): improve events logs (#823)
* chore(insights): improve events logs * chore: remove redundant initializers
1 parent c060289 commit 555c1de

File tree

7 files changed

+38
-24
lines changed

7 files changed

+38
-24
lines changed

Sources/AlgoliaSearchClient/Helpers/DisjunctiveFacetingHelper.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,6 @@ struct DisjunctiveFacetingHelper {
1616
let refinements: [Attribute: [String]]
1717
let disjunctiveFacets: Set<Attribute>
1818

19-
init(query: Query,
20-
refinements: [Attribute: [String]],
21-
disjunctiveFacets: Set<Attribute>) {
22-
self.query = query
23-
self.refinements = refinements
24-
self.disjunctiveFacets = disjunctiveFacets
25-
}
26-
2719
/// Build filters SQL string from the provided refinements and disjunctive facets set
2820
func buildFilters(excluding excludedAttribute: Attribute?) -> String {
2921
String(

Sources/AlgoliaSearchClient/Helpers/Wait/WaitableWrapper.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,6 @@ public struct WaitableWrapper<T> {
1212
public let wrapped: T
1313
let tasksToWait: [Waitable]
1414

15-
init(wrapped: T, tasksToWait: [Waitable]) {
16-
self.wrapped = wrapped
17-
self.tasksToWait = tasksToWait
18-
}
19-
2015
}
2116

2217
extension WaitableWrapper where T: IndexTask {

Sources/AlgoliaSearchClient/Models/Insights/Event/EventType.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Foundation
99

1010
extension InsightsEvent {
1111

12-
public struct EventType: StringOption, ProvidingCustomOption {
12+
public struct EventType: StringOption, ProvidingCustomOption, CustomStringConvertible {
1313

1414
public static var click: Self { .init(rawValue: #function) }
1515
public static var view: Self { .init(rawValue: #function) }
@@ -21,6 +21,10 @@ extension InsightsEvent {
2121
self.rawValue = rawValue
2222
}
2323

24+
public var description: String {
25+
rawValue
26+
}
27+
2428
}
2529

2630
}

Sources/AlgoliaSearchClient/Models/Insights/Event/InsightsEvent.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,21 @@ extension InsightsEvent: Codable {
9191
}
9292

9393
}
94+
95+
extension InsightsEvent: CustomStringConvertible {
96+
97+
public var description: String {
98+
"""
99+
\n{
100+
name: \"\(name)\",
101+
type: \(type),
102+
indexName: \(indexName),
103+
userToken: \(userToken ?? "none"),
104+
timestamp: \(timestamp?.description ?? "none"),
105+
queryID: \(queryID ?? "none"),
106+
\(resources)
107+
}
108+
"""
109+
}
110+
111+
}

Sources/AlgoliaSearchClient/Models/Insights/InsightsEvent+Resources.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,21 @@ extension InsightsEvent {
3131

3232
}
3333

34+
extension InsightsEvent.Resources: CustomStringConvertible {
35+
36+
public var description: String {
37+
switch self {
38+
case .filters(let filters):
39+
return "filters: \(filters)"
40+
case .objectIDs(let objectIDs):
41+
return "object IDs: \(objectIDs)"
42+
case .objectIDsWithPositions(let objectIDsPositions):
43+
return "object IDs & positions: \(objectIDsPositions)"
44+
}
45+
}
46+
47+
}
48+
3449
extension InsightsEvent.Resources: Codable {
3550

3651
enum CodingKeys: String, CodingKey {

Sources/AlgoliaSearchClient/Models/Logs/LogType.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ public struct LogType: Codable {
1111

1212
let rawValue: String
1313

14-
init(rawValue: String) {
15-
self.rawValue = rawValue
16-
}
17-
1814
/// Retrieve all the logs.
1915
public static var all: Self { .init(rawValue: #function) }
2016

Sources/AlgoliaSearchClient/Models/Search/Response/MultiSearchResponse.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,6 @@ public extension MultiSearchResponse {
8787
/// Error occured while facets search response decoding
8888
public let facetSearchResponseDecodingError: Error
8989

90-
init(searchResponseDecodingError: Error,
91-
facetSearchResponseDecodingError: Error) {
92-
self.searchResponseDecodingError = searchResponseDecodingError
93-
self.facetSearchResponseDecodingError = facetSearchResponseDecodingError
94-
}
95-
9690
}
9791

9892
}

0 commit comments

Comments
 (0)