Event.kt 23.2 KB
Newer Older
1
2
3
/* 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
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4

5
6
package org.mozilla.fenix.components.metrics

7
import android.content.Context
8
import mozilla.components.browser.errorpages.ErrorType
9
import mozilla.components.browser.state.search.SearchEngine
10
import mozilla.components.feature.top.sites.TopSite
11
import org.mozilla.fenix.GleanMetrics.Addons
12
import org.mozilla.fenix.GleanMetrics.AppTheme
13
import org.mozilla.fenix.GleanMetrics.Autoplay
14
15
16
17
18
import org.mozilla.fenix.GleanMetrics.Collections
import org.mozilla.fenix.GleanMetrics.ContextMenu
import org.mozilla.fenix.GleanMetrics.CrashReporter
import org.mozilla.fenix.GleanMetrics.ErrorPage
import org.mozilla.fenix.GleanMetrics.Events
19
import org.mozilla.fenix.GleanMetrics.Logins
20
import org.mozilla.fenix.GleanMetrics.Onboarding
21
import org.mozilla.fenix.GleanMetrics.ProgressiveWebApp
22
import org.mozilla.fenix.GleanMetrics.SearchShortcuts
23
import org.mozilla.fenix.GleanMetrics.Tip
24
import org.mozilla.fenix.GleanMetrics.ToolbarSettings
25
import org.mozilla.fenix.GleanMetrics.TopSites
26
import org.mozilla.fenix.GleanMetrics.TrackingProtection
27
import org.mozilla.fenix.R
28
import java.util.Locale
29

30
sealed class Event {
31

32
    // Interaction Events
33
34
35
36
    object OpenedAppFirstRun : Event()
    object InteractWithSearchURLArea : Event()
    object DismissedOnboarding : Event()
    object ClearedPrivateData : Event()
37
38
39
    object AddBookmark : Event()
    object RemoveBookmark : Event()
    object OpenedBookmark : Event()
Colin Lee's avatar
Colin Lee committed
40
41
42
43
44
45
46
47
48
    object OpenedBookmarkInNewTab : Event()
    object OpenedBookmarksInNewTabs : Event()
    object OpenedBookmarkInPrivateTab : Event()
    object OpenedBookmarksInPrivateTabs : Event()
    object EditedBookmark : Event()
    object MovedBookmark : Event()
    object ShareBookmark : Event()
    object CopyBookmark : Event()
    object AddBookmarkFolder : Event()
49
    object RemoveBookmarkFolder : Event()
Colin Lee's avatar
Colin Lee committed
50
    object RemoveBookmarks : Event()
51
52
53
    object CustomTabsClosed : Event()
    object CustomTabsActionTapped : Event()
    object CustomTabsMenuOpened : Event()
54
    object UriOpened : Event()
55
56
    object SyncAuthOpened : Event()
    object SyncAuthClosed : Event()
Grisha Kruglov's avatar
Grisha Kruglov committed
57
    object SyncAuthSignUp : Event()
58
    object SyncAuthSignIn : Event()
59
    object SyncAuthSignOut : Event()
60
    object SyncAuthScanPairing : Event()
61
62
    object SyncAuthUseEmail : Event()
    object SyncAuthUseEmailProblem : Event()
Grisha Kruglov's avatar
Grisha Kruglov committed
63
64
65
    object SyncAuthPaired : Event()
    object SyncAuthRecovered : Event()
    object SyncAuthOtherExternal : Event()
66
67
    object SyncAuthFromSharedReuse : Event()
    object SyncAuthFromSharedCopy : Event()
68
69
    object SyncAccountOpened : Event()
    object SyncAccountSyncNow : Event()
70
71
    object SendTab : Event()
    object SignInToSendTab : Event()
72
73
74
75
76
    object HistoryOpened : Event()
    object HistoryItemShared : Event()
    object HistoryItemOpened : Event()
    object HistoryItemRemoved : Event()
    object HistoryAllItemsRemoved : Event()
77
78
    object ReaderModeAvailable : Event()
    object ReaderModeOpened : Event()
79
    object ReaderModeClosed : Event()
80
    object ReaderModeAppearanceOpened : Event()
81
82
83
84
85
86
87
    object CollectionRenamed : Event()
    object CollectionTabRestored : Event()
    object CollectionAllTabsRestored : Event()
    object CollectionTabRemoved : Event()
    object CollectionShared : Event()
    object CollectionRemoved : Event()
    object CollectionTabSelectOpened : Event()
88
89
    object CollectionTabLongPressed : Event()
    object CollectionAddTabPressed : Event()
90
    object CollectionRenamePressed : Event()
91
92
    object SearchWidgetNewTabPressed : Event()
    object SearchWidgetVoiceSearchPressed : Event()
93
94
95
    object FindInPageOpened : Event()
    object FindInPageClosed : Event()
    object FindInPageSearchCommitted : Event()
96
97
    object PrivateBrowsingSnackbarUndoTapped : Event()
    object PrivateBrowsingNotificationTapped : Event()
98
99
100
101
102
103
    object PrivateBrowsingCreateShortcut : Event()
    object PrivateBrowsingAddShortcutCFR : Event()
    object PrivateBrowsingCancelCFR : Event()
    object PrivateBrowsingPinnedShortcutPrivateTab : Event()
    object PrivateBrowsingStaticShortcutTab : Event()
    object PrivateBrowsingStaticShortcutPrivateTab : Event()
104
105
    object TabMediaPlay : Event()
    object TabMediaPause : Event()
106
107
108
    object MediaPlayState : Event()
    object MediaPauseState : Event()
    object MediaStopState : Event()
109
110
    object MediaFullscreenState : Event()
    object MediaPictureInPictureState : Event()
111
112
113
114
115
116
117
    object InAppNotificationDownloadOpen : Event()
    object InAppNotificationDownloadTryAgain : Event()
    object NotificationDownloadCancel : Event()
    object NotificationDownloadOpen : Event()
    object NotificationDownloadPause : Event()
    object NotificationDownloadResume : Event()
    object NotificationDownloadTryAgain : Event()
118
    object DownloadAdded : Event()
119
120
121
    object DownloadsScreenOpened : Event()
    object DownloadsItemOpened : Event()
    object DownloadsItemDeleted : Event()
122
123
    object NotificationMediaPlay : Event()
    object NotificationMediaPause : Event()
124
    object TopSiteOpenDefault : Event()
125
    object TopSiteOpenGoogle : Event()
126
127
    object TopSiteOpenFrecent : Event()
    object TopSiteOpenPinned : Event()
128
129
130
    object TopSiteOpenInNewTab : Event()
    object TopSiteOpenInPrivateTab : Event()
    object TopSiteRemoved : Event()
131
132
133
134
135
    object TrackingProtectionTrackerList : Event()
    object TrackingProtectionIconPressed : Event()
    object TrackingProtectionSettingsPanel : Event()
    object TrackingProtectionSettings : Event()
    object TrackingProtectionException : Event()
136
137
138
    object OpenLogins : Event()
    object OpenOneLogin : Event()
    object CopyLogin : Event()
139
140
141
    object DeleteLogin : Event()
    object EditLogin : Event()
    object EditLoginSave : Event()
142
    object ViewLoginPassword : Event()
143
144
    object CustomEngineAdded : Event()
    object CustomEngineDeleted : Event()
145
    object PrivateBrowsingShowSearchSuggestions : Event()
146
    object WhatsNewTapped : Event()
147
148
    object SupportTapped : Event()
    object PrivacyNoticeTapped : Event()
ekager's avatar
ekager committed
149
150
    object PocketTopSiteClicked : Event()
    object PocketTopSiteRemoved : Event()
151
    object FennecToFenixMigrated : Event()
152
    object AddonsOpenInSettings : Event()
153
    object VoiceSearchTapped : Event()
154
    object SearchWidgetInstalled : Event()
155
156
157
158
159
    object OnboardingAutoSignIn : Event()
    object OnboardingManualSignIn : Event()
    object OnboardingPrivacyNotice : Event()
    object OnboardingPrivateBrowsing : Event()
    object OnboardingFinish : Event()
160
    object ChangedToDefaultBrowser : Event()
161

162
163
164
165
166
    object LoginDialogPromptDisplayed : Event()
    object LoginDialogPromptCancelled : Event()
    object LoginDialogPromptSave : Event()
    object LoginDialogPromptNeverSave : Event()

167
168
169
170
171
    object ContextualHintETPDisplayed : Event()
    object ContextualHintETPDismissed : Event()
    object ContextualHintETPOutsideTap : Event()
    object ContextualHintETPInsideTap : Event()

172
    // Tab tray
173
174
175
176
177
178
179
180
181
182
183
184
    object TabsTrayOpened : Event()
    object TabsTrayClosed : Event()
    object OpenedExistingTab : Event()
    object ClosedExistingTab : Event()
    object TabsTrayPrivateModeTapped : Event()
    object TabsTrayNormalModeTapped : Event()
    object NewTabTapped : Event()
    object NewPrivateTabTapped : Event()
    object TabsTrayMenuOpened : Event()
    object TabsTraySaveToCollectionPressed : Event()
    object TabsTrayShareAllTabsPressed : Event()
    object TabsTrayCloseAllTabsPressed : Event()
185
186
    object TabsTrayCfrDismissed : Event()
    object TabsTrayCfrTapped : Event()
187

188
189
190
    object ProgressiveWebAppOpenFromHomescreenTap : Event()
    object ProgressiveWebAppInstallAsShortcut : Event()

ekager's avatar
ekager committed
191
192
193
    object MasterPasswordMigrationSuccess : Event()
    object MasterPasswordMigrationDisplayed : Event()

194
195
    object TabSettingsOpened : Event()

196
197
    object CopyUrlUsed : Event()

198
199
    object SyncedTabOpened : Event()

200
201
    object RecentlyClosedTabsOpened : Event()

202
203
204
205
206
    object ContextMenuCopyTapped : Event()
    object ContextMenuSearchTapped : Event()
    object ContextMenuSelectAllTapped : Event()
    object ContextMenuShareTapped : Event()

207
    // Interaction events with extras
208

209
210
211
212
213
214
215
216
217
218
    data class TopSiteSwipeCarousel(val page: Int) : Event() {
        override val extras: Map<TopSites.swipeCarouselKeys, String>?
            get() = hashMapOf(TopSites.swipeCarouselKeys.page to page.toString())
    }

    data class TopSiteLongPress(val type: TopSite.Type) : Event() {
        override val extras: Map<TopSites.longPressKeys, String>?
            get() = hashMapOf(TopSites.longPressKeys.type to type.name)
    }

219
220
221
222
223
224
225
226
227
228
    data class ProgressiveWebAppForeground(val timeForegrounded: Long) : Event() {
        override val extras: Map<ProgressiveWebApp.foregroundKeys, String>?
            get() = mapOf(ProgressiveWebApp.foregroundKeys.timeMs to timeForegrounded.toString())
    }

    data class ProgressiveWebAppBackground(val timeBackgrounded: Long) : Event() {
        override val extras: Map<ProgressiveWebApp.backgroundKeys, String>?
            get() = mapOf(ProgressiveWebApp.backgroundKeys.timeMs to timeBackgrounded.toString())
    }

229
230
231
    data class OnboardingToolbarPosition(val position: Position) : Event() {
        enum class Position { TOP, BOTTOM }

232
233
        override val extras: Map<Onboarding.prefToggledToolbarPositionKeys, String>?
            get() = hashMapOf(Onboarding.prefToggledToolbarPositionKeys.position to position.name)
234
235
236
237
238
    }

    data class OnboardingTrackingProtection(val setting: Setting) : Event() {
        enum class Setting { STRICT, STANDARD }

239
240
        override val extras: Map<Onboarding.prefToggledTrackingProtKeys, String>?
            get() = hashMapOf(Onboarding.prefToggledTrackingProtKeys.setting to setting.name)
241
242
243
244
245
    }

    data class OnboardingThemePicker(val theme: Theme) : Event() {
        enum class Theme { LIGHT, DARK, FOLLOW_DEVICE }

246
247
        override val extras: Map<Onboarding.prefToggledThemePickerKeys, String>?
            get() = mapOf(Onboarding.prefToggledThemePickerKeys.theme to theme.name)
248
    }
249

250
251
252
253
254
    data class PreferenceToggled(
        val preferenceKey: String,
        val enabled: Boolean,
        val context: Context
    ) : Event() {
255
        private val booleanPreferenceTelemetryAllowList = listOf(
256
257
258
            context.getString(R.string.pref_key_show_search_suggestions),
            context.getString(R.string.pref_key_remote_debugging),
            context.getString(R.string.pref_key_telemetry),
259
260
261
            context.getString(R.string.pref_key_tracking_protection),
            context.getString(R.string.pref_key_search_bookmarks),
            context.getString(R.string.pref_key_search_browsing_history),
262
            context.getString(R.string.pref_key_show_clipboard_suggestions),
263
            context.getString(R.string.pref_key_show_search_engine_shortcuts),
264
            context.getString(R.string.pref_key_open_links_in_a_private_tab),
265
266
            context.getString(R.string.pref_key_sync_logins),
            context.getString(R.string.pref_key_sync_bookmarks),
267
            context.getString(R.string.pref_key_sync_history),
268
            context.getString(R.string.pref_key_show_voice_search),
269
            context.getString(R.string.pref_key_show_search_suggestions_in_private)
270
271
        )

272
        override val extras: Map<Events.preferenceToggledKeys, String>?
273
            get() = mapOf(
274
275
                Events.preferenceToggledKeys.preferenceKey to preferenceKey,
                Events.preferenceToggledKeys.enabled to enabled.toString()
276
277
278
279
            )

        init {
            // If the event is not in the allow list, we don't want to track it
280
            require(booleanPreferenceTelemetryAllowList.contains(preferenceKey))
281
282
283
        }
    }

284
285
286
287
288
    data class AddonsOpenInToolbarMenu(val addonId: String) : Event() {
        override val extras: Map<Addons.openAddonInToolbarMenuKeys, String>?
            get() = hashMapOf(Addons.openAddonInToolbarMenuKeys.addonId to addonId)
    }

289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
    data class TipDisplayed(val identifier: String) : Event() {
        override val extras: Map<Tip.displayedKeys, String>?
            get() = hashMapOf(Tip.displayedKeys.identifier to identifier)
    }

    data class TipPressed(val identifier: String) : Event() {
        override val extras: Map<Tip.pressedKeys, String>?
            get() = hashMapOf(Tip.pressedKeys.identifier to identifier)
    }

    data class TipClosed(val identifier: String) : Event() {
        override val extras: Map<Tip.closedKeys, String>?
            get() = hashMapOf(Tip.closedKeys.identifier to identifier)
    }

304
305
    data class ToolbarPositionChanged(val position: Position) : Event() {
        enum class Position { TOP, BOTTOM }
306

307
308
309
310
        override val extras: Map<ToolbarSettings.changedPositionKeys, String>?
            get() = hashMapOf(ToolbarSettings.changedPositionKeys.position to position.name)
    }

311
312
    data class OpenedLink(val mode: Mode) : Event() {
        enum class Mode { NORMAL, PRIVATE }
313

314
315
316
317
        override val extras: Map<Events.openedLinkKeys, String>?
            get() = hashMapOf(Events.openedLinkKeys.mode to mode.name)
    }

318
    data class TrackingProtectionSettingChanged(val setting: Setting) : Event() {
319
        enum class Setting { STRICT, STANDARD, CUSTOM }
320

321
322
323
324
        override val extras: Map<TrackingProtection.etpSettingChangedKeys, String>?
            get() = hashMapOf(TrackingProtection.etpSettingChangedKeys.etpSetting to setting.name)
    }

325
326
327
328
329
330
331
    data class SaveLoginsSettingChanged(val setting: Setting) : Event() {
        enum class Setting { NEVER_SAVE, ASK_TO_SAVE }

        override val extras: Map<Logins.saveLoginsSettingChangedKeys, String>?
            get() = hashMapOf(Logins.saveLoginsSettingChangedKeys.setting to setting.name)
    }

332
333
    data class OpenedApp(val source: Source) : Event() {
        enum class Source { APP_ICON, LINK, CUSTOM_TAB }
334

335
336
337
338
        override val extras: Map<Events.appOpenedKeys, String>?
            get() = hashMapOf(Events.appOpenedKeys.source to source.name)
    }

339
340
341
342
343
344
345
346
    data class AppReceivedIntent(val source: Source) : Event() {

        enum class Source { APP_ICON, LINK, CUSTOM_TAB, UNKNOWN }

        override val extras: Map<Events.appOpenedAllStartupKeys, String>?
            get() = hashMapOf(Events.appOpenedAllStartupKeys.source to source.name)
    }

347
348
349
    data class AppAllStartup(
        val source: Source,
        val type: Type,
350
351
        val hasSavedInstanceState: Boolean? = null,
        var launchTime: Long? = null
352
    ) : Event() {
353
        enum class Source { APP_ICON, LINK, CUSTOM_TAB, UNKNOWN }
354
        enum class Type { COLD, WARM, HOT, ERROR }
355

356
        override val extras: Map<Events.appOpenedAllStartupKeys, String>?
357
358
359
360
361
362
363
364
365
366
367
            get() {
                val extrasMap = hashMapOf(
                    Events.appOpenedAllStartupKeys.source to source.toString(),
                    Events.appOpenedAllStartupKeys.type to type.toString()
                )
                // we are only sending hasSavedInstanceState whenever we get data from
                // activity's oncreate() method.
                if (hasSavedInstanceState != null) {
                    extrasMap[Events.appOpenedAllStartupKeys.hasSavedInstanceState] =
                        hasSavedInstanceState.toString()
                }
368
                if (launchTime != null) {
369
                    extrasMap[Events.appOpenedAllStartupKeys.firstFramePreDrawNanos] =
370
371
                        launchTime.toString()
                }
372
373
                return extrasMap
            }
374
375
    }

376
    data class CollectionSaveButtonPressed(val fromScreen: String) : Event() {
377
378
        override val extras: Map<Collections.saveButtonKeys, String>?
            get() = mapOf(Collections.saveButtonKeys.fromScreen to fromScreen)
379
380
    }

381
    data class CollectionSaved(val tabsOpenCount: Int, val tabsSelectedCount: Int) : Event() {
382
        override val extras: Map<Collections.savedKeys, String>?
383
            get() = mapOf(
384
385
                Collections.savedKeys.tabsOpen to tabsOpenCount.toString(),
                Collections.savedKeys.tabsSelected to tabsSelectedCount.toString()
386
387
388
389
            )
    }

    data class CollectionTabsAdded(val tabsOpenCount: Int, val tabsSelectedCount: Int) : Event() {
390
        override val extras: Map<Collections.tabsAddedKeys, String>?
391
            get() = mapOf(
392
393
                Collections.tabsAddedKeys.tabsOpen to tabsOpenCount.toString(),
                Collections.tabsAddedKeys.tabsSelected to tabsSelectedCount.toString()
394
395
396
            )
    }

397
    data class ErrorPageVisited(val errorType: ErrorType) : Event() {
398
399
        override val extras: Map<ErrorPage.visitedErrorKeys, String>?
            get() = mapOf(ErrorPage.visitedErrorKeys.errorType to errorType.name)
400
401
    }

402
403
    data class SearchBarTapped(val source: Source) : Event() {
        enum class Source { HOME, BROWSER }
404

405
406
        override val extras: Map<Events.searchBarTappedKeys, String>?
            get() = mapOf(Events.searchBarTappedKeys.source to source.name)
407
408
    }

409
    data class EnteredUrl(val autoCompleted: Boolean) : Event() {
410
411
        override val extras: Map<Events.enteredUrlKeys, String>?
            get() = mapOf(Events.enteredUrlKeys.autocomplete to autoCompleted.toString())
412
413
    }

Jeff Boek's avatar
Jeff Boek committed
414
415
    data class PerformedSearch(val eventSource: EventSource) : Event() {
        sealed class EngineSource {
416
417
418
            abstract val engine: SearchEngine
            abstract val isCustom: Boolean

419
420
421
422
423
            data class Default(override val engine: SearchEngine, override val isCustom: Boolean) :
                EngineSource()

            data class Shortcut(override val engine: SearchEngine, override val isCustom: Boolean) :
                EngineSource()
424
425
426
427

            // https://github.com/mozilla-mobile/fenix/issues/1607
            // Sanitize identifiers for custom search engines.
            val identifier: String
428
                get() = if (isCustom) "custom" else engine.id
Jeff Boek's avatar
Jeff Boek committed
429
430
431
432
433
434
435
436
437
438
439
440
441
442

            val searchEngine: SearchEngine
                get() = when (this) {
                    is Default -> engine
                    is Shortcut -> engine
                }

            val descriptor: String
                get() = when (this) {
                    is Default -> "default"
                    is Shortcut -> "shortcut"
                }
        }

443
        sealed class EventSource(open val engineSource: EngineSource) {
444
445
446
            data class Suggestion(override val engineSource: EngineSource) :
                EventSource(engineSource)

447
448
449
450
            data class Action(override val engineSource: EngineSource) : EventSource(engineSource)
            data class Widget(override val engineSource: EngineSource) : EventSource(engineSource)
            data class Shortcut(override val engineSource: EngineSource) : EventSource(engineSource)
            data class Other(override val engineSource: EngineSource) : EventSource(engineSource)
Jeff Boek's avatar
Jeff Boek committed
451
452
453
454
455

            private val label: String
                get() = when (this) {
                    is Suggestion -> "suggestion"
                    is Action -> "action"
456
457
458
                    is Widget -> "widget"
                    is Shortcut -> "shortcut"
                    is Other -> "other"
Jeff Boek's avatar
Jeff Boek committed
459
460
461
                }

            val countLabel: String
462
                get() = "${engineSource.identifier.toLowerCase(Locale.getDefault())}.$label"
Jeff Boek's avatar
Jeff Boek committed
463
464

            val sourceLabel: String
465
466
467
468
469
                get() = "${engineSource.descriptor}.$label"
        }

        enum class SearchAccessPoint {
            SUGGESTION, ACTION, WIDGET, SHORTCUT, NONE
Jeff Boek's avatar
Jeff Boek committed
470
471
        }

472
473
        override val extras: Map<Events.performedSearchKeys, String>?
            get() = mapOf(Events.performedSearchKeys.source to eventSource.sourceLabel)
474
475
    }

476
477
    data class SearchShortcutSelected(val engine: SearchEngine, val isCustom: Boolean) : Event() {
        private val engineName = if (isCustom) "custom" else engine.name
478
        override val extras: Map<SearchShortcuts.selectedKeys, String>?
479
            get() = mapOf(SearchShortcuts.selectedKeys.engine to engineName)
480
481
    }

482
    data class DarkThemeSelected(val source: Source) : Event() {
483
        enum class Source { SETTINGS }
484

485
486
487
488
        override val extras: Map<AppTheme.darkThemeSelectedKeys, String>?
            get() = mapOf(AppTheme.darkThemeSelectedKeys.source to source.name)
    }

489
490
491
492
493
494
495
496
497
498
    data class SearchWithAds(val providerName: String) : Event() {
        val label: String
            get() = providerName
    }

    data class SearchAdClicked(val providerName: String) : Event() {
        val label: String
            get() = providerName
    }

499
500
501
502
503
    data class SearchInContent(val keyName: String) : Event() {
        val label: String
            get() = keyName
    }

504
    class ContextMenuItemTapped private constructor(val item: String) : Event() {
505
506
        override val extras: Map<ContextMenu.itemTappedKeys, String>?
            get() = mapOf(ContextMenu.itemTappedKeys.named to item)
507
508

        companion object {
509
510
            fun create(context_item: String) =
                allowList[context_item]?.let { ContextMenuItemTapped(it) }
511
512
513
514
515
516
517
518

            private val allowList = mapOf(
                "mozac.feature.contextmenu.open_in_new_tab" to "open_in_new_tab",
                "mozac.feature.contextmenu.open_in_private_tab" to "open_in_private_tab",
                "mozac.feature.contextmenu.open_image_in_new_tab" to "open_image_in_new_tab",
                "mozac.feature.contextmenu.save_image" to "save_image",
                "mozac.feature.contextmenu.share_link" to "share_link",
                "mozac.feature.contextmenu.copy_link" to "copy_link",
519
520
                "mozac.feature.contextmenu.copy_image_location" to "copy_image_location",
                "mozac.feature.contextmenu.share_image" to "share_image"
521
522
523
            )
        }
    }
Jeff Boek's avatar
Jeff Boek committed
524

525
    object CrashReporterOpened : Event()
526
527
    data class AddonInstalled(val addonId: String) : Event()

528
    data class CrashReporterClosed(val crashSubmitted: Boolean) : Event() {
529
530
        override val extras: Map<CrashReporter.closedKeys, String>?
            get() = mapOf(CrashReporter.closedKeys.crashSubmitted to crashSubmitted.toString())
531
532
    }

533
534
    data class BrowserMenuItemTapped(val item: Item) : Event() {
        enum class Item {
535
            SETTINGS, HELP, DESKTOP_VIEW_ON, DESKTOP_VIEW_OFF, FIND_IN_PAGE, NEW_TAB,
536
            NEW_PRIVATE_TAB, SHARE, BACK, FORWARD, RELOAD, STOP, OPEN_IN_FENIX,
537
            SAVE_TO_COLLECTION, ADD_TO_TOP_SITES, ADD_TO_HOMESCREEN, QUIT, READER_MODE_ON,
538
            READER_MODE_OFF, OPEN_IN_APP, BOOKMARK, READER_MODE_APPEARANCE, ADDONS_MANAGER,
Kate Glazko's avatar
Kate Glazko committed
539
            BOOKMARKS, HISTORY, SYNC_TABS, DOWNLOADS
540
541
        }

542
        override val extras: Map<Events.browserMenuActionKeys, String>?
543
            get() = mapOf(Events.browserMenuActionKeys.item to item.toString().toLowerCase(Locale.ROOT))
544
545
546
547
548
549
550
551
552
    }

    data class TabCounterMenuItemTapped(val item: Item) : Event() {
        enum class Item {
            NEW_TAB, NEW_PRIVATE_TAB, CLOSE_TAB
        }

        override val extras: Map<Events.tabCounterMenuActionKeys, String>?
            get() = mapOf(Events.tabCounterMenuActionKeys.item to item.toString().toLowerCase(Locale.ROOT))
553
554
    }

555
556
557
558
559
560
561
562
563
564
565
    object AutoPlaySettingVisited : Event()

    data class AutoPlaySettingChanged(val setting: AutoplaySetting) : Event() {
        enum class AutoplaySetting {
            BLOCK_CELLULAR, BLOCK_AUDIO, BLOCK_ALL
        }

        override val extras: Map<Autoplay.settingChangedKeys, String>?
            get() = mapOf(Autoplay.settingChangedKeys.autoplaySetting to setting.toString().toLowerCase(Locale.ROOT))
    }

Jeff Boek's avatar
Jeff Boek committed
566
567
    sealed class Search

568
    internal open val extras: Map<*, String>?
569
570
        get() = null
}