// Copyright 2025 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef IOS_CHROME_BROWSER_INTELLIGENCE_BWG_METRICS_GEMINI_METRICS_H_
#define IOS_CHROME_BROWSER_INTELLIGENCE_BWG_METRICS_GEMINI_METRICS_H_

#import <Foundation/Foundation.h>

#import "ios/public/provider/chrome/browser/bwg/gemini_api.h"

namespace base {
class TimeDelta;
class TimeTicks;
}  // namespace base

namespace optimization_guide {
enum class OptimizationGuideDecision;
}  // namespace optimization_guide

namespace gemini {
enum class EntryPoint;
enum class FloatyUpdateSource;
enum class ImageActionButtonType;
enum class InputPlateAttachmentOption;
enum class FirstRunState;
enum class RegenerateOptionType;
// Encapsulates a set of ineligibility reasons computed during a single Gemini
// eligibility check.
struct IneligibilityReasons {
  bool workspace = false;
  bool chrome_enterprise = false;
  bool account_capability = false;
  bool authentication = false;

  IneligibilityReasons() = default;

  IneligibilityReasons& set_workspace(bool value);
  IneligibilityReasons& set_chrome_enterprise(bool value);
  IneligibilityReasons& set_account_capability(bool value);
  IneligibilityReasons& set_authentication(bool value);
};
}  // namespace gemini

namespace ios::provider {
enum class GeminiViewState;
}

// UMA histogram key for IOS.Gemini.Eligibility.
extern const char kEligibilityHistogram[];

// UMA histogram key for IOS.Gemini.FRE.State.
extern const char kGeminiFirstRunStateHistogram[];

// UMA histogram key for IOS.Gemini.EntryPoint.
extern const char kEntryPointHistogram[];

// UMA histogram key for IOS.Gemini.SignInRequiredSnackbar.Shown.
extern const char kSignInRequiredSnackbarShownHistogram[];

// UMA histogram key for IOS.Gemini.EntryPoint.Available.
extern const char kEntryPointAvailableHistogram[];

// UMA histogram key for IOS.Gemini.FRE.EntryPoint.
extern const char kFirstRunEntryPointHistogram[];

// UMA histogram key for IOS.Gemini.FRE.PromoAction.
extern const char kFirstRunPromoActionHistogram[];

// UMA histogram key for IOS.Gemini.FRE.ConsentAction.
extern const char kFirstRunConsentActionHistogram[];

// UMA histogram key for IOS.Gemini.Session.PromptCount.
extern const char kSessionPromptCountHistogram[];

// UMA histogram key for IOS.Gemini.Session.FirstPrompt.
extern const char kSessionFirstPromptHistogram[];

// UMA histogram key for IOS.Gemini.Session.TabSwitchCount.
extern const char kSessionTabSwitchCountHistogram[];

// UMA histogram key for IOS.Gemini.Floaty.TimeMinimized.
extern const char kFloatyTimeMinimizedHistogram[];

// UMA histogram key for IOS.Gemini.Floaty.ViewStateTransition.
extern const char kFloatyViewStateTransitionHistogram[];

// UMA histogram key for IOS.Gemini.Floaty.ShownFromSource.
extern const char kFloatyShownFromSourceHistogram[];

// UMA histogram key for IOS.Gemini.Floaty.HiddenFromSource.
extern const char kFloatyHiddenFromSourceHistogram[];

// UMA histogram key for IOS.Gemini.Floaty.DismissedState.
extern const char kFloatyDismissedStateHistogram[];

// UMA histogram key for IOS.Gemini.PageAvailability.
extern const char kGeminiPageAvailabilityHistogram[];

// Enum for the IOS.Gemini.FirstRun.PromoAction and
// IOS.Gemini.FirstRun.ConsentAction histograms.
// LINT.IfChange(IOSGeminiFirstRunAction)
enum class IOSGeminiFirstRunAction {
  kAccept = 0,
  kDismiss = 1,
  kLinkClick = 2,
  kMaxValue = kLinkClick,
};
// LINT.ThenChange(/tools/metrics/histograms/metadata/ios/enums.xml:IOSGeminiFirstRunAction)

