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

feat: Add timezone to events #1504

merged 1 commit into from
Oct 30, 2024

Conversation

robbie-c
Copy link
Member

@robbie-c robbie-c commented Oct 29, 2024

Changes

Add timezone to events (timezone looks like Europe/London).

In older browsers that don't support Intl, this property won't be sent.

This is useful for a couple of things:

  • I want to add a time of day query, which shows you how active your site is at different times of day, and it'd be cool to have a toggle to show it by the user's timezone (so you could see that e.g. around the world your app is always popular at 8am)
  • I can use this for the cookieless rotating salt, to figure out which day's salt to use

Checklist

  • Tests for new code (see advice on the tests we use)
  • Accounted for the impact of any changes across different browsers
  • Accounted for backwards compatibility of any changes (no breaking changes in posthog-js!)

Copy link

vercel bot commented Oct 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
posthog-js ✅ Ready (Inspect) Visit Preview Oct 29, 2024 7:25pm

Copy link
Member

@pauldambra pauldambra left a comment

Choose a reason for hiding this comment

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

this is great... IMHO the solution to passing dates around and knowing what's happening

@robbie-c robbie-c changed the title Add timezone to events feat: Add timezone to events Oct 29, 2024
Copy link

Size Change: +1.19 kB (+0.04%)

Total Size: 2.95 MB

Filename Size Change
dist/array.full.es5.js 249 kB +122 B (+0.05%)
dist/array.full.js 335 kB +119 B (+0.04%)
dist/array.full.no-external.js 334 kB +119 B (+0.04%)
dist/array.js 166 kB +119 B (+0.07%)
dist/array.no-external.js 165 kB +119 B (+0.07%)
dist/main.js 167 kB +119 B (+0.07%)
dist/module.full.js 335 kB +119 B (+0.04%)
dist/module.full.no-external.js 334 kB +119 B (+0.04%)
dist/module.js 166 kB +119 B (+0.07%)
dist/module.no-external.js 165 kB +119 B (+0.07%)
ℹ️ View Unchanged
Filename Size
dist/all-external-dependencies.js 182 kB
dist/exception-autocapture.js 8.77 kB
dist/external-scripts-loader.js 2.19 kB
dist/recorder-v2.js 102 kB
dist/recorder.js 103 kB
dist/surveys-preview.js 56.7 kB
dist/surveys.js 62.1 kB
dist/tracing-headers.js 1.33 kB
dist/web-vitals.js 10.3 kB

compressed-size-action

@robbie-c robbie-c added the bump minor Bump minor version when this PR gets merged label Oct 30, 2024
@robbie-c robbie-c merged commit ce93acd into main Oct 30, 2024
20 of 22 checks passed
@robbie-c robbie-c deleted the feature/add-timezone-to-events branch October 30, 2024 08:54
@@ -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;
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bump minor Bump minor version when this PR gets merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants