1 import type { SimpleMap } from '@proton/shared/lib/interfaces';
3 // Reminder: both auth & un-auth measurement groups need to be whitelisted by the back-end. Make sure to specify it to the back-end or your measurement will be silently ignored.
4 export enum TelemetryMeasurementGroups {
5 accountSignup = 'account.any.signup',
6 accountSignupBasic = 'account.any.signup_basic',
7 accountOrgLogoUpload = 'account.web.org_logo_upload',
8 accountSecurityCheckup = 'account.web.security_checkup',
9 calendarEncryptedSearch = 'calendar.web.encrypted_search',
10 calendarIcsSurgery = 'calendar.web.ics_surgery',
11 calendarTimeZoneSelector = 'calendar.web.timezone_selector',
12 calendarVideoConferencing = 'calendar.web.video_conferencing',
13 accountCancellation = 'account.web.cancellation',
14 settingsHeartBeat = 'any.web.settings_heart_beat',
15 /** Not only calendar scope because party crasher on mail and drawer */
16 calendarInvite = 'any.web.calendar_invite',
17 changelogOpened = 'any.changelog_opened',
18 keyTransparency = 'any.web.key_transparency',
19 subscriptionModal = 'any.web.subscription_modal',
20 mailOnboarding = 'mail.web.onboarding',
21 mailPrivacyDropdown = 'mail.web.privacy_dropdown',
22 mailSelectAll = 'mail.web.select_all',
23 mailSnooze = 'mail.web.snooze',
24 mailSignup = 'mail.web.signup',
25 mailComposerAssistant = 'mail.web.composer_assistant',
26 mailProtonTips = 'mail.web.proton_tips',
27 mailDesktopDefaultMailto = 'mail.desktop.default_mailto',
28 /** Setting it to any even if mail only ATM. We will expand it to other apps soon */
29 securityCenter = 'any.web.security_center',
30 paymentsFlow = 'payments.flow',
32 driveWebFeaturePerformance = 'drive.web.feature_performance_unauth',
33 driveWebActions = 'drive.web.actions_unauth',
35 collapsibleLeftSidebar = 'any.web.collapsible_left_sidebar',
36 smartBanner = 'any.web.smart_banner',
37 clientInstalls = 'common.any.client_installs',
38 upsellModals = 'any.web.upsell_modals',
40 docsSuggestions = 'common.web.suggestions',
43 export enum TelemetryMailOnboardingEvents {
44 start_onboarding_modals = 'start_onboarding_modals',
45 finish_onboarding_modals = 'finish_onboarding_modals',
46 select_theme = 'select_theme',
47 enable_gmail_forwarding = 'enable_gmail_forwarding',
48 change_login = 'change_login',
49 change_login_checklist = 'change_login_checklist',
50 finish_change_login = 'finish_change_login',
51 download_desktop_app = 'download_desktop_app',
52 premium_features = 'premium_features',
53 close_checklist = 'close_checklist',
54 clicked_checklist_setting = 'clicked_checklist_setting',
57 export enum TelemetrySubscriptionModalEvents {
58 initialization = 'initialization',
62 export enum TelemetryMailTrial2024UpsellModal {
63 noThanks = 'no_thanks',
64 closeModal = 'close_modal',
68 export enum TelemetryCalendarEvents {
69 change_temporary_time_zone = 'change_temporary_time_zone',
70 enable_encrypted_search = 'enable_encrypted_search',
71 answer_invite = 'answer_invite',
74 export enum TelemetryCalendarVideoConferencing {
75 video_conference_widget = 'video_conference_widget',
76 video_conference_settings_toggle = 'video_conference_settings_toggle',
77 video_conference_zoom_integration = 'video_conference_zoom_integration',
80 export enum TelemetryIcsSurgeryEvents {
82 import_publish = 'import_publish',
83 invitation = 'invitation',
86 export enum TelemetryAccountSignupBasicEvents {
87 flow_started = 'flow_started',
88 account_created = 'account_created',
91 export enum TelemetryAccountSignupEvents {
92 pageLoad = 'fe.page_load',
93 planSelect = 'user.plan_select',
94 cycleSelect = 'user.cycle_select',
95 currencySelect = 'user.currency_select',
96 paymentSelect = 'user.payment_select',
97 userCheckout = 'user.checkout',
98 userSignIn = 'user.sign_in',
99 interactAccountCreate = 'user.interact.account_create',
100 interactUpsell = 'user.interact.upsell',
101 interactCreditCard = 'user.interact.credit_card',
102 interactPassword = 'user.interact.password',
103 interactRecoveryKit = 'user.interact.recovery',
104 interactDownload = 'user.interact.download',
105 beAvailableExternal = 'be.available_external',
106 beSignInSuccess = 'be.sign_in_success',
107 beSignOutSuccess = 'be.sign_out_success',
108 bePaymentMethods = 'be.payments_available',
109 checkoutError = 'be.checkout_error',
110 hvNeeded = 'be.hv_needed',
111 loadPaymentBtc = 'fe.load_payment_btc',
112 onboardingStart = 'fe.onboarding_start',
113 onboardShown = 'fe.onboarding_shown',
114 onboardFinish = 'fe.onboarding_finish',
115 signupFinish = 'fe.signup_finish',
118 export enum TelemetryAccountCancellationEvents {
119 startCancellation = 'start_cancellation',
120 cancelPage = 'cancel_page',
121 cancelModal = 'cancel_modal',
122 feedbackModal = 'feedback_modal',
123 resubscribeModal = 'resubscribe_modal',
124 dashboardReactivate = 'dashboard_reactivate',
125 upsellModal = 'upsell_modal',
128 export enum TelemetryAccountOrganizationLogoUploadEvents {
129 processStart = 'process_start',
130 processSuccess = 'process_success',
131 processFailure = 'process_failure',
134 export enum TelemetryAccountSecurityCheckupEvents {
135 pageLoad = 'page_load',
137 completeRecoveryMultiple = 'cohort_change.complete_recovery_multiple',
138 completeRecoverySingle = 'cohort_change.complete_recovery_single',
139 accountRecoveryEnabled = 'cohort_change.account_recovery_enabled',
142 export enum TelemetryKeyTransparencyErrorEvents {
143 self_audit_error = 'self_audit_error',
144 key_verification_failure = 'key_verification_failure',
147 export enum TelemetryDesktopEvents {
148 client_first_launch = 'client_first_launch',
151 export enum TelemetryMailEvents {
152 privacy_dropdown_opened = 'privacy_dropdown_opened',
153 snooze_open_dropdown = 'snooze_open_dropdown',
156 export enum TelemetryMailSelectAllEvents {
157 button_move_to_archive = 'button_move_to_archive',
158 button_move_to_trash = 'button_move_to_trash',
159 banner_move_to = 'banner_move_to',
160 banner_label_as = 'banner_label_as',
161 banner_mark_as_read = 'banner_mark_as_read',
162 banner_mark_as_unread = 'banner_mark_as_unread',
163 banner_permanent_delete = 'banner_permanent_delete',
166 export enum TelemetryMailComposerAssistantEvents {
167 show_assistant = 'show_assistant',
168 free_trial_start = 'free_trial_start',
169 download_model = 'download_model',
170 use_answer = 'use_answer',
171 not_use_answer = 'not_use_answer',
172 request_assistant = 'request_assistant',
173 assistant_error = 'assistant_error',
174 send_message = 'send_message',
175 pause_download = 'pause_download',
176 load_model = 'load_model',
177 unload_model = 'unload_model',
178 incompatible_assistant = 'incompatible_assistant',
181 export enum TelemetryMailHeartbeatEvents {
182 mail_heartbeat = 'mail_heartbeat',
185 export enum TelemetryMailDefaultMailto {
186 mailto_heartbeat = 'mailto_heartbeat',
189 export enum TelemetryChangelog {
193 export enum TelemetrySecurityCenterEvents {
194 account_security_card = 'account_security_card',
195 proton_pass_discover_banner = 'proton_pass_discover_banner',
196 proton_pass_create_alias = 'proton_pass_create_alias',
197 proton_sentinel_toggle = 'proton_sentinel_toggle',
200 export enum TelemetryPaymentsEvents {
201 load_payment = 'load_payment',
202 payment_attempt = 'payment_attempt',
203 payment_success = 'payment_success',
204 payment_failure = 'payment_failure',
207 export enum TelemetryDriveWebFeature {
208 performance = 'drive_web_feature_performance_unauth',
209 actions = 'drive_web_actions_unauth',
212 export enum TelemetryCollapsibleLeftSidebarEvents {
213 toggleLeftSidebar = 'toggle_left_sidebar',
216 export enum TelemetryUpsellModalsEvents {
217 clickUpsellModals = 'click_upsell_modals',
220 export enum TelemetryProtonTipsEvents {
221 tipDispayed = 'tip_displayed',
222 CTAButtonClicked = 'cta_clicked',
223 tipChangeState = 'tip_change_state',
224 closeButtonClicked = 'close_button_clicked',
225 tipSnoozed = 'tip_snoozed',
228 export enum TelemetrySmartBannerEvents {
229 clickAppStoreLink = 'click_app_store_link',
232 export enum TelemetryDocsEvents {
233 suggestion_created = 'suggestion.created',
234 suggestion_resolved = 'suggestion.resolved',
235 suggestion_commented = 'suggestion.comment',
238 export type TelemetryEvents =
239 | TelemetrySubscriptionModalEvents
240 | TelemetryMailTrial2024UpsellModal
241 | TelemetryCalendarEvents
242 | TelemetryIcsSurgeryEvents
243 | TelemetryAccountSignupBasicEvents
244 | TelemetryAccountSignupEvents
245 | TelemetryAccountCancellationEvents
246 | TelemetryKeyTransparencyErrorEvents
247 | TelemetryMailEvents
248 | TelemetryMailSelectAllEvents
249 | TelemetryMailComposerAssistantEvents
250 | TelemetryMailOnboardingEvents
252 | TelemetrySecurityCenterEvents
253 | TelemetryPaymentsEvents
254 | TelemetryAccountOrganizationLogoUploadEvents
255 | TelemetryDriveWebFeature
256 | TelemetryAccountSecurityCheckupEvents
257 | TelemetryCollapsibleLeftSidebarEvents
258 | TelemetryUpsellModalsEvents
259 | TelemetryProtonTipsEvents
260 | TelemetryMailHeartbeatEvents
261 | TelemetrySmartBannerEvents
262 | TelemetryDesktopEvents
263 | TelemetryMailDefaultMailto
264 | TelemetryDocsEvents
265 | TelemetryCalendarVideoConferencing;
267 export interface TelemetryReport {
268 measurementGroup: TelemetryMeasurementGroups;
269 event: TelemetryEvents;
270 values?: SimpleMap<number>;
271 dimensions?: SimpleMap<string>;
274 export const sendTelemetryData = (data: {
275 MeasurementGroup: TelemetryMeasurementGroups;
276 Event: TelemetryEvents;
277 Values?: SimpleMap<number>;
278 Dimensions?: SimpleMap<string>;
281 url: 'data/v1/stats',
284 Values: data.Values || {},
285 Dimensions: data.Dimensions || {},
289 export const sendMultipleTelemetryData = (data: { reports: TelemetryReport[] }) => {
290 const EventInfo = data.reports.map(({ measurementGroup, event, values, dimensions }) => ({
291 MeasurementGroup: measurementGroup,
293 Values: values || {},
294 Dimensions: dimensions || {},
299 url: 'data/v1/stats/multiple',