// Records the user action on the FRE Promo.
void RecordFirstRunPromoAction(IOSGeminiFirstRunAction action);

// Records the user action on the FRE Consent Screen.
void RecordFirstRunConsentAction(IOSGeminiFirstRunAction action);

// Enum for the IOS.Gemini.Live.FREOutcome histogram.
// LINT.IfChange(IOSGeminiLiveFREOutcome)
enum class IOSGeminiLiveFREOutcome {
  kSuccess = 0,
  kDismissedOnConsent = 1,
  kDeniedOSMicPermission = 2,
  kDeniedChromeMicPermission = 3,
  kMaxValue = kDeniedChromeMicPermission,
};
// LINT.ThenChange(/tools/metrics/histograms/metadata/ios/enums.xml:IOSGeminiLiveFREOutcome)

// Records the final outcome of the Gemini Live FRE flow.
void RecordLiveFREOutcome(IOSGeminiLiveFREOutcome outcome);

// Records that the user tapped the Live button to switch to Live mode.
void RecordLiveButtonTapped();

// Records that a Gemini Live session has started.
void RecordLiveSessionStarted();

// Records native OS microphone prompt events.
void RecordLiveOSMicPromptShown();
void RecordLiveOSMicPromptAllowed();
void RecordLiveOSMicPromptDenied();

// Records in-app Chrome side microphone permission prompt events.
void RecordLiveChromeMicPromptShown();
void RecordLiveChromeMicPromptAllowed();
void RecordLiveChromeMicPromptDenied();

// Records OS settings redirect alert events.
void RecordLiveSettingsRedirectShown();
void RecordLiveSettingsRedirectOpenSettings();
void RecordLiveSettingsRedirectCancel();

// Represents the type of page or WebState when a Gemini session is invoked.
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
// LINT.IfChange(IOSGeminiInvocationPageType)
enum class IOSGeminiInvocationPageType {
  kExtractableWebPage = 0,
  kPdfDocument = 1,
  kNewTabPage = 2,
  kChromeInternalOther = 3,
  kOtherNonExtractable = 4,
  kNoWebState = 5,
  kMaxValue = kNoWebState,
};
// LINT.ThenChange(/tools/metrics/histograms/metadata/ios/enums.xml:IOSGeminiInvocationPageType)

// UMA histogram key for IOS.Gemini.InvocationPageType.
extern const char kGeminiInvocationPageTypeHistogram[];

// Records the type of page when Gemini is invoked.
void RecordGeminiInvocationPageType(IOSGeminiInvocationPageType page_type);

// LINT.IfChange(IOSGeminiPageAvailability)
enum class IOSGeminiPageAvailability {
  kUnavailable = 0,
  kAvailable = 1,
  kSearchResultPage = 2,  // Deprecated
  kMaxValue = kSearchResultPage,
};
// LINT.ThenChange(/tools/metrics/histograms/metadata/ios/enums.xml:IOSGeminiPageAvailability)

// Records the reason why Gemini is available or unavailable for a given page.
void RecordGeminiPageAvailability(IOSGeminiPageAvailability reason);

// Enum for tracking Gemini ineligibility reasons.
// LINT.IfChange(IOSGeminiIneligibilityReason)
enum class IOSGeminiIneligibilityReason {
  kWorkspaceRestricted = 0,
  kChromeEnterpriseDisabled = 1,
  kInsufficientAccountCapability = 2,
  kAccountUnauthenticated = 3,
  kMaxValue = kAccountUnauthenticated
};
// LINT.ThenChange(/tools/metrics/histograms/metadata/ios/enums.xml:IOSGeminiIneligibilityReason)

// UMA histogram key for IOS.Gemini.IneligibilityReason.
extern const char kGeminiIneligibilityReasonHistogram[];

