learning_ai_clock/ios/ChronoMind/Shared/Cloud/TelemetryService.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

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() }
}