@@ -82,11 +82,11 @@ public void trackUserLogin(@NotNull Account user, @NotNull String authType) {
8282 .register (meterRegistry )
8383 .increment ();
8484
85- logger .debug ("Tracked login for user {} with auth type {}" , user . getId (), authType );
86- } catch (Exception e ) {
87- logger .warn ("Failed to track login metric for user {} : {}" , user . getId () , e .getMessage ());
88- }
89- }
85+ logger .debug ("Tracked login metric" );
86+ } catch (Exception e ) {
87+ logger .warn ("Failed to track login metric: {}" , e .getMessage ());
88+ }
89+ }
9090
9191 /**
9292 * Track a user logout event
@@ -102,18 +102,17 @@ public void trackUserLogout(@NotNull Account user, @NotNull String logoutType) {
102102 .register (meterRegistry )
103103 .increment ();
104104
105- logger .debug ("Tracked logout for user {} with logout type {}" , user . getId (), logoutType );
106- } catch (Exception e ) {
107- logger .warn ("Failed to track logout metric for user {} : {}" , user . getId () , e .getMessage ());
108- }
109- }
105+ logger .debug ("Tracked logout metric" );
106+ } catch (Exception e ) {
107+ logger .warn ("Failed to track logout metric: {}" , e .getMessage ());
108+ }
109+ }
110110
111- /**
112- * Track a user registration event
113- * @param user The newly registered user
114- * @param emailProvider The email provider (e.g., "gmail", "yahoo", "other")
115- */
116- public void trackUserRegistration (@ NotNull Account user , @ NotNull String emailProvider ) {
111+ /**
112+ * Track a user registration event
113+ * @param user The newly registered user
114+ */
115+ public void trackUserRegistration (@ NotNull Account user ) {
117116 try {
118117 String authType = user .getAuthenticationType () != null ?
119118 String .valueOf (user .getAuthenticationType ().getCode ()) : "unknown" ;
@@ -125,34 +124,32 @@ public void trackUserRegistration(@NotNull Account user, @NotNull String emailPr
125124 .register (meterRegistry )
126125 .increment ();
127126
128- logger .debug ("Tracked registration for user {} with email provider {}" , user . getId (), emailProvider );
129- } catch (Exception e ) {
130- logger .warn ("Failed to track registration metric for user {} : {}" , user . getId () , e .getMessage ());
131- }
132- }
127+ logger .debug ("Tracked registration metric" );
128+ } catch (Exception e ) {
129+ logger .warn ("Failed to track registration metric: {}" , e .getMessage ());
130+ }
131+ }
133132
134- /**
135- * Track a user account activation event
136- * @param user The user whose account was activated
137- */
138- public void trackUserActivation (@ NotNull Account user ) {
133+ /**
134+ * Track a user account activation event
135+ * @param user The user whose account was activated
136+ */
137+ public void trackUserActivation (@ NotNull Account user ) {
139138 try {
140- String authType = user .getAuthenticationType () != null ?
141- String .valueOf (user .getAuthenticationType ().getCode ()) : "unknown" ;
142- String emailProvider = extractEmailProvider (user .getEmail ());
143-
144- Counter .builder (USER_ACTIVATIONS )
145- .description ("Total number of user account activations" )
146- .tag ("email_provider" , emailProvider )
147- .tag ("auth_type" , authType )
148- .register (meterRegistry )
149- .increment ();
150-
151- logger .debug ("Tracked activation for user {} with email provider {}" , user .getId (), emailProvider );
152- } catch (Exception e ) {
153- logger .warn ("Failed to track activation metric for user {}: {}" , user .getId (), e .getMessage ());
154- }
155- }
139+ String authType = user .getAuthenticationType () != null ?
140+ String .valueOf (user .getAuthenticationType ().getCode ()) : "unknown" ;
141+
142+ Counter .builder (USER_ACTIVATIONS )
143+ .description ("Total number of user account activations" )
144+ .tag ("auth_type" , authType )
145+ .register (meterRegistry )
146+ .increment ();
147+
148+ logger .debug ("Tracked activation metric" );
149+ } catch (Exception e ) {
150+ logger .warn ("Failed to track activation metric: {}" , e .getMessage ());
151+ }
152+ }
156153
157154 /**
158155 * Track a mindmap creation event
@@ -172,35 +169,30 @@ public void trackMindmapCreation(@NotNull Mindmap mindmap, @NotNull Account user
172169 .register (meterRegistry )
173170 .increment ();
174171
175- logger .debug ("Tracked mindmap creation: {} by user {} (type: {}, visibility: {})" ,
176- mindmap .getId (), user .getId (), creationType , visibility );
177- } catch (Exception e ) {
178- logger .warn ("Failed to track mindmap creation metric for mindmap {}: {}" , mindmap .getId (), e .getMessage ());
179- }
180- }
172+ logger .debug ("Tracked mindmap creation metric" );
173+ } catch (Exception e ) {
174+ logger .warn ("Failed to track mindmap creation metric: {}" , e .getMessage ());
175+ }
176+ }
181177
182- /**
183- * Track when a user is suspended/disabled
184- * @param user The user who was suspended
185- * @param reason The suspension reason
186- */
187- public void trackUserSuspension (@ NotNull Account user , @ NotNull String reason ) {
188- try {
189- String emailProvider = extractEmailProvider (user .getEmail ());
190-
191- Counter .builder (USER_SUSPENSIONS )
192- .description ("Total number of users suspended" )
193- .tag ("reason" , reason .toLowerCase ())
194- .tag ("user_type" , String .valueOf (user .getAuthenticationType ().getCode ()))
195- .tag ("email_provider" , emailProvider )
196- .register (meterRegistry )
197- .increment ();
198-
199- logger .debug ("Tracked user suspension: {} suspended for reason {}" , user .getId (), reason );
200- } catch (Exception e ) {
201- logger .warn ("Failed to track user suspension metric for user {}: {}" , user .getId (), e .getMessage ());
202- }
203- }
178+ /**
179+ * Track when a user is suspended/disabled
180+ * @param user The user who was suspended
181+ * @param reason The suspension reason
182+ */
183+ public void trackUserSuspension (@ NotNull Account user , @ NotNull String reason ) {
184+ Counter .builder (USER_SUSPENSIONS )
185+ .description ("Total number of users suspended" )
186+ .tag ("reason" , reason .toLowerCase ())
187+ .tag ("user_type" , String .valueOf (user .getAuthenticationType ().getCode ()))
188+ .register (meterRegistry )
189+ .increment ();
190+
191+ logger .debug ("Tracked user suspension metric" );
192+ } catch (Exception e ) {
193+ logger .warn ("Failed to track user suspension metric: {}" , e .getMessage ());
194+ }
195+ }
204196
205197 /**
206198 * Track when a mindmap is made public
@@ -216,38 +208,33 @@ public void trackMindmapMadePublic(@NotNull Mindmap mindmap, @NotNull Account us
216208 .register (meterRegistry )
217209 .increment ();
218210
219- logger .debug ("Tracked mindmap made public: {} by user {}" , mindmap . getId (), user . getId () );
220- } catch (Exception e ) {
221- logger .warn ("Failed to track mindmap made public metric for mindmap {} : {}" , mindmap . getId () , e .getMessage ());
222- }
223- }
211+ logger .debug ("Tracked mindmap made public metric" );
212+ } catch (Exception e ) {
213+ logger .warn ("Failed to track mindmap made public metric: {}" , e .getMessage ());
214+ }
215+ }
224216
225- /**
226- * Track when a mindmap is shared with a collaborator
227- * @param mindmap The mindmap that was shared
228- * @param collaboratorEmail The email of the collaborator
229- * @param role The collaboration role granted
230- * @param sharedBy The user who shared the mindmap
231- */
232- public void trackMindmapShared (@ NotNull Mindmap mindmap , @ NotNull String collaboratorEmail , @ NotNull String role , @ NotNull Account sharedBy ) {
233- try {
234- String emailProvider = extractEmailProvider (collaboratorEmail );
235-
236- Counter .builder (MINDMAPS_SHARED )
237- .description ("Total number of mindmaps shared with collaborators" )
238- .tag ("role" , role .toLowerCase ())
239- .tag ("collaborator_email_provider" , emailProvider )
240- .tag ("sharer_type" , String .valueOf (sharedBy .getAuthenticationType ().getCode ()))
241- .tag ("mindmap_visibility" , mindmap .isPublic () ? "public" : "private" )
242- .register (meterRegistry )
243- .increment ();
244-
245- logger .debug ("Tracked mindmap shared: {} shared with {} (role: {}) by user {}" ,
246- mindmap .getId (), emailProvider , role , sharedBy .getId ());
247- } catch (Exception e ) {
248- logger .warn ("Failed to track mindmap shared metric for mindmap {}: {}" , mindmap .getId (), e .getMessage ());
249- }
250- }
217+ /**
218+ * Track when a mindmap is shared with a collaborator
219+ * @param mindmap The mindmap that was shared
220+ * @param role The collaboration role granted
221+ * @param sharedBy The user who shared the mindmap
222+ */
223+ public void trackMindmapShared (@ NotNull Mindmap mindmap , @ NotNull String role , @ NotNull Account sharedBy ) {
224+ try {
225+ Counter .builder (MINDMAPS_SHARED )
226+ .description ("Total number of mindmaps shared with collaborators" )
227+ .tag ("role" , role .toLowerCase ())
228+ .tag ("sharer_type" , String .valueOf (sharedBy .getAuthenticationType ().getCode ()))
229+ .tag ("mindmap_visibility" , mindmap .isPublic () ? "public" : "private" )
230+ .register (meterRegistry )
231+ .increment ();
232+
233+ logger .debug ("Tracked mindmap shared metric" );
234+ } catch (Exception e ) {
235+ logger .warn ("Failed to track mindmap shared metric: {}" , e .getMessage ());
236+ }
237+ }
251238
252239 /**
253240 * Track a spam analysis event - unified metric that captures all spam analysis results
@@ -316,11 +303,11 @@ public void trackSpamPrevention(@NotNull Mindmap mindmap, @NotNull String action
316303 .register (meterRegistry )
317304 .increment ();
318305
319- logger .debug ("Tracked spam prevention: {} action blocked for mindmap {}" , action , mindmap . getId () );
320- } catch (Exception e ) {
321- logger .warn ("Failed to track spam prevention metric for mindmap {} : {}" , mindmap . getId () , e .getMessage ());
322- }
323- }
306+ logger .debug ("Tracked spam prevention metric" );
307+ } catch (Exception e ) {
308+ logger .warn ("Failed to track spam prevention metric: {}" , e .getMessage ());
309+ }
310+ }
324311
325312 /**
326313 * Track inactive user processing metrics
@@ -411,48 +398,4 @@ public void trackInactiveMindmapMigration(int usersProcessed, int mindmapsMigrat
411398 }
412399 }
413400
414- /**
415- * Extract email provider from email address
416- * @param email The email address
417- * @return The email provider (e.g., "gmail", "yahoo", "hotmail", "other")
418- */
419- @ NotNull
420- public String extractEmailProvider (@ Nullable String email ) {
421- if (email == null || !email .contains ("@" )) {
422- return "other" ;
423- }
424-
425- String domain = email .substring (email .lastIndexOf ("@" ) + 1 ).toLowerCase ();
426-
427- // Map common email providers
428- switch (domain ) {
429- case "gmail.com" :
430- case "googlemail.com" :
431- return "gmail" ;
432- case "yahoo.com" :
433- case "yahoo.co.uk" :
434- case "yahoo.fr" :
435- case "yahoo.de" :
436- return "yahoo" ;
437- case "hotmail.com" :
438- case "outlook.com" :
439- case "live.com" :
440- return "microsoft" ;
441- case "aol.com" :
442- return "aol" ;
443- case "icloud.com" :
444- case "me.com" :
445- case "mac.com" :
446- return "apple" ;
447- default :
448- // Check if it's a known business domain
449- if (domain .contains ("edu" )) {
450- return "education" ;
451- } else if (domain .contains ("gov" )) {
452- return "government" ;
453- } else {
454- return "other" ;
455- }
456- }
457- }
458- }
401+ }
0 commit comments