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(persons): rename urls.person(id) to urls.personDistinctId(id) #17734

Merged
merged 3 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ export const commandPaletteLogic = kea<commandPaletteLogicType>({
display: `View person ${input}`,
executor: () => {
const { push } = router.actions
push(urls.person(person.distinct_ids[0]))
push(urls.personByDistinctId(person.distinct_ids[0]))
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function redirectOnSelectItems(
} else if (groupType === TaxonomicFilterGroupType.Cohorts) {
router.actions.push(urls.cohort(value))
} else if (groupType === TaxonomicFilterGroupType.Persons) {
router.actions.push(urls.person(String(value)))
router.actions.push(urls.personByDistinctId(String(value)))
} else if (groupType.startsWith(TaxonomicFilterGroupType.GroupNamesPrefix)) {
router.actions.push(urls.group((item as Group).group_type_index, String(value)))
} else if (groupType === TaxonomicFilterGroupType.Insights) {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/queries/nodes/DataTable/renderColumn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export function renderColumn(
} else if (key === 'person' && isPersonsNode(query.source)) {
const personRecord = record as PersonType
return (
<Link to={urls.person(personRecord.distinct_ids[0])}>
<Link to={urls.personByDistinctId(personRecord.distinct_ids[0])}>
<PersonDisplay noLink withIcon person={personRecord} noPopover />
</Link>
)
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/scenes/appScenes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const appScenes: Record<Scene, () => any> = {
[Scene.Replay]: () => import('./session-recordings/SessionRecordings'),
[Scene.ReplaySingle]: () => import('./session-recordings/detail/SessionRecordingDetail'),
[Scene.ReplayPlaylist]: () => import('./session-recordings/playlist/SessionRecordingsPlaylistScene'),
[Scene.Person]: () => import('./persons/Person'),
[Scene.Person]: () => import('./persons/PersonScene'),
[Scene.Persons]: () => import('./persons/PersonsScene'),
[Scene.Groups]: () => import('./groups/Groups'),
[Scene.Group]: () => import('./groups/Group'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,14 @@ const WARNING_TYPE_RENDERER = {
return (
<>
Refused to merge already identified person{' '}
<Link to={urls.person(details.sourcePersonDistinctId)}>{details.sourcePersonDistinctId}</Link> into{' '}
<Link to={urls.person(details.targetPersonDistinctId)}>{details.targetPersonDistinctId}</Link> via an
$identify or $create_alias call (event uuid: <code>{details.eventUuid}</code>).
<Link to={urls.personByDistinctId(details.sourcePersonDistinctId)}>
{details.sourcePersonDistinctId}
</Link>{' '}
into{' '}
<Link to={urls.personByDistinctId(details.targetPersonDistinctId)}>
{details.targetPersonDistinctId}
</Link>{' '}
via an $identify or $create_alias call (event uuid: <code>{details.eventUuid}</code>).
</>
)
},
Expand All @@ -51,9 +56,9 @@ const WARNING_TYPE_RENDERER = {
return (
<>
Refused to merge an illegal distinct_id{' '}
<Link to={urls.person(details.illegalDistinctId)}>{details.illegalDistinctId}</Link> with{' '}
<Link to={urls.person(details.otherDistinctId)}>{details.otherDistinctId}</Link> via an $identify or
$create_alias call (event uuid: <code>{details.eventUuid}</code>).
<Link to={urls.personByDistinctId(details.illegalDistinctId)}>{details.illegalDistinctId}</Link> with{' '}
<Link to={urls.personByDistinctId(details.otherDistinctId)}>{details.otherDistinctId}</Link> via an
$identify or $create_alias call (event uuid: <code>{details.eventUuid}</code>).
</>
)
},
Expand Down Expand Up @@ -116,8 +121,8 @@ const WARNING_TYPE_RENDERER = {
return (
<>
Event ingestion has overflowed capacity for distinct_id{' '}
<Link to={urls.person(details.overflowDistinctId)}>{details.overflowDistinctId}</Link>. Events will
still be processed, but are likely to be delayed longer than usual.
<Link to={urls.personByDistinctId(details.overflowDistinctId)}>{details.overflowDistinctId}</Link>.
Events will still be processed, but are likely to be delayed longer than usual.
</>
)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function backlinkHref(id: string, type: TaxonomicFilterGroupType): string {
} else if (type === TaxonomicFilterGroupType.Cohorts) {
return urls.cohort(id)
} else if (type === TaxonomicFilterGroupType.Persons) {
return urls.person(id)
return urls.personByDistinctId(id)
} else if (type === TaxonomicFilterGroupType.Insights) {
return urls.insightView(id as InsightModel['short_id'])
} else if (type === TaxonomicFilterGroupType.FeatureFlags) {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/scenes/notebooks/Nodes/NotebookNodePerson.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,13 @@ export const NotebookNodePerson = createPostHogWidgetNode<NotebookNodePersonAttr
Component,
heightEstimate: 300,
minHeight: 100,
href: (attrs) => urls.person(attrs.id),
href: (attrs) => urls.personByDistinctId(attrs.id),
resizeable: true,
attributes: {
id: {},
},
pasteOptions: {
find: urls.person('(.+)', false),
find: urls.personByDistinctId('(.+)', false),
getAttributes: async (match) => {
return { id: match[1] }
},
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/scenes/persons/PersonPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function PersonPreview(props: PersonPreviewProps): JSX.Element | null {
}

const display = asDisplay(person)
const url = urls.person(person?.distinct_ids[0])
const url = urls.personByDistinctId(person?.distinct_ids[0])

return (
<div className="flex flex-col overflow-hidden max-h-80 max-w-160 gap-2">
Expand All @@ -51,7 +51,11 @@ export function PersonPreview(props: PersonPreviewProps): JSX.Element | null {
onNotebookOpened={() => props.onClose?.()}
size="small"
/>
<LemonButton size="small" icon={<IconOpenInNew />} to={urls.person(person?.distinct_ids[0])} />
<LemonButton
size="small"
icon={<IconOpenInNew />}
to={urls.personByDistinctId(person?.distinct_ids[0])}
/>
</div>

<div className="flex-1 overflow-y-auto border-t">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { PersonDashboard } from './PersonDashboard'
import { NotebookSelectButton } from 'scenes/notebooks/NotebookSelectButton/NotebookSelectButton'

export const scene: SceneExport = {
component: Person,
component: PersonScene,
logic: personsLogic,
paramsToProps: ({ params: { _: rawUrlId } }): (typeof personsLogic)['props'] => ({
syncWithUrl: true,
Expand Down Expand Up @@ -106,7 +106,7 @@ function PersonCaption({ person }: { person: PersonType }): JSX.Element {
)
}

export function Person(): JSX.Element | null {
export function PersonScene(): JSX.Element | null {
const {
showCustomerSuccessDashboards,
person,
Expand All @@ -127,7 +127,7 @@ export function Person(): JSX.Element | null {
return personLoading ? <SpinnerOverlay sceneLevel /> : <NotFound object="Person" />
}

const url = urls.person(urlId || person.distinct_ids[0] || String(person.id))
const url = urls.personByDistinctId(urlId || person.distinct_ids[0] || String(person.id))

return (
<>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/scenes/persons/activityDescriptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function personActivityDescriber(logItem: ActivityLogItem): HumanizedChan
}
listParts={distinctIds.map((di) => (
<span key={di} className="highlighted-activity">
<Link to={urls.person(di)}>{di}</Link>
<Link to={urls.personByDistinctId(di)}>{di}</Link>
</span>
))}
/>
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/scenes/persons/person-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { asLink, asDisplay } from './person-utils'
describe('the person header', () => {
describe('linking to a person', () => {
const personLinksTestCases = [
{ distinctIds: ['a uuid'], expectedLink: urls.person('a uuid'), name: 'with one id' },
{ distinctIds: ['a uuid'], expectedLink: urls.personByDistinctId('a uuid'), name: 'with one id' },
{
distinctIds: ['the first uuid', 'a uuid'],
expectedLink: urls.person('the first uuid'),
expectedLink: urls.personByDistinctId('the first uuid'),
name: 'with more than one id',
},
{
Expand All @@ -19,7 +19,7 @@ describe('the person header', () => {
},
{
distinctIds: ['a+dicey/@!'],
expectedLink: urls.person('a+dicey/@!'),
expectedLink: urls.personByDistinctId('a+dicey/@!'),
name: 'with no ids',
},
]
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/scenes/persons/person-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export function asDisplay(person: PersonPropType | null | undefined, maxLength?:

export const asLink = (person?: PersonPropType | null): string | undefined =>
person?.distinct_id
? urls.person(person.distinct_id)
? urls.personByDistinctId(person.distinct_id)
: person?.distinct_ids?.length
? urls.person(person.distinct_ids[0])
? urls.personByDistinctId(person.distinct_ids[0])
: undefined
2 changes: 1 addition & 1 deletion frontend/src/scenes/project-homepage/NewlySeenPersons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function PersonRow({ person }: { person: PersonType }): JSX.Element {

return (
<ProjectHomePageCompactListItem
to={urls.person(person.distinct_ids[0])}
to={urls.personByDistinctId(person.distinct_ids[0])}
title={asDisplay(person)}
subtitle={`First seen ${dayjs(person.created_at).fromNow()}`}
prefix={<ProfilePicture name={asDisplay(person)} />}
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/scenes/retention/RetentionModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ export function RetentionModal(): JSX.Element | null {
) : (
<LemonButton
size="small"
to={urls.person(personAppearances.person.distinct_ids[0])}
to={urls.personByDistinctId(
personAppearances.person.distinct_ids[0]
)}
data-attr="retention-person-link"
>
{asDisplay(personAppearances.person)}
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/scenes/scenes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ export const routes: Record<string, Scene> = {
}, {} as Record<string, Scene>),
[urls.replaySingle(':id')]: Scene.ReplaySingle,
[urls.replayPlaylist(':id')]: Scene.ReplayPlaylist,
[urls.person('*', false)]: Scene.Person,
[urls.personByDistinctId('*', false)]: Scene.Person,
[urls.persons()]: Scene.Persons,
[urls.groups(':groupTypeIndex')]: Scene.Groups,
[urls.group(':groupTypeIndex', ':groupKey', false)]: Scene.Group,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/scenes/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const urls = {
combineUrl(`/replay/playlists/${id}`, filters ? { filters } : {}).url,
replaySingle: (id: string, filters?: Partial<FilterType>): string =>
combineUrl(`/replay/${id}`, filters ? { filters } : {}).url,
person: (id: string, encode: boolean = true): string =>
personByDistinctId: (id: string, encode: boolean = true): string =>
encode ? `/person/${encodeURIComponent(id)}` : `/person/${id}`,
persons: (): string => '/persons',
groups: (groupTypeIndex: string | number): string => `/groups/${groupTypeIndex}`,
Expand Down
Loading