Skip to content

Commit 0506e7f

Browse files
criticalAYBrayanDSO
authored andcommitted
refactor: extract analytics constants
1 parent d0d41f9 commit 0506e7f

7 files changed

Lines changed: 309 additions & 280 deletions

File tree

Lines changed: 292 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,292 @@
1+
/*
2+
* Copyright (c) 2018 Mike Hardy <mike@mikehardy.net>
3+
* Copyright (c) 2026 Ashish Yadav <mailtoashish693@gmail.com>
4+
*
5+
* This program is free software; you can redistribute it and/or modify it under
6+
* the terms of the GNU General Public License as published by the Free Software
7+
* Foundation; either version 3 of the License, or (at your option) any later
8+
* version.
9+
*
10+
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
11+
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12+
* PARTICULAR PURPOSE. See the GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License along with
15+
* this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
package com.ichi2.anki.analytics
19+
20+
import androidx.annotation.VisibleForTesting
21+
import com.ichi2.anki.R
22+
23+
/**
24+
* A centralized repository for all constant values used in analytics tracking.
25+
*/
26+
object AnalyticsConstants {
27+
object Category {
28+
const val SYNC = "Sync"
29+
const val LINK_CLICKED = "LinkClicked"
30+
const val SETTING = "Setting"
31+
}
32+
33+
/**
34+
* These Strings must not be changed as they are used for analytic comparisons between AnkiDroid versions.
35+
* If a new string is added here then the respective changes must also be made in AnalyticsConstantsTest.kt
36+
* All the constant strings added here must be annotated with @AnalyticsConstant.
37+
*/
38+
object Actions {
39+
// Analytics actions used in Help Dialog
40+
@AnalyticsConstant
41+
val OPENED_HELP_DIALOG = "Opened HelpDialogBox"
42+
43+
@AnalyticsConstant
44+
val OPENED_USING_ANKIDROID = "Opened Using AnkiDroid"
45+
46+
@AnalyticsConstant
47+
val OPENED_GET_HELP = "Opened Get Help"
48+
49+
@AnalyticsConstant
50+
val OPENED_SUPPORT_ANKIDROID = "Opened Support AnkiDroid"
51+
52+
@AnalyticsConstant
53+
val OPENED_COMMUNITY = "Opened Community"
54+
55+
@AnalyticsConstant
56+
val OPENED_PRIVACY = "Opened Privacy"
57+
58+
@AnalyticsConstant
59+
val OPENED_ANKIWEB_TERMS_AND_CONDITIONS = "Opened AnkiWeb Terms and Conditions"
60+
61+
@AnalyticsConstant
62+
val OPENED_ANKIDROID_PRIVACY_POLICY = "Opened AnkiDroid Privacy Policy"
63+
64+
@AnalyticsConstant
65+
val OPENED_ANKIWEB_PRIVACY_POLICY = "Opened AnkiWeb Privacy Policy"
66+
67+
@AnalyticsConstant
68+
val OPENED_ANKIDROID_MANUAL = "Opened AnkiDroid Manual"
69+
70+
@AnalyticsConstant
71+
val OPENED_ANKI_MANUAL = "Opened Anki Manual"
72+
73+
@AnalyticsConstant
74+
val OPENED_ANKIDROID_FAQ = "Opened AnkiDroid FAQ"
75+
76+
@AnalyticsConstant
77+
val OPENED_MAILING_LIST = "Opened Mailing List"
78+
79+
@AnalyticsConstant
80+
val OPENED_REPORT_BUG = "Opened Report a Bug"
81+
82+
@AnalyticsConstant
83+
val OPENED_DONATE = "Opened Donate"
84+
85+
@AnalyticsConstant
86+
val OPENED_TRANSLATE = "Opened Translate"
87+
88+
@AnalyticsConstant
89+
val OPENED_DEVELOP = "Opened Develop"
90+
91+
@AnalyticsConstant
92+
val OPENED_RATE = "Opened Rate"
93+
94+
@AnalyticsConstant
95+
val OPENED_OTHER = "Opened Other"
96+
97+
@AnalyticsConstant
98+
val OPENED_SEND_FEEDBACK = "Opened Send Feedback"
99+
100+
@AnalyticsConstant
101+
val OPENED_ANKI_FORUMS = "Opened Anki Forums"
102+
103+
@AnalyticsConstant
104+
val OPENED_REDDIT = "Opened Reddit"
105+
106+
@AnalyticsConstant
107+
val OPENED_DISCORD = "Opened Discord"
108+
109+
@AnalyticsConstant
110+
val OPENED_FACEBOOK = "Opened Facebook"
111+
112+
@AnalyticsConstant
113+
val OPENED_TWITTER = "Opened Twitter"
114+
115+
@AnalyticsConstant
116+
val EXCEPTION_REPORT = "Exception Report"
117+
118+
@AnalyticsConstant
119+
val IMPORT_APKG_FILE = "Import APKG"
120+
121+
@AnalyticsConstant
122+
val IMPORT_COLPKG_FILE = "Import COLPKG"
123+
124+
@AnalyticsConstant
125+
val IMPORT_CSV_FILE = "Import CSV"
126+
127+
@AnalyticsConstant
128+
val TAPPED_SETTING = "Tapped setting"
129+
130+
@AnalyticsConstant
131+
val CHANGED_SETTING = "Changed setting"
132+
}
133+
134+
@VisibleForTesting
135+
val reportablePrefKeys =
136+
setOf(
137+
// ******************************** General ************************************************
138+
R.string.error_reporting_mode_key, // Error reporting mode
139+
R.string.paste_png_key, // Paste clipboard images as PNG
140+
R.string.deck_for_new_cards_key, // Deck for new cards
141+
R.string.exit_via_double_tap_back_key, // Press back twice to go back/exit
142+
R.string.anki_card_external_context_menu_key, // ‘Anki Card’ Menu
143+
R.string.card_browser_external_context_menu_key, // ‘Card Browser’ Menu
144+
// ******************************** Reviewing **********************************************
145+
R.string.day_offset_preference, // Start of next day
146+
R.string.learn_cutoff_preference, // Learn ahead limit
147+
R.string.time_limit_preference, // Timebox time limit
148+
R.string.keep_screen_on_preference, // Disable screen timeout
149+
R.string.double_tap_timeout_pref_key, // Double tap time interval (milliseconds)
150+
// ******************************** Sync ***************************************************
151+
R.string.sync_fetch_media_key, // Fetch media on sync
152+
R.string.automatic_sync_choice_key, // Automatic synchronization
153+
R.string.sync_status_badge_key, // Display synchronization status
154+
R.string.metered_sync_key, // Allow sync on metered connections
155+
R.string.sync_io_timeout_secs_key, // Network timeout
156+
R.string.one_way_sync_key, // One-way sync
157+
// ******************************** Backup *************************************************
158+
R.string.pref_minutes_between_automatic_backups_key,
159+
R.string.pref_daily_backups_to_keep_key,
160+
R.string.pref_weekly_backups_to_keep_key,
161+
R.string.pref_monthly_backups_to_keep_key,
162+
// ******************************** Appearance *********************************************
163+
R.string.app_theme_key, // Theme
164+
R.string.day_theme_key, // Day theme
165+
R.string.night_theme_key, // Night theme
166+
R.string.pref_deck_picker_background_key, // Background image
167+
R.string.pref_remove_wallpaper_key, // Remove wallpaper
168+
R.string.fullscreen_mode_preference, // Fullscreen mode
169+
R.string.center_vertically_preference, // Center align
170+
R.string.show_estimates_preference, // Show button time
171+
R.string.answer_buttons_position_preference, // Answer buttons position
172+
R.string.show_topbar_preference, // Show top bar
173+
R.string.show_progress_preference, // Show remaining
174+
R.string.show_eta_preference, // Show ETA
175+
R.string.show_audio_play_buttons_key, // Show play buttons on cards with audio (reversed in collection: HIDE_AUDIO_PLAY_BUTTONS)
176+
R.string.pref_display_filenames_in_browser_key, // Display filenames in card browser
177+
R.string.show_deck_title_key, // Show deck title
178+
// ******************************** Controls *********************************************
179+
R.string.gestures_preference, // Enable gestures
180+
R.string.gestures_corner_touch_preference, // 9-point touch
181+
R.string.nav_drawer_gesture_key, // Full screen navigation drawer
182+
R.string.pref_swipe_sensitivity_key, // Swipe sensitivity
183+
R.string.show_answer_command_key,
184+
R.string.answer_again_command_key,
185+
R.string.answer_hard_command_key,
186+
R.string.answer_good_command_key,
187+
R.string.answer_easy_command_key,
188+
R.string.undo_command_key,
189+
R.string.redo_command_key,
190+
R.string.edit_command_key,
191+
R.string.mark_command_key,
192+
R.string.bury_card_command_key,
193+
R.string.suspend_card_command_key,
194+
R.string.delete_command_key,
195+
R.string.play_media_command_key,
196+
R.string.abort_command_key,
197+
R.string.bury_note_command_key,
198+
R.string.suspend_note_command_key,
199+
R.string.flag_red_command_key,
200+
R.string.flag_orange_command_key,
201+
R.string.flag_green_command_key,
202+
R.string.flag_blue_command_key,
203+
R.string.flag_pink_command_key,
204+
R.string.flag_turquoise_command_key,
205+
R.string.flag_purple_command_key,
206+
R.string.remove_flag_command_key,
207+
R.string.page_up_command_key,
208+
R.string.page_down_command_key,
209+
R.string.tag_command_key,
210+
R.string.card_info_command_key,
211+
R.string.previous_card_info_command_key,
212+
R.string.record_voice_command_key,
213+
R.string.replay_voice_command_key,
214+
R.string.save_voice_command_key,
215+
R.string.toggle_whiteboard_command_key,
216+
R.string.toggle_eraser_command_key,
217+
R.string.clear_whiteboard_command_key,
218+
R.string.change_whiteboard_pen_color_command_key,
219+
R.string.toggle_auto_advance_command_key,
220+
R.string.show_hint_command_key,
221+
R.string.show_all_hints_command_key,
222+
R.string.add_note_command_key,
223+
R.string.reschedule_command_key,
224+
R.string.user_action_1_key,
225+
R.string.user_action_2_key,
226+
R.string.user_action_3_key,
227+
R.string.user_action_4_key,
228+
R.string.user_action_5_key,
229+
R.string.user_action_6_key,
230+
R.string.user_action_7_key,
231+
R.string.user_action_8_key,
232+
R.string.user_action_9_key,
233+
// ******************************** Accessibility ******************************************
234+
R.string.card_zoom_preference,
235+
R.string.image_zoom_preference,
236+
R.string.answer_button_size_preference,
237+
R.string.show_large_answer_buttons_preference,
238+
R.string.pref_card_browser_font_scale_key,
239+
R.string.pref_card_minimal_click_time,
240+
// ******************************** Advanced ***********************************************
241+
R.string.pref_ankidroid_directory_key, // AnkiDroid directory
242+
R.string.double_scrolling_gap_key, // Double scrolling
243+
R.string.disable_hardware_render_key, // Disable card hardware render
244+
R.string.safe_display_key, // Safe display mode
245+
R.string.use_input_tag_key, // Type answer into the card
246+
R.string.disable_single_field_edit_key, // Disable Single-Field Edit Mode
247+
R.string.note_editor_newline_replace_key, // Replace newlines with HTML
248+
R.string.type_in_answer_focus_key, // Focus ‘type in answer’
249+
R.string.media_import_allow_all_files_key, // Allow all files in media imports
250+
R.string.enable_api_key, // Enable AnkiDroid API
251+
R.string.use_fixed_port_pref_key, // localStorage in Study Screen
252+
// ******************************** App bar buttons ****************************************
253+
R.string.reset_custom_buttons_key,
254+
R.string.custom_button_undo_key,
255+
R.string.custom_button_redo_key,
256+
R.string.custom_button_schedule_card_key,
257+
R.string.custom_button_flag_key,
258+
R.string.custom_button_edit_card_key,
259+
R.string.custom_button_tags_key,
260+
R.string.custom_button_add_card_key,
261+
R.string.custom_button_replay_key,
262+
R.string.custom_button_card_info_key,
263+
R.string.custom_button_previous_card_info_key,
264+
R.string.custom_button_select_tts_key,
265+
R.string.custom_button_deck_options_key,
266+
R.string.custom_button_mark_card_key,
267+
R.string.custom_button_toggle_mic_toolbar_key,
268+
R.string.custom_button_bury_key,
269+
R.string.custom_button_suspend_key,
270+
R.string.custom_button_delete_key,
271+
R.string.custom_button_enable_whiteboard_key,
272+
R.string.custom_button_toggle_eraser_key,
273+
R.string.custom_button_toggle_stylus_key,
274+
R.string.custom_button_save_whiteboard_key,
275+
R.string.custom_button_whiteboard_pen_color_key,
276+
R.string.custom_button_show_hide_whiteboard_key,
277+
R.string.custom_button_clear_whiteboard_key,
278+
R.string.custom_button_toggle_auto_advance,
279+
R.string.custom_button_user_action_1_key,
280+
R.string.custom_button_user_action_2_key,
281+
R.string.custom_button_user_action_3_key,
282+
R.string.custom_button_user_action_4_key,
283+
R.string.custom_button_user_action_5_key,
284+
R.string.custom_button_user_action_6_key,
285+
R.string.custom_button_user_action_7_key,
286+
R.string.custom_button_user_action_8_key,
287+
R.string.custom_button_user_action_9_key,
288+
// *********************************** Study Screen ************************************
289+
R.string.new_reviewer_options_key,
290+
R.string.show_answer_feedback_key,
291+
)
292+
}

0 commit comments

Comments
 (0)