learning_ai_clock/ios/ChronoMind/Shared/Cloud/FeatureFlagService.swift
saravanakumardb1 d1b4534b22 refactor(ios): migrate Cloud/ files to ByteLystPlatformSDK — eliminate duplicated platform code
Replaced standalone implementations with thin wrappers over shared SDK:
- KeychainHelper → delegates to BLKeychain (53→27 lines)
- TelemetryService → delegates to BLTelemetryClient (139→55 lines)
- FeatureFlagService → delegates to BLFeatureFlagClient (72→39 lines)
- AuthService → delegates to BLAuthClient (359→171 lines)
- project.yml → added ByteLystPlatformSDK local package dependency

Total: 623 lines of duplicated code → 292 lines of thin wrappers.
PlatformSyncManager kept as-is (product-specific timer DTOs).
All existing call-site APIs preserved — zero breaking changes.
2026-02-28 22:12:37 -08:00

39 lines
1.1 KiB
Swift

// Feature Flag Client
// Thin wrapper over ByteLystPlatformSDK's BLFeatureFlagClient.
// Keeps existing call-site API (FeatureFlagService.shared.isEnabled).
import Foundation
import ByteLystPlatformSDK
@MainActor
final class FeatureFlagService: ObservableObject {
static let shared = FeatureFlagService()
@Published private(set) var flags: [String: Bool] = [:]
private let flagClient: BLFeatureFlagClient
private init() {
let config = BLPlatformConfig.fromInfoPlist(
productId: "chronomind",
defaultBaseURL: "https://api.chronomind.app",
bundleId: "com.saravana.chronomind"
)
let client = BLPlatformClient(config: config)
flagClient = BLFeatureFlagClient(config: config, client: client)
}
// MARK: - Public API
func start(userId: String? = nil) {
flagClient.start(userId: userId)
}
func stop() {
flagClient.stop()
}
func isEnabled(_ key: String) -> Bool {
flagClient.isEnabled(key)
}
}