Function: getMonitorDisplayIdentifier()
getMonitorDisplayIdentifier(
monitor
:Monitor
,siteFallback
:string
):string
Defined in: src/utils/fallbacks.ts:287
Generate display identifier for a monitor dynamically. Replaces hardcoded backward compatibility patterns.
Parametersโ
monitorโ
Monitor object
siteFallbackโ
string
Fallback site identifier
Returnsโ
string
Display identifier string
Remarksโ
This function uses a configuration-driven approach to support new monitor types without requiring code changes. To add support for a new monitor type:
- Add an entry to MONITOR_IDENTIFIER_GENERATORS with a function that extracts the identifier 2. The function will automatically use the new generator
Exampleโ
// HTTP monitor
getMonitorDisplayIdentifier(
{ type: "http", url: "https://example.com" },
"Site"
);
// Returns: "https://example.com"
// Port monitor
getMonitorDisplayIdentifier(
{ type: "port", host: "example.com", port: 80 },
"Site"
);
// Returns: "example.com:80"
// Unknown type
getMonitorDisplayIdentifier({ type: "unknown" }, "My Site");
// Returns: "My Site"