File: lens_overlay_metrics.cc

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (532 lines) | stat: -rw-r--r-- 23,145 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/lens/lens_overlay_metrics.h"

#include <cstddef>

#include "base/metrics/histogram_functions.h"
#include "base/metrics/user_metrics.h"
#include "base/time/time.h"
#include "components/lens/lens_features.h"
#include "components/lens/lens_overlay_mime_type.h"
#include "services/metrics/public/cpp/ukm_builders.h"

namespace lens {

std::string InvocationSourceToString(
    LensOverlayInvocationSource invocation_source) {
  switch (invocation_source) {
    case LensOverlayInvocationSource::kAppMenu:
      return "AppMenu";
    case LensOverlayInvocationSource::kContentAreaContextMenuPage:
      return "ContentAreaContextMenuPage";
    case LensOverlayInvocationSource::kContentAreaContextMenuImage:
      return "ContentAreaContextMenuImage";
    case LensOverlayInvocationSource::kToolbar:
      return "Toolbar";
    case LensOverlayInvocationSource::kFindInPage:
      return "FindInPage";
    case LensOverlayInvocationSource::kOmnibox:
      return "Omnibox";
    case LensOverlayInvocationSource::kLVFShutterButton:
      return "LVFShutterButton";
    case LensOverlayInvocationSource::kLVFGallery:
      return "LVFGallery";
    case LensOverlayInvocationSource::kContextMenu:
      return "ContextMenu";
    case LensOverlayInvocationSource::kOmniboxPageAction:
      return "OmniboxPageAction";
    case LensOverlayInvocationSource::kOmniboxContextualSuggestion:
      return "OmniboxContextualSuggestion";
    case LensOverlayInvocationSource::kHomeworkActionChip:
      return "HomeworkActionChip";
    case LensOverlayInvocationSource::kAIHub:
      return "AIHub";
    case LensOverlayInvocationSource::kFREPromo:
      return "FREPromo";
  }
}

std::string FirstInteractionTypeToString(
    LensOverlayFirstInteractionType interaction_type) {
  switch (interaction_type) {
    case LensOverlayFirstInteractionType::kPermissionDialog:
      return "Permission";
    case LensOverlayFirstInteractionType::kLensMenu:
      return "LensMenu";
    case LensOverlayFirstInteractionType::kRegionSelect:
      return "RegionSelect";
    case LensOverlayFirstInteractionType::kTextSelect:
      return "TextSelect";
    case LensOverlayFirstInteractionType::kSearchbox:
      return "Searchbox";
  }
}

std::string MimeTypeToMetricString(lens::MimeType mime_type) {
  switch (mime_type) {
    case lens::MimeType::kPdf:
      return "Pdf";
    case lens::MimeType::kHtml:
      return "Html";
    case lens::MimeType::kPlainText:
      return "PlainText";
    case lens::MimeType::kAnnotatedPageContent:
      return "AnnotatedPageContent";
    case lens::MimeType::kImage:
      return "Image";
    case lens::MimeType::kVideo:
      return "Video";
    case lens::MimeType::kAudio:
      return "Audio";
    case lens::MimeType::kJson:
      return "Json";
    default:
      return "Unknown";
  }
}

void RecordPermissionRequestedToBeShown(
    bool shown,
    LensOverlayInvocationSource invocation_source) {
  base::UmaHistogramBoolean("Lens.Overlay.PermissionBubble.Shown", shown);
  const auto histogram_name =
      "Lens.Overlay.PermissionBubble.ByInvocationSource." +
      InvocationSourceToString(invocation_source) + ".Shown";
  base::UmaHistogramBoolean(histogram_name, shown);
}

void RecordPermissionUserAction(LensPermissionUserAction user_action,
                                LensOverlayInvocationSource invocation_source) {
  base::UmaHistogramEnumeration("Lens.Overlay.PermissionBubble.UserAction",
                                user_action);
  const auto histogram_name =
      "Lens.Overlay.PermissionBubble.ByInvocationSource." +
      InvocationSourceToString(invocation_source) + ".UserAction";
  base::UmaHistogramEnumeration(histogram_name, user_action);
}

void RecordInvocation(LensOverlayInvocationSource invocation_source,
                      lens::MimeType document_content_type) {
  base::UmaHistogramEnumeration("Lens.Overlay.Invoked", invocation_source);

  // UMA Invocation sliced by document type.
  const auto sliced_invoked_histogram_name =
      "Lens.Overlay.ByDocumentType." +
      MimeTypeToMetricString(document_content_type) + ".Invoked";
  base::UmaHistogramBoolean(sliced_invoked_histogram_name, true);
}

void RecordDismissal(LensOverlayDismissalSource dismissal_source) {
  base::UmaHistogramEnumeration("Lens.Overlay.Dismissed", dismissal_source);
}

void RecordInvocationResultedInSearch(
    LensOverlayInvocationSource invocation_source,
    bool search_performed_in_session) {
  // UMA unsliced InvocationResultedInSearch.
  base::UmaHistogramBoolean("Lens.Overlay.InvocationResultedInSearch",
                            search_performed_in_session);

  // UMA InvocationResultedInSearch sliced by entry point.
  const auto sliced_search_performed_histogram_name =
      "Lens.Overlay.ByInvocationSource." +
      InvocationSourceToString(invocation_source) +
      ".InvocationResultedInSearch";
  base::UmaHistogramBoolean(sliced_search_performed_histogram_name,
                            search_performed_in_session);
}

void RecordSessionDuration(LensOverlayInvocationSource invocation_source,
                           base::TimeDelta duration) {
  // UMA unsliced session duration.
  base::UmaHistogramCustomTimes("Lens.Overlay.SessionDuration", duration,
                                /*min=*/base::Milliseconds(1),
                                /*max=*/base::Minutes(10), /*buckets=*/50);

  // UMA session duration sliced by entry point.
  const auto sliced_session_duration_histogram_name =
      "Lens.Overlay.ByInvocationSource." +
      InvocationSourceToString(invocation_source) + ".SessionDuration";
  base::UmaHistogramCustomTimes(sliced_session_duration_histogram_name,
                                duration,
                                /*min=*/base::Milliseconds(1),
                                /*max=*/base::Minutes(10), /*buckets=*/50);
}

void RecordContextualSearchboxSessionEndMetrics(
    ukm::SourceId source_id,
    ContextualSearchboxSessionEndMetrics session_end_metrics,
    lens::MimeType page_content_type,
    lens::MimeType document_content_type) {
  // UMA contextual searchbox shown in session.
  base::UmaHistogramBoolean("Lens.Overlay.ContextualSearchBox.ShownInSession",
                            session_end_metrics.searchbox_shown_);

  // UMA contextual searchbox shown in session sliced by page content type.
  const auto sliced_page_content_invoked_histogram_name =
      "Lens.Overlay.ContextualSearchBox.ByPageContentType." +
      MimeTypeToMetricString(page_content_type) + ".ShownInSession";
  base::UmaHistogramBoolean(sliced_page_content_invoked_histogram_name,
                            session_end_metrics.searchbox_shown_);

  // UMA contextual searchbox shown in session sliced by document type.
  const auto sliced_document_invoked_histogram_name =
      "Lens.Overlay.ContextualSearchBox.ByDocumentType." +
      MimeTypeToMetricString(document_content_type) + ".ShownInSession";
  base::UmaHistogramBoolean(sliced_document_invoked_histogram_name,
                            session_end_metrics.searchbox_shown_);

  // Record UKM for contextual search box shown in session.
  if (source_id != ukm::kInvalidSourceId) {
    ukm::builders::Lens_Overlay_ContextualSearchBox_ShownInSession event(
        source_id);
    event.SetWasShown(session_end_metrics.searchbox_shown_)
        .SetPageContentType(static_cast<int64_t>(page_content_type))
        .Record(ukm::UkmRecorder::Get());
  }

  // Don't record the rest of the contextual searchbox metrics if it was not
  // shown in the session.
  if (!session_end_metrics.searchbox_shown_) {
    return;
  }

  // UMA contextual searchbox focused in session.
  base::UmaHistogramBoolean("Lens.Overlay.ContextualSearchBox.FocusedInSession",
                            session_end_metrics.searchbox_focused_);
  // UMA contextual searchbox focused in session sliced by document type.
  const auto sliced_focused_histogram_name =
      "Lens.Overlay.ContextualSearchBox.ByPageContentType." +
      MimeTypeToMetricString(page_content_type) + ".FocusedInSession";
  base::UmaHistogramBoolean(sliced_focused_histogram_name,
                            session_end_metrics.searchbox_focused_);

  bool zps_shown_in_session =
      session_end_metrics.zps_shown_on_initial_query_ ||
      session_end_metrics.zps_shown_on_follow_up_query_;
  // UMA contextual zps shown in session.
  base::UmaHistogramBoolean("Lens.Overlay.ContextualSuggest.ZPS.ShownInSession",
                            zps_shown_in_session);
  // UMA contextual zps shown in session sliced by document type.
  const auto sliced_contextual_zps_histogram_name =
      "Lens.Overlay.ContextualSuggest.ZPS.ByPageContentType." +
      MimeTypeToMetricString(page_content_type) + ".ShownInSession";
  base::UmaHistogramBoolean(sliced_contextual_zps_histogram_name,
                            zps_shown_in_session);

  // UMA contextual zps used in session.
  base::UmaHistogramBoolean(
      "Lens.Overlay.ContextualSuggest.ZPS.SuggestionUsedInSession",
      session_end_metrics.zps_used_);
  // UMA contextual zps used in session sliced by document type.
  const auto sliced_contextual_zps_used_histogram_name =
      "Lens.Overlay.ContextualSuggest.ZPS.ByPageContentType." +
      MimeTypeToMetricString(page_content_type) + ".SuggestionUsedInSession";
  base::UmaHistogramBoolean(sliced_contextual_zps_used_histogram_name,
                            session_end_metrics.zps_used_);

  // UMA contextual query issued in session.
  base::UmaHistogramBoolean(
      "Lens.Overlay.ContextualSuggest.QueryIssuedInSession",
      session_end_metrics.query_issued_);
  // UMA contextual query issued in session sliced by document type.
  const auto sliced_contextual_query_issued_histogram_name =
      "Lens.Overlay.ContextualSuggest.ByPageContentType." +
      MimeTypeToMetricString(page_content_type) + ".QueryIssuedInSession";
  base::UmaHistogramBoolean(sliced_contextual_query_issued_histogram_name,
                            session_end_metrics.query_issued_);

  // Only record the contextual query issued before zps shown metrics if a
  // contextual query was issued in the session.
  if (session_end_metrics.query_issued_) {
    // UMA initial contextual query issued before zps shown in session.
    base::UmaHistogramBoolean(
        "Lens.Overlay.ContextualSuggest.InitialQuery."
        "QueryIssuedInSessionBeforeSuggestShown",
        session_end_metrics.initial_query_issued_before_zps_shown_);
    // UMA initial contextual query issued before zps shown in session sliced by
    // page content type.
    const auto
        sliced_contextual_query_issued_before_zps_shown_initial_histogram_name =
            "Lens.Overlay.ContextualSuggest.InitialQuery.ByPageContentType." +
            MimeTypeToMetricString(page_content_type) +
            ".QueryIssuedInSessionBeforeSuggestShown";
    base::UmaHistogramBoolean(
        sliced_contextual_query_issued_before_zps_shown_initial_histogram_name,
        session_end_metrics.initial_query_issued_before_zps_shown_);
  }

  if (session_end_metrics.follow_up_query_issued_) {
    // UMA follow up contextual query issued before zps shown in session.
    base::UmaHistogramBoolean(
        "Lens.Overlay.ContextualSuggest.FollowUpQuery."
        "QueryIssuedInSessionBeforeSuggestShown",
        session_end_metrics.follow_up_query_issued_before_zps_shown_);
    // UMA initial contextual query issued before zps shown in session sliced by
    // page content type.
    const auto
        sliced_contextual_query_issued_before_zps_shown_follow_up_histogram_name =
            "Lens.Overlay.ContextualSuggest.FollowUpQuery.ByPageContentType." +
            MimeTypeToMetricString(page_content_type) +
            ".QueryIssuedInSessionBeforeSuggestShown";
    base::UmaHistogramBoolean(
        sliced_contextual_query_issued_before_zps_shown_follow_up_histogram_name,
        session_end_metrics.follow_up_query_issued_before_zps_shown_);
  }

  if (source_id == ukm::kInvalidSourceId) {
    return;
  }

  // UKM contextual searchbox focused in session.
  ukm::builders::Lens_Overlay_ContextualSearchbox_FocusedInSession(source_id)
      .SetFocusedInSession(session_end_metrics.searchbox_focused_)
      .SetPageContentType(static_cast<int64_t>(page_content_type))
      .Record(ukm::UkmRecorder::Get());

  // UKM contextual zps shown in session.
  ukm::builders::Lens_Overlay_ContextualSuggest_ZPS_ShownInSession(source_id)
      .SetShownInSession(zps_shown_in_session)
      .SetPageContentType(static_cast<int64_t>(page_content_type))
      .Record(ukm::UkmRecorder::Get());

  // UKM contextual zps used in session.
  ukm::builders::Lens_Overlay_ContextualSuggest_ZPS_SuggestionUsedInSession(
      source_id)
      .SetSuggestionUsedInSession(session_end_metrics.zps_used_)
      .SetPageContentType(static_cast<int64_t>(page_content_type))
      .Record(ukm::UkmRecorder::Get());

  // UKM contextual query issued in session.
  ukm::builders::Lens_Overlay_ContextualSuggest_QueryIssuedInSession(source_id)
      .SetQueryIssuedInSession(session_end_metrics.query_issued_)
      .SetPageContentType(static_cast<int64_t>(page_content_type))
      .Record(ukm::UkmRecorder::Get());
}

void RecordSessionForegroundDuration(
    LensOverlayInvocationSource invocation_source,
    base::TimeDelta duration) {
  // UMA unsliced session duration.
  base::UmaHistogramCustomTimes("Lens.Overlay.SessionForegroundDuration",
                                duration,
                                /*min=*/base::Milliseconds(1),
                                /*max=*/base::Minutes(10), /*buckets=*/50);

  // UMA session duration sliced by entry point.
  const auto sliced_session_duration_histogram_name =
      "Lens.Overlay.ByInvocationSource." +
      InvocationSourceToString(invocation_source) +
      ".SessionForegroundDuration";
  base::UmaHistogramCustomTimes(sliced_session_duration_histogram_name,
                                duration,
                                /*min=*/base::Milliseconds(1),
                                /*max=*/base::Minutes(10), /*buckets=*/50);
}

void RecordTimeToFirstInteraction(
    LensOverlayInvocationSource invocation_source,
    base::TimeDelta time_to_first_interaction,
    LensOverlayFirstInteractionType first_interaction_type,
    ukm::SourceId source_id) {
  // UMA unsliced TimeToFirstInteraction.
  base::UmaHistogramCustomTimes("Lens.Overlay.TimeToFirstInteraction",
                                time_to_first_interaction,
                                /*min=*/base::Milliseconds(1),
                                /*max=*/base::Minutes(10), /*buckets=*/50);
  // UMA TimeToFirstInteraction sliced by entry point.
  const auto sliced_time_to_first_interaction_histogram_name =
      "Lens.Overlay.ByInvocationSource." +
      InvocationSourceToString(invocation_source) + ".TimeToFirstInteraction";
  base::UmaHistogramCustomTimes(sliced_time_to_first_interaction_histogram_name,
                                time_to_first_interaction,
                                /*min=*/base::Milliseconds(1),
                                /*max=*/base::Minutes(10), /*buckets=*/50);

  // UMA TimeToFirstInteraction sliced by interaction type.
  const auto interaction_type_histogram_name =
      "Lens.Overlay.TimeToFirstInteraction." +
      FirstInteractionTypeToString(first_interaction_type);

  base::UmaHistogramCustomTimes(interaction_type_histogram_name,
                                time_to_first_interaction,
                                /*min=*/base::Milliseconds(1),
                                /*max=*/base::Minutes(10), /*buckets=*/50);

  if (source_id == ukm::kInvalidSourceId) {
    return;
  }

  // UKM unsliced TimeToFirstInteraction.
  ukm::builders::Lens_Overlay_TimeToFirstInteraction(source_id)
      .SetAllEntryPoints(time_to_first_interaction.InMilliseconds())
      .SetFirstInteractionType(static_cast<int64_t>(first_interaction_type))
      .Record(ukm::UkmRecorder::Get());
  // UKM TimeToFirstInteraction sliced by entry point.
  ukm::builders::Lens_Overlay_TimeToFirstInteraction event(source_id);
  switch (invocation_source) {
    case lens::LensOverlayInvocationSource::kAppMenu:
      event.SetAppMenu(time_to_first_interaction.InMilliseconds());
      break;
    case lens::LensOverlayInvocationSource::kContentAreaContextMenuPage:
      event.SetContentAreaContextMenuPage(
          time_to_first_interaction.InMilliseconds());
      break;
    case lens::LensOverlayInvocationSource::kContentAreaContextMenuImage:
      // Not recorded since the image menu entry point results in a search
      // without the user having to interact with the overlay. Time to first
      // interaction in this case is essentially zero.
      break;
    case LensOverlayInvocationSource::kLVFShutterButton:
    case LensOverlayInvocationSource::kLVFGallery:
    case LensOverlayInvocationSource::kContextMenu:
      // Not recorded since for LVF and context menu invocation the first
      // interaction is done automatically by autoselection.
      break;
    case lens::LensOverlayInvocationSource::kToolbar:
      event.SetToolbar(time_to_first_interaction.InMilliseconds());
      break;
    case lens::LensOverlayInvocationSource::kFindInPage:
      event.SetFindInPage(time_to_first_interaction.InMilliseconds());
      break;
    case lens::LensOverlayInvocationSource::kOmnibox:
    case lens::LensOverlayInvocationSource::kAIHub:
      event.SetOmnibox(time_to_first_interaction.InMilliseconds());
      break;
    case lens::LensOverlayInvocationSource::kOmniboxPageAction:
      event.SetOmniboxPageAction(time_to_first_interaction.InMilliseconds());
      break;
    case lens::LensOverlayInvocationSource::kOmniboxContextualSuggestion:
      event.SetOmniboxContextualSuggestion(
          time_to_first_interaction.InMilliseconds());
      break;
    case lens::LensOverlayInvocationSource::kFREPromo:
      // First interaction for Lens Overlay is already recorded and sliced by invocation
      // source.
      break;
    case lens::LensOverlayInvocationSource::kHomeworkActionChip:
      event.SetHomeworkActionChip(time_to_first_interaction.InMilliseconds());
      break;
  }
  event.SetFirstInteractionType(static_cast<int64_t>(first_interaction_type))
      .Record(ukm::UkmRecorder::Get());
}

void RecordNewTabGenerated(LensOverlayNewTabSource tab_source) {
  base::UmaHistogramEnumeration("Lens.Overlay.GeneratedTab", tab_source);
}

void RecordGeneratedTabCount(int generated_tab_count) {
  base::UmaHistogramCounts100("Lens.Overlay.GeneratedTab.SessionCount",
                              generated_tab_count);
}

void RecordUKMSessionEndMetrics(
    ukm::SourceId source_id,
    LensOverlayInvocationSource invocation_source,
    bool search_performed_in_session,
    base::TimeDelta session_duration,
    lens::MimeType document_content_type,
    std::optional<base::TimeDelta> session_foreground_duration,
    std::optional<int> generated_tab_count) {
  if (source_id == ukm::kInvalidSourceId) {
    return;
  }
  ukm::builders::Lens_Overlay_SessionEnd event(source_id);

  if (session_foreground_duration.has_value()) {
    event.SetSessionForegroundDuration(
        session_foreground_duration->InMilliseconds());
  }
  if (generated_tab_count.has_value()) {
    event.SetGeneratedTabCount(*generated_tab_count);
  }

  event.SetInvocationSource(static_cast<int64_t>(invocation_source))
      .SetInvocationResultedInSearch(search_performed_in_session)
      .SetSessionDuration(session_duration.InMilliseconds())
      .SetInvocationDocumentType(static_cast<int64_t>(document_content_type))
      .Record(ukm::UkmRecorder::Get());
}

void RecordLensResponseTime(base::TimeDelta response_time) {
  base::UmaHistogramTimes("Lens.Overlay.LensResponseTime", response_time);
}

void RecordContextualSearchboxTimeToFirstFocus(
    base::TimeDelta time_to_focus,
    lens::MimeType page_content_type) {
  const auto sliced_time_to_interaction_histogram_name =
      "Lens.Overlay.ContextualSearchBox.ByPageContentType." +
      MimeTypeToMetricString(page_content_type) +
      ".TimeFromInvocationToFirstFocus";
  base::UmaHistogramCustomTimes(sliced_time_to_interaction_histogram_name,
                                time_to_focus,
                                /*min=*/base::Milliseconds(1),
                                /*max=*/base::Minutes(5), /*buckets=*/50);
}

void RecordContextualSearchboxTimeToFocusAfterNavigation(
    base::TimeDelta time_to_focus,
    lens::MimeType page_content_type) {
  const auto sliced_time_to_interaction_histogram_name =
      "Lens.Overlay.ContextualSearchBox.ByPageContentType." +
      MimeTypeToMetricString(page_content_type) +
      ".TimeFromNavigationToFirstFocus";
  base::UmaHistogramCustomTimes(sliced_time_to_interaction_histogram_name,
                                time_to_focus,
                                /*min=*/base::Milliseconds(1),
                                /*max=*/base::Minutes(10), /*buckets=*/50);
}

void RecordContextualSearchboxTimeToInteractionAfterNavigation(
    base::TimeDelta time_to_interaction,
    lens::MimeType page_content_type) {
  const auto sliced_time_to_interaction_histogram_name =
      "Lens.Overlay.ContextualSearchBox.ByPageContentType." +
      MimeTypeToMetricString(page_content_type) +
      ".TimeFromNavigationToFirstInteraction";
  base::UmaHistogramCustomTimes(sliced_time_to_interaction_histogram_name,
                                time_to_interaction,
                                /*min=*/base::Milliseconds(1),
                                /*max=*/base::Minutes(10), /*buckets=*/50);
}

void RecordDocumentSizeBytes(lens::MimeType page_content_type,
                             size_t document_size_bytes) {
  const auto sliced_invoked_histogram_name =
      "Lens.Overlay.ByPageContentType." +
      MimeTypeToMetricString(page_content_type) + ".DocumentSize2";
  base::UmaHistogramCustomCounts(sliced_invoked_histogram_name,
                                 document_size_bytes / 1000, 1, 100000, 100);
}

void RecordPdfPageCount(uint32_t page_count) {
  base::UmaHistogramCounts10000("Lens.Overlay.ByPageContentType.Pdf.PageCount",
                               page_count);
}

void RecordOcrDomSimilarity(double similarity) {
  base::UmaHistogramPercentage("Lens.Overlay.OcrDomSimilarity",
                               similarity * 100);
}

void RecordSidePanelResultStatus(SidePanelResultStatus status) {
  base::UmaHistogramEnumeration("Lens.Overlay.SidePanelResultStatus", status);
}

void RecordSidePanelMenuOptionSelected(
    lens::LensOverlaySidePanelMenuOption menu_option) {
  base::UmaHistogramEnumeration(
      "Lens.Overlay.SidePanel.SelectedMoreInfoMenuOption", menu_option);
}

void RecordHandleTextDirectiveResult(
    lens::LensOverlayTextDirectiveResult result) {
  base::UmaHistogramEnumeration("Lens.Overlay.TextDirectiveResult", result);
}

}  // namespace lens