Skip to content

Conversation

Copy link

Copilot AI commented Nov 12, 2025

Problem

Users redirecting between PostHog Cloud regions (US/EU) must wait 7 seconds on every redirect, even for frequent cross-region users.

Changes

Added an "Always redirect" checkbox that persists user preference in localStorage to skip the countdown:

UI Changes:

  • Added LemonCheckbox to redirect modal with label "Always redirect"
  • Checkbox state persists across sessions via localStorage.ph_auto_redirect_region

Behavior:

  • Unchecked (default): Shows modal with 7-second countdown
  • Checked: Redirects immediately, skips modal entirely
  • Preference checked on mount in useOnMountEffect

Analytics:

  • Redirect to logged-in instance modal shown - fires for both manual (modal shown) and automatic redirects
  • When auto-redirecting, event includes auto: true property to distinguish from manual modal displays
  • Redirect to logged-in instance always redirect toggled - tracks preference changes
// Check localStorage on mount
const autoRedirectEnabled = localStorage.getItem(AUTO_REDIRECT_KEY) === 'true'
if (autoRedirectEnabled) {
    posthog.capture('Redirect to logged-in instance modal shown', { 
        ..., 
        auto: true 
    })
    window.location.assign(newUrl.href)  // Skip modal
} else {
    setAlwaysRedirect(autoRedirectEnabled)
    setIsOpen(true)  // Show timer modal
    posthog.capture('Redirect to logged-in instance modal shown', { ... })
}

How did you test this code?

  • Added unit tests for localStorage read/write (13 tests total, all passing)
  • Verified TypeScript compilation and linting
  • Existing redirect logic unchanged when checkbox unchecked

Changelog: (features only) Is this feature complete?

Yes

Original prompt

There is a dialog that says:
"You're already logged into PostHog Cloud in the EU region."

This dialog automatically redirects after 5 seconds. Add a checkbox "Always redirect", that stores a local property that allows me to skip waiting for the automatic redirect


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add checkbox to skip automatic redirect in PostHog Cloud dialog Add "Always redirect" checkbox to skip region redirect delay Nov 12, 2025
@IchordeDionysos
Copy link

@copilot frontend/src/scenes/authentication/RedirectToLoggedInInstance.tsx:110-114
Use the same event with a property "auto": true instead

frontend/src/scenes/authentication/RedirectToLoggedInInstance.tsx:106

Copy link
Author

Copilot AI commented Nov 13, 2025

@copilot frontend/src/scenes/authentication/RedirectToLoggedInInstance.tsx:110-114
Use the same event with a property "auto": true instead
...

Changed to use the same event name 'Redirect to logged-in instance modal shown' with property auto: true for automatic redirects. Also moved setAlwaysRedirect to only run when showing the modal (line 118), since it's not needed when auto-redirecting.

Commit: f634f1e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants