@@ -9,7 +9,7 @@ import { AuthMechChart, AuthMechDataPoint } from './auth-mech-chart'
99import { DailySignupsChart , DailySignupsDataPoint } from './daily-signups-chart'
1010import { DailyLoginFailsChart , DailyLoginFailsDataPoint } from './daily-login-fails-chart'
1111import { DateRangePicker , DateRange } from '@/components/ui/date-range-picker'
12- import { startOfDay , endOfDay , format , subDays } from 'date-fns'
12+ import { startOfDay , endOfDay , format } from 'date-fns'
1313import {
1414 Select ,
1515 SelectContent ,
@@ -33,21 +33,13 @@ interface SummaryMetrics {
3333 conversion_rate : number
3434}
3535
36- interface UsersResult {
37- data : { total_users : number } [ ]
38- }
39-
40- interface ConversionRateResult {
41- data : { conversion_rate : number } [ ]
42- }
43-
4436interface LogEntry {
45- timestamp : string
46- type : string
47- description : string
48- id : string
49- connection : string
50- application : string
37+ event_time : string
38+ event_type : string
39+ description : string
40+ id : string
41+ connection : string
42+ application : string
5143}
5244
5345export default function Auth0Dashboard ( ) {
@@ -117,9 +109,8 @@ export default function Auth0Dashboard() {
117109 if ( ! token ) return
118110 setIsLoading ( true )
119111 try {
120- const fromDate = format ( dateRange . from , "yyyy-MM-dd HH:mm:ss" )
121- const toDate = format ( dateRange . to , "yyyy-MM-dd HH:mm:ss" )
122- const thirtyDaysAgo = format ( subDays ( new Date ( ) , 30 ) , "yyyy-MM-dd HH:mm:ss" )
112+ const fromDate = dateRange . from ? format ( dateRange . from , "yyyy-MM-dd HH:mm:ss" ) : format ( new Date ( ) , "yyyy-MM-dd HH:mm:ss" )
113+ const toDate = dateRange . to ? format ( dateRange . to , "yyyy-MM-dd HH:mm:ss" ) : format ( new Date ( ) , "yyyy-MM-dd HH:mm:ss" )
123114
124115 const params = {
125116 date_from : fromDate ,
@@ -129,13 +120,6 @@ export default function Auth0Dashboard() {
129120 ...( selectedConnection !== 'all' && { connection_id : selectedConnection } )
130121 }
131122
132- const thirtyDayParams = {
133- date_from : thirtyDaysAgo ,
134- time_range : timeRange ,
135- ...( selectedApp !== 'all' && { client_id : selectedApp } ) ,
136- ...( selectedConnection !== 'all' && { connection_id : selectedConnection } )
137- }
138-
139123 const [
140124 usersResult ,
141125 applicationsResult ,
@@ -151,31 +135,21 @@ export default function Auth0Dashboard() {
151135 dailyLoginFailsResult ,
152136 logsResult
153137 ] = await Promise . all ( [
154- pipe < UsersResult > ( token , 'auth0_users_total' , selectedApp !== 'all' || selectedConnection !== 'all' ? {
155- time_range : timeRange ,
156- ...( selectedApp !== 'all' && { client_id : selectedApp } ) ,
157- ...( selectedConnection !== 'all' && { connection_id : selectedConnection } )
158- } : undefined ) ,
159- pipe ( token , 'auth0_applications' ) ,
160- pipe ( token , 'auth0_apis' ) ,
161- pipe ( token , 'auth0_connections' ) ,
162- pipe ( token , 'auth0_signups' , thirtyDayParams ) ,
163- pipe ( token , 'auth0_mau' , thirtyDayParams ) ,
164- pipe < ConversionRateResult > ( token , 'auth0_conversion_rate' , thirtyDayParams ) ,
138+ pipe ( token , 'auth0_users_total' , params ) ,
139+ pipe ( token , 'auth0_applications' , params ) ,
140+ pipe ( token , 'auth0_apis' , params ) ,
141+ pipe ( token , 'auth0_connections' , params ) ,
142+ pipe ( token , 'auth0_signups' , params ) ,
143+ pipe ( token , 'auth0_mau' , params ) ,
144+ pipe ( token , 'auth0_conversion_rate' , params ) ,
165145 pipe < { data : UserRetentionDataPoint [ ] } > ( token , 'auth0_user_retention_ts' , params ) ,
166146 pipe < { data : DauDataPoint [ ] } > ( token , 'auth0_dau_ts' , params ) ,
167- dateRange . compareMode ? pipe < { data : DauDataPoint [ ] } > ( token , 'auth0_dau_ts' , {
168- ...params ,
169- date_from : comparisonFromDate ,
170- date_to : comparisonToDate
171- } ) : Promise . resolve ( { data : [ ] } ) ,
172147 pipe < { data : AuthMechDataPoint [ ] } > ( token , 'auth0_mech_usage' , params ) ,
173148 pipe < { data : DailySignupsDataPoint [ ] } > ( token , 'auth0_daily_signups' , params ) ,
174149 pipe < { data : DailyLoginFailsDataPoint [ ] } > ( token , 'auth0_daily_login_fails' , params ) ,
175150 pipe < { data : LogEntry [ ] } > ( token , 'auth0_logs' , {
151+ ...params ,
176152 page : logsPage ,
177- date_from : format ( logsDateRange . from , "yyyy-MM-dd HH:mm:ss" ) ,
178- date_to : format ( logsDateRange . to , "yyyy-MM-dd HH:mm:ss" ) ,
179153 ...( logsFilters . eventType !== 'all' && { event_type : logsFilters . eventType } ) ,
180154 ...( logsFilters . connection !== 'all' && { connection : logsFilters . connection } ) ,
181155 ...( logsFilters . clientName !== 'all' && { client_name : logsFilters . clientName } )
@@ -206,10 +180,7 @@ export default function Auth0Dashboard() {
206180 }
207181
208182 fetchMetrics ( )
209- return ( ) => {
210- mounted = false
211- }
212- } , [ token , dateRange . from , dateRange . to , dateRange . compareMode , selectedApp , selectedConnection , timeRange , logsPage ] )
183+ } , [ token , dateRange . from , dateRange . to , selectedApp , selectedConnection , timeRange , logsPage ] )
213184
214185 const fetchLogs = useCallback ( async ( ) => {
215186 if ( ! token || ! logsDateRange ?. from || ! logsDateRange ?. to ) return
@@ -349,7 +320,6 @@ export default function Auth0Dashboard() {
349320 < div className = "grid gap-4 grid-cols-1" >
350321 < DauChart
351322 data = { dauData }
352- comparisonData = { dateRange . compareMode ? dauComparisonData : undefined }
353323 timeRange = { timeRange }
354324 className = "h-[300px]"
355325 />
@@ -395,9 +365,9 @@ export default function Auth0Dashboard() {
395365 } }
396366 onFiltersChange = { ( filters ) => {
397367 if ( filters . dateRange ) setLogsDateRange ( filters . dateRange )
398- if ( filters . eventType ) setLogsFilters ( prev => ( { ...prev , eventType : filters . eventType } ) )
399- if ( filters . connection ) setLogsFilters ( prev => ( { ...prev , connection : filters . connection } ) )
400- if ( filters . clientName ) setLogsFilters ( prev => ( { ...prev , clientName : filters . clientName } ) )
368+ if ( filters . eventType ) setLogsFilters ( prev => ( { ...prev , eventType : filters . eventType as string } ) )
369+ if ( filters . connection ) setLogsFilters ( prev => ( { ...prev , connection : filters . connection as string } ) )
370+ if ( filters . clientName ) setLogsFilters ( prev => ( { ...prev , clientName : filters . clientName as string } ) )
401371 setLogsPage ( 0 )
402372 } }
403373 />
0 commit comments