Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions FirebaseVertexAI/Sources/FirebaseInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@ struct FirebaseInfo: Sendable {
let auth: AuthInterop?
let projectID: String
let apiKey: String
let googleAppID: String
let firebaseAppID: String
let app: FirebaseApp

init(appCheck: AppCheckInterop? = nil,
auth: AuthInterop? = nil,
projectID: String,
apiKey: String,
googleAppID: String,
firebaseAppID: String,
firebaseApp: FirebaseApp) {
self.appCheck = appCheck
self.auth = auth
self.projectID = projectID
self.apiKey = apiKey
self.googleAppID = googleAppID
self.firebaseAppID = firebaseAppID
app = firebaseApp
}
}
2 changes: 1 addition & 1 deletion FirebaseVertexAI/Sources/GenerativeAIService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ struct GenerativeAIService {
}

if firebaseInfo.app.isDataCollectionDefaultEnabled {
urlRequest.setValue(firebaseInfo.googleAppID, forHTTPHeaderField: "X-Firebase-AppId")
urlRequest.setValue(firebaseInfo.firebaseAppID, forHTTPHeaderField: "X-Firebase-AppId")
if let appVersion = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String {
urlRequest.setValue(appVersion, forHTTPHeaderField: "X-Firebase-AppVersion")
}
Expand Down
2 changes: 1 addition & 1 deletion FirebaseVertexAI/Sources/VertexAI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public class VertexAI {
auth: ComponentType<AuthInterop>.instance(for: AuthInterop.self, in: app.container),
projectID: projectID,
apiKey: apiKey,
googleAppID: app.options.googleAppID,
firebaseAppID: app.options.googleAppID,
firebaseApp: app
)
self.apiConfig = apiConfig
Expand Down
2 changes: 1 addition & 1 deletion FirebaseVertexAI/Tests/Unit/ChatTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#if os(watchOS)
throw XCTSkip("Custom URL protocols are unsupported in watchOS 2 and later.")
#endif // os(watchOS)
MockURLProtocol.requestHandler = { request in

Check warning on line 47 in FirebaseVertexAI/Tests/Unit/ChatTests.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-15, Xcode_16.2, watchOS)

code after 'throw' will never be executed
let response = HTTPURLResponse(
url: request.url!,
statusCode: 200,
Expand All @@ -62,7 +62,7 @@
firebaseInfo: FirebaseInfo(
projectID: "my-project-id",
apiKey: "API_KEY",
googleAppID: "My app ID",
firebaseAppID: "My app ID",
firebaseApp: app
),
apiConfig: APIConfig(service: .vertexAI, version: .v1beta),
Expand Down
6 changes: 3 additions & 3 deletions FirebaseVertexAI/Tests/Unit/GenerativeModelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1478,7 +1478,7 @@
auth: auth,
projectID: "my-project-id",
apiKey: "API_KEY",
googleAppID: "My app ID",
firebaseAppID: "My app ID",
firebaseApp: app
)
}
Expand All @@ -1492,7 +1492,7 @@
#if os(watchOS)
throw XCTSkip("Custom URL protocols are unsupported in watchOS 2 and later.")
#endif // os(watchOS)
return { request in

Check warning on line 1495 in FirebaseVertexAI/Tests/Unit/GenerativeModelTests.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-15, Xcode_16.2, watchOS)

code after 'throw' will never be executed
// This is *not* an HTTPURLResponse
let response = URLResponse(
url: request.url!,
Expand All @@ -1519,7 +1519,7 @@
#if os(watchOS)
throw XCTSkip("Custom URL protocols are unsupported in watchOS 2 and later.")
#endif // os(watchOS)
let bundle = BundleTestUtil.bundle()

Check warning on line 1522 in FirebaseVertexAI/Tests/Unit/GenerativeModelTests.swift

View workflow job for this annotation

GitHub Actions / spm-unit (macos-15, Xcode_16.2, watchOS)

code after 'throw' will never be executed
let fileURL = try XCTUnwrap(bundle.url(forResource: name, withExtension: ext))
return { request in
let requestURL = try XCTUnwrap(request.url)
Expand All @@ -1531,11 +1531,11 @@
XCTAssert(apiClientTags.contains(GenerativeAIService.firebaseVersionTag))
XCTAssertEqual(request.value(forHTTPHeaderField: "X-Firebase-AppCheck"), appCheckToken)

let googleAppID = request.value(forHTTPHeaderField: "X-Firebase-AppId")
let firebaseAppID = request.value(forHTTPHeaderField: "X-Firebase-AppId")
let appVersion = request.value(forHTTPHeaderField: "X-Firebase-AppVersion")
let expectedAppVersion =
try? XCTUnwrap(Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String)
XCTAssertEqual(googleAppID, dataCollection ? "My app ID" : nil)
XCTAssertEqual(firebaseAppID, dataCollection ? "My app ID" : nil)
XCTAssertEqual(appVersion, dataCollection ? expectedAppVersion : nil)

if let authToken {
Expand Down
Loading