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.
55 lines
1.8 KiB
Swift
55 lines
1.8 KiB
Swift
// ── Platform Telemetry Client ─────────────────────────────────
|
|
// Thin wrapper over ByteLystPlatformSDK's BLTelemetryClient.
|
|
// Keeps existing call-site API (CMTelemetryService.shared.trackEvent/trackTimer/trackScreen).
|
|
// Privacy: no PII, only action names + timing metrics.
|
|
|
|
import Foundation
|
|
import ByteLystPlatformSDK
|
|
|
|
@MainActor
|
|
final class CMTelemetryService {
|
|
static let shared = CMTelemetryService()
|
|
|
|
private let telemetry: BLTelemetryClient
|
|
|
|
private init() {
|
|
let config = BLPlatformConfig.fromInfoPlist(
|
|
productId: "chronomind",
|
|
defaultBaseURL: "https://api.chronomind.app",
|
|
bundleId: "com.saravana.chronomind",
|
|
appGroupId: "group.com.chronomind.shared"
|
|
)
|
|
let client = BLPlatformClient(config: config)
|
|
telemetry = BLTelemetryClient(config: config, client: client)
|
|
}
|
|
|
|
// MARK: - Public API
|
|
|
|
func start() { telemetry.start() }
|
|
func stop() { telemetry.stop() }
|
|
|
|
func trackEvent(
|
|
_ eventType: String,
|
|
module: String,
|
|
name: String,
|
|
feature: String? = nil,
|
|
message: String? = nil,
|
|
tags: [String: String]? = nil,
|
|
metrics: [String: Double]? = nil
|
|
) {
|
|
telemetry.trackEvent(eventType, module: module, name: name,
|
|
feature: feature, message: message,
|
|
tags: tags, metrics: metrics)
|
|
}
|
|
|
|
func trackTimer(_ name: String, tags: [String: String]? = nil, metrics: [String: Double]? = nil) {
|
|
trackEvent("info", module: "timers", name: name, tags: tags, metrics: metrics)
|
|
}
|
|
|
|
func trackScreen(_ screen: String) {
|
|
telemetry.trackScreen(screen)
|
|
}
|
|
|
|
func flush() { telemetry.flush() }
|
|
}
|