@@ -35,7 +35,7 @@ async function sendAnalytics(p) {
3535 const formData = new FormData ( ) ;
3636 formData . append ( "data" , JSON . stringify ( log ) ) ;
3737
38- fetch ( 'https://script.google.com/macros/s/AKfycbxAP4kL4hH0YTdpJsUC1jKGlnIKYa4RnHnG532hX2IJHK6FXIebVEuPyuwJv8veVNyD /exec' , {
38+ fetch ( 'https://script.google.com/macros/s/AKfycbyjf6pKC8fpgh_8Ee081286tvSxpSQve2rKgUv4x5GeTTwFuIZQkOSz0eMg6lxE2JU /exec' , {
3939 method : 'POST' ,
4040 body : formData
4141 } )
@@ -50,6 +50,22 @@ async function sendAnalytics(p) {
5050 } ) ;
5151}
5252
53+ function getLocalTimeZone ( ) {
54+ const date = new Date ( ) ;
55+ const timeZone = Intl . DateTimeFormat ( ) . resolvedOptions ( ) . timeZone ;
56+
57+ // Get the time zone abbreviation using toLocaleString
58+ const options = { timeZone, timeZoneName : 'short' } ;
59+ const timeZoneInfo = date . toLocaleString ( 'en-US' , options ) ;
60+
61+ // The abbreviation is usually at the end of the returned string
62+ const abbreviation = timeZoneInfo . split ( ' ' ) . pop ( ) ;
63+
64+ return `${ timeZone } (${ abbreviation } )` ;
65+ }
66+
67+
68+
5369function getOS ( ) {
5470 const userAgent = navigator . userAgent ;
5571
@@ -80,6 +96,43 @@ function getOS() {
8096 }
8197}
8298
99+ function getDetroitDateTime ( ) {
100+ // Create a date object for the current time
101+ const now = new Date ( ) ;
102+
103+ // Convert the current time to Detroit time (Eastern Time)
104+ const options = {
105+ timeZone : 'America/New_York' ,
106+ month : 'long' ,
107+ day : 'numeric' ,
108+ year : 'numeric' ,
109+ hour : 'numeric' ,
110+ minute : 'numeric' ,
111+ hour12 : true
112+ } ;
113+
114+ // Get the formatted date
115+ const detroitDate = new Intl . DateTimeFormat ( 'en-US' , options ) . format ( now ) ;
116+
117+ // Split the date and time
118+ const [ monthDay , year , time ] = detroitDate . split ( ', ' ) ;
119+ const [ month , dayWithSuffix ] = monthDay . split ( ' ' ) ;
120+
121+ // Determine the ordinal suffix for the day
122+ const day = parseInt ( dayWithSuffix , 10 ) ;
123+ const suffix = ( day ) => {
124+ if ( day > 3 && day < 21 ) return 'th' ; // Catch 11th-13th
125+ return [ 'st' , 'nd' , 'rd' ] [ day % 10 - 1 ] || 'th' ;
126+ } ;
127+
128+ // Combine everything into the desired format
129+ return `${ month } ${ day } ${ suffix ( day ) } , ${ year } ` ;
130+ }
131+
132+ function getLocalLanguage ( ) {
133+ return navigator . language || navigator . userLanguage ; // For older versions of IE
134+ }
135+
83136async function getCurrentDateTime ( page ) {
84137
85138 const now = new Date ( ) ;
@@ -99,14 +152,17 @@ async function getCurrentDateTime(page) {
99152 const time = now . toLocaleString ( 'en-US' , { hour : 'numeric' , minute : 'numeric' , hour12 : true } ) . toLowerCase ( ) ;
100153 // Combine everything into the desired format
101154 return {
102- time : `${ month } ${ day } ${ suffix ( day ) } , ${ now . getFullYear ( ) } at ${ time } ` ,
103- type : page ,
104- post : window . location . hash ,
155+ site : window . location . href ,
156+ localTime : `${ month } ${ day } ${ suffix ( day ) } , ${ now . getFullYear ( ) } at ${ time } ` ,
157+ hqTime : getDetroitDateTime ( ) ,
158+ page : page ,
159+ hash : window . location . hash ,
105160 ip : ip ,
106161 os : getOS ( ) ,
107162 location : `${ locationn . city } , ${ locationn . region } ${ locationn . postal } ` ,
163+ timeZone : getLocalTimeZone ( ) ,
164+ lang : getLocalLanguage ( ) ,
108165 wifi : locationn . org ,
109- gmaps : `https://www.google.com/maps?q=${ locationn . loc . split ( ',' ) [ 0 ] } ,${ locationn . loc . split ( ',' ) [ 1 ] } ` ,
110- site : window . location . href
166+ gmaps : `https://www.google.com/maps?q=${ locationn . loc . split ( ',' ) [ 0 ] } ,${ locationn . loc . split ( ',' ) [ 1 ] } `
111167 }
112168}
0 commit comments