Skip to content

Commit

Permalink
feat: add link from live events view to explore view (#29349)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Michael Matloka <[email protected]>
  • Loading branch information
3 people authored Mar 1, 2025
1 parent cbf88b2 commit e6cdfed
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 17 deletions.
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

0 comments on commit e6cdfed

Please sign in to comment.