New package ByteLystDiagnostics with: - Core types: DiagnosticsSession, TraceSpan, LogEntry, Breadcrumb - DiagnosticsClient: actor-based singleton with polling - BreadcrumbTrail: ring buffer (max 100) for timeline - NetworkInterceptor: URLProtocol-based HTTP capture - DeviceState: battery, memory, storage, network, thermal - 20+ XCTest unit tests Features: - configure()/start()/stop() lifecycle - trace() async span wrapper - log() with breadcrumb integration - breadcrumb() manual timeline markers - ETag-based config polling - 30-second batch flush Platforms: iOS 15+, macOS 13+, watchOS 8+, tvOS 15+
74 lines
2.4 KiB
Swift
74 lines
2.4 KiB
Swift
/**
|
|
* ByteLystDiagnostics
|
|
*
|
|
* Remote diagnostics and debug tracing client for the ByteLyst ecosystem.
|
|
* Provides polling, logging, tracing, network capture, and breadcrumbs for iOS/macOS.
|
|
*
|
|
* Example usage:
|
|
* ```swift
|
|
* import ByteLystDiagnostics
|
|
*
|
|
* // Configure
|
|
* let config = DiagnosticsConfiguration(
|
|
* productId: "myapp",
|
|
* anonymousInstallId: "install_123",
|
|
* platform: "ios",
|
|
* channel: "ios_app",
|
|
* osFamily: "ios",
|
|
* appVersion: "1.0.0",
|
|
* buildNumber: "100",
|
|
* releaseChannel: "stable",
|
|
* serverUrl: "https://api.bytelyst.com"
|
|
* )
|
|
*
|
|
* await DiagnosticsClient.shared.configure(config)
|
|
* await DiagnosticsClient.shared.start()
|
|
*
|
|
* // Auto-instrumented trace
|
|
* let result = try await DiagnosticsClient.shared.trace(name: "fetchUser") {
|
|
* try await fetchUser()
|
|
* }
|
|
*
|
|
* // Manual breadcrumb
|
|
* await DiagnosticsClient.shared.breadcrumb(
|
|
* category: "user",
|
|
* message: "Tapped submit button",
|
|
* data: ["buttonId": AnyCodable("submit")]
|
|
* )
|
|
*
|
|
* // Manual log
|
|
* await DiagnosticsClient.shared.log(
|
|
* level: .info,
|
|
* message: "User signed in",
|
|
* module: "Auth",
|
|
* context: ["userId": AnyCodable(userId)]
|
|
* )
|
|
* ```
|
|
*/
|
|
|
|
// MARK: - Core
|
|
@_exported import Foundation
|
|
|
|
// Types
|
|
public typealias ByteLystDiagnosticsTypes = DiagnosticsSession
|
|
public typealias ByteLystDiagnosticsLogLevel = DiagnosticsLogLevel
|
|
public typealias ByteLystDiagnosticsSessionStatus = DiagnosticsSessionStatus
|
|
public typealias ByteLystDiagnosticsCollectionLevel = DiagnosticsCollectionLevel
|
|
public typealias ByteLystDiagnosticsTraceSpan = DiagnosticsTraceSpan
|
|
public typealias ByteLystDiagnosticsLogEntry = DiagnosticsLogEntry
|
|
public typealias ByteLystDiagnosticsBreadcrumb = DiagnosticsBreadcrumb
|
|
public typealias ByteLystDiagnosticsNetworkRequest = DiagnosticsNetworkRequest
|
|
public typealias ByteLystDiagnosticsDeviceState = DiagnosticsDeviceState
|
|
public typealias ByteLystDiagnosticsIngestBatch = DiagnosticsIngestBatch
|
|
public typealias ByteLystDiagnosticsClientState = DiagnosticsClientState
|
|
public typealias ByteLystDiagnosticsConfiguration = DiagnosticsConfiguration
|
|
public typealias ByteLystDiagnosticsLogger = DiagnosticsLogger
|
|
public typealias ByteLystDiagnosticsNoOpLogger = NoOpDiagnosticsLogger
|
|
public typealias ByteLystDiagnosticsOSLogger = OSDiagnosticsLogger
|
|
|
|
// Errors
|
|
public typealias ByteLystDiagnosticsError = DiagnosticsError
|
|
|
|
// Version
|
|
public let ByteLystDiagnosticsVersion = "0.1.0"
|