-
Notifications
You must be signed in to change notification settings - Fork 15
fix(login): send client timezone for analytics requests #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -188,12 +188,17 @@ export const fetchUserProfile = async (username: string, token: string) => { | |||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| export const fetchWeeklyTabUsage = async (token: string) => { | ||||||||||||||||||||||||||||||
| const res = await fetch(`${BACKEND_URL}/api/analytics/tab-usage/weekly`, { | ||||||||||||||||||||||||||||||
| headers: { Authorization: `Bearer ${token}` } | ||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||
| const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone; | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
Comment on lines
+191
to
+192
|
||||||||||||||||||||||||||||||
| const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone; | |
| let timezone = 'UTC'; | |
| try { | |
| const options = typeof Intl !== 'undefined' && typeof Intl.DateTimeFormat === 'function' | |
| ? Intl.DateTimeFormat().resolvedOptions() | |
| : null; | |
| if (options && typeof options.timeZone === 'string' && options.timeZone.trim() !== '') { | |
| timezone = options.timeZone; | |
| } | |
| } catch { | |
| // Fallback to default 'UTC' timezone if retrieval fails | |
| } |
akash-kumar-dev marked this conversation as resolved.
Show resolved
Hide resolved
Copilot
AI
Jan 31, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The timezone retrieval using Intl.DateTimeFormat().resolvedOptions().timeZone lacks error handling. If this API fails or returns undefined in some browsers or environments, the function will silently pass an undefined or malformed timezone parameter. Consider adding a try-catch block with a fallback timezone (e.g., 'UTC') or validation to ensure the timezone is valid before using it.
akash-kumar-dev marked this conversation as resolved.
Show resolved
Hide resolved
Copilot
AI
Jan 31, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing await keyword before res.json(). While this doesn't break functionality (the promise is still returned correctly), it's inconsistent with other similar functions in this file (see lines 135, 153, 160, 168, 176, 211, 219, 261) that use return await res.json(). For consistency and better error handling within this function's scope, add the await keyword.
Uh oh!
There was an error while loading. Please reload this page.