feat(impersonation): add change user to impersonation tray#66384
Draft
xljones wants to merge 1 commit into
Draft
feat(impersonation): add change user to impersonation tray#66384xljones wants to merge 1 commit into
xljones wants to merge 1 commit into
Conversation
Add a "Change user" button to the impersonation tray that switches to another member of the impersonated org without logging out. Reuses the original impersonation reason (cached per user id in localStorage, swept on logout) and pre-fills the read-write upgrade modal with it. Generated-By: PostHog Code Task-Id: 8febe93f-9a2c-4866-b518-4233ea1628b7
Contributor
|
Size Change: 0 B Total Size: 64.3 MB ℹ️ View Unchanged
|
Contributor
|
Reviews (1): Last reviewed commit: "feat(impersonation): add change user to ..." | Re-trigger Greptile |
Comment on lines
+208
to
+212
| if (!resolvedReason) { | ||
| // The component prompts for a reason before dispatching when none is cached. | ||
| actions.changeUserFailure('A reason is required to change user') | ||
| return | ||
| } |
Contributor
There was a problem hiding this comment.
Silent failure when no reason can be resolved — the guard dispatches
changeUserFailure without showing a toast, so if this path is ever reached (e.g., localStorage is cleared between the component's render-time check and the listener running), the operator sees the loading indicator briefly reset with no explanation. Every other failure branch in this logic shows a toast.
Suggested change
| if (!resolvedReason) { | |
| // The component prompts for a reason before dispatching when none is cached. | |
| actions.changeUserFailure('A reason is required to change user') | |
| return | |
| } | |
| if (!resolvedReason) { | |
| // The component prompts for a reason before dispatching when none is cached. | |
| lemonToast.error('A reason is required to change user') | |
| actions.changeUserFailure('A reason is required to change user') | |
| return | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When impersonating a customer, switching to a different person in the same org means logging out and re-impersonating from scratch, re-entering the reason each time. Support staff often need to hop between users (e.g. an admin vs. a regular member) to reproduce an issue.
Changes
/admin/login/user/<id>/endpoint (no backend change —AdminImpersonationMiddlewarealready restores staff identity on/admin/paths mid-session), keeping the current read-only/read-write mode and doing a full reload.How did you test this code?
I'm an agent (PostHog Code). Automated tests only, no manual testing:
impersonationNoticeLogic.test.ts— member grouping/sorting/exclusion, change-user (reason reuse, read-only matching, reload, failure, no-reason guard), per-user reason keying (wrong-user reason not returned), and clear-all on logout/return.ImpersonationReasonModal.test.tsx(new) — upgrade modal pre-fills and confirms with the cached reason without re-typing.tsgoclean for the changed files.🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Built with PostHog Code (Claude). Key decisions: reused the existing loginas endpoint rather than adding a backend route (the admin-impersonation middleware makes mid-session re-impersonation work); cached the reason keyed by user id so a stale localStorage entry can never be applied to the wrong person, and sweep all entries on logout. No skills were required.
Created with PostHog Code