// UMA histogram key for IOS.Gemini.StartupTime.FirstRun.
extern const char kStartupTimeWithFirstRunHistogram[];

// UMA histogram key for IOS.Gemini.StartupTime.NotFirstRun.
extern const char kStartupTimeNoFirstRunHistogram[];

// Enum for tracking session cancellation reasons.
// LINT.IfChange(IOSGeminiSessionCancellationReason)
enum class IOSGeminiSessionCancellationReason {
  kUnknown = 0,
  kStopButtonTapped = 1,
  kOutsideTapped = 2,
  kExpandedStateCloseButtonTapped = 3,
  kCollapsedStateCloseButtonTapped = 4,
  kLoadingStateCloseButtonTapped = 5,
  kMaxValue = kLoadingStateCloseButtonTapped,
};
// LINT.ThenChange(/tools/metrics/histograms/metadata/ios/enums.xml:IOSGeminiSessionCancellationReason)

// Enum for tracking reasons why Gemini Live transitions to dormant mode.
// LINT.IfChange(IOSGeminiDormantReason)
enum class IOSGeminiDormantReason {
  kUnknown = 0,
  kInterruptedByExternalAudio = 1,
  kLowVolumeInBackground = 2,
  kLowVolumeInForeground = 3,
  kInactivityTimeout = 4,
  kLongInteractionTimeout = 5,
  kMovedToBackgroundWhenMicOff = 6,
  kUserStop = 7,
  kUserPause = 8,
  kServerPause = 9,
  kMaxValue = kServerPause,
};
// LINT.ThenChange(/tools/metrics/histograms/metadata/ios/enums.xml:IOSGeminiDormantReason)

// Records the reason for a gemini session cancellation.
void RecordGeminiSessionCancellation(IOSGeminiSessionCancellationReason reason);

// UMA histogram key for IOS.Gemini.Session.CancellationReason.
extern const char kGeminiSessionCancellationHistogram[];

// UMA histogram key for IOS.Gemini.Session.Time.
extern const char kGeminiSessionTimeHistogram[];

// UMA histogram key for IOS.Gemini.SessionLength.WithPrompt.
extern const char kGeminiSessionLengthWithPromptHistogram[];

// UMA histogram key for IOS.Gemini.SessionLength.Abandoned.
extern const char kGeminiSessionLengthAbandonedHistogram[];

// UMA histogram key for IOS.Gemini.SessionLength.FRE.WithPrompt.
extern const char kGeminiSessionLengthFirstRunWithPromptHistogram[];

// UMA histogram key for IOS.Gemini.SessionLength.FRE.Abandoned.
extern const char kGeminiSessionLengthFirstRunAbandonedHistogram[];

// TODO(crbug.com/481711842): Replace this enum with its equivalent defined in
// gemini_constants.h as gemini::InputType.
// Enum for the IOS.Gemini.FirstPrompt.SubmissionMethod histogram.
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
// LINT.IfChange(IOSGeminiFirstPromptSubmissionMethod)
enum class IOSGeminiFirstPromptSubmissionMethod {
  kText = 0,
  kSummarize = 1,
  kCheckThisSite = 2,
  kFindRelatedSites = 3,
  kAskAboutPage = 4,
  kCreateFaq = 5,
  kUnknown = 6,
  kZeroStateSuggestions = 7,
  kWhatCanGeminiDo = 8,
  kDiscoveryCard = 9,
  kOmniboxSummarize = 10,
  kOmniboxPrompt = 11,
  kTransitionToLive = 12,
  kOnboardingWhatCanGeminiDo = 13,
  kOnboardingAskAboutPage = 14,
  kOnboardingSummarize = 15,
  kSuggestedReply = 16,
  kNanoBananaTurnThisPageIntoAComicStrip = 17,
  kNanoBananaMakeAFolkArtIllustration = 18,
  kNanoBananaMakeACustomMiniFigure = 19,
  kNanoBananaGiveMeAGrungeMakeover = 20,
  kNanoBananaTurnThisImageIntoAVintagePostcard = 21,
  kNanoBananaTurnThisImageIntoAWatercolorPainting = 22,
  kNanoBananaMakeThisImageLookLikeInstantFilm = 23,
  kEditMenuPrompt = 24,
  kOnboardingNoIAmDone = 25,
  kOnboardingKeepLearning = 26,
  kAppSwitcherSummarize = 27,
  kMaxValue = kAppSwitcherSummarize,
};
// LINT.ThenChange(
//   /tools/metrics/histograms/metadata/ios/enums.xml:IOSGeminiFirstPromptSubmissionMethod,
//   /ios/chrome/browser/intelligence/bwg/utils/gemini_constants.h:InputType
// )

