: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(endpoints): report clipboard copy failures on copy buttons (#90395)
Arno Hillen1b5ec218efda
diff --git a/products/endpoints/frontend/EndpointHeader.tsx b/products/endpoints/frontend/EndpointHeader.tsxindex 5a9e2074a602..467a71777346 100644--- a/products/endpoints/frontend/EndpointHeader.tsx+++ b/products/endpoints/frontend/EndpointHeader.tsx@@ -5,8 +5,8 @@ import { LemonButton, LemonLabel, LemonSwitch } from '@posthog/lemon-ui'import { AccessControlAction } from 'lib/components/AccessControlAction'import { superpowersLogic } from 'lib/components/Superpowers/superpowersLogic'-import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'import { getAccessControlDisabledReason } from 'lib/utils/accessControlUtils'+import { copyToClipboard } from 'lib/utils/copyToClipboard'import { objectsEqual } from 'lib/utils/objects'import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'@@ -230,10 +230,7 @@ function DebugField({ label, value }: { label: string; value: string }): JSX.Ele<LemonButtontype="secondary"size="xsmall"- onClick={() => {- navigator.clipboard.writeText(value)- lemonToast.success(`${label} copied to clipboard`)- }}+ onClick={() => void copyToClipboard(value, label)}className="font-mono text-xs">{value}diff --git a/products/endpoints/frontend/Endpoints.tsx b/products/endpoints/frontend/Endpoints.tsxindex 229b4963d4d4..9d214afc2516 100644--- a/products/endpoints/frontend/Endpoints.tsx+++ b/products/endpoints/frontend/Endpoints.tsx@@ -14,7 +14,7 @@ import { LemonTable, LemonTableColumn, LemonTableColumns } from 'lib/lemon-ui/Leimport { atColumn, createdAtColumn, createdByColumn } from 'lib/lemon-ui/LemonTable/columnUtils'import { LemonTableLink } from 'lib/lemon-ui/LemonTable/LemonTableLink'import { LemonTag } from 'lib/lemon-ui/LemonTag'-import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'+import { copyToClipboard } from 'lib/utils/copyToClipboard'import { urls } from 'scenes/urls'import { SceneContent } from '~/layout/scenes/components/SceneContent'@@ -129,10 +129,7 @@ export const EndpointsTable = (): JSX.Element => {<LemonButtontype="secondary"size="xsmall"- onClick={() => {- navigator.clipboard.writeText(record.endpoint_path)- lemonToast.success('Endpoint URL copied to clipboard')- }}+ onClick={() => void copyToClipboard(record.endpoint_path, 'endpoint URL')}className="font-mono text-xs">{record.endpoint_path}diff --git a/products/endpoints/frontend/endpoint-tabs/EndpointOverview.tsx b/products/endpoints/frontend/endpoint-tabs/EndpointOverview.tsxindex 67f557c40c8f..2f536048cceb 100644--- a/products/endpoints/frontend/endpoint-tabs/EndpointOverview.tsx+++ b/products/endpoints/frontend/endpoint-tabs/EndpointOverview.tsx@@ -3,8 +3,8 @@ import { useValues } from 'kea'import { LemonButton, LemonLabel, LemonTag, ProfilePicture } from '@posthog/lemon-ui'import { TZLabel } from 'lib/components/TZLabel'-import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'import { Link } from 'lib/lemon-ui/Link'+import { copyToClipboard } from 'lib/utils/copyToClipboard'import { urls } from 'scenes/urls'import { endpointLogic } from '../endpointLogic'@@ -54,10 +54,7 @@ export function EndpointOverview(): JSX.Element {<LemonButtontype="secondary"size="xsmall"- onClick={() => {- navigator.clipboard.writeText(endpoint.endpoint_path)- lemonToast.success('Endpoint URL copied to clipboard')- }}+ onClick={() => void copyToClipboard(endpoint.endpoint_path, 'endpoint URL')}className="font-mono text-xs">{endpoint.endpoint_path}@@ -101,10 +98,7 @@ export function EndpointOverview(): JSX.Element {<LemonButtontype="secondary"size="xsmall"- onClick={() => {- navigator.clipboard.writeText(versionUrl!)- lemonToast.success('Version URL copied to clipboard')- }}+ onClick={() => void copyToClipboard(versionUrl!, 'version URL')}className="font-mono text-xs">{versionUrl}