//
//  BluetoothPairingProtocol.swift
//  MVM5G
//
//  Created by Matt Bruce on 4/15/22.
//  Copyright © 2022 Kyle. All rights reserved.
//

import Foundation

/// This Protocol will be implemented by a variation of BluetoothPairing Classes
protocol BluetoothParingProtocol: AnyObject, MFFGHSAnalyticsProtocol {
    var bluetoothConfig: BluetoothConfigModel? { get set }
    var bluetoothDebugger: BluetoothDebugger? { get set }
    func getBleAdvertiseName() -> String
    func track(_ data: [String: Any])
    func track(_ message: String, function: String, additionalData: [String: Any])
}

extension BluetoothParingProtocol {
    func track(_ message: String, function: String = #function, additionalData: [String: Any] = [:]) {
        guard bluetoothConfig != nil else { return }

        let data = additionalData.values.isEmpty ? "" :  "\r   \(additionalData)"
        bluetoothDebugger?.addLog(message: "\(message)\(data)")
        
        trackGemini(value: ([GMFGConstant.functionName: function,
                             GMFGConstant.BLE.advertisedData: getBleAdvertiseName(),
                             "message": message
        ]).merging(additionalData, uniquingKeysWith: { $1 }), logType: .BLE)
    }
}
