Skip to content
Open
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
6 changes: 5 additions & 1 deletion app/screens/route-details/route-details-screen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { calculateDelayedTime } from "../../utils/helpers/date-helpers"
import { useSafeAreaInsets } from "react-native-safe-area-context"
import { isLiquidGlassSupported, LiquidGlassView } from "@callstack/liquid-glass"
import { translate } from "../../i18n"
import { trackEvent } from "../../services/analytics"

const ROOT: ViewStyle = {
flex: 1,
Expand Down Expand Up @@ -312,7 +313,10 @@ export function RouteDetailsScreen({ route, navigation }: RouteDetailsScreenProp
>
{hasWagonData && (
<Pressable
onPress={() => navigation.navigate("routeDetailsTrainInfo", { train: routeItem.trains[0] })}
onPress={() => {
trackEvent("train_info_sheet_opened")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To improve maintainability and prevent typos, consider defining analytics event names as constants in a central location instead of using raw strings.

For example, you could create a constants file:

// app/services/analytics/events.ts
export const ANALYTICS_EVENTS = {
  TRAIN_INFO_SHEET_OPENED: "train_info_sheet_opened",
} as const;

And then use it in your component:

// app/screens/route-details/route-details-screen.tsx
import { ANALYTICS_EVENTS } from "../../services/analytics/events";
// ...
trackEvent(ANALYTICS_EVENTS.TRAIN_INFO_SHEET_OPENED);

This approach makes event names reusable, discoverable, and safer to use across the codebase.

navigation.navigate("routeDetailsTrainInfo", { train: routeItem.trains[0] })
}}
accessibilityLabel={translate("routeDetails.trainInformation")}
>
<LiquidGlassView
Expand Down
Loading