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.

fix(insights): correct mobile actions and transfer navigation (#107042)

Matt Pua3d58970f948c
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index cc416bb2617f..68fcb0fbaddb 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -6516,6 +6516,14 @@ snapshots:
hash: v1.k794b7964.f93f5836e1334a281785def757008dc8ffa21aa628abdad3699de6be7dfc57da.3fn8SNwLnaHNnbN_MopoEAmij74NXlwTFqZ_0EvbX5I
products-notebooks-dashboard-widget--saved-results--light:
hash: v1.k794b7964.f12c96e51ba15ba72a9e624e28c236e2117b2b1702aa983d7a0ad522c3d1e75e.ZrLMAxC9Z4gZ5qqJz7qFUUC7ykih0WvLmTJxitYD9Mg
+ products-notebooks-dashboard-widget--search-dashboard-by-creator--narrow--dark:
+ hash: v1.k794b7964.420b88ad149d19152ff8f1239ea9d8d35319e0b1bf4c1aae14cb773d958a1ae2.b7tEuMNcWeYGsqZkDKNZCz7H-xg8-d3H11AK-HWJzOY
+ products-notebooks-dashboard-widget--search-dashboard-by-creator--narrow--light:
+ hash: v1.k794b7964.c461f66b8a15203df372652f6322e407dc9f5fa6cf45156480bdc88822a30ce6.zx8iNjt1xP_kfZ3uydSe4Nj_F171G4DgizV_-l8lcBA
+ products-notebooks-dashboard-widget--search-dashboard-by-creator--wide--dark:
+ hash: v1.k794b7964.123382b87f95f9b8839032c88505de0eaf4eceed9092e1f25c24e87af669720c.Cg1vVScDMXtN7SDdxobEI3LqaI3-78O9-Xi8rRwWk54
+ products-notebooks-dashboard-widget--search-dashboard-by-creator--wide--light:
+ hash: v1.k794b7964.1a1fd60764b15bdd8ab1072705aae80fe0ac8e20846d7b0d3dddf0cbbf320f89.qBmud_ddtUDMuW4A3gkMxRN2UbQRoJ-0SgT4QmEJHn8
products-notebooks-notebook-widget-trust-controls--gate--dark:
hash: v1.k794b7964.97a5e7b5f92071f677d09773a3dea88ead3c9a71e85dbd6f6de8875ffc7a3036.9u2VOZ-O_aSU002VK8iAydGcjIYBXzRIacAelaDLJ6Y
products-notebooks-notebook-widget-trust-controls--gate--light:
diff --git a/frontend/src/scenes/insights/SidePanel/InsightPanelActions.tsx b/frontend/src/scenes/insights/SidePanel/InsightPanelActions.tsx
index 65c9bc30f39d..b36e37fd09ec 100644
--- a/frontend/src/scenes/insights/SidePanel/InsightPanelActions.tsx
+++ b/frontend/src/scenes/insights/SidePanel/InsightPanelActions.tsx
@@ -99,7 +99,7 @@ export function InsightPanelActions({ insightLogicProps }: { insightLogicProps:
{isSavedInsight && canCopyToProject && (
<ButtonPrimitive
menuItem
- onClick={() => push(urls.resourceTransfer('Insight', insight.id!))}
+ onClick={() => push(urls.resourceTransfer('Insight', insight.id!, insight.short_id))}
data-attr="insight-copy-to-project"
tooltip="Copy this insight to another project"
>
diff --git a/frontend/src/scenes/insights/SidePanel/InsightSceneMenuBar.tsx b/frontend/src/scenes/insights/SidePanel/InsightSceneMenuBar.tsx
index 8d8160b9ef50..415fdfab6e4d 100644
--- a/frontend/src/scenes/insights/SidePanel/InsightSceneMenuBar.tsx
+++ b/frontend/src/scenes/insights/SidePanel/InsightSceneMenuBar.tsx
@@ -288,7 +288,7 @@ function InsightSceneMenuBarInner({ insightLogicProps }: { insightLogicProps: In
<SceneMenuBarFileItems dataAttrKey={RESOURCE_TYPE} />
{showCopyToProject && (
<SceneMenuBarItem
- onClick={() => push(urls.resourceTransfer('Insight', insight.id!))}
+ onClick={() => push(urls.resourceTransfer('Insight', insight.id!, insight.short_id))}
data-attr={`${RESOURCE_TYPE}-menubar-copy-to-project`}
>
<IconCopy />
diff --git a/frontend/src/scenes/insights/insightLogic.tsx b/frontend/src/scenes/insights/insightLogic.tsx
index 68f54a677492..b3e3772d92df 100644
--- a/frontend/src/scenes/insights/insightLogic.tsx
+++ b/frontend/src/scenes/insights/insightLogic.tsx
@@ -41,6 +41,7 @@ import { Scene } from 'scenes/sceneTypes'
import { urls } from 'scenes/urls'
import { userLogic } from 'scenes/userLogic'
+import { sidePanelStateLogic } from '~/layout/navigation-3000/sidepanel/sidePanelStateLogic'
import { getLastNewFolder, refreshTreeItem } from '~/layout/panel-layout/ProjectTree/projectTreeLogic'
import { cohortsModel } from '~/models/cohortsModel'
import { dashboardsModel } from '~/models/dashboardsModel'
@@ -1332,7 +1333,13 @@ export const insightLogic: LogicWrapper<insightLogicType> = kea<insightLogicType
logic.actions.addInsight(newInsight)
}
lemonToast.success('Insight duplicated')
- redirectToInsight && router.actions.push(urls.insightEdit(newInsight.short_id))
+ if (redirectToInsight) {
+ const sidePanel = sidePanelStateLogic.findMounted()
+ if (sidePanel?.values.modalMode) {
+ sidePanel.actions.closeSidePanel()
+ }
+ router.actions.push(urls.insightEdit(newInsight.short_id))
+ }
} catch (e: any) {
// Nothing downstream reports this: the copy is created by a plain listener rather than
// a loader, so without a toast here a failure is indistinguishable from a dead button.
diff --git a/frontend/src/scenes/resource-transfer/ResourceTransfer.test.ts b/frontend/src/scenes/resource-transfer/ResourceTransfer.test.ts
new file mode 100644
index 000000000000..fa5c24eaa21b
--- /dev/null
+++ b/frontend/src/scenes/resource-transfer/ResourceTransfer.test.ts
@@ -0,0 +1,15 @@
+import { sourceResourceUrl } from './ResourceTransfer'
+
+describe('resource transfer back link', () => {
+ it('returns to the source insight using its short id', () => {
+ expect(sourceResourceUrl('Insight', '42', 'abc123')).toBe('/insights/abc123')
+ })
+
+ it('returns to the insights list when a direct transfer URL has no short id', () => {
+ expect(sourceResourceUrl('Insight', '42')).toBe('/insights')
+ })
+
+ it('returns to other resource pages using their numeric ids', () => {
+ expect(sourceResourceUrl('Dashboard', '42')).toBe('/dashboard/42')
+ })
+})
diff --git a/frontend/src/scenes/resource-transfer/ResourceTransfer.tsx b/frontend/src/scenes/resource-transfer/ResourceTransfer.tsx
index 34c720e1757e..ea9c465d6938 100644
--- a/frontend/src/scenes/resource-transfer/ResourceTransfer.tsx
+++ b/frontend/src/scenes/resource-transfer/ResourceTransfer.tsx
@@ -1,4 +1,5 @@
import { useActions, useValues } from 'kea'
+import { router } from 'kea-router'
import { useCallback } from 'react'
import { LemonButton, LemonInputSelect, LemonSelect, LemonSkeleton } from '@posthog/lemon-ui'
@@ -25,6 +26,7 @@ export const scene: SceneExport<ResourceTransferLogicProps> = {
}
export function ResourceTransfer(props: ResourceTransferLogicProps): JSX.Element {
+ const { searchParams } = useValues(router)
const logic = resourceTransferLogic(props)
const {
destinationTeamId,
@@ -49,7 +51,7 @@ export function ResourceTransfer(props: ResourceTransferLogicProps): JSX.Element
resourceType={{ type: 'Resource Transfer' }}
forceBackTo={{
name: rootResourceName ?? props.resourceKind,
- path: sourceResourceUrl(props.resourceKind, props.resourceId),
+ path: sourceResourceUrl(props.resourceKind, props.resourceId, searchParams.insight_short_id),
key: 'resource-transfer-back',
}}
/>
@@ -127,12 +129,12 @@ export function ResourceTransfer(props: ResourceTransferLogicProps): JSX.Element
)
}
-function sourceResourceUrl(resourceKind: string, resourceId: string): string {
+export function sourceResourceUrl(resourceKind: string, resourceId: string, insightShortId?: string): string {
switch (resourceKind) {
case 'Dashboard':
return urls.dashboard(resourceId)
case 'Insight':
- return urls.insightView(resourceId as InsightShortId)
+ return insightShortId ? urls.insightView(insightShortId as InsightShortId) : urls.insights()
case 'Survey':
return urls.survey(resourceId)
default:
diff --git a/frontend/src/scenes/urls.test.ts b/frontend/src/scenes/urls.test.ts
index 1d2d4d382920..39f921d32d59 100644
--- a/frontend/src/scenes/urls.test.ts
+++ b/frontend/src/scenes/urls.test.ts
@@ -1,6 +1,13 @@
import { urls } from './urls'
describe('urls', () => {
+ it('keeps the numeric transfer id and the insight short id separate', () => {
+ expect(urls.resourceTransfer('Insight', 42, 'abc123')).toBe(
+ '/resource-transfer/Insight/42?insight_short_id=abc123'
+ )
+ expect(urls.resourceTransfer('Dashboard', 42)).toBe('/resource-transfer/Dashboard/42')
+ })
+
it('links to the web analytics recap scene', () => {
expect(urls.webAnalyticsRecap()).toEqual('/web/recap')
})
diff --git a/frontend/src/scenes/urls.ts b/frontend/src/scenes/urls.ts
index 5383c155b5b4..8f1e3c8000fa 100644
--- a/frontend/src/scenes/urls.ts
+++ b/frontend/src/scenes/urls.ts
@@ -153,8 +153,8 @@ export const urls = {
variables: (): string => '/data-management/variables',
variable: (id: string | ':id'): string => `/data-management/variables/${id}`,
variableEdit: (id: string | ':id'): string => `/data-management/variables/${id}/edit`,
- resourceTransfer: (resourceKind: string, resourceId: string | number): string =>
- `/resource-transfer/${resourceKind}/${resourceId}`,
+ resourceTransfer: (resourceKind: string, resourceId: string | number, insightShortId?: string): string =>
+ combineUrl(`/resource-transfer/${resourceKind}/${resourceId}`, { insight_short_id: insightShortId }).url,
dashboardTemplateCopyToProject: (templateId: string | ':sourceTemplateId', sourceTeamId?: number): string => {
const path = `/dashboard/templates/${templateId}/copy-to-project`
return sourceTeamId === undefined
diff --git a/products/subscriptions/frontend/components/Subscriptions/views/SubscriptionOverviewComponents.tsx b/products/subscriptions/frontend/components/Subscriptions/views/SubscriptionOverviewComponents.tsx
index 176a93ff6de5..4b4e43bc9993 100644
--- a/products/subscriptions/frontend/components/Subscriptions/views/SubscriptionOverviewComponents.tsx
+++ b/products/subscriptions/frontend/components/Subscriptions/views/SubscriptionOverviewComponents.tsx
@@ -85,7 +85,7 @@ export function SubscriptionEmptyState({
return (
<LemonCard hoverEffect={false} className="p-6">
- <div className="flex gap-3 items-start">
+ <div className="flex flex-col items-start gap-3 @min-[30rem]/subscription-modal:flex-row">
{illustration ? (
illustration
) : (