// UMA histogram key for IOS.Gemini.FirstPrompt.SubmissionMethod.
extern const char kFirstPromptSubmissionMethodHistogram[];

// UMA histogram key for IOS.Gemini.Prompt.SubmissionMethod.
extern const char kPromptSubmissionMethodHistogram[];

// UMA histogram key for IOS.Gemini.Prompt.ImagesAttached.Count.
extern const char kPromptImagesAttachedCountHistogram[];

// UMA histogram key for IOS.Gemini.Prompt.ImageRemix.Enabled.
extern const char kPromptImageRemixEnabledHistogram[];

// UMA histogram key for IOS.Gemini.Prompt.LongPressImage.Included.
extern const char kPromptLongPressImageIncludedHistogram[];

// UMA histogram key for IOS.Gemini.Prompt.ContextAttachment.
extern const char kPromptContextAttachmentHistogram[];

// UMA histogram key for IOS.Gemini.Prompt.TabsAttachedCount.
extern const char kPromptTabsAttachedCountHistogram[];

// UMA histogram key for IOS.Gemini.Prompt.MultiTabUsed.
extern const char kPromptMultiTabUsedHistogram[];

// UMA histogram key for IOS.Gemini.BlockQuerySubmissionWhileLoading.
extern const char kBlockQuerySubmissionWhileLoadingHistogram[];

// UMA histogram key for IOS.Gemini.ShowPageLoadingSnackbarOnOpeningInvocation.
extern const char kShowPageLoadingSnackbarOnOpeningInvocationHistogram[];

// UMA histogram key for IOS.Gemini.Response.GeneratedImage.Included.
extern const char kResponseGeneratedImageIncluded[];

// UMA histogram key for IOS.Gemini.Response.Latency.
extern const char kResponseLatencyHistogram[];

// UMA histogram key for IOS.Gemini.Response.Latency.MultiTabUsed.
extern const char kResponseLatencyMultiTabUsedHistogram[];

// UMA histogram key for IOS.Gemini.Response.Latency.MultiTabNotUsed.
extern const char kResponseLatencyMultiTabNotUsedHistogram[];

// UMA histogram key for IOS.Gemini.Response.Latency.WithContext.
extern const char kResponseLatencyWithContextHistogram[];

// UMA histogram key for IOS.Gemini.Response.Latency.WithoutContext.
extern const char kResponseLatencyWithoutContextHistogram[];

// UMA histogram key for IOS.Gemini.Response.Latency.WithGeneratedImage.
extern const char kResponseLatencyWithGeneratedImageHistogram[];

// UMA histogram key for IOS.Gemini.Response.Latency.WithoutGeneratedImage.
extern const char kResponseLatencyWithoutGeneratedImageHistogram[];

// UMA histogram key for IOS.Gemini.EditMenuPrompt.SelectedText.Length.
extern const char kEditMenuSelectedTextLengthHistogram[];

// UMA histogram key for IOS.Gemini.GlicContextualCue.Decision.
extern const char kGlicContextualCueDecisionHistogram[];

// Represents the completed Gemini session types.
enum class IOSGeminiSessionType {
  kUnknown = 0,
  kWithPrompt = 1,
  kAbandoned = 2,
  kMaxValue = kAbandoned,
};

