Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add link from live events view to explore view #29349

Merged
merged 13 commits into from
Mar 1, 2025
Merged
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 24 additions & 15 deletions frontend/src/queries/nodes/DataTable/EventRowActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { More } from 'lib/lemon-ui/LemonButton/More'
import { copyToClipboard } from 'lib/utils/copyToClipboard'
import { getCurrentTeamId } from 'lib/utils/getAppContext'
import React from 'react'
import { createActionFromEvent } from 'scenes/activity/explore/createActionFromEvent'
import { insightUrlForEvent } from 'scenes/insights/utils'
import { teamLogic } from 'scenes/teamLogic'
Expand Down Expand Up @@ -40,21 +41,7 @@ export function EventRowActions({ event }: EventActionProps): JSX.Element {
Create action from event
</LemonButton>
)}
{event.uuid && event.timestamp && (
<LemonButton
fullWidth
sideIcon={<IconLink />}
data-attr="events-table-event-link"
onClick={() =>
void copyToClipboard(
urls.absolute(urls.currentProject(urls.event(String(event.uuid), event.timestamp))),
'link to event'
)
}
>
Copy link to event
</LemonButton>
)}
{event.uuid && event.timestamp && <EventCopyLinkButton event={event} />}
<ViewRecordingButton
fullWidth
inModal
Expand Down Expand Up @@ -94,3 +81,25 @@ export function EventRowActions({ event }: EventActionProps): JSX.Element {
/>
)
}

export const EventCopyLinkButton = React.forwardRef<
HTMLButtonElement,
{ event: Pick<EventType, 'uuid' | 'timestamp'> }
>(function EventCopyLinkButton({ event }, ref) {
return (
<LemonButton
ref={ref}
fullWidth
sideIcon={<IconLink />}
data-attr="events-table-event-link"
onClick={() =>
void copyToClipboard(
urls.absolute(urls.currentProject(urls.event(String(event.uuid), event.timestamp))),
'link to event'
)
}
>
Copy link to event
</LemonButton>
)
})
17 changes: 17 additions & 0 deletions frontend/src/scenes/activity/live/LiveEventsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ import { useActions, useValues } from 'kea'
import { PropertyKeyInfo } from 'lib/components/PropertyKeyInfo'
import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
import { TZLabel } from 'lib/components/TZLabel'
import { More } from 'lib/lemon-ui/LemonButton/More'
import { LemonTable, LemonTableColumns } from 'lib/lemon-ui/LemonTable'
import { liveEventsTableLogic } from 'scenes/activity/live/liveEventsTableLogic'
import { PersonDisplay } from 'scenes/persons/PersonDisplay'

import { EventCopyLinkButton } from '~/queries/nodes/DataTable/EventRowActions'
import type { LiveEvent } from '~/types'

const columns: LemonTableColumns<LiveEvent> = [
Expand Down Expand Up @@ -46,6 +48,21 @@ const columns: LemonTableColumns<LiveEvent> = [
return <TZLabel time={event.timestamp} />
},
},
{
dataIndex: '__more' as any,
render: function Render(_, event: LiveEvent) {
return (
<More
overlay={
<Tooltip title="It may take up to a few minutes for the event to show up in the Explore view">
<EventCopyLinkButton event={event} />
</Tooltip>
}
/>
)
},
width: 0,
},
]

export function LiveEventsTable(): JSX.Element {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/scenes/scenes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,8 @@ export const redirects: Record<
])
try {
const timestamp = decodeURIComponent(_)
const after = dayjs(timestamp).subtract(1, 'second').startOf('second').toISOString()
const before = dayjs(timestamp).add(1, 'second').startOf('second').toISOString()
const after = dayjs(timestamp).subtract(15, 'second').startOf('second').toISOString()
const before = dayjs(timestamp).add(15, 'second').startOf('second').toISOString()
Object.assign(query.source as EventsQuery, { before, after })
} catch (e) {
lemonToast.error('Invalid event timestamp')
Expand Down
Loading