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.

feat(dashboards): copy an insight link from the tile menu (#87535)

Paul D'Ambrae038dcf25de5
diff --git a/frontend/src/lib/components/Cards/InsightCard/InsightMeta.tsx b/frontend/src/lib/components/Cards/InsightCard/InsightMeta.tsx
index c6d6fd0b4507..ccdd8a09b8d0 100644
--- a/frontend/src/lib/components/Cards/InsightCard/InsightMeta.tsx
+++ b/frontend/src/lib/components/Cards/InsightCard/InsightMeta.tsx
@@ -14,6 +14,7 @@ import { ExportButton } from 'lib/components/ExportButton/ExportButton'
import { ObjectTags } from 'lib/components/ObjectTags/ObjectTags'
import { FEATURE_FLAGS } from 'lib/constants'
import { dayjs } from 'lib/dayjs'
+import { IconLink } from 'lib/lemon-ui/icons'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { LemonDivider } from 'lib/lemon-ui/LemonDivider'
import { LemonMarkdown } from 'lib/lemon-ui/LemonMarkdown'
@@ -25,6 +26,7 @@ import { Spinner } from 'lib/lemon-ui/Spinner'
import { Splotch, SplotchColor } from 'lib/lemon-ui/Splotch'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { accessLevelSatisfied } from 'lib/utils/accessControlUtils'
+import { copyToClipboard } from 'lib/utils/copyToClipboard'
import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
import { capitalizeFirstLetter } from 'lib/utils/strings'
import { insightDataLogic } from 'scenes/insights/insightDataLogic'
@@ -385,6 +387,18 @@ export function InsightMeta({
}
: undefined
+ // Carries the dashboard's filters and variables, so the link opens exactly what the tile shows
+ const insightViewUrl = urls.insightView(
+ short_id,
+ dashboardId,
+ variablesOverride,
+ filtersOverride,
+ tileFiltersOverride
+ )
+ const copyInsightLink = (): void => {
+ void copyToClipboard(urls.absolute(urls.currentProject(insightViewUrl)), 'insight link')
+ }
+
return (
<>
<CardMeta
@@ -400,13 +414,7 @@ export function InsightMeta({
popoverTopHeading={popoverTopHeadingEl}
content={
<InsightMetaContent
- link={urls.insightView(
- short_id,
- dashboardId,
- variablesOverride,
- filtersOverride,
- tileFiltersOverride
- )}
+ link={insightViewUrl}
title={name}
fallbackTitle={summary}
description={insight.description}
@@ -440,14 +448,17 @@ export function InsightMeta({
{/* Insight related */}
{canViewInsight && (
<LemonButton
- to={urls.insightView(
- short_id,
- dashboardId,
- variablesOverride,
- filtersOverride,
- tileFiltersOverride
- )}
+ to={insightViewUrl}
fullWidth
+ sideAction={{
+ icon: <IconLink />,
+ tooltip: 'Copy link to insight',
+ 'aria-label': 'Copy link to insight',
+ 'data-attr': dashboardId
+ ? 'copy-insight-link-from-dashboard'
+ : 'copy-insight-link-from-card-list-view',
+ onClick: copyInsightLink,
+ }}
>
View
</LemonButton>