// TODO(crbug.com/481711842): Replace this enum and its
// gemini_session_delegate.h equivalent with an enum in gemini_constants.h
// Enum for the IOS.Gemini.Feedback histogram.
// LINT.IfChange(IOSGeminiFeedback)
enum class IOSGeminiFeedback {
  kThumbsUp = 0,
  kThumbsDown = 1,
  kMaxValue = kThumbsDown,
};
// LINT.ThenChange(
//    /ios/chrome/browser/intelligence/bwg/model/gemini_session_delegate.h:GeminiFeedbackType,
//    /tools/metrics/histograms/metadata/ios/enums.xml:IOSGeminiFeedback
//)

// UMA histogram key for IOS.Gemini.Feedback.
extern const char kFeedbackHistogram[];

// Enum for the IOS.Gemini.ImageRemix.ContextMenuEntryPoint.AspectRatio.*
// histograms.
// LINT.IfChange(IOSGeminiAspectRatioBucket)
enum class IOSGeminiAspectRatioBucket {
  kUnknown = 0,
  kVeryTall = 1,
  kTall = 2,
  kSlightlyTall = 3,
  kPerfectSquare = 4,
  kSlightlyWide = 5,
  kWide = 6,
  kVeryWide = 7,
  kMaxValue = kVeryWide,
};
// LINT.ThenChange(/tools/metrics/histograms/metadata/ios/enums.xml:IOSGeminiAspectRatioBucket)

// Enum for the IOS.Gemini.CameraFlow.OSCameraAuthorization.InitialStatus
// histogram.
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
// LINT.IfChange(IOSGeminiOSCameraAuthorizationInitialStatus)
enum class IOSGeminiOSCameraAuthorizationInitialStatus {
  kNotDetermined = 0,
  kRestricted = 1,
  kDenied = 2,
  kAuthorized = 3,
  kSourceTypeUnavailable = 4,
  kMaxValue = kSourceTypeUnavailable,
};
// LINT.ThenChange(/tools/metrics/histograms/metadata/ios/enums.xml:IOSGeminiOSCameraAuthorizationInitialStatus)

// UMA histogram key for
// IOS.Gemini.CameraFlow.OSCameraAuthorization.InitialStatus.
extern const char kCameraFlowOSCameraAuthorizationInitialStatusHistogram[];

// Enum for the IOS.Gemini.CameraFlow.OSCameraAuthorization.Result histogram.
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
// LINT.IfChange(IOSGeminiCameraFlowOSCameraAuthorizationResult)
enum class IOSGeminiCameraFlowOSCameraAuthorizationResult {
  kGranted = 0,
  kDenied = 1,
  kMaxValue = kDenied,
};
// LINT.ThenChange(/tools/metrics/histograms/metadata/ios/enums.xml:IOSGeminiCameraFlowOSCameraAuthorizationResult)

// UMA histogram key for
// IOS.Gemini.CameraFlow.OSCameraAuthorizationRequest.Result.
extern const char kCameraFlowOSAuthorizationRequestResultHistogram[];

// Enum for the IOS.Gemini.CameraFlow.GoToOSSettingsAlert.Result histogram.
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
// LINT.IfChange(IOSGeminiGoToOSSettingsAlertResult)
enum class IOSGeminiGoToOSSettingsAlertResult {
  kGoToSettings = 0,
  kNoThanks = 1,
  kMaxValue = kNoThanks,
};
// LINT.ThenChange(/tools/metrics/histograms/metadata/ios/enums.xml:IOSGeminiGoToOSSettingsAlertResult)

// UMA histogram key for
// IOS.Gemini.CameraFlow.GoToOSSettingsAlert.Result.
extern const char kCameraFlowGoToOSSettingsAlertResultHistogram[];

// UMA histogram key for
// IOS.Gemini.CameraFlow.GeminiCameraPermission.InitialValue.
extern const char kCameraFlowGeminiCameraPermissionInitialValueHistogram[];

