Skip to content

Commit 64c8c04

Browse files
committed
Rename configure_BETA to getStableIdentifier
1 parent a0b31a4 commit 64c8c04

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

Sources/AIProxy/AIProxy.swift

+12-2
Original file line numberDiff line numberDiff line change
@@ -830,13 +830,23 @@ public struct AIProxy {
830830
}
831831
#endif
832832

833+
/// This is a beta feature.
834+
/// It returns a stable, anonymous identifier that you can annotate requests to AIProxy with.
835+
/// You must add the 'iCloud key-value storage' capability to use this:
836+
/// 1. Tap on your project in Xcode's project tree
837+
/// 2. Tap on your target in the sidebar
838+
/// 3. Tap on Signing & Capabilities in the top nav
839+
/// 4. Tap the plus sign next to 'Capability'
840+
/// 5. Add iCloud
841+
/// 6. Select the 'Key-value storage' service
833842
@NetworkActor
834-
public static func configure_BETA() async {
843+
public static func getStableIdentifier() async -> String? {
835844
do {
836-
try await AnonymousAccountStorage.sync()
845+
return try await AnonymousAccountStorage.sync()
837846
} catch {
838847
aiproxyLogger.critical("Could not configure an AIProxy anonymous account: \(error.localizedDescription)")
839848
}
849+
return nil
840850
}
841851

842852
private init() {

Sources/AIProxy/AnonymousAccount/AIProxyStorage.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ private let kAIProxyRemoteAccount = "aiproxy-remote"
1212
internal let kAIProxyUKVSAccount = "aiproxy-ukvs"
1313

1414

15-
public final class AIProxyStorage {
15+
final class AIProxyStorage {
1616

1717
static private let keychain = AIProxyKeychain()
1818
static private let ukvs = NSUbiquitousKeyValueStore.default

Sources/AIProxy/AnonymousAccount/AnonymousAccountStorage.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ final class AnonymousAccountStorage {
3838
private static var localAccountChain: [AnonymousAccount] = []
3939

4040
/// This is expected to be called as part of the application launch.
41-
static func sync() async throws {
41+
static func sync() async throws -> String {
4242
#if false
4343
try await AIProxyStorage.clear()
4444
#endif
@@ -133,6 +133,8 @@ final class AnonymousAccountStorage {
133133
aiproxyLogger.info("Local account chain is \(localAccountChain)")
134134
aiproxyLogger.info("Anonymous account identifier is \(self.resolvedAccount!.uuid)")
135135
#endif
136+
137+
return localAccount.uuid
136138
}
137139

138140
/// Called when NSUbiquitousKeyValueStore was remotely updated.

0 commit comments

Comments
 (0)