Skip to content

Commit 4f3f8f0

Browse files
committed
Updating user agent formatting.
1 parent 9196f8a commit 4f3f8f0

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

Sources/PowerSync/Kotlin/KotlinPowerSyncDatabaseImpl.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ final class KotlinPowerSyncDatabaseImpl: PowerSyncDatabaseProtocol,
6262
params: resolvedOptions.params.mapValues { $0.toKotlinMap() },
6363
options: createSyncOptions(
6464
newClient: resolvedOptions.newClientImplementation,
65-
userAgent: "PowerSync Swift SDK",
65+
userAgent: userAgent(),
6666
loggingConfig: resolvedOptions.clientConfiguration?.requestLogger?.toKotlinConfig()
6767
)
6868
)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import Foundation
2+
3+
#if os(iOS)
4+
import UIKit
5+
#elseif os(macOS)
6+
import AppKit
7+
#endif
8+
9+
func userAgent() -> String {
10+
let libraryVersion = "1.0.0" // TODO: Replace with actual library version
11+
12+
#if os(iOS)
13+
let osName = "iOS"
14+
let osVersion = UIDevice.current.systemVersion
15+
#elseif os(macOS)
16+
let osName = "macOS"
17+
let version = ProcessInfo.processInfo.operatingSystemVersion
18+
let osVersion = "\(version.majorVersion).\(version.minorVersion)"
19+
#else
20+
let osName = "unknown"
21+
let osVersion = ProcessInfo.processInfo.operatingSystemVersionString
22+
#endif
23+
24+
return "powersync-swift/\(libraryVersion) \(osName)/\(osVersion)"
25+
}

0 commit comments

Comments
 (0)