Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore: promote the actual important impersonation actions (#71466)

Luke Beltone3dbba7113f7
diff --git a/frontend/src/layout/navigation/ImpersonationNotice/ImpersonationNotice.scss b/frontend/src/layout/navigation/ImpersonationNotice/ImpersonationNotice.scss
index 0ab033057689..70c3cbd85c2b 100644
--- a/frontend/src/layout/navigation/ImpersonationNotice/ImpersonationNotice.scss
+++ b/frontend/src/layout/navigation/ImpersonationNotice/ImpersonationNotice.scss
@@ -1,4 +1,6 @@
.ImpersonationNotice {
+ --impersonation-notice-border-accent: var(--color-border-warning);
+
display: flex;
width: 26rem;
background-color: var(--color-bg-surface-primary);
@@ -38,6 +40,8 @@
}
&--read-write {
+ --impersonation-notice-border-accent: var(--color-border-error);
+
.ImpersonationNotice__sidebar {
background: var(--danger);
}
@@ -163,19 +167,32 @@
color: var(--text-primary);
}
- // The change-user menu trigger sits inline in the "Signed in as …" sentence,
- // so it reads as the (clickable) email rather than a standalone button.
- &__user-trigger.LemonButton {
+ &__inline-trigger.LemonButton {
display: inline-flex;
- max-width: 100%;
min-height: auto;
- padding: 0 0.25rem;
font-size: inherit;
- font-weight: 600;
vertical-align: baseline;
- border: 1px solid var(--color-border-warning);
+ }
+
+ &__user-trigger.LemonButton {
+ max-width: 100%;
+ font-weight: 600;
+ border: 1px solid var(--impersonation-notice-border-accent);
border-radius: var(--radius);
}
+
+ &__expiry {
+ display: flex;
+ gap: 0.5rem;
+ align-items: center;
+ font-size: var(--text-xs);
+ color: var(--color-text-tertiary);
+
+ // Match the refresh icon to the subtle expiry text.
+ .LemonButton {
+ --lemon-button-color: var(--color-text-tertiary);
+ }
+ }
}
@keyframes ImpersonationNotice__fadeScaleIn {
diff --git a/frontend/src/layout/navigation/ImpersonationNotice/ImpersonationNotice.tsx b/frontend/src/layout/navigation/ImpersonationNotice/ImpersonationNotice.tsx
index 4b3f06d3753b..798ee74dcb83 100644
--- a/frontend/src/layout/navigation/ImpersonationNotice/ImpersonationNotice.tsx
+++ b/frontend/src/layout/navigation/ImpersonationNotice/ImpersonationNotice.tsx
@@ -3,7 +3,7 @@ import './ImpersonationNotice.scss'
import { useActions, useValues } from 'kea'
import { useCallback, useEffect, useRef, useState } from 'react'
-import { IconChevronDown, IconCollapse, IconEllipsis, IconWarning } from '@posthog/icons'
+import { IconChevronDown, IconCollapse, IconRefresh, IconWarning } from '@posthog/icons'
import { LemonButton, LemonCheckbox, LemonMenu, LemonTag, Tooltip } from '@posthog/lemon-ui'
import { DraggableWithSnapZones, DraggableWithSnapZonesRef } from 'lib/components/DraggableWithSnapZones'
@@ -70,7 +70,7 @@ function CountDown({ datetime, callback }: { datetime: dayjs.Dayjs; callback?: (
}
}, [pastCountdown, callback])
- return <span className="tabular-nums text-warning">{countdown}</span>
+ return <span className="tabular-nums">{countdown}</span>
}
function LoginAsContent({
@@ -149,6 +149,7 @@ function ImpersonationNoticeContent(): JSX.Element {
const {
closeUpgradeModal,
upgradeImpersonation,
+ openUpgradeModal,
setSessionExpired,
returnToPostHog,
changeUser,
@@ -198,7 +199,7 @@ function ImpersonationNoticeContent(): JSX.Element {
loading={isChangingUser}
tooltip={`Currently impersonating ${user?.email} - click to switch user`}
truncate
- className="ImpersonationNotice__user-trigger text-warning"
+ className="ImpersonationNotice__inline-trigger ImpersonationNotice__user-trigger text-warning"
>
{user?.email}
</LemonButton>
@@ -210,21 +211,36 @@ function ImpersonationNoticeContent(): JSX.Element {
</>
)}
.
- {user?.is_impersonated_until && (
- <>
- {' '}
- Expires in{' '}
- <CountDown datetime={dayjs(user.is_impersonated_until)} callback={handleSessionExpired} />.
- </>
- )}
</p>
+ {user?.is_impersonated_until && (
+ <div className="ImpersonationNotice__expiry">
+ <span>
+ Expires in{' '}
+ <CountDown datetime={dayjs(user.is_impersonated_until)} callback={handleSessionExpired} />
+ </span>
+ <LemonButton
+ type="secondary"
+ size="xxsmall"
+ icon={<IconRefresh />}
+ onClick={() => loadUser()}
+ loading={userLoading}
+ tooltip="Refresh"
+ />
+ </div>
+ )}
<div className="flex gap-2 justify-end">
- <LemonButton type="secondary" size="small" onClick={() => loadUser()} loading={userLoading}>
- Refresh
- </LemonButton>
+ {isReadOnly && (
+ <LemonButton
+ type="secondary"
+ size="small"
+ onClick={() => openUpgradeModal()}
+ tooltip="Upgrade your impersonation session to have read-write permissions"
+ >
+ Upgrade to read-write
+ </LemonButton>
+ )}
<LemonButton
- type="secondary"
- status="danger"
+ type="primary"
size="small"
onClick={() => logout()}
sideAction={{
@@ -284,7 +300,7 @@ export function ImpersonationNotice(): JSX.Element | null {
ticketContext,
adminLoginUrls,
} = useValues(impersonationNoticeLogic)
- const { minimize, maximize, openUpgradeModal, setPageVisible } = useActions(impersonationNoticeLogic)
+ const { minimize, maximize, setPageVisible } = useActions(impersonationNoticeLogic)
const { isVisible: isPageVisible } = usePageVisibility()
@@ -355,18 +371,6 @@ export function ImpersonationNotice(): JSX.Element | null {
<div className="ImpersonationNotice__header">
<IconWarning className="ImpersonationNotice__warning-icon" />
<span className="ImpersonationNotice__title">{title}</span>
- {isImpersonated && isReadOnly && (
- <LemonMenu
- items={[
- {
- label: 'Upgrade to read-write',
- onClick: openUpgradeModal,
- },
- ]}
- >
- <LemonButton size="xsmall" icon={<IconEllipsis />} />
- </LemonMenu>
- )}
<LemonButton size="xsmall" icon={<IconCollapse />} onClick={handleMinimize} />
</div>
<div className="ImpersonationNotice__content">