diff --git a/Sources/PowerSync/Kotlin/KotlinPowerSyncDatabaseImpl.swift b/Sources/PowerSync/Kotlin/KotlinPowerSyncDatabaseImpl.swift index aa81d1d..5097007 100644 --- a/Sources/PowerSync/Kotlin/KotlinPowerSyncDatabaseImpl.swift +++ b/Sources/PowerSync/Kotlin/KotlinPowerSyncDatabaseImpl.swift @@ -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() ) ) diff --git a/Sources/PowerSync/Kotlin/sync/UserAgent.swift b/Sources/PowerSync/Kotlin/sync/UserAgent.swift new file mode 100644 index 0000000..f56792b --- /dev/null +++ b/Sources/PowerSync/Kotlin/sync/UserAgent.swift @@ -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)" +} \ No newline at end of file