// Enum for the IOS.Gemini.CameraFlow.GeminiCameraPermissionAlert.Result
// histogram.
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
// LINT.IfChange(IOSGeminiCameraPermissionAlertResult)
enum class IOSGeminiCameraPermissionAlertResult {
  kAllow = 0,
  kDontAllow = 1,
  kMaxValue = kDontAllow,
};
// LINT.ThenChange(/tools/metrics/histograms/metadata/ios/enums.xml:IOSGeminiCameraPermissionAlertResult)

// UMA histogram key for
// IOS.Gemini.CameraFlow.GeminiCameraPermissionAlert.Result.
extern const char kCameraFlowGeminiCameraPermissionAlertResultHistogram[];

// Enum for the IOS.Gemini.CameraFlow.CameraPicker.Result histogram.
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
// LINT.IfChange(IOSGeminiCameraPickerResult)
enum class IOSGeminiCameraPickerResult {
  kCancelled = 0,
  kFinishedWithoutImage = 1,
  kFinishedWithImage = 2,
  kMaxValue = kFinishedWithImage,
};
// LINT.ThenChange(/tools/metrics/histograms/metadata/ios/enums.xml:IOSGeminiCameraPickerResult)

// UMA histogram key for
// IOS.Gemini.CameraFlow.CameraPicker.Result.
extern const char kCameraFlowCameraPickerResultHistogram[];

// UMA histogram key for
// IOS.Gemini.ImageRemix.ContextMenuEntryPoint.AspectRatio.Tapped.
extern const char kImageRemixContextMenuEntryPointAspectRatioTappedHistogram[];

// UMA histogram key for IOS.Gemini.ImageActionButton.
extern const char kImageActionButtonHistogram[];

// UMA histogram key for IOS.Gemini.InputPlateAttachmentOption.
extern const char kInputPlateAttachmentOptionHistogram[];

// Records that an image action button was tapped.
void RecordGeminiImageActionButtonTapped(gemini::ImageActionButtonType type);

// Records that an input plate attachment option was tapped.
void RecordGeminiInputPlateAttachmentOptionTapped(
    gemini::InputPlateAttachmentOption option);

// Records that the Image Remix context menu entry point was shown.
void RecordImageRemixContextMenuEntryPointShown();

// Records that the Image Remix context menu entry point was tapped with the
// given image aspect ratio.
void RecordImageRemixContextMenuEntryPointTapped(double aspect_ratio);

// Records user feedback on a Gemini response.
void RecordGeminiFeedback(IOSGeminiFeedback feedback);

// Records that the Gemini session/floaty UI was successfully opened.
void RecordGeminiSessionOpened();

// Records the duration of a Gemini session.
void RecordGeminiSessionTime(base::TimeDelta session_duration);

// Records the duration of a Gemini session by type of session.
void RecordGeminiSessionLengthByType(base::TimeDelta session_duration,
                                     bool is_first_run,
                                     IOSGeminiSessionType session_type);

// Records when user sees the Gemini entry point impression.
// Can be called once every 10 minutes to avoid spam logging.
void RecordGeminiEntryPointImpression(gemini::EntryPoint entry_point);

// Records when the sign-in required snackbar is shown.
void RecordSignInRequiredSnackbarShown(gemini::EntryPoint entry_point);

// Records when the Gemini entry point is available to the user.
// Only used for entry points that are not available on almost all pages.
// For example the edit menu entry point is only available once the user has
// selected some text, and is eligible to use the feature.
void RecordGeminiEntryPointAvailable(gemini::EntryPoint entry_point);

// Records that the Gemini FRE was shown.
void RecordFirstRunShown();

// Records user action for first response received.
void RecordFirstResponseReceived();

// Records that the user submitted their first prompt.
void RecordFirstPromptSubmission(IOSGeminiFirstPromptSubmissionMethod method);

// Records the submission method for any prompt.
void RecordPromptSubmissionMethod(IOSGeminiFirstPromptSubmissionMethod method);

