Skip to content
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

feat: Add timezone to events #1504

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/utils/event-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,14 @@ export const Info = {
return props
},

timezone: function (): string | undefined {
try {
return Intl.DateTimeFormat().resolvedOptions().timeZone
} catch {
return undefined
}
},

properties: function (): Properties {
if (!userAgent) {
return {}
Expand All @@ -194,6 +202,7 @@ export const Info = {
$browser: Info.browser(userAgent, navigator.vendor),
$device: Info.device(userAgent),
$device_type: Info.deviceType(userAgent),
$timezone: Info.timezone(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@robbie-c would be interesting to add $locale as well
did not test but something like:

function getBrowserLocale(): string | undefined {
    try {
        return navigator.language || navigator.languages[0];
    } catch {
        return undefined;
    }
}

}),
{
$current_url: location?.href,
Expand Down
Loading