getCurrentEventID
Returns the active event ID(s) for the current session.
The return type of getCurrentEventID changed from string | null to string | string[] | null. In a multi-event session, this method returns all active event IDs as string[] rather than a single string.
Update any code that assumes the return value is always a string. Use a type guard (Array.isArray(result)) or switch to getCurrentEventIDs, which always returns string[] and is the preferred API for multi-event sessions.
Overview
Use this method to retrieve the event ID(s) for the current session.
- Single-event session — returns the event ID as a
string. - Multi-event session — returns all active event IDs as
string[], in the same order they were passed touserDidStartWatchingEvent. - No active session — returns
null.
For multi-event sessions, getCurrentEventIDs is equivalent and often clearer because it always returns string[].
Method Signature
getCurrentEventID(): string | string[] | null;
Parameters
This method takes no parameters.
Return Value
The active event ID(s) for the current session, or null if no session is active.
| State | Return value |
|---|---|
| Single-event session | string — the active event ID |
| Multi-event session | string[] — all active event IDs |
| No active session | null |
Example
const eventId = SDK.getMaestroEventViewModel().getCurrentEventID();
if (eventId === null) {
console.log('No active session.');
} else if (Array.isArray(eventId)) {
// Multi-event session
console.log('Active event IDs:', eventId);
} else {
// Single-event session
console.log('Active event ID:', eventId);
}
Notes
- Use
getCurrentEventIDswhen you always need an array — it returnsstring[]in both single- and multi-event sessions. - The return type is
string | string[] | nullrather than alwaysstring[]for backward compatibility.