@@ -24,28 +24,23 @@ function listLogins() {
2424 const optionalArgs = {
2525 maxResults : 10
2626 } ;
27- try {
28- if ( ! AdminReports || ! AdminReports . Activities ) {
29- throw new Error ( 'Enable the AdminReports Advanced Service.' ) ;
30- }
31- const response = AdminReports . Activities . list (
32- userKey , applicationName , optionalArgs ) ;
33- const activities = response . items ;
34- if ( ! activities || activities . length === 0 ) {
35- console . log ( 'No logins found.' ) ;
36- return ;
37- }
38- // Print login events
39- console . log ( 'Logins:' ) ;
40- for ( const activity of activities ) {
41- if ( activity . id ?. time && activity . actor ?. email && activity . events ?. [ 0 ] ?. name ) {
42- console . log ( '%s: %s (%s)' , activity . id . time , activity . actor . email ,
43- activity . events [ 0 ] . name ) ;
44- }
27+ if ( ! AdminReports || ! AdminReports . Activities ) {
28+ throw new Error ( 'Enable the AdminReports Advanced Service.' ) ;
29+ }
30+ const response = AdminReports . Activities . list (
31+ userKey , applicationName , optionalArgs ) ;
32+ const activities = response . items ;
33+ if ( ! activities || activities . length === 0 ) {
34+ console . log ( 'No logins found.' ) ;
35+ return ;
36+ }
37+ // Print login events
38+ console . log ( 'Logins:' ) ;
39+ for ( const activity of activities ) {
40+ if ( activity . id ?. time && activity . actor ?. email && activity . events ?. [ 0 ] ?. name ) {
41+ console . log ( '%s: %s (%s)' , activity . id . time , activity . actor . email ,
42+ activity . events [ 0 ] . name ) ;
4543 }
46- } catch ( err ) {
47- // TODO (developer)- Handle exception from the Report API
48- console . log ( 'Failed with error %s' , /** @type {Error } */ ( err ) . message ) ;
4944 }
5045}
5146// [END admin_sdk_reports_quickstart]
0 commit comments