1 import type { SimpleMap } from '@proton/shared/lib/interfaces';
3 export enum TelemetryMeasurementGroups {
4 accountSignup = 'account.any.signup',
5 accountSignupBasic = 'account.any.signup_basic',
6 accountOrgLogoUpload = 'account.web.org_logo_upload',
7 accountSecurityCheckup = 'account.web.security_checkup',
8 calendarEncryptedSearch = 'calendar.web.encrypted_search',
9 calendarIcsSurgery = 'calendar.web.ics_surgery',
10 calendarTimeZoneSelector = 'calendar.web.timezone_selector',
11 accountCancellation = 'account.web.cancellation',
12 /** Not only calendar scope because party crasher on mail and drawer */
13 calendarInvite = 'any.web.calendar_invite',
14 changelogOpened = 'any.changelog_opened',
15 keyTransparency = 'any.web.key_transparency',
16 subscriptionModal = 'any.web.subscription_modal',
17 mailPrivacyDropdown = 'mail.web.privacy_dropdown',
18 mailSelectAll = 'mail.web.select_all',
19 mailSnooze = 'mail.web.snooze',
20 mailSignup = 'mail.web.signup',
21 mailSimpleLogin = 'mail.web.simplelogin_popups',
22 mailComposerAssistant = 'mail.web.composer_assistant',
23 /** Setting it to any even if mail only ATM. We will expand it to other apps soon */
24 securityCenter = 'any.web.security_center',
25 paymentsFlow = 'payments.flow',
27 driveWebFeaturePerformance = 'drive.web.feature_performance',
29 collapsibleLeftSidebar = 'any.web.collapsible_left_sidebar',
32 export enum TelemetrySubscriptionModalEvents {
33 initialization = 'initialization',
37 export enum TelemetryMailTrial2024UpsellModal {
38 noThanks = 'no_thanks',
39 closeModal = 'close_modal',
43 export enum TelemetrySimpleLoginEvents {
44 spam_view = 'spam_view',
45 newsletter_unsubscribe = 'newsletter_unsubscribe',
46 simplelogin_modal_view = 'simplelogin_modal_view',
47 go_to_simplelogin = 'go_to_simplelogin',
50 export enum TelemetryCalendarEvents {
51 change_temporary_time_zone = 'change_temporary_time_zone',
52 enable_encrypted_search = 'enable_encrypted_search',
53 answer_invite = 'answer_invite',
56 export enum TelemetryIcsSurgeryEvents {
58 import_publish = 'import_publish',
59 invitation = 'invitation',
62 export enum TelemetryAccountSignupBasicEvents {
63 flow_started = 'flow_started',
64 account_created = 'account_created',
67 export enum TelemetryAccountSignupEvents {
68 pageLoad = 'fe.page_load',
69 planSelect = 'user.plan_select',
70 cycleSelect = 'user.cycle_select',
71 currencySelect = 'user.currency_select',
72 paymentSelect = 'user.payment_select',
73 userCheckout = 'user.checkout',
74 userSignIn = 'user.sign_in',
75 interactAccountCreate = 'user.interact.account_create',
76 interactUpsell = 'user.interact.upsell',
77 interactCreditCard = 'user.interact.credit_card',
78 interactPassword = 'user.interact.password',
79 interactRecoveryKit = 'user.interact.recovery',
80 interactDownload = 'user.interact.download',
81 beAvailableExternal = 'be.available_external',
82 beSignInSuccess = 'be.sign_in_success',
83 beSignOutSuccess = 'be.sign_out_success',
84 bePaymentMethods = 'be.payments_available',
85 checkoutError = 'be.checkout_error',
86 hvNeeded = 'be.hv_needed',
87 loadPaymentBtc = 'fe.load_payment_btc',
88 onboardingStart = 'fe.onboarding_start',
89 onboardShown = 'fe.onboarding_shown',
90 onboardFinish = 'fe.onboarding_finish',
91 signupFinish = 'fe.signup_finish',
94 export enum TelemtryAccountCancellationEvents {
95 startCancellation = 'start_cancellation',
96 cancelPage = 'cancel_page',
97 cancelModal = 'cancel_modal',
98 feedbackModal = 'feedback_modal',
99 resubscribeModal = 'resubscribe_modal',
100 dashboardReactivate = 'dashboard_reactivate',
103 export enum TelemetryAccountOrganizationLogoUploadEvents {
104 processStart = 'process_start',
105 processSuccess = 'process_success',
106 processFailure = 'process_failure',
109 export enum TelemetryAccountSecurityCheckupEvents {
110 pageLoad = 'page_load',
112 completeRecoveryMultiple = 'cohort_change.complete_recovery_multiple',
113 completeRecoverySingle = 'cohort_change.complete_recovery_single',
114 accountRecoveryEnabled = 'cohort_change.account_recovery_enabled',
117 export enum TelemetryKeyTransparencyErrorEvents {
118 self_audit_error = 'self_audit_error',
119 key_verification_failure = 'key_verification_failure',
122 export enum TelemetryMailEvents {
123 privacy_dropdown_opened = 'privacy_dropdown_opened',
124 snooze_open_dropdown = 'snooze_open_dropdown',
127 export enum TelemetryMailSelectAllEvents {
128 notification_move_to = 'notification_move_to',
129 button_move_to_archive = 'button_move_to_archive',
130 button_move_to_trash = 'button_move_to_trash',
131 banner_move_to = 'banner_move_to',
132 banner_label_as = 'banner_label_as',
133 banner_mark_as_read = 'banner_mark_as_read',
134 banner_mark_as_unread = 'banner_mark_as_unread',
135 banner_permanent_delete = 'banner_permanent_delete',
138 export enum TelemetryMailComposerAssistantEvents {
139 show_assistant = 'show_assistant',
140 free_trial_start = 'free_trial_start',
141 download_model = 'download_model',
142 use_answer = 'use_answer',
143 not_use_answer = 'not_use_answer',
144 request_assistant = 'request_assistant',
145 assistant_error = 'assistant_error',
146 send_message = 'send_message',
147 pause_download = 'pause_download',
148 load_model = 'load_model',
149 unload_model = 'unload_model',
150 incompatible_assistant = 'incompatible_assistant',
153 export enum TelemetryChangelog {
157 export enum TelemetrySecurityCenterEvents {
158 account_security_card = 'account_security_card',
159 proton_pass_discover_banner = 'proton_pass_discover_banner',
160 proton_pass_create_alias = 'proton_pass_create_alias',
161 proton_sentinel_toggle = 'proton_sentinel_toggle',
164 export enum TelemetryPaymentsEvents {
165 load_payment = 'load_payment',
166 payment_attempt = 'payment_attempt',
167 payment_success = 'payment_success',
168 payment_failure = 'payment_failure',
171 export enum TelemetryDriveWebFeature {
172 performance = 'drive_web_feature_performance',
175 export enum TelemetryCollapsibleLeftSidebarEvents {
176 toggleLeftSidebar = 'toggle_left_sidebar',
179 export type TelemetryEvents =
180 | TelemetrySimpleLoginEvents
181 | TelemetrySubscriptionModalEvents
182 | TelemetryMailTrial2024UpsellModal
183 | TelemetryCalendarEvents
184 | TelemetryIcsSurgeryEvents
185 | TelemetryAccountSignupBasicEvents
186 | TelemetryAccountSignupEvents
187 | TelemtryAccountCancellationEvents
188 | TelemetryKeyTransparencyErrorEvents
189 | TelemetryMailEvents
190 | TelemetryMailSelectAllEvents
191 | TelemetryMailComposerAssistantEvents
193 | TelemetrySecurityCenterEvents
194 | TelemetryPaymentsEvents
195 | TelemetryAccountOrganizationLogoUploadEvents
196 | TelemetryDriveWebFeature
197 | TelemetryAccountSecurityCheckupEvents
198 | TelemetryCollapsibleLeftSidebarEvents;
200 export interface TelemetryReport {
201 measurementGroup: TelemetryMeasurementGroups;
202 event: TelemetryEvents;
203 values?: SimpleMap<number>;
204 dimensions?: SimpleMap<string>;
207 export const sendTelemetryData = (data: {
208 MeasurementGroup: TelemetryMeasurementGroups;
209 Event: TelemetryEvents;
210 Values?: SimpleMap<number>;
211 Dimensions?: SimpleMap<string>;
214 url: 'data/v1/stats',
217 Values: data.Values || {},
218 Dimensions: data.Dimensions || {},
222 export const sendMultipleTelemetryData = (data: { reports: TelemetryReport[] }) => {
223 const EventInfo = data.reports.map(({ measurementGroup, event, values, dimensions }) => ({
224 MeasurementGroup: measurementGroup,
226 Values: values || {},
227 Dimensions: dimensions || {},
232 url: 'data/v1/stats/multiple',