@@ -24,6 +24,7 @@ import { BarChart3, Users, DollarSign, Percent } from 'lucide-react';
2424import { auth } from '@/lib/firebase' ;
2525import { collection , query , where , getDocs } from 'firebase/firestore' ;
2626import { db } from '@/lib/firebase' ;
27+ import Logger from '@/utils/logger' ;
2728
2829interface GlobalStats {
2930 totalRevenue : number ;
@@ -48,7 +49,7 @@ const DashboardStats = ({ activeCampaigns, totalCampaigns, totalAffiliates, user
4849 useEffect ( ( ) => {
4950 const loadGlobalStats = async ( ) => {
5051 if ( ! userId ) {
51- console . log ( '📊 SECURITY - No userId provided for stats') ;
52+ Logger . security ( ' No userId provided for stats') ;
5253 return ;
5354 }
5455
@@ -58,15 +59,15 @@ const DashboardStats = ({ activeCampaigns, totalCampaigns, totalAffiliates, user
5859 return ; // Sortir si l'auth n'est pas prête
5960 }
6061
61- console . log ( `📊 SECURITY - Loading secured global stats ${ periodLabel } for:` , userId ) ;
62+ Logger . security ( ` Loading secured global stats ${ periodLabel } for: ${ userId } ` ) ;
6263
6364 // Récupérer les campagnes de l'utilisateur avec vérification de propriété
6465 const campaignsQuery = query ( collection ( db , 'campaigns' ) , where ( 'userId' , '==' , userId ) ) ;
6566 const campaignsSnapshot = await getDocs ( campaignsQuery ) ;
6667 const campaignIds = campaignsSnapshot . docs . map ( doc => doc . id ) ;
6768
6869 if ( campaignIds . length === 0 ) {
69- console . log ( '📊 SECURITY - No campaigns found for user') ;
70+ Logger . security ( ' No campaigns found for user') ;
7071 setLoading ( false ) ;
7172 return ;
7273 }
@@ -113,7 +114,7 @@ const DashboardStats = ({ activeCampaigns, totalCampaigns, totalAffiliates, user
113114
114115 const conversionRate = totalClicks > 0 ? ( totalConversions / totalClicks ) * 100 : 0 ;
115116
116- console . log ( `📊 SECURITY - Secured stats calculated ${ periodLabel } :`, {
117+ Logger . security ( ` Secured stats calculated ${ periodLabel } :`, {
117118 totalClicks,
118119 totalConversions,
119120 totalRevenue,
@@ -247,9 +248,9 @@ export const Dashboard = memo(() => {
247248 // CORRECTION: Vérification de sécurité au montage SEULEMENT quand l'auth est prête
248249 useEffect ( ( ) => {
249250 if ( ! isLoading ) {
250- console . log ( '📊 SECURITY - Dashboard mounted, checking authentication') ;
251+ Logger . security ( ' Dashboard mounted, checking authentication') ;
251252 if ( ! requireAuthentication ( 'accéder au dashboard' ) ) {
252- console . log ( '📊 SECURITY - Auth not ready or failed, will retry when ready') ;
253+ Logger . warning ( ' Auth not ready or failed, will retry when ready') ;
253254 }
254255 }
255256 } , [ requireAuthentication , isLoading ] ) ;
@@ -261,7 +262,7 @@ export const Dashboard = memo(() => {
261262 if ( newCampaignCreated ) {
262263 try {
263264 const campaignData = JSON . parse ( newCampaignCreated ) ;
264- console . log ( '🎉 DASHBOARD: Nouvelle campagne détectée:', campaignData ) ;
265+ Logger . info ( ' Nouvelle campagne détectée:', campaignData ) ;
265266
266267 setNewCampaignData ( campaignData ) ;
267268 setShowSuccessModal ( true ) ;
@@ -284,7 +285,7 @@ export const Dashboard = memo(() => {
284285 if ( isAuthenticated && ! tourCompleted && ! campaignsLoading && ! affiliatesLoading ) {
285286 // Attendre un peu que le dashboard soit rendu
286287 const timer = setTimeout ( ( ) => {
287- console . log ( '🎯 Starting guided tour for new user') ;
288+ Logger . info ( ' Starting guided tour for new user') ;
288289 startTour ( ) ;
289290 } , 1000 ) ;
290291
@@ -294,11 +295,11 @@ export const Dashboard = memo(() => {
294295
295296 const handleLogout = useCallback ( async ( ) => {
296297 try {
297- console . log ( '🔐 SECURITY - User logout initiated') ;
298+ Logger . security ( ' User logout initiated') ;
298299 await auth . signOut ( ) ;
299300 localStorage . removeItem ( 'auth_user' ) ;
300301 sessionStorage . clear ( ) ; // Nettoyer toutes les données de session
301- console . log ( '🔐 SECURITY - User logged out successfully') ;
302+ Logger . security ( ' User logged out successfully') ;
302303 } catch ( error ) {
303304 console . error ( '🔐 SECURITY - Logout error:' , error ) ;
304305 }
0 commit comments