remove fake names from profile

This commit is contained in:
Carl-Gerhard Lindesvärd
2024-05-06 09:20:45 +02:00
parent 2e2ee1422f
commit fc0a6a3c73
8 changed files with 55 additions and 41 deletions

View File

@@ -24,6 +24,7 @@ export async function updateProfile(
await upsertProfile({
id: profileId,
isExternal: true,
projectId,
properties: {
...(properties ?? {}),
@@ -45,7 +46,7 @@ export async function incrementProfileProperty(
const { profileId, property, value } = request.body;
const projectId = request.projectId;
const profile = await getProfileById(profileId);
const profile = await getProfileById(profileId, projectId);
if (!profile) {
return reply.status(404).send('Not found');
}
@@ -69,6 +70,7 @@ export async function incrementProfileProperty(
id: profile.id,
projectId,
properties: profile.properties,
isExternal: true,
});
reply.status(202).send(profile.id);
@@ -83,7 +85,7 @@ export async function decrementProfileProperty(
const { profileId, property, value } = request.body;
const projectId = request.projectId;
const profile = await getProfileById(profileId);
const profile = await getProfileById(profileId, projectId);
if (!profile) {
return reply.status(404).send('Not found');
}
@@ -107,6 +109,7 @@ export async function decrementProfileProperty(
id: profile.id,
projectId,
properties: profile.properties,
isExternal: true,
});
reply.status(202).send(profile.id);

View File

@@ -6,6 +6,7 @@ import { Tooltiper } from '@/components/ui/tooltip';
import { useAppParams } from '@/hooks/useAppParams';
import { useNumber } from '@/hooks/useNumerFormatter';
import { cn } from '@/utils/cn';
import { getProfileName } from '@/utils/getters';
import Link from 'next/link';
import type {
@@ -96,10 +97,7 @@ export function EventListItem(props: EventListItemProps) {
</div>
</div>
<div className="flex gap-4">
<Tooltiper
asChild
content={`${profile?.firstName} ${profile?.lastName}`}
>
<Tooltiper asChild content={getProfileName(profile)}>
<Link
prefetch={false}
onClick={(e) => {
@@ -108,7 +106,7 @@ export function EventListItem(props: EventListItemProps) {
href={`/${organizationSlug}/${projectId}/profiles/${profile?.id}`}
className="max-w-[80px] overflow-hidden text-ellipsis whitespace-nowrap text-sm text-muted-foreground hover:underline"
>
{profile?.firstName} {profile?.lastName}
{getProfileName(profile)}
</Link>
</Tooltiper>

View File

@@ -58,7 +58,7 @@ export default async function Page({
const startDate = parseAsString.parseServerSide(searchParams.startDate);
const endDate = parseAsString.parseServerSide(searchParams.endDate);
const [profile, events, count, conversions] = await Promise.all([
getProfileById(profileId),
getProfileById(profileId, projectId),
getEventList(eventListOptions),
getEventsCount(eventListOptions),
getConversionEventNames(projectId),

View File

@@ -1,6 +1,15 @@
import type { IServiceProfile } from '@openpanel/db';
export function getProfileName(profile: IServiceProfile | undefined | null) {
if (!profile) return 'No name';
return [profile.firstName, profile.lastName].filter(Boolean).join(' ');
if (!profile) return 'Unknown';
if (!profile.isExternal) {
return profile.id;
}
return (
[profile.firstName, profile.lastName].filter(Boolean).join(' ') ||
profile.email ||
profile.id
);
}