// Records that the user received a response from Gemini with a boolean
// indicating whether a generated image was included in the response.
void RecordGeminiResponseReceived(bool generated_image_included);

// Records that the user tapped the "Get Started" button on the Gemini FRE promo
// screen.
void RecordFirstRunPromoAccept();

// Records that the user tapped the "Cancel" button on the Gemini FRE promo
// screen.
void RecordFirstRunPromoDismiss();

// Records that the user accepted the Gemini FRE consent.
void RecordFirstRunConsentAccept();

// Records that the user dismissed the Gemini FRE consent.
void RecordFirstRunConsentDismiss();

// Records that the user clicked a link on the Gemini FRE consent screen.
void RecordFirstRunConsentLinkClick();

// Records that the Tab Picker was opened.
void RecordGeminiTabPickerOpened();

// Records that the Tab Picker was dismissed.
void RecordGeminiTabPickerDismissed();

// Records that the tab attachment limit error snackbar was shown in the Tab
// Picker.
void RecordGeminiTabPickerErrorAttachmentLimit();

// Records that the cannot reload tab error snackbar was shown in the Tab
// Picker.
void RecordGeminiTabPickerErrorCannotReloadTab();

// Records that the cannot attach tab error snackbar was shown in the Tab
// Picker.
void RecordGeminiTabPickerErrorCannotAttachTab();

// Records that a shared (non-active) tab was detached from a Floaty chip in the
// Gemini session.
void RecordGeminiTabDetached();

// Records that the active tab was attached from a Floaty chip in the Gemini
// session.
void RecordGeminiActiveTabAttached();

// Records that the active tab was detached from a Floaty chip in the Gemini
// session.
void RecordGeminiActiveTabDetached();

// Records the latency from prompt submission to response received, including
// metadata about the prompt & response.
void RecordResponseLatency(base::TimeDelta latency,
                           bool had_page_context,
                           bool had_generated_image,
                           bool was_multi_tab_used);

// Records the total number of prompts sent in a Gemini session.
void RecordSessionPromptCount(int prompt_count);

// Records if a first prompt was sent in a Gemini session.
void RecordSessionFirstPrompt(bool had_first_prompt);

// Records the total number of tab switches during a floaty session.
void RecordSessionTabSwitchCount(int tab_switch_count);

// Enum for the IOS.Gemini.ViewStateTransition histogram.
// LINT.IfChange(IOSGeminiViewStateTransition)
enum class IOSGeminiViewStateTransition {
  kUnknown = 0,
  kCollapsedToExpanded = 1,
  kExpandedToCollapsed = 2,
  kHiddenToCollapsed = 3,
  kHiddenToExpanded = 4,
  kMaxValue = kHiddenToExpanded,
};
// LINT.ThenChange(/tools/metrics/histograms/metadata/ios/enums.xml:IOSGeminiViewStateTransition)

// Records the floaty transition from expanded to collapsed.
void RecordFloatyExpandedToCollapsed();

// Records the floaty transition from collapsed to expanded.
void RecordFloatyCollapsedToExpanded();

// Records the floaty dismissing with the given state.
void RecordFloatyDismissedState(ios::provider::GeminiViewState state);

// Records the length of time a floaty is minimized until it is expanded.
void RecordFloatyMinimizedTime(base::TimeTicks elapsed_minimized_floaty_time);

// Records whether a Gemini eligibility check was successful.
void RecordGeminiEligibility(bool eligible);

// Records the First Run state for Gemini.
void RecordGeminiFirstRunState(gemini::FirstRunState state);

// Records all of the Gemini ineligibility reasons. One record will be sent at
// most per associated value of IOSGeminiIneligibilityReason.
void RecordGeminiIneligibilityReasons(gemini::IneligibilityReasons reasons);

// Records the Gemini floaty view state transition.
void RecordGeminiViewStateTransition(IOSGeminiViewStateTransition transition);

// Records the `view_state` that will be shown from the hidden state.
void RecordGeminiViewStateHiddenToShown(
    ios::provider::GeminiViewState view_state);

