import Foundation
import Sentry

enum BugReporting {
    static let dsn = "https://5ef8c516e95244bc88e859fc428ec5a0@bugsink.nixc.us/5"

    static func start() {
        SentrySDK.start { options in
            options.dsn = dsn
            options.debug = false
            options.enableCrashHandler = true
            options.enableAutoSessionTracking = true
            options.sendDefaultPii = false

            // Attach stack traces to all logged errors
            options.attachStacktrace = true

            // Sample rate for regular events (1.0 = send everything)
            options.sampleRate = 1.0
        }
    }

    /// Capture a non-fatal error manually
    static func capture(_ error: Error) {
        SentrySDK.capture(error: error)
    }

    /// Capture a message manually
    static func capture(message: String) {
        SentrySDK.capture(message: message)
    }
}
