🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.
fix(events): don't pass display labels to t() (#1088)
Alex Duggleby86a550759a6b
diff --git a/client/src/app/[site]/events/components/EventLog/EventDetailsSheet.tsx b/client/src/app/[site]/events/components/EventLog/EventDetailsSheet.tsxindex 9d8e920b7..32d59bccf 100644--- a/client/src/app/[site]/events/components/EventLog/EventDetailsSheet.tsx+++ b/client/src/app/[site]/events/components/EventLog/EventDetailsSheet.tsx@@ -61,7 +61,7 @@ export function EventDetailsSheet({ open, onOpenChange, event, site }: EventDeta<SheetTitle><div className="flex items-center gap-2"><EventTypeIcon type={event?.type || ""} className="w-5 h-5" />- <span className="font-medium">{getEventTypeLabel(event?.type || "", t)}</span>+ <span className="font-medium">{getEventTypeLabel(event?.type || "")}</span></div></SheetTitle></SheetHeader>diff --git a/client/src/app/[site]/events/components/EventLog/EventRow.tsx b/client/src/app/[site]/events/components/EventLog/EventRow.tsxindex 9d6db72d6..877947f7c 100644--- a/client/src/app/[site]/events/components/EventLog/EventRow.tsx+++ b/client/src/app/[site]/events/components/EventLog/EventRow.tsx@@ -34,7 +34,7 @@ export function EventRow({ event, site, onClick }: EventRowProps) {const pagePath = buildEventPath(event);const pageUrl = `https://${event.hostname}${pagePath}`;const isPageview = event.type === "pageview";- const eventData = isPageview ? null : getMainData(event, eventProperties, getEventDisplayName, t);+ const eventData = isPageview ? null : getMainData(event, eventProperties, getEventDisplayName);const userProfileId = event.identified_user_id || event.user_id;const displayName = getUserDisplayName({identified_user_id: event.identified_user_id || undefined,@@ -55,7 +55,7 @@ export function EventRow({ event, site, onClick }: EventRowProps) {</div></TooltipTrigger><TooltipContent>- <span>{getEventTypeLabel(event.type, t)}</span>+ <span>{getEventTypeLabel(event.type)}</span></TooltipContent></Tooltip></div>diff --git a/client/src/app/[site]/events/components/EventLog/eventLogUtils.tsx b/client/src/app/[site]/events/components/EventLog/eventLogUtils.tsxindex f9eb9cd15..8e2269c05 100644--- a/client/src/app/[site]/events/components/EventLog/eventLogUtils.tsx+++ b/client/src/app/[site]/events/components/EventLog/eventLogUtils.tsx@@ -1,7 +1,7 @@"use client";import { Event } from "../../../../../api/analytics/endpoints";-import { EVENT_TYPE_CONFIG, EventDisplayNameFormatter, TranslationFunction } from "../../../../../lib/events";+import { EVENT_TYPE_CONFIG, EventDisplayNameFormatter } from "../../../../../lib/events";export function getEventKey(event: Event) {return `${event.timestamp}-${event.session_id}-${event.user_id}-${event.type}-${event.event_name ?? ""}-${event.pathname}`;@@ -18,9 +18,11 @@ export function parseEventProperties(event: Event): Record<string, any> {return {};}-export function getEventTypeLabel(type: string, t?: TranslationFunction) {- const label = EVENT_TYPE_CONFIG.find(item => item.value === type)?.label ?? "Event";- return t ? t(label) : label;+// EVENT_TYPE_CONFIG labels are display strings ("Pageview", "Input Change"), not+// message keys, so they must not be passed to t() — doing so throws MISSING_MESSAGE+// and breaks the events page. Return them as-is.+export function getEventTypeLabel(type: string) {+ return EVENT_TYPE_CONFIG.find(item => item.value === type)?.label ?? "Event";}export function buildEventPath(event: Event) {@@ -30,8 +32,7 @@ export function buildEventPath(event: Event) {export function getMainData(event: Event,props: Record<string, any>,- getEventDisplayName: EventDisplayNameFormatter,- t?: TranslationFunction+ getEventDisplayName: EventDisplayNameFormatter) {const isPageview = event.type === "pageview";const isOutbound = event.type === "outbound";@@ -61,6 +62,6 @@ export function getMainData(}return {- label: event.event_name || (t ? t("Event") : "Event"),+ label: event.event_name || "Event",};}