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(web-analytics): Send timezone to flags v2 #1849

Merged
merged 1 commit into from
Mar 26, 2025

Conversation

robbie-c
Copy link
Member

@robbie-c robbie-c commented Mar 26, 2025

Changes

Send timezone to flags v2. It's needed to figure out the user's calendar date, for the cookieless hash. We should merge PostHog/posthog#30304 first

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!)

It's needed to figure out the user's calendar date, for the cookieless hash
Copy link

vercel bot commented Mar 26, 2025

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

Name Status Preview Updated (UTC)
posthog-js ✅ Ready (Inspect) Visit Preview Mar 26, 2025 9:23am

@@ -71,6 +71,14 @@ export default function Home() {

<button className="ph-no-capture">Ignore certain elements</button>

<button
onClick={() => {
posthog?.reloadFeatureFlags()
Copy link
Member Author

Choose a reason for hiding this comment

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

I just included this button here as it's a reliable way to trigger a call to the flags endpoint

@robbie-c robbie-c changed the title Send timezone to flags v2 feat(web-analytics): Send timezone to flags v2 Mar 26, 2025
@robbie-c robbie-c requested review from dmarticus, haacked and a team March 26, 2025 09:22
@robbie-c robbie-c marked this pull request as ready for review March 26, 2025 09:22
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Adds timezone information to feature flag requests when using flags v2 API, enabling proper calendar date determination for cookieless hash functionality.

  • Added timezone parameter in src/posthog-featureflags.ts when both __preview_flags_v2 and __preview_remote_config configs are enabled
  • Added reloadFeatureFlags button in playground app for testing flag reloading functionality
  • Implementation maintains backward compatibility by only adding timezone for v2 API requests
  • Uses existing Info.timezone() utility to retrieve timezone data

2 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

Copy link

Size Change: +300 B (+0.01%)

Total Size: 3.64 MB

Filename Size Change
dist/array.full.es5.js 302 kB +30 B (+0.01%)
dist/array.full.js 382 kB +30 B (+0.01%)
dist/array.full.no-external.js 381 kB +30 B (+0.01%)
dist/array.js 189 kB +30 B (+0.02%)
dist/array.no-external.js 188 kB +30 B (+0.02%)
dist/main.js 190 kB +30 B (+0.02%)
dist/module.full.js 382 kB +30 B (+0.01%)
dist/module.full.no-external.js 381 kB +30 B (+0.01%)
dist/module.js 189 kB +30 B (+0.02%)
dist/module.no-external.js 188 kB +30 B (+0.02%)
ℹ️ View Unchanged
Filename Size
dist/all-external-dependencies.js 220 kB
dist/customizations.full.js 14.1 kB
dist/dead-clicks-autocapture.js 14.4 kB
dist/exception-autocapture.js 9.94 kB
dist/external-scripts-loader.js 2.75 kB
dist/posthog-recorder.js 211 kB
dist/recorder-v2.js 115 kB
dist/recorder.js 115 kB
dist/surveys-preview.js 71.3 kB
dist/surveys.js 76.6 kB
dist/tracing-headers.js 1.76 kB
dist/web-vitals.js 10.4 kB

compressed-size-action

@robbie-c robbie-c requested review from a team and lricoy and removed request for a team March 26, 2025 18:42
@robbie-c robbie-c added the bump patch Bump patch version when this PR gets merged label Mar 26, 2025
Copy link
Member

@lricoy lricoy left a comment

Choose a reason for hiding this comment

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

LGTM

@robbie-c robbie-c merged commit 44d15aa into main Mar 26, 2025
29 of 33 checks passed
@robbie-c robbie-c deleted the feat/send-extra-cookieless-flags-to-rust-flags branch March 26, 2025 19:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bump patch Bump patch version when this PR gets merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants