-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Insights): add user-agent extension (#274)
- Loading branch information
1 parent
27ab59c
commit 42b5d08
Showing
10 changed files
with
48 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
github "apple/swift-log" ~> 1.4 | ||
github "algolia/algoliasearch-client-swift" ~> 8.15 | ||
github "algolia/algoliasearch-client-swift" ~> 8.17 | ||
github "algolia/instantsearch-telemetry-native" ~> 0.1.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ntSearchCore/Helper/UserAgentSetter.swift → ...archCore/Helper/CoreUserAgentSetter.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
Sources/InstantSearchInsights/Helpers/InsightsUserAgentSetter.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// InsightsUserAgentSetter.swift | ||
// | ||
// | ||
// Created by Vladislav Fitc on 03/02/2023. | ||
// | ||
|
||
import AlgoliaSearchClient | ||
import Foundation | ||
|
||
struct InsightsUserAgentSetter { | ||
/// Add the library's version to the client's user agents, if not already present. | ||
static let set = Self() | ||
|
||
init() { | ||
UserAgentController.append(UserAgent(title: "Algolia insights for iOS", version: Version.current.description)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// UserAgentTest.swift | ||
// | ||
// | ||
// Created by Vladislav Fitc on 03/02/2023. | ||
// | ||
|
||
import AlgoliaSearchClient | ||
@testable import InstantSearchInsights | ||
import XCTest | ||
|
||
class UserAgentTest: XCTestCase { | ||
func testUserAgentUniqueness() { | ||
Insights.register(appId: "a", apiKey: "a") | ||
Insights.register(appId: "b", apiKey: "b") | ||
Insights.register(appId: "c", apiKey: "c") | ||
XCTAssertEqual(UserAgentController.extensions.filter { $0.userAgentExtension.contains("Algolia insights for iOS") }.count, 1) | ||
} | ||
} |