// Records the floaty being shown from the `source` that triggered the call.
void RecordFloatyShownFromSource(gemini::FloatyUpdateSource source);

// Records the floaty being hidden from the `source` that triggered the call.
void RecordFloatyHiddenFromSource(gemini::FloatyUpdateSource source);

// Records that the user clicked a URL in a Gemini session.
void RecordURLOpened();

// Records entry point metrics with context about whether FRE is shown.
void RecordGeminiEntryPointClick(gemini::EntryPoint entry_point,
                                 bool is_fre_flow);

// Records that the user tapped the new chat button in a Gemini session.
void RecordGeminiNewChatButtonTapped();

// Records that the user tapped the regenerate button in the Gemini floaty.
void RecordGeminiRegenerateButtonTapped(gemini::RegenerateOptionType option);

// Records that the AI Hub new badge was tapped.
void RecordAIHubNewBadgeTapped();

// Records that the AI Hub icon was tapped.
void RecordAIHubIconTapped();

// Records that the user sent a prompt in a Gemini session. Includes parameters
// for histogram metrics.
void RecordGeminiPromptSent(bool is_nano_banana_enabled,
                            int images_attached_count,
                            bool long_press_image_included,
                            bool has_page_context,
                            int tabs_attached_count,
                            bool was_multi_tab_used);

// Records the result of an OS-level camera authorization request.
void RecordGeminiCameraFlowOSAuthorizationResult(bool granted);

// Records the result of the alert directing users to OS settings.
void RecordGeminiCameraFlowGoToOSSettingsAlertResult(bool accepted);

// Records the result of the Gemini camera permission alert.
void RecordGeminiCameraFlowGeminiCameraPermissionAlertResult(bool accepted);

// Records that the Gemini camera flow began.
void RecordGeminiCameraFlowBegan();

// Records the initial OS camera authorization status value.
void RecordGeminiCameraFlowOSCameraAuthorizationInitialStatus(
    IOSGeminiOSCameraAuthorizationInitialStatus authorization_status);

// Records the initial Gemini camera permission value.
void RecordGeminiCameraFlowGeminiCameraPermissionInitialValue(bool enabled);

// Records that the camera picker was presented.
void RecordGeminiCameraFlowPresentCameraPicker();

// Records the result of the camera picker.
void RecordGeminiCameraFlowCameraPickerResult(
    IOSGeminiCameraPickerResult result);

// Records the length of the selected text in the edit menu.
void RecordGeminiEditMenuSelectedTextLength(int length);

// Records the glic contextual cue decision for Gemini.
void RecordGeminiGlicContextualCueDecision(
    optimization_guide::OptimizationGuideDecision decision);

// Records the dormant reason when Gemini Live transitions to dormant mode.
void RecordGeminiLiveDormantReason(ios::provider::GeminiDormantReason reason);

// Records the response latency (time Gemini takes to respond between thinking
// and responding).
void RecordGeminiLiveResponseLatency(base::TimeDelta latency);

// Records the response duration (how long the spoken response lasted,
// recorded only if the response finished naturally).
void RecordGeminiLiveResponseDuration(base::TimeDelta duration);

// Records the turn count at the end of the session. A turn is defined as the
// cycle of the user speaking and Gemini responding.
void RecordGeminiLiveTurnCount(int turn_count);

// Records the accumulated duration of Gemini Live mode segments within
// a single Gemini interaction.
void RecordGeminiLiveAccumulatedDuration(base::TimeDelta duration);

// Records whether query submission is blocked while page context is loading.
void RecordBlockQuerySubmissionWhileLoading(bool block_submission);

// Records whether to display the page loading snackbar on the opening
// invocation while page context is loading.
void RecordShowPageLoadingSnackbarOnOpeningInvocation(bool show_snackbar);

#endif  // IOS_CHROME_BROWSER_INTELLIGENCE_BWG_METRICS_GEMINI_METRICS_H_
