Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/PowerSync/Kotlin/KotlinPowerSyncDatabaseImpl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ final class KotlinPowerSyncDatabaseImpl: PowerSyncDatabaseProtocol,
params: resolvedOptions.params.mapValues { $0.toKotlinMap() },
options: createSyncOptions(
newClient: resolvedOptions.newClientImplementation,
userAgent: "PowerSync Swift SDK",
userAgent: userAgent(),
loggingConfig: resolvedOptions.clientConfiguration?.requestLogger?.toKotlinConfig()
)
)
Expand Down
25 changes: 25 additions & 0 deletions Sources/PowerSync/Kotlin/sync/UserAgent.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Foundation

#if os(iOS)
import UIKit
#elseif os(macOS)
import AppKit
#endif

func userAgent() -> String {
let libraryVersion = "1.0.0" // TODO: Replace with actual library version

#if os(iOS)
let osName = "iOS"
let osVersion = UIDevice.current.systemVersion
#elseif os(macOS)
let osName = "macOS"
let version = ProcessInfo.processInfo.operatingSystemVersion
let osVersion = "\(version.majorVersion).\(version.minorVersion)"
#else
let osName = "unknown"
let osVersion = ProcessInfo.processInfo.operatingSystemVersionString
#endif

return "powersync-swift/\(libraryVersion) \(osName)/\(osVersion)"
}