Skip to main content

userDidStartWatchingEvent

Indicates that a user has started watching an event and initializes the event view model.

Overview

When a user starts watching an event, call this method to initialize the necessary components for the Maestro panel and interactive features. This method creates a new event view model and establishes the connection between the SDK and your application's event delegate.

Method Signature

userDidStartWatchingEvent(config: SDKEventConfigParams): Promise<IMaestroEvent>;

Parameters

ParameterTypeDescription
configSDKEventConfigParamsA config object containing the necessary fields to properly initialize the event view model

SDKEventConfigParams Interface

export type SDKEventConfigParams = {
/**
* The instance of the app's implementation of IMaestroEventDelegate
*/
delegate: IMaestroEventDelegate;
/**
* The page ID to use to load the page configuration.
*/
pageId?: string;
/**
* User settings for customizing SDK behavior (panel visibility, feature toggles, etc.)
*/
userSettings?: IUserSettings;
/**
* Event ID as metadata value to use to load the page configuration.
* For cases where a page ID is unknown, you can load the config from a specific page metadata value.
*/
eventId?: string;
/**
* @description - Indicates whether to use the production environment for this event.
* @default true
*/
useProdEnv?: boolean;
};

See IMaestroEventDelegate

Return Value

A Promise that resolves to an IMaestroEvent instance, which provides methods for interacting with the current event.

Example

const Sidebar = () => {
useEffect(() => {
startWatchingEvent();
}, []);

// Start watching an event
async function startWatchingEvent() {
// Your IMaestroEventDelegate implementation
const delegate = new MyEventDelegate();

try {
// Initialize the event in the SDK
const event = await SDK.userDidStartWatchingEvent({
pageId: 'YOUR_PAGE_ID',
delegate,
});
} catch (error) {
console.error("Failed to start watching event:", error);
}
}

return <div id="panel" />;
};

Notes

  • The SDK must be configured with configure() before calling this method.
  • Try to call this method as soon as you have the necessary data.