Revision control
Copy as Markdown
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
import Foundation
/// A permission the Quick Answers voice flow needs before it can run.
public enum QuickAnswersPermission: String {
/// Captures the user's audio.
case microphone
/// Turns the captured audio into a transcription.
case speechRecognition = "speech_recognition"
}
/// Events of a single question take an `isFollowUp` dimension: `true` when the question was asked after a
/// previous answer in the same session, `false` for the first one.
public protocol QuickAnswersTelemetry {
/// Fires when the user initiates the Quick Answers flow.
/// - Parameter model: The model backing the request.
func quickAnswersRequested(model: QuickAnswersModel)
/// Fires when the service starts attempting to capture user audio.
func recordingStarted(isFollowUp: Bool)
/// Fires when the transcription completes.
/// - Parameters:
/// - outcome: `true` if the transcription succeeded, `false` if it failed.
/// - errorType: A description of the failure when `outcome` is `false`, otherwise `nil`.
func recordingCompleted(outcome: Bool, errorType: String?, isFollowUp: Bool)
/// Fires when the results service starts to fetch results from the backend.
@MainActor
func resultsStarted(isFollowUp: Bool)
/// Fires when the results service returns the summary or errors out.
/// - Parameters:
/// - outcome: `true` if the results were fetched successfully, `false` if it failed.
/// - errorType: A description of the failure when `outcome` is `false`, otherwise `nil`.
/// - model: The model backing the request.
@MainActor
func resultsCompleted(outcome: Bool, errorType: String?, model: QuickAnswersModel, isFollowUp: Bool)
/// Fires when the user denies one of the permissions the voice flow needs.
/// - Parameter permission: The permission that was denied.
func permissionDenied(permission: QuickAnswersPermission)
/// Fires when the user taps a citation source in the results.
func citationTapped()
/// Fires when the Quick Answers screen is dismissed.
func closed()
/// Fires when the user is shown the consent dialogue.
/// - Parameter agreed: `true` if the user accepted, `false` otherwise.
func consentShown(agreed